@genesislcap/foundation-forms 15.22.2 → 15.23.1-alpha-b23a0275e.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.
@@ -3024,6 +3024,37 @@
3024
3024
  "kind": "javascript-module",
3025
3025
  "path": "src/jsonforms/renderers/ConnectedSelectControlRenderer.ts",
3026
3026
  "declarations": [
3027
+ {
3028
+ "kind": "function",
3029
+ "name": "shouldReuseDisplayedValue",
3030
+ "return": {
3031
+ "type": {
3032
+ "text": "boolean"
3033
+ }
3034
+ },
3035
+ "parameters": [
3036
+ {
3037
+ "name": "currentValue",
3038
+ "type": {
3039
+ "text": "unknown"
3040
+ }
3041
+ },
3042
+ {
3043
+ "name": "previousRawValue",
3044
+ "type": {
3045
+ "text": "unknown"
3046
+ }
3047
+ },
3048
+ {
3049
+ "name": "displayedValue",
3050
+ "type": {
3051
+ "text": "string | undefined"
3052
+ }
3053
+ }
3054
+ ],
3055
+ "description": "Whether a freshly recomputed fallback should be discarded in favour of whatever the\ncombobox is already displaying.",
3056
+ "privacy": "public"
3057
+ },
3027
3058
  {
3028
3059
  "kind": "function",
3029
3060
  "name": "ConnectedSelectControlRendererTemplate",
@@ -3047,6 +3078,14 @@
3047
3078
  }
3048
3079
  ],
