@stonecrop/schema 0.48.1 → 0.49.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.
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/badge.ts"],"sourcesContent":["import type { FieldOptions } from './field'\n\n/**\n * Semantic badge variant. Maps to theme tokens `--sc-badge-{variant}-*`.\n * @public\n */\nexport type BadgeVariant = 'neutral' | 'success' | 'warning' | 'danger' | 'brand'\n\n/**\n * Where ABadge paints the same descriptor.\n * @public\n */\nexport type BadgePresentation = 'cell-fill' | 'input-accent'\n\n/**\n * Per-choice badge configuration in a Select options map.\n * @public\n */\nexport interface BadgeSpecObject {\n\tvariant?: BadgeVariant\n\tcolor?: string\n\tlabel?: string\n}\n\n/**\n * Value in a choice→badge map: shorthand variant or object form.\n * @public\n */\nexport type BadgeSpec = BadgeVariant | BadgeSpecObject\n\n/**\n * Select field options when choices carry badge colors.\n * @public\n */\nexport interface SelectOptions extends Record<string, unknown> {\n\tchoices: string[]\n\tbadges?: Record<string, BadgeSpec>\n}\n\n/**\n * Resolved badge for rendering. Returned by `format` or built from an options map.\n * @public\n */\nexport interface BadgeDescriptor {\n\tlabel: string\n\tvariant?: BadgeVariant\n\tcolor?: string\n}\n\nconst BADGE_VARIANTS = new Set<string>(['neutral', 'success', 'warning', 'danger', 'brand'])\n\nconst BADGE_SPEC_OBJECT_KEYS = new Set(['variant', 'color', 'label'])\n\nfunction isOptionsRecord(options: FieldOptions): options is Record<string, unknown> {\n\treturn !Array.isArray(options)\n}\n\nfunction isBadgeVariant(value: unknown): value is BadgeVariant {\n\treturn typeof value === 'string' && BADGE_VARIANTS.has(value)\n}\n\nfunction isBadgeSpecObject(value: unknown): value is BadgeSpecObject {\n\tif (value === null || typeof value !== 'object' || Array.isArray(value)) return false\n\tfor (const key of Object.keys(value)) {\n\t\tif (!BADGE_SPEC_OBJECT_KEYS.has(key)) return false\n\t}\n\tconst obj = value as BadgeSpecObject\n\tif (obj.variant !== undefined && !isBadgeVariant(obj.variant)) return false\n\tif (obj.color !== undefined && typeof obj.color !== 'string') return false\n\tif (obj.label !== undefined && typeof obj.label !== 'string') return false\n\treturn true\n}\n\nfunction isBadgeSpec(value: unknown): value is BadgeSpec {\n\treturn isBadgeVariant(value) || isBadgeSpecObject(value)\n}\n\n/**\n * Narrows an options record to the structured `{ choices, badges }` form. A type predicate rather\n * than a cast: `SelectOptions` requires `choices`, so asserting into it trips `no-unsafe-type-assertion`.\n */\nfunction isStructuredSelectOptions(options: Record<string, unknown>): options is SelectOptions {\n\treturn Array.isArray(options.choices)\n}\n\n/**\n * True when `value` is a resolved badge descriptor for ACell / ADropdown.\n * @public\n */\nexport function isBadgeDescriptor(value: unknown): value is BadgeDescriptor {\n\tif (value === null || typeof value !== 'object' || Array.isArray(value)) return false\n\t// Partial<> keeps this a widening assertion; asserting into BadgeDescriptor itself (required\n\t// `label`) narrows, which `no-unsafe-type-assertion` rejects.\n\tconst obj = value as Partial<BadgeDescriptor>\n\tif (typeof obj.label !== 'string') return false\n\tif (obj.variant !== undefined && !isBadgeVariant(obj.variant)) return false\n\tif (obj.color !== undefined && typeof obj.color !== 'string') return false\n\treturn true\n}\n\n/**\n * True when `options` is a Select choice map (`{ Open: \"warning\", ... }` or\n * `{ choices: [...], badges: {...} }`), not a quantity/currency/code config bag.\n * @public\n */\nexport function isSelectChoiceMap(options: FieldOptions | undefined): options is Record<string, BadgeSpec> {\n\tif (options === undefined || Array.isArray(options) || !isOptionsRecord(options)) return false\n\tif (isStructuredSelectOptions(options)) {\n\t\tconst badges = options.badges\n\t\tif (badges === undefined) return false\n\t\treturn Object.values(badges).every(isBadgeSpec)\n\t}\n\tconst entries = Object.entries(options)\n\tif (entries.length === 0) return false\n\treturn entries.every(([, value]) => isBadgeSpec(value))\n}\n\n/**\n * True when `options` uses the structured SelectOptions shape.\n * @public\n */\nexport function isSelectOptions(options: FieldOptions | undefined): options is SelectOptions {\n\tif (options === undefined || Array.isArray(options) || !isOptionsRecord(options)) return false\n\treturn isStructuredSelectOptions(options)\n}\n\n/**\n * Dropdown / filter choice strings.\n * @public\n */\nexport function selectChoices(options: FieldOptions | undefined): string[] {\n\tif (options === undefined) return []\n\tif (Array.isArray(options)) return options\n\tif (!isOptionsRecord(options)) return []\n\tif (isStructuredSelectOptions(options)) return options.choices\n\tif (isSelectChoiceMap(options)) return Object.keys(options)\n\treturn []\n}\n\nfunction normalizeBadgeSpec(spec: unknown, key: string): BadgeDescriptor {\n\tif (isBadgeVariant(spec)) {\n\t\treturn { label: key, variant: spec }\n\t}\n\t// A malformed spec still names a real choice, so keep the label and drop only the styling.\n\t// Reading `.variant`/`.color` off an unvalidated value is what let a misspelt variant reach the\n\t// DOM as an unmatched class, and threw outright on null.\n\tif (!isBadgeSpecObject(spec)) {\n\t\treturn { label: key }\n\t}\n\treturn {\n\t\tlabel: spec.label ?? key,\n\t\tvariant: spec.variant,\n\t\tcolor: spec.color,\n\t}\n}\n\nfunction lookupFromBareMap(map: Record<string, BadgeSpec>, key: string | undefined): BadgeDescriptor | undefined {\n\tif (key === undefined || key === '') return undefined\n\tif (!(key in map)) return undefined\n\treturn normalizeBadgeSpec(map[key], key)\n}\n\nfunction lookupFromStructured(options: SelectOptions, key: string | undefined): BadgeDescriptor | undefined {\n\tif (key === undefined || key === '') return undefined\n\tconst badges = options.badges\n\tif (!badges || !(key in badges)) return undefined\n\treturn normalizeBadgeSpec(badges[key], key)\n}\n\n/**\n * Resolve a stored choice value to a badge descriptor using field options.\n * @public\n */\nexport function lookupBadge(options: FieldOptions | undefined, key: string | undefined): BadgeDescriptor | undefined {\n\tif (options === undefined || key === undefined || key === '') return undefined\n\tif (Array.isArray(options)) return undefined\n\tif (!isOptionsRecord(options)) return undefined\n\tif (isStructuredSelectOptions(options)) return lookupFromStructured(options, key)\n\tif (isSelectChoiceMap(options)) return lookupFromBareMap(options, key)\n\treturn undefined\n}\n\n/**\n * Whether field options carry any badge mapping.\n * @public\n */\nexport function hasBadgeOptions(options: FieldOptions | undefined): boolean {\n\tif (options === undefined || Array.isArray(options)) return false\n\tif (!isOptionsRecord(options)) return false\n\tif (isStructuredSelectOptions(options)) return options.badges !== undefined && Object.keys(options.badges).length > 0\n\treturn isSelectChoiceMap(options)\n}\n"],"mappings":";;;;;AAiDA,IAAM,iCAAiB,IAAI,IAAY;CAAC;CAAW;CAAW;CAAW;CAAU;AAAO,CAAC;AAE3F,IAAM,yCAAyB,IAAI,IAAI;CAAC;CAAW;CAAS;AAAO,CAAC;AAEpE,SAAS,gBAAgB,SAA2D;CACnF,OAAO,CAAC,MAAM,QAAQ,OAAO;AAC9B;AAEA,SAAS,eAAe,OAAuC;CAC9D,OAAO,OAAO,UAAU,YAAY,eAAe,IAAI,KAAK;AAC7D;AAEA,SAAS,kBAAkB,OAA0C;CACpE,IAAI,UAAU,QAAQ,OAAO,UAAU,YAAY,MAAM,QAAQ,KAAK,GAAG,OAAO;CAChF,KAAK,MAAM,OAAO,OAAO,KAAK,KAAK,GAClC,IAAI,CAAC,uBAAuB,IAAI,GAAG,GAAG,OAAO;CAE9C,MAAM,MAAM;CACZ,IAAI,IAAI,YAAY,KAAA,KAAa,CAAC,eAAe,IAAI,OAAO,GAAG,OAAO;CACtE,IAAI,IAAI,UAAU,KAAA,KAAa,OAAO,IAAI,UAAU,UAAU,OAAO;CACrE,IAAI,IAAI,UAAU,KAAA,KAAa,OAAO,IAAI,UAAU,UAAU,OAAO;CACrE,OAAO;AACR;AAEA,SAAS,YAAY,OAAoC;CACxD,OAAO,eAAe,KAAK,KAAK,kBAAkB,KAAK;AACxD;;;;;AAMA,SAAS,0BAA0B,SAA4D;CAC9F,OAAO,MAAM,QAAQ,QAAQ,OAAO;AACrC;;;;;AAMA,SAAgB,kBAAkB,OAA0C;CAC3E,IAAI,UAAU,QAAQ,OAAO,UAAU,YAAY,MAAM,QAAQ,KAAK,GAAG,OAAO;CAGhF,MAAM,MAAM;C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OAAO;EACN,OAAO,KAAK,SAAS;EACrB,SAAS,KAAK;EACd,OAAO,KAAK;CACb;AACD;AAEA,SAAS,kBAAkB,KAAgC,KAAsD;CAChH,IAAI,QAAQ,KAAA,KAAa,QAAQ,IAAI,OAAO,KAAA;CAC5C,IAAI,EAAE,OAAO,MAAM,OAAO,KAAA;CAC1B,OAAO,mBAAmB,IAAI,MAAM,GAAG;AACxC;AAEA,SAAS,qBAAqB,SAAwB,KAAsD;CAC3G,IAAI,QAAQ,KAAA,KAAa,QAAQ,IAAI,OAAO,KAAA;CAC5C,MAAM,SAAS,QAAQ;CACvB,IAAI,CAAC,UAAU,EAAE,OAAO,SAAS,OAAO,KAAA;CACxC,OAAO,mBAAmB,OAAO,MAAM,GAAG;AAC3C;;;;;AAMA,SAAgB,YAAY,SAAmC,KAAsD;CACpH,IAAI,YAAY,KAAA,KAAa,QAAQ,KAAA,KAAa,QAAQ,IAAI,OAAO,KAAA;CACrE,IAAI,MAAM,QAAQ,OAAO,GAAG,OAAO,KAAA;CACnC,IAAI,CAAC,gBAAgB,OAAO,GAAG,OAAO,KAAA;CACtC,IAAI,0BAA0B,OAAO,GAAG,OAAO,qBAAqB,SAAS,GAAG;CAChF,IAAI,kBAAkB,OAAO,GAAG,OAAO,kBAAkB,SAAS,GAAG;AAEtE;;;;;AAMA,SAAgB,gBAAgB,SAA4C;CAC3E,IAAI,YAAY,KAAA,KAAa,MAAM,QAAQ,OAAO,GAAG,OAAO;CAC5D,IAAI,CAAC,gBAAgB,OAAO,GAAG,OAAO;CACtC,IAAI,0BAA0B,OAAO,GAAG,OAAO,QAAQ,WAAW,KAAA,KAAa,OAAO,KAAK,QAAQ,MAAM,CAAC,CAAC,SAAS;CACpH,OAAO,kBAAkB,OAAO;AACjC"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/badge.ts"],"sourcesContent":["import type { FieldOptions } from './field'\n\n/**\n * Semantic badge variant. Maps to theme tokens `--sc-badge-{variant}-*`.\n * @public\n */\nexport type BadgeVariant = 'neutral' | 'success' | 'warning' | 'danger' | 'brand'\n\n/**\n * Where ABadge paints the same descriptor.\n * @public\n */\nexport type BadgePresentation = 'cell-fill' | 'input-accent'\n\n/**\n * Per-choice badge configuration in a Select options map.\n * @public\n */\nexport interface BadgeSpecObject {\n\t/** Semantic variant, painted with the theme's `--sc-badge-{variant}-*` tokens */\n\tvariant?: BadgeVariant\n\t/** A CSS color painted over the variant's background, text and accent */\n\tcolor?: string\n\t/** Text the badge shows; the choice value when omitted */\n\tlabel?: string\n}\n\n/**\n * Value in a choice→badge map: shorthand variant or object form.\n * @public\n */\nexport type BadgeSpec = BadgeVariant | BadgeSpecObject\n\n/**\n * Select field options when choices carry badge colors.\n * @public\n */\nexport interface SelectOptions extends Record<string, unknown> {\n\t/** The stored values a field can take, in the order a dropdown lists them */\n\tchoices: string[]\n\t/** A badge per choice, keyed by the choice's stored value; a choice without one shows as plain text */\n\tbadges?: Record<string, BadgeSpec>\n}\n\n/**\n * Resolved badge for rendering. Returned by `format` or built from an options map.\n * @public\n */\nexport interface BadgeDescriptor {\n\t/** Text the badge shows */\n\tlabel: string\n\t/** Semantic variant, painted with the theme's `--sc-badge-{variant}-*` tokens */\n\tvariant?: BadgeVariant\n\t/** A CSS color painted over the variant's background, text and accent */\n\tcolor?: string\n}\n\nconst BADGE_VARIANTS = new Set<string>(['neutral', 'success', 'warning', 'danger', 'brand'])\n\nconst BADGE_SPEC_OBJECT_KEYS = new Set(['variant', 'color', 'label'])\n\nfunction isOptionsRecord(options: FieldOptions): options is Record<string, unknown> {\n\treturn !Array.isArray(options)\n}\n\nfunction isBadgeVariant(value: unknown): value is BadgeVariant {\n\treturn typeof value === 'string' && BADGE_VARIANTS.has(value)\n}\n\nfunction isBadgeSpecObject(value: unknown): value is BadgeSpecObject {\n\tif (value === null || typeof value !== 'object' || Array.isArray(value)) return false\n\tfor (const key of Object.keys(value)) {\n\t\tif (!BADGE_SPEC_OBJECT_KEYS.has(key)) return false\n\t}\n\tconst obj = value as BadgeSpecObject\n\tif (obj.variant !== undefined && !isBadgeVariant(obj.variant)) return false\n\tif (obj.color !== undefined && typeof obj.color !== 'string') return false\n\tif (obj.label !== undefined && typeof obj.label !== 'string') return false\n\treturn true\n}\n\nfunction isBadgeSpec(value: unknown): value is BadgeSpec {\n\treturn isBadgeVariant(value) || isBadgeSpecObject(value)\n}\n\n/**\n * Narrows an options record to the structured `{ choices, badges }` form. A type predicate rather\n * than a cast: `SelectOptions` requires `choices`, so asserting into it trips `no-unsafe-type-assertion`.\n */\nfunction isStructuredSelectOptions(options: Record<string, unknown>): options is SelectOptions {\n\treturn Array.isArray(options.choices)\n}\n\n/**\n * True when `value` is a resolved badge descriptor for ACell / ADropdown.\n * @public\n */\nexport function isBadgeDescriptor(value: unknown): value is BadgeDescriptor {\n\tif (value === null || typeof value !== 'object' || Array.isArray(value)) return false\n\t// Partial<> keeps this a widening assertion; asserting into BadgeDescriptor itself (required\n\t// `label`) narrows, which `no-unsafe-type-assertion` rejects.\n\tconst obj = value as Partial<BadgeDescriptor>\n\tif (typeof obj.label !== 'string') return false\n\tif (obj.variant !== undefined && !isBadgeVariant(obj.variant)) return false\n\tif (obj.color !== undefined && typeof obj.color !== 'string') return false\n\treturn true\n}\n\n/**\n * True when `options` is a Select choice map (`{ Open: \"warning\", ... }` or\n * `{ choices: [...], badges: {...} }`), not a quantity/currency/code config bag.\n * @public\n */\nexport function isSelectChoiceMap(options: FieldOptions | undefined): options is Record<string, BadgeSpec> {\n\tif (options === undefined || Array.isArray(options) || !isOptionsRecord(options)) return false\n\tif (isStructuredSelectOptions(options)) {\n\t\tconst badges = options.badges\n\t\tif (badges === undefined) return false\n\t\treturn Object.values(badges).every(isBadgeSpec)\n\t}\n\tconst entries = Object.entries(options)\n\tif (entries.length === 0) return false\n\treturn entries.every(([, value]) => isBadgeSpec(value))\n}\n\n/**\n * True when `options` uses the structured SelectOptions shape.\n * @public\n */\nexport function isSelectOptions(options: FieldOptions | undefined): options is SelectOptions {\n\tif (options === undefined || Array.isArray(options) || !isOptionsRecord(options)) return false\n\treturn isStructuredSelectOptions(options)\n}\n\n/**\n * Dropdown / filter choice strings.\n * @public\n */\nexport function selectChoices(options: FieldOptions | undefined): string[] {\n\tif (options === undefined) return []\n\tif (Array.isArray(options)) return options\n\tif (!isOptionsRecord(options)) return []\n\tif (isStructuredSelectOptions(options)) return options.choices\n\tif (isSelectChoiceMap(options)) return Object.keys(options)\n\treturn []\n}\n\nfunction normalizeBadgeSpec(spec: unknown, key: string): BadgeDescriptor {\n\tif (isBadgeVariant(spec)) {\n\t\treturn { label: key, variant: spec }\n\t}\n\t// A malformed spec still names a real choice, so keep the label and drop only the styling.\n\t// Reading `.variant`/`.color` off an unvalidated value is what let a misspelt variant reach the\n\t// DOM as an unmatched class, and threw outright on null.\n\tif (!isBadgeSpecObject(spec)) {\n\t\treturn { label: key }\n\t}\n\treturn {\n\t\tlabel: spec.label ?? key,\n\t\tvariant: spec.variant,\n\t\tcolor: spec.color,\n\t}\n}\n\nfunction lookupFromBareMap(map: Record<string, BadgeSpec>, key: string | undefined): BadgeDescriptor | undefined {\n\tif (key === undefined || key === '') return undefined\n\tif (!(key in map)) return undefined\n\treturn normalizeBadgeSpec(map[key], key)\n}\n\nfunction lookupFromStructured(options: SelectOptions, key: string | undefined): BadgeDescriptor | undefined {\n\tif (key === undefined || key === '') return undefined\n\tconst badges = options.badges\n\tif (!badges || !(key in badges)) return undefined\n\treturn normalizeBadgeSpec(badges[key], key)\n}\n\n/**\n * Resolve a stored choice value to a badge descriptor using field options.\n * @public\n */\nexport function lookupBadge(options: FieldOptions | undefined, key: string | undefined): BadgeDescriptor | undefined {\n\tif (options === undefined || key === undefined || key === '') return undefined\n\tif (Array.isArray(options)) return undefined\n\tif (!isOptionsRecord(options)) return undefined\n\tif (isStructuredSelectOptions(options)) return lookupFromStructured(options, key)\n\tif (isSelectChoiceMap(options)) return lookupFromBareMap(options, key)\n\treturn undefined\n}\n\n/**\n * Whether field options carry any badge mapping.\n * @public\n */\nexport function hasBadgeOptions(options: FieldOptions | undefined): boolean {\n\tif (options === undefined || Array.isArray(options)) return false\n\tif (!isOptionsRecord(options)) return false\n\tif (isStructuredSelectOptions(options)) return options.badges !== undefined && Object.keys(options.badges).length > 0\n\treturn isSelectChoiceMap(options)\n}\n"],"mappings":";;;;;AAyDA,IAAM,iCAAiB,IAAI,IAAY;CAAC;CAAW;CAAW;CAAW;CAAU;AAAO,CAAC;AAE3F,IAAM,yCAAyB,IAAI,IAAI;CAAC;CAAW;CAAS;AAAO,CAAC;AAEpE,SAAS,gBAAgB,SAA2D;CACnF,OAAO,CAAC,MAAM,QAAQ,OAAO;AAC9B;AAEA,SAAS,eAAe,OAAuC;CAC9D,OAAO,OAAO,UAAU,YAAY,eAAe,IAAI,KAAK;AAC7D;AAEA,SAAS,kBAAkB,OAA0C;CACpE,IAAI,UAAU,QAAQ,OAAO,UAAU,YAAY,MAAM,QAAQ,KAAK,GAAG,OAAO;CAChF,KAAK,MAAM,OAAO,OAAO,KAAK,KAAK,GAClC,IAAI,CAAC,uBAAuB,IAAI,GAAG,GAAG,OAAO;CAE9C,MAAM,MAAM;CACZ,IAAI,IAAI,YAAY,KAAA,KAAa,CAAC,eAAe,IAAI,OAAO,GAAG,OAAO;CACtE,IAAI,IAAI,UAAU,KAAA,KAAa,OAAO,IAAI,UAAU,UAAU,OAAO;CACrE,IAAI,IAAI,UAAU,KAAA,KAAa,OAAO,IAAI,UAAU,UAAU,OAAO;CACrE,OAAO;AACR;AAEA,SAAS,YAAY,OAAoC;CACxD,OAAO,eAAe,KAAK,KAAK,kBAAkB,KAAK;AACxD;;;;;AAMA,SAAS,0BAA0B,SAA4D;CAC9F,OAAO,MAAM,QAAQ,QAAQ,OAAO;AACrC;;;;;AAMA,SAAgB,kBAAkB,OAA0C;CAC3E,IAAI,UAAU,QAAQ,OAAO,UAAU,YAAY,MAAM,QAAQ,KAAK,GAAG,OAAO;CAGhF,MAAM,MAAM;CACZ,I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EACN,OAAO,KAAK,SAAS;EACrB,SAAS,KAAK;EACd,OAAO,KAAK;CACb;AACD;AAEA,SAAS,kBAAkB,KAAgC,KAAsD;CAChH,IAAI,QAAQ,KAAA,KAAa,QAAQ,IAAI,OAAO,KAAA;CAC5C,IAAI,EAAE,OAAO,MAAM,OAAO,KAAA;CAC1B,OAAO,mBAAmB,IAAI,MAAM,GAAG;AACxC;AAEA,SAAS,qBAAqB,SAAwB,KAAsD;CAC3G,IAAI,QAAQ,KAAA,KAAa,QAAQ,IAAI,OAAO,KAAA;CAC5C,MAAM,SAAS,QAAQ;CACvB,IAAI,CAAC,UAAU,EAAE,OAAO,SAAS,OAAO,KAAA;CACxC,OAAO,mBAAmB,OAAO,MAAM,GAAG;AAC3C;;;;;AAMA,SAAgB,YAAY,SAAmC,KAAsD;CACpH,IAAI,YAAY,KAAA,KAAa,QAAQ,KAAA,KAAa,QAAQ,IAAI,OAAO,KAAA;CACrE,IAAI,MAAM,QAAQ,OAAO,GAAG,OAAO,KAAA;CACnC,IAAI,CAAC,gBAAgB,OAAO,GAAG,OAAO,KAAA;CACtC,IAAI,0BAA0B,OAAO,GAAG,OAAO,qBAAqB,SAAS,GAAG;CAChF,IAAI,kBAAkB,OAAO,GAAG,OAAO,kBAAkB,SAAS,GAAG;AAEtE;;;;;AAMA,SAAgB,gBAAgB,SAA4C;CAC3E,IAAI,YAAY,KAAA,KAAa,MAAM,QAAQ,OAAO,GAAG,OAAO;CAC5D,IAAI,CAAC,gBAAgB,OAAO,GAAG,OAAO;CACtC,IAAI,0BAA0B,OAAO,GAAG,OAAO,QAAQ,WAAW,KAAA,KAAa,OAAO,KAAK,QAAQ,MAAM,CAAC,CAAC,SAAS;CACpH,OAAO,kBAAkB,OAAO;AACjC"}
package/dist/record.js CHANGED
@@ -1,4 +1,4 @@
1
- import { s as componentLinkExpansion, t as flattenFields } from "./flatten-BaPZLJ2O.js";
1
+ import { l as resolveLinkRenderMode, s as componentLinkExpansion, t as flattenFields } from "./flatten-BaPZLJ2O.js";
2
2
  //#region src/record.ts
3
3
  /**
4
4
  * Reduce a record's *inline* link values to the ids that get persisted.
@@ -21,19 +21,46 @@ import { s as componentLinkExpansion, t as flattenFields } from "./flatten-BaPZL
21
21
  * A fieldset's children are the record's own keys, since a fieldset is layout, so they are
22
22
  * reduced where every other field is.
23
23
  *
24
- * @param fields - the doctype's top-level fields
24
+ * A record also carries the rows of each relation its doctype declares in `links`, under the key
25
+ * the read path writes them to (`link.fieldname ?? key`), and each row is a record of the target
26
+ * doctype. Given `resolve`, those rows are reduced by the target doctype in turn, so a link picked
27
+ * inside a row leaves as its id too. A relation rendered as a picker is a link field, reduced above,
28
+ * never a record to descend into; {@link resolveLinkRenderMode} decides which, as it does for the
29
+ * read path.
30
+ *
31
+ * @param meta - the record's doctype
25
32
  * @param record - the record to reduce; not mutated
33
+ * @param resolve - finds a relation's target doctype by the `target` it declares; without it only
34
+ * the record's own fields are reduced, and a relation whose target it does not find keeps its rows
35
+ * as they came
26
36
  * @returns a shallow copy with every inline link reduced to its id
27
37
  * @public
28
38
  */
29
- function unwrapInlineLinks(fields, record) {
30
- const inline = new Set(flattenFields(fields).filter((field) => field.kind === "field" && Boolean(field.doctype)).filter((field) => componentLinkExpansion(field.component) === "inline").map((field) => field.fieldname));
31
- if (inline.size === 0) return record;
39
+ function unwrapInlineLinks(meta, record, resolve) {
40
+ const flat = flattenFields(meta.fields);
41
+ const inline = new Set(flat.filter((field) => field.kind === "field" && Boolean(field.doctype)).filter((field) => componentLinkExpansion(field.component) === "inline").map((field) => field.fieldname));
42
+ const nested = Object.entries(meta.links ?? {}).flatMap(([linkName, link]) => {
43
+ const fieldname = link.fieldname ?? linkName;
44
+ const mode = resolveLinkRenderMode(link, flat.find((field) => field.fieldname === fieldname)?.component);
45
+ const target = mode === "inline" ? void 0 : resolve?.(link.target);
46
+ return target ? [{
47
+ fieldname,
48
+ mode,
49
+ target
50
+ }] : [];
51
+ });
52
+ if (inline.size === 0 && nested.length === 0) return record;
32
53
  const result = { ...record };
33
54
  for (const [key, value] of Object.entries(result)) {
34
55
  if (!inline.has(key) || value === null || typeof value !== "object" || Array.isArray(value)) continue;
35
56
  if ("id" in value) result[key] = value.id;
36
57
  }
58
+ for (const { fieldname, mode, target } of nested) {
59
+ const value = result[fieldname];
60
+ const unwrapRow = (row) => unwrapInlineLinks(target, row, resolve);
61
+ if (mode === "table" && Array.isArray(value)) result[fieldname] = value.map((row) => row !== null && typeof row === "object" ? unwrapRow(row) : row);
62
+ else if (mode === "record" && value !== null && typeof value === "object" && !Array.isArray(value)) result[fieldname] = unwrapRow(value);
63
+ }
37
64
  return result;
38
65
  }
39
66
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"record.js","names":[],"sources":["../src/record.ts"],"sourcesContent":["import { componentLinkExpansion } from './component-meta'\nimport type { DoctypeField } from './field'\nimport { flattenFields } from './flatten'\n\n/**\n * Reduce a record's *inline* link values to the ids that get persisted.\n *\n * The adapter returns an inline link as `{ id, displayText }`, so that is what a record holds\n * everywhere it is read — the store, a list row, a form field. A column takes the id alone, so\n * this is the single definition of the shape a record leaves in, and it belongs at the boundary\n * a record crosses on its way to the server, never on the way into the store.\n *\n * Doing it on the way in destroys the text the adapter looked up: nothing else holds it, so the\n * field that resolved a moment ago renders its raw id, and the same record then renders\n * differently depending on whether anything had edited the form yet. That is the bug this exists\n * to prevent, and its damage is a wrong render, not a throw.\n *\n * Only *inline* links may be reduced. An inline link's value is indistinguishable by inspection\n * from an expanded one (`{ id, ...the whole target record }`), so `component` — which states\n * which of the two a field is — is what tells them apart, via {@link componentLinkExpansion}.\n * Reducing an expanded link would send the id in place of the record.\n *\n * A fieldset's children are the record's own keys, since a fieldset is layout, so they are\n * reduced where every other field is.\n *\n * @param fields - the doctype's top-level fields\n * @param record - the record to reduce; not mutated\n * @returns a shallow copy with every inline link reduced to its id\n * @public\n */\nexport function unwrapInlineLinks(fields: readonly DoctypeField[], record: Record<string, any>): Record<string, any> {\n\tconst inline = new Set(\n\t\tflattenFields(fields)\n\t\t\t.filter(field => field.kind === 'field' && Boolean(field.doctype))\n\t\t\t.filter(field => componentLinkExpansion(field.component) === 'inline')\n\t\t\t.map(field => field.fieldname)\n\t)\n\tif (inline.size === 0) return record\n\n\tconst result: Record<string, any> = { ...record }\n\tfor (const [key, value] of Object.entries(result)) {\n\t\tif (!inline.has(key) || value === null || typeof value !== 'object' || Array.isArray(value)) continue\n\t\t// `'id' in value` rather than a truthiness test: an inline link that was never resolved\n\t\t// is still a bare scalar, and reducing it a second time would be a no-op at best.\n\t\tif ('id' in value) result[key] = value.id\n\t}\n\treturn result\n}\n\n/**\n * A field's value, read part by part from the fields its `parts` names.\n *\n * @param parts - the field's `parts`: the field holding each part, keyed by part\n * @param record - the record holding those fields\n * @returns the value, keyed by part\n * @public\n */\nexport function readParts(\n\tparts: Readonly<Record<string, string>>,\n\trecord: Readonly<Record<string, unknown>>\n): Record<string, unknown> {\n\treturn Object.fromEntries(Object.entries(parts).map(([part, fieldname]) => [part, record[fieldname]]))\n}\n\n/**\n * The fields to set after a field's component edits its value: one per part that changed. A part\n * left alone keeps exactly what the record holds, and anything the component derives (a stock\n * quantity, a conversion factor) is no part, so it is never written.\n *\n * @param parts - the field's `parts`: the field holding each part, keyed by part\n * @param record - the record before the edit\n * @param value - the component's edited value, keyed by part\n * @returns the changed fields and their new values\n * @public\n */\nexport function partsPatch(\n\tparts: Readonly<Record<string, string>>,\n\trecord: Readonly<Record<string, unknown>>,\n\tvalue: Readonly<Record<string, unknown>>\n): Record<string, unknown> {\n\tconst patch: Record<string, unknown> = {}\n\tfor (const [part, fieldname] of Object.entries(parts)) {\n\t\tif (!Object.is(value[part], record[fieldname])) patch[fieldname] = value[part]\n\t}\n\treturn patch\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,SAAgB,kBAAkB,QAAiC,QAAkD;CACpH,MAAM,SAAS,IAAI,IAClB,cAAc,MAAM,CAAC,CACnB,QAAO,UAAS,MAAM,SAAS,WAAW,QAAQ,MAAM,OAAO,CAAC,CAAC,CACjE,QAAO,UAAS,uBAAuB,MAAM,SAAS,MAAM,QAAQ,CAAC,CACrE,KAAI,UAAS,MAAM,SAAS,CAC/B;CACA,IAAI,OAAO,SAAS,GAAG,OAAO;CAE9B,MAAM,SAA8B,EAAE,GAAG,OAAO;CAChD,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,MAAM,GAAG;EAClD,IAAI,CAAC,OAAO,IAAI,GAAG,KAAK,UAAU,QAAQ,OAAO,UAAU,YAAY,MAAM,QAAQ,KAAK,GAAG;EAG7F,IAAI,QAAQ,OAAO,OAAO,OAAO,MAAM;CACxC;CACA,OAAO;AACR;;;;;;;;;AAUA,SAAgB,UACf,OACA,QAC0B;CAC1B,OAAO,OAAO,YAAY,OAAO,QAAQ,KAAK,CAAC,CAAC,KAAK,CAAC,MAAM,eAAe,CAAC,MAAM,OAAO,UAAU,CAAC,CAAC;AACtG;;;;;;;;;;;;AAaA,SAAgB,WACf,OACA,QACA,OAC0B;CAC1B,MAAM,QAAiC,CAAC;CACxC,KAAK,MAAM,CAAC,MAAM,cAAc,OAAO,QAAQ,KAAK,GACnD,IAAI,CAAC,OAAO,GAAG,MAAM,OAAO,OAAO,UAAU,GAAG,MAAM,aAAa,MAAM;CAE1E,OAAO;AACR"}
1
+ {"version":3,"file":"record.js","names":[],"sources":["../src/record.ts"],"sourcesContent":["import { componentLinkExpansion, resolveLinkRenderMode } from './component-meta'\nimport type { DoctypeMeta } from './doctype'\nimport { flattenFields } from './flatten'\n\n/**\n * Reduce a record's *inline* link values to the ids that get persisted.\n *\n * The adapter returns an inline link as `{ id, displayText }`, so that is what a record holds\n * everywhere it is read — the store, a list row, a form field. A column takes the id alone, so\n * this is the single definition of the shape a record leaves in, and it belongs at the boundary\n * a record crosses on its way to the server, never on the way into the store.\n *\n * Doing it on the way in destroys the text the adapter looked up: nothing else holds it, so the\n * field that resolved a moment ago renders its raw id, and the same record then renders\n * differently depending on whether anything had edited the form yet. That is the bug this exists\n * to prevent, and its damage is a wrong render, not a throw.\n *\n * Only *inline* links may be reduced. An inline link's value is indistinguishable by inspection\n * from an expanded one (`{ id, ...the whole target record }`), so `component` — which states\n * which of the two a field is — is what tells them apart, via {@link componentLinkExpansion}.\n * Reducing an expanded link would send the id in place of the record.\n *\n * A fieldset's children are the record's own keys, since a fieldset is layout, so they are\n * reduced where every other field is.\n *\n * A record also carries the rows of each relation its doctype declares in `links`, under the key\n * the read path writes them to (`link.fieldname ?? key`), and each row is a record of the target\n * doctype. Given `resolve`, those rows are reduced by the target doctype in turn, so a link picked\n * inside a row leaves as its id too. A relation rendered as a picker is a link field, reduced above,\n * never a record to descend into; {@link resolveLinkRenderMode} decides which, as it does for the\n * read path.\n *\n * @param meta - the record's doctype\n * @param record - the record to reduce; not mutated\n * @param resolve - finds a relation's target doctype by the `target` it declares; without it only\n * the record's own fields are reduced, and a relation whose target it does not find keeps its rows\n * as they came\n * @returns a shallow copy with every inline link reduced to its id\n * @public\n */\nexport function unwrapInlineLinks(\n\tmeta: DoctypeMeta,\n\trecord: Record<string, any>,\n\tresolve?: (target: string) => DoctypeMeta | undefined\n): Record<string, any> {\n\tconst flat = flattenFields(meta.fields)\n\tconst inline = new Set(\n\t\tflat\n\t\t\t.filter(field => field.kind === 'field' && Boolean(field.doctype))\n\t\t\t.filter(field => componentLinkExpansion(field.component) === 'inline')\n\t\t\t.map(field => field.fieldname)\n\t)\n\tconst nested = Object.entries(meta.links ?? {}).flatMap(([linkName, link]) => {\n\t\tconst fieldname = link.fieldname ?? linkName\n\t\tconst mode = resolveLinkRenderMode(link, flat.find(field => field.fieldname === fieldname)?.component)\n\t\tconst target = mode === 'inline' ? undefined : resolve?.(link.target)\n\t\treturn target ? [{ fieldname, mode, target }] : []\n\t})\n\tif (inline.size === 0 && nested.length === 0) return record\n\n\tconst result: Record<string, any> = { ...record }\n\tfor (const [key, value] of Object.entries(result)) {\n\t\tif (!inline.has(key) || value === null || typeof value !== 'object' || Array.isArray(value)) continue\n\t\t// `'id' in value` rather than a truthiness test: an inline link that was never resolved\n\t\t// is still a bare scalar, and reducing it a second time would be a no-op at best.\n\t\tif ('id' in value) result[key] = value.id\n\t}\n\tfor (const { fieldname, mode, target } of nested) {\n\t\tconst value = result[fieldname]\n\t\tconst unwrapRow = (row: Record<string, any>) => unwrapInlineLinks(target, row, resolve)\n\t\tif (mode === 'table' && Array.isArray(value)) {\n\t\t\tresult[fieldname] = value.map(row => (row !== null && typeof row === 'object' ? unwrapRow(row) : row))\n\t\t} else if (mode === 'record' && value !== null && typeof value === 'object' && !Array.isArray(value)) {\n\t\t\tresult[fieldname] = unwrapRow(value)\n\t\t}\n\t}\n\treturn result\n}\n\n/**\n * A field's value, read part by part from the fields its `parts` names.\n *\n * @param parts - the field's `parts`: the field holding each part, keyed by part\n * @param record - the record holding those fields\n * @returns the value, keyed by part\n * @public\n */\nexport function readParts(\n\tparts: Readonly<Record<string, string>>,\n\trecord: Readonly<Record<string, unknown>>\n): Record<string, unknown> {\n\treturn Object.fromEntries(Object.entries(parts).map(([part, fieldname]) => [part, record[fieldname]]))\n}\n\n/**\n * The fields to set after a field's component edits its value: one per part that changed. A part\n * left alone keeps exactly what the record holds, and anything the component derives (a stock\n * quantity, a conversion factor) is no part, so it is never written.\n *\n * @param parts - the field's `parts`: the field holding each part, keyed by part\n * @param record - the record before the edit\n * @param value - the component's edited value, keyed by part\n * @returns the changed fields and their new values\n * @public\n */\nexport function partsPatch(\n\tparts: Readonly<Record<string, string>>,\n\trecord: Readonly<Record<string, unknown>>,\n\tvalue: Readonly<Record<string, unknown>>\n): Record<string, unknown> {\n\tconst patch: Record<string, unknown> = {}\n\tfor (const [part, fieldname] of Object.entries(parts)) {\n\t\tif (!Object.is(value[part], record[fieldname])) patch[fieldname] = value[part]\n\t}\n\treturn patch\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCA,SAAgB,kBACf,M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AAK,GAClG,OAAO,aAAa,UAAU,KAAK;CAErC;CACA,OAAO;AACR;;;;;;;;;AAUA,SAAgB,UACf,OACA,QAC0B;CAC1B,OAAO,OAAO,YAAY,OAAO,QAAQ,KAAK,CAAC,CAAC,KAAK,CAAC,MAAM,eAAe,CAAC,MAAM,OAAO,UAAU,CAAC,CAAC;AACtG;;;;;;;;;;;;AAaA,SAAgB,WACf,OACA,QACA,OAC0B;CAC1B,MAAM,QAAiC,CAAC;CACxC,KAAK,MAAM,CAAC,MAAM,cAAc,OAAO,QAAQ,KAAK,GACnD,IAAI,CAAC,OAAO,GAAG,MAAM,OAAO,OAAO,UAAU,GAAG,MAAM,aAAa,MAAM;CAE1E,OAAO;AACR"}
package/dist/schema.d.ts CHANGED
@@ -91,8 +91,11 @@ export declare type AuthoredDoctype = Record<string, unknown>;
91
91
  * @public
92
92
  */
93
93
  export declare interface BadgeDescriptor {
94
+ /** Text the badge shows */
94
95
  label: string;
96
+ /** Semantic variant, painted with the theme's `--sc-badge-{variant}-*` tokens */
95
97
  variant?: BadgeVariant;
98
+ /** A CSS color painted over the variant's background, text and accent */
96
99
  color?: string;
97
100
  }
98
101
 
@@ -113,8 +116,11 @@ export declare type BadgeSpec = BadgeVariant | BadgeSpecObject;
113
116
  * @public
114
117
  */
115
118
  export declare interface BadgeSpecObject {
119
+ /** Semantic variant, painted with the theme's `--sc-badge-{variant}-*` tokens */
116
120
  variant?: BadgeVariant;
121
+ /** A CSS color painted over the variant's background, text and accent */
117
122
  color?: string;
123
+ /** Text the badge shows; the choice value when omitted */
118
124
  label?: string;
119
125
  }
120
126
 
@@ -1655,7 +1661,9 @@ export declare function selectChoices(options: FieldOptions | undefined): string
1655
1661
  * @public
1656
1662
  */
1657
1663
  export declare interface SelectOptions extends Record<string, unknown> {
1664
+ /** The stored values a field can take, in the order a dropdown lists them */
1658
1665
  choices: string[];
1666
+ /** A badge per choice, keyed by the choice's stored value; a choice without one shows as plain text */
1659
1667
  badges?: Record<string, BadgeSpec>;
1660
1668
  }
1661
1669
 
@@ -1882,12 +1890,22 @@ export declare type TriggerDefinition = z.infer<typeof TriggerDefinition>;
1882
1890
  * A fieldset's children are the record's own keys, since a fieldset is layout, so they are
1883
1891
  * reduced where every other field is.
1884
1892
  *
1885
- * @param fields - the doctype's top-level fields
1893
+ * A record also carries the rows of each relation its doctype declares in `links`, under the key
1894
+ * the read path writes them to (`link.fieldname ?? key`), and each row is a record of the target
1895
+ * doctype. Given `resolve`, those rows are reduced by the target doctype in turn, so a link picked
1896
+ * inside a row leaves as its id too. A relation rendered as a picker is a link field, reduced above,
1897
+ * never a record to descend into; {@link resolveLinkRenderMode} decides which, as it does for the
1898
+ * read path.
1899
+ *
1900
+ * @param meta - the record's doctype
1886
1901
  * @param record - the record to reduce; not mutated
1902
+ * @param resolve - finds a relation's target doctype by the `target` it declares; without it only
1903
+ * the record's own fields are reduced, and a relation whose target it does not find keeps its rows
1904
+ * as they came
1887
1905
  * @returns a shallow copy with every inline link reduced to its id
1888
1906
  * @public
1889
1907
  */
1890
- export declare function unwrapInlineLinks(fields: readonly DoctypeField[], record: Record<string, any>): Record<string, any>;
1908
+ export declare function unwrapInlineLinks(meta: DoctypeMeta, record: Record<string, any>, resolve?: (target: string) => DoctypeMeta | undefined): Record<string, any>;
1891
1909
 
1892
1910
  /**
1893
1911
  * Validate a doctype definition
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stonecrop/schema",
3
- "version": "0.48.1",
3
+ "version": "0.49.0",
4
4
  "description": "Stonecrop schema definitions and validation tooling",
5
5
  "keywords": [
6
6
  "doctype",