@abgov/jsonforms-components 2.58.2 → 2.58.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.esm.js +54 -0
- package/package.json +1 -1
- package/renderer-catalog.json +2 -2
package/index.esm.js
CHANGED
|
@@ -12314,17 +12314,67 @@ const PrimitiveArrayControl = props => {
|
|
|
12314
12314
|
const addItem = () => {
|
|
12315
12315
|
handleChange(path, [...items, '']);
|
|
12316
12316
|
};
|
|
12317
|
+
const getOptionValue = option => typeof option === 'string' ? option : option.const;
|
|
12318
|
+
const getOptionLabel = option => typeof option === 'string' ? option : option.title || option.const;
|
|
12319
|
+
const getOptionDescription = option => typeof option === 'string' ? undefined : option.description;
|
|
12317
12320
|
const removeItem = index => {
|
|
12318
12321
|
const copy = [...items];
|
|
12319
12322
|
copy.splice(index, 1);
|
|
12320
12323
|
handleChange(path, copy);
|
|
12321
12324
|
};
|
|
12325
|
+
const getPrimitiveArrayOptions = schema => {
|
|
12326
|
+
const itemSchema = schema == null ? void 0 : schema.items;
|
|
12327
|
+
if (Array.isArray(itemSchema == null ? void 0 : itemSchema.oneOf)) {
|
|
12328
|
+
return itemSchema.oneOf;
|
|
12329
|
+
}
|
|
12330
|
+
if (Array.isArray(itemSchema == null ? void 0 : itemSchema.enum)) {
|
|
12331
|
+
return itemSchema.enum;
|
|
12332
|
+
}
|
|
12333
|
+
return [];
|
|
12334
|
+
};
|
|
12322
12335
|
const itemUiSchema = Object.assign({}, uischema, {
|
|
12323
12336
|
scope: '#'
|
|
12324
12337
|
});
|
|
12338
|
+
const options = uischema.options || {};
|
|
12325
12339
|
const label = (uischema == null ? void 0 : uischema.label) || (schema == null ? void 0 : schema.title) || 'Item';
|
|
12326
12340
|
const arrayLabel = getLabelText(uischema.scope, label);
|
|
12327
12341
|
const prettyLabel = pluralize.singular(arrayLabel.charAt(0).toLocaleUpperCase() + arrayLabel.slice(1));
|
|
12342
|
+
if (options.format === 'checkboxes') {
|
|
12343
|
+
const checkboxOptions = getPrimitiveArrayOptions(schema);
|
|
12344
|
+
return jsxs(Visible, {
|
|
12345
|
+
visible: visible,
|
|
12346
|
+
children: [jsx("h4", {
|
|
12347
|
+
children: prettyLabel
|
|
12348
|
+
}), jsx("div", {
|
|
12349
|
+
children: checkboxOptions.map(option => {
|
|
12350
|
+
const value = getOptionValue(option);
|
|
12351
|
+
const text = getOptionLabel(option);
|
|
12352
|
+
const description = getOptionDescription(option);
|
|
12353
|
+
const checked = items.includes(value);
|
|
12354
|
+
return jsx(GoabCheckbox, {
|
|
12355
|
+
name: value,
|
|
12356
|
+
value: value,
|
|
12357
|
+
text: text,
|
|
12358
|
+
description: description,
|
|
12359
|
+
checked: checked,
|
|
12360
|
+
disabled: !enabled,
|
|
12361
|
+
testId: `${value}-checkbox`,
|
|
12362
|
+
onChange: detail => {
|
|
12363
|
+
let newValue = [...items];
|
|
12364
|
+
if (detail.value) {
|
|
12365
|
+
if (!newValue.includes(value)) {
|
|
12366
|
+
newValue.push(value);
|
|
12367
|
+
}
|
|
12368
|
+
} else {
|
|
12369
|
+
newValue = newValue.filter(item => item !== value);
|
|
12370
|
+
}
|
|
12371
|
+
handleChange(path, newValue.length ? newValue : undefined);
|
|
12372
|
+
}
|
|
12373
|
+
}, value);
|
|
12374
|
+
})
|
|
12375
|
+
})]
|
|
12376
|
+
});
|
|
12377
|
+
}
|
|
12328
12378
|
return jsxs(Visible, {
|
|
12329
12379
|
visible: visible,
|
|
12330
12380
|
children: [jsx("div", {
|
|
@@ -12336,6 +12386,10 @@ const PrimitiveArrayControl = props => {
|
|
|
12336
12386
|
onClick: () => addItem(),
|
|
12337
12387
|
children: ["Add ", prettyLabel]
|
|
12338
12388
|
})
|
|
12389
|
+
}), jsx("pre", {
|
|
12390
|
+
children: JSON.stringify(schema.items, null, 2)
|
|
12391
|
+
}), jsx("pre", {
|
|
12392
|
+
children: JSON.stringify(itemUiSchema, null, 2)
|
|
12339
12393
|
}), items.length === 0 && jsxs("p", {
|
|
12340
12394
|
style: {
|
|
12341
12395
|
opacity: 0.7
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abgov/jsonforms-components",
|
|
3
|
-
"version": "2.58.
|
|
3
|
+
"version": "2.58.3",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "Government of Alberta - React renderers for JSON Forms based on the design system.",
|
|
6
6
|
"repository": "https://github.com/GovAlta/adsp-monorepo",
|
package/renderer-catalog.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": "1.0.0",
|
|
3
|
-
"generatedAt": "2026-04-
|
|
4
|
-
"sourceCommit": "
|
|
3
|
+
"generatedAt": "2026-04-06T15:32:07.375Z",
|
|
4
|
+
"sourceCommit": "1d7a0054291ed3ec1af68caee9d7554ce382199e",
|
|
5
5
|
"sourcePath": "libs/jsonforms-components/src/index.ts",
|
|
6
6
|
"rendererCount": 33,
|
|
7
7
|
"renderers": [
|