@abgov/jsonforms-components 1.23.4 → 1.24.1

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 CHANGED
@@ -1625,9 +1625,9 @@ $$b({ target: 'Object', stat: true, arity: 2, forced: Object.assign !== assign }
1625
1625
  assign: assign
1626
1626
  });
1627
1627
 
1628
- let _$7 = t => t,
1629
- _t$7;
1630
- const FormFieldWrapper = styled.div(_t$7 || (_t$7 = _$7`
1628
+ let _$8 = t => t,
1629
+ _t$8;
1630
+ const FormFieldWrapper = styled.div(_t$8 || (_t$8 = _$8`
1631
1631
  margin-bottom: var(--goa-space-l);
1632
1632
  `));
1633
1633
 
@@ -2686,17 +2686,26 @@ const onChangeForNumericControl = props => {
2686
2686
  }
2687
2687
  }
2688
2688
  };
2689
+ /**
2690
+ * Helper function to process onChange event for input enum checkboxes controls.
2691
+ * @param data
2692
+ * @param name
2693
+ * @param value
2694
+ * @returns {string[]}
2695
+ */
2696
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
2697
+ const onChangeForCheckboxData = (data, name, value) => data ? !value ? data === null || data === void 0 ? void 0 : data.filter(item => item !== name) : [...data, name] : [name];
2689
2698
 
2690
- let _$6 = t => t,
2691
- _t$6,
2699
+ let _$7 = t => t,
2700
+ _t$7,
2692
2701
  _t2$4;
2693
- styled.div(_t$6 || (_t$6 = _$6`
2702
+ styled.div(_t$7 || (_t$7 = _$7`
2694
2703
  height: 70vh;
2695
2704
  overflow-y: auto;
2696
2705
  padding-left: var(--goa-space-2xs);
2697
2706
  padding-right: var(--goa-space-2xs);
2698
2707
  `));
2699
- const Visible = styled.div(_t2$4 || (_t2$4 = _$6`
2708
+ const Visible = styled.div(_t2$4 || (_t2$4 = _$7`
2700
2709
  display: ${0};
2701
2710
  `), p => p.visible ? 'initial' : 'none');
2702
2711
 
@@ -3393,7 +3402,7 @@ if (DESCRIPTORS$1 && isCallable$2(NativeSymbol) && (!('description' in SymbolPro
3393
3402
  }
3394
3403
 
3395
3404
  const GoAInputText = props => {
3396
- var _a, _b, _c, _d, _e, _f, _g;
3405
+ var _a, _b, _c, _d, _e, _f, _g, _h;
3397
3406
  const {
3398
3407
  data,
3399
3408
  config,
@@ -3415,7 +3424,8 @@ const GoAInputText = props => {
3415
3424
  value: data,
3416
3425
  width: '100%',
3417
3426
  readonly: readOnly,
3418
- placeholder: placeholder,
3427
+ placeholder: placeholder
3428
+ }, (_g = uischema.options) === null || _g === void 0 ? void 0 : _g.componentProps, {
3419
3429
  // maxLength={appliedUiSchemaOptions?.maxLength}
3420
3430
  name: (appliedUiSchemaOptions === null || appliedUiSchemaOptions === void 0 ? void 0 : appliedUiSchemaOptions.name) || `${id || label}-input`,
3421
3431
  testId: (appliedUiSchemaOptions === null || appliedUiSchemaOptions === void 0 ? void 0 : appliedUiSchemaOptions.testId) || `${id}-input`,
@@ -3438,7 +3448,7 @@ const GoAInputText = props => {
3438
3448
  value: autoCapitalize ? value.toUpperCase() : value
3439
3449
  });
3440
3450
  }
3441
- }, (_g = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _g === void 0 ? void 0 : _g.componentProps));
3451
+ }, (_h = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _h === void 0 ? void 0 : _h.componentProps));
3442
3452
  };
3443
3453
  const GoATextControl = props => jsx(GoAInputBaseControl, Object.assign({}, props, {
3444
3454
  input: GoAInputText
@@ -4174,6 +4184,142 @@ const BooleanRadioControl = props => jsx(GoAInputBaseControl, Object.assign({},
4174
4184
  const GoABooleanRadioControlTester = rankWith(3, and(isBooleanControl, optionIs('radio', true)));
4175
4185
  const GoABooleanRadioControl = withJsonFormsControlProps(BooleanRadioControl);
4176
4186
 
4187
+ var $$3 = _export;
4188
+ var $includes = arrayIncludes.includes;
4189
+ var fails$2 = fails$o;
4190
+ var addToUnscopables = addToUnscopables$3;
4191
+
4192
+ // FF99+ bug
4193
+ var BROKEN_ON_SPARSE = fails$2(function () {
4194
+ // eslint-disable-next-line es/no-array-prototype-includes -- detection
4195
+ return !Array(1).includes();
4196
+ });
4197
+
4198
+ // `Array.prototype.includes` method
4199
+ // https://tc39.es/ecma262/#sec-array.prototype.includes
4200
+ $$3({ target: 'Array', proto: true, forced: BROKEN_ON_SPARSE }, {
4201
+ includes: function includes(el /* , fromIndex = 0 */) {
4202
+ return $includes(this, el, arguments.length > 1 ? arguments[1] : undefined);
4203
+ }
4204
+ });
4205
+
4206
+ // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables
4207
+ addToUnscopables('includes');
4208
+
4209
+ var isRegExp = isRegexp;
4210
+
4211
+ var $TypeError$1 = TypeError;
4212
+
4213
+ var notARegexp = function (it) {
4214
+ if (isRegExp(it)) {
4215
+ throw new $TypeError$1("The method doesn't accept regular expressions");
4216
+ } return it;
4217
+ };
4218
+
4219
+ var wellKnownSymbol = wellKnownSymbol$e;
4220
+
4221
+ var MATCH = wellKnownSymbol('match');
4222
+
4223
+ var correctIsRegexpLogic = function (METHOD_NAME) {
4224
+ var regexp = /./;
4225
+ try {
4226
+ '/./'[METHOD_NAME](regexp);
4227
+ } catch (error1) {
4228
+ try {
4229
+ regexp[MATCH] = false;
4230
+ return '/./'[METHOD_NAME](regexp);
4231
+ } catch (error2) { /* empty */ }
4232
+ } return false;
4233
+ };
4234
+
4235
+ var $$2 = _export;
4236
+ var uncurryThis$1 = functionUncurryThis;
4237
+ var notARegExp = notARegexp;
4238
+ var requireObjectCoercible = requireObjectCoercible$7;
4239
+ var toString$1 = toString$a;
4240
+ var correctIsRegExpLogic = correctIsRegexpLogic;
4241
+
4242
+ var stringIndexOf = uncurryThis$1(''.indexOf);
4243
+
4244
+ // `String.prototype.includes` method
4245
+ // https://tc39.es/ecma262/#sec-string.prototype.includes
4246
+ $$2({ target: 'String', proto: true, forced: !correctIsRegExpLogic('includes') }, {
4247
+ includes: function includes(searchString /* , position = 0 */) {
4248
+ return !!~stringIndexOf(
4249
+ toString$1(requireObjectCoercible(this)),
4250
+ toString$1(notARegExp(searchString)),
4251
+ arguments.length > 1 ? arguments[1] : undefined
4252
+ );
4253
+ }
4254
+ });
4255
+
4256
+ let _$6 = t => t,
4257
+ _t$6;
4258
+ const Checkboxes = ({
4259
+ children,
4260
+ orientation,
4261
+ testId
4262
+ }) => {
4263
+ return jsx(CheckBoxGroupDiv, {
4264
+ "data-testid": testId,
4265
+ className: orientation,
4266
+ children: children
4267
+ });
4268
+ };
4269
+ const CheckBoxGroupDiv = styled.div(_t$6 || (_t$6 = _$6`
4270
+ .horizontal {
4271
+ display: flex;
4272
+ flex-direction: row;
4273
+ }
4274
+
4275
+ .vertical {
4276
+ display: inline-block;
4277
+ }
4278
+ `));
4279
+
4280
+ const CheckboxGroup = props => {
4281
+ var _a, _b;
4282
+ const {
4283
+ data,
4284
+ className,
4285
+ id,
4286
+ schema,
4287
+ uischema,
4288
+ path,
4289
+ handleChange,
4290
+ options,
4291
+ config,
4292
+ label,
4293
+ t
4294
+ } = props;
4295
+ const enumData = (schema === null || schema === void 0 ? void 0 : schema.enum) || [];
4296
+ const appliedUiSchemaOptions = merge({}, config, props.uischema.options, options);
4297
+ return jsx(Checkboxes, {
4298
+ orientation: ((_a = uischema.options) === null || _a === void 0 ? void 0 : _a.orientation) ? (_b = uischema.options) === null || _b === void 0 ? void 0 : _b.orientation : 'vertical',
4299
+ testId: `${label || id}-jsonforms-checkboxes`,
4300
+ children: enumData.map(enumValue => {
4301
+ return jsx(GoACheckbox, Object.assign({
4302
+ name: enumValue,
4303
+ checked: data ? data.includes(enumValue) : false,
4304
+ value: `${enumValue}`
4305
+ }, appliedUiSchemaOptions, {
4306
+ text: enumValue,
4307
+ testId: `${enumValue}-checkbox`,
4308
+ onChange: (name, value) => {
4309
+ handleChange(path, onChangeForCheckboxData(data, name, value));
4310
+ }
4311
+ }));
4312
+ })
4313
+ });
4314
+ };
4315
+ const EnumCheckboxControl = props => {
4316
+ return jsx(GoAInputBaseControl, Object.assign({}, props, {
4317
+ input: CheckboxGroup
4318
+ }));
4319
+ };
4320
+ const GoAEnumCheckboxGroupControl = withJsonFormsEnumProps(withTranslateProps(EnumCheckboxControl), true);
4321
+ const GoACheckoutGroupControlTester = rankWith(18, and(isEnumControl, optionIs('format', 'checkbox')));
4322
+
4177
4323
  const renderLayoutElements = (elements, schema, path, enabled, renderers, cells) => {
4178
4324
  return elements.map((child, index) => jsx("div", {
4179
4325
  children: jsx(JsonFormsDispatch, {
@@ -4337,10 +4483,10 @@ const RightAlignmentDiv = styled.div(_t10 || (_t10 = _$4`
4337
4483
  justify-content: flex-end;
4338
4484
  `));
4339
4485
 
4340
- var toString$1 = toString$a;
4486
+ var toString = toString$a;
4341
4487
 
4342
4488
  var normalizeStringArgument$1 = function (argument, $default) {
4343
- return argument === undefined ? arguments.length < 2 ? '' : $default : toString$1(argument);
4489
+ return argument === undefined ? arguments.length < 2 ? '' : $default : toString(argument);
4344
4490
  };
4345
4491
 
4346
4492
  var isObject = isObject$b;
@@ -4354,10 +4500,10 @@ var installErrorCause$1 = function (O, options) {
4354
4500
  }
4355
4501
  };
4356
4502
 
4357
- var uncurryThis$1 = functionUncurryThis;
4503
+ var uncurryThis = functionUncurryThis;
4358
4504
 
4359
4505
  var $Error = Error;
4360
- var replace = uncurryThis$1(''.replace);
4506
+ var replace = uncurryThis(''.replace);
4361
4507
 
4362
4508
  var TEST = (function (arg) { return String(new $Error(arg).stack); })('zxcasd');
4363
4509
  // eslint-disable-next-line redos/no-vulnerable -- safe
@@ -4370,10 +4516,10 @@ var errorStackClear = function (stack, dropEntries) {
4370
4516
  } return stack;
4371
4517
  };
4372
4518
 
4373
- var fails$2 = fails$o;
4519
+ var fails$1 = fails$o;
4374
4520
  var createPropertyDescriptor = createPropertyDescriptor$4;
4375
4521
 
4376
- var errorStackInstallable = !fails$2(function () {
4522
+ var errorStackInstallable = !fails$1(function () {
4377
4523
  var error = new Error('a');
4378
4524
  if (!('stack' in error)) return true;
4379
4525
  // eslint-disable-next-line es/no-object-defineproperty -- safe
@@ -4460,7 +4606,7 @@ var wrapErrorConstructorWithCause$1 = function (FULL_NAME, wrapper, FORCED, IS_A
4460
4606
  };
4461
4607
 
4462
4608
  /* eslint-disable no-unused-vars -- required for functions `.length` */
4463
- var $$3 = _export;
4609
+ var $$1 = _export;
4464
4610
  var global$2 = global$i;
4465
4611
  var apply = functionApply;
4466
4612
  var wrapErrorConstructorWithCause = wrapErrorConstructorWithCause$1;
@@ -4474,14 +4620,14 @@ var FORCED$1 = new Error('e', { cause: 7 }).cause !== 7;
4474
4620
  var exportGlobalErrorCauseWrapper = function (ERROR_NAME, wrapper) {
4475
4621
  var O = {};
4476
4622
  O[ERROR_NAME] = wrapErrorConstructorWithCause(ERROR_NAME, wrapper, FORCED$1);
4477
- $$3({ global: true, constructor: true, arity: 1, forced: FORCED$1 }, O);
4623
+ $$1({ global: true, constructor: true, arity: 1, forced: FORCED$1 }, O);
4478
4624
  };
4479
4625
 
4480
4626
  var exportWebAssemblyErrorCauseWrapper = function (ERROR_NAME, wrapper) {
4481
4627
  if (WebAssembly && WebAssembly[ERROR_NAME]) {
4482
4628
  var O = {};
4483
4629
  O[ERROR_NAME] = wrapErrorConstructorWithCause(WEB_ASSEMBLY + '.' + ERROR_NAME, wrapper, FORCED$1);
4484
- $$3({ target: WEB_ASSEMBLY, stat: true, constructor: true, arity: 1, forced: FORCED$1 }, O);
4630
+ $$1({ target: WEB_ASSEMBLY, stat: true, constructor: true, arity: 1, forced: FORCED$1 }, O);
4485
4631
  }
4486
4632
  };
4487
4633
 
@@ -4517,75 +4663,6 @@ exportWebAssemblyErrorCauseWrapper('RuntimeError', function (init) {
4517
4663
  return function RuntimeError(message) { return apply(init, this, arguments); };
4518
4664
  });
4519
4665
 
4520
- var $$2 = _export;
4521
- var $includes = arrayIncludes.includes;
4522
- var fails$1 = fails$o;
4523
- var addToUnscopables = addToUnscopables$3;
4524
-
4525
- // FF99+ bug
4526
- var BROKEN_ON_SPARSE = fails$1(function () {
4527
- // eslint-disable-next-line es/no-array-prototype-includes -- detection
4528
- return !Array(1).includes();
4529
- });
4530
-
4531
- // `Array.prototype.includes` method
4532
- // https://tc39.es/ecma262/#sec-array.prototype.includes
4533
- $$2({ target: 'Array', proto: true, forced: BROKEN_ON_SPARSE }, {
4534
- includes: function includes(el /* , fromIndex = 0 */) {
4535
- return $includes(this, el, arguments.length > 1 ? arguments[1] : undefined);
4536
- }
4537
- });
4538
-
4539
- // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables
4540
- addToUnscopables('includes');
4541
-
4542
- var isRegExp = isRegexp;
4543
-
4544
- var $TypeError$1 = TypeError;
4545
-
4546
- var notARegexp = function (it) {
4547
- if (isRegExp(it)) {
4548
- throw new $TypeError$1("The method doesn't accept regular expressions");
4549
- } return it;
4550
- };
4551
-
4552
- var wellKnownSymbol = wellKnownSymbol$e;
4553
-
4554
- var MATCH = wellKnownSymbol('match');
4555
-
4556
- var correctIsRegexpLogic = function (METHOD_NAME) {
4557
- var regexp = /./;
4558
- try {
4559
- '/./'[METHOD_NAME](regexp);
4560
- } catch (error1) {
4561
- try {
4562
- regexp[MATCH] = false;
4563
- return '/./'[METHOD_NAME](regexp);
4564
- } catch (error2) { /* empty */ }
4565
- } return false;
4566
- };
4567
-
4568
- var $$1 = _export;
4569
- var uncurryThis = functionUncurryThis;
4570
- var notARegExp = notARegexp;
4571
- var requireObjectCoercible = requireObjectCoercible$7;
4572
- var toString = toString$a;
4573
- var correctIsRegExpLogic = correctIsRegexpLogic;
4574
-
4575
- var stringIndexOf = uncurryThis(''.indexOf);
4576
-
4577
- // `String.prototype.includes` method
4578
- // https://tc39.es/ecma262/#sec-string.prototype.includes
4579
- $$1({ target: 'String', proto: true, forced: !correctIsRegExpLogic('includes') }, {
4580
- includes: function includes(searchString /* , position = 0 */) {
4581
- return !!~stringIndexOf(
4582
- toString(requireObjectCoercible(this)),
4583
- toString(notARegExp(searchString)),
4584
- arguments.length > 1 ? arguments[1] : undefined
4585
- );
4586
- }
4587
- });
4588
-
4589
4666
  class ContextProviderClass {
4590
4667
  addDataByUrl(key, url, processDataFunction, token) {
4591
4668
  return __awaiter(this, void 0, void 0, function* () {
@@ -6532,6 +6609,9 @@ const GoABaseRenderers = [
6532
6609
  }, {
6533
6610
  tester: GoARadioGroupControlTester,
6534
6611
  renderer: GoAEnumRadioGroupControl
6612
+ }, {
6613
+ tester: GoACheckoutGroupControlTester,
6614
+ renderer: GoAEnumCheckboxGroupControl
6535
6615
  }, {
6536
6616
  tester: GoABooleanControlTester,
6537
6617
  renderer: GoABooleanControl
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abgov/jsonforms-components",
3
- "version": "1.23.4",
3
+ "version": "1.24.1",
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",
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ interface CheckboxGroupProps {
3
+ orientation?: CheckboxGroupOrientation;
4
+ testId?: string;
5
+ children?: React.ReactNode;
6
+ }
7
+ export type CheckboxGroupOrientation = 'horizontal' | 'vertical';
8
+ declare const Checkboxes: ({ children, orientation, testId }: CheckboxGroupProps) => JSX.Element;
9
+ export default Checkboxes;
@@ -0,0 +1,12 @@
1
+ import React from 'react';
2
+ import { ControlProps, OwnPropsOfEnum, RankedTester } from '@jsonforms/core';
3
+ import { TranslateProps } from '@jsonforms/react';
4
+ import { WithInputProps } from './type';
5
+ import { WithOptionLabel } from '../../util';
6
+ import { EnumCellProps, WithClassname } from '@jsonforms/core';
7
+ type CheckboxGroupProp = EnumCellProps & WithClassname & TranslateProps & WithInputProps;
8
+ export declare const CheckboxGroup: (props: CheckboxGroupProp) => JSX.Element;
9
+ export declare const EnumCheckboxControl: (props: ControlProps & OwnPropsOfEnum & WithOptionLabel & TranslateProps) => import("react/jsx-runtime").JSX.Element;
10
+ export declare const GoAEnumCheckboxGroupControl: React.ComponentType<import("@jsonforms/core").OwnPropsOfControl & OwnPropsOfEnum>;
11
+ export declare const GoACheckoutGroupControlTester: RankedTester;
12
+ export {};
@@ -10,3 +10,4 @@ export * from './InputEnum';
10
10
  export * from './InputEnumRadios';
11
11
  export * from './InputBooleanControl';
12
12
  export * from './InputBooleanRadioControl';
13
+ export * from './InputEnumCheckboxes';
@@ -67,3 +67,11 @@ export declare const onChangeForDateTimeControl: (props: EventChangeControlProps
67
67
  * @param props - EventChangeControlProps
68
68
  */
69
69
  export declare const onChangeForNumericControl: (props: EventChangeControlProps) => void;
70
+ /**
71
+ * Helper function to process onChange event for input enum checkboxes controls.
72
+ * @param data
73
+ * @param name
74
+ * @param value
75
+ * @returns {string[]}
76
+ */
77
+ export declare const onChangeForCheckboxData: (data: any, name: string, value: string) => any;