@namroodinc/liquid-editorial 0.1.1 → 0.1.4

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 (55) hide show
  1. package/AGENTS.md +11 -0
  2. package/README.md +8 -0
  3. package/UPGRADING.md +56 -0
  4. package/dist/chunks/{EntryEditor-cjDk4vdH.cjs → EntryEditor-C32lKKnV.cjs} +2 -2
  5. package/dist/chunks/{EntryEditor-cjDk4vdH.cjs.map → EntryEditor-C32lKKnV.cjs.map} +1 -1
  6. package/dist/chunks/EntryEditor-xVuiqtFo.js +181 -0
  7. package/dist/chunks/{EntryEditor-BF808OZR.js.map → EntryEditor-xVuiqtFo.js.map} +1 -1
  8. package/dist/chunks/RichTextEditor-CSpjsL1z.js +357 -0
  9. package/dist/chunks/RichTextEditor-CSpjsL1z.js.map +1 -0
  10. package/dist/chunks/RichTextEditor-DC_0oN1s.cjs +2 -0
  11. package/dist/chunks/RichTextEditor-DC_0oN1s.cjs.map +1 -0
  12. package/dist/components/AssetGrid/index.js.map +1 -1
  13. package/dist/components/EntryEditor/index.cjs +1 -1
  14. package/dist/components/EntryEditor/index.js +3 -3
  15. package/dist/components/EntryPicker/index.cjs +1 -1
  16. package/dist/components/EntryPicker/index.cjs.map +1 -1
  17. package/dist/components/EntryPicker/index.js +4 -4
  18. package/dist/components/EntryPicker/index.js.map +1 -1
  19. package/dist/components/Field/index.js.map +1 -1
  20. package/dist/components/ImageCropper/index.js.map +1 -1
  21. package/dist/components/Modal/index.cjs +1 -1
  22. package/dist/components/Modal/index.cjs.map +1 -1
  23. package/dist/components/Modal/index.js +2 -2
  24. package/dist/components/Modal/index.js.map +1 -1
  25. package/dist/components/Modal/style.css +1 -0
  26. package/dist/components/RichTextEditor/index.cjs +1 -1
  27. package/dist/components/RichTextEditor/index.d.cts.map +1 -1
  28. package/dist/components/RichTextEditor/index.d.ts.map +1 -1
  29. package/dist/components/RichTextEditor/index.js +3 -1
  30. package/dist/components/SortableList/index.cjs +1 -1
  31. package/dist/components/SortableList/index.cjs.map +1 -1
  32. package/dist/components/SortableList/index.d.cts +4 -3
  33. package/dist/components/SortableList/index.d.cts.map +1 -1
  34. package/dist/components/SortableList/index.d.ts +4 -3
  35. package/dist/components/SortableList/index.d.ts.map +1 -1
  36. package/dist/components/SortableList/index.js +55 -48
  37. package/dist/components/SortableList/index.js.map +1 -1
  38. package/dist/components/Table/index.cjs +1 -1
  39. package/dist/components/Table/index.cjs.map +1 -1
  40. package/dist/components/Table/index.d.cts +5 -1
  41. package/dist/components/Table/index.d.cts.map +1 -1
  42. package/dist/components/Table/index.d.ts +5 -1
  43. package/dist/components/Table/index.d.ts.map +1 -1
  44. package/dist/components/Table/index.js +74 -55
  45. package/dist/components/Table/index.js.map +1 -1
  46. package/dist/components/Table/style.css +4 -0
  47. package/dist/components/Time/index.js.map +1 -1
  48. package/dist/index.cjs +1 -1
  49. package/dist/index.js +13 -13
  50. package/package.json +3 -1
  51. package/dist/chunks/EntryEditor-BF808OZR.js +0 -181
  52. package/dist/chunks/RichTextEditor-DRt-kibg.js +0 -248
  53. package/dist/chunks/RichTextEditor-DRt-kibg.js.map +0 -1
  54. package/dist/chunks/RichTextEditor-tFkISOvq.cjs +0 -2
  55. package/dist/chunks/RichTextEditor-tFkISOvq.cjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["_Fragment","cx","parts","MONTHS","MINUTE","HOUR","DAY","WEEK","pad","value","formatAbsoluteDate","options","stem","date","hasYear","formatAbsoluteTime","stamp","hasTimeZone","zone","part","formatRelativeTime","delta","now","days","Time","forwardRef","describedBy","rest","anchorRef","useRef","isOpen","setIsOpen","useState","tooltipId","useId","setTick","useEffect","format","id","t","refreshInterval","label","isTipped","hasTooltip","Fragment","node","ref","className","tabIndex","title","onMouseEnter","event","onMouseLeave","onFocus","onBlur","onKeyDown","Popover"],"sources":["../../../src/components/Time/index.tsx"],"sourcesContent":["import {\n forwardRef,\n useEffect,\n useId,\n useRef,\n useState,\n type HTMLAttributes,\n} from \"react\";\nimport { Popover } from \"../Popover\";\nimport \"./style.css\";\n\nfunction cx(...parts: (string | undefined | false)[]) {\n return parts.filter(Boolean).join(\" \");\n}\n\nconst MONTHS = [\n \"Jan\",\n \"Feb\",\n \"Mar\",\n \"Apr\",\n \"May\",\n \"Jun\",\n \"Jul\",\n \"Aug\",\n \"Sep\",\n \"Oct\",\n \"Nov\",\n \"Dec\",\n];\n\nconst MINUTE = 60_000;\nconst HOUR = 60 * MINUTE;\nconst DAY = 24 * HOUR;\nconst WEEK = 7 * DAY;\n\nfunction pad(value: number) {\n return String(value).padStart(2, \"0\");\n}\n\n/** Day before month, one order everywhere: `12 Jun 2026`. */\nexport function formatAbsoluteDate(date: Date, options: { hasYear?: boolean } = {}) {\n const { hasYear = true } = options;\n const stem = `${date.getDate()} ${MONTHS[date.getMonth()]}`;\n return hasYear ? `${stem} ${date.getFullYear()}` : stem;\n}\n\n/** The tooltip form: `6 Aug 2026, 11:05`, with the reader's zone appended. */\nexport function formatAbsoluteTime(date: Date, options: { hasTimeZone?: boolean } = {}) {\n const { hasTimeZone = true } = options;\n const stamp = `${formatAbsoluteDate(date)}, ${pad(date.getHours())}:${pad(date.getMinutes())}`;\n if (!hasTimeZone) return stamp;\n const zone = new Intl.DateTimeFormat(undefined, { timeZoneName: \"short\" })\n .formatToParts(date)\n .find((part) => part.type === \"timeZoneName\")?.value;\n return zone ? `${stamp} ${zone}` : stamp;\n}\n\n/**\n * Relative up to a week, absolute after. Future dates are always absolute — a\n * scheduled publish reads `12 Jun`, never `in 3 days`.\n */\nexport function formatRelativeTime(date: Date, now: Date = new Date()) {\n const delta = now.getTime() - date.getTime();\n if (delta < 0) {\n return formatAbsoluteDate(date, { hasYear: date.getFullYear() !== now.getFullYear() });\n }\n if (delta < MINUTE) return \"Just now\";\n if (delta < HOUR) return `${Math.floor(delta / MINUTE)}m ago`;\n if (delta < DAY) return `${Math.floor(delta / HOUR)}h ago`;\n if (delta < WEEK) {\n const days = Math.floor(delta / DAY);\n return `${days} ${days === 1 ? \"day\" : \"days\"} ago`;\n }\n return formatAbsoluteDate(date, { hasYear: date.getFullYear() !== now.getFullYear() });\n}\n\nexport type TimeFormat = \"auto\" | \"relative\" | \"absolute\";\n\nexport interface TimeProps extends Omit<HTMLAttributes<HTMLElement>, \"children\"> {\n /** The instant to print — Date, epoch ms, or an ISO string. */\n value: Date | string | number;\n /** `auto` ages the value; `absolute` always prints the date. */\n format?: TimeFormat;\n /** Show the absolute stamp on hover and focus. */\n hasTooltip?: boolean;\n /** Append the reader's time zone to the tooltip. */\n hasTimeZone?: boolean;\n /** Pin \"now\" — useful for tests and stories. */\n now?: Date;\n /** Re-render interval in ms while the value is still relative. */\n refreshInterval?: number;\n}\n\n/**\n * A machine-readable `<time>` that ages itself. One form per cell: relative or\n * absolute, never both side by side.\n */\nexport const Time = forwardRef<HTMLTimeElement, TimeProps>(function Time(\n {\n value,\n format = \"auto\",\n hasTooltip = true,\n hasTimeZone = true,\n now,\n refreshInterval = 30_000,\n className,\n tabIndex,\n title,\n onMouseEnter,\n onMouseLeave,\n onFocus,\n onBlur,\n onKeyDown,\n \"aria-describedby\": describedBy,\n ...rest\n },\n ref,\n) {\n const date = value instanceof Date ? value : new Date(value);\n const anchorRef = useRef<HTMLTimeElement | null>(null);\n const [isOpen, setIsOpen] = useState(false);\n const tooltipId = useId();\n const [, setTick] = useState(0);\n\n useEffect(() => {\n if (format === \"absolute\" || now) return;\n const id = window.setInterval(() => setTick((t) => t + 1), refreshInterval);\n return () => window.clearInterval(id);\n }, [format, now, refreshInterval]);\n\n if (Number.isNaN(date.getTime())) return null;\n\n const reference = now ?? new Date();\n const label =\n format === \"absolute\"\n ? formatAbsoluteDate(date)\n : formatRelativeTime(date, reference);\n const stamp = formatAbsoluteTime(date, { hasTimeZone });\n const isTipped = hasTooltip && label !== stamp;\n\n return (\n <>\n <time\n ref={(node) => {\n anchorRef.current = node;\n if (typeof ref === \"function\") ref(node);\n else if (ref) ref.current = node;\n }}\n dateTime={date.toISOString()}\n suppressHydrationWarning\n className={cx(\"ds-time\", !isTipped && \"ds-time--plain\", className)}\n tabIndex={tabIndex ?? (isTipped ? 0 : undefined)}\n aria-describedby={[describedBy, isTipped && isOpen && tooltipId].filter(Boolean).join(\" \") || undefined}\n title={title ?? (isTipped ? undefined : stamp)}\n onMouseEnter={(event) => {\n onMouseEnter?.(event);\n if (isTipped && !event.defaultPrevented) setIsOpen(true);\n }}\n onMouseLeave={(event) => {\n onMouseLeave?.(event);\n if (isTipped && !event.defaultPrevented) setIsOpen(false);\n }}\n onFocus={(event) => {\n onFocus?.(event);\n if (isTipped && !event.defaultPrevented) setIsOpen(true);\n }}\n onBlur={(event) => {\n onBlur?.(event);\n if (isTipped && !event.defaultPrevented) setIsOpen(false);\n }}\n onKeyDown={(event) => {\n onKeyDown?.(event);\n if (isTipped && !event.defaultPrevented && event.key === \"Escape\") setIsOpen(false);\n }}\n {...rest}\n >\n {label}\n </time>\n {isTipped && (\n <Popover\n anchorRef={anchorRef}\n isOpen={isOpen}\n id={tooltipId}\n role=\"tooltip\"\n className=\"ds-surface-raised ds-time-tooltip\"\n >\n {stamp}\n </Popover>\n )}\n </>\n );\n});\n"],"mappings":";;;;AAWA,SAASC,EAAG,GAAGC,GAAuC;CACpD,OAAOA,EAAM,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG;AACvC;AAEA,IAAMC,IAAS;CACb;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,GAEMC,IAAS,KACTC,IAAO,KAAKD,GACZE,IAAM,KAAKD,GACXE,IAAO,IAAID;AAEjB,SAASE,EAAI,GAAe;CAC1B,OAAO,OAAOC,CAAK,CAAC,CAAC,SAAS,GAAG,GAAG;AACtC;AAGA,SAAgBC,EAAmB,GAAY,IAAiC,CAAC,GAAG;CAClF,IAAM,EAAE,aAAU,OAASC,GACrBC,IAAO,GAAGC,EAAK,QAAQ,EAAE,G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AM,oBAAkBpB,EAAU,EAAI;EACzD;EACA,eAAe,MAAU;GAEvB,AADAqB,IAAeD,CAAK,GAChBT,KAAY,CAACS,EAAM,oBAAkBpB,EAAU,EAAK;EAC1D;EACA,UAAU,MAAU;GAElB,AADAsB,IAAUF,CAAK,GACXT,KAAY,CAACS,EAAM,oBAAkBpB,EAAU,EAAI;EACzD;EACA,SAAS,MAAU;GAEjB,AADAuB,IAASH,CAAK,GACVT,KAAY,CAACS,EAAM,oBAAkBpB,EAAU,EAAK;EAC1D;EACA,YAAY,MAAU;GAEpB,AADAwB,IAAYJ,CAAK,GACbT,KAAY,CAACS,EAAM,oBAAoBA,EAAM,QAAQ,YAAUpB,EAAU,EAAK;EACpF;EACA,GAAIJ;EAEH,UAAAc;CACG,CAAA,GACLC,KACC,kBAACc,GAAD;EACa;EACH;EACR,IAAIvB;EACJ,MAAK;EACL,WAAU;EAET,UAAAjB;CACM,CAAA,CAEX,EAAA,CAAA;AAEN,CAAC"}
