@json-layout/core 0.21.1 → 0.22.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 (50) hide show
  1. package/package.json +1 -1
  2. package/src/compile/index.js +17 -9
  3. package/src/compile/serialize.js +2 -1
  4. package/src/compile/skeleton-node.js +78 -23
  5. package/src/compile/skeleton-tree.js +22 -2
  6. package/src/compile/types.ts +3 -2
  7. package/src/compile/utils/resolve-refs.js +99 -38
  8. package/src/state/index.js +11 -7
  9. package/src/state/state-node.js +12 -9
  10. package/src/state/types.ts +2 -2
  11. package/types/compile/index.d.ts +0 -16
  12. package/types/compile/index.d.ts.map +0 -1
  13. package/types/compile/serialize.d.ts +0 -6
  14. package/types/compile/serialize.d.ts.map +0 -1
  15. package/types/compile/skeleton-node.d.ts +0 -18
  16. package/types/compile/skeleton-node.d.ts.map +0 -1
  17. package/types/compile/skeleton-tree.d.ts +0 -13
  18. package/types/compile/skeleton-tree.d.ts.map +0 -1
  19. package/types/compile/types.d.ts +0 -57
  20. package/types/compile/types.d.ts.map +0 -1
  21. package/types/compile/utils/resolve-refs.d.ts +0 -9
  22. package/types/compile/utils/resolve-refs.d.ts.map +0 -1
  23. package/types/i18n/en.d.ts +0 -3
  24. package/types/i18n/en.d.ts.map +0 -1
  25. package/types/i18n/fr.d.ts +0 -3
  26. package/types/i18n/fr.d.ts.map +0 -1
  27. package/types/i18n/index.d.ts +0 -3
  28. package/types/i18n/index.d.ts.map +0 -1
  29. package/types/i18n/types.d.ts +0 -36
  30. package/types/i18n/types.d.ts.map +0 -1
  31. package/types/index.d.ts +0 -5
  32. package/types/index.d.ts.map +0 -1
  33. package/types/state/index.d.ts +0 -285
  34. package/types/state/index.d.ts.map +0 -1
  35. package/types/state/state-node.d.ts +0 -36
  36. package/types/state/state-node.d.ts.map +0 -1
  37. package/types/state/state-tree.d.ts +0 -13
  38. package/types/state/state-tree.d.ts.map +0 -1
  39. package/types/state/types.d.ts +0 -175
  40. package/types/state/types.d.ts.map +0 -1
  41. package/types/state/utils/display.d.ts +0 -51
  42. package/types/state/utils/display.d.ts.map +0 -1
  43. package/types/state/utils/immutable.d.ts +0 -21
  44. package/types/state/utils/immutable.d.ts.map +0 -1
  45. package/types/utils/build.d.ts +0 -5
  46. package/types/utils/build.d.ts.map +0 -1
  47. package/types/utils/clone.d.ts +0 -3
  48. package/types/utils/clone.d.ts.map +0 -1
  49. package/types/utils/doc-options.d.ts +0 -14
  50. package/types/utils/doc-options.d.ts.map +0 -1
