pict-section-form 1.2.3 → 1.3.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.
Files changed (23) hide show
  1. package/eslint.config.mjs +2 -2
  2. package/package.json +7 -2
  3. package/source/providers/Pict-Provider-DynamicSolver.js +2 -0
  4. package/source/providers/Pict-Provider-Informary.js +22 -21
  5. package/source/providers/dynamictemplates/Pict-DynamicTemplates-DefaultFormTemplates-ReadOnly.js +10 -0
  6. package/source/providers/dynamictemplates/Pict-DynamicTemplates-DefaultFormTemplates.js +23 -0
  7. package/source/providers/inputs/Pict-Provider-Input-ObjectEditor.js +478 -0
  8. package/test/Pict-Provider-Informary-RenderSelector_tests.js +145 -0
  9. package/test/Pict-Provider-Informary_tests.js +111 -0
  10. package/test/PictSectionForm-Basic_tests.js +3 -0
  11. package/tsconfig.build.json +16 -0
  12. package/tsconfig.json +1 -1
  13. package/types/source/providers/Pict-Provider-DynamicTabularData.d.ts +33 -0
  14. package/types/source/providers/Pict-Provider-DynamicTabularData.d.ts.map +1 -1
  15. package/types/source/providers/Pict-Provider-Informary.d.ts +12 -13
  16. package/types/source/providers/Pict-Provider-Informary.d.ts.map +1 -1
  17. package/types/source/providers/layouts/Pict-Layout-Custom.d.ts.map +1 -1
  18. package/types/source/providers/layouts/Pict-Layout-Record.d.ts.map +1 -1
  19. package/types/source/providers/layouts/Pict-Layout-Tabular.d.ts +202 -0
  20. package/types/source/providers/layouts/Pict-Layout-Tabular.d.ts.map +1 -1
  21. package/types/source/providers/layouts/Pict-Layout-VerticalRecord.d.ts.map +1 -1
  22. package/types/source/services/ManifestFactory.d.ts +2 -1
  23. package/types/source/services/ManifestFactory.d.ts.map +1 -1
package/eslint.config.mjs CHANGED
@@ -3,8 +3,8 @@ import pluginJs from "@eslint/js";
3
3
 
4
4
 
5
5
  export default [
6
- { files: ["source/**"], languageOptions: { sourceType: "commonjs" } },
7
- { languageOptions: { globals: { ...globals.browser, ...globals.mocha, } } },
6
+ { files: ["source/**", "test/**"], languageOptions: { sourceType: "commonjs" } },
7
+ { languageOptions: { globals: { ...globals.browser, ...globals.mocha, ...globals.node, } } },
8
8
  pluginJs.configs.recommended,
9
9
  { rules: { "no-prototype-builtins": "off", "no-unused-vars": "warn", "no-case-declarations": "warn" } },
10
10
  ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pict-section-form",
3
- "version": "1.2.3",
3
+ "version": "1.3.0",
4
4
  "description": "Pict dynamic form sections",
5
5
  "main": "source/Pict-Section-Form.js",
6
6
  "directories": {
@@ -21,7 +21,8 @@
21
21
  "build": "npx quack build",
22
22
  "test": "npx quack test",
23
23
  "lint": "eslint source/**",
24
- "types": "tsc -p .",
24
+ "types": "tsc -p ./tsconfig.build.json",
25
+ "check": "tsc -p ./tsconfig.json --noEmit",
25
26
  "docker-dev-build": "docker build ./ -f Dockerfile_LUXURYCode -t pict-section-form-image:local",
26
27
  "docker-dev-run": "docker run -it -d --name pict-section-form-dev -p 48888:8080 -p 49999:9999 -v \"$PWD/.config:/home/coder/.config\" -v \"$PWD:/home/coder/pict-section-form\" -u \"$(id -u):$(id -g)\" -e \"DOCKER_USER=$USER\" pict-section-form-image:local",
27
28
  "docker-dev-shell": "docker exec -it pict-section-form-dev /bin/bash"
@@ -31,6 +32,9 @@
31
32
  "license": "MIT",
32
33
  "devDependencies": {
33
34
  "@eslint/js": "^9.39.2",
35
+ "@types/chai": "^4.3.20",
36
+ "@types/mocha": "^10.0.10",
37
+ "@types/node": "^22.19.21",
34
38
  "browser-env": "^3.3.0",
35
39
  "eslint": "^9.39.2",
36
40
  "jquery": "^4.0.0",
@@ -49,6 +53,7 @@
49
53
  "pict-provider": "^1.0.13",
50
54
  "pict-section-excalidraw": "^1.0.3",
51
55
  "pict-section-markdowneditor": "^1.0.19",
56
+ "pict-section-objecteditor": "^1.0.3",
52
57
  "pict-section-tuigrid": "^1.0.31",
53
58
  "pict-template": "^1.0.15",
54
59
  "pict-view": "^1.0.68"
@@ -19,6 +19,7 @@ const libInputLink = require('./inputs/Pict-Provider-Input-Link.js');
19
19
  const libInputTemplatedEntityLookup = require('./inputs/Pict-Provider-Input-TemplatedEntityLookup.js');
20
20
  const libInputChart = require('./inputs/Pict-Provider-Input-Chart.js');
21
21
  const libInputTabularTriggerGroup = require('./inputs/Pict-Provider-Input-TabularTriggerGroup.js');
22
+ const libInputObjectEditor = require('./inputs/Pict-Provider-Input-ObjectEditor.js');
22
23
 
23
24
  /** @type {Record<string, any>} */
24
25
  const _DefaultProviderConfiguration = (
@@ -82,6 +83,7 @@ class PictDynamicSolver extends libPictProvider
82
83
  this.pict.addProviderSingleton('Pict-Input-Link', libInputLink.default_configuration, libInputLink);
83
84
  this.pict.addProviderSingleton('Pict-Input-Chart', libInputChart.default_configuration, libInputChart);
84
85
  this.pict.addProviderSingleton('Pict-Input-TabularTriggerGroup', libInputTabularTriggerGroup.default_configuration, libInputTabularTriggerGroup);
86
+ this.pict.addProviderSingleton('Pict-Input-ObjectEditor', libInputObjectEditor.default_configuration, libInputObjectEditor);
85
87
  }
86
88
 
87
89
  logSolveOutcome(pSolveOutcome)
@@ -96,7 +96,7 @@ class PictDynamicFormsInformary extends libPictProvider
96
96
  *
97
97
  * @param {object} pAppStateData - The application state data object to marshal the form data to.
98
98
  * @param {string} pFormHash - The form hash representing the form elements.
99
- * @param {object} pManifest - The manifest object used to map form data to the application state data.
99
+ * @param {import('manyfest')} pManifest - The manifest object used to map form data to the application state data.
100
100
  * @param {string} [pDatum] - The datum hash to pull in. If not provided, all data is marshalled.
101
101
  * @param {number|string} [pRecordIndex] - The record index to pull in. If not provided, all data is marshalled.
102
102
  */
@@ -120,19 +120,19 @@ class PictDynamicFormsInformary extends libPictProvider
120
120
  * Marshals a specific form element's data to the application state data.
121
121
  *
122
122
  * @param {string} pFormHash - The hash of the form.
123
- * @param {HTMLElement} tmpFormElement - The form element to marshal.
124
- * @param {Object} tmpManifest - The manifest object to set values.
123
+ * @param {HTMLElement} pFormElement - The form element to marshal.
124
+ * @param {import('manyfest')} pManifest - The manifest object to set values.
125
125
  * @param {Object} pAppStateData - The application state data object.
126
126
  * @param {any} [pDatumFilter] - Optional filter for datum address.
127
127
  * @param {any} [pRecordIndexFilter] - Optional filter for record index.
128
128
  * @returns {boolean} - Returns false if the element falls outside the filters or if the browser value is null.
129
129
  */
130
- marshalSpecicificFormElementToData(pFormHash, tmpFormElement, tmpManifest, pAppStateData, pDatumFilter, pRecordIndexFilter)
130
+ marshalSpecicificFormElementToData(pFormHash, pFormElement, pManifest, pAppStateData, pDatumFilter, pRecordIndexFilter)
131
131
  {
132
- const tmpDatumAddress = tmpFormElement.getAttribute('data-i-datum');
132
+ const tmpDatumAddress = pFormElement.getAttribute('data-i-datum');
133
133
 
134
- const tmpContainerAddress = tmpFormElement.getAttribute('data-i-container');
135
- const tmpIndex = tmpFormElement.getAttribute('data-i-index');
134
+ const tmpContainerAddress = pFormElement.getAttribute('data-i-container');
135
+ const tmpIndex = pFormElement.getAttribute('data-i-index');
136
136
 
137
137
  // Process the filters
138
138
  // TODO: Now that this is a function, having these filters here is not good. We need to move this to the caller. But the above getAttribute is required... rethink filtering?
@@ -160,13 +160,14 @@ class PictDynamicFormsInformary extends libPictProvider
160
160
 
161
161
  if (!tmpContainerAddress)
162
162
  {
163
- tmpManifest.setValueAtAddress(pAppStateData, tmpDatumAddress, tmpBrowserValue);
163
+ pManifest.setValueAtAddress(pAppStateData, tmpDatumAddress, tmpBrowserValue);
164
164
  }
165
165
  else
166
166
  {
167
167
  // Compose the address .. right now only arrays
168
- tmpManifest.setValueAtAddress(pAppStateData, this.getComposedContainerAddress(tmpContainerAddress, tmpIndex, tmpDatumAddress), tmpBrowserValue);
169
- }
168
+ pManifest.setValueAtAddress(pAppStateData, this.getComposedContainerAddress(tmpContainerAddress, tmpIndex, tmpDatumAddress), tmpBrowserValue);
169
+ }
170
+ return true;
170
171
  }
171
172
 
172
173
  /**
@@ -174,7 +175,7 @@ class PictDynamicFormsInformary extends libPictProvider
174
175
  *
175
176
  * @param {object} pAppStateData - The application state data to marshal into the form. Usually AppData but can be other objects.
176
177
  * @param {string} pFormHash - The hash of the form to marshal data into. This is the data-i-form attribute.
177
- * @param {object} pManifest - The manifest object. If not provided, the generic manifest is used.
178
+ * @param {import('manyfest')} pManifest - The manifest object. If not provided, the generic manifest is used.
178
179
  */
179
180
  marshalDataToForm(pAppStateData, pFormHash, pManifest)
180
181
  {
@@ -185,20 +186,19 @@ class PictDynamicFormsInformary extends libPictProvider
185
186
  // Enumerate the form elements, and put data in them for each address
186
187
  for (let i = 0; i < tmpFormElements.length; i++)
187
188
  {
188
- this.marshalSpecificElementDataToForm(pFormHash, tmpFormElements[i], tmpManifest, pAppStateData);
189
+ this.marshalSpecificElementDataToForm(tmpFormElements[i], tmpManifest, pAppStateData);
189
190
  }
190
191
  }
191
192
 
192
193
  /**
193
194
  * Marshals specific element data to a form.
194
195
  *
195
- * @param {string} pFormHash - The hash of the form.
196
196
  * @param {HTMLElement} pFormElement - The form element to marshal data to.
197
- * @param {Object} tmpManifest - The manifest object containing data retrieval methods.
198
- * @param {Object} pAppStateData - The application state data.
197
+ * @param {import('manyfest')} pManifest - The manifest object containing data retrieval methods.
198
+ * @param {Record<string, any>} pAppStateData - The application state data.
199
199
  * @returns {boolean} Returns false if the form element does not have a datum address.
200
200
  */
201
- marshalSpecificElementDataToForm(pFormHash, pFormElement, tmpManifest, pAppStateData)
201
+ marshalSpecificElementDataToForm(pFormElement, pManifest, pAppStateData)
202
202
  {
203
203
  let tmpDatumAddress = pFormElement.getAttribute('data-i-datum');
204
204
 
@@ -213,7 +213,7 @@ class PictDynamicFormsInformary extends libPictProvider
213
213
 
214
214
  if (!tmpContainerAddress)
215
215
  {
216
- let tmpAppStateValue = tmpManifest.getValueAtAddress(pAppStateData, tmpDatumAddress);
216
+ let tmpAppStateValue = pManifest.getValueAtAddress(pAppStateData, tmpDatumAddress);
217
217
 
218
218
  if (this.pict.LogNoisiness > 3)
219
219
  {
@@ -222,12 +222,12 @@ class PictDynamicFormsInformary extends libPictProvider
222
222
 
223
223
  if (tmpAppStateValue != null)
224
224
  {
225
- this.pict.ContentAssignment.assignContent(this.getContentBrowserAddress(pFormHash, tmpDatumAddress, tmpContainerAddress, tmpIndex), tmpAppStateValue);
225
+ this.pict.ContentAssignment.assignContent(pFormElement, tmpAppStateValue);
226
226
  }
227
227
  }
228
228
  else
229
229
  {
230
- let tmpAppStateValue = tmpManifest.getValueAtAddress(pAppStateData, this.getComposedContainerAddress(tmpContainerAddress, tmpIndex, tmpDatumAddress));
230
+ let tmpAppStateValue = pManifest.getValueAtAddress(pAppStateData, this.getComposedContainerAddress(tmpContainerAddress, tmpIndex, tmpDatumAddress));
231
231
 
232
232
  if (this.pict.LogNoisiness > 3)
233
233
  {
@@ -236,14 +236,15 @@ class PictDynamicFormsInformary extends libPictProvider
236
236
 
237
237
  if (tmpAppStateValue != null)
238
238
  {
239
- this.pict.ContentAssignment.assignContent(this.getContentBrowserAddress(pFormHash, tmpDatumAddress, tmpContainerAddress, tmpIndex), tmpAppStateValue);
239
+ this.pict.ContentAssignment.assignContent(pFormElement, tmpAppStateValue);
240
240
  }
241
241
  }
242
+ return true;
242
243
  }
243
244
 
244
245
  /**
245
246
  * Manually marshals data to a form by assigning content based on context in the descriptor.
246
- * @param {object} pInput - The input manifest descriptor to marshal data to form from.
247
+ * @param {Record<string, any>} pInput - The input manifest descriptor to marshal data to form from.
247
248
  * @returns boolean if assignment was successful
248
249
  */
249
250
  manualMarshalDataToFormByInput(pInput)
@@ -186,6 +186,16 @@ Glug glug glug Oo... -->
186
186
  <!-- DataType DateTime {~D:Record.Hash~} {~D:Record.DataType~} -->
187
187
  <input disabled type="hidden" {~D:Record.Macro.InputFullProperties~} value="">
188
188
  <span>{~D:Record.Name~}:</span> <input disabled {~D:Record.Macro.ControlAttr~} id="DATETIME-INPUT-FOR-{~D:Record.Macro.RawHTMLID~}" onchange="{~D:Record.Macro.DataRequestFunction~}" type="datetime-local" value="" />
189
+ `
190
+ },
191
+ {
192
+ "HashPostfix": "-Template-Input-InputType-ObjectEditor",
193
+ "DefaultInputExtensions": ["Pict-Input-ObjectEditor"],
194
+ "Template": /*HTML*/`
195
+ <!-- InputType ObjectEditor {~D:Record.Hash~} {~D:Record.DataType~} -->
196
+ <input disabled type="hidden" {~D:Record.Macro.InputFullProperties~} {~D:Record.Macro.InputChangeHandler~} value="">
197
+ <span>{~D:Record.Name~}:</span>
198
+ <div {~D:Record.Macro.ControlAttr~} id="DISPLAY-FOR-{~D:Record.Macro.RawHTMLID~}" class="pict-section-form-objecteditor pict-section-form-objecteditor-readonly"></div>
189
199
  `
190
200
  },
191
201
  /*
@@ -324,6 +324,16 @@ Glug glug glug Oo... -->
324
324
  <input type="hidden" {~D:Record.Macro.InputFullProperties~} {~D:Record.Macro.InputChangeHandler~} value="">
325
325
  <span>{~D:Record.Name~}:</span>
326
326
  <div {~D:Record.Macro.ControlAttr~} id="DISPLAY-FOR-{~D:Record.Macro.RawHTMLID~}" class="pict-section-form-diagram"></div>
327
+ `
328
+ },
329
+ {
330
+ "HashPostfix": "-Template-Input-InputType-ObjectEditor",
331
+ "DefaultInputExtensions": ["Pict-Input-ObjectEditor"],
332
+ "Template": /*HTML*/`
333
+ <!-- InputType ObjectEditor {~D:Record.Hash~} {~D:Record.DataType~} -->
334
+ <input type="hidden" {~D:Record.Macro.InputFullProperties~} {~D:Record.Macro.InputChangeHandler~} value="">
335
+ <span>{~D:Record.Name~}:</span>
336
+ <div {~D:Record.Macro.ControlAttr~} id="DISPLAY-FOR-{~D:Record.Macro.RawHTMLID~}" class="pict-section-form-objecteditor"></div>
327
337
  `
328
338
  },
329
339
  /*
@@ -555,6 +565,19 @@ Glug glug glug Oo... -->
555
565
  <span>{~D:Record.PictForm.ExtraDescription~}</span>
556
566
  <div {~D:Record.Macro.ControlAttr~} id="DISPLAY-FOR-{~D:Record.Macro.RawHTMLID~}" class="pict-section-form-diagram"></div>
557
567
  </div>
568
+ `
569
+ },
570
+ {
571
+ "HashPostfix": "-VerticalTemplate-Input-InputType-ObjectEditor",
572
+ "DefaultInputExtensions": ["Pict-Input-ObjectEditor"],
573
+ "Template": /*HTML*/`
574
+ <!-- InputType ObjectEditor {~D:Record.Hash~} {~D:Record.DataType~} -->
575
+ <div class="pict-form-vertical-input">
576
+ <input type="hidden" {~D:Record.Macro.InputFullProperties~} {~D:Record.Macro.InputChangeHandler~} value="">
577
+ <label class="pict-form-label">{~D:Record.Name~}</label>
578
+ <span>{~D:Record.PictForm.ExtraDescription~}</span>
579
+ <div {~D:Record.Macro.ControlAttr~} id="DISPLAY-FOR-{~D:Record.Macro.RawHTMLID~}" class="pict-section-form-objecteditor"></div>
580
+ </div>
558
581
  `
559
582
  },
560
583
  /*