diff --git a/packages/form/src/triage/array-primitive.ts b/packages/form/src/triage/array-primitive.ts
index 4a279b9..29e7707 100644
--- a/packages/form/src/triage/array-primitive.ts
+++ b/packages/form/src/triage/array-primitive.ts
@@ -54,6 +54,8 @@ export const fieldArrayPrimitive = (
handleChange(path, enumValue, schemaPathAugmented);
};
+ const disabled = uiOptions?.['ui:disabled'] || false;
+
const options = {
label: schema.title,
helpText,
@@ -61,6 +63,8 @@ export const fieldArrayPrimitive = (
value: dataLevel ?? schema?.default,
enum: items.enum,
+ disabled,
+
// itemsLabel,
level,
diff --git a/packages/form/src/triage/array.ts b/packages/form/src/triage/array.ts
index 13a6496..91ac8b0 100644
--- a/packages/form/src/triage/array.ts
+++ b/packages/form/src/triage/array.ts
@@ -11,7 +11,7 @@ export const fieldArray = (
dataLevel: unknown,
path: Path,
uiState: unknown,
- uiSchema: UiSchema,
+ uiOptions: UiSchema,
handleChange: Jsf['_handleChange'],
dig: Jsf['_dig'],
schemaPath: Path,
@@ -60,7 +60,7 @@ export const fieldArray = (
dataLevel[index],
[...path, index],
uiState,
- uiSchema?.[index],
+ uiOptions?.[index],
schemaPathAugmented,
required,
level + 1,
@@ -162,7 +162,7 @@ export const fieldArray = (
) {
itemLabel = schema.items.title;
}
- const arrayLabel = schema.title ?? uiSchema?.['ui:title'];
+ const arrayLabel = schema.title ?? uiOptions?.['ui:title'];
const options = {
label: arrayLabel,
diff --git a/packages/form/src/triage/primitive.ts b/packages/form/src/triage/primitive.ts
index 3079a8e..0566931 100644
--- a/packages/form/src/triage/primitive.ts
+++ b/packages/form/src/triage/primitive.ts
@@ -3,11 +3,9 @@
/* eslint-disable arrow-body-style */
/* eslint-disable max-lines */
-import type { JSONSchema7 } from '@jsfe/types';
-
import type { Jsf } from '../json-schema-form.js';
-import type { Widgets, Path, UiSchema } from '@jsfe/types';
+import type { Widgets, Path, UiSchema, JSONSchema7 } from '@jsfe/types';
import { html } from 'lit';
export const fieldPrimitive = (
@@ -46,6 +44,9 @@ export const fieldPrimitive = (
'';
const placeholder = uiOptions?.['ui:placeholder'] ?? '';
+ const disabled = uiOptions?.['ui:disabled'] || false;
+ const readonly = uiOptions?.['ui:readonly'] || false;
+
let baseValue: unknown;
if (value !== undefined) {
@@ -86,6 +87,8 @@ export const fieldPrimitive = (
handleKeydown,
id,
required,
+ disabled,
+ readonly,
};
if (
diff --git a/packages/shoelace/src/widgets/button-group-boolean.ts b/packages/shoelace/src/widgets/button-group-boolean.ts
index 696b0cd..3db36b1 100644
--- a/packages/shoelace/src/widgets/button-group-boolean.ts
+++ b/packages/shoelace/src/widgets/button-group-boolean.ts
@@ -24,10 +24,17 @@ export const buttonGroupBoolean: Widgets['buttonGroupBoolean'] = (
);
}}
>
- ${options.trueLabel ?? 'Yes'}
- ${options.falseLabel ?? 'No'}
diff --git a/packages/shoelace/src/widgets/button-group.ts b/packages/shoelace/src/widgets/button-group.ts
index f46af76..e7ff648 100644
--- a/packages/shoelace/src/widgets/button-group.ts
+++ b/packages/shoelace/src/widgets/button-group.ts
@@ -29,7 +29,12 @@ export const buttonGroup: Widgets['buttonGroup'] = (options) => html`
>
${options.enum?.map(
(enumVal) =>
- html`${enumVal}`,
)}
diff --git a/packages/shoelace/src/widgets/checkbox-group.ts b/packages/shoelace/src/widgets/checkbox-group.ts
index 6914ac2..a101ea3 100644
--- a/packages/shoelace/src/widgets/checkbox-group.ts
+++ b/packages/shoelace/src/widgets/checkbox-group.ts
@@ -41,6 +41,7 @@ export const checkboxGroup: Widgets['checkboxGroup'] = (options) => html`
options.valueChangedCallback?.(newData);
}}
+ .disabled=${options.disabled}
>${enumValue}`;
})}
diff --git a/packages/shoelace/src/widgets/checkbox.ts b/packages/shoelace/src/widgets/checkbox.ts
index ddebca4..d42635a 100644
--- a/packages/shoelace/src/widgets/checkbox.ts
+++ b/packages/shoelace/src/widgets/checkbox.ts
@@ -18,6 +18,7 @@ export const checkbox: Widgets['checkbox'] = (options) => html`
const { checked: newValue } = event.target as SlCheckbox;
options.valueChangedCallback?.(newValue);
}}
+ .disabled=${options.disabled}
>
diff --git a/packages/shoelace/src/widgets/color-picker.ts b/packages/shoelace/src/widgets/color-picker.ts
index ecd08b8..86794ba 100644
--- a/packages/shoelace/src/widgets/color-picker.ts
+++ b/packages/shoelace/src/widgets/color-picker.ts
@@ -16,6 +16,7 @@ export const colorPicker: Widgets['colorPicker'] = (options) => html`
options.valueChangedCallback?.(newValue);
}}
+ .disabled=${options.disabled}
>
${options.helpText}
diff --git a/packages/shoelace/src/widgets/date.ts b/packages/shoelace/src/widgets/date.ts
index b4189f7..9b65e54 100644
--- a/packages/shoelace/src/widgets/date.ts
+++ b/packages/shoelace/src/widgets/date.ts
@@ -28,6 +28,8 @@ export const date: Widgets['date'] = (options) => html`
value,
);
}}
+ .disabled=${options.disabled}
+ .readonly=${options.readonly}
>
`;
diff --git a/packages/shoelace/src/widgets/number.ts b/packages/shoelace/src/widgets/number.ts
index e14a9ea..b717fbb 100644
--- a/packages/shoelace/src/widgets/number.ts
+++ b/packages/shoelace/src/widgets/number.ts
@@ -25,4 +25,6 @@ export const number: Widgets['number'] = (options) =>
console.log(newValue);
options.valueChangedCallback?.(newValue);
}}
+ .disabled=${options.disabled}
+ .readonly=${options.readonly}
>`;
diff --git a/packages/shoelace/src/widgets/radio-group-boolean.ts b/packages/shoelace/src/widgets/radio-group-boolean.ts
index e228f7c..f7d82d9 100644
--- a/packages/shoelace/src/widgets/radio-group-boolean.ts
+++ b/packages/shoelace/src/widgets/radio-group-boolean.ts
@@ -10,6 +10,7 @@ import type { SlRadioGroup } from '@shoelace-style/shoelace';
export const radioGroupBoolean: Widgets['radioGroupBoolean'] = (
options,
) => html`
+
- ${options.trueLabel ?? 'Yes'}
- ${options.falseLabel ?? 'No'}
+ ${options.trueLabel ?? 'Yes'}
+ ${options.falseLabel ?? 'No'}
`;
diff --git a/packages/shoelace/src/widgets/radio-group.ts b/packages/shoelace/src/widgets/radio-group.ts
index 81e09e4..8195ed1 100644
--- a/packages/shoelace/src/widgets/radio-group.ts
+++ b/packages/shoelace/src/widgets/radio-group.ts
@@ -30,7 +30,9 @@ export const radioGroup: Widgets['radioGroup'] = (options) => html`
>
${options.enum?.map(
(enumVal) =>
- html`${enumVal}`,
+ html`${enumVal}`,
)}
`;
diff --git a/packages/shoelace/src/widgets/range.ts b/packages/shoelace/src/widgets/range.ts
index fca58eb..97d3771 100644
--- a/packages/shoelace/src/widgets/range.ts
+++ b/packages/shoelace/src/widgets/range.ts
@@ -24,4 +24,5 @@ export const range: Widgets['number'] = (options) =>
console.log(newValue);
options.valueChangedCallback?.(newValue);
}}
+ .disabled=${options.disabled}
>`;
diff --git a/packages/shoelace/src/widgets/rating.ts b/packages/shoelace/src/widgets/rating.ts
index 6bee7c3..6524bfc 100644
--- a/packages/shoelace/src/widgets/rating.ts
+++ b/packages/shoelace/src/widgets/rating.ts
@@ -28,5 +28,7 @@ export const rating: Widgets['number'] = (options) =>
console.log(newValue);
options.valueChangedCallback?.(newValue);
}}
+ .disabled=${options.disabled}
+ .readonly=${options.readonly}
>
`;
diff --git a/packages/shoelace/src/widgets/select-multiple.ts b/packages/shoelace/src/widgets/select-multiple.ts
index aeae0aa..94e6a5b 100644
--- a/packages/shoelace/src/widgets/select-multiple.ts
+++ b/packages/shoelace/src/widgets/select-multiple.ts
@@ -7,13 +7,14 @@ import type { SlSelect, SlSelectEvent } from '@shoelace-style/shoelace';
export const selectMultiple: Widgets['selectMultiple'] = (options) => html`
{
const { value } = event.target as SlSelect;
diff --git a/packages/shoelace/src/widgets/select.ts b/packages/shoelace/src/widgets/select.ts
index a3c400e..5a1a239 100644
--- a/packages/shoelace/src/widgets/select.ts
+++ b/packages/shoelace/src/widgets/select.ts
@@ -7,8 +7,6 @@ import '@shoelace-style/shoelace/dist/components/select/select.js';
import '@shoelace-style/shoelace/dist/components/option/option.js';
import type { SlSelect } from '@shoelace-style/shoelace';
-// .label=${options.label}
-// .helpText=${options.helpText}
export const select: Widgets['select'] = (options) => html`
html`
}
options.valueChangedCallback?.(newValue);
}}
+ .disabled=${options.disabled}
+ label=${ifDefined(options.label)}
+ .helpText=${options.helpText ?? ''}
>${options.enum?.map(
(enumValue) =>
html`
diff --git a/packages/shoelace/src/widgets/switch.ts b/packages/shoelace/src/widgets/switch.ts
index a3871db..78dbf6c 100644
--- a/packages/shoelace/src/widgets/switch.ts
+++ b/packages/shoelace/src/widgets/switch.ts
@@ -17,6 +17,7 @@ export const switchh: Widgets['switch'] = (options) => html`
const { checked: newValue } = event.target as SlSwitch;
options.valueChangedCallback?.(newValue);
}}
+ .disabled=${options.disabled}
>${options.label}
${options.helpText
? html` - ${options.helpText}`
diff --git a/packages/shoelace/src/widgets/text.ts b/packages/shoelace/src/widgets/text.ts
index 7d5f234..0e63560 100644
--- a/packages/shoelace/src/widgets/text.ts
+++ b/packages/shoelace/src/widgets/text.ts
@@ -24,6 +24,8 @@ export const text: Widgets['text'] = (options) => html`
const { value: newValue } = event.target as SlInput;
options.valueChangedCallback?.(newValue);
}}
+ .disabled=${options.disabled}
+ .readonly=${options.readonly}
>
`;
diff --git a/packages/shoelace/src/widgets/textarea.ts b/packages/shoelace/src/widgets/textarea.ts
index fc3460f..d4cbac7 100644
--- a/packages/shoelace/src/widgets/textarea.ts
+++ b/packages/shoelace/src/widgets/textarea.ts
@@ -22,6 +22,8 @@ export const textarea: Widgets['textarea'] = (options) => html`
const { value: newValue } = event.target as SlTextarea;
options.valueChangedCallback?.(newValue);
}}
+ .disabled=${options.disabled}
+ .readonly=${options.readonly}
>
`;
diff --git a/packages/types/src/ui-schema.ts b/packages/types/src/ui-schema.ts
index 3ca31af..d046ae1 100644
--- a/packages/types/src/ui-schema.ts
+++ b/packages/types/src/ui-schema.ts
@@ -5,6 +5,9 @@ export type UiOptions = {
'ui:title'?: string;
'ui:description'?: string;
+ 'ui:disabled'?: boolean;
+ 'ui:readonly'?: boolean;
+
'ui:widget'?:
| 'radio'
| 'button'