1
+ {"version":3,"file":"index.js","names":["_Fragment","Fragment$1","cx","parts","MONTHS","MINUTE","HOUR","DAY","WEEK","pad","value","formatAbsoluteDate","options","stem","date","hasYear","formatAbsoluteTime","stamp","hasTimeZone","zone","part","formatRelativeTime","delta","now","days","Time","forwardRef","describedBy","rest","anchorRef","useRef","isOpen","setIsOpen","useState","tooltipId","useId","setTick","useEffect","format","id","t","refreshInterval","label","isTipped","hasTooltip","node","ref","className","tabIndex","title","onMouseEnter","event","onMouseLeave","onFocus","onBlur","onKeyDown","Popover"],"sources":["../../../src/components/Time/index.tsx"],"sourcesContent":["import {\n forwardRef,\n useEffect,\n useId,\n useRef,\n useState,\n type HTMLAttributes,\n} from \"react\";\nimport { Popover } from \"../Popover\";\nimport \"./style.css\";\n\nfunction cx(...parts: (string | undefined | false)[]) {\n return parts.filter(Boolean).join(\" \");\n}\n\nconst MONTHS = [\n \"Jan\",\n \"Feb\",\n \"Mar\",\n \"Apr\",\n \"May\",\n \"Jun\",\n \"Jul\",\n \"Aug\",\n \"Sep\",\n \"Oct\",\n \"Nov\",\n \"Dec\",\n];\n\nconst MINUTE = 60_000;\nconst HOUR = 60 * MINUTE;\nconst DAY = 24 * HOUR;\nconst WEEK = 7 * DAY;\n\nfunction pad(value: number) {\n return String(value).padStart(2, \"0\");\n}\n\n/** Day before month, one order everywhere: `12 Jun 2026`. */\nexport function formatAbsoluteDate(date: Date, options: { hasYear?: boolean } = {}) {\n const { hasYear = true } = options;\n const stem = `${date.getDate()} ${MONTHS[date.getMonth()]}`;\n return hasYear ? `${stem} ${date.getFullYear()}` : stem;\n}\n\n/** The tooltip form: `6 Aug 2026, 11:05`, with the reader's zone appended. */\nexport function formatAbsoluteTime(date: Date, options: { hasTimeZone?: boolean } = {}) {\n const { hasTimeZone = true } = options;\n const stamp = `${formatAbsoluteDate(date)}, ${pad(date.getHours())}:${pad(date.getMinutes())}`;\n if (!hasTimeZone) return stamp;\n const zone = new Intl.DateTimeFormat(undefined, { timeZoneName: \"short\" })\n .formatToParts(date)\n .find((part) => part.type === \"timeZoneName\")?.value;\n return zone ? `${stamp} ${zone}` : stamp;\n}\n\n/**\n * Relative up to a week, absolute after. Future dates are always absolute — a\n * scheduled publish reads `12 Jun`, never `in 3 days`.\n */\nexport function formatRelativeTime(date: Date, now: Date = new Date()) {\n const delta = now.getTime() - date.getTime();\n if (delta < 0) {\n return formatAbsoluteDate(date, { hasYear: date.getFullYear() !== now.getFullYear() });\n }\n if (delta < MINUTE) return \"Just now\";\n if (delta < HOUR) return `${Math.floor(delta / MINUTE)}m ago`;\n if (delta < DAY) return `${Math.floor(delta / HOUR)}h ago`;\n if (delta < WEEK) {\n const days = Math.floor(delta / DAY);\n return `${days} ${days === 1 ? \"day\" : \"days\"} ago`;\n }\n return formatAbsoluteDate(date, { hasYear: date.getFullYear() !== now.getFullYear() });\n}\n\nexport type TimeFormat = \"auto\" | \"relative\" | \"absolute\";\n\nexport interface TimeProps extends Omit<HTMLAttributes<HTMLElement>, \"children\"> {\n /** The instant to print — Date, epoch ms, or an ISO string. */\n value: Date | string | number;\n /** `auto` ages the value; `absolute` always prints the date. */\n format?: TimeFormat;\n /** Show the absolute stamp on hover and focus. */\n hasTooltip?: boolean;\n /** Append the reader's time zone to the tooltip. */\n hasTimeZone?: boolean;\n /** Pin \"now\" — useful for tests and stories. */\n now?: Date;\n /** Re-render interval in ms while the value is still relative. */\n refreshInterval?: number;\n}\n\n/**\n * A machine-readable `<time>` that ages itself. One form per cell: relative or\n * absolute, never both side by side.\n */\nexport const Time = forwardRef<HTMLTimeElement, TimeProps>(function Time(\n {\n value,\n format = \"auto\",\n hasTooltip = true,\n hasTimeZone = true,\n now,\n refreshInterval = 30_000,\n className,\n tabIndex,\n title,\n onMouseEnter,\n onMouseLeave,\n onFocus,\n onBlur,\n onKeyDown,\n \"aria-describedby\": describedBy,\n ...rest\n },\n ref,\n) {\n const date = value instanceof Date ? value : new Date(value);\n const anchorRef = useRef<HTMLTimeElement | null>(null);\n const [isOpen, setIsOpen] = useState(false);\n const tooltipId = useId();\n const [, setTick] = useState(0);\n\n useEffect(() => {\n if (format === \"absolute\" || now) return;\n const id = window.setInterval(() => setTick((t) => t + 1), refreshInterval);\n return () => window.clearInterval(id);\n }, [format, now, refreshInterval]);\n\n if (Number.isNaN(date.getTime())) return null;\n\n const reference = now ?? new Date();\n const label =\n format === \"absolute\"\n ? formatAbsoluteDate(date)\n : formatRelativeTime(date, reference);\n const stamp = formatAbsoluteTime(date, { hasTimeZone });\n const isTipped = hasTooltip && label !== stamp;\n\n return (\n <>\n <time\n ref={(node) => {\n anchorRef.current = node;\n if (typeof ref === \"function\") ref(node);\n else if (ref) ref.current = node;\n }}\n dateTime={date.toISOString()}\n suppressHydrationWarning\n className={cx(\"ds-time\", !isTipped && \"ds-time--plain\", className)}\n tabIndex={tabIndex ?? (isTipped ? 0 : undefined)}\n aria-describedby={[describedBy, isTipped && isOpen && tooltipId].filter(Boolean).join(\" \") || undefined}\n title={title ?? (isTipped ? undefined : stamp)}\n onMouseEnter={(event) => {\n onMouseEnter?.(event);\n if (isTipped && !event.defaultPrevented) setIsOpen(true);\n }}\n onMouseLeave={(event) => {\n onMouseLeave?.(event);\n if (isTipped && !event.defaultPrevented) setIsOpen(false);\n }}\n onFocus={(event) => {\n onFocus?.(event);\n if (isTipped && !event.defaultPrevented) setIsOpen(true);\n }}\n onBlur={(event) => {\n onBlur?.(event);\n if (isTipped && !event.defaultPrevented) setIsOpen(false);\n }}\n onKeyDown={(event) => {\n onKeyDown?.(event);\n if (isTipped && !event.defaultPrevented && event.key === \"Escape\") setIsOpen(false);\n }}\n {...rest}\n >\n {label}\n </time>\n {isTipped && (\n <Popover\n anchorRef={anchorRef}\n isOpen={isOpen}\n id={tooltipId}\n role=\"tooltip\"\n className=\"ds-surface-raised ds-time-tooltip\"\n >\n {stamp}\n </Popover>\n )}\n </>\n );\n});\n"],"mappings":";;;;AAWA,SAASE,EAAG,GAAGC,GAAuC;CACpD,OAAOA,EAAM,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG;AACvC;AAEA,IAAMC,IAAS;CACb;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,GAEMC,IAAS,KACTC,IAAO,KAAKD,GACZE,IAAM,KAAKD,GACXE,IAAO,IAAID;AAEjB,SAASE,EAAI,GAAe;CAC1B,OAAO,OAAOC,CAAK,CAAC,CAAC,SAAS,GAAG,GAAG;AACtC;AAGA,SAAgBC,EAAmB,GAAY,IAAiC,CAAC,GAAG;CAClF,IAAM,EAAE,aAAU,OAASC,GACrBC,IAAO,GAAGC,EAAK,QAAQ,EAAE,GAAGV,EAAOU,EAAK,SAAS;CACvD,OAAOC,IAAU,GAAGF,EAAK,GAAGC,EAAK,YAAY,MAAMD;AACrD;AAGA,SAAgBG,EAAmB,GAAY,IAAqC,CAAC,GAAG;CACtF,IAAM,EAAE,iBAAc,OAASJ,GACzBK,IAAQ,GAAGN,EAAmBG,CAAI,EAAE,IAAIL,EAA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I;EACzD;EACA,SAAS,MAAU;GAEjB,AADAsB,IAASH,CAAK,GACVR,KAAY,CAACQ,EAAM,oBAAkBnB,EAAU,EAAK;EAC1D;EACA,YAAY,MAAU;GAEpB,AADAuB,IAAYJ,CAAK,GACbR,KAAY,CAACQ,EAAM,oBAAoBA,EAAM,QAAQ,YAAUnB,EAAU,EAAK;EACpF;EACA,GAAIJ;EAEH,UAAAc;CACG,CAAA,GACLC,KACC,kBAACa,GAAD;EACa;EACH;EACR,IAAItB;EACJ,MAAK;EACL,WAAU;EAET,UAAAjB;CACM,CAAA,CAEX,EAAA,CAAA;AAEN,CAAC"}
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./chunks/Icon-CWsA1W83.cjs"),t=require("./components/Button/index.cjs"),n=require("./components/ButtonGroup/index.cjs"),r=require("./chunks/RichTextEditor-tFkISOvq.cjs"),i=require("./components/Badge/index.cjs"),a=require("./components/Modal/index.cjs"),o=require("./components/FieldAffix/index.cjs"),s=require("./components/SearchField/index.cjs"),c=require("./components/SortableList/index.cjs"),l=require("./components/EntryPicker/index.cjs"),u=require("./components/Field/index.cjs"),d=require("./components/NumberField/index.cjs"),f=require("./components/Switch/index.cjs"),p=require("./components/TextField/index.cjs"),m=require("./chunks/EntryEditor-cjDk4vdH.cjs"),h=require("./components/Board/index.cjs"),g=require("./components/Drawer/index.cjs"),_=require("./components/Avatar/index.cjs"),v=require("./components/Grid/index.cjs"),y=require("./components/Choice/index.cjs"),b=require("./components/Table/index.cjs"),x=require("./components/Popover/index.cjs"),S=require("./components/Menu/index.cjs"),C=require("./components/Toast/index.cjs"),w=require("./components/Skeleton/index.cjs"),T=require("./components/SideNav/index.cjs"),E=require("./components/TopNav/index.cjs"),D=require("./components/SubNav/index.cjs"),O=require("./components/SelectionCard/index.cjs"),k=require("./components/Stepper/index.cjs"),A=require("./components/AssetGrid/index.cjs"),j=require("./components/ImageCropper/index.cjs"),M=require("./components/Container/index.cjs"),N=require("./components/Select/index.cjs"),P=require("./components/Slider/index.cjs"),F=require("./components/DatePicker/index.cjs"),I=require("./components/TagsInput/index.cjs"),L=require("./components/Time/index.cjs");exports.AssetGrid=A.AssetGrid,exports.AssetGridEmpty=A.AssetGridEmpty,exports.AssetTile=A.AssetTile,exports.AssetTileSkeleton=A.AssetTileSkeleton,exports.Avatar=_.Avatar,exports.AvatarGroup=_.AvatarGroup,exports.Badge=i.Badge,exports.Board=h.Board,exports.BoardCard=h.BoardCard,exports.BoardColumn=h.BoardColumn,exports.Button=t.Button,exports.ButtonGroup=n.ButtonGroup,exports.Calendar=F.Calendar,exports.Checkbox=y.Checkbox,exports.CheckboxCard=O.CheckboxCard,exports.ChoiceGroup=y.ChoiceGroup,exports.Container=M.Container,exports.DateField=F.DateField,exports.DateRangeField=F.DateRangeField,exports.Drawer=g.Drawer,exports.EntryEditor=m.t,exports.EntryPicker=l.EntryPicker,exports.Field=u.Field,exports.FieldAffix=o.FieldAffix,exports.Grid=v.Grid,exports.GridItem=v.GridItem,exports.Icon=e.t,exports.ImageCropper=j.ImageCropper,exports.Menu=S.Menu,exports.MenuItem=S.MenuItem,exports.MenuLabel=S.MenuLabel,exports.MenuSeparator=S.MenuSeparator,exports.Modal=a.Modal,exports.NumberField=d.NumberField,exports.NumberRangeField=d.NumberRangeField,exports.Popover=x.Popover,exports.Radio=y.Radio,exports.RadioCard=O.RadioCard,exports.RangeSlider=P.RangeSlider,exports.RichTextEditor=r.t,exports.SearchField=s.SearchField,exports.Select=N.Select,exports.SelectionCardGroup=O.SelectionCardGroup,exports.SideNav=T.SideNav,exports.SideNavFooter=T.SideNavFooter,exports.SideNavHeader=T.SideNavHeader,exports.SideNavItem=T.SideNavItem,exports.SideNavSection=T.SideNavSection,exports.Skeleton=w.Skeleton,exports.SkeletonText=w.SkeletonText,exports.Slider=P.Slider,exports.SortableList=c.SortableList,exports.SortableListItem=c.SortableListItem,exports.Stack=v.Stack,exports.Stepper=k.Stepper,exports.SubNav=D.SubNav,exports.SubNavButton=D.SubNavButton,exports.SubNavItem=D.SubNavItem,exports.Switch=f.Switch,exports.Table=b.Table,exports.TableBody=b.TableBody,exports.TableCell=b.TableCell,exports.TableEmpty=b.TableEmpty,exports.TableFrame=b.TableFrame,exports.TableHead=b.TableHead,exports.TableHeaderCell=b.TableHeaderCell,exports.TableRow=b.TableRow,exports.TableToolbar=b.TableToolbar,exports.TagsInput=I.TagsInput,exports.TextArea=p.TextArea,exports.TextField=p.TextField,exports.Time=L.Time,exports.Toast=C.Toast,exports.ToastProvider=C.ToastProvider,exports.TopNav=E.TopNav,exports.TopNavItem=E.TopNavItem,exports.cropRatios=j.cropRatios,exports.cropToBlob=j.cropToBlob,exports.formatAbsoluteDate=L.formatAbsoluteDate,exports.formatAbsoluteTime=L.formatAbsoluteTime,exports.formatIsoDate=F.formatIsoDate,exports.formatRelativeTime=L.formatRelativeTime,exports.iconNames=e.n,exports.icons=e.r,exports.useSideNavCollapsed=T.useSideNavCollapsed,exports.useToast=C.useToast,exports.validateEntryValues=m.n;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./chunks/Icon-CWsA1W83.cjs"),t=require("./components/Button/index.cjs"),n=require("./components/ButtonGroup/index.cjs"),r=require("./components/Field/index.cjs"),i=require("./components/Modal/index.cjs"),a=require("./components/TextField/index.cjs"),o=require("./chunks/RichTextEditor-DC_0oN1s.cjs"),s=require("./components/Badge/index.cjs"),c=require("./components/FieldAffix/index.cjs"),l=require("./components/SearchField/index.cjs"),u=require("./components/SortableList/index.cjs"),d=require("./components/EntryPicker/index.cjs"),f=require("./components/NumberField/index.cjs"),p=require("./components/Switch/index.cjs"),m=require("./chunks/EntryEditor-C32lKKnV.cjs"),h=require("./components/Board/index.cjs"),g=require("./components/Drawer/index.cjs"),_=require("./components/Avatar/index.cjs"),v=require("./components/Grid/index.cjs"),y=require("./components/Choice/index.cjs"),b=require("./components/Table/index.cjs"),x=require("./components/Popover/index.cjs"),S=require("./components/Menu/index.cjs"),C=require("./components/Toast/index.cjs"),w=require("./components/Skeleton/index.cjs"),T=require("./components/SideNav/index.cjs"),E=require("./components/TopNav/index.cjs"),D=require("./components/SubNav/index.cjs"),O=require("./components/SelectionCard/index.cjs"),k=require("./components/Stepper/index.cjs"),A=require("./components/AssetGrid/index.cjs"),j=require("./components/ImageCropper/index.cjs"),M=require("./components/Container/index.cjs"),N=require("./components/Select/index.cjs"),P=require("./components/Slider/index.cjs"),F=require("./components/DatePicker/index.cjs"),I=require("./components/TagsInput/index.cjs"),L=require("./components/Time/index.cjs");exports.AssetGrid=A.AssetGrid,exports.AssetGridEmpty=A.AssetGridEmpty,exports.AssetTile=A.AssetTile,exports.AssetTileSkeleton=A.AssetTileSkeleton,exports.Avatar=_.Avatar,exports.AvatarGroup=_.AvatarGroup,exports.Badge=s.Badge,exports.Board=h.Board,exports.BoardCard=h.BoardCard,exports.BoardColumn=h.BoardColumn,exports.Button=t.Button,exports.ButtonGroup=n.ButtonGroup,exports.Calendar=F.Calendar,exports.Checkbox=y.Checkbox,exports.CheckboxCard=O.CheckboxCard,exports.ChoiceGroup=y.ChoiceGroup,exports.Container=M.Container,exports.DateField=F.DateField,exports.DateRangeField=F.DateRangeField,exports.Drawer=g.Drawer,exports.EntryEditor=m.t,exports.EntryPicker=d.EntryPicker,exports.Field=r.Field,exports.FieldAffix=c.FieldAffix,exports.Grid=v.Grid,exports.GridItem=v.GridItem,exports.Icon=e.t,exports.ImageCropper=j.ImageCropper,exports.Menu=S.Menu,exports.MenuItem=S.MenuItem,exports.MenuLabel=S.MenuLabel,exports.MenuSeparator=S.MenuSeparator,exports.Modal=i.Modal,exports.NumberField=f.NumberField,exports.NumberRangeField=f.NumberRangeField,exports.Popover=x.Popover,exports.Radio=y.Radio,exports.RadioCard=O.RadioCard,exports.RangeSlider=P.RangeSlider,exports.RichTextEditor=o.t,exports.SearchField=l.SearchField,exports.Select=N.Select,exports.SelectionCardGroup=O.SelectionCardGroup,exports.SideNav=T.SideNav,exports.SideNavFooter=T.SideNavFooter,exports.SideNavHeader=T.SideNavHeader,exports.SideNavItem=T.SideNavItem,exports.SideNavSection=T.SideNavSection,exports.Skeleton=w.Skeleton,exports.SkeletonText=w.SkeletonText,exports.Slider=P.Slider,exports.SortableList=u.SortableList,exports.SortableListItem=u.SortableListItem,exports.Stack=v.Stack,exports.Stepper=k.Stepper,exports.SubNav=D.SubNav,exports.SubNavButton=D.SubNavButton,exports.SubNavItem=D.SubNavItem,exports.Switch=p.Switch,exports.Table=b.Table,exports.TableBody=b.TableBody,exports.TableCell=b.TableCell,exports.TableEmpty=b.TableEmpty,exports.TableFrame=b.TableFrame,exports.TableHead=b.TableHead,exports.TableHeaderCell=b.TableHeaderCell,exports.TableRow=b.TableRow,exports.TableToolbar=b.TableToolbar,exports.TagsInput=I.TagsInput,exports.TextArea=a.TextArea,exports.TextField=a.TextField,exports.Time=L.Time,exports.Toast=C.Toast,exports.ToastProvider=C.ToastProvider,exports.TopNav=E.TopNav,exports.TopNavItem=E.TopNavItem,exports.cropRatios=j.cropRatios,exports.cropToBlob=j.cropToBlob,exports.formatAbsoluteDate=L.formatAbsoluteDate,exports.formatAbsoluteTime=L.formatAbsoluteTime,exports.formatIsoDate=F.formatIsoDate,exports.formatRelativeTime=L.formatRelativeTime,exports.iconNames=e.n,exports.icons=e.r,exports.useSideNavCollapsed=T.useSideNavCollapsed,exports.useToast=C.useToast,exports.validateEntryValues=m.n;
package/dist/index.js CHANGED
@@ -1,18 +1,18 @@
1
1
  import { n as e, r as t, t as n } from "./chunks/Icon-CGY1FNXT.js";