@@ -67,7 +67,7 @@ const produceStateNodeMessages = produce((draft, layoutMessages, options) => {
67
67
 
68
68
  /** @type {(draft: Record<string, unknown>, parentDataPath: string, children?: import('../index.js').StateNode[], additionalPropertiesErrors?: import('ajv').ErrorObject[], propertyKeys?: string[], removePropertyKeys?: string[]) => Record<string, unknown>} */
69
69
  const produceStateNodeData = produce((draft, parentDataPath, children, additionalPropertiesErrors, propertyKeys, removePropertyKeys) => {
70
- if (propertyKeys) {
70
+ if (propertyKeys && (propertyKeys.length || children?.length)) {
71
71
  for (const key of Object.keys(draft)) {
72
72
  if (!propertyKeys.includes(key)) delete draft[key]
73
73
  }
@@ -159,7 +159,10 @@ const matchError = (error, skeleton, dataPath, parentDataPath) => {
159
159
  * @returns {boolean}
160
160
  */
161
161
  const matchChildError = (error, skeleton, dataPath, parentDataPath) => {
162
- if (!error.schemaPath.startsWith(skeleton.pointer)) return false
162
+ if (!(
163
+ error.schemaPath === skeleton.pointer ||
164
+ error.schemaPath.startsWith(skeleton.pointer + '/')
165
+ )) return false
163
166
  if (error.instancePath.startsWith(dataPath)) return true
164
167
  return false
165
168
  }
@@ -262,7 +265,7 @@ export function createStateNode (
262
265
  // NOTE we have to exclude nodes with errors from the cache, because context.errors is unpurely modified
263
266
  // TODO: implement a cleaner way to filter context.errors while being able to reuse nodes with errors
264
267
  if (skeleton.pure && reusedNode && !reusedNode.error && !reusedNode.childError) {
265
- cacheKey = [parentOptions, compiledLayout, fullKey, skeleton, childDefinition, parentDisplay.width, validationState, context.activeItems, context.initial, data]
268
+ cacheKey = [parentOptions, compiledLayout, fullKey, skeleton, childDefinition, parentDisplay.width, validationState, context.activatedItems, context.initial, data]
266
269
  if (context.cacheKeys[fullKey] && shallowEqualArray(context.cacheKeys[fullKey], cacheKey)) {
267
270
  return reusedNode
268
271
  }
@@ -334,7 +337,7 @@ export function createStateNode (
334
337
  if (key === '$oneOf' && skeleton.childrenTrees) {
335
338
  // find the oneOf child that was either previously selected, if none were selected select the child that is valid with current data
336
339
  /** @type {number} */
337
- const activeChildTreeIndex = fullKey in context.activeItems ? context.activeItems[fullKey] : skeleton.childrenTrees?.findIndex((childTree) => compiledLayout.validates[childTree.root.pointer](data))
340
+ const activeChildTreeIndex = fullKey in context.activatedItems ? context.activatedItems[fullKey] : skeleton.childrenTrees?.findIndex((childTree) => compiledLayout.validates[compiledLayout.skeletonTrees[childTree].root.pointer](data))
338
341
  if (activeChildTreeIndex !== -1) {
339
342
  context.errors = context.errors?.filter(error => {
340
343
  const originalError = error.params?.errors?.[0] ?? error
@@ -344,10 +347,9 @@ export function createStateNode (
344
347
  if (originalError.schemaPath.startsWith(skeleton.pointer) && !originalError.schemaPath.startsWith(skeleton.pointer + '/' + activeChildTreeIndex)) return false
345
348
  return true
346
349
  })
347
- context.activeItems = produce(context.activeItems, draft => { draft[fullKey] = activeChildTreeIndex })
348
350
  const activeChildKey = `${fullKey}/${activeChildTreeIndex}`
349
351
  if (context.autofocusTarget === fullKey) context.autofocusTarget = activeChildKey
350
- const activeChildTree = skeleton.childrenTrees[activeChildTreeIndex]
352
+ const activeChildTree = compiledLayout.skeletonTrees[skeleton.childrenTrees[activeChildTreeIndex]]
351
353
  children = [
352
354
  createStateNode(
353
355
  context,
@@ -372,7 +374,7 @@ export function createStateNode (
372
374
 
373
375
  if (layout.comp === 'list') {
374
376
  const arrayData = /** @type {unknown[]} */(data ?? [])
375
- const childSkeleton = /** @type {import('../index.js').SkeletonNode} */(skeleton?.childrenTrees?.[0]?.root)
377
+ const childSkeleton = /** @type {import('../index.js').SkeletonNode} */(skeleton?.childrenTrees?.[0] && compiledLayout.skeletonTrees[skeleton?.childrenTrees?.[0]]?.root)
376
378
  const listItemOptions = layout.listEditMode === 'inline' ? options : produceReadonlyArrayItemOptions(options)
377
379
  children = []
378
380
  let focusChild = context.autofocusTarget === fullKey
@@ -382,7 +384,7 @@ export function createStateNode (
382
384
  if (focusChild) context.autofocusTarget = childFullKey
383
385
  const child = createStateNode(
384
386
  context,
385
- (layout.listEditMode === 'inline-single' && context.activeItems[fullKey] === i) ? options : listItemOptions,
387
+ (layout.listEditMode === 'inline-single' && context.activatedItems[fullKey] === i) ? options : listItemOptions,
386
388
  compiledLayout,
387
389
  i,
388
390
  childFullKey,
@@ -420,7 +422,8 @@ export function createStateNode (
420
422
  (validationState.initialized === false && options.initialValidation === 'always') ||
421
423
  (validationState.initialized === false && options.initialValidation === 'withData' && !isDataEmpty(data))
422
424
 
423
- let nodeData = children
425
+ /** @type {unknown} */
426
+ let nodeData = typeof data === 'object' && !(data instanceof File)
424
427
  ? produceStateNodeData(
425
428
  /** @type {Record<string, unknown>} */(data ?? {}),
426
429
  dataPath,
@@ -62,7 +62,7 @@ export interface CreateStateTreeContext {
62
62
  errors?: ErrorObject[]
63
63
  additionalPropertiesErrors?: ErrorObject[]
64
64
  files: FileRef[]
65
- activeItems: Record<string, number>
65
+ activatedItems: Record<string, number>
66
66
  autofocusTarget: string | null
67
67
  initial: boolean
68
68
  rehydrate: boolean
@@ -76,7 +76,7 @@ export interface FileRef {
76
76
  dataPath: string
77
77
  }
78
78
 
79
- // [parentOptions, compiledLayout, fullKey, skeleton, childDefinition, parentWidth, validationState, activeItems, initial, data]
79
+ // [parentOptions, compiledLayout, fullKey, skeleton, childDefinition, parentWidth, validationState, activatedItems, initial, data]
80
80
  export type StateNodeCacheKey = [
81
81
  StateNodeOptions,
82
82
  CompiledLayout,
@@ -1,16 +0,0 @@
1
- /**
2
- * @param {object} _schema
3
- * @param {PartialCompileOptions} [partialOptions]
4
- * @returns {CompiledLayout}
5
- */
6
- export function compile(_schema: object, partialOptions?: import("./types.js").PartialCompileOptions | undefined): CompiledLayout;
7
- export { resolveRefs } from "./utils/resolve-refs.js";
8
- /** @type {(draft: PartialCompileOptions, newOptions: PartialCompileOptions) => PartialCompileOptions} */
9
- export const produceCompileOptions: (draft: PartialCompileOptions, newOptions: PartialCompileOptions) => PartialCompileOptions;
10
- export type SkeletonTree = import('./types.js').SkeletonTree;
11
- export type SkeletonNode = import('./types.js').SkeletonNode;
12
- export type CompiledLayout = import('./types.js').CompiledLayout;
13
- export type CompileOptions = import('./types.js').CompileOptions;
14
- export type PartialCompileOptions = import('./types.js').PartialCompileOptions;
15
- export type CompiledExpression = import('./types.js').CompiledExpression;
16
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/compile/index.js"],"names":[],"mappings":"AAgGA;;;;GAIG;AACH,iCAJW,MAAM,4EAEJ,cAAc,CAkF1B;;AAnJD,yGAAyG;AACzG,4CADmB,qBAAqB,cAAc,qBAAqB,KAAK,qBAAqB,CAQnG;2BAxBW,OAAO,YAAY,EAAE,YAAY;2BACjC,OAAO,YAAY,EAAE,YAAY;6BACjC,OAAO,YAAY,EAAE,cAAc;6BACnC,OAAO,YAAY,EAAE,cAAc;oCACnC,OAAO,YAAY,EAAE,qBAAqB;iCAC1C,OAAO,YAAY,EAAE,kBAAkB"}
@@ -1,6 +0,0 @@
1
- /**
2
- * @param {import('./index.js').CompiledLayout} compiledLayout
3
- * @returns {string}
4
- */
5
- export function serialize(compiledLayout: import('./index.js').CompiledLayout): string;
6
- //# sourceMappingURL=serialize.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"serialize.d.ts","sourceRoot":"","sources":["../../src/compile/serialize.js"],"names":[],"mappings":"AAoBA;;;GAGG;AACH,0CAHW,OAAO,YAAY,EAAE,cAAc,GACjC,MAAM,CAkFlB"}
@@ -1,18 +0,0 @@
1
- /**
2
- * @param {any} schema
3
- * @param {import('./index.js').CompileOptions} options
4
- * @param {string[]} validates
5
- * @param {Record<string, string[]>} validationErrors
6
- * @param {Record<string, import('@json-layout/vocabulary').NormalizedLayout>} normalizedLayouts
7
- * @param {import('@json-layout/vocabulary').Expression[]} expressions
8
- * @param {string | number} key
9
- * @param {string} pointer
10
- * @param {string | null} parentPointer
11
- * @param {boolean} required
12
- * @param {string} [condition]
13
- * @param {boolean} [dependent]
14
- * @param {string} [knownType]
15
- * @returns {import('./types.js').SkeletonNode}
16
- */
17
- export function makeSkeletonNode(schema: any, options: import('./index.js').CompileOptions, validates: string[], validationErrors: Record<string, string[]>, normalizedLayouts: Record<string, import('@json-layout/vocabulary').NormalizedLayout>, expressions: import('@json-layout/vocabulary').Expression[], key: string | number, pointer: string, parentPointer: string | null, required: boolean, condition?: string | undefined, dependent?: boolean | undefined, knownType?: string | undefined): import('./types.js').SkeletonNode;
18
- //# sourceMappingURL=skeleton-node.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"skeleton-node.d.ts","sourceRoot":"","sources":["../../src/compile/skeleton-node.js"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;GAeG;AACH,yCAfW,GAAG,WACH,OAAO,YAAY,EAAE,cAAc,aACnC,MAAM,EAAE,oBACR,OAAO,MAAM,EAAE,MAAM,EAAE,CAAC,qBACxB,OAAO,MAAM,EAAE,OAAO,yBAAyB,EAAE,gBAAgB,CAAC,eAClE,OAAO,yBAAyB,EAAE,UAAU,EAAE,OAC9C,MAAM,GAAG,MAAM,WACf,MAAM,iBACN,MAAM,GAAG,IAAI,YACb,OAAO,oGAIL,OAAO,YAAY,EAAE,YAAY,CAwT7C"}
@@ -1,13 +0,0 @@
1
- /**
2
- * @param {any} schema
3
- * @param {import('./index.js').CompileOptions} options
4
- * @param {string[]} validates
5
- * @param {Record<string, string[]>} validationErrors
6
- * @param {Record<string, import('@json-layout/vocabulary').NormalizedLayout>} normalizedLayouts
7
- * @param {import('@json-layout/vocabulary').Expression[]} expressions
8
- * @param {string} pointer
9
- * @param {string} title
10
- * @returns {import('./types.js').SkeletonTree}
11
- */
12
- export function makeSkeletonTree(schema: any, options: import('./index.js').CompileOptions, validates: string[], validationErrors: Record<string, string[]>, normalizedLayouts: Record<string, import('@json-layout/vocabulary').NormalizedLayout>, expressions: import('@json-layout/vocabulary').Expression[], pointer: string, title: string): import('./types.js').SkeletonTree;
13
- //# sourceMappingURL=skeleton-tree.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"skeleton-tree.d.ts","sourceRoot":"","sources":["../../src/compile/skeleton-tree.js"],"names":[],"mappings":"AAKA;;;;;;;;;;GAUG;AACH,yCAVW,GAAG,WACH,OAAO,YAAY,EAAE,cAAc,aACnC,MAAM,EAAE,oBACR,OAAO,MAAM,EAAE,MAAM,EAAE,CAAC,qBACxB,OAAO,MAAM,EAAE,OAAO,yBAAyB,EAAE,gBAAgB,CAAC,eAClE,OAAO,yBAAyB,EAAE,UAAU,EAAE,WAC9C,MAAM,SACN,MAAM,GACJ,OAAO,YAAY,EAAE,YAAY,CAe7C"}
@@ -1,57 +0,0 @@
1
- import type ajvModule from 'ajv/dist/2019.js';
2
- import type MarkdownIt from 'markdown-it';
3
- import { type ComponentInfo, type BaseCompObject, type NormalizedLayout, type StateNodeOptionsBase, type Expression } from '@json-layout/vocabulary';
4
- import { type ValidateFunction, type SchemaObject } from 'ajv/dist/2019.js';
5
- import { type Display } from '../state/utils/display.js';
6
- import { type LocaleMessages } from '../i18n/types.js';
7
- export interface ParentContextExpression {
8
- data: unknown;
9
- parent: ParentContextExpression | undefined | null;
10
- }
11
- export type CompiledExpression = (data: any, options: StateNodeOptionsBase, context: object, display: Display, layout: BaseCompObject, validates: Record<string, ValidateFunction>, rootData?: unknown, parent?: ParentContextExpression | null) => any;
12
- export interface CompileOptions {
13
- ajv: ajvModule.default;
14
- ajvOptions?: ajvModule.Options;
15
- code: boolean;
16
- markdown: (text: string) => string;
17
- markdownItOptions?: MarkdownIt.Options;
18
- locale: string;
19
- messages: LocaleMessages;
20
- optionsKeys: string[];
21
- components: Record<string, ComponentInfo>;
22
- }
23
- export type PartialCompileOptions = Partial<Omit<CompileOptions, 'messages'>> & {
24
- messages?: Partial<LocaleMessages>;
25
- components?: Record<string, Omit<ComponentInfo, 'name'>>;
26
- };
27
- export interface CompiledLayout {
28
- options?: CompileOptions;
29
- schema?: SchemaObject;
30
- skeletonTree: SkeletonTree;
31
- validates: Record<string, ValidateFunction>;
32
- validationErrors: Record<string, string[]>;
33
- normalizedLayouts: Record<string, NormalizedLayout>;
34
- expressions: CompiledExpression[];
35
- locale: string;
36
- messages: LocaleMessages;
37
- components: Record<string, Omit<ComponentInfo, 'schema'>>;
38
- localizeErrors: (errors: ajvModule.ErrorObject[]) => void;
39
- }
40
- export interface SkeletonTree {
41
- title: string;
42
- root: SkeletonNode;
43
- }
44
- export interface SkeletonNode {
45
- key: string | number;
46
- pointer: string;
47
- parentPointer: string | null;
48
- pure: boolean;
49
- propertyKeys: string[];
50
- roPropertyKeys: string[];
51
- condition?: Expression;
52
- children?: SkeletonNode[];
53
- childrenTrees?: SkeletonTree[];
54
- required?: boolean;
55
- nullable?: boolean;
56
- }
57
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/compile/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,kBAAkB,CAAA;AAC7C,OAAO,KAAK,UAAU,MAAM,aAAa,CAAA;AACzC,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,cAAc,EAAE,KAAK,gBAAgB,EAAE,KAAK,oBAAoB,EAAE,KAAK,UAAU,EAAE,MAAM,yBAAyB,CAAA;AACpJ,OAAO,EAAE,KAAK,gBAAgB,EAAE,KAAK,YAAY,EAAoB,MAAM,kBAAkB,CAAA;AAC7F,OAAO,EA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AO,CAAC,EAAE,cAAc,CAAA;IACxB,MAAM,CAAC,EAAE,YAAY,CAAA;IACrB,YAAY,EAAE,YAAY,CAAA;IAC1B,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAA;IAC3C,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAA;IAC1C,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAA;IACnD,WAAW,EAAE,kBAAkB,EAAE,CAAA;IACjC,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,cAAc,CAAA;IACxB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,aAAa,EAAE,QAAQ,CAAC,CAAC,CAAA;IACzD,cAAc,EAAE,CAAC,MAAM,EAAE,SAAS,CAAC,WAAW,EAAE,KAAK,IAAI,CAAA;CAC1D;AAID,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,YAAY,CAAA;CACnB;AAID,MAAM,WAAW,YAAY;IAC3B,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;IACpB,OAAO,EAAE,MAAM,CAAA;IACf,aAAa,EAAE,MAAM,GAAG,IAAI,CAAA;IAC5B,IAAI,EAAE,OAAO,CAAA;IACb,YAAY,EAAE,MAAM,EAAE,CAAA;IACtB,cAAc,EAAE,MAAM,EAAE,CAAA;IACxB,SAAS,CAAC,EAAE,UAAU,CAAA;IACtB,QAAQ,CAAC,EAAE,YAAY,EAAE,CAAA;IACzB,aAAa,CAAC,EAAE,YAAY,EAAE,CAAA;IAC9B,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB"}
@@ -1,9 +0,0 @@
1
- /**
2
- * @param {import('ajv').SchemaObject} schema
3
- * @param {ajvModule.default} ajv
4
- * @param {string} locale
5
- * @returns {import('ajv').SchemaObject}
6
- */
7
- export function resolveRefs(schema: import('ajv').SchemaObject, ajv: ajvModule.default, locale?: string): import('ajv').SchemaObject;
8
- import ajvModule from 'ajv/dist/2019.js';
9
- //# sourceMappingURL=resolve-refs.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"resolve-refs.d.ts","sourceRoot":"","sources":["../../../src/compile/utils/resolve-refs.js"],"names":[],"mappings":"AA2DA;;;;;GAKG;AACH,oCALW,OAAO,KAAK,EAAE,YAAY,OAC1B,UAAU,OAAO,WACjB,MAAM,GACJ,OAAO,KAAK,EAAE,YAAY,CAKtC;sBApEqB,kBAAkB"}
@@ -1,3 +0,0 @@
1
- declare const _default: import('./types.js').LocaleMessages;
2
- export default _default;
3
- //# sourceMappingURL=en.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"en.d.ts","sourceRoot":"","sources":["../../src/i18n/en.js"],"names":[],"mappings":"wBAAW,OAAO,YAAY,EAAE,cAAc"}
@@ -1,3 +0,0 @@
1
- declare const _default: import('./types.js').LocaleMessages;
2
- export default _default;
3
- //# sourceMappingURL=fr.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fr.d.ts","sourceRoot":"","sources":["../../src/i18n/fr.js"],"names":[],"mappings":"wBAAW,OAAO,YAAY,EAAE,cAAc"}
@@ -1,3 +0,0 @@
1
- declare const _default: Record<string, import('./types.js').LocaleMessages>;
2
- export default _default;
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/i18n/index.js"],"names":[],"mappings":"wBAGW,OAAO,MAAM,EAAE,OAAO,YAAY,EAAE,cAAc,CAAC"}
@@ -1,36 +0,0 @@
1
- export interface CompileOptionsMessages {
2
- errorOneOf: string;
3
- errorRequired: string;
4
- }
5
- export interface StateOptionsMessages {
6
- addItem: string;
7
- delete: string;
8
- edit: string;
9
- close: string;
10
- duplicate: string;
11
- sort: string;
12
- up: string;
13
- down: string;
14
- showHelp: string;
15
- mdeLink1: string;
16
- mdeLink2: string;
17
- mdeImg1: string;
18
- mdeImg2: string;
19
- mdeTable1: string;
20
- mdeTable2: string;
21
- bold: string;
22
- italic: string;
23
- heading: string;
24
- quote: string;
25
- unorderedList: string;
26
- orderedList: string;
27
- createLink: string;
28
- insertImage: string;
29
- createTable: string;
30
- preview: string;
31
- mdeGuide: string;
32
- undo: string;
33
- redo: string;
34
- }
35
- export type LocaleMessages = CompileOptionsMessages & StateOptionsMessages;
36
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/i18n/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,sBAAsB;IACrC,UAAU,EAAE,MAAM,CAAA;IAClB,aAAa,EAAE,MAAM,CAAA;CACtB;AAED,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,SAAS,EAAE,MAAM,CAAA;IACjB,IAAI,EAAE,MAAM,CAAA;IACZ,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,MAAM,CAAA;IACf,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,MAAM,CAAA;IACjB,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,MAAM,CAAA;IACf,KAAK,EAAE,MAAM,CAAA;IACb,aAAa,EAAE,MAAM,CAAA;IACrB,WAAW,EAAE,MAAM,CAAA;IACnB,UAAU,EAAE,MAAM,CAAA;IAClB,WAAW,EAAE,MAAM,CAAA;IACnB,WAAW,EAAE,MAAM,CAAA;IACnB,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,EAAE,MAAM,CAAA;IAChB,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;CACb;AAED,MAAM,MAAM,cAAc,GAAG,sBAAsB,GAAG,oBAAoB,CAAA"}
package/types/index.d.ts DELETED
@@ -1,5 +0,0 @@
1
- export * from "./compile/index.js";
2
- export * from "./state/index.js";
3
- export { default as i18n } from "./i18n/index.js";
4
- export { default as clone } from "./utils/clone.js";
5
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":""}
@@ -1,285 +0,0 @@
1
- export { Display } from "./utils/display.js";
2
- /**
3
- * @typedef {import('./types.js').StateNode} StateNode
4
- * @typedef {import('./types.js').StateTree} StateTree
5
- * @typedef {import('./types.js').StatefulLayoutOptions} StatefulLayoutOptions
6
- * @typedef {import('./types.js').StatefulLayoutEvents} StatefulLayoutEvents
7
- * @typedef {import('./types.js').CreateStateTreeContext} CreateStateTreeContext
8
- * @typedef {import('./types.js').TextFieldNode} TextFieldNode
9
- * @typedef {import('./types.js').TextareaNode} TextareaNode
10
- * @typedef {import('./types.js').NumberFieldNode} NumberFieldNode
11
- * @typedef {import('./types.js').SliderNode} SliderNode
12
- * @typedef {import('./types.js').SectionNode} SectionNode
13
- * @typedef {import('./types.js').SelectNode} SelectNode
14
- * @typedef {import('./types.js').AutocompleteNode} AutocompleteNode
15
- * @typedef {import('./types.js').RadioGroupNode} RadioGroupNode
16
- * @typedef {import('./types.js').CheckboxGroupNode} CheckboxGroupNode
17
- * @typedef {import('./types.js').SwitchGroupNode} SwitchGroupNode
18
- * @typedef {import('./types.js').ComboboxNode} ComboboxNode
19
- * @typedef {import('./types.js').CheckboxNode} CheckboxNode
20
- * @typedef {import('./types.js').SwitchNode} SwitchNode
21
- * @typedef {import('./types.js').ColorPickerNode} ColorPickerNode
22
- * @typedef {import('./types.js').DatePickerNode} DatePickerNode
23
- * @typedef {import('./types.js').DateTimePickerNode} DateTimePickerNode
24
- * @typedef {import('./types.js').TimePickerNode} TimePickerNode
25
- * @typedef {import('./types.js').ExpansionPanelsNode} ExpansionPanelsNode
26
- * @typedef {import('./types.js').TabsNode} TabsNode
27
- * @typedef {import('./types.js').VerticalTabsNode} VerticalTabsNode
28
- * @typedef {import('./types.js').StepperNode} StepperNode
29
- * @typedef {import('./types.js').OneOfSelectNode} OneOfSelectNode
30
- * @typedef {import('./types.js').ListNode} ListNode
31
- * @typedef {import('./types.js').FileInputNode} FileInputNode
32
- * @typedef {import('./types.js').FileRef} FileRef
33
- */
34
- /** @type {(node: StateNode | undefined) => node is SectionNode} */
35
- export const isSection: (node: StateNode | undefined) => node is import("./types.js").SectionNode;
36
- /** @type {(node: StateNode | undefined, components: Record<string, import('@json-layout/vocabulary').ComponentInfo>) => node is SelectNode | ComboboxNode | AutocompleteNode} */
37
- export const isItemsNode: (node: StateNode | undefined, components: Record<string, import('@json-layout/vocabulary').ComponentInfo>) => node is import("./types.js").SelectNode | import("./types.js").AutocompleteNode | import("./types.js").ComboboxNode;
38
- export class StatefulLayout {
39
- /**
40
- * @param {import("../index.js").CompiledLayout} compiledLayout
41
- * @param {import("../index.js").SkeletonTree} skeletonTree
42
- * @param {Partial<StatefulLayoutOptions>} options
43
- * @param {unknown} [data]
44
- */
45
- constructor(compiledLayout: import("../index.js").CompiledLayout, skeletonTree: import("../index.js").SkeletonTree, options: Partial<StatefulLayoutOptions>, data?: unknown);
46
- /**
47
- * @readonly
48
- * @type {import('mitt').Emitter<StatefulLayoutEvents>}
49
- */
50
- readonly events: import('mitt').Emitter<StatefulLayoutEvents>;
51
- /**
52
- * @private
53
- * @readonly
54
- * @type {import('../index.js').CompiledLayout}
55
- */
56
- private readonly _compiledLayout;
57
- get compiledLayout(): import("../compile/types.js").CompiledLayout;
58
- /**
59
- * @private
60
- * @type {StateTree}
61
- */
62
- private _stateTree;
63
- get stateTree(): import("./types.js").StateTree;
64
- /**
65
- * @readonly
66
- * @type {import('../index.js').SkeletonTree}
67
- */
68
- readonly skeletonTree: import('../index.js').SkeletonTree;
69
- /**
70
- * @private
71
- * @type {Display}
72
- */
73
- private _display;
74
- get display(): Display;
75
- /**
76
- * @private
77
- * @type {import('./types.js').ValidationState}
78
- */
79
- private _validationState;
80
- /**
81
- * @private
82
- * @param {Partial<import('./types.js').ValidationState>} validationState
83
- */
84
- set validationState(arg: import("./types.js").ValidationState);
85
- /**
86
- * @returns {import('./types.js').ValidationState}
87
- */
88
- get validationState(): import("./types.js").ValidationState;
89
- /**
90
- * @private
91
- * @type {StatefulLayoutOptions}
92
- */
93
- private _options;
94
- /**
95
- * @param {Partial<StatefulLayoutOptions>} options
96
- */
97
- set options(arg: import("./types.js").StatefulLayoutOptions);
98
- /**
99
- * @returns {StatefulLayoutOptions}
100
- */
101
- get options(): import("./types.js").StatefulLayoutOptions;
102
- /**
103
- * @private
104
- * @type {unknown}
105
- */
106
- private _data;
107
- set data(arg: unknown);
108
- get data(): unknown;
109
- /**
110
- * @private
111
- * @type {unknown}
112
- */
113
- private _previousData;
114
- /**
115
- * @private
116
- * @type {boolean}
117
- */
118
- private _dataWaitingForBlur;
119
- /**
120
- * @private
121
- * @type {CreateStateTreeContext}
122
- */
123
- private _lastCreateStateTreeContext;
124
- /**
125
- * @private
126
- * @type {string | null}
127
- */
128
- private _autofocusTarget;
129
- /**
130
- * @private
131
- * @type {string | null}
132
- */
133
- private _previousAutofocusTarget;
134
- /**
135
- * @type {FileRef[]}
136
- */
137
- files: FileRef[];
138
- /**
139
- * @type {Record<string, number>}
140
- */
141
- activeItems: Record<string, number>;
142
- /**
143
- * @private
144
- * @param {Partial<StatefulLayoutOptions>} options
145
- */
146
- private prepareOptions;
147
- /**
148
- * @private
149
- */
150
- private initValidationState;
151
- /**
152
- * @private
153
- */
154
- private updateState;
155
- /**
156
- * @private
157
- */
158
- private emitData;
159
- /**
160
- * @private
161
- * @param {boolean} rehydrate
162
- */
163
- private createStateTree;
164
- validate(): void;
165
- resetValidation(): void;
166
- /**
167
- * @returns {boolean}
168
- */
169
- get valid(): boolean;
170
- /**
171
- * @returns {string[]}
172
- */
173
- get errors(): string[];
174
- /**
175
- * @returns {boolean}
176
- */
177
- get hasHiddenError(): boolean;
178
- /**
179
- * @private
180
- * @param {StateNode} node
181
- * @returns {import('../compile/types.js').ParentContextExpression | null}
182
- */
183
- private getParentContextExpression;
184
- /**
185
- * @param {StateNode} node
186
- * @param {import('@json-layout/vocabulary').Expression} expression
187
- * @param {any} data
188
- * @returns {any}
189
- */
190
- evalNodeExpression(node: StateNode, expression: import('@json-layout/vocabulary').Expression, data: any): any;
191
- /**
192
- * @private
193
- * @param {StateNode} node
194
- * @param {unknown} data
195
- * @param {boolean} [validated]
196
- * @param {number} [activateKey]
197
- */
198
- private applyInput;
199
- /**
200
- * @private
201
- * @type {null | [StateNode, unknown, boolean, number | undefined, ReturnType<typeof setTimeout>]}
202
- */
203
- private debouncedInput;
204
- applyDebouncedInput(): void;
205
- /**
206
- * @param {StateNode} node
207
- * @param {unknown} data
208
- * @param {number} [activateKey]
209
- */
210
- input(node: StateNode, data: unknown, activateKey?: number | undefined): void;
211
- /**
212
- * @param {StateNode} node
213
- */
214
- blur(node: StateNode): void;
215
- /**
216
- * @param {StateNode} node
217
- */
218
- validateNodeRecurse(node: StateNode): void;
219
- /**
220
- * @private
221
- * @type {Record<string, {key: any, appliedQ: boolean, items: import('@json-layout/vocabulary').SelectItems}>}
222
- */
223
- private _itemsCache;
224
- /**
225
- * @private
226
- * @param {StateNode} node
227
- * @param {string} q
228
- * @returns {Promise<{appliedQ: boolean, items: import('@json-layout/vocabulary').SelectItems}>}
229
- */
230
- private getItemsWithoutCache;
231
- /**
232
- * @param {StateNode} node
233
- * @param {string} q
234
- * @returns {Promise<import('@json-layout/vocabulary').SelectItems>}
235
- */
236
- getItems(node: StateNode, q?: string): Promise<import('@json-layout/vocabulary').SelectItems>;
237
- /**
238
- * @param {StateNode} node
239
- * @param {any} rawItem
240
- * @returns {import('@json-layout/vocabulary').SelectItem}
241
- */
242
- prepareSelectItem(node: StateNode, rawItem: any): import('@json-layout/vocabulary').SelectItem;
243
- /**
244
- * @param {StateNode} node
245
- * @param {number} key
246
- */
247
- activateItem(node: StateNode, key: number): void;
248
- /**
249
- * @param {StateNode} node
250
- */
251
- deactivateItem(node: StateNode): void;
252
- handleAutofocus(): void;
253
- }
254
- export type StateNode = import('./types.js').StateNode;
255
- export type StateTree = import('./types.js').StateTree;
256
- export type StatefulLayoutOptions = import('./types.js').StatefulLayoutOptions;
257
- export type StatefulLayoutEvents = import('./types.js').StatefulLayoutEvents;
258
- export type CreateStateTreeContext = import('./types.js').CreateStateTreeContext;
259
- export type TextFieldNode = import('./types.js').TextFieldNode;
260
- export type TextareaNode = import('./types.js').TextareaNode;
261
- export type NumberFieldNode = import('./types.js').NumberFieldNode;
262
- export type SliderNode = import('./types.js').SliderNode;
263
- export type SectionNode = import('./types.js').SectionNode;
264
- export type SelectNode = import('./types.js').SelectNode;
265
- export type AutocompleteNode = import('./types.js').AutocompleteNode;
266
- export type RadioGroupNode = import('./types.js').RadioGroupNode;
267
- export type CheckboxGroupNode = import('./types.js').CheckboxGroupNode;
268
- export type SwitchGroupNode = import('./types.js').SwitchGroupNode;
269
- export type ComboboxNode = import('./types.js').ComboboxNode;
270
- export type CheckboxNode = import('./types.js').CheckboxNode;
271
- export type SwitchNode = import('./types.js').SwitchNode;
272
- export type ColorPickerNode = import('./types.js').ColorPickerNode;
273
- export type DatePickerNode = import('./types.js').DatePickerNode;
274
- export type DateTimePickerNode = import('./types.js').DateTimePickerNode;
275
- export type TimePickerNode = import('./types.js').TimePickerNode;
276
- export type ExpansionPanelsNode = import('./types.js').ExpansionPanelsNode;
277
- export type TabsNode = import('./types.js').TabsNode;
278
- export type VerticalTabsNode = import('./types.js').VerticalTabsNode;
279
- export type StepperNode = import('./types.js').StepperNode;
280
- export type OneOfSelectNode = import('./types.js').OneOfSelectNode;
281
- export type ListNode = import('./types.js').ListNode;
282
- export type FileInputNode = import('./types.js').FileInputNode;
283
- export type FileRef = import('./types.js').FileRef;
284
- import { Display } from './utils/display.js';
285
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/state/index.js"],"names":[],"mappings":";AAYA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,mEAAmE;AACnE,+BADkB,SAAS,GAAG,SAAS,8CACoC;AAE3E,iLAAiL;AACjL,iCADkB,SAAS,GAAG,SAAS,cAAc,OAAO,MAAM,EAAE,OAAO,yBAAyB,EAAE,aAAa,CAAC,yHACnB;AAoCjG;IAgIE;;;;;OAKG;IACH,4BALW,OAAO,aAAa,EAAE,cAAc,gBACpC,OAAO,aAAa,EAAE,YAAY,WAClC,QAAQ,qBAAqB,CAAC,SAC9B,OAAO,EAejB;IAlJD;;;OAGG;IACH,iBAFU,OAAO,MAAM,EAAE,OAAO,CAAC,oBAAoB,CAAC,CAEhD;IAEN;;;;OAIG;IACH,iCAAe;IACf,mEAAqD;IAErD;;;OAGG;IAEH,mBAAU;IACV,gDAA2C;IAE3C;;;OAGG;IACH,uBAFU,OAAO,aAAa,EAAE,YAAY,CAEhC;IAEZ;;;OAGG;IAEH,iBAAQ;IACR,uBAAuC;IAEvC;;;OAGG;IAEH,yBAAgB;IAQhB;;;OAGG;IACH,+DAOC;IAlBD;;OAEG;IACH,4DAEC;IAeD;;;OAGG;IAEH,iBAAQ;IAKR;;OAEG;IACH,6DAGC;IAVD;;OAEG;IACH,0DAAuC;IASvC;;;OAGG;IACH,cAAK;IAEL,uBAIC;IALD,oBAAiC;IAOjC;;;OAGG;IACH,sBAAa;IAEb;;;OAGG;IACH,4BAA2B;IAE3B;;;OAGG;IAEH,oCAA2B;IAE3B;;;OAGG;IACH,yBAAgB;IAChB;;;OAGG;IACH,iCAAwB;IAExB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