Skip to content

Commit 2b69a12

Browse files
committed
feat: add semi-broken webawesome (shoelace) ui set
It's not fully migrated yet, either for the new API and the old JSX to literal implementation (2024). Will skip directly to the 2025 impl.
1 parent 83b2fb4 commit 2b69a12

38 files changed

+1491
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { JsonSchemaFormWebawesome } from './form.js';
2+
3+
JsonSchemaFormWebawesome.define();

packages/webawesome/src/form.ts

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
import { Form, JsonSchemaFormElement, WidgetTree } from '@jsfe/generics/form';
2+
import { html } from '@lit-labs/signals';
3+
import { css, unsafeCSS } from 'lit';
4+
5+
// import { styles } from './styles.js';
6+
import * as widgets from './widgets/index.js';
7+
8+
// import styles from '@jsfe/webawesome/css?inline';
9+
10+
export class JsonSchemaFormWebawesome extends JsonSchemaFormElement {
11+
// static styles = [
12+
// // unsafeCSS(styles),
13+
// // To be populated by user
14+
// /* styles */
15+
// css`
16+
// * {
17+
// display: none;
18+
// /* */
19+
// }
20+
// `,
21+
// ];
22+
23+
static readonly tagName = 'jsf-webawesome';
24+
25+
widgets = widgets;
26+
27+
render() {
28+
// return html`hello`;
29+
30+
// console.log(this.schema);
31+
32+
if (!this.form) return html`No form`;
33+
34+
return html`
35+
FORM WA
36+
<details>
37+
<pre>${JSON.stringify(this.schema, null, 2)}</pre>
38+
<pre>${JSON.stringify(this.form.rootField, null, 2)}</pre>
39+
</details>
40+
41+
${Form({
42+
children: html`
43+
<!-- -->
44+
${WidgetTree({
45+
rootField: this.form.rootField,
46+
widgets: this.widgets,
47+
})}
48+
49+
<!-- -->
50+
${this.widgets.Submit({})}
51+
52+
<!-- -->
53+
`,
54+
form: this.form,
55+
})}
56+
57+
<!-- -->
58+
`;
59+
}
60+
}
61+
62+
// /* eslint-disable max-classes-per-file */
63+
// // import { Jsf } from '@jsfe/engine';
64+
// import * as widgets from './widgets/index.js';
65+
// import { styles } from './styles.js';
66+
// import { customElement, property } from 'lit/decorators.js';
67+
// import { html, LitElement, type TemplateResult } from 'lit';
68+
// import { JSONSchemaForm } from '@jsfe/engine';
69+
// import type { Field } from '@jsfe/engine/core/src/exp-types.js';
70+
71+
// // export class JsfFormWa extends Jsf {
72+
// // public widgets = widgets;
73+
74+
// // public styleSheets = [styles];
75+
// // }
76+
77+
// // @customElement('jsfe-form-wa')
78+
// export class JsfeFormWa extends LitElement {
79+
// @property({ type: Object }) form: JSONSchemaForm = new JSONSchemaForm({});
80+
81+
// public static Field(field: Field): TemplateResult | TemplateResult[] {
82+
// const widgetType = field.widget;
83+
// console.log({ widgetType });
84+
85+
// if (widgetType && widgetType in widgets) {
86+
// let children = undefined;
87+
// if (field.children)
88+
// children =
89+
// field.children?.map((child) => JsfeFormWa.Field(child)) ?? [];
90+
// const fieldContent =
91+
// widgetType && widgets[widgetType]?.({ ...field, children });
92+
93+
// return html`
94+
// <slot name=${field.html?.name || '_'}>${fieldContent} </slot>
95+
// `;
96+
// }
97+
98+
// return html`Missing ${widgetType}`;
99+
// }
100+
101+
// render() {
102+
// // ${JSON.stringify(this.form.fields)}
103+
// return html`
104+
// FORM WA
105+
// <form
106+
// @submit=${(event: SubmitEvent) => {
107+
// console.log(event);
108+
109+
// const { json } = this.form.handleFormSubmit(event);
110+
// console.log({ json });
111+
// }}
112+
// @input=${(event: InputEvent) => this.form.handleFormEvent(event)}
113+
// @change=${(event: InputEvent) => this.form.handleFormEvent(event)}
114+
// >
115+
// ${JsfeFormWa.Field(this.form.root)}
116+
117+
// <button type="submit">OK</button>
118+
// </form>
119+
// <!-- -->
120+
// `;
121+
// // ${this.form.field['CustomWidgets.MyCustomWidgetBigButton'].type}
122+
// }
123+
124+
// static styles = [];
125+
// }
126+
127+
declare global {
128+
interface HTMLElementTagNameMap {
129+
'jsf-webawesome': JsonSchemaFormWebawesome;
130+
}
131+
}

packages/webawesome/src/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export { JsonSchemaFormWebawesome } from './form.js';
2+
3+
export * as widgets from './widgets/index.js';
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
@import './widgets/_all';
2+
@import './widgets/_fieldset';
3+
@import './widgets/array';
4+
@import './widgets/callout';
5+
@import './widgets/checkbox-group';
6+
@import './widgets/checkbox';
7+
@import './widgets/color-picker';
8+
@import './widgets/object';
9+
@import './widgets/radio-group-boolean';
10+
@import './widgets/radio-group';
11+
@import './widgets/rating';
12+
@import './widgets/submit';

0 commit comments

Comments
 (0)