3049
3080
  "exports": [
3081
+ {
3082
+ "kind": "js",
3083
+ "name": "shouldReuseDisplayedValue",
3084
+ "declaration": {
3085
+ "name": "shouldReuseDisplayedValue",
3086
+ "module": "src/jsonforms/renderers/ConnectedSelectControlRenderer.ts"
3087
+ }
3088
+ },
3050
3089
  {
3051
3090
  "kind": "js",
3052
3091
  "name": "ConnectedSelectControlRendererTemplate",
@@ -1,4 +1,15 @@
1
1
  import { DispatchRenderer } from './dispatch-renderer';
2
+ /**
3
+ * Whether a freshly recomputed fallback should be discarded in favour of whatever the
4
+ * combobox is already displaying.
5
+ * @remarks
6
+ * True only when the raw stored value hasn't changed since we last computed a value for
7
+ * this control *and* the combobox currently has something displayed - i.e. this is a
8
+ * re-render triggered by an unrelated field elsewhere in the form, not a genuine change to
9
+ * this control's own value.
10
+ * @public exported for testing
11
+ */
12
+ export declare const shouldReuseDisplayedValue: (currentValue: unknown, previousRawValue: unknown, displayedValue: string | undefined) => boolean;
2
13
  export declare const ConnectedSelectControlRendererTemplate: (prefix?: string) => import("@microsoft/fast-element").ViewTemplate<DispatchRenderer, any>;
3
14
  export declare const ConnectedSelectControlRendererEntry: any;
4
15
  //# sourceMappingURL=ConnectedSelectControlRenderer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ConnectedSelectControlRenderer.d.ts","sourceRoot":"","sources":["../../../../src/jsonforms/renderers/ConnectedSelectControlRenderer.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAmBvD,eAAO,MAAM,sCAAsC,GACjD,SAAQ,MAAe,0EA6CxB,CAAC;AAEF,eAAO,MAAM,mCAAmC,EAAE,GAMjD,CAAC"}
1
+ {"version":3,"file":"ConnectedSelectControlRenderer.d.ts","sourceRoot":"","sources":["../../../../src/jsonforms/renderers/ConnectedSelectControlRenderer.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAKvD;;;;;;;;;GASG;AACH,eAAO,MAAM,yBAAyB,GACpC,cAAc,OAAO,EACrB,kBAAkB,OAAO,EACzB,gBAAgB,MAAM,GAAG,SAAS,KACjC,OAAgE,CAAC;AAsCpE,eAAO,MAAM,sCAAsC,GACjD,SAAQ,MAAe,0EA6CxB,CAAC;AAEF,eAAO,MAAM,mCAAmC,EAAE,GAMjD,CAAC"}
@@ -6,6 +6,18 @@ import { optionIs } from '../testers/optionIs';
6
6
  import { controlWrapperTemplate } from './ControlWrapperRenderer';
7
7
  import { SELECT_CONTROL_RANK } from './RenderersRanks';
8
8
  OptionsDatasource;
9
+ /**
10
+ * Whether a freshly recomputed fallback should be discarded in favour of whatever the
11
+ * combobox is already displaying.
12
+ * @remarks
13
+ * True only when the raw stored value hasn't changed since we last computed a value for
14
+ * this control *and* the combobox currently has something displayed - i.e. this is a
15
+ * re-render triggered by an unrelated field elsewhere in the form, not a genuine change to
16
+ * this control's own value.
17
+ * @public exported for testing
18
+ */
19
+ export const shouldReuseDisplayedValue = (currentValue, previousRawValue, displayedValue) => previousRawValue === currentValue && !!displayedValue;
20
+ const lastRawValueByRenderer = new WeakMap();
9
21
  /**
10
22
  * Gets the display value for the connected select control
11
23
  * @param dispatchRenderer - The dispatch renderer instance
@@ -16,9 +28,25 @@ const getConnectedSelectDisplayValue = (dispatchRenderer) => {
16
28
  const currentValue = dispatchRenderer.control.data;
17
29
  if (!currentValue)
18
30
  return '';
19
- const options = ((_a = dispatchRenderer.control.uischema.options) === null || _a === void 0 ? void 0 : _a.data) || [];
20
- const option = options.find((opt) => opt.value === currentValue);
21
- return String((option === null || option === void 0 ? void 0 : option.label) || currentValue);
31
+ const options = (_a = dispatchRenderer.control.uischema.options) === null || _a === void 0 ? void 0 : _a.data;
32
+ if (options) {
33
+ const option = options.find((opt) => opt.value === currentValue);
34
+ return String((option === null || option === void 0 ? void 0 : option.label) || currentValue);
35
+ }
36
+ // No static option list (e.g. allOptionsResourceName-backed controls): the sibling
37
+ // <options-datasource> resolves the display label asynchronously once its data loads
38
+ // (see OptionsDatasource.syncComponentData, which sets the combobox's value directly).
39
+ // This binding re-evaluates on every unrelated form field change - any JSONForms dispatch
40
+ // replaces `control` with a new object - which would otherwise stomp that resolved label
41
+ // back to the raw stored value on every such re-render, since nothing here previously
42
+ // guarded against it.
43
+ const previousRawValue = lastRawValueByRenderer.get(dispatchRenderer);
44
+ const combobox = dispatchRenderer.querySelector(`#${CSS.escape(dispatchRenderer.control.path)}`);
45
+ if (shouldReuseDisplayedValue(currentValue, previousRawValue, combobox === null || combobox === void 0 ? void 0 : combobox.value)) {
46
+ return combobox.value;
47
+ }
48
+ lastRawValueByRenderer.set(dispatchRenderer, currentValue);
49
+ return String(currentValue);
22
50
  };
23
51
  export const ConnectedSelectControlRendererTemplate = (prefix = 'zero') => html `
24
52
  <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.22.2",
4
+ "version": "15.23.1-alpha-b23a0275e.0",
5
5
  "sideEffects": false,
6
6
  "license": "SEE LICENSE IN license.txt",
7
7
  "main": "dist/esm/index.js",
@@ -59,13 +59,13 @@
59
59
  }
60
60
  },
61
61
  "devDependencies": {
62
- "@genesislcap/foundation-testing": "15.22.2",
63
- "@genesislcap/genx": "15.22.2",
64
- "@genesislcap/rollup-builder": "15.22.2",
65
- "@genesislcap/ts-builder": "15.22.2",
66
- "@genesislcap/uvu-playwright-builder": "15.22.2",
67
- "@genesislcap/vite-builder": "15.22.2",
68
- "@genesislcap/webpack-builder": "15.22.2",
62
+ "@genesislcap/foundation-testing": "15.23.1-alpha-b23a0275e.0",
63
+ "@genesislcap/genx": "15.23.1-alpha-b23a0275e.0",
64
+ "@genesislcap/rollup-builder": "15.23.1-alpha-b23a0275e.0",
65
+ "@genesislcap/ts-builder": "15.23.1-alpha-b23a0275e.0",
66
+ "@genesislcap/uvu-playwright-builder": "15.23.1-alpha-b23a0275e.0",
67
+ "@genesislcap/vite-builder": "15.23.1-alpha-b23a0275e.0",
68
+ "@genesislcap/webpack-builder": "15.23.1-alpha-b23a0275e.0",
69
69
  "@types/json-schema": "^7.0.11",
70
70
  "@types/papaparse": "^5.3.14"
71
71
  },
@@ -82,12 +82,12 @@
82
82
  }
83
83
  },
84
84
  "dependencies": {
85
- "@genesislcap/foundation-comms": "15.22.2",
86
- "@genesislcap/foundation-criteria": "15.22.2",
87
- "@genesislcap/foundation-logger": "15.22.2",
88
- "@genesislcap/foundation-notifications": "15.22.2",
89
- "@genesislcap/foundation-ui": "15.22.2",
90
- "@genesislcap/foundation-utils": "15.22.2",
85
+ "@genesislcap/foundation-comms": "15.23.1-alpha-b23a0275e.0",
86
+ "@genesislcap/foundation-criteria": "15.23.1-alpha-b23a0275e.0",
87
+ "@genesislcap/foundation-logger": "15.23.1-alpha-b23a0275e.0",
88
+ "@genesislcap/foundation-notifications": "15.23.1-alpha-b23a0275e.0",
89
+ "@genesislcap/foundation-ui": "15.23.1-alpha-b23a0275e.0",
90
+ "@genesislcap/foundation-utils": "15.23.1-alpha-b23a0275e.0",
91
91
  "@json-schema-tools/dereferencer": "^1.6.1",
92
92
  "@jsonforms/core": "^3.2.1",
93
93
  "@microsoft/fast-components": "2.30.6",