@namroodinc/liquid-editorial 0.1.10 → 0.2.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/AGENTS.md +1 -1
- package/README.md +32 -16
- package/UPGRADING.md +68 -0
- package/dist/chunks/FormEditor-8bz3pOdP.cjs +2 -0
- package/dist/chunks/FormEditor-8bz3pOdP.cjs.map +1 -0
- package/dist/chunks/FormEditor-DuW8x78Y.js +330 -0
- package/dist/chunks/FormEditor-DuW8x78Y.js.map +1 -0
- package/dist/components/AppShell/index.cjs +1 -1
- package/dist/components/AppShell/index.cjs.map +1 -1
- package/dist/components/AppShell/index.d.cts.map +1 -1
- package/dist/components/AppShell/index.d.ts.map +1 -1
- package/dist/components/AppShell/index.js +1 -0
- package/dist/components/AppShell/index.js.map +1 -1
- package/dist/components/Badge/style.css +24 -21
- package/dist/components/Drawer/index.cjs +1 -1
- package/dist/components/Drawer/index.cjs.map +1 -1
- package/dist/components/Drawer/index.d.cts +3 -2
- package/dist/components/Drawer/index.d.cts.map +1 -1
- package/dist/components/Drawer/index.d.ts +3 -2
- package/dist/components/Drawer/index.d.ts.map +1 -1
- package/dist/components/Drawer/index.js +11 -10
- package/dist/components/Drawer/index.js.map +1 -1
- package/dist/components/Drawer/style.css +37 -79
- package/dist/components/EntryPicker/index.cjs +1 -1
- package/dist/components/EntryPicker/index.cjs.map +1 -1
- package/dist/components/EntryPicker/index.d.cts +3 -1
- package/dist/components/EntryPicker/index.d.cts.map +1 -1
- package/dist/components/EntryPicker/index.d.ts +3 -1
- package/dist/components/EntryPicker/index.d.ts.map +1 -1
- package/dist/components/EntryPicker/index.js +45 -43
- package/dist/components/EntryPicker/index.js.map +1 -1
- package/dist/components/FormEditor/control.d.cts +15 -0
- package/dist/components/FormEditor/control.d.cts.map +1 -0
- package/dist/components/FormEditor/control.d.ts +15 -0
- package/dist/components/FormEditor/control.d.ts.map +1 -0
- package/dist/components/FormEditor/index.cjs +1 -0
- package/dist/components/FormEditor/index.d.cts +28 -0
- package/dist/components/FormEditor/index.d.cts.map +1 -0
- package/dist/components/FormEditor/index.d.ts +28 -0
- package/dist/components/FormEditor/index.d.ts.map +1 -0
- package/dist/components/FormEditor/index.js +2 -0
- package/dist/components/FormEditor/model.d.cts +86 -0
- package/dist/components/FormEditor/model.d.cts.map +1 -0
- package/dist/components/FormEditor/model.d.ts +86 -0
- package/dist/components/FormEditor/model.d.ts.map +1 -0
- package/dist/components/FormEditor/style.css +25 -0
- package/dist/components/NumberField/index.cjs +1 -1
- package/dist/components/NumberField/index.cjs.map +1 -1
- package/dist/components/NumberField/index.d.cts +3 -0
- package/dist/components/NumberField/index.d.cts.map +1 -1
- package/dist/components/NumberField/index.d.ts +3 -0
- package/dist/components/NumberField/index.d.ts.map +1 -1
- package/dist/components/NumberField/index.js +20 -20
- package/dist/components/NumberField/index.js.map +1 -1
- package/dist/components/RichTextEditor/index.cjs +1 -1
- package/dist/components/RichTextEditor/index.js +0 -1
- package/dist/components/SelectionCard/index.cjs +1 -1
- package/dist/components/SelectionCard/index.cjs.map +1 -1
- package/dist/components/SelectionCard/index.d.cts +4 -1
- package/dist/components/SelectionCard/index.d.cts.map +1 -1
- package/dist/components/SelectionCard/index.d.ts +4 -1
- package/dist/components/SelectionCard/index.d.ts.map +1 -1
- package/dist/components/SelectionCard/index.js +3 -3
- package/dist/components/SelectionCard/index.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +20 -20
- package/dist/styles.css +1 -1
- package/dist/tokens.css +15 -5
- package/package.json +1 -1
- package/dist/chunks/EntryEditor-CcyYtH74.js +0 -191
- package/dist/chunks/EntryEditor-CcyYtH74.js.map +0 -1
- package/dist/chunks/EntryEditor-DIpc1iPF.cjs +0 -2
- package/dist/chunks/EntryEditor-DIpc1iPF.cjs.map +0 -1
- package/dist/components/EntryEditor/index.cjs +0 -1
- package/dist/components/EntryEditor/index.d.cts +0 -21
- package/dist/components/EntryEditor/index.d.cts.map +0 -1
- package/dist/components/EntryEditor/index.d.ts +0 -21
- package/dist/components/EntryEditor/index.d.ts.map +0 -1
- package/dist/components/EntryEditor/index.js +0 -6
- package/dist/components/EntryEditor/model.d.cts +0 -33
- package/dist/components/EntryEditor/model.d.cts.map +0 -1
- package/dist/components/EntryEditor/model.d.ts +0 -33
- package/dist/components/EntryEditor/model.d.ts.map +0 -1
- package/dist/components/EntryEditor/style.css +0 -8
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"EntryEditor-CcyYtH74.js","names":["documentError","emptyDocument","RichTextEditor","fieldTypes","assertModel","ids","field","model","parseUtcDateTime","value","match","canonical","date","isLink","key","hasRichText","node","requiredError","textError","richTextError","error","linkError","item","validators","validateEntryValues","values","selectedIds","link","id","pickerValue","links","EntryControl","accessibility","Control","TextField","TextArea","isDisabled","stored","onChange","event","NumberField","next","Switch","required","EntryPicker","EntryEditor","rest","internal","setInternal","useState","defaultValue","changed","setChanged","current","validation","commit","previous","onValueChange","className","isPicker","label","errors","showAllErrors","Field","pickerItems"],"sources":["../../src/components/EntryEditor/model.ts","../../src/components/EntryEditor/index.tsx"],"sourcesContent":["import type { JSONContent } from \"@tiptap/react\";\nimport { documentError } from \"../RichTextEditor/document\";\nimport type { RichTextDocument } from \"../RichTextEditor\";\n\ninterface ContentFieldBase {\n id: string;\n label: string;\n hint?: string;\n placeholder?: string;\n required?: boolean;\n}\n\nexport type ContentField = ContentFieldBase & (\n | { type: \"shortText\" | \"longText\" | \"richText\" | \"number\" | \"boolean\" | \"dateTime\"; multiple?: never }\n | { type: \"asset\" | \"reference\"; multiple?: boolean }\n);\n\nexport interface ContentModel {\n fields: readonly ContentField[];\n}\n\nexport interface AssetValue { assetId: string }\nexport interface ReferenceValue { entryId: string }\nexport type EntryFieldValue = string | number | boolean | RichTextDocument | AssetValue | ReferenceValue | AssetValue[] | ReferenceValue[];\nexport type EntryValues = Record<string, EntryFieldValue | undefined>;\nexport type EntryErrors = Partial<Record<string, string>>;\n\nconst fieldTypes = new Set([\"shortText\", \"longText\", \"richText\", \"number\", \"boolean\", \"dateTime\", \"asset\", \"reference\"]);\n\nfunction assertModel(model: ContentModel) {\n const ids = new Set<string>();\n for (const field of model.fields) {\n if (!field.id?.trim() || ids.has(field.id)) throw new Error(\"Content model field IDs must be nonempty and unique.\");\n if (!fieldTypes.has(field.type)) throw new Error(`Unsupported content field type: ${field.type}`);\n ids.add(field.id);\n }\n}\n\n/** Accept UTC ISO strings without rolling invalid dates into the next month. */\nexport function parseUtcDateTime(value: unknown): string | undefined {\n if (typeof value !== \"string\") return;\n const match = /^(\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2})(?::(\\d{2})(?:\\.(\\d{1,3}))?)?(?:Z|\\+00:00)$/.exec(value);\n if (!match) return;\n const canonical = `${match[1]}:${match[2] ?? \"00\"}.${(match[3] ?? \"\").padEnd(3, \"0\")}Z`;\n const date = new Date(canonical);\n if (Number.isFinite(date.getTime()) && date.toISOString() === canonical) return canonical;\n}\n\nfunction isLink(value: unknown, key: \"assetId\" | \"entryId\"): boolean {\n return !!value && typeof value === \"object\" && key in value &&\n typeof (value as Record<string, unknown>)[key] === \"string\" &&\n ((value as Record<string, string>)[key]).trim().length > 0;\n}\n\nfunction hasRichText(node: JSONContent): boolean {\n return !!node.text?.trim() || node.type === \"horizontalRule\" || !!node.content?.some(hasRichText);\n}\n\nfunction requiredError(field: ContentField): string {\n return `${field.label} is required.`;\n}\n\nfunction textError(field: ContentField, value: unknown): string | undefined {\n if (typeof value !== \"string\") return \"Enter text.\";\n if (field.required && !value.trim()) return requiredError(field);\n}\n\nfunction richTextError(field: ContentField, value: unknown): string | undefined {\n const error = documentError(value);\n if (error) return error;\n if (field.required && !hasRichText(value as RichTextDocument)) return requiredError(field);\n}\n\nfunction linkError(field: ContentField, value: unknown): string | undefined {\n const key = field.type === \"asset\" ? \"assetId\" : \"entryId\";\n const valid = field.multiple\n ? Array.isArray(value) && value.every((item) => isLink(item, key))\n : isLink(value, key);\n if (!valid) {\n return field.multiple\n ? `Choose a list of ${field.type === \"asset\" ? \"assets\" : \"entries\"}.`\n : `Choose an ${field.type === \"asset\" ? \"asset\" : \"entry\"}.`;\n }\n if (field.required && Array.isArray(value) && value.length === 0) return requiredError(field);\n}\n\nconst validators: Record<ContentField[\"type\"], (field: ContentField, value: unknown) => string | undefined> = {\n shortText: textError,\n longText: textError,\n richText: richTextError,\n number: (_field, value) => typeof value === \"number\" && Number.isFinite(value) ? undefined : \"Enter a finite number.\",\n boolean: (_field, value) => typeof value === \"boolean\" ? undefined : \"Choose a boolean value.\",\n dateTime: (_field, value) => parseUtcDateTime(value) ? undefined : \"Enter a valid UTC date and time.\",\n asset: linkError,\n reference: linkError,\n};\n\n/** Validate data loaded from JSON as well as values emitted by EntryEditor. */\nexport function validateEntryValues(model: ContentModel, values: Record<string, unknown>): EntryErrors {\n assertModel(model);\n return Object.fromEntries(model.fields.flatMap((field): [string, string][] => {\n const value = Object.hasOwn(values, field.id) ? values[field.id] : undefined;\n const error = value === undefined\n ? field.required ? requiredError(field) : undefined\n : validators[field.type](field, value);\n return error ? [[field.id, error]] : [];\n }));\n}\n","import { useState, type HTMLAttributes } from \"react\";\nimport { EntryPicker, type EntryItem } from \"../EntryPicker\";\nimport { Field, type FieldProps } from \"../Field\";\nimport { NumberField } from \"../NumberField\";\nimport { RichTextEditor, type RichTextDocument } from \"../RichTextEditor\";\nimport { emptyDocument } from \"../RichTextEditor/document\";\nimport { Switch } from \"../Switch\";\nimport { TextArea, TextField } from \"../TextField\";\nimport { parseUtcDateTime, validateEntryValues, type ContentField, type ContentModel, type EntryErrors, type EntryFieldValue, type EntryValues } from \"./model\";\nimport \"./style.css\";\n\nexport { validateEntryValues } from \"./model\";\nexport type { AssetValue, ContentField, ContentModel, EntryErrors, EntryFieldValue, EntryValues, ReferenceValue } from \"./model\";\n\nexport interface EntryEditorProps extends Omit<HTMLAttributes<HTMLDivElement>, \"defaultValue\" | \"onChange\"> {\n model: ContentModel;\n value?: EntryValues;\n defaultValue?: EntryValues;\n onValueChange?: (values: EntryValues) => void;\n /** Available assets or entries, keyed by content field ID. */\n pickerItems?: Record<string, EntryItem[]>;\n /** App-provided messages take precedence over built-in validation. */\n errors?: EntryErrors;\n isDisabled?: boolean;\n /** Reveal validation for untouched fields, for example after a submit attempt. */\n showAllErrors?: boolean;\n}\n\nfunction selectedIds(field: ContentField, value: EntryFieldValue | undefined): string[] {\n const key = field.type === \"asset\" ? \"assetId\" : \"entryId\";\n const links = Array.isArray(value) ? value : value === undefined ? [] : [value];\n return links.flatMap((link) => {\n if (!link || typeof link !== \"object\" || !(key in link)) return [];\n const id = (link as unknown as Record<string, unknown>)[key];\n return typeof id === \"string\" ? [id] : [];\n });\n}\n\nfunction pickerValue(field: ContentField, ids: string[]): EntryFieldValue | undefined {\n if (field.type === \"asset\") {\n const links = ids.map((assetId) => ({ assetId }));\n return field.multiple ? links : links[0];\n }\n const links = ids.map((entryId) => ({ entryId }));\n return field.multiple ? links : links[0];\n}\n\nfunction EntryControl({ field, stored, items, isDisabled, accessibility: { required, ...accessibility }, onChange }: {\n field: ContentField;\n stored: EntryFieldValue | undefined;\n items: EntryItem[];\n isDisabled: boolean;\n accessibility: Parameters<FieldProps[\"children\"]>[0];\n onChange: (value: EntryFieldValue | undefined) => void;\n}) {\n switch (field.type) {\n case \"shortText\":\n case \"longText\": {\n const Control = field.type === \"shortText\" ? TextField : TextArea;\n return <Control {...accessibility} required={required} disabled={isDisabled} placeholder={field.placeholder}\n value={typeof stored === \"string\" ? stored : \"\"} onChange={(event) => onChange(event.target.value)} />;\n }\n case \"number\":\n return <NumberField {...accessibility} required={required} isDisabled={isDisabled} placeholder={field.placeholder} step=\"any\"\n hasSteppers={false} value={typeof stored === \"number\" && Number.isFinite(stored) ? stored : \"\"}\n onValueChange={(next) => { if (next === \"\" || Number.isFinite(next)) onChange(next === \"\" ? undefined : next); }} />;\n case \"boolean\":\n return <Switch {...accessibility} isDisabled={isDisabled} isSelected={stored === true} onSelectedChange={onChange} />;\n case \"dateTime\":\n return <TextField {...accessibility} required={required} disabled={isDisabled} type=\"datetime-local\" step=\"0.001\"\n value={parseUtcDateTime(stored)?.slice(0, -1) ?? \"\"}\n onChange={(event) => onChange(parseUtcDateTime(`${event.target.value}Z`))} />;\n case \"richText\":\n return <RichTextEditor {...accessibility} label={field.label} isRequired={required} isDisabled={isDisabled}\n placeholder={field.placeholder} format=\"json\" value={stored === undefined ? emptyDocument : stored as RichTextDocument}\n onChange={onChange} />;\n case \"asset\":\n case \"reference\":\n return <div {...accessibility} role=\"group\">\n <EntryPicker items={items} value={selectedIds(field, stored)}\n label={field.type === \"asset\" ? \"Assets\" : \"Entries\"} addLabel={`Choose ${field.label}`}\n mode={field.multiple ? \"multiple\" : \"single\"} isDisabled={isDisabled}\n onValueChange={(ids) => onChange(pickerValue(field, ids))} />\n </div>;\n }\n}\n\n/** An ordered set of content inputs; submission and persistence belong to the app. */\nexport function EntryEditor({\n model,\n value,\n defaultValue = {},\n onValueChange,\n pickerItems = {},\n errors = {},\n isDisabled = false,\n showAllErrors = false,\n className,\n ...rest\n}: EntryEditorProps) {\n const [internal, setInternal] = useState<EntryValues>(defaultValue);\n const [changed, setChanged] = useState<Set<string>>(() => new Set());\n const current = value ?? internal;\n const validation = validateEntryValues(model, current);\n\n const commit = (id: string, next: EntryFieldValue | undefined) => {\n if (isDisabled) return;\n const values = { ...current };\n if (next === undefined) delete values[id];\n else values[id] = next;\n if (value === undefined) setInternal(values);\n setChanged((previous) => new Set(previous).add(id));\n onValueChange?.(values);\n };\n\n return (\n <div className={[\"ds-entry-editor\", className].filter(Boolean).join(\" \")} {...rest}>\n {model.fields.map((field) => {\n const stored = Object.hasOwn(current, field.id) ? current[field.id] : undefined;\n const isPicker = field.type === \"asset\" || field.type === \"reference\";\n const label = field.type === \"dateTime\" ? `${field.label} (UTC)` : field.label;\n const error = errors[field.id] ?? (showAllErrors || changed.has(field.id) ? validation[field.id] : undefined);\n return (\n <Field key={field.id} label={label} hint={field.hint} error={error} isRequired={field.required} isGroup={isPicker}>\n {(accessibility) => <EntryControl field={field} stored={stored} items={pickerItems[field.id] ?? []}\n isDisabled={isDisabled} accessibility={accessibility} onChange={(next) => commit(field.id, next)} />}\n </Field>\n );\n })}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;AA2BA,IAAMG,oBAAa,IAAI,IAAI;CAAC;CAAa;CAAY;CAAY;CAAU;CAAW;CAAY;CAAS;AAAW,CAAC;AAEvH,SAASC,EAAY,GAAqB;CACxC,IAAMC,oBAAM,IAAI,IAAY;CAC5B,KAAK,IAAMC,KAASC,EAAM,QAAQ;EAChC,IAAI,CAACD,EAAM,IAAI,KAAK,KAAKD,EAAI,IAAIC,EAAM,EAAE,GAAG,MAAU,MAAM,sDAAsD;EAClH,IAAI,CAACH,EAAW,IAAIG,EAAM,IAAI,GAAG,MAAU,MAAM,mCAAmCA,EAAM,MAAM;EAChG,EAAI,IAAIA,EAAM,EAAE;CAClB;AACF;AAGA,SAAgBE,EAAiB,GAAoC;CACnE,IAAI,OAAOC,KAAU,UAAU;CAC/B,IAAMC,IAAQ,8EAA8E,KAAKD,CAAK;CACtG,IAAI,CAACC,GAAO;CACZ,IAAMC,IAAY,GAAGD,EAAM,GAAG,GAAGA,EAAM,MAAM,KAAK,IAAIA,EAAM,MAAM,GAAA,CAAI,OAAO,GAAG,GAAG,EAAE,IAC/EE,IAAO,IAAI,KAAKD,CAAS;CAC/B,IAAI,OAAO,SAASC,EAAK,QAAQ,CAAC,KAAKA,EAAK,YAAY,MAAMD,GAAW,OAAOA;AAClF;AAEA,SAASE,EAAO,GAAgB,GAAqC;CACnE,OAAO,CAAC,CAACJ,KAAS,OAAOA,KAAU,YAAYK,KAAOL,KACpD,OAAQA,EAAkCK,MAAS,YACjDL,EAAiCK,EAAI,CAAE,KAAK,CA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gD,EAAWhD,EAAM,MAAM,KAAA;GACnG,OACE,kBAACyD,GAAD;IAA6B;IAAO,MAAMzD,EAAM;IAAa;IAAO,YAAYA,EAAM;IAAU,SAASqD;IACrG,WAAA,MAAkB,kBAAC5B,GAAD;KAAqB;KAAe;KAAQ,OAAOiC,EAAY1D,EAAM,OAAO,CAAC;KACnF;KAA2B;KAAe,WAAW,MAASiD,EAAOjD,EAAM,IAAImC,CAAI;IAAI,CAAA;GAChG,GAHKnC,EAAM,EAGX;EAEX,CAAC;CACE,CAAA;AAET"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const e=require("../components/Field/index.cjs"),t=require("../components/TextField/index.cjs"),n=require("./RichTextEditor-BxtlbjXj.cjs"),r=require("../components/EntryPicker/index.cjs"),i=require("../components/NumberField/index.cjs"),a=require("../components/Switch/index.cjs");let o=require("react"),s=require("react/jsx-runtime");var c=new Set([`shortText`,`longText`,`richText`,`number`,`boolean`,`dateTime`,`asset`,`reference`]);function l(e){let t=new Set;for(let n of e.fields){if(!n.id?.trim()||t.has(n.id))throw Error(`Content model field IDs must be nonempty and unique.`);if(!c.has(n.type))throw Error(`Unsupported content field type: ${n.type}`);t.add(n.id)}}function u(e){if(typeof e!=`string`)return;let t=/^(\d{4}-\d{2}-\d{2}T\d{2}:\d{2})(?::(\d{2})(?:\.(\d{1,3}))?)?(?:Z|\+00:00)$/.exec(e);if(!t)return;let n=`${t[1]}:${t[2]??`00`}.${(t[3]??``).padEnd(3,`0`)}Z`,r=new Date(n);if(Number.isFinite(r.getTime())&&r.toISOString()===n)return n}function d(e,t){return!!e&&typeof e==`object`&&t in e&&typeof e[t]==`string`&&e[t].trim().length>0}function f(e){return!!e.text?.trim()||e.type===`horizontalRule`||!!e.content?.some(f)}function p(e){return`${e.label} is required.`}function m(e,t){if(typeof t!=`string`)return`Enter text.`;if(e.required&&!t.trim())return p(e)}function h(e,t){let r=n.n(t);if(r)return r;if(e.required&&!f(t))return p(e)}function g(e,t){let n=e.type===`asset`?`assetId`:`entryId`;if(!(e.multiple?Array.isArray(t)&&t.every(e=>d(e,n)):d(t,n)))return e.multiple?`Choose a list of ${e.type===`asset`?`assets`:`entries`}.`:`Choose an ${e.type===`asset`?`asset`:`entry`}.`;if(e.required&&Array.isArray(t)&&t.length===0)return p(e)}var _={shortText:m,longText:m,richText:h,number:(e,t)=>typeof t==`number`&&Number.isFinite(t)?void 0:`Enter a finite number.`,boolean:(e,t)=>typeof t==`boolean`?void 0:`Choose a boolean value.`,dateTime:(e,t)=>u(t)?void 0:`Enter a valid UTC date and time.`,asset:g,reference:g};function v(e,t){return l(e),Object.fromEntries(e.fields.flatMap(e=>{let n=Object.hasOwn(t,e.id)?t[e.id]:void 0,r=n===void 0?e.required?p(e):void 0:_[e.type](e,n);return r?[[e.id,r]]:[]}))}function y(e,t){let n=e.type===`asset`?`assetId`:`entryId`;return(Array.isArray(t)?t:t===void 0?[]:[t]).flatMap(e=>{if(!e||typeof e!=`object`||!(n in e))return[];let t=e[n];return typeof t==`string`?[t]:[]})}function b(e,t){if(e.type===`asset`){let n=t.map(e=>({assetId:e}));return e.multiple?n:n[0]}let n=t.map(e=>({entryId:e}));return e.multiple?n:n[0]}function x({field:e,stored:o,items:c,isDisabled:l,accessibility:{required:d,...f},onChange:p}){switch(e.type){case`shortText`:case`longText`:{let n=e.type===`shortText`?t.TextField:t.TextArea;return(0,s.jsx)(n,{...f,required:d,disabled:l,placeholder:e.placeholder,value:typeof o==`string`?o:``,onChange:e=>p(e.target.value)})}case`number`:return(0,s.jsx)(i.NumberField,{...f,required:d,isDisabled:l,placeholder:e.placeholder,step:`any`,hasSteppers:!1,value:typeof o==`number`&&Number.isFinite(o)?o:``,onValueChange:e=>{(e===``||Number.isFinite(e))&&p(e===``?void 0:e)}});case`boolean`:return(0,s.jsx)(a.Switch,{...f,isDisabled:l,isSelected:o===!0,onSelectedChange:p});case`dateTime`:return(0,s.jsx)(t.TextField,{...f,required:d,disabled:l,type:`datetime-local`,step:`0.001`,value:u(o)?.slice(0,-1)??``,onChange:e=>p(u(`${e.target.value}Z`))});case`richText`:return(0,s.jsx)(n.t,{...f,label:e.label,isRequired:d,isDisabled:l,placeholder:e.placeholder,format:`json`,value:o===void 0?n.r:o,onChange:p});case`asset`:case`reference`:return(0,s.jsx)(`div`,{...f,role:`group`,children:(0,s.jsx)(r.EntryPicker,{items:c,value:y(e,o),label:e.type===`asset`?`Assets`:`Entries`,addLabel:`Choose ${e.label}`,mode:e.multiple?`multiple`:`single`,isDisabled:l,onValueChange:t=>p(b(e,t))})})}}function S({model:t,value:n,defaultValue:r={},onValueChange:i,pickerItems:a={},errors:c={},isDisabled:l=!1,showAllErrors:u=!1,className:d,...f}){let[p,m]=(0,o.useState)(r),[h,g]=(0,o.useState)(()=>new Set),_=n??p,y=v(t,_),b=(e,t)=>{if(l)return;let r={..._};t===void 0?delete r[e]:r[e]=t,n===void 0&&m(r),g(t=>new Set(t).add(e)),i?.(r)};return(0,s.jsx)(`div`,{className:[`ds-entry-editor`,d].filter(Boolean).join(` `),...f,children:t.fields.map(t=>{let n=Object.hasOwn(_,t.id)?_[t.id]:void 0,r=t.type===`asset`||t.type===`reference`,i=t.type===`dateTime`?`${t.label} (UTC)`:t.label,o=c[t.id]??(u||h.has(t.id)?y[t.id]:void 0);return(0,s.jsx)(e.Field,{label:i,hint:t.hint,error:o,isRequired:t.required,isGroup:r,children:e=>(0,s.jsx)(x,{field:t,stored:n,items:a[t.id]??[],isDisabled:l,accessibility:e,onChange:e=>b(t.id,e)})},t.id)})})}Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return v}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return S}});
|
|
2
|
-
//# sourceMappingURL=EntryEditor-DIpc1iPF.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"EntryEditor-DIpc1iPF.cjs","names":["documentError","TextField","TextArea","NumberField","Switch","RichTextEditor","emptyDocument","EntryPicker","useState","Field","require_components_Field_index","require_components_TextField_index","require_RichTextEditor","require_components_EntryPicker_index","require_components_NumberField_index","require_components_Switch_index","react","react_jsx_runtime","fieldTypes","assertModel","ids","field","model","parseUtcDateTime","value","match","canonical","date","isLink","key","hasRichText","node","requiredError","textError","richTextError","error","linkError","item","validators","validateEntryValues","values","selectedIds","link","id","pickerValue","links","EntryControl","accessibility","Control","isDisabled","stored","onChange","event","next","required","EntryEditor","rest","internal","setInternal","defaultValue","changed","setChanged","current","validation","commit","previous","onValueChange","className","isPicker","label","errors","showAllErrors","pickerItems"],"sources":["../../src/components/EntryEditor/model.ts","../../src/components/EntryEditor/index.tsx"],"sourcesContent":["import type { JSONContent } from \"@tiptap/react\";\nimport { documentError } from \"../RichTextEditor/document\";\nimport type { RichTextDocument } from \"../RichTextEditor\";\n\ninterface ContentFieldBase {\n id: string;\n label: string;\n hint?: string;\n placeholder?: string;\n required?: boolean;\n}\n\nexport type ContentField = ContentFieldBase & (\n | { type: \"shortText\" | \"longText\" | \"richText\" | \"number\" | \"boolean\" | \"dateTime\"; multiple?: never }\n | { type: \"asset\" | \"reference\"; multiple?: boolean }\n);\n\nexport interface ContentModel {\n fields: readonly ContentField[];\n}\n\nexport interface AssetValue { assetId: string }\nexport interface ReferenceValue { entryId: string }\nexport type EntryFieldValue = string | number | boolean | RichTextDocument | AssetValue | ReferenceValue | AssetValue[] | ReferenceValue[];\nexport type EntryValues = Record<string, EntryFieldValue | undefined>;\nexport type EntryErrors = Partial<Record<string, string>>;\n\nconst fieldTypes = new Set([\"shortText\", \"longText\", \"richText\", \"number\", \"boolean\", \"dateTime\", \"asset\", \"reference\"]);\n\nfunction assertModel(model: ContentModel) {\n const ids = new Set<string>();\n for (const field of model.fields) {\n if (!field.id?.trim() || ids.has(field.id)) throw new Error(\"Content model field IDs must be nonempty and unique.\");\n if (!fieldTypes.has(field.type)) throw new Error(`Unsupported content field type: ${field.type}`);\n ids.add(field.id);\n }\n}\n\n/** Accept UTC ISO strings without rolling invalid dates into the next month. */\nexport function parseUtcDateTime(value: unknown): string | undefined {\n if (typeof value !== \"string\") return;\n const match = /^(\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2})(?::(\\d{2})(?:\\.(\\d{1,3}))?)?(?:Z|\\+00:00)$/.exec(value);\n if (!match) return;\n const canonical = `${match[1]}:${match[2] ?? \"00\"}.${(match[3] ?? \"\").padEnd(3, \"0\")}Z`;\n const date = new Date(canonical);\n if (Number.isFinite(date.getTime()) && date.toISOString() === canonical) return canonical;\n}\n\nfunction isLink(value: unknown, key: \"assetId\" | \"entryId\"): boolean {\n return !!value && typeof value === \"object\" && key in value &&\n typeof (value as Record<string, unknown>)[key] === \"string\" &&\n ((value as Record<string, string>)[key]).trim().length > 0;\n}\n\nfunction hasRichText(node: JSONContent): boolean {\n return !!node.text?.trim() || node.type === \"horizontalRule\" || !!node.content?.some(hasRichText);\n}\n\nfunction requiredError(field: ContentField): string {\n return `${field.label} is required.`;\n}\n\nfunction textError(field: ContentField, value: unknown): string | undefined {\n if (typeof value !== \"string\") return \"Enter text.\";\n if (field.required && !value.trim()) return requiredError(field);\n}\n\nfunction richTextError(field: ContentField, value: unknown): string | undefined {\n const error = documentError(value);\n if (error) return error;\n if (field.required && !hasRichText(value as RichTextDocument)) return requiredError(field);\n}\n\nfunction linkError(field: ContentField, value: unknown): string | undefined {\n const key = field.type === \"asset\" ? \"assetId\" : \"entryId\";\n const valid = field.multiple\n ? Array.isArray(value) && value.every((item) => isLink(item, key))\n : isLink(value, key);\n if (!valid) {\n return field.multiple\n ? `Choose a list of ${field.type === \"asset\" ? \"assets\" : \"entries\"}.`\n : `Choose an ${field.type === \"asset\" ? \"asset\" : \"entry\"}.`;\n }\n if (field.required && Array.isArray(value) && value.length === 0) return requiredError(field);\n}\n\nconst validators: Record<ContentField[\"type\"], (field: ContentField, value: unknown) => string | undefined> = {\n shortText: textError,\n longText: textError,\n richText: richTextError,\n number: (_field, value) => typeof value === \"number\" && Number.isFinite(value) ? undefined : \"Enter a finite number.\",\n boolean: (_field, value) => typeof value === \"boolean\" ? undefined : \"Choose a boolean value.\",\n dateTime: (_field, value) => parseUtcDateTime(value) ? undefined : \"Enter a valid UTC date and time.\",\n asset: linkError,\n reference: linkError,\n};\n\n/** Validate data loaded from JSON as well as values emitted by EntryEditor. */\nexport function validateEntryValues(model: ContentModel, values: Record<string, unknown>): EntryErrors {\n assertModel(model);\n return Object.fromEntries(model.fields.flatMap((field): [string, string][] => {\n const value = Object.hasOwn(values, field.id) ? values[field.id] : undefined;\n const error = value === undefined\n ? field.required ? requiredError(field) : undefined\n : validators[field.type](field, value);\n return error ? [[field.id, error]] : [];\n }));\n}\n","import { useState, type HTMLAttributes } from \"react\";\nimport { EntryPicker, type EntryItem } from \"../EntryPicker\";\nimport { Field, type FieldProps } from \"../Field\";\nimport { NumberField } from \"../NumberField\";\nimport { RichTextEditor, type RichTextDocument } from \"../RichTextEditor\";\nimport { emptyDocument } from \"../RichTextEditor/document\";\nimport { Switch } from \"../Switch\";\nimport { TextArea, TextField } from \"../TextField\";\nimport { parseUtcDateTime, validateEntryValues, type ContentField, type ContentModel, type EntryErrors, type EntryFieldValue, type EntryValues } from \"./model\";\nimport \"./style.css\";\n\nexport { validateEntryValues } from \"./model\";\nexport type { AssetValue, ContentField, ContentModel, EntryErrors, EntryFieldValue, EntryValues, ReferenceValue } from \"./model\";\n\nexport interface EntryEditorProps extends Omit<HTMLAttributes<HTMLDivElement>, \"defaultValue\" | \"onChange\"> {\n model: ContentModel;\n value?: EntryValues;\n defaultValue?: EntryValues;\n onValueChange?: (values: EntryValues) => void;\n /** Available assets or entries, keyed by content field ID. */\n pickerItems?: Record<string, EntryItem[]>;\n /** App-provided messages take precedence over built-in validation. */\n errors?: EntryErrors;\n isDisabled?: boolean;\n /** Reveal validation for untouched fields, for example after a submit attempt. */\n showAllErrors?: boolean;\n}\n\nfunction selectedIds(field: ContentField, value: EntryFieldValue | undefined): string[] {\n const key = field.type === \"asset\" ? \"assetId\" : \"entryId\";\n const links = Array.isArray(value) ? value : value === undefined ? [] : [value];\n return links.flatMap((link) => {\n if (!link || typeof link !== \"object\" || !(key in link)) return [];\n const id = (link as unknown as Record<string, unknown>)[key];\n return typeof id === \"string\" ? [id] : [];\n });\n}\n\nfunction pickerValue(field: ContentField, ids: string[]): EntryFieldValue | undefined {\n if (field.type === \"asset\") {\n const links = ids.map((assetId) => ({ assetId }));\n return field.multiple ? links : links[0];\n }\n const links = ids.map((entryId) => ({ entryId }));\n return field.multiple ? links : links[0];\n}\n\nfunction EntryControl({ field, stored, items, isDisabled, accessibility: { required, ...accessibility }, onChange }: {\n field: ContentField;\n stored: EntryFieldValue | undefined;\n items: EntryItem[];\n isDisabled: boolean;\n accessibility: Parameters<FieldProps[\"children\"]>[0];\n onChange: (value: EntryFieldValue | undefined) => void;\n}) {\n switch (field.type) {\n case \"shortText\":\n case \"longText\": {\n const Control = field.type === \"shortText\" ? TextField : TextArea;\n return <Control {...accessibility} required={required} disabled={isDisabled} placeholder={field.placeholder}\n value={typeof stored === \"string\" ? stored : \"\"} onChange={(event) => onChange(event.target.value)} />;\n }\n case \"number\":\n return <NumberField {...accessibility} required={required} isDisabled={isDisabled} placeholder={field.placeholder} step=\"any\"\n hasSteppers={false} value={typeof stored === \"number\" && Number.isFinite(stored) ? stored : \"\"}\n onValueChange={(next) => { if (next === \"\" || Number.isFinite(next)) onChange(next === \"\" ? undefined : next); }} />;\n case \"boolean\":\n return <Switch {...accessibility} isDisabled={isDisabled} isSelected={stored === true} onSelectedChange={onChange} />;\n case \"dateTime\":\n return <TextField {...accessibility} required={required} disabled={isDisabled} type=\"datetime-local\" step=\"0.001\"\n value={parseUtcDateTime(stored)?.slice(0, -1) ?? \"\"}\n onChange={(event) => onChange(parseUtcDateTime(`${event.target.value}Z`))} />;\n case \"richText\":\n return <RichTextEditor {...accessibility} label={field.label} isRequired={required} isDisabled={isDisabled}\n placeholder={field.placeholder} format=\"json\" value={stored === undefined ? emptyDocument : stored as RichTextDocument}\n onChange={onChange} />;\n case \"asset\":\n case \"reference\":\n return <div {...accessibility} role=\"group\">\n <EntryPicker items={items} value={selectedIds(field, stored)}\n label={field.type === \"asset\" ? \"Assets\" : \"Entries\"} addLabel={`Choose ${field.label}`}\n mode={field.multiple ? \"multiple\" : \"single\"} isDisabled={isDisabled}\n onValueChange={(ids) => onChange(pickerValue(field, ids))} />\n </div>;\n }\n}\n\n/** An ordered set of content inputs; submission and persistence belong to the app. */\nexport function EntryEditor({\n model,\n value,\n defaultValue = {},\n onValueChange,\n pickerItems = {},\n errors = {},\n isDisabled = false,\n showAllErrors = false,\n className,\n ...rest\n}: EntryEditorProps) {\n const [internal, setInternal] = useState<EntryValues>(defaultValue);\n const [changed, setChanged] = useState<Set<string>>(() => new Set());\n const current = value ?? internal;\n const validation = validateEntryValues(model, current);\n\n const commit = (id: string, next: EntryFieldValue | undefined) => {\n if (isDisabled) return;\n const values = { ...current };\n if (next === undefined) delete values[id];\n else values[id] = next;\n if (value === undefined) setInternal(values);\n setChanged((previous) => new Set(previous).add(id));\n onValueChange?.(values);\n };\n\n return (\n <div className={[\"ds-entry-editor\", className].filter(Boolean).join(\" \")} {...rest}>\n {model.fields.map((field) => {\n const stored = Object.hasOwn(current, field.id) ? current[field.id] : undefined;\n const isPicker = field.type === \"asset\" || field.type === \"reference\";\n const label = field.type === \"dateTime\" ? `${field.label} (UTC)` : field.label;\n const error = errors[field.id] ?? (showAllErrors || changed.has(field.id) ? validation[field.id] : undefined);\n return (\n <Field key={field.id} label={label} hint={field.hint} error={error} isRequired={field.required} isGroup={isPicker}>\n {(accessibility) => <EntryControl field={field} stored={stored} items={pickerItems[field.id] ?? []}\n isDisabled={isDisabled} accessibility={accessibility} onChange={(next) => commit(field.id, next)} />}\n </Field>\n );\n })}\n </div>\n );\n}\n"],"mappings":"A,+UA2BA,IAAMkB,EAAa,IAAI,IAAI,CAAC,YAAa,WAAY,WAAY,SAAU,UAAW,WAAY,QAAS,WAAW,CAAC,EAEvH,SAASC,EAAY,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EAAA,IAAA,CAAC6B,EAAD,CAAqB,QAAe,SAAQ,MAAO0B,EAAYnD,EAAM,KAAO,CAAC,EACnF,aAA2B,gBAAe,SAAW,GAAS2C,EAAO3C,EAAM,GAAIgC,CAAI,CAAI,CAAA,CAChG,EAHKhC,EAAM,EAGX,CAEX,CAAC,CACE,CAAA,CAET,C"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require("../Field/index.cjs"),require("../TextField/index.cjs"),require("../EntryPicker/index.cjs"),require("../NumberField/index.cjs"),require("../Switch/index.cjs");const e=require("../../chunks/EntryEditor-DIpc1iPF.cjs");exports.EntryEditor=e.t,exports.validateEntryValues=e.n;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { type HTMLAttributes } from "react";
|
|
2
|
-
import { type EntryItem } from "../EntryPicker/index.cjs";
|
|
3
|
-
import { type ContentModel, type EntryErrors, type EntryValues } from "./model.cjs";
|
|
4
|
-
export { validateEntryValues } from "./model.cjs";
|
|
5
|
-
export type { AssetValue, ContentField, ContentModel, EntryErrors, EntryFieldValue, EntryValues, ReferenceValue } from "./model.cjs";
|
|
6
|
-
export interface EntryEditorProps extends Omit<HTMLAttributes<HTMLDivElement>, "defaultValue" | "onChange"> {
|
|
7
|
-
model: ContentModel;
|
|
8
|
-
value?: EntryValues;
|
|
9
|
-
defaultValue?: EntryValues;
|
|
10
|
-
onValueChange?: (values: EntryValues) => void;
|
|
11
|
-
/** Available assets or entries, keyed by content field ID. */
|
|
12
|
-
pickerItems?: Record<string, EntryItem[]>;
|
|
13
|
-
/** App-provided messages take precedence over built-in validation. */
|
|
14
|
-
errors?: EntryErrors;
|
|
15
|
-
isDisabled?: boolean;
|
|
16
|
-
/** Reveal validation for untouched fields, for example after a submit attempt. */
|
|
17
|
-
showAllErrors?: boolean;
|
|
18
|
-
}
|
|
19
|
-
/** An ordered set of content inputs; submission and persistence belong to the app. */
|
|
20
|
-
export declare function EntryEditor({ model, value, defaultValue, onValueChange, pickerItems, errors, isDisabled, showAllErrors, className, ...rest }: EntryEditorProps): import("react").JSX.Element;
|
|
21
|
-
//# sourceMappingURL=index.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../../src/components/EntryEditor/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,OAAO,CAAC;AACtD,OAAO,EAAe,KAAK,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAO7D,OAAO,EAA4D,KAAK,YAAY,EAAE,KAAK,WAAW,EAAwB,KAAK,WAAW,EAAE,MAAM,SAAS,CAAC;AAChK,OAAO,aAAa,CAAC;AAErB,OAAO,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAC9C,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,eAAe,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAEjI,MAAM,WAAW,gBAAiB,SAAQ,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC;IACzG,KAAK,EAAE,YAAY,CAAC;IACpB,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,YAAY,CAAC,EAAE,WAAW,CAAC;IAC3B,aAAa,CAAC,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,IAAI,CAAC;IAC9C,8DAA8D;IAC9D,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC;IAC1C,sEAAsE;IACtE,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,kFAAkF;IAClF,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AA6DD,sFAAsF;AACtF,wBAAgB,WAAW,CAAC,EAC1B,KAAK,EACL,KAAK,EACL,YAAiB,EACjB,aAAa,EACb,WAAgB,EAChB,MAAW,EACX,UAAkB,EAClB,aAAqB,EACrB,SAAS,EACT,GAAG,IAAI,EACR,EAAE,gBAAgB,+BAgClB"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { type HTMLAttributes } from "react";
|
|
2
|
-
import { type EntryItem } from "../EntryPicker/index.js";
|
|
3
|
-
import { type ContentModel, type EntryErrors, type EntryValues } from "./model.js";
|
|
4
|
-
export { validateEntryValues } from "./model.js";
|
|
5
|
-
export type { AssetValue, ContentField, ContentModel, EntryErrors, EntryFieldValue, EntryValues, ReferenceValue } from "./model.js";
|
|
6
|
-
export interface EntryEditorProps extends Omit<HTMLAttributes<HTMLDivElement>, "defaultValue" | "onChange"> {
|
|
7
|
-
model: ContentModel;
|
|
8
|
-
value?: EntryValues;
|
|
9
|
-
defaultValue?: EntryValues;
|
|
10
|
-
onValueChange?: (values: EntryValues) => void;
|
|
11
|
-
/** Available assets or entries, keyed by content field ID. */
|
|
12
|
-
pickerItems?: Record<string, EntryItem[]>;
|
|
13
|
-
/** App-provided messages take precedence over built-in validation. */
|
|
14
|
-
errors?: EntryErrors;
|
|
15
|
-
isDisabled?: boolean;
|
|
16
|
-
/** Reveal validation for untouched fields, for example after a submit attempt. */
|
|
17
|
-
showAllErrors?: boolean;
|
|
18
|
-
}
|
|
19
|
-
/** An ordered set of content inputs; submission and persistence belong to the app. */
|
|
20
|
-
export declare function EntryEditor({ model, value, defaultValue, onValueChange, pickerItems, errors, isDisabled, showAllErrors, className, ...rest }: EntryEditorProps): import("react").JSX.Element;
|
|
21
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/EntryEditor/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,OAAO,CAAC;AACtD,OAAO,EAAe,KAAK,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAO7D,OAAO,EAA4D,KAAK,YAAY,EAAE,KAAK,WAAW,EAAwB,KAAK,WAAW,EAAE,MAAM,SAAS,CAAC;AAChK,OAAO,aAAa,CAAC;AAErB,OAAO,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAC9C,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,eAAe,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAEjI,MAAM,WAAW,gBAAiB,SAAQ,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC;IACzG,KAAK,EAAE,YAAY,CAAC;IACpB,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,YAAY,CAAC,EAAE,WAAW,CAAC;IAC3B,aAAa,CAAC,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,IAAI,CAAC;IAC9C,8DAA8D;IAC9D,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC;IAC1C,sEAAsE;IACtE,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,kFAAkF;IAClF,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AA6DD,sFAAsF;AACtF,wBAAgB,WAAW,CAAC,EAC1B,KAAK,EACL,KAAK,EACL,YAAiB,EACjB,aAAa,EACb,WAAgB,EAChB,MAAW,EACX,UAAkB,EAClB,aAAqB,EACrB,SAAS,EACT,GAAG,IAAI,EACR,EAAE,gBAAgB,+BAgClB"}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import type { RichTextDocument } from "../RichTextEditor/index.cjs";
|
|
2
|
-
interface ContentFieldBase {
|
|
3
|
-
id: string;
|
|
4
|
-
label: string;
|
|
5
|
-
hint?: string;
|
|
6
|
-
placeholder?: string;
|
|
7
|
-
required?: boolean;
|
|
8
|
-
}
|
|
9
|
-
export type ContentField = ContentFieldBase & ({
|
|
10
|
-
type: "shortText" | "longText" | "richText" | "number" | "boolean" | "dateTime";
|
|
11
|
-
multiple?: never;
|
|
12
|
-
} | {
|
|
13
|
-
type: "asset" | "reference";
|
|
14
|
-
multiple?: boolean;
|
|
15
|
-
});
|
|
16
|
-
export interface ContentModel {
|
|
17
|
-
fields: readonly ContentField[];
|
|
18
|
-
}
|
|
19
|
-
export interface AssetValue {
|
|
20
|
-
assetId: string;
|
|
21
|
-
}
|
|
22
|
-
export interface ReferenceValue {
|
|
23
|
-
entryId: string;
|
|
24
|
-
}
|
|
25
|
-
export type EntryFieldValue = string | number | boolean | RichTextDocument | AssetValue | ReferenceValue | AssetValue[] | ReferenceValue[];
|
|
26
|
-
export type EntryValues = Record<string, EntryFieldValue | undefined>;
|
|
27
|
-
export type EntryErrors = Partial<Record<string, string>>;
|
|
28
|
-
/** Accept UTC ISO strings without rolling invalid dates into the next month. */
|
|
29
|
-
export declare function parseUtcDateTime(value: unknown): string | undefined;
|
|
30
|
-
/** Validate data loaded from JSON as well as values emitted by EntryEditor. */
|
|
31
|
-
export declare function validateEntryValues(model: ContentModel, values: Record<string, unknown>): EntryErrors;
|
|
32
|
-
export {};
|
|
33
|
-
//# sourceMappingURL=model.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"model.d.cts","sourceRoot":"","sources":["../../../src/components/EntryEditor/model.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAE1D,UAAU,gBAAgB;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,MAAM,YAAY,GAAG,gBAAgB,GAAG,CAC1C;IAAE,IAAI,EAAE,WAAW,GAAG,UAAU,GAAG,UAAU,GAAG,QAAQ,GAAG,SAAS,GAAG,UAAU,CAAC;IAAC,QAAQ,CAAC,EAAE,KAAK,CAAA;CAAE,GACrG;IAAE,IAAI,EAAE,OAAO,GAAG,WAAW,CAAC;IAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE,CACtD,CAAC;AAEF,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,SAAS,YAAY,EAAE,CAAC;CACjC;AAED,MAAM,WAAW,UAAU;IAAG,OAAO,EAAE,MAAM,CAAA;CAAE;AAC/C,MAAM,WAAW,cAAc;IAAG,OAAO,EAAE,MAAM,CAAA;CAAE;AACnD,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,gBAAgB,GAAG,UAAU,GAAG,cAAc,GAAG,UAAU,EAAE,GAAG,cAAc,EAAE,CAAC;AAC3I,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,eAAe,GAAG,SAAS,CAAC,CAAC;AACtE,MAAM,MAAM,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;AAa1D,gFAAgF;AAChF,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAOnE;AAmDD,+EAA+E;AAC/E,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,WAAW,CASrG"}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import type { RichTextDocument } from "../RichTextEditor/index.js";
|
|
2
|
-
interface ContentFieldBase {
|
|
3
|
-
id: string;
|
|
4
|
-
label: string;
|
|
5
|
-
hint?: string;
|
|
6
|
-
placeholder?: string;
|
|
7
|
-
required?: boolean;
|
|
8
|
-
}
|
|
9
|
-
export type ContentField = ContentFieldBase & ({
|
|
10
|
-
type: "shortText" | "longText" | "richText" | "number" | "boolean" | "dateTime";
|
|
11
|
-
multiple?: never;
|
|
12
|
-
} | {
|
|
13
|
-
type: "asset" | "reference";
|
|
14
|
-
multiple?: boolean;
|
|
15
|
-
});
|
|
16
|
-
export interface ContentModel {
|
|
17
|
-
fields: readonly ContentField[];
|
|
18
|
-
}
|
|
19
|
-
export interface AssetValue {
|
|
20
|
-
assetId: string;
|
|
21
|
-
}
|
|
22
|
-
export interface ReferenceValue {
|
|
23
|
-
entryId: string;
|
|
24
|
-
}
|
|
25
|
-
export type EntryFieldValue = string | number | boolean | RichTextDocument | AssetValue | ReferenceValue | AssetValue[] | ReferenceValue[];
|
|
26
|
-
export type EntryValues = Record<string, EntryFieldValue | undefined>;
|
|
27
|
-
export type EntryErrors = Partial<Record<string, string>>;
|
|
28
|
-
/** Accept UTC ISO strings without rolling invalid dates into the next month. */
|
|
29
|
-
export declare function parseUtcDateTime(value: unknown): string | undefined;
|
|
30
|
-
/** Validate data loaded from JSON as well as values emitted by EntryEditor. */
|
|
31
|
-
export declare function validateEntryValues(model: ContentModel, values: Record<string, unknown>): EntryErrors;
|
|
32
|
-
export {};
|
|
33
|
-
//# sourceMappingURL=model.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../../src/components/EntryEditor/model.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAE1D,UAAU,gBAAgB;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,MAAM,YAAY,GAAG,gBAAgB,GAAG,CAC1C;IAAE,IAAI,EAAE,WAAW,GAAG,UAAU,GAAG,UAAU,GAAG,QAAQ,GAAG,SAAS,GAAG,UAAU,CAAC;IAAC,QAAQ,CAAC,EAAE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