Skip to content

Commit 9a33cbb

Browse files
committed
fix: better styles, material export
1 parent 6991c7a commit 9a33cbb

37 files changed

+426
-65
lines changed

packages/carbon/README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
# JSON Schema Form Element — ***Carbon*** edition
22

3-
See the [documentation](../../README.md).
3+
```sh
4+
npm install @jsfe/carbon
5+
```
6+
7+
Consult the [documentation](../../README.md).
8+
Open the [playground](https://jsfe.js.org).
49

510
---
611

packages/carbon/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,15 @@
2929
"exports": {
3030
".": "./dist/esm/index.js",
3131
"./scss": "./src/styles.scss",
32+
"./scss/*": "./src/widgets/*.scss",
3233
"./css": "./dist/esm/styles.css",
3334
"./jss": "./dist/esm/styles.js",
3435
"./min": "./dist/esm-min"
3536
},
3637
"files": [
3738
"./dist/esm",
3839
"./dist/esm-min",
39-
"./src/styles.scss",
40+
"./src/**/*.scss",
4041
"./vscode.html-custom-data.json",
4142
"./vscode.css-custom-data.json",
4243
"./custom-elements.json"

packages/form/README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1-
# JSON Schema Form Element — ***Form*** edition
1+
# JSON Schema Form Element — ***Barebone*** edition
22

3-
See the [documentation](../../README.md).
3+
```sh
4+
npm install @jsfe/form
5+
```
6+
7+
Consult the [documentation](../../README.md).
8+
Open the [playground](https://jsfe.js.org).
49

510
---
611

packages/form/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,15 @@
2727
"exports": {
2828
".": "./dist/esm/index.js",
2929
"./scss": "./src/styles.scss",
30+
"./scss/*": "./src/widgets/*.scss",
3031
"./css": "./dist/esm/styles.css",
3132
"./jss": "./dist/esm/styles.js",
3233
"./min": "./dist/esm-min"
3334
},
3435
"files": [
3536
"./dist/esm",
3637
"./dist/esm-min",
37-
"./src/styles.scss",
38+
"./src/**/*.scss",
3839
"./vscode.html-custom-data.json",
3940
"./vscode.css-custom-data.json",
4041
"./custom-elements.json"

packages/form/src/json-schema-form.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ export class Jsf extends LitElement {
6060
uiSchema: UiSchema,
6161
schemaPath: Path,
6262
required = false,
63+
level = 0,
6364
): TemplateResult<1> => {
6465
let result: TemplateResult<1> | undefined;
6566
const currentNode: JSONSchema7 = node;
@@ -151,6 +152,7 @@ export class Jsf extends LitElement {
151152
this._dig.bind(this),
152153
schemaPathAugmented,
153154
this.widgets,
155+
level,
154156
);
155157
}
156158

@@ -178,6 +180,7 @@ export class Jsf extends LitElement {
178180
// this._handleKeydown.bind(this),
179181
schemaPathAugmented,
180182
this.widgets,
183+
level,
181184
);
182185
}
183186

@@ -206,6 +209,7 @@ export class Jsf extends LitElement {
206209
this._dig.bind(this),
207210
schemaPathAugmented,
208211
this.widgets,
212+
level,
209213
);
210214

211215
/* --- Additionals Array items --- */
@@ -266,6 +270,8 @@ export class Jsf extends LitElement {
266270
this._dig.bind(this),
267271
schemaPathAugmented,
268272
this.widgets,
273+
required,
274+
level,
269275
);
270276
}
271277
}

packages/form/src/triage/array-primitive.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export const fieldArrayPrimitive = (
1414
// dig: Jsf['_dig'],
1515
schemaPath: Path,
1616
widgets: Widgets,
17+
level = 0,
1718
) => {
1819
// if (!Array.isArray(dataLevel)) return html``;
1920

@@ -62,6 +63,8 @@ export const fieldArrayPrimitive = (
6263

6364
// itemsLabel,
6465

66+
level,
67+
6568
id,
6669
// required,
6770
valueChangedCallback,

packages/form/src/triage/array.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ export const fieldArray = (
1616
dig: Jsf['_dig'],
1717
schemaPath: Path,
1818
widgets: Widgets,
19+
required = false,
20+
level = 0,
1921
) => {
2022
if (!Array.isArray(dataLevel)) return html``;
2123

@@ -60,6 +62,8 @@ export const fieldArray = (
6062
uiState,
6163
uiSchema,
6264
schemaPathAugmented,
65+
required,
66+
level + 1,
6367
);
6468

6569
const move = (direction: number) => (_event: Event) => {
@@ -168,6 +172,8 @@ export const fieldArray = (
168172
controls: {
169173
add: { click: addItemClick },
170174
},
175+
176+
level,
171177
};
172178

173179
return widgets?.array?.(options);

packages/form/src/triage/object.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export const fieldObject = (
1111
dig: Jsf['_dig'],
1212
schemaPath: Path,
1313
widgets: Widgets,
14+
level = 0,
1415
) => {
1516
const error = 'Wrong object field';
1617
if (typeof schema.properties !== 'object')
@@ -44,6 +45,7 @@ export const fieldObject = (
4445
uiSchema?.[propName],
4546
schemaPathAugmented,
4647
required,
48+
level + 1,
4749
);
4850
},
4951
);
@@ -60,6 +62,7 @@ export const fieldObject = (
6062
label,
6163
helpText: schema.description,
6264
children,
65+
level,
6366
};
6467

6568
return (

packages/form/src/triage/primitive.ts

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,20 @@ export const fieldPrimitive = (
134134
}
135135

136136
if (schema.type === 'string') {
137+
let inputType = 'text';
138+
if (schema.format === 'password' || schema.format === 'email') {
139+
inputType = schema.format;
140+
}
141+
142+
if (uiOptions?.['ui:options']?.inputType === 'tel') {
143+
inputType = 'tel';
144+
}
137145
const options = {
138146
...baseOptions,
139147
value: baseValue ? String(baseValue) : '',
140148

149+
inputType,
150+
141151
minLength: schema.minLength,
142152
maxLength: schema.maxLength,
143153
pattern: schema.pattern,
@@ -146,6 +156,10 @@ export const fieldPrimitive = (
146156
if (uiOptions?.['ui:widget'] === 'textarea') {
147157
return widgets?.textarea?.(options) || missing('textarea');
148158
}
159+
if (typeof uiOptions?.['ui:widget'] === 'string') {
160+
const customWidgetName = uiOptions?.['ui:widget'];
161+
return widgets?.[customWidgetName]?.(options) || missing('custom');
162+
}
149163

150164
return widgets?.text?.(options) || missing('text');
151165
}
@@ -205,3 +219,36 @@ export const fieldPrimitive = (
205219

206220
return missing(`Wrong input for: ${path.join('/')}`);
207221
};
222+
223+
/*
224+
225+
AJV-Formats
226+
https://ajv.js.org/packages/ajv-formats.html
227+
228+
date: full-date according to RFC3339 (opens new window).
229+
time: time (time-zone is mandatory).
230+
date-time: date-time (time-zone is mandatory).
231+
iso-time: time with optional time-zone.
232+
iso-date-time: date-time with optional time-zone.
233+
duration: duration from RFC3339(opens new window)
234+
uri: full URI.
235+
uri-reference: URI reference, including full and relative URIs.
236+
uri-template: URI template according to RFC6570(opens new window)
237+
url (deprecated): URL record (opens new window).
238+
email: email address.
239+
hostname: host name according to RFC1034 (opens new window).
240+
ipv4: IP address v4.
241+
ipv6: IP address v6.
242+
regex: tests whether a string is a valid regular expression by passing it to RegExp constructor.
243+
uuid: Universally Unique IDentifier according to RFC4122 (opens new window).
244+
json-pointer: JSON-pointer according to RFC6901 (opens new window).
245+
relative-json-pointer: relative JSON-pointer according to this draft (opens new window).
246+
byte: base64 encoded data according to the openApi 3.0.0 specification(opens new window)
247+
int32: signed 32 bits integer according to the openApi 3.0.0 specification(opens new window)
248+
int64: signed 64 bits according to the openApi 3.0.0 specification(opens new window)
249+
float: float according to the openApi 3.0.0 specification(opens new window)
250+
double: double according to the openApi 3.0.0 specification(opens new window)
251+
password: password string according to the openApi 3.0.0 specification(opens new window)
252+
binary: binary string according to the openApi 3.0.0 specification
253+
254+
*/

packages/material/README.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
# JSON Schema Form Element — ***Material*** edition
22

3-
See the [documentation](../../README.md).
3+
```sh
4+
npm install @jsfe/material
5+
```
6+
7+
Consult the [documentation](../../README.md).
8+
Open the [playground](https://jsfe.js.org).
49

510
---
611

@@ -24,10 +29,10 @@ See the [documentation](../../README.md).
2429

2530
### Fields
2631

27-
| Name | Privacy | Type | Default | Description | Inherited From |
28-
| -------------------- | ------- | ------- | ---------- | ----------- | -------------- |
29-
| `dataChangeCallback` | public | | `widgets` | | |
30-
| `styleSheets` | public | `array` | `[styles]` | | |
32+
| Name | Privacy | Type | Default | Description | Inherited From |
33+
| ------------- | ------- | ------- | ---------- | ----------- | -------------- |
34+
| `widgets` | public | | `widgets` | | |
35+
| `styleSheets` | public | `array` | `[styles]` | | |
3136

3237
<hr/>
3338

0 commit comments

Comments
 (0)