2
2
  import { Button as r } from "./components/Button/index.js";
3
3
  import { ButtonGroup as i } from "./components/ButtonGroup/index.js";
4
- import { t as a } from "./chunks/RichTextEditor-DRt-kibg.js";
5
- import { Badge as o } from "./components/Badge/index.js";
6
- import { Modal as s } from "./components/Modal/index.js";
7
- import { FieldAffix as c } from "./components/FieldAffix/index.js";
8
- import { SearchField as l } from "./components/SearchField/index.js";
9
- import { SortableList as u, SortableListItem as d } from "./components/SortableList/index.js";
10
- import { EntryPicker as f } from "./components/EntryPicker/index.js";
11
- import { Field as p } from "./components/Field/index.js";
12
- import { NumberField as m, NumberRangeField as h } from "./components/NumberField/index.js";
13
- import { Switch as g } from "./components/Switch/index.js";
14
- import { TextArea as _, TextField as v } from "./components/TextField/index.js";
15
- import { n as y, t as b } from "./chunks/EntryEditor-BF808OZR.js";
4
+ import { Field as a } from "./components/Field/index.js";
5
+ import { Modal as o } from "./components/Modal/index.js";
6
+ import { TextArea as s, TextField as c } from "./components/TextField/index.js";
7
+ import { t as l } from "./chunks/RichTextEditor-CSpjsL1z.js";
8
+ import { Badge as u } from "./components/Badge/index.js";
9
+ import { FieldAffix as d } from "./components/FieldAffix/index.js";
10
+ import { SearchField as f } from "./components/SearchField/index.js";
11
+ import { SortableList as p, SortableListItem as m } from "./components/SortableList/index.js";
12
+ import { EntryPicker as h } from "./components/EntryPicker/index.js";
13
+ import { NumberField as g, NumberRangeField as _ } from "./components/NumberField/index.js";
14
+ import { Switch as v } from "./components/Switch/index.js";
15
+ import { n as y, t as b } from "./chunks/EntryEditor-xVuiqtFo.js";
16
16
  import { Board as x, BoardCard as S, BoardColumn as C } from "./components/Board/index.js";
17
17
  import { Drawer as w } from "./components/Drawer/index.js";
18
18
  import { Avatar as T, AvatarGroup as E } from "./components/Avatar/index.js";
@@ -36,4 +36,4 @@ import { RangeSlider as Se, Slider as Ce } from "./components/Slider/index.js";
36
36
  import { Calendar as we, DateField as Te, DateRangeField as Ee, formatIsoDate as De } from "./components/DatePicker/index.js";
37
37
  import { TagsInput as Oe } from "./components/TagsInput/index.js";
38
38
  import { Time as ke, formatAbsoluteDate as Ae, formatAbsoluteTime as je, formatRelativeTime as Me } from "./components/Time/index.js";
39
- export { pe as AssetGrid, me as AssetGridEmpty, he as AssetTile, ge as AssetTileSkeleton, T as Avatar, E as AvatarGroup, o as Badge, x as Board, S as BoardCard, C as BoardColumn, r as Button, i as ButtonGroup, we as Calendar, A as Checkbox, le as CheckboxCard, j as ChoiceGroup, be as Container, Te as DateField, Ee as DateRangeField, w as Drawer, b as EntryEditor, f as EntryPicker, p as Field, c as FieldAffix, D as Grid, O as GridItem, n as Icon, _e as ImageCropper, U as Menu, W as MenuItem, G as MenuLabel, K as MenuSeparator, s as Modal, m as NumberField, h as NumberRangeField, H as Popover, M as Radio, ue as RadioCard, Se as RangeSlider, a as RichTextEditor, l as SearchField, xe as Select, de as SelectionCardGroup, Q as SideNav, $ as SideNavFooter, ee as SideNavHeader, te as SideNavItem, ne as SideNavSection, X as Skeleton, Z as SkeletonText, Ce as Slider, u as SortableList, d as SortableListItem, k as Stack, fe as Stepper, oe as SubNav, se as SubNavButton, ce as SubNavItem, g as Switch, N as Table, P as TableBody, F as TableCell, I as TableEmpty, L as TableFrame, R as TableHead, z as TableHeaderCell, B as TableRow, V as TableToolbar, Oe as TagsInput, _ as TextArea, v as TextField, ke as Time, q as Toast, J as ToastProvider, ie as TopNav, ae as TopNavItem, ve as cropRatios, ye as cropToBlob, Ae as formatAbsoluteDate, je as formatAbsoluteTime, De as formatIsoDate, Me as formatRelativeTime, e as iconNames, t as icons, re as useSideNavCollapsed, Y as useToast, y as validateEntryValues };
39
+ export { pe as AssetGrid, me as AssetGridEmpty, he as AssetTile, ge as AssetTileSkeleton, T as Avatar, E as AvatarGroup, u as Badge, x as Board, S as BoardCard, C as BoardColumn, r as Button, i as ButtonGroup, we as Calendar, A as Checkbox, le as CheckboxCard, j as ChoiceGroup, be as Container, Te as DateField, Ee as DateRangeField, w as Drawer, b as EntryEditor, h as EntryPicker, a as Field, d as FieldAffix, D as Grid, O as GridItem, n as Icon, _e as ImageCropper, U as Menu, W as MenuItem, G as MenuLabel, K as MenuSeparator, o as Modal, g as NumberField, _ as NumberRangeField, H as Popover, M as Radio, ue as RadioCard, Se as RangeSlider, l as RichTextEditor, f as SearchField, xe as Select, de as SelectionCardGroup, Q as SideNav, $ as SideNavFooter, ee as SideNavHeader, te as SideNavItem, ne as SideNavSection, X as Skeleton, Z as SkeletonText, Ce as Slider, p as SortableList, m as SortableListItem, k as Stack, fe as Stepper, oe as SubNav, se as SubNavButton, ce as SubNavItem, v as Switch, N as Table, P as TableBody, F as TableCell, I as TableEmpty, L as TableFrame, R as TableHead, z as TableHeaderCell, B as TableRow, V as TableToolbar, Oe as TagsInput, s as TextArea, c as TextField, ke as Time, q as Toast, J as ToastProvider, ie as TopNav, ae as TopNavItem, ve as cropRatios, ye as cropToBlob, Ae as formatAbsoluteDate, je as formatAbsoluteTime, De as formatIsoDate, Me as formatRelativeTime, e as iconNames, t as icons, re as useSideNavCollapsed, Y as useToast, y as validateEntryValues };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@namroodinc/liquid-editorial",
3
- "version": "0.1.1",
3
+ "version": "0.1.4",
4
4
  "description": "A bold, accessible React component library for editorial products.",
5
5
  "author": "Namrood Inc",
6
6
  "license": "MIT",
@@ -26,6 +26,8 @@
26
26
  },
27
27
  "files": [
28
28
  "dist",
29
+ "AGENTS.md",
30
+ "UPGRADING.md",
29
31
  "README.md",
30
32
  "LICENSE"
31
33
  ],
@@ -1,181 +0,0 @@
1
- import { n as e, r as t, t as n } from "./RichTextEditor-DRt-kibg.js";
2
- import { EntryPicker as r } from "../components/EntryPicker/index.js";
3
- import { Field as i } from "../components/Field/index.js";
4
- import { NumberField as a } from "../components/NumberField/index.js";
5
- import { Switch as o } from "../components/Switch/index.js";
6
- import { TextArea as s, TextField as c } from "../components/TextField/index.js";
7
- import { useState as l } from "react";
8
- import { jsx as u } from "react/jsx-runtime";
9
- //#region src/components/EntryEditor/model.ts
10
- var d = /* @__PURE__ */ new Set([
11
- "shortText",
12
- "longText",
13
- "richText",
14
- "number",
15
- "boolean",
16
- "dateTime",
17
- "asset",
18
- "reference"
19
- ]);
20
- function f(e) {
21
- let t = /* @__PURE__ */ new Set();
22
- for (let n of e.fields) {
23
- if (!n.id?.trim() || t.has(n.id)) throw Error("Content model field IDs must be nonempty and unique.");
24
- if (!d.has(n.type)) throw Error(`Unsupported content field type: ${n.type}`);
25
- t.add(n.id);
26
- }
27
- }
28
- function p(e) {
29
- if (typeof e != "string") return;
30
- let t = /^(\d{4}-\d{2}-\d{2}T\d{2}:\d{2})(?::(\d{2})(?:\.(\d{1,3}))?)?(?:Z|\+00:00)$/.exec(e);
31
- if (!t) return;
32
- let n = `${t[1]}:${t[2] ?? "00"}.${(t[3] ?? "").padEnd(3, "0")}Z`, r = new Date(n);
33
- if (Number.isFinite(r.getTime()) && r.toISOString() === n) return n;
34
- }
35
- function m(e, t) {
36
- return !!e && typeof e == "object" && t in e && typeof e[t] == "string" && e[t].trim().length > 0;
37
- }
38
- function h(e) {
39
- return !!e.text?.trim() || e.type === "horizontalRule" || !!e.content?.some(h);
40
- }
41
- function g(t, n) {
42
- return f(t), Object.fromEntries(t.fields.flatMap((t) => {
43
- let r = Object.hasOwn(n, t.id) ? n[t.id] : void 0, i;
44
- if (r === void 0) t.required && (i = `${t.label} is required.`);
45
- else switch (t.type) {
46
- case "shortText":
47
- case "longText":
48
- typeof r == "string" ? t.required && !r.trim() && (i = `${t.label} is required.`) : i = "Enter text.";
49
- break;
50
- case "richText":
51
- i = e(r), !i && t.required && !h(r) && (i = `${t.label} is required.`);
52
- break;
53
- case "number":
54
- (typeof r != "number" || !Number.isFinite(r)) && (i = "Enter a finite number.");
55
- break;
56
- case "boolean":
57
- typeof r != "boolean" && (i = "Choose a boolean value.");
58
- break;
59
- case "dateTime":
60
- p(r) || (i = "Enter a valid UTC date and time.");
61
- break;
62
- case "asset":
63
- case "reference": {
64
- let e = t.type === "asset" ? "assetId" : "entryId";
65
- (t.multiple ? !Array.isArray(r) || !r.every((t) => m(t, e)) : !m(r, e)) ? i = t.multiple ? `Choose a list of ${t.type === "asset" ? "assets" : "entries"}.` : `Choose an ${t.type === "asset" ? "asset" : "entry"}.` : t.required && Array.isArray(r) && r.length === 0 && (i = `${t.label} is required.`);
66
- break;
67
- }
68
- }
69
- return i ? [[t.id, i]] : [];
70
- }));
71
- }
72
- //#endregion
73
- //#region src/components/EntryEditor/index.tsx
74
- function _(e, t) {
75
- let n = e.type === "asset" ? "assetId" : "entryId";
76
- return (Array.isArray(t) ? t : t === void 0 ? [] : [t]).flatMap((e) => {
77
- if (!e || typeof e != "object" || !(n in e)) return [];
78
- let t = e[n];
79
- return typeof t == "string" ? [t] : [];
80
- });
81
- }
82
- function v({ model: e, value: d, defaultValue: f = {}, onValueChange: m, pickerItems: h = {}, errors: v = {}, isDisabled: y = !1, showAllErrors: b = !1, className: x, ...S }) {
83
- let [C, w] = l(f), [T, E] = l(() => /* @__PURE__ */ new Set()), D = d ?? C, O = g(e, D), k = (e, t) => {
84
- if (y) return;
85
- let n = { ...D };
86
- t === void 0 ? delete n[e] : n[e] = t, d === void 0 && w(n), E((t) => new Set(t).add(e)), m?.(n);
87
- };
88
- return /* @__PURE__ */ u("div", {
89
- className: ["ds-entry-editor", x].filter(Boolean).join(" "),
90
- ...S,
91
- children: e.fields.map((e) => {
92
- let l = Object.hasOwn(D, e.id) ? D[e.id] : void 0, d = e.type === "asset" || e.type === "reference", f = e.type === "dateTime" ? `${e.label} (UTC)` : e.label, m = v[e.id] ?? (b || T.has(e.id) ? O[e.id] : void 0);
93
- return /* @__PURE__ */ u(i, {
94
- label: f,
95
- hint: e.hint,
96
- error: m,
97
- isRequired: e.required,
98
- isGroup: d,
99
- children: ({ required: i, ...d }) => {
100
- switch (e.type) {
101
- case "shortText":
102
- case "longText": {
103
- let t = e.type === "shortText" ? c : s;
104
- return /* @__PURE__ */ u(t, {
105
- ...d,
106
- required: i,
107
- disabled: y,
108
- placeholder: e.placeholder,
109
- value: typeof l == "string" ? l : "",
110
- onChange: (t) => k(e.id, t.target.value)
111
- });
112
- }
113
- case "number": return /* @__PURE__ */ u(a, {
114
- ...d,
115
- required: i,
116
- isDisabled: y,
117
- placeholder: e.placeholder,
118
- step: "any",
119
- hasSteppers: !1,
120
- value: typeof l == "number" && Number.isFinite(l) ? l : "",
121
- onValueChange: (t) => {
122
- (t === "" || Number.isFinite(t)) && k(e.id, t === "" ? void 0 : t);
123
- }
124
- });
125
- case "boolean": return /* @__PURE__ */ u(o, {
126
- ...d,
127
- isDisabled: y,
128
- isSelected: l === !0,
129
- onSelectedChange: (t) => k(e.id, t)
130
- });
131
- case "dateTime": return /* @__PURE__ */ u(c, {
132
- ...d,
133
- required: i,
134
- disabled: y,
135
- type: "datetime-local",
136
- step: "0.001",
137
- value: p(l)?.slice(0, -1) ?? "",
138
- onChange: (t) => k(e.id, p(`${t.target.value}Z`))
139
- });
140
- case "richText": return /* @__PURE__ */ u(n, {
141
- ...d,
142
- label: e.label,
143
- isRequired: i,
144
- isDisabled: y,
145
- placeholder: e.placeholder,
146
- format: "json",
147
- value: l === void 0 ? t : l,
148
- onChange: (t) => k(e.id, t)
149
- });
150
- case "asset":
151
- case "reference": return /* @__PURE__ */ u("div", {
152
- ...d,
153
- role: "group",
154
- children: /* @__PURE__ */ u(r, {
155
- items: h[e.id] ?? [],
156
- value: _(e, l),
157
- label: e.type === "asset" ? "Assets" : "Entries",
158
- addLabel: `Choose ${e.label}`,
159
- mode: e.multiple ? "multiple" : "single",
160
- isDisabled: y,
161
- onValueChange: (t) => {
162
- if (e.type === "asset") {
163
- let n = t.map((e) => ({ assetId: e }));
164
- k(e.id, e.multiple ? n : n[0]);
165
- } else {
166
- let n = t.map((e) => ({ entryId: e }));
167
- k(e.id, e.multiple ? n : n[0]);
168
- }
169
- }
170
- })
171
- });
172
- }
173
- }
174
- }, e.id);
175
- })
176
- });
177
- }
178
- //#endregion
179
- export { g as n, v as t };
180
-
181
- //# sourceMappingURL=EntryEditor-BF808OZR.js.map
@@ -1,248 +0,0 @@
1
- import { Button as e } from "../components/Button/index.js";
2
- import { ButtonGroup as t } from "../components/ButtonGroup/index.js";
3
- /* empty css */
4
- import { forwardRef as n, useCallback as r, useEffect as i, useId as a, useMemo as o, useState as s } from "react";
5
- import { jsx as c, jsxs as l } from "react/jsx-runtime";
6
- import { EditorContent as u, createDocument as d, getSchema as f, useEditor as p, useEditorState as m } from "@tiptap/react";
7
- import { Placeholder as h } from "@tiptap/extension-placeholder";
8
- import { StarterKit as g } from "@tiptap/starter-kit";
9
- import { Link as _ } from "@tiptap/extension-link";
10
- //#region src/components/RichTextEditor/document.ts
11
- var v = {
12
- type: "doc",
13
- content: [{ type: "paragraph" }]
14
- };
15
- function y() {
16
- return [g.configure({ link: !1 }), _.configure({
17
- openOnClick: !1,
18
- autolink: !0
19
- })];
20
- }
21
- var b = f(y());
22
- function x(e) {
23
- return e.content?.length ? e : {
24
- ...e,
25
- content: v.content
26
- };
27
- }
28
- function S(e) {
29
- try {
30
- if (!e || typeof e != "object" || !("type" in e) || e.type !== "doc") throw Error();
31
- let t = (e) => {
32
- let n = b.nodes[e.type ?? ""];
33
- if (!n || Object.keys(e).some((e) => ![
34
- "type",
35
- "attrs",
36
- "content",
37
- "marks",
38
- "text"
39
- ].includes(e)) || e.text !== void 0 && e.type !== "text" || e.attrs && Object.keys(e.attrs).some((e) => !Object.hasOwn(n.spec.attrs ?? {}, e))) throw Error();
40
- for (let t of e.marks ?? []) {
41
- let e = b.marks[t.type];
42
- if (!e || Object.keys(t).some((e) => !["type", "attrs"].includes(e)) || Object.keys(t.attrs ?? {}).some((t) => !Object.hasOwn(e.spec.attrs ?? {}, t))) throw Error();
43
- }
44
- e.content?.forEach(t);
45
- }, n = e;
46
- t(n), b.nodeFromJSON(x(n)).check();
47
- } catch {
48
- return "Unsupported or invalid rich-text document.";
49
- }
50
- }
51
- //#endregion
52
- //#region src/components/RichTextEditor/index.tsx
53
- var C = [
54
- [
55
- {
56
- id: "bold",
57
- icon: "bold",
58
- label: "Bold",
59
- run: (e) => e.chain().focus().toggleBold().run(),
60
- active: (e) => e.isActive("bold")
61
- },
62
- {
63
- id: "italic",
64
- icon: "italic",
65
- label: "Italic",
66
- run: (e) => e.chain().focus().toggleItalic().run(),
67
- active: (e) => e.isActive("italic")
68
- },
69
- {
70
- id: "strike",
71
- icon: "strikethrough",
72
- label: "Strikethrough",
73
- run: (e) => e.chain().focus().toggleStrike().run(),
74
- active: (e) => e.isActive("strike")
75
- },
76
- {
77
- id: "code",
78
- icon: "code",
79
- label: "Inline code",
80
- run: (e) => e.chain().focus().toggleCode().run(),
81
- active: (e) => e.isActive("code")
82
- }
83
- ],
84
- [
85
- {
86
- id: "h2",
87
- icon: "heading-2",
88
- label: "Heading",
89
- run: (e) => e.chain().focus().toggleHeading({ level: 2 }).run(),
90
- active: (e) => e.isActive("heading", { level: 2 })
91
- },
92
- {
93
- id: "h3",
94
- icon: "heading-3",
95
- label: "Subheading",
96
- run: (e) => e.chain().focus().toggleHeading({ level: 3 }).run(),
97
- active: (e) => e.isActive("heading", { level: 3 })
98
- },
99
- {
100
- id: "quote",
101
- icon: "quote",
102
- label: "Quote",
103
- run: (e) => e.chain().focus().toggleBlockquote().run(),
104
- active: (e) => e.isActive("blockquote")
105
- }
106
- ],
107
- [{
108
- id: "ul",
109
- icon: "list",
110
- label: "Bulleted list",
111
- run: (e) => e.chain().focus().toggleBulletList().run(),
112
- active: (e) => e.isActive("bulletList")
113
- }, {
114
- id: "ol",
115
- icon: "list-ordered",
116
- label: "Numbered list",
117
- run: (e) => e.chain().focus().toggleOrderedList().run(),
118
- active: (e) => e.isActive("orderedList")
119
- }],
120
- [{
121
- id: "undo",
122
- icon: "undo",
123
- label: "Undo",
124
- run: (e) => e.chain().focus().undo().run()
125
- }, {
126
- id: "redo",
127
- icon: "redo",
128
- label: "Redo",
129
- run: (e) => e.chain().focus().redo().run()
130
- }]
131
- ], w = n(function(n, f) {
132
- let { placeholder: g = "Write something…", size: _ = "md", isDisabled: b = !1, isInvalid: w = !1, label: T = "Rich text editor", className: E, toolbarExtra: D, id: O, isRequired: k, "aria-labelledby": A, "aria-describedby": j, "aria-invalid": M } = n, [N, P] = s(!1), [F] = s(() => n.defaultValue ?? (n.format === "json" ? v : "")), I = n.value === void 0 ? F : n.value, L = o(() => n.format === "json" ? S(I) : void 0, [n.format, I]), R = a(), z = w || !!L || M, B = b || !!L, V = o(() => ({
133
- role: "textbox",
134
- "aria-label": T,
135
- "aria-multiline": "true",
136
- ...O ? { id: O } : {},
137
- ...A ? { "aria-labelledby": A } : {},
138
- ...j ? { "aria-describedby": j } : {},
139
- ...z ? { "aria-invalid": String(z) } : {},
140
- ...k ? { "aria-required": "true" } : {}
141
- }), [
142
- T,
143
- O,
144
- A,
145
- j,
146
- z,
147
- k
148
- ]), H = p({
149
- immediatelyRender: !1,
150
- editable: !B,
151
- content: L ? v : typeof I == "string" ? I : x(I),
152
- extensions: [...y(), h.configure({ placeholder: g })],
153
- editorProps: { attributes: V },
154
- onFocus: () => P(!0),
155
- onBlur: () => P(!1),
156
- onUpdate: ({ editor: e }) => {
157
- B || (n.format === "json" ? n.onChange?.(e.getJSON()) : n.onChange?.(e.getHTML()));
158
- }
159
- });
160
- i(() => {
161
- H && (H.setEditable(!B, !1), H.setOptions({ editorProps: { attributes: V } }));
162
- }, [
163
- H,
164
- B,
165
- V
166
- ]), i(() => {
167
- if (!H || n.value === void 0 || L) return;
168
- let e = typeof n.value == "string" ? d(n.value, H.schema) : H.schema.nodeFromJSON(x(n.value));
169
- e.eq(H.state.doc) || H.commands.setContent(e, { emitUpdate: !1 });
170
- }, [
171
- H,
172
- n.value,
173
- L
174
- ]);
175
- let U = m({
176
- editor: H,
177
- selector: ({ editor: e }) => e ? {
178
- active: Object.fromEntries(C.flat().map((t) => [t.id, t.active?.(e) ?? !1])),
179
- linkActive: e.isActive("link")
180
- } : null
181
- }), W = r(() => {
182
- if (!H) return;
183
- if (H.isActive("link")) {
184
- H.chain().focus().unsetLink().run();
185
- return;
186
- }
187
- let e = window.prompt("Link to");
188
- e && H.chain().focus().extendMarkRange("link").setLink({ href: e }).run();
189
- }, [H]);
190
- return /* @__PURE__ */ l("div", {
191
- ref: f,
192
- className: ["ds-rte", E].filter(Boolean).join(" "),
193
- "data-focused": N || void 0,
194
- "data-disabled": B || void 0,
195
- "aria-invalid": z || void 0,
196
- children: [L && /* @__PURE__ */ c("p", {
197
- id: R,
198
- role: "alert",
199
- className: "ds-field__error",
200
- children: L
201
- }), /* @__PURE__ */ l("div", {
202
- hidden: !!L,
203
- children: [/* @__PURE__ */ l("div", {
204
- className: "ds-rte__toolbar",
205
- role: "toolbar",
206
- "aria-label": `${T} formatting`,
207
- children: [
208
- C.map((n, r) => /* @__PURE__ */ c(t, {
209
- "aria-label": `Formatting ${r + 1}`,
210
- children: n.map((t) => /* @__PURE__ */ c(e, {
211
- size: "sm",
212
- isIconOnly: !0,
213
- iconStart: t.icon,
214
- "aria-label": t.label,
215
- title: t.label,
216
- "aria-pressed": t.active ? U?.active[t.id] : void 0,
217
- variant: U?.active[t.id] ? "active" : "neutral",
218
- isDisabled: B || !H,
219
- onClick: () => H && t.run(H)
220
- }, t.id))
221
- }, r)),
222
- /* @__PURE__ */ c(t, {
223
- "aria-label": "Link",
224
- children: /* @__PURE__ */ c(e, {
225
- size: "sm",
226
- isIconOnly: !0,
227
- iconStart: U?.linkActive ? "link-off" : "link",
228
- "aria-label": U?.linkActive ? "Remove link" : "Add link",
229
- title: U?.linkActive ? "Remove link" : "Add link",
230
- variant: U?.linkActive ? "active" : "neutral",
231
- isDisabled: B || !H,
232
- onClick: W
233
- })
234
- }),
235
- D
236
- ]
237
- }), /* @__PURE__ */ c("div", {
238
- className: "ds-rte__content",
239
- "data-size": _,
240
- children: /* @__PURE__ */ c(u, { editor: H })
241
- })]
242
- })]
243
- });
244
- });
245
- //#endregion
246
- export { S as n, v as r, w as t };
247
-
248
- //# sourceMappingURL=RichTextEditor-DRt-kibg.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"RichTextEditor-DRt-kibg.js","names":["emptyDocument","richTextExtensions","StarterKit","Link","schema","getSchema","normalizeDocument","document","documentError","value","check","type","node","key","mark","markType","GROUPS","RichTextEditor","forwardRef","labelledBy","describedBy","ariaInvalid","props","isFocused","setIsFocused","useState","initialValue","content","contentError","useMemo","errorId","useId","invalid","isInvalid","disabled","isDisabled","attributes","label","id","isRequired","editor","useEditor","Placeholder","useEffect","next","createDocument","state","useEditorState","toggleLink","useCallback","href","className","ButtonGroup","i","group","Button","tool","toolbarExtra","size","EditorContent"],"sources":["../../src/components/RichTextEditor/document.ts","../../src/components/RichTextEditor/index.tsx"],"sourcesContent":["import { getSchema, type JSONContent } from \"@tiptap/react\";\nimport { StarterKit } from \"@tiptap/starter-kit\";\nimport { Link } from \"@tiptap/extension-link\";\n\nexport type RichTextDocument = JSONContent & { type: \"doc\" };\n\nexport const emptyDocument: RichTextDocument = { type: \"doc\", content: [{ type: \"paragraph\" }] };\n\nexport function richTextExtensions() {\n return [StarterKit.configure({ link: false }), Link.configure({ openOnClick: false, autolink: true })];\n}\n\nconst schema = getSchema(richTextExtensions());\n\n/** ProseMirror represents an empty writing surface with one empty paragraph. */\nexport function normalizeDocument(document: RichTextDocument): RichTextDocument {\n return !document.content?.length ? { ...document, content: emptyDocument.content } : document;\n}\n\nexport function documentError(value: unknown): string | undefined {\n try {\n if (!value || typeof value !== \"object\" || !(\"type\" in value) || value.type !== \"doc\") throw new Error();\n const check = (node: JSONContent) => {\n const type = schema.nodes[node.type ?? \"\"];\n if (!type || Object.keys(node).some((key) => ![\"type\", \"attrs\", \"content\", \"marks\", \"text\"].includes(key)) ||\n (node.text !== undefined && node.type !== \"text\") ||\n (node.attrs && Object.keys(node.attrs).some((key) => !Object.hasOwn(type.spec.attrs ?? {}, key)))) {\n throw new Error();\n }\n for (const mark of node.marks ?? []) {\n const markType = schema.marks[mark.type];\n if (!markType || Object.keys(mark).some((key) => ![\"type\", \"attrs\"].includes(key)) ||\n Object.keys(mark.attrs ?? {}).some((key) => !Object.hasOwn(markType.spec.attrs ?? {}, key))) {\n throw new Error();\n }\n }\n node.content?.forEach(check);\n };\n const document = value as RichTextDocument;\n check(document);\n schema.nodeFromJSON(normalizeDocument(document)).check();\n } catch {\n return \"Unsupported or invalid rich-text document.\";\n }\n}\n","import { forwardRef, useCallback, useEffect, useId, useMemo, useState, type AriaAttributes, type ReactNode } from \"react\";\nimport { createDocument, EditorContent, useEditor, useEditorState, type Editor } from \"@tiptap/react\";\nimport { Placeholder } from \"@tiptap/extension-placeholder\";\nimport { Button } from \"../Button\";\nimport { ButtonGroup } from \"../ButtonGroup\";\nimport type { IconName } from \"../Icon/icons\";\nimport { documentError, emptyDocument, normalizeDocument, richTextExtensions, type RichTextDocument } from \"./document\";\nimport \"../Field/style.css\";\nimport \"./style.css\";\n\nexport type RichTextEditorSize = \"sm\" | \"md\" | \"lg\";\n\nexport type { RichTextDocument } from \"./document\";\n\ninterface RichTextEditorCommonProps {\n placeholder?: string;\n size?: RichTextEditorSize;\n isDisabled?: boolean;\n isInvalid?: boolean;\n /** Accessible name for the editing surface. */\n label?: string;\n className?: string;\n /** Extra controls appended to the toolbar, e.g. a word count. */\n toolbarExtra?: ReactNode;\n /** Applied to the editable surface. */\n id?: string;\n isRequired?: boolean;\n \"aria-labelledby\"?: string;\n \"aria-describedby\"?: string;\n \"aria-invalid\"?: AriaAttributes[\"aria-invalid\"];\n}\n\nexport type RichTextEditorProps = RichTextEditorCommonProps & (\n | { format?: \"html\"; value?: string; defaultValue?: string; onChange?: (html: string) => void }\n | { format: \"json\"; value?: RichTextDocument; defaultValue?: RichTextDocument; onChange?: (document: RichTextDocument) => void }\n);\n\ninterface ToolItem {\n id: string;\n icon: IconName;\n label: string;\n run: (editor: Editor) => void;\n active?: (editor: Editor) => boolean;\n}\n\nconst GROUPS: ToolItem[][] = [\n [\n {\n id: \"bold\",\n icon: \"bold\",\n label: \"Bold\",\n run: (e) => e.chain().focus().toggleBold().run(),\n active: (e) => e.isActive(\"bold\"),\n },\n {\n id: \"italic\",\n icon: \"italic\",\n label: \"Italic\",\n run: (e) => e.chain().focus().toggleItalic().run(),\n active: (e) => e.isActive(\"italic\"),\n },\n {\n id: \"strike\",\n icon: \"strikethrough\",\n label: \"Strikethrough\",\n run: (e) => e.chain().focus().toggleStrike().run(),\n active: (e) => e.isActive(\"strike\"),\n },\n {\n id: \"code\",\n icon: \"code\",\n label: \"Inline code\",\n run: (e) => e.chain().focus().toggleCode().run(),\n active: (e) => e.isActive(\"code\"),\n },\n ],\n [\n {\n id: \"h2\",\n icon: \"heading-2\",\n label: \"Heading\",\n run: (e) => e.chain().focus().toggleHeading({ level: 2 }).run(),\n active: (e) => e.isActive(\"heading\", { level: 2 }),\n },\n {\n id: \"h3\",\n icon: \"heading-3\",\n label: \"Subheading\",\n run: (e) => e.chain().focus().toggleHeading({ level: 3 }).run(),\n active: (e) => e.isActive(\"heading\", { level: 3 }),\n },\n {\n id: \"quote\",\n icon: \"quote\",\n label: \"Quote\",\n run: (e) => e.chain().focus().toggleBlockquote().run(),\n active: (e) => e.isActive(\"blockquote\"),\n },\n ],\n [\n {\n id: \"ul\",\n icon: \"list\",\n label: \"Bulleted list\",\n run: (e) => e.chain().focus().toggleBulletList().run(),\n active: (e) => e.isActive(\"bulletList\"),\n },\n {\n id: \"ol\",\n icon: \"list-ordered\",\n label: \"Numbered list\",\n run: (e) => e.chain().focus().toggleOrderedList().run(),\n active: (e) => e.isActive(\"orderedList\"),\n },\n ],\n [\n {\n id: \"undo\",\n icon: \"undo\",\n label: \"Undo\",\n run: (e) => e.chain().focus().undo().run(),\n },\n {\n id: \"redo\",\n icon: \"redo\",\n label: \"Redo\",\n run: (e) => e.chain().focus().redo().run(),\n },\n ],\n];\n\n/**\n * The editorial writing surface. Rich text plus links — the same field skin,\n * radius and states as `TextField`, with the toolbar inside the frame.\n */\nexport const RichTextEditor = forwardRef<HTMLDivElement, RichTextEditorProps>(\n function RichTextEditor(\n props,\n ref,\n ) {\n const {\n placeholder = \"Write something…\",\n size = \"md\",\n isDisabled = false,\n isInvalid = false,\n label = \"Rich text editor\",\n className,\n toolbarExtra,\n id,\n isRequired,\n \"aria-labelledby\": labelledBy,\n \"aria-describedby\": describedBy,\n \"aria-invalid\": ariaInvalid,\n } = props;\n const [isFocused, setIsFocused] = useState(false);\n const [initialValue] = useState(() => props.defaultValue ?? (props.format === \"json\" ? emptyDocument : \"\"));\n const content = props.value !== undefined ? props.value : initialValue;\n const contentError = useMemo(() => props.format === \"json\" ? documentError(content) : undefined, [props.format, content]);\n const errorId = useId();\n const invalid = isInvalid || !!contentError || ariaInvalid;\n const disabled = isDisabled || !!contentError;\n const attributes = useMemo(() => ({\n role: \"textbox\",\n \"aria-label\": label,\n \"aria-multiline\": \"true\",\n ...(id ? { id } : {}),\n ...(labelledBy ? { \"aria-labelledby\": labelledBy } : {}),\n ...(describedBy ? { \"aria-describedby\": describedBy } : {}),\n ...(invalid ? { \"aria-invalid\": String(invalid) } : {}),\n ...(isRequired ? { \"aria-required\": \"true\" } : {}),\n }), [label, id, labelledBy, describedBy, invalid, isRequired]);\n\n const editor = useEditor({\n immediatelyRender: false,\n editable: !disabled,\n content: contentError ? emptyDocument : typeof content === \"string\" ? content : normalizeDocument(content),\n extensions: [\n ...richTextExtensions(),\n Placeholder.configure({ placeholder }),\n ],\n editorProps: {\n attributes,\n },\n onFocus: () => setIsFocused(true),\n onBlur: () => setIsFocused(false),\n onUpdate: ({ editor: e }) => {\n if (disabled) return;\n if (props.format === \"json\") props.onChange?.(e.getJSON() as RichTextDocument);\n else props.onChange?.(e.getHTML());\n },\n });\n\n useEffect(() => {\n if (!editor) return;\n editor.setEditable(!disabled, false);\n editor.setOptions({ editorProps: { attributes } });\n }, [editor, disabled, attributes]);\n\n useEffect(() => {\n if (!editor || props.value === undefined || contentError) return;\n const next = typeof props.value === \"string\"\n ? createDocument(props.value, editor.schema)\n : editor.schema.nodeFromJSON(normalizeDocument(props.value));\n // Parent echoes should preserve the current selection and undo history.\n if (!next.eq(editor.state.doc)) editor.commands.setContent(next, { emitUpdate: false });\n }, [editor, props.value, contentError]);\n\n const state = useEditorState({\n editor,\n selector: ({ editor: e }) =>\n e\n ? {\n active: Object.fromEntries(\n GROUPS.flat().map((t) => [t.id, t.active?.(e) ?? false]),\n ),\n linkActive: e.isActive(\"link\"),\n }\n : null,\n });\n\n const toggleLink = useCallback(() => {\n if (!editor) return;\n if (editor.isActive(\"link\")) {\n editor.chain().focus().unsetLink().run();\n return;\n }\n const href = window.prompt(\"Link to\");\n if (!href) return;\n editor.chain().focus().extendMarkRange(\"link\").setLink({ href }).run();\n }, [editor]);\n\n return (\n <div\n ref={ref}\n className={[\"ds-rte\", className].filter(Boolean).join(\" \")}\n data-focused={isFocused || undefined}\n data-disabled={disabled || undefined}\n aria-invalid={invalid || undefined}\n >\n {contentError && <p id={errorId} role=\"alert\" className=\"ds-field__error\">{contentError}</p>}\n <div hidden={!!contentError}>\n <div className=\"ds-rte__toolbar\" role=\"toolbar\" aria-label={`${label} formatting`}>\n {GROUPS.map((group, i) => (\n <ButtonGroup key={i} aria-label={`Formatting ${i + 1}`}>\n {group.map((tool) => (\n <Button\n key={tool.id}\n size=\"sm\"\n isIconOnly\n iconStart={tool.icon}\n aria-label={tool.label}\n title={tool.label}\n aria-pressed={tool.active ? state?.active[tool.id] : undefined}\n variant={state?.active[tool.id] ? \"active\" : \"neutral\"}\n isDisabled={disabled || !editor}\n onClick={() => editor && tool.run(editor)}\n />\n ))}\n </ButtonGroup>\n ))}\n <ButtonGroup aria-label=\"Link\">\n <Button\n size=\"sm\"\n isIconOnly\n iconStart={state?.linkActive ? \"link-off\" : \"link\"}\n aria-label={state?.linkActive ? \"Remove link\" : \"Add link\"}\n title={state?.linkActive ? \"Remove link\" : \"Add link\"}\n variant={state?.linkActive ? \"active\" : \"neutral\"}\n isDisabled={disabled || !editor}\n onClick={toggleLink}\n />\n </ButtonGroup>\n {toolbarExtra}\n </div>\n <div className=\"ds-rte__content\" data-size={size}>\n <EditorContent editor={editor} />\n </div>\n </div>\n </div>\n );\n },\n);\n"],"mappings":";;;;;;;;;;AAMA,IAAaA,IAAkC;CAAE,MAAM;CAAO,SA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AAA,GAC3F,kBAAC,OAAD;GAAK,QAAQ,CAAC,CAACA;GAAf,UAAA,CACE,kBAAC,OAAD;IAAK,WAAU;IAAkB,MAAK;IAAU,cAAY,GAAGS,EAAM;IAArE,UAAA;KACGrB,EAAO,KAAK,GAAO,MAClB,kBAACoC,GAAD;MAAqB,cAAY,cAAcC,IAAI;MAChD,UAAAC,EAAM,KAAK,MACV,kBAACC,GAAD;OAEE,MAAK;OACL,YAAA;OACA,WAAWC,EAAK;OAChB,cAAYA,EAAK;OACjB,OAAOA,EAAK;OACZ,gBAAcA,EAAK,SAASV,GAAO,OAAOU,EAAK,MAAM,KAAA;OACrD,SAASV,GAAO,OAAOU,EAAK,MAAM,WAAW;OAC7C,YAAYtB,KAAY,CAACM;OACzB,eAAeA,KAAUgB,EAAK,IAAIhB,CAAM;MACzC,GAVMgB,EAAK,EAUX,CACF;KACU,GAfKH,CAeL,CACd;KACD,kBAACD,GAAD;MAAa,cAAW;MACtB,UAAA,kBAACG,GAAD;OACE,MAAK;OACL,YAAA;OACA,WAAWT,GAAO,aAAa,aAAa;OAC5C,cAAYA,GAAO,aAAa,gBAAgB;OAChD,OAAOA,GAAO,aAAa,gBAAgB;OAC3C,SAASA,GAAO,aAAa,WAAW;OACxC,YAAYZ,KAAY,CAACM;OACzB,SAASQ;MACV,CAAA;KACU,CAAA;KACZS;IACE;GACL,CAAA,GAAA,kBAAC,OAAD;IAAK,WAAU;IAAkB,aAAWC;IAC1C,UAAA,kBAACC,GAAD,EAAuB,UAAS,CAAA;GAC7B,CAAA,CACF;EACF,CAAA,CAAA;;AAET,CACF"}
@@ -1,2 +0,0 @@
1
- const e=require("../components/Button/index.cjs"),t=require("../components/ButtonGroup/index.cjs");;/* empty css */let n=require("react"),r=require("react/jsx-runtime"),i=require("@tiptap/react"),a=require("@tiptap/extension-placeholder"),o=require("@tiptap/starter-kit"),s=require("@tiptap/extension-link");var c={type:`doc`,content:[{type:`paragraph`}]};function l(){return[o.StarterKit.configure({link:!1}),s.Link.configure({openOnClick:!1,autolink:!0})]}var u=(0,i.getSchema)(l());function d(e){return e.content?.length?e:{...e,content:c.content}}function f(e){try{if(!e||typeof e!=`object`||!(`type`in e)||e.type!==`doc`)throw Error();let t=e=>{let n=u.nodes[e.type??``];if(!n||Object.keys(e).some(e=>![`type`,`attrs`,`content`,`marks`,`text`].includes(e))||e.text!==void 0&&e.type!==`text`||e.attrs&&Object.keys(e.attrs).some(e=>!Object.hasOwn(n.spec.attrs??{},e)))throw Error();for(let t of e.marks??[]){let e=u.marks[t.type];if(!e||Object.keys(t).some(e=>![`type`,`attrs`].includes(e))||Object.keys(t.attrs??{}).some(t=>!Object.hasOwn(e.spec.attrs??{},t)))throw Error()}e.content?.forEach(t)},n=e;t(n),u.nodeFromJSON(d(n)).check()}catch{return`Unsupported or invalid rich-text document.`}}var p=[[{id:`bold`,icon:`bold`,label:`Bold`,run:e=>e.chain().focus().toggleBold().run(),active:e=>e.isActive(`bold`)},{id:`italic`,icon:`italic`,label:`Italic`,run:e=>e.chain().focus().toggleItalic().run(),active:e=>e.isActive(`italic`)},{id:`strike`,icon:`strikethrough`,label:`Strikethrough`,run:e=>e.chain().focus().toggleStrike().run(),active:e=>e.isActive(`strike`)},{id:`code`,icon:`code`,label:`Inline code`,run:e=>e.chain().focus().toggleCode().run(),active:e=>e.isActive(`code`)}],[{id:`h2`,icon:`heading-2`,label:`Heading`,run:e=>e.chain().focus().toggleHeading({level:2}).run(),active:e=>e.isActive(`heading`,{level:2})},{id:`h3`,icon:`heading-3`,label:`Subheading`,run:e=>e.chain().focus().toggleHeading({level:3}).run(),active:e=>e.isActive(`heading`,{level:3})},{id:`quote`,icon:`quote`,label:`Quote`,run:e=>e.chain().focus().toggleBlockquote().run(),active:e=>e.isActive(`blockquote`)}],[{id:`ul`,icon:`list`,label:`Bulleted list`,run:e=>e.chain().focus().toggleBulletList().run(),active:e=>e.isActive(`bulletList`)},{id:`ol`,icon:`list-ordered`,label:`Numbered list`,run:e=>e.chain().focus().toggleOrderedList().run(),active:e=>e.isActive(`orderedList`)}],[{id:`undo`,icon:`undo`,label:`Undo`,run:e=>e.chain().focus().undo().run()},{id:`redo`,icon:`redo`,label:`Redo`,run:e=>e.chain().focus().redo().run()}]],m=(0,n.forwardRef)(function(o,s){let{placeholder:u=`Write something…`,size:m=`md`,isDisabled:h=!1,isInvalid:g=!1,label:_=`Rich text editor`,className:v,toolbarExtra:y,id:b,isRequired:x,"aria-labelledby":S,"aria-describedby":C,"aria-invalid":w}=o,[T,E]=(0,n.useState)(!1),[D]=(0,n.useState)(()=>o.defaultValue??(o.format===`json`?c:``)),O=o.value===void 0?D:o.value,k=(0,n.useMemo)(()=>o.format===`json`?f(O):void 0,[o.format,O]),A=(0,n.useId)(),j=g||!!k||w,M=h||!!k,N=(0,n.useMemo)(()=>({role:`textbox`,"aria-label":_,"aria-multiline":`true`,...b?{id:b}:{},...S?{"aria-labelledby":S}:{},...C?{"aria-describedby":C}:{},...j?{"aria-invalid":String(j)}:{},...x?{"aria-required":`true`}:{}}),[_,b,S,C,j,x]),P=(0,i.useEditor)({immediatelyRender:!1,editable:!M,content:k?c:typeof O==`string`?O:d(O),extensions:[...l(),a.Placeholder.configure({placeholder:u})],editorProps:{attributes:N},onFocus:()=>E(!0),onBlur:()=>E(!1),onUpdate:({editor:e})=>{M||(o.format===`json`?o.onChange?.(e.getJSON()):o.onChange?.(e.getHTML()))}});(0,n.useEffect)(()=>{P&&(P.setEditable(!M,!1),P.setOptions({editorProps:{attributes:N}}))},[P,M,N]),(0,n.useEffect)(()=>{if(!P||o.value===void 0||k)return;let e=typeof o.value==`string`?(0,i.createDocument)(o.value,P.schema):P.schema.nodeFromJSON(d(o.value));e.eq(P.state.doc)||P.commands.setContent(e,{emitUpdate:!1})},[P,o.value,k]);let F=(0,i.useEditorState)({editor:P,selector:({editor:e})=>e?{active:Object.fromEntries(p.flat().map(t=>[t.id,t.active?.(e)??!1])),linkActive:e.isActive(`link`)}:null}),I=(0,n.useCallback)(()=>{if(!P)return;if(P.isActive(`link`)){P.chain().focus().unsetLink().run();return}let e=window.prompt(`Link to`);e&&P.chain().focus().extendMarkRange(`link`).setLink({href:e}).run()},[P]);return(0,r.jsxs)(`div`,{ref:s,className:[`ds-rte`,v].filter(Boolean).join(` `),"data-focused":T||void 0,"data-disabled":M||void 0,"aria-invalid":j||void 0,children:[k&&(0,r.jsx)(`p`,{id:A,role:`alert`,className:`ds-field__error`,children:k}),(0,r.jsxs)(`div`,{hidden:!!k,children:[(0,r.jsxs)(`div`,{className:`ds-rte__toolbar`,role:`toolbar`,"aria-label":`${_} formatting`,children:[p.map((n,i)=>(0,r.jsx)(t.ButtonGroup,{"aria-label":`Formatting ${i+1}`,children:n.map(t=>(0,r.jsx)(e.Button,{size:`sm`,isIconOnly:!0,iconStart:t.icon,"aria-label":t.label,title:t.label,"aria-pressed":t.active?F?.active[t.id]:void 0,variant:F?.active[t.id]?`active`:`neutral`,isDisabled:M||!P,onClick:()=>P&&t.run(P)},t.id))},i)),(0,r.jsx)(t.ButtonGroup,{"aria-label":`Link`,children:(0,r.jsx)(e.Button,{size:`sm`,isIconOnly:!0,iconStart:F?.linkActive?`link-off`:`link`,"aria-label":F?.linkActive?`Remove link`:`Add link`,title:F?.linkActive?`Remove link`:`Add link`,variant:F?.linkActive?`active`:`neutral`,isDisabled:M||!P,onClick:I})}),y]}),(0,r.jsx)(`div`,{className:`ds-rte__content`,"data-size":m,children:(0,r.jsx)(i.EditorContent,{editor:P})})]})]})});Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return f}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return m}});
2
- //# sourceMappingURL=RichTextEditor-tFkISOvq.cjs.map