@genesislcap/foundation-forms 15.54.0 → 15.55.0

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.
@@ -1717,6 +1717,12 @@
1717
1717
  }
1718
1718
  ]
1719
1719
  },
1720
+ {
1721
+ "kind": "javascript-module",
1722
+ "path": "src/jsonforms/cleared-value.ts",
1723
+ "declarations": [],
1724
+ "exports": []
1725
+ },
1720
1726
  {
1721
1727
  "kind": "javascript-module",
1722
1728
  "path": "src/jsonforms/json-forms.ts",
@@ -0,0 +1,20 @@
1
+ import { JsonSchema, UpdateAction } from '@jsonforms/core';
2
+ /**
3
+ * `null` keeps a nullable field cleared (AJV's `useDefaults` only fills absent keys); a
4
+ * non-nullable field accepts no null, so its key is removed instead.
5
+ * @internal
6
+ */
7
+ export declare const clearedValueFor: (schema: JsonSchema | undefined) => null | undefined;
8
+ /**
9
+ * Rewrites a `null`/`undefined` write to the cleared value the field's schema accepts, so every
10
+ * control (including consumer and React slot renderers) clears a field the same way.
11
+ * @internal
12
+ */
13
+ export declare const normalizeClearedValue: (action: UpdateAction, rootSchema: JsonSchema | undefined) => UpdateAction;
14
+ /**
15
+ * Removing a key makes AJV write the schema default back, so an input emptied mid-typing writes
16
+ * `''` (keeping data in step with the box) and the key is only removed on `change`.
17
+ * @internal
18
+ */
19
+ export declare const emptiedInputValue: (event: Event, schema: JsonSchema | undefined) => "" | undefined;
20
+ //# sourceMappingURL=cleared-value.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cleared-value.d.ts","sourceRoot":"","sources":["../../../src/jsonforms/cleared-value.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAwB,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAgBjF;;;;GAIG;AACH,eAAO,MAAM,eAAe,GAAI,QAAQ,UAAU,GAAG,SAAS,KAAG,IAAI,GAAG,SACvB,CAAC;AAElD;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,GACh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IAwBC,SAAS,EAAE,8BAA8B,EAAE,CAAC;IACxD,gBAAgB;IAIJ,cAAc,EAAE,cAAc,CAAC;IAC3C,qBAAqB;IAIT,GAAG,EAAE,GAAG,CAAiD;IACrE,UAAU;IAIiB,QAAQ,EAAE,OAAO,CAAC;IAC7C,eAAe;IAIH,MAAM,EAAE,GAAG,CAAC;IACxB,aAAa;IAIb;;;OAGG;IACS,iBAAiB,EAAE,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,CAAa;IACtE,wBAAwB;IAUxB;;;OAGG;IACS,UAAU,EAAE,OAAO,CAAS;IACxC,iBAAiB;IAUjB;;;OAGG;IACS,iBAAiB,EAAE,WAAW,EAAE,CAAM;IAClD,wBAAwB;IAIxB,IAAI,KAAK,IAAI,aAAa,CAuBzB;IAED,QAAQ,GAAI,QAAQ,YAAY,UAkB9B;IAEF;;;;OAIG;IACH,eAAe,CAAC,MAAM,EAAE,WAAW,EAAE;IAKrC;;;OAGG;IACH,iBAAiB;IAKjB,OAAO,CAAC,qBAAqB;IAI7B,OAAO,CAAC,2BAA2B;IAenC,OAAO,CAAC,uBAAuB;IAO/B;;;;;OAKG;IACH,QAAQ,GAAI,UAAU,eAAe,EAAE,UAAiC,KAAG,WAAW,EAAE,CAoDtF;IAEI,uBAAuB;CAQ9B"}
@@ -12,6 +12,8 @@ import { DispatchRenderer } from './dispatch-renderer';
12
12
  * @internal
13
13
  */
14
14
  export declare function formatDateControlValue(control: any): string;
15
+ /** @internal */
16
+ export declare const toDateControlValue: (inputValue: string) => number | undefined;
15
17
  export declare const DateControlRendererTemplate: (prefix?: string) => import("@microsoft/fast-element").ViewTemplate<DispatchRenderer, any>;
16
18
  export declare const DateControlRendererEntry: RendererEntry;
17
19
  //# sourceMappingURL=DateControlRenderer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"DateControlRenderer.d.ts","sourceRoot":"","sources":["../../../../src/jsonforms/renderers/DateControlRenderer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAI5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAgBvD;;;;;;;;;;GAUG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,GAAG,GAAG,MAAM,CAc3D;AAED,eAAO,MAAM,2BAA2B,GAAI,SAAQ,MAAe,0EA8BlE,CAAC;AAEF,eAAO,MAAM,wBAAwB,EAAE,aAMtC,CAAC"}
1
+ {"version":3,"file":"DateControlRenderer.d.ts","sourceRoot":"","sources":["../../../../src/jsonforms/renderers/DateControlRenderer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAI5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAgBvD;;;;;;;;;;GAUG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,GAAG,GAAG,MAAM,CAc3D;AAED,gBAAgB;AAChB,eAAO,MAAM,kBAAkB,GAAI,YAAY,MAAM,KAAG,MAAM,GAAG,SACR,CAAC;AAE1D,eAAO,MAAM,2BAA2B,GAAI,SAAQ,MAAe,0EAwBlE,CAAC;AAEF,eAAO,MAAM,wBAAwB,EAAE,aAMtC,CAAC"}
@@ -1,5 +1,7 @@
1
1
  import { RendererEntry } from '../../types';
2
2
  import { DispatchRenderer } from './dispatch-renderer';
3
+ /** @internal */
4
+ export declare const toRadioGroupValue: (value: string | undefined) => string | undefined;
3
5
  export declare const EnumRadioGroupControlRendererTemplate: (prefix?: string) => import("@microsoft/fast-element").ViewTemplate<DispatchRenderer, any>;
4
6
  /**
5
7
  * A JSON Forms renderer that renders enum options as a radio-group.
@@ -1 +1 @@
1
- {"version":3,"file":"EnumRadioGroupControlRenderer.d.ts","sourceRoot":"","sources":["../../../../src/jsonforms/renderers/EnumRadioGroupControlRenderer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAG5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAoBvD,eAAO,MAAM,qCAAqC,GAChD,SAAQ,MAAe,0EAgCxB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,kCAAkC,EAAE,aAMhD,CAAC"}
1
+ {"version":3,"file":"EnumRadioGroupControlRenderer.d.ts","sourceRoot":"","sources":["../../../../src/jsonforms/renderers/EnumRadioGroupControlRenderer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAG5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAoBvD,gBAAgB;AAChB,eAAO,MAAM,iBAAiB,GAAI,OAAO,MAAM,GAAG,SAAS,KAAG,MAAM,GAAG,SACnD,CAAC;AAErB,eAAO,MAAM,qCAAqC,GAChD,SAAQ,MAAe,0EA+BxB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,kCAAkC,EAAE,aAMhD,CAAC"}
@@ -4,6 +4,10 @@ import { DispatchRenderer } from './dispatch-renderer';
4
4
  export declare const resolveMaximumInputPrecision: (fieldSchema: GenesisJsonSchema, options?: {
5
5
  maximumInputPrecision?: number;
6
6
  }) => number;
7
+ /** @internal */
8
+ export declare function handleNumberChange(x: DispatchRenderer, c: {
9
+ event: Event;
10
+ }): any;
7
11
  export declare const NumberControlRendererTemplate: (prefix?: string) => import("@microsoft/fast-element").ViewTemplate<DispatchRenderer, any>;
8
12
  export declare const NumberControlRendererEntry: RendererEntry;
9
13
  //# sourceMappingURL=NumberControlRenderer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"NumberControlRenderer.d.ts","sourceRoot":"","sources":["../../../../src/jsonforms/renderers/NumberControlRenderer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAG3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAsBvD,eAAO,MAAM,4BAA4B,GACvC,aAAa,iBAAiB,EAC9B,UAAU;IAAE,qBAAqB,CAAC,EAAE,MAAM,CAAA;CAAE,KAC3C,MAQF,CAAC;AAqBF,eAAO,MAAM,6BAA6B,GAAI,SAAQ,MAAe,0EAkCpE,CAAC;AAEF,eAAO,MAAM,0BAA0B,EAAE,aAMxC,CAAC"}
1
+ {"version":3,"file":"NumberControlRenderer.d.ts","sourceRoot":"","sources":["../../../../src/jsonforms/renderers/NumberControlRenderer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAI3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAsBvD,eAAO,MAAM,4BAA4B,GACvC,aAAa,iBAAiB,EAC9B,UAAU;IAAE,qBAAqB,CAAC,EAAE,MAAM,CAAA;CAAE,KAC3C,MAQF,CAAC;AAMF,gBAAgB;AAChB,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,gBAAgB,EAAE,CAAC,EAAE;IAAE,KAAK,EAAE,KAAK,CAAA;CAAE,OAa1E;AAED,eAAO,MAAM,6BAA6B,GAAI,SAAQ,MAAe,0EAkCpE,CAAC;AAEF,eAAO,MAAM,0BAA0B,EAAE,aAMxC,CAAC"}
@@ -1,4 +1,11 @@
1
+ import type { StringRendererOptions } from '../../types';
1
2
  import { DispatchRenderer } from './dispatch-renderer';
3
+ /**
4
+ * An empty result is `undefined` rather than `''`, which GSF would store as an empty string
5
+ * instead of clearing the field.
6
+ * @internal
7
+ */
8
+ export declare function toStringControlValue(inputValue: string, textTransform?: StringRendererOptions['textTransform']): string | undefined;
2
9
  export declare const getStringControlRendererTemplate: (prefix?: string) => import("@microsoft/fast-element").ViewTemplate<DispatchRenderer, any>;
3
10
  export declare const StringControlRendererTemplate: import("@microsoft/fast-element").ViewTemplate<DispatchRenderer, any>;
4
11
  //# sourceMappingURL=StringControlRenderer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"StringControlRenderer.d.ts","sourceRoot":"","sources":["../../../../src/jsonforms/renderers/StringControlRenderer.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAuBvD,eAAO,MAAM,gCAAgC,GAAI,SAAQ,MAAe,0EAgDvE,CAAC;AACF,eAAO,MAAM,6BAA6B,uEAEzC,CAAC"}
1
+ {"version":3,"file":"StringControlRenderer.d.ts","sourceRoot":"","sources":["../../../../src/jsonforms/renderers/StringControlRenderer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAGzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEvD;;;;GAIG;AACH,wBAAgB,oBAAoB,CAClC,UAAU,EAAE,MAAM,EAClB,aAAa,GAAE,qBAAqB,CAAC,eAAe,CAAU,GAC7D,MAAM,GAAG,SAAS,CAWpB;AAUD,eAAO,MAAM,gCAAgC,GAAI,SAAQ,MAAe,0EAgDvE,CAAC;AACF,eAAO,MAAM,6BAA6B,uEAEzC,CAAC"}
@@ -0,0 +1,43 @@
1
+ import { Resolve, UPDATE_DATA } from '@jsonforms/core';
2
+ const allowsNull = (schema) => {
3
+ var _a, _b;
4
+ return schema.type === 'null' ||
5
+ (Array.isArray(schema.type) && schema.type.includes('null')) ||
6
+ [...((_a = schema.oneOf) !== null && _a !== void 0 ? _a : []), ...((_b = schema.anyOf) !== null && _b !== void 0 ? _b : [])].some(allowsNull);
7
+ };
8
+ const toSchemaPath = (dataPath) => [
9
+ '#',
10
+ ...dataPath
11
+ .replace(/^\//, '')
12
+ .split(/[./]/)
13
+ .map((segment) => (/^\d+$/.test(segment) ? 'items' : `properties/${segment}`)),
14
+ ].join('/');
15
+ /**
16
+ * `null` keeps a nullable field cleared (AJV's `useDefaults` only fills absent keys); a
17
+ * non-nullable field accepts no null, so its key is removed instead.
18
+ * @internal
19
+ */
20
+ export const clearedValueFor = (schema) => schema && allowsNull(schema) ? null : undefined;
21
+ /**
22
+ * Rewrites a `null`/`undefined` write to the cleared value the field's schema accepts, so every
23
+ * control (including consumer and React slot renderers) clears a field the same way.
24
+ * @internal
25
+ */
26
+ export const normalizeClearedValue = (action, rootSchema) => {
27
+ if (action.type !== UPDATE_DATA || !action.path || !rootSchema) {
28
+ return action;
29
+ }
30
+ const { path, updater } = action;
31
+ return Object.assign(Object.assign({}, action), { updater: (existing) => {
32
+ var _a;
33
+ return (_a = updater(existing)) !== null && _a !== void 0 ? _a : clearedValueFor(Resolve.schema(rootSchema, toSchemaPath(path), rootSchema));
34
+ } });
35
+ };
36
+ /**
37
+ * Removing a key makes AJV write the schema default back, so an input emptied mid-typing writes
38
+ * `''` (keeping data in step with the box) and the key is only removed on `change`.
39
+ * @internal
40
+ */
41
+ export const emptiedInputValue = (event, schema) => event.type === 'input' && (schema === null || schema === void 0 ? void 0 : schema.default) !== undefined && clearedValueFor(schema) === undefined
42
+ ? ''
43
+ : undefined;
@@ -3,6 +3,7 @@ import { isDev } from '@genesislcap/foundation-utils';
3
3
  import { Actions, configReducer, coreReducer, createAjv, Generate, i18nReducer, Resolve, } from '@jsonforms/core';
4
4
  import { attr, css, customElement, FASTElement, html, Observable, observable, when, } from '@microsoft/fast-element';
5
5
  import { genesisErrorTranslator, logger } from '../utils';
6
+ import { normalizeClearedValue } from './cleared-value';
6
7
  const TIMESTAMP_FIELD = '#/properties/TIMESTAMP';
7
8
  const template = html `
8
9
  <template>
@@ -59,7 +60,7 @@ let JSONForms = class JSONForms extends FASTElement {
59
60
  // back into core so renderers (which read `core.additionalErrors`) see
60
61
  // the fresh errors. Without this, the value baked in by `Actions.init`
61
62
  // sticks forever even when validators would now return [].
62
- const nextCore = coreReducer(this.jsonforms.core, action);
63
+ const nextCore = coreReducer(this.jsonforms.core, normalizeClearedValue(action, this.schema));
63
64
  if (action.path) {
64
65
  const editedPath = action.path.startsWith('/')
65
66
  ? action.path
@@ -20,7 +20,7 @@ export const resolveSelectionValue = (control, detail) => {
20
20
  if (!delimiter) {
21
21
  return detail;
22
22
  }
23
- return detail && detail.length ? detail.join(delimiter) : null;
23
+ return detail && detail.length ? detail.join(delimiter) : undefined;
24
24
  };
25
25
  export const ConnectedMultiselectControlRendererTemplate = (prefix = 'zero') => html `
26
26
  <template>
@@ -29,7 +29,7 @@ const typeSwitch = (control) => {
29
29
  * @internal
30
30
  */
31
31
  export function formatDateControlValue(control) {
32
- if (!control.data)
32
+ if (control.data == null || control.data === '')
33
33
  return '';
34
34
  const type = typeSwitch(control);
35
35
  const date = new Date(control.data);
@@ -42,6 +42,8 @@ export function formatDateControlValue(control) {
42
42
  const minute = padded(date.getMinutes());
43
43
  return `${year}-${month}-${day}` + (type === 'datetime-local' ? `T${hour}:${minute}` : '');
44
44
  }
45
+ /** @internal */
46
+ export const toDateControlValue = (inputValue) => inputValue ? new Date(inputValue).getTime() : undefined;
45
47
  export const DateControlRendererTemplate = (prefix = 'zero') => html `
46
48
  <template>
47
49
  ${controlWrapperTemplate({
@@ -57,15 +59,8 @@ export const DateControlRendererTemplate = (prefix = 'zero') => html `
57
59
  tabindex="${(x) => { var _a, _b; return (_b = (_a = x.control.uischema) === null || _a === void 0 ? void 0 : _a.options) === null || _b === void 0 ? void 0 : _b.tabIndex; }}"
58
60
  @blur=${(x, c) => {
59
61
  const target = c.event.target;
60
- const inputValue = target.value;
61
62
  x.onBlur();
62
- if (inputValue) {
63
- const timestamp = new Date(inputValue).getTime();
64
- x.control.handleChange(x.control.path, timestamp);
65
- }
66
- else {
67
- x.control.handleChange(x.control.path, undefined);
68
- }
63
+ x.control.handleChange(x.control.path, toDateControlValue(target.value));
69
64
  }}"
70
65
  style="width: 100%"
71
66
  ></${prefix}-text-field>
@@ -19,6 +19,8 @@ const radioGroupStyles = (prefix) => `
19
19
  align-items: flex-start;
20
20
  }
21
21
  `;
22
+ /** @internal */
23
+ export const toRadioGroupValue = (value) => value || undefined;
22
24
  export const EnumRadioGroupControlRendererTemplate = (prefix = 'zero') => html `
23
25
  <template>
24
26
  <style>
@@ -34,10 +36,8 @@ export const EnumRadioGroupControlRendererTemplate = (prefix = 'zero') => html `
34
36
  id=${(x) => x.control.path}
35
37
  data-test-id=${(x) => x.control.path}
36
38
  @change=${(x, c) => {
37
- var _a;
38
39
  const target = c.event.currentTarget;
39
- const value = (_a = target.value) !== null && _a !== void 0 ? _a : '';
40
- x.control.handleChange(x.control.path, value === '' ? null : value);
40
+ x.control.handleChange(x.control.path, toRadioGroupValue(target.value));
41
41
  x.onBlur();
42
42
  }}
43
43
  >
@@ -1,5 +1,6 @@
1
1
  import { hasType, mapStateToControlProps, rankWith } from '@jsonforms/core';
2
2
  import { html } from '@microsoft/fast-element';
3
+ import { emptiedInputValue } from '../cleared-value';
3
4
  import { isBigDecimal, isOneOfNumber } from '../testers/isOneOfNumber';
4
5
  import { controlWrapperTemplate } from './ControlWrapperRenderer';
5
6
  import { NUMBER_CONTROL_RANK } from './RenderersRanks';
@@ -30,12 +31,13 @@ const shouldSubmitAsString = (fieldSchema) => {
30
31
  return hasType(fieldSchema, 'string') ||
31
32
  ((_b = (_a = fieldSchema.oneOf) === null || _a === void 0 ? void 0 : _a.some((branch) => hasType(branch, 'string'))) !== null && _b !== void 0 ? _b : false);
32
33
  };
33
- function handleNumberChange(x, c) {
34
+ /** @internal */
35
+ export function handleNumberChange(x, c) {
34
36
  var _a;
35
37
  const host = c.event.currentTarget;
36
38
  const raw = String((_a = host === null || host === void 0 ? void 0 : host.value) !== null && _a !== void 0 ? _a : '');
37
39
  if (raw === '') {
38
- return x.control.handleChange(x.control.path, undefined);
40
+ return x.control.handleChange(x.control.path, emptiedInputValue(c.event, x.control.schema));
39
41
  }
40
42
  const value = parseFloat(raw);
41
43
  if (isNaN(value)) {
@@ -57,7 +59,7 @@ export const NumberControlRendererTemplate = (prefix = 'zero') => html `
57
59
  prefix=${(x) => { var _a, _b; return (_b = (_a = x.control.uischema) === null || _a === void 0 ? void 0 : _a.options) === null || _b === void 0 ? void 0 : _b.prefix; }}
58
60
  suffix=${(x) => { var _a, _b; return (_b = (_a = x.control.uischema) === null || _a === void 0 ? void 0 : _a.options) === null || _b === void 0 ? void 0 : _b.suffix; }}
59
61
  ?hide-affix-from-screen-reader=${(x) => { var _a, _b; return (_b = (_a = x.control.uischema) === null || _a === void 0 ? void 0 : _a.options) === null || _b === void 0 ? void 0 : _b.hideAffixFromScreenReader; }}
60
- :value=${(x) => (x.control.data === undefined ? '' : String(x.control.data))}
62
+ :value=${(x) => (x.control.data == null ? '' : String(x.control.data))}
61
63
  :maximumInputPrecision=${(x) => resolveMaximumInputPrecision(fieldSchemaFromControl(x.control), x.control.uischema.options)}
62
64
  tabindex="${(x) => { var _a, _b; return (_b = (_a = x.control.uischema) === null || _a === void 0 ? void 0 : _a.options) === null || _b === void 0 ? void 0 : _b.tabIndex; }}"
63
65
  @change=${handleNumberChange}
@@ -1,24 +1,26 @@
1
1
  import { whenElse } from '@genesislcap/foundation-utils';
2
2
  import { html } from '@microsoft/fast-element';
3
+ import { emptiedInputValue } from '../cleared-value';
3
4
  import { controlWrapperTemplate } from './ControlWrapperRenderer';
5
+ /**
6
+ * An empty result is `undefined` rather than `''`, which GSF would store as an empty string
7
+ * instead of clearing the field.
8
+ * @internal
9
+ */
10
+ export function toStringControlValue(inputValue, textTransform = 'none') {
11
+ const transformedValue = typeof textTransform === 'function'
12
+ ? textTransform(inputValue)
13
+ : textTransform === 'uppercase'
14
+ ? inputValue.toUpperCase()
15
+ : textTransform === 'lowercase'
16
+ ? inputValue.toLowerCase()
17
+ : inputValue;
18
+ return transformedValue === '' ? undefined : transformedValue;
19
+ }
4
20
  function changeHandler(x, c) {
5
- var _a, _b, _c;
6
- const inputValue = c.event.target.value;
7
- const options = (_b = (_a = x.control.uischema) === null || _a === void 0 ? void 0 : _a.options) !== null && _b !== void 0 ? _b : {};
8
- const textTransform = (_c = options.textTransform) !== null && _c !== void 0 ? _c : 'none';
9
- let transformedValue = inputValue;
10
- if (typeof textTransform === 'function') {
11
- transformedValue = textTransform(inputValue);
12
- }
13
- else {
14
- transformedValue =
15
- textTransform === 'uppercase'
16
- ? inputValue.toUpperCase()
17
- : textTransform === 'lowercase'
18
- ? inputValue.toLowerCase()
19
- : inputValue;
20
- }
21
- x.control.handleChange(x.control.path, transformedValue === '' ? null : transformedValue);
21
+ var _a, _b;
22
+ const value = toStringControlValue(c.event.target.value, (_b = (_a = x.control.uischema) === null || _a === void 0 ? void 0 : _a.options) === null || _b === void 0 ? void 0 : _b.textTransform);
23
+ x.control.handleChange(x.control.path, value !== null && value !== void 0 ? value : emptiedInputValue(c.event, x.control.schema));
22
24
  }
23
25
  export const getStringControlRendererTemplate = (prefix = 'zero') => html `
24
26
  <template>
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@genesislcap/foundation-forms",
3
3
  "description": "Genesis Foundation Forms",
4
- "version": "15.54.0",
4
+ "version": "15.55.0",
5
5
  "sideEffects": false,
6
6
  "license": "SEE LICENSE IN license.txt",
7
7
  "main": "dist/esm/index.js",
@@ -56,12 +56,12 @@
56
56
  }
57
57
  },
58
58
  "devDependencies": {
59
- "@genesislcap/foundation-testing": "15.54.0",
60
- "@genesislcap/genx": "15.54.0",
61
- "@genesislcap/ts-builder": "15.54.0",
62
- "@genesislcap/uvu-playwright-builder": "15.54.0",
63
- "@genesislcap/vite-builder": "15.54.0",
64
- "@genesislcap/webpack-builder": "15.54.0",
59
+ "@genesislcap/foundation-testing": "15.55.0",
60
+ "@genesislcap/genx": "15.55.0",
61
+ "@genesislcap/ts-builder": "15.55.0",
62
+ "@genesislcap/uvu-playwright-builder": "15.55.0",
63
+ "@genesislcap/vite-builder": "15.55.0",
64
+ "@genesislcap/webpack-builder": "15.55.0",
65
65
  "@types/json-schema": "^7.0.11",
66
66
  "@types/papaparse": "^5.3.14"
67
67
  },
@@ -78,12 +78,12 @@
78
78
  }
79
79
  },
80
80
  "dependencies": {
81
- "@genesislcap/foundation-comms": "15.54.0",
82
- "@genesislcap/foundation-criteria": "15.54.0",
83
- "@genesislcap/foundation-logger": "15.54.0",
84
- "@genesislcap/foundation-notifications": "15.54.0",
85
- "@genesislcap/foundation-ui": "15.54.0",
86
- "@genesislcap/foundation-utils": "15.54.0",
81
+ "@genesislcap/foundation-comms": "15.55.0",
82
+ "@genesislcap/foundation-criteria": "15.55.0",
83
+ "@genesislcap/foundation-logger": "15.55.0",
84
+ "@genesislcap/foundation-notifications": "15.55.0",
85
+ "@genesislcap/foundation-ui": "15.55.0",
86
+ "@genesislcap/foundation-utils": "15.55.0",
87
87
  "@json-schema-tools/dereferencer": "^1.6.1",
88
88
  "@jsonforms/core": "^3.2.1",
89
89
  "@microsoft/fast-components": "2.30.6",