@es-joy/jsoe 0.12.4 → 0.13.1

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 (37) hide show
  1. package/.nyc_output/out.json +11754 -11508
  2. package/CHANGES.md +8 -0
  3. package/demo/index.js +38 -29
  4. package/dist/formatAndTypeChoices.d.ts +11 -2
  5. package/dist/formatAndTypeChoices.d.ts.map +1 -1
  6. package/dist/formats/structuredCloning.d.ts.map +1 -1
  7. package/dist/formats.d.ts +52 -10
  8. package/dist/formats.d.ts.map +1 -1
  9. package/dist/fundamentalTypes/arrayType.d.ts.map +1 -1
  10. package/dist/fundamentalTypes/dateType.d.ts.map +1 -1
  11. package/dist/fundamentalTypes/errorType.d.ts.map +1 -1
  12. package/dist/fundamentalTypes/regexpType.d.ts.map +1 -1
  13. package/dist/index.d.ts +1 -1
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +795 -620
  16. package/dist/superTypes/errorsSpecialType.d.ts.map +1 -1
  17. package/dist/typeChoices.d.ts +4 -0
  18. package/dist/typeChoices.d.ts.map +1 -1
  19. package/dist/types.d.ts +308 -74
  20. package/dist/types.d.ts.map +1 -1
  21. package/package.json +1 -1
  22. package/src/formatAndTypeChoices.js +20 -5
  23. package/src/formats/indexedDBKey.js +1 -1
  24. package/src/formats/json.js +1 -1
  25. package/src/formats/schemaAndArbitrary.js +1 -1
  26. package/src/formats/schemaOnly.js +1 -1
  27. package/src/formats/structuredCloning.js +22 -13
  28. package/src/formats.js +87 -26
  29. package/src/fundamentalTypes/arrayReferenceType.js +2 -2
  30. package/src/fundamentalTypes/arrayType.js +43 -23
  31. package/src/fundamentalTypes/dateType.js +2 -3
  32. package/src/fundamentalTypes/errorType.js +5 -3
  33. package/src/fundamentalTypes/regexpType.js +2 -3
  34. package/src/index.js +1 -1
  35. package/src/superTypes/errorsSpecialType.js +12 -5
  36. package/src/typeChoices.js +21 -10
  37. package/src/types.js +579 -527
@@ -1 +1 @@
1
- {"version":3,"file":"errorsSpecialType.d.ts","sourceRoot":"","sources":["../../src/superTypes/errorsSpecialType.js"],"names":[],"mappings":";sBAOa,MAAM;+BAaN,gBAAgB,GAAC,yBAAyB;AAyBvD;;GAEG;AACH,iCAFU,OAAO,wBAAwB,EAAE,eAAe,CA+sBxD"}
1
+ {"version":3,"file":"errorsSpecialType.d.ts","sourceRoot":"","sources":["../../src/superTypes/errorsSpecialType.js"],"names":[],"mappings":";sBAOa,MAAM;+BAaN,gBAAgB,GAAC,yBAAyB;AAyBvD;;GAEG;AACH,iCAFU,OAAO,wBAAwB,EAAE,eAAe,CAstBxD"}
@@ -57,6 +57,8 @@
57
57
  * requireObject?: boolean,
58
58
  * objectHasValue?: boolean,
59
59
  * topRoot?: import('./types.js').RootElement,
60
+ * formats?: import('./formats.js').default
61
+ * types?: import('./types.js').default
60
62
  * schema?: string,
61
63
  * schemaContent?: object,
62
64
  * }} cfg
@@ -105,6 +107,8 @@ export type BuildTypeChoices = (cfg: {
105
107
  requireObject?: boolean;
106
108
  objectHasValue?: boolean;
107
109
  topRoot?: import('./types.js').RootElement;
110
+ formats?: import('./formats.js').default;
111
+ types?: import('./types.js').default;
108
112
  schema?: string;
109
113
  schemaContent?: object;
110
114
  }) => {
@@ -1 +1 @@
1
- {"version":3,"file":"typeChoices.d.ts","sourceRoot":"","sources":["../src/typeChoices.js"],"names":[],"mappings":"AASA;;;;;;GAMG;AAEH;;GAEG;AAEH;;;;;GAKG;AAEH;;GAEG;AAEH;;;;;GAKG;AAEH;;;;;;GAMG;AAEH;;;GAGG;AAEH;;;GAGG;AAEH;;;;;GAKG;AAEH;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH;;GAEG;AACH,+BAFU,gBAAgB,CA2PxB;4BA3UiB;IAClB,IAAQ,EAAE,MAAM,CAAC;IACjB,SAAa,CAAC,EAAE,OAAO,cAAc,EAAE,oBAAoB,CAAC;IAC5D,cAAkB,CAAC,EAAE,OAAO,CAAA;CACzB,K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B,cAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,OAAW,CAAC,EAAE,OAAO,YAAY,EAAE,WAAW,CAAC;IAC/C,OAAW,CAAC,EAAE,OAAO,cAAc,EAAE,OAAO,CAAA;IAC5C,KAAS,CAAC,EAAE,OAAO,YAAY,EAAE,OAAO,CAAA;IACxC,MAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAiB,CAAC,EAAE,MAAM,CAAC;CACxB,KACS;IACZ,QAAY,EAAE,CAAC,MAAM,EAAE,WAAW,EAAE,aAAa,EAAE,WAAW,CAAC,CAAC;IAChE,QAAY,EAAE,QAAQ,CAAC;IACvB,OAAW,EAAE,OAAO,CAAC;IACrB,cAAkB,EAAE,cAAc,CAAC;IACnC,QAAY,EAAE,QAAQ,CAAA;CACnB"}
package/dist/types.d.ts CHANGED
@@ -1,5 +1,9 @@
1
1
  export function getPropertyValueFromLegend(legend: HTMLLegendElement): string;
2
2
  export default Types;
3
+ /**
4
+ * Any other possibilities than `div`?
5
+ */
6
+ export type RootElement = HTMLDivElement;
3
7
  /**
4
8
  * Utility to retrieve the type out of a type root element.
5
9
  */
@@ -8,7 +12,7 @@ export type GetTypeForRoot = (root: RootElement | null) => string;
8
12
  * Utility to get the value out of a type root element with a given
9
13
  * state and path.
10
14
  */
11
- export type GetValueForRoot = (root: RootElement, stateObj?: StateObject | undefined, currentPath?: string | undefined) => StructuredCloneValue;
15
+ export type GetValueForRoot = (root: RootElement, stateObj: StateObject, currentPath?: string | undefined) => StructuredCloneValue;
12
16
  /**
13
17
  * Utility to get the form control (e.g., input element) for a root.
14
18
  */
@@ -16,17 +20,36 @@ export type GetFormControlForRoot = (root: RootElement) => null | HTMLInputEleme
16
20
  /**
17
21
  * Utility to get the value for a root using its ancestor and state.
18
22
  */
19
- export type GetValueFromRootAncestor = (selOrEl: string | HTMLElement, stateObj?: StateObject | undefined) => StructuredCloneValue;
23
+ export type GetValueFromRootAncestor = (selOrEl: string | HTMLElement, stateObj: StateObject) => StructuredCloneValue;
20
24
  export type GetFormControlFromRootAncestor = (selOrEl: string | HTMLElement) => null | HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement | HTMLButtonElement;
21
- export type GetTypesForFormatAndState = (format: string, state?: string | undefined) => AvailableType[] | undefined;
22
25
  export type GetOptionForType = (type: AvailableType) => [string, {
23
26
  value: AvailableType;
24
27
  title?: string;
25
28
  }];
26
- export type GetTypeOptionsForFormatAndState = (format: string, parserState?: string | undefined) => [string, {
29
+ export type GetTypeOptionsForFormatAndState = (format: import('./formats.js').AvailableFormat, parserState?: string | undefined) => [string, {
27
30
  value: AvailableType;
28
31
  title?: string;
29
32
  }][];
33
+ export type GetPossibleSchemasForPathAndType = (keypath: string, parentPath: string, arrayOrObjectPropertyName: string, valueType: string) => StateObject;
34
+ export type StateObject = {
35
+ typeNamespace?: string | undefined;
36
+ readonly?: boolean | undefined;
37
+ format?: import("./formats.js").AvailableFormat | undefined;
38
+ formats?: Formats | undefined;
39
+ types?: Types | undefined;
40
+ error?: Error | undefined;
41
+ rootUI?: Element | undefined;
42
+ schema?: string | undefined;
43
+ schemaContent?: object | undefined;
44
+ getPossibleSchemasForPathAndType?: GetPossibleSchemasForPathAndType | undefined;
45
+ paths?: {
46
+ [currentPath: string]: {
47
+ referentPath: string;
48
+ expectArrayReferent: boolean;
49
+ };
50
+ } | undefined;
51
+ handlingReference?: boolean | undefined;
52
+ };
30
53
  export type GetUIForModeAndType = (cfg: {
31
54
  readonly?: boolean;
32
55
  resultType?: "both" | "keys" | "values";
@@ -96,6 +119,7 @@ export type RootInfo = {
96
119
  ][];
97
120
  parent?: object;
98
121
  parentPath?: string | number;
122
+ types?: Types;
99
123
  };
100
124
  export type TypeObjectSetValue = (info: {
101
125
  root: HTMLDivElement;
@@ -201,12 +225,15 @@ export type TypeObject = {
201
225
  topRoot?: HTMLDivElement;
202
226
  resultType?: "keys" | "values" | "both";
203
227
  format: import('./formats.js').AvailableFormat;
228
+ types: Types;
204
229
  }) => import("jamilih").JamilihArray;
205
230
  editUI: (info: {
206
231
  value?: StructuredCloneValue;
207
232
  typeNamespace?: string;
208
233
  bringIntoFocus?: boolean;
209
234
  format?: import('./formats.js').AvailableFormat;
235
+ formats?: import('./formats.js').default;
236
+ types: Types;
210
237
  resultType?: "keys" | "values" | "both";
211
238
  type?: AvailableType;
212
239
  arrayState?: string;
@@ -243,6 +270,7 @@ export type TypeObject = {
243
270
  */
244
271
  validateAll?: ((info: {
245
272
  topRoot: HTMLDivElement;
273
+ types: Types;
246
274
  }) => void) | undefined;
247
275
  /**
248
276
  * The type after which it should be placed and its
@@ -256,28 +284,10 @@ export type TypeObject = {
256
284
  } | undefined;
257
285
  };
258
286
  export type AvailableType = "null" | "true" | "false" | "number" | "bigint" | "string" | "arrayReference" | "objectReference" | "array" | "object" | "date" | "userObject" | "undef" | "SpecialRealNumber" | "SpecialNumber" | "regexp" | "BooleanObject" | "NumberObject" | "StringObject" | "map" | "set" | "file" | "filelist" | "blobHTML" | "arraybuffer" | "arraybufferview" | "dataview" | "imagedata" | "imagebitmap" | "int8array" | "uint8array" | "uint8clampedarray" | "int16array" | "uint16array" | "int32array" | "uint32array" | "float32array" | "float64array" | "ValidDate" | "arrayNonindexKeys" | "error" | "errors" | "blob" | "domexception" | "domrect" | "dompoint" | "dommatrix";
259
- export type GetPossibleSchemasForPathAndType = (keypath: string, parentPath: string, arrayOrObjectPropertyName: string, valueType: string) => StateObject;
260
- export type StateObject = {
261
- typeNamespace?: string | undefined;
262
- readonly?: boolean | undefined;
263
- format?: import("./formats.js").AvailableFormat | undefined;
264
- error?: Error | undefined;
265
- rootUI?: Element | undefined;
266
- schema?: string | undefined;
267
- schemaContent?: object | undefined;
268
- getPossibleSchemasForPathAndType?: GetPossibleSchemasForPathAndType | undefined;
269
- paths?: {
270
- [currentPath: string]: {
271
- referentPath: string;
272
- expectArrayReferent: boolean;
273
- };
274
- } | undefined;
275
- handlingReference?: boolean | undefined;
276
- };
277
287
  /**
278
288
  * Any other possibilities than `div`?
289
+ * @typedef {HTMLDivElement} RootElement
279
290
  */
280
- export type RootElement = HTMLDivElement;
281
291
  /**
282
292
  * Utility to retrieve the type out of a type root element.
283
293
  * @callback GetTypeForRoot
@@ -289,7 +299,7 @@ export type RootElement = HTMLDivElement;
289
299
  * state and path.
290
300
  * @callback GetValueForRoot
291
301
  * @param {RootElement} root
292
- * @param {StateObject} [stateObj]
302
+ * @param {StateObject} stateObj
293
303
  * @param {string} [currentPath]
294
304
  * @returns {StructuredCloneValue}
295
305
  */
@@ -304,7 +314,7 @@ export type RootElement = HTMLDivElement;
304
314
  * Utility to get the value for a root using its ancestor and state.
305
315
  * @callback GetValueFromRootAncestor
306
316
  * @param {string|HTMLElement} selOrEl
307
- * @param {StateObject} [stateObj]
317
+ * @param {StateObject} stateObj
308
318
  * @returns {StructuredCloneValue}
309
319
  */
310
320
  /**
@@ -313,12 +323,6 @@ export type RootElement = HTMLDivElement;
313
323
  * @returns {null|HTMLInputElement|HTMLTextAreaElement|HTMLSelectElement|
314
324
  * HTMLButtonElement}
315
325
  */
316
- /**
317
- * @callback GetTypesForFormatAndState
318
- * @param {string} format
319
- * @param {string} [state]
320
- * @returns {AvailableType[]|undefined}
321
- */
322
326
  /**
323
327
  * @callback GetOptionForType
324
328
  * @param {AvailableType} type
@@ -326,10 +330,37 @@ export type RootElement = HTMLDivElement;
326
330
  */
327
331
  /**
328
332
  * @callback GetTypeOptionsForFormatAndState
329
- * @param {string} format
333
+ * @param {import('./formats.js').AvailableFormat} format
330
334
  * @param {string} [parserState]
331
335
  * @returns {[string, {value: AvailableType, title?: string}][]}
332
336
  */
337
+ /**
338
+ * @typedef {(
339
+ * keypath: string,
340
+ * parentPath: string,
341
+ * arrayOrObjectPropertyName: string,
342
+ * valueType: string
343
+ * ) => StateObject} GetPossibleSchemasForPathAndType
344
+ */
345
+ /**
346
+ * @typedef {{
347
+ * typeNamespace?: string,
348
+ * "readonly"?: boolean,
349
+ * format?: import('./formats.js').AvailableFormat,
350
+ * formats?: import('./formats.js').default,
351
+ * types?: Types,
352
+ * error?: Error,
353
+ * rootUI?: Element,
354
+ * schema?: string,
355
+ * schemaContent?: object,
356
+ * getPossibleSchemasForPathAndType?: GetPossibleSchemasForPathAndType,
357
+ * paths?: {[currentPath: string]: {
358
+ * referentPath: string,
359
+ * expectArrayReferent: boolean
360
+ * }},
361
+ * handlingReference?: boolean
362
+ * }} StateObject
363
+ */
333
364
  /**
334
365
  * @typedef {(cfg: {
335
366
  * readonly?: boolean,
@@ -400,33 +431,153 @@ export type RootElement = HTMLDivElement;
400
431
  * ) => void} CustomValidateAllReferences
401
432
  */
402
433
  /**
403
- * @type {{
404
- * availableTypes: {
405
- * [key in AvailableType]: Partial<TypeObject>|string[]
406
- * },
407
- * getTypeForRoot: GetTypeForRoot,
408
- * getValueForRoot: GetValueForRoot,
409
- * getFormControlForRoot: GetFormControlForRoot,
410
- * getValueFromRootAncestor: GetValueFromRootAncestor,
411
- * getFormControlFromRootAncestor: GetFormControlFromRootAncestor,
412
- * getTypesForFormatAndState: GetTypesForFormatAndState,
413
- * getOptionForType: GetOptionForType,
414
- * getTypeOptionsForFormatAndState: GetTypeOptionsForFormatAndState,
415
- * getUIForModeAndType: GetUIForModeAndType,
416
- * contexts: {
417
- * [key: string]: {
418
- * [key: string]: {type: AvailableType, after: AvailableType}[]
419
- * }
420
- * },
421
- * validValuesSet: ValidValuesSet,
422
- * validateAllReferences: ValidateAllReferences,
423
- * validate: Validate,
424
- * setValue: SetValue,
425
- * getValueForString: GetValueForString,
426
- * customValidateAllReferences?: CustomValidateAllReferences
427
- * }}
434
+ * @typedef {import('./formats.js').StructuredCloneValue} StructuredCloneValue
435
+ */
436
+ /**
437
+ * @typedef {import('jamilih').JamilihArray} JamilihArray
438
+ */
439
+ /**
440
+ * @typedef {{
441
+ * format: import('./formats.js').AvailableFormat,
442
+ * match: boolean|RegExpMatchArray|null
443
+ * endMatchTypeObjs: TypeObject[],
444
+ * remnant: string,
445
+ * rootHolder: [
446
+ * type: string,
447
+ * parent: object|undefined,
448
+ * parentPath: string|number|undefined,
449
+ * path: string
450
+ * ][],
451
+ * parent?: object,
452
+ * parentPath?: string|number,
453
+ * types?: Types
454
+ * }} RootInfo
455
+ */
456
+ /**
457
+ * @typedef {(
458
+ * info: {
459
+ * root: HTMLDivElement,
460
+ * value: StructuredCloneValue
461
+ * }
462
+ * ) => void} TypeObjectSetValue
428
463
  */
429
- declare const Types: {
464
+ /**
465
+ * @typedef {object} TypeObject
466
+ * @property {[
467
+ * string, {value?: AvailableType, title?: string}?
468
+ * ]} option Creates the option HTML. May set an option `title` or `value`
469
+ * @property {boolean} [array] Private context variable. Whether or not
470
+ * it is an array. Do not use in other types.
471
+ * @property {boolean} [map] Private context variable. Whether or not
472
+ * it is a `Map`. Do not use in other types.
473
+ * @property {boolean} [set] Private context variable. Whether or not
474
+ * it is a `Set`. Do not use in other types.
475
+ * @property {boolean} [filelist] Private context variable. Whether or not
476
+ * it is a `FileList` type. Do not use in other types.
477
+ * @property {boolean} [sparse] Private context variable. Whether or not
478
+ * it is a sparse array. Do not use in other types.
479
+ * @property {boolean} [valid] Private context variable. Whether or not
480
+ * it is a valid date. Do not use in other types.
481
+ * @property {string[]} [regexEndings] Used for string parsing.
482
+ * @property {RegExp|((nonGrouping?: boolean) => RegExp)} [stringRegex] Used
483
+ * for string parsing. If not present, use `stringRegexBegin` and
484
+ * `stringRegexEnd`.
485
+ * @property {RegExp} [stringRegexBegin] Used for string parsing. If not
486
+ * present, use `stringRegex`
487
+ * @property {RegExp} [stringRegexEnd] Used for string parsing. If not
488
+ * present, use `stringRegex`
489
+ * @property {(v: StructuredCloneValue) => boolean} [valueMatch] Function to
490
+ * check whether this subtype matches
491
+ * @property {string} [superType] The greater fundamental type to which
492
+ * the type belongs
493
+ * @property {(
494
+ * s: string, info?: RootInfo
495
+ * ) => {
496
+ * value?: StructuredCloneValue,
497
+ * remnant?: string,
498
+ * assign?: false
499
+ * }} toValue Converts from string to value. May use
500
+ * `stringRegex` to find components.
501
+ * @property {(info: {
502
+ * root: HTMLDivElement,
503
+ * stateObj?: StateObject,
504
+ * currentPath?: string
505
+ * }) =>
506
+ * StructuredCloneValue
507
+ * } getValue Gets the value for the type
508
+ * @property {TypeObjectSetValue} [setValue] Should set the value of the
509
+ * form's `getInput` element
510
+ * @property {(info: {
511
+ * value?: StructuredCloneValue,
512
+ * typeNamespace?: string,
513
+ * type?: AvailableType,
514
+ * topRoot?: HTMLDivElement,
515
+ * resultType?: "keys"|"values"|"both",
516
+ * format: import('./formats.js').AvailableFormat,
517
+ * types: Types
518
+ * }) => JamilihArray} viewUI
519
+ * @property {(info: {
520
+ * value?: StructuredCloneValue,
521
+ * typeNamespace?: string,
522
+ * bringIntoFocus?: boolean,
523
+ * format?: import('./formats.js').AvailableFormat,
524
+ * formats?: import('./formats.js').default,
525
+ * types: Types,
526
+ * resultType?: "keys"|"values"|"both",
527
+ * type?: AvailableType,
528
+ * arrayState?: string,
529
+ * buildTypeChoices?: import('./typeChoices.js').BuildTypeChoices,
530
+ * topRoot?: HTMLDivElement
531
+ * }) => JamilihArray} editUI
532
+ * @property {(info: {root: HTMLDivElement}) =>
533
+ * HTMLInputElement|HTMLTextAreaElement|HTMLSelectElement|
534
+ * HTMLButtonElement} getInput Gets the form control (with `value`)
535
+ * @property {(
536
+ * info: {root: HTMLDivElement}
537
+ * ) => HTMLSelectElement} [getSelect]
538
+ * @property {(path: string, value: StructuredCloneValue) =>
539
+ * StructuredCloneValue} [resolveReference] Gets the reference. For array
540
+ * and object references types only
541
+ * @property {(info: {root: HTMLDivElement, topRoot?: HTMLDivElement}) => {
542
+ * message?: string,
543
+ * valid: boolean
544
+ * }} [validate] Message will be used if validity is false.
545
+ * @property {(info: {
546
+ * topRoot: HTMLDivElement,
547
+ * types: Types
548
+ * }) => void} [validateAll] For
549
+ * validation of array and object references only.
550
+ * @property {{
551
+ * structuredCloning: {
552
+ * after: AvailableType,
553
+ * contexts: string[]
554
+ * }
555
+ * }} [stateDependent] The type after which it should be placed and its
556
+ * context types
557
+ */
558
+ /**
559
+ * @typedef {"null"|"true"|"false"|"number"|"bigint"|"string"|"arrayReference"|
560
+ * "objectReference"|"array"|"object"|"date"|"userObject"|"undef"|
561
+ * "SpecialRealNumber"|"SpecialNumber"|"regexp"|"BooleanObject"|
562
+ * "NumberObject"|"StringObject"|"map"|"set"|"file"|"filelist"|"blobHTML"|
563
+ * "arraybuffer"|"arraybufferview"|"dataview"|"imagedata"|"imagebitmap"|
564
+ * "int8array"|"uint8array"|"uint8clampedarray"|"int16array"|"uint16array"|
565
+ * "int32array"|"uint32array"|"float32array"|"float64array"|"ValidDate"|
566
+ * "arrayNonindexKeys"|"error"|"errors"|"blob"|"domexception"|"domrect"|
567
+ * "dompoint"|"dommatrix"} AvailableType
568
+ */
569
+ /**
570
+ *
571
+ */
572
+ declare class Types {
573
+ formats: Formats;
574
+ /** @type {CustomValidateAllReferences|undefined} */
575
+ customValidateAllReferences: CustomValidateAllReferences | undefined;
576
+ /**
577
+ * @type {{
578
+ * [key in AvailableType]: Partial<TypeObject>|string[]
579
+ * }}
580
+ */
430
581
  availableTypes: {
431
582
  string: string[] | Partial<TypeObject>;
432
583
  number: string[] | Partial<TypeObject>;
@@ -476,15 +627,13 @@ declare const Types: {
476
627
  dompoint: string[] | Partial<TypeObject>;
477
628
  dommatrix: string[] | Partial<TypeObject>;
478
629
  };
479
- getTypeForRoot: GetTypeForRoot;
480
- getValueForRoot: GetValueForRoot;
481
- getFormControlForRoot: GetFormControlForRoot;
482
- getValueFromRootAncestor: GetValueFromRootAncestor;
483
- getFormControlFromRootAncestor: GetFormControlFromRootAncestor;
484
- getTypesForFormatAndState: GetTypesForFormatAndState;
485
- getOptionForType: GetOptionForType;
486
- getTypeOptionsForFormatAndState: GetTypeOptionsForFormatAndState;
487
- getUIForModeAndType: GetUIForModeAndType;
630
+ /**
631
+ * @type {{
632
+ * [key: string]: {
633
+ * [key: string]: {type: AvailableType, after: AvailableType}[]
634
+ * }
635
+ * }}
636
+ */
488
637
  contexts: {
489
638
  [key: string]: {
490
639
  [key: string]: {
@@ -493,11 +642,96 @@ declare const Types: {
493
642
  }[];
494
643
  };
495
644
  };
496
- validValuesSet: ValidValuesSet;
497
- validateAllReferences: ValidateAllReferences;
498
- validate: Validate;
499
- setValue: SetValue;
500
- getValueForString: GetValueForString;
501
- customValidateAllReferences?: CustomValidateAllReferences | undefined;
502
- };
645
+ /**
646
+ * @param {import('./formats.js').AvailableFormat} format
647
+ * @param {StructuredCloneValue} record
648
+ * @param {StateObject} stateObj
649
+ * @returns {Promise<Element>}
650
+ */
651
+ getControlsForFormatAndValue(format: import('./formats.js').AvailableFormat, record: StructuredCloneValue, stateObj: StateObject): Promise<Element>;
652
+ /**
653
+ * @param {import('./formats.js').AvailableFormat} format
654
+ * @param {string} context
655
+ * @returns {{
656
+ * type: AvailableType
657
+ * after: AvailableType
658
+ * }[]}
659
+ */
660
+ getContextInfo(format: import('./formats.js').AvailableFormat, context: string): {
661
+ type: AvailableType;
662
+ after: AvailableType;
663
+ }[];
664
+ getValueForRoot(root: RootElement, stateObj: StateObject, currentPath?: string | undefined): StructuredCloneValue;
665
+ getFormControlForRoot(root: RootElement): null | HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement | HTMLButtonElement;
666
+ getValueFromRootAncestor(selOrEl: string | HTMLElement, stateObj: StateObject): StructuredCloneValue;
667
+ getFormControlFromRootAncestor(selOrEl: string | HTMLElement): null | HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement | HTMLButtonElement;
668
+ getOptionForType(type: AvailableType): [string, {
669
+ value: AvailableType;
670
+ title?: string;
671
+ }];
672
+ getTypeOptionsForFormatAndState(format: import('./formats.js').AvailableFormat, parserState?: string | undefined): [string, {
673
+ value: AvailableType;
674
+ title?: string;
675
+ }][];
676
+ getUIForModeAndType(cfg: {
677
+ readonly?: boolean;
678
+ resultType?: "both" | "keys" | "values";
679
+ typeNamespace?: string;
680
+ type: AvailableType;
681
+ topRoot?: RootElement;
682
+ bringIntoFocus?: boolean | undefined;
683
+ buildTypeChoices?: import('./typeChoices.js').BuildTypeChoices;
684
+ format: import('./formats.js').AvailableFormat;
685
+ schemaContent?: object;
686
+ schemaState?: GetPossibleSchemasForPathAndType;
687
+ value: StructuredCloneValue;
688
+ hasValue: boolean;
689
+ replaced?: StructuredCloneValue;
690
+ }): HTMLElement;
691
+ validateAllReferences(cfg: {
692
+ topRoot: RootElement;
693
+ }): void;
694
+ validate(cfg: {
695
+ type: AvailableType;
696
+ root: RootElement;
697
+ topRoot?: RootElement;
698
+ }): boolean;
699
+ setValue(cfg: {
700
+ type: AvailableType;
701
+ root: RootElement;
702
+ value: StructuredCloneValue;
703
+ }): void;
704
+ getValueForString(s: string, cfg: {
705
+ format: import('./formats.js').AvailableFormat;
706
+ state?: string | undefined;
707
+ endMatchTypeObjs?: TypeObject[] | undefined;
708
+ firstRun?: boolean | undefined;
709
+ rootHolder?: [type: string, parent: {
710
+ [key: string]: any;
711
+ } | undefined, parentPath: string | number | undefined, path: string][] | undefined;
712
+ parent?: {
713
+ [key: string]: any;
714
+ } | undefined;
715
+ parentPath?: string | number | undefined;
716
+ }): [
717
+ value: StructuredCloneValue,
718
+ remnant: string,
719
+ beginOnly: boolean,
720
+ assign: boolean
721
+ ];
722
+ /**
723
+ * @param {AvailableType} type
724
+ * @returns {Partial<TypeObject>|string[]}
725
+ */
726
+ getTypeObject(type: AvailableType): Partial<TypeObject> | string[];
727
+ }
728
+ declare namespace Types {
729
+ function getTypeForRoot(root: HTMLDivElement | null): string;
730
+ function validValuesSet(cfg: {
731
+ form: HTMLFormElement;
732
+ typeNamespace?: string | undefined;
733
+ keySelectClass?: string | undefined;
734
+ }): boolean;
735
+ }
736
+ import Formats from './formats.js';
503
737
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.js"],"names":[],"mappings":"AAiDO,mDAHI,iBAAiB,GACf,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;oBApLI,cAAc"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@es-joy/jsoe",
3
- "version": "0.12.4",
3
+ "version": "0.13.1",
4
4
  "type": "module",
5
5
  "types": "./dist/index.d.ts",
6
6
  "main": "./src/index.js",
@@ -1,7 +1,7 @@
1
1
  import {jml} from './vendor-imports.js';
2
2
  import {buildTypeChoices} from './typeChoices.js';
3
3
  import Types from './types.js';
4
- import {getControlsForFormatAndValue} from './formats.js';
4
+ import Formats from './formats.js';
5
5
  import {$e, DOM} from './utils/templateUtils.js';
6
6
 
7
7
  /**
@@ -90,6 +90,8 @@ export const getFormatAndSchemaChoices = ({schema, hasKeyPath} = {}) => {
90
90
  * plain object).
91
91
  * @param {string} [cfg.typeNamespace] Used to prevent conflicts with other
92
92
  * instances of typeChoices on the page
93
+ * @param {import('./formats.js').default} cfg.formats
94
+ * @param {import('./types.js').default} [cfg.types]
93
95
  * @returns {{
94
96
  * formatChoices: FormatChoices,
95
97
  * typesHolder: TypesHolder,
@@ -98,7 +100,9 @@ export const getFormatAndSchemaChoices = ({schema, hasKeyPath} = {}) => {
98
100
  * currentPath: string) => import('./formats.js').StructuredCloneValue,
99
101
  * getType: () => string,
100
102
  * validValuesSet: () => boolean,
101
- * setValue: SetValue
103
+ * setValue: SetValue,
104
+ * formats: import('./formats.js').default,
105
+ * types: import('./types.js').default
102
106
  * }} The selector for types and the container for them. Both should be
103
107
  * added to the page.
104
108
  */
@@ -108,7 +112,9 @@ export function formatAndTypeChoices ({
108
112
  hasValue,
109
113
  singleValue,
110
114
  hasKeyPath,
111
- typeNamespace
115
+ typeNamespace,
116
+ formats = new Formats(),
117
+ types = new Types()
112
118
  }) {
113
119
  const format = 'structuredCloning';
114
120
  const formatChoices = /** @type {FormatChoices} */ (jml('select', {
@@ -155,6 +161,8 @@ export function formatAndTypeChoices ({
155
161
  ),
156
162
  // resultType: 'both',
157
163
  format: this.value,
164
+ formats,
165
+ types,
158
166
  typeNamespace,
159
167
  requireObject: hasKeyPath,
160
168
  objectHasValue: hasValue,
@@ -206,6 +214,8 @@ export function formatAndTypeChoices ({
206
214
  // resultType: 'both',
207
215
  topRoot: /** @type {HTMLDivElement} */ ($e(typesHolder, 'div[data-type]')),
208
216
  format,
217
+ formats,
218
+ types,
209
219
  typeNamespace,
210
220
  requireObject: hasKeyPath,
211
221
  objectHasValue: hasValue,
@@ -214,6 +224,8 @@ export function formatAndTypeChoices ({
214
224
  }).domArray}, typesHolder);
215
225
 
216
226
  return {
227
+ formats,
228
+ types,
217
229
  formatChoices,
218
230
  typesHolder,
219
231
  // Easier for Jamilih
@@ -232,11 +244,13 @@ export function formatAndTypeChoices ({
232
244
  const root = /** @type {HTMLDivElement & {$getTypeRoot: TypeRootGetter}} */ (
233
245
  typesHolder
234
246
  ).$getTypeRoot();
235
- return Types.getValueForRoot(/** @type {HTMLDivElement} */ (root), {
247
+ return types.getValueForRoot(/** @type {HTMLDivElement} */ (root), {
236
248
  typeNamespace,
237
249
  format: /** @type {import('./formats.js').AvailableFormat} */ (
238
250
  formatChoices.value
239
251
  ),
252
+ formats,
253
+ types,
240
254
  ...stateObj
241
255
  }, currentPath);
242
256
  },
@@ -269,7 +283,8 @@ export function formatAndTypeChoices ({
269
283
  /** @type {SetValue} */
270
284
  async setValue (value, stateObj) {
271
285
  const rootEditUI = /** @type {HTMLDivElement} */ (
272
- await getControlsForFormatAndValue(
286
+ await formats.getControlsForFormatAndValue(
287
+ types,
273
288
  /** @type {import('./formats.js').AvailableFormat} */ (
274
289
  formatChoices.value
275
290
  ),
@@ -32,7 +32,7 @@ const indexedDBKey = {
32
32
  stateObj.format = 'indexedDBKey';
33
33
  return structuredCloning.iterate(records, stateObj);
34
34
  },
35
- getTypesForState (state) {
35
+ getTypesForState (types, state) {
36
36
  if (!state || ['array'].includes(state)) {
37
37
  return this.types();
38
38
  }