@genesislcap/foundation-forms 15.3.4 → 15.4.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.
@@ -1,5 +1,17 @@
1
1
  import { RendererEntry } from '../../types';
2
2
  import { DispatchRenderer } from './dispatch-renderer';
3
+ /**
4
+ * Computes the `<input type="date"|"datetime-local">` text value for a control's stored epoch.
5
+ *
6
+ * A date-only value ("YYYY-MM-DD", written back via `new Date(inputValue)` below) is parsed as
7
+ * UTC midnight per spec, but a datetime-local value ("YYYY-MM-DDTHH:MM") is parsed as local
8
+ * time. Reading a DATE control's stored epoch back with local getters disagrees with that UTC
9
+ * write, shifting the displayed day by one for any negative UTC offset — so DATE reads via UTC
10
+ * getters to match, while DATETIME (a true instant, correctly local on both ends) keeps local
11
+ * getters.
12
+ * @internal
13
+ */
14
+ export declare function formatDateControlValue(control: any): string;
3
15
  export declare const DateControlRendererTemplate: (prefix?: string) => import("@microsoft/fast-element").ViewTemplate<DispatchRenderer, any>;
4
16
  export declare const DateControlRendererEntry: RendererEntry;
5
17
  //# 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,eAAO,MAAM,2BAA2B,GAAI,SAAQ,MAAe,0EA6ClE,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,eAAO,MAAM,2BAA2B,GAAI,SAAQ,MAAe,0EA8BlE,CAAC;AAEF,eAAO,MAAM,wBAAwB,EAAE,aAMtC,CAAC"}
@@ -17,25 +17,38 @@ const typeSwitch = (control) => {
17
17
  }
18
18
  return ((_b = control.schema) === null || _b === void 0 ? void 0 : _b.genesisType) === GenesisType.DATETIME ? 'datetime-local' : 'date';
19
19
  };
20
+ /**
21
+ * Computes the `<input type="date"|"datetime-local">` text value for a control's stored epoch.
22
+ *
23
+ * A date-only value ("YYYY-MM-DD", written back via `new Date(inputValue)` below) is parsed as
24
+ * UTC midnight per spec, but a datetime-local value ("YYYY-MM-DDTHH:MM") is parsed as local
25
+ * time. Reading a DATE control's stored epoch back with local getters disagrees with that UTC
26
+ * write, shifting the displayed day by one for any negative UTC offset — so DATE reads via UTC
27
+ * getters to match, while DATETIME (a true instant, correctly local on both ends) keeps local
28
+ * getters.
29
+ * @internal
30
+ */
31
+ export function formatDateControlValue(control) {
32
+ if (!control.data)
33
+ return '';
34
+ const type = typeSwitch(control);
35
+ const date = new Date(control.data);
36
+ const padded = (dateComponent) => dateComponent.toString().padStart(2, '0');
37
+ const isDateOnly = type !== 'datetime-local';
38
+ const year = isDateOnly ? date.getUTCFullYear() : date.getFullYear();
39
+ const month = padded((isDateOnly ? date.getUTCMonth() : date.getMonth()) + 1);
40
+ const day = padded(isDateOnly ? date.getUTCDate() : date.getDate());
41
+ const hour = padded(date.getHours());
42
+ const minute = padded(date.getMinutes());
43
+ return `${year}-${month}-${day}` + (type === 'datetime-local' ? `T${hour}:${minute}` : '');
44
+ }
20
45
  export const DateControlRendererTemplate = (prefix = 'zero') => html `
21
46
  <template>
22
47
  ${controlWrapperTemplate({
23
48
  prefix,
24
49
  innerTemplate: html `
25
50
  <${prefix}-text-field
26
- :value=${(x) => {
27
- if (!x.control.data)
28
- return '';
29
- const type = typeSwitch(x.control);
30
- const date = new Date(x.control.data);
31
- const padded = (dateComponent) => dateComponent.toString().padStart(2, '0');
32
- const year = date.getFullYear();
33
- const month = padded(date.getMonth() + 1);
34
- const day = padded(date.getDate());
35
- const hour = padded(date.getHours());
36
- const minute = padded(date.getMinutes());
37
- return (`${year}-${month}-${day}` + (type === 'datetime-local' ? `T${hour}:${minute}` : ''));
38
- }}
51
+ :value=${(x) => formatDateControlValue(x.control)}
39
52
  id=${(x) => x.control.path}
40
53
  type="${(x) => typeSwitch(x.control)}"
41
54
  data-test-id=${(x) => x.control.path}
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.3.4",
4
+ "version": "15.4.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.3.4",
63
- "@genesislcap/genx": "15.3.4",
64
- "@genesislcap/rollup-builder": "15.3.4",
65
- "@genesislcap/ts-builder": "15.3.4",
66
- "@genesislcap/uvu-playwright-builder": "15.3.4",
67
- "@genesislcap/vite-builder": "15.3.4",
68
- "@genesislcap/webpack-builder": "15.3.4",
62
+ "@genesislcap/foundation-testing": "15.4.0",
63
+ "@genesislcap/genx": "15.4.0",
64
+ "@genesislcap/rollup-builder": "15.4.0",
65
+ "@genesislcap/ts-builder": "15.4.0",
66
+ "@genesislcap/uvu-playwright-builder": "15.4.0",
67
+ "@genesislcap/vite-builder": "15.4.0",
68
+ "@genesislcap/webpack-builder": "15.4.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.3.4",
86
- "@genesislcap/foundation-criteria": "15.3.4",
87
- "@genesislcap/foundation-logger": "15.3.4",
88
- "@genesislcap/foundation-notifications": "15.3.4",
89
- "@genesislcap/foundation-ui": "15.3.4",
90
- "@genesislcap/foundation-utils": "15.3.4",
85
+ "@genesislcap/foundation-comms": "15.4.0",
86
+ "@genesislcap/foundation-criteria": "15.4.0",
87
+ "@genesislcap/foundation-logger": "15.4.0",
88
+ "@genesislcap/foundation-notifications": "15.4.0",
89
+ "@genesislcap/foundation-ui": "15.4.0",
90
+ "@genesislcap/foundation-utils": "15.4.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",
@@ -109,5 +109,5 @@
109
109
  "access": "public"
110
110
  },
111
111
  "customElements": "dist/custom-elements.json",
112
- "gitHead": "191a57bd28a112b5cd2b282a9c0dbb8c8b689617"
112
+ "gitHead": "2c61100a9805e799c8047a26ad6a147d1ac1af87"
113
113
  }