@es-joy/jsoe 0.4.3 → 0.4.5
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/CHANGES.md +8 -0
- package/dist/types.d.ts +470 -349
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/fundamentalTypes/objectReferenceType.js +10 -10
- package/src/fundamentalTypes/objectType.js +6 -6
- package/src/types.js +171 -141
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.js"],"names":[],"mappings":"AAsCO,mDAHI,iBAAiB,GACf,MAAM,CAmBlB
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.js"],"names":[],"mappings":"AAsCO,mDAHI,iBAAiB,GACf,MAAM,CAmBlB;;;;;oCAKW,WAAW,YACV,MAAM,GAAC,SAAS,GAAC,IAAI;;;;;qCAOvB,WAAW,2EAGT,oBAAoB;;;;2CAMtB,WAAW,KACT,IAAI,GAChB,gBAAoB,GAAC,mBAAmB,GAAC,iBAAiB,GAAC,iBAAiB;;;;iDAMlE,MAAM,GAAC,OAAO,YACd,WAAW,KACT,oBAAoB;uDAKtB,MAAM,GAAC,OAAO,KACZ,IAAI,GAAC,gBAAgB,GAAC,mBAAmB,GAAC,iBAAiB,GACvE,iBAAqB;iDAKX,MAAM,iCAEJ,aAAa,EAAE,GAAC,SAAS;sCAK3B,aAAa,KACX,CAAC,MAAM,EAAE;IAAC,KAAK,EAAE,aAAa,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAC,CAAC;uDAKlD,MAAM,uCAEJ,CAAC,MAAM,EAAE;IAAC,KAAK,EAAE,aAAa,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAC,CAAC,EAAE;wCAK5C;IAClB,QAAY,CAAC,EAAE,OAAO,CAAC;IACvB,UAAc,CAAC,EAAE,MAAM,GA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oBAAW,IAAI;;;mBAAnB,IAAI;;oBAAW,IAAI;;;mBAAnB,IAAI;;oBAAW,IAAI;;;mBAAnB,IAAI;;oBAAW,IAAI;;;mBAAnB,IAAI;;oBAAW,IAAI;;;mBAAnB,IAAI;;oBAAW,IAAI;;;mBAAnB,IAAI;;oBAAW,IAAI;;;mBAAnB,IAAI;;oBAAW,IAAI;;;mBAAnB,IAAI;;oBAAW,IAAI;;;mBAAnB,IAAI;;oBAAW,IAAI;;;mBAAnB,IAAI;;oBAAW,IAAI;;;mBAAnB,IAAI;;oBAAW,IAAI;;;mBAAnB,IAAI;;oBAAW,IAAI;;;mBAAnB,IAAI;;oBAAW,IAAI;;;mBAAnB,IAAI;;oBAAW,IAAI;;;mBAAnB,IAAI;;oBAAW,IAAI;;;mBAAnB,IAAI;;oBAAW,IAAI;;;mBAAnB,IAAI;;oBAAW,IAAI;;;mBAAnB,IAAI;;oBAAW,IAAI;;;mBAAnB,IAAI;;oBAAW,IAAI;;;mBAAnB,IAAI;;oBAAW,IAAI;;;mBAAnB,IAAI;;oBAAW,IAAI;;;mBAAnB,IAAI;;oBAAW,IAAI;;;mBAAnB,IAAI;;oBAAW,IAAI;;;oBAEf,cAAc;qBACb,eAAe;2BACT,qBAAqB;8BAClB,wBAAwB;oCAClB,8BAA8B;+BACnC,yBAAyB;sBAClC,gBAAgB;qCACD,+BAA+B;yBAC3C,mBAAmB;;;;sBAGd,aAAa;uBAAS,aAAa;;;;oBAG7C,cAAc;2BACP,qBAAqB;cAClC,QAAQ;cACR,QAAQ;uBACC,iBAAiB;;EAIxB"}
|
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import arrayReferenceType from './arrayReferenceType.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* @type {import('../types.js').TypeObject & {type: string}}
|
|
@@ -8,10 +8,10 @@ const objectReferenceType = {
|
|
|
8
8
|
type: 'object',
|
|
9
9
|
stringRegex: /^objectRef\((?:|\/[^)]*)\)$/u,
|
|
10
10
|
toValue (...args) {
|
|
11
|
-
return
|
|
11
|
+
return arrayReferenceType.toValue.apply(this, args);
|
|
12
12
|
},
|
|
13
13
|
resolveReference (...args) {
|
|
14
|
-
return
|
|
14
|
+
return arrayReferenceType.resolveReference?.apply(
|
|
15
15
|
this, args
|
|
16
16
|
);
|
|
17
17
|
},
|
|
@@ -26,27 +26,27 @@ const objectReferenceType = {
|
|
|
26
26
|
}
|
|
27
27
|
},
|
|
28
28
|
getInput (...args) {
|
|
29
|
-
return
|
|
29
|
+
return arrayReferenceType.getInput.apply(this, args);
|
|
30
30
|
},
|
|
31
31
|
setValue (...args) {
|
|
32
|
-
return
|
|
32
|
+
return arrayReferenceType.setValue?.apply(this, args);
|
|
33
33
|
},
|
|
34
34
|
getValue (...args) {
|
|
35
|
-
return
|
|
35
|
+
return arrayReferenceType.getValue.apply(this, args);
|
|
36
36
|
},
|
|
37
37
|
validate (...args) {
|
|
38
38
|
return /** @type {{message?: string | undefined; valid: boolean;}} */ (
|
|
39
|
-
|
|
39
|
+
arrayReferenceType.validate?.apply(this, args)
|
|
40
40
|
);
|
|
41
41
|
},
|
|
42
42
|
validateAll (...args) {
|
|
43
|
-
return
|
|
43
|
+
return arrayReferenceType.validateAll?.apply(this, args);
|
|
44
44
|
},
|
|
45
45
|
viewUI (...args) {
|
|
46
|
-
return
|
|
46
|
+
return arrayReferenceType.viewUI.apply(this, args);
|
|
47
47
|
},
|
|
48
48
|
editUI (...args) {
|
|
49
|
-
return
|
|
49
|
+
return arrayReferenceType.editUI.apply(this, args);
|
|
50
50
|
}
|
|
51
51
|
};
|
|
52
52
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import arrayType from './arrayType.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* @type {import('../types.js').TypeObject}
|
|
@@ -9,19 +9,19 @@ const objectType = {
|
|
|
9
9
|
stringRegexBegin: /^\{/u,
|
|
10
10
|
stringRegexEnd: /^\}/u,
|
|
11
11
|
toValue (...args) {
|
|
12
|
-
return
|
|
12
|
+
return arrayType.toValue.apply(this, args);
|
|
13
13
|
},
|
|
14
14
|
getValue (...args) {
|
|
15
|
-
return
|
|
15
|
+
return arrayType.getValue.apply(this, args);
|
|
16
16
|
},
|
|
17
17
|
getInput (...args) {
|
|
18
|
-
return
|
|
18
|
+
return arrayType.getInput.apply(this, args);
|
|
19
19
|
},
|
|
20
20
|
viewUI (...args) {
|
|
21
|
-
return
|
|
21
|
+
return arrayType.viewUI.apply(this, args);
|
|
22
22
|
},
|
|
23
23
|
editUI ({...args}) {
|
|
24
|
-
return
|
|
24
|
+
return arrayType.editUI.call(this, {
|
|
25
25
|
...args, type: 'object'
|
|
26
26
|
});
|
|
27
27
|
}
|
package/src/types.js
CHANGED
|
@@ -55,6 +55,172 @@ export const getPropertyValueFromLegend = (legend) => {
|
|
|
55
55
|
return String(Number.parseInt(propElem.textContent) - 1);
|
|
56
56
|
};
|
|
57
57
|
|
|
58
|
+
/**
|
|
59
|
+
* Utility to retrieve the type out of a type root element.
|
|
60
|
+
* @callback GetTypeForRoot
|
|
61
|
+
* @param {?RootElement} root
|
|
62
|
+
* @returns {string|undefined|null} Why would it not exist?
|
|
63
|
+
*/
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Utility to get the value out of a type root element with a given
|
|
67
|
+
* state and path.
|
|
68
|
+
* @callback GetValueForRoot
|
|
69
|
+
* @param {RootElement} root
|
|
70
|
+
* @param {StateObject} [stateObj]
|
|
71
|
+
* @param {string} [currentPath]
|
|
72
|
+
* @returns {StructuredCloneValue}
|
|
73
|
+
*/
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Utility to get the form control (e.g., input element) for a root.
|
|
77
|
+
* @callback GetFormControlForRoot
|
|
78
|
+
* @param {RootElement} root
|
|
79
|
+
* @returns {null|
|
|
80
|
+
* HTMLInputElement|HTMLTextAreaElement|HTMLSelectElement|HTMLButtonElement}
|
|
81
|
+
*/
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Utility to get the value for a root using its ancestor and state.
|
|
85
|
+
* @callback GetValueFromRootAncestor
|
|
86
|
+
* @param {string|Element} selOrEl
|
|
87
|
+
* @param {StateObject} stateObj
|
|
88
|
+
* @returns {StructuredCloneValue}
|
|
89
|
+
*/
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* @callback GetFormControlFromRootAncestor
|
|
93
|
+
* @param {string|Element} selOrEl
|
|
94
|
+
* @returns {null|HTMLInputElement|HTMLTextAreaElement|HTMLSelectElement|
|
|
95
|
+
* HTMLButtonElement}
|
|
96
|
+
*/
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* @callback GetTypesForFormatAndState
|
|
100
|
+
* @param {string} format
|
|
101
|
+
* @param {string} [state]
|
|
102
|
+
* @returns {AvailableType[]|undefined}
|
|
103
|
+
*/
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* @callback GetOptionForType
|
|
107
|
+
* @param {AvailableType} type
|
|
108
|
+
* @returns {[string, {value: AvailableType, title?: string}]}
|
|
109
|
+
*/
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* @callback GetTypeOptionsForFormatAndState
|
|
113
|
+
* @param {string} format
|
|
114
|
+
* @param {string} [parserState]
|
|
115
|
+
* @returns {[string, {value: AvailableType, title?: string}][]}
|
|
116
|
+
*/
|
|
117
|
+
|
|
118
|
+
/* eslint-disable jsdoc/valid-types -- readonly reserved */
|
|
119
|
+
/**
|
|
120
|
+
* @typedef {(cfg: {
|
|
121
|
+
* readonly?: boolean,
|
|
122
|
+
* resultType?: "both"|"keys"|"values",
|
|
123
|
+
* typeNamespace?: string,
|
|
124
|
+
* type: AvailableType,
|
|
125
|
+
* topRoot?: RootElement,
|
|
126
|
+
* bringIntoFocus?: boolean|undefined,
|
|
127
|
+
* buildTypeChoices?: import('./typeChoices.js').BuildTypeChoices,
|
|
128
|
+
* format: import('./formats.js').AvailableFormat,
|
|
129
|
+
* schemaContent?: object
|
|
130
|
+
* schemaState?: GetPossibleSchemasForPathAndType,
|
|
131
|
+
* value: StructuredCloneValue,
|
|
132
|
+
* hasValue: boolean,
|
|
133
|
+
* replaced?: StructuredCloneValue,
|
|
134
|
+
* }) => Element} GetUIForModeAndType
|
|
135
|
+
*/
|
|
136
|
+
/* eslint-enable jsdoc/valid-types -- readonly reserved */
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* @typedef {(cfg: {
|
|
140
|
+
* form: HTMLFormElement,
|
|
141
|
+
* typeNamespace?: string,
|
|
142
|
+
* keySelectClass?: string,
|
|
143
|
+
* }) => boolean} ValidValuesSet
|
|
144
|
+
*/
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* @typedef {(cfg: {
|
|
148
|
+
* topRoot: RootElement
|
|
149
|
+
* }) => void} ValidateAllReferences
|
|
150
|
+
*/
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* @typedef {(cfg: {
|
|
154
|
+
* type: AvailableType,
|
|
155
|
+
* root: RootElement,
|
|
156
|
+
* topRoot?: RootElement
|
|
157
|
+
* }) => boolean} Validate
|
|
158
|
+
*/
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* @typedef {(cfg: {
|
|
162
|
+
* type: AvailableType,
|
|
163
|
+
* root: RootElement,
|
|
164
|
+
* value: StructuredCloneValue,
|
|
165
|
+
* }) => void} SetValue
|
|
166
|
+
*/
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* @typedef {(s: string, cfg: {
|
|
170
|
+
* format: import('./formats.js').AvailableFormat,
|
|
171
|
+
* state: string,
|
|
172
|
+
* endMatchTypeObjs?: TypeObject[]
|
|
173
|
+
* firstRun?: boolean,
|
|
174
|
+
* rootHolder?: [
|
|
175
|
+
* type: string,
|
|
176
|
+
* parent: {[key: string]: any},
|
|
177
|
+
* parentPath: string|number,
|
|
178
|
+
* path: string
|
|
179
|
+
* ][],
|
|
180
|
+
* parent: {[key: string]: any},
|
|
181
|
+
* parentPath: string|number
|
|
182
|
+
* }) => [
|
|
183
|
+
* value: StructuredCloneValue,
|
|
184
|
+
* remnant: string,
|
|
185
|
+
* beginOnly: boolean,
|
|
186
|
+
* assign: boolean
|
|
187
|
+
* ]} GetValueForString
|
|
188
|
+
*/
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* @typedef {(
|
|
192
|
+
* info: {topRoot: HTMLDivElement}
|
|
193
|
+
* ) => void} CustomValidateAllReferences
|
|
194
|
+
*/
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* @type {{
|
|
198
|
+
* availableTypes: {
|
|
199
|
+
* [key in AvailableType]: Partial<TypeObject>|string[]|
|
|
200
|
+
* {valid: true}|{sparse: true}
|
|
201
|
+
* },
|
|
202
|
+
* getTypeForRoot: GetTypeForRoot,
|
|
203
|
+
* getValueForRoot: GetValueForRoot,
|
|
204
|
+
* getFormControlForRoot: GetFormControlForRoot,
|
|
205
|
+
* getValueFromRootAncestor: GetValueFromRootAncestor,
|
|
206
|
+
* getFormControlFromRootAncestor: GetFormControlFromRootAncestor,
|
|
207
|
+
* getTypesForFormatAndState: GetTypesForFormatAndState,
|
|
208
|
+
* getOptionForType: GetOptionForType,
|
|
209
|
+
* getTypeOptionsForFormatAndState: GetTypeOptionsForFormatAndState,
|
|
210
|
+
* getUIForModeAndType: GetUIForModeAndType,
|
|
211
|
+
* contexts: {
|
|
212
|
+
* [key: string]: {
|
|
213
|
+
* [key: string]: {type: AvailableType, after: AvailableType}[]
|
|
214
|
+
* }
|
|
215
|
+
* },
|
|
216
|
+
* validValuesSet: ValidValuesSet,
|
|
217
|
+
* validateAllReferences: ValidateAllReferences,
|
|
218
|
+
* validate: Validate,
|
|
219
|
+
* setValue: SetValue,
|
|
220
|
+
* getValueForString: GetValueForString,
|
|
221
|
+
* customValidateAllReferences?: CustomValidateAllReferences
|
|
222
|
+
* }}
|
|
223
|
+
*/
|
|
58
224
|
const Types = {};
|
|
59
225
|
|
|
60
226
|
/**
|
|
@@ -314,23 +480,17 @@ copyTypeObjs(
|
|
|
314
480
|
]
|
|
315
481
|
);
|
|
316
482
|
|
|
317
|
-
/**
|
|
318
|
-
* Utility to retrieve the type out of a type root element.
|
|
319
|
-
* @public
|
|
320
|
-
* @param {?RootElement} root
|
|
321
|
-
* @returns {string|undefined|null} Why would it not exist?
|
|
322
|
-
*/
|
|
323
483
|
Types.getTypeForRoot = (root) => {
|
|
324
484
|
return root && root.dataset.type;
|
|
325
485
|
};
|
|
326
486
|
|
|
327
487
|
/**
|
|
328
488
|
* @typedef {(
|
|
329
|
-
*
|
|
330
|
-
*
|
|
331
|
-
*
|
|
332
|
-
*
|
|
333
|
-
*
|
|
489
|
+
* keypath: string,
|
|
490
|
+
* parentPath: string,
|
|
491
|
+
* arrayOrObjectPropertyName: string,
|
|
492
|
+
* valueType: string
|
|
493
|
+
* ) => StateObject} GetPossibleSchemasForPathAndType
|
|
334
494
|
*/
|
|
335
495
|
|
|
336
496
|
/**
|
|
@@ -351,15 +511,6 @@ Types.getTypeForRoot = (root) => {
|
|
|
351
511
|
* }} StateObject
|
|
352
512
|
*/
|
|
353
513
|
|
|
354
|
-
/**
|
|
355
|
-
* Utility to get the value out of a type root element with a given
|
|
356
|
-
* state and path.
|
|
357
|
-
* @public
|
|
358
|
-
* @param {RootElement} root
|
|
359
|
-
* @param {StateObject} stateObj
|
|
360
|
-
* @param {string} [currentPath]
|
|
361
|
-
* @returns {StructuredCloneValue}
|
|
362
|
-
*/
|
|
363
514
|
Types.getValueForRoot = (root, stateObj, currentPath) => {
|
|
364
515
|
const typeObject = /** @type {TypeObject} */ (
|
|
365
516
|
Types.availableTypes[
|
|
@@ -372,13 +523,6 @@ Types.getValueForRoot = (root, stateObj, currentPath) => {
|
|
|
372
523
|
});
|
|
373
524
|
};
|
|
374
525
|
|
|
375
|
-
/**
|
|
376
|
-
* Utility to get the form control (e.g., input element) for a root.
|
|
377
|
-
* @public
|
|
378
|
-
* @param {RootElement} root
|
|
379
|
-
* @returns {null|
|
|
380
|
-
* HTMLInputElement|HTMLTextAreaElement|HTMLSelectElement|HTMLButtonElement}
|
|
381
|
-
*/
|
|
382
526
|
Types.getFormControlForRoot = (root) => {
|
|
383
527
|
const typeObj = /** @type {TypeObject} */ (Types.availableTypes[
|
|
384
528
|
/** @type {AvailableType} */
|
|
@@ -391,13 +535,6 @@ Types.getFormControlForRoot = (root) => {
|
|
|
391
535
|
return typeObj.getInput({root});
|
|
392
536
|
};
|
|
393
537
|
|
|
394
|
-
/**
|
|
395
|
-
* Utility to get the value for a root using its ancestor and state.
|
|
396
|
-
* @public
|
|
397
|
-
* @param {string|Element} selOrEl
|
|
398
|
-
* @param {StateObject} stateObj
|
|
399
|
-
* @returns {StructuredCloneValue}
|
|
400
|
-
*/
|
|
401
538
|
Types.getValueFromRootAncestor = (selOrEl, stateObj) => {
|
|
402
539
|
return Types.getValueForRoot(
|
|
403
540
|
/** @type {RootElement} */
|
|
@@ -406,12 +543,6 @@ Types.getValueFromRootAncestor = (selOrEl, stateObj) => {
|
|
|
406
543
|
);
|
|
407
544
|
};
|
|
408
545
|
|
|
409
|
-
/**
|
|
410
|
-
* @public
|
|
411
|
-
* @param {string|Element} selOrEl
|
|
412
|
-
* @returns {null|HTMLInputElement|HTMLTextAreaElement|HTMLSelectElement|
|
|
413
|
-
* HTMLButtonElement}
|
|
414
|
-
*/
|
|
415
546
|
Types.getFormControlFromRootAncestor = (selOrEl) => {
|
|
416
547
|
const root = /** @type {RootElement} */ ($e(selOrEl, 'div[data-type]'));
|
|
417
548
|
if (!root) {
|
|
@@ -420,20 +551,10 @@ Types.getFormControlFromRootAncestor = (selOrEl) => {
|
|
|
420
551
|
return Types.getFormControlForRoot(root);
|
|
421
552
|
};
|
|
422
553
|
|
|
423
|
-
/**
|
|
424
|
-
* @param {string} format
|
|
425
|
-
* @param {string} [state]
|
|
426
|
-
* @returns {AvailableType[]|undefined}
|
|
427
|
-
*/
|
|
428
554
|
Types.getTypesForFormatAndState = (
|
|
429
555
|
format, state
|
|
430
556
|
) => Formats.availableFormats[format].getTypesForState(state);
|
|
431
557
|
|
|
432
|
-
/**
|
|
433
|
-
* @public
|
|
434
|
-
* @param {AvailableType} type
|
|
435
|
-
* @returns {[string, {value: AvailableType, title?: string}]}
|
|
436
|
-
*/
|
|
437
558
|
Types.getOptionForType = (type) => {
|
|
438
559
|
/** @type {[string, {value?: AvailableType, title?: string}?]} */
|
|
439
560
|
const optInfo = [
|
|
@@ -447,12 +568,6 @@ Types.getOptionForType = (type) => {
|
|
|
447
568
|
);
|
|
448
569
|
};
|
|
449
570
|
|
|
450
|
-
/**
|
|
451
|
-
* @public
|
|
452
|
-
* @param {string} format
|
|
453
|
-
* @param {string} [parserState]
|
|
454
|
-
* @returns {[string, {value: AvailableType, title?: string}][]}
|
|
455
|
-
*/
|
|
456
571
|
Types.getTypeOptionsForFormatAndState = (format, parserState) => {
|
|
457
572
|
const typesForFormatAndState = Types.getTypesForFormatAndState(
|
|
458
573
|
format, parserState
|
|
@@ -465,32 +580,11 @@ Types.getTypeOptionsForFormatAndState = (format, parserState) => {
|
|
|
465
580
|
});
|
|
466
581
|
};
|
|
467
582
|
|
|
468
|
-
/* eslint-disable jsdoc/valid-types -- readonly reserved */
|
|
469
|
-
/**
|
|
470
|
-
* @public
|
|
471
|
-
* @param {object} cfg
|
|
472
|
-
* @param {boolean} [cfg.readonly]
|
|
473
|
-
* @param {"both"|"keys"|"values"} [cfg.resultType]
|
|
474
|
-
* @param {string} [cfg.typeNamespace]
|
|
475
|
-
* @param {AvailableType} cfg.type
|
|
476
|
-
* @param {RootElement} [cfg.topRoot]
|
|
477
|
-
* @param {boolean|undefined} cfg.bringIntoFocus
|
|
478
|
-
* @param {import('./typeChoices.js').BuildTypeChoices} [cfg.buildTypeChoices]
|
|
479
|
-
* @param {import('./formats.js').AvailableFormat} cfg.format
|
|
480
|
-
* @param {object} [cfg.schemaContent]
|
|
481
|
-
* @param {GetPossibleSchemasForPathAndType} [cfg.schemaState] Not currently
|
|
482
|
-
* in use
|
|
483
|
-
* @param {StructuredCloneValue} cfg.value
|
|
484
|
-
* @param {boolean} cfg.hasValue
|
|
485
|
-
* @param {StructuredCloneValue} [cfg.replaced]
|
|
486
|
-
* @returns {Element}
|
|
487
|
-
*/
|
|
488
583
|
Types.getUIForModeAndType = ({
|
|
489
584
|
readonly, resultType, typeNamespace, type, topRoot, bringIntoFocus,
|
|
490
585
|
buildTypeChoices, format, schemaContent, schemaState, value, hasValue,
|
|
491
586
|
replaced
|
|
492
587
|
}) => {
|
|
493
|
-
/* eslint-enable jsdoc/valid-types -- readonly reserved */
|
|
494
588
|
const typeObj = /** @type {TypeObject} */ (Types.availableTypes[type]);
|
|
495
589
|
const arg = hasValue
|
|
496
590
|
? {
|
|
@@ -519,13 +613,6 @@ Types.getUIForModeAndType = ({
|
|
|
519
613
|
return root;
|
|
520
614
|
};
|
|
521
615
|
|
|
522
|
-
/**
|
|
523
|
-
* @type {{
|
|
524
|
-
* [key: string]: {
|
|
525
|
-
* [key: string]: {type: AvailableType, after: AvailableType}[]
|
|
526
|
-
* }
|
|
527
|
-
* }}
|
|
528
|
-
*/
|
|
529
616
|
Types.contexts = {};
|
|
530
617
|
Object.entries(Types.availableTypes).forEach(([typ, typeObj]) => {
|
|
531
618
|
const type = /** @type {AvailableType} */ (typ);
|
|
@@ -546,14 +633,6 @@ Object.entries(Types.availableTypes).forEach(([typ, typeObj]) => {
|
|
|
546
633
|
}
|
|
547
634
|
});
|
|
548
635
|
|
|
549
|
-
/**
|
|
550
|
-
* @public
|
|
551
|
-
* @param {object} cfg
|
|
552
|
-
* @param {HTMLFormElement} cfg.form
|
|
553
|
-
* @param {string} [cfg.typeNamespace]
|
|
554
|
-
* @param {string} [cfg.keySelectClass]
|
|
555
|
-
* @returns {boolean}
|
|
556
|
-
*/
|
|
557
636
|
Types.validValuesSet = ({form, typeNamespace, keySelectClass}) => {
|
|
558
637
|
// If form is hidden, don't list errors by default
|
|
559
638
|
if (!form.offsetParent ||
|
|
@@ -592,12 +671,6 @@ Types.validValuesSet = ({form, typeNamespace, keySelectClass}) => {
|
|
|
592
671
|
* @typedef {HTMLDivElement} RootElement
|
|
593
672
|
*/
|
|
594
673
|
|
|
595
|
-
/**
|
|
596
|
-
* @public
|
|
597
|
-
* @param {object} cfg
|
|
598
|
-
* @param {RootElement} cfg.topRoot
|
|
599
|
-
* @returns {void}
|
|
600
|
-
*/
|
|
601
674
|
Types.validateAllReferences = ({topRoot}) => {
|
|
602
675
|
/* istanbul ignore if -- Unreachable? */
|
|
603
676
|
if (!topRoot) {
|
|
@@ -619,19 +692,6 @@ Types.validateAllReferences = ({topRoot}) => {
|
|
|
619
692
|
}
|
|
620
693
|
};
|
|
621
694
|
|
|
622
|
-
/**
|
|
623
|
-
* @type {null|((info: {topRoot: HTMLDivElement}) => void)}
|
|
624
|
-
*/
|
|
625
|
-
Types.customValidateAllReferences = null;
|
|
626
|
-
|
|
627
|
-
/**
|
|
628
|
-
* @public
|
|
629
|
-
* @param {object} cfg
|
|
630
|
-
* @param {AvailableType} cfg.type
|
|
631
|
-
* @param {RootElement} cfg.root
|
|
632
|
-
* @param {RootElement} [cfg.topRoot]
|
|
633
|
-
* @returns {boolean}
|
|
634
|
-
*/
|
|
635
695
|
Types.validate = ({type, root, topRoot}) => {
|
|
636
696
|
const typeObj = /** @type {TypeObject} */ (Types.availableTypes[type]);
|
|
637
697
|
// Todo (low): We limit for now to input boxes which have `validate`
|
|
@@ -650,13 +710,6 @@ Types.validate = ({type, root, topRoot}) => {
|
|
|
650
710
|
return true;
|
|
651
711
|
};
|
|
652
712
|
|
|
653
|
-
/**
|
|
654
|
-
* @param {object} cfg
|
|
655
|
-
* @param {AvailableType} cfg.type
|
|
656
|
-
* @param {RootElement} cfg.root
|
|
657
|
-
* @param {StructuredCloneValue} cfg.value
|
|
658
|
-
* @returns {void}
|
|
659
|
-
*/
|
|
660
713
|
Types.setValue = ({type, root, value}) => {
|
|
661
714
|
const typeObj = /** @type {TypeObject} */ (Types.availableTypes[type]);
|
|
662
715
|
if (typeObj.setValue) {
|
|
@@ -683,29 +736,6 @@ function escapeRegex (str) {
|
|
|
683
736
|
// format to the URL, but that is still expecting our Router
|
|
684
737
|
// string syntax)
|
|
685
738
|
|
|
686
|
-
/**
|
|
687
|
-
* @public
|
|
688
|
-
* @param {string} s
|
|
689
|
-
* @param {object} cfg
|
|
690
|
-
* @param {import('./formats.js').AvailableFormat} cfg.format
|
|
691
|
-
* @param {string} cfg.state
|
|
692
|
-
* @param {TypeObject[]} [cfg.endMatchTypeObjs=[]]
|
|
693
|
-
* @param {boolean} [cfg.firstRun=true]
|
|
694
|
-
* @param {[
|
|
695
|
-
* type: string,
|
|
696
|
-
* parent: {[key: string]: any},
|
|
697
|
-
* parentPath: string|number,
|
|
698
|
-
* path: string
|
|
699
|
-
* ][]} [cfg.rootHolder=[]]
|
|
700
|
-
* @param {{[key: string]: any}} cfg.parent
|
|
701
|
-
* @param {string|number} cfg.parentPath
|
|
702
|
-
* @returns {[
|
|
703
|
-
* value: StructuredCloneValue,
|
|
704
|
-
* remnant: string,
|
|
705
|
-
* beginOnly: boolean,
|
|
706
|
-
* assign: boolean
|
|
707
|
-
* ]}
|
|
708
|
-
*/
|
|
709
739
|
Types.getValueForString = (s, {
|
|
710
740
|
format, state, endMatchTypeObjs = [], firstRun = true,
|
|
711
741
|
rootHolder = [], parent, parentPath
|