@techzyapp/ui-library 1.0.39 → 1.0.40

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 (125) hide show
  1. package/dist/{AdminRoot-B2lwjQig.cjs → AdminRoot-CRTBGUxq.cjs} +2 -2
  2. package/dist/{AdminRoot-B2lwjQig.cjs.map → AdminRoot-CRTBGUxq.cjs.map} +1 -1
  3. package/dist/{AdminRoot-BTPLhufU.js → AdminRoot-JOgiNkJA.js} +3 -3
  4. package/dist/{AdminRoot-BTPLhufU.js.map → AdminRoot-JOgiNkJA.js.map} +1 -1
  5. package/dist/{CodeBlock-BbIC5BRK.cjs → CodeBlock-C3mG_seZ.cjs} +2 -2
  6. package/dist/{CodeBlock-BbIC5BRK.cjs.map → CodeBlock-C3mG_seZ.cjs.map} +1 -1
  7. package/dist/{CodeBlock-C8A6E-tJ.js → CodeBlock-DrWRSRmO.js} +2 -2
  8. package/dist/{CodeBlock-C8A6E-tJ.js.map → CodeBlock-DrWRSRmO.js.map} +1 -1
  9. package/dist/{ColorRamp-B_-ZPqMa.cjs → ColorRamp-D9_5JULy.cjs} +2 -2
  10. package/dist/{ColorRamp-B_-ZPqMa.cjs.map → ColorRamp-D9_5JULy.cjs.map} +1 -1
  11. package/dist/{ColorRamp-CCfImssD.js → ColorRamp-Mp_ddhmb.js} +2 -2
  12. package/dist/{ColorRamp-CCfImssD.js.map → ColorRamp-Mp_ddhmb.js.map} +1 -1
  13. package/dist/{CopyButton-CUEEp_Na.cjs → CopyButton-DZeYcG68.cjs} +2 -2
  14. package/dist/CopyButton-DZeYcG68.cjs.map +1 -0
  15. package/dist/{CopyButton-BD5sN32G.js → CopyButton-Yg5ZVTiX.js} +2 -2
  16. package/dist/CopyButton-Yg5ZVTiX.js.map +1 -0
  17. package/dist/{DescriptionList-BD65gv7C.js → DescriptionList-CG08_qwT.js} +2 -2
  18. package/dist/{DescriptionList-BD65gv7C.js.map → DescriptionList-CG08_qwT.js.map} +1 -1
  19. package/dist/{DescriptionList-BlAJIabM.cjs → DescriptionList-S9C6Tp90.cjs} +2 -2
  20. package/dist/{DescriptionList-BlAJIabM.cjs.map → DescriptionList-S9C6Tp90.cjs.map} +1 -1
  21. package/dist/{ErrorBoundary-sQY2sFdu.js → ErrorBoundary-BILk_3fM.js} +2 -2
  22. package/dist/{ErrorBoundary-sQY2sFdu.js.map → ErrorBoundary-BILk_3fM.js.map} +1 -1
  23. package/dist/{ErrorBoundary-6HvsCoJ8.cjs → ErrorBoundary-JCNa0_Ys.cjs} +2 -2
  24. package/dist/{ErrorBoundary-6HvsCoJ8.cjs.map → ErrorBoundary-JCNa0_Ys.cjs.map} +1 -1
  25. package/dist/{ErrorState-DdxOeZy2.js → ErrorState-DI28ZCJN.js} +3 -3
  26. package/dist/{ErrorState-DdxOeZy2.js.map → ErrorState-DI28ZCJN.js.map} +1 -1
  27. package/dist/{ErrorState-To_MAOf4.cjs → ErrorState-MQBeyF2n.cjs} +2 -2
  28. package/dist/{ErrorState-To_MAOf4.cjs.map → ErrorState-MQBeyF2n.cjs.map} +1 -1
  29. package/dist/{FileUploader-CWH-RS-z.js → FileUploader-DwAl3UXI.js} +2 -2
  30. package/dist/{FileUploader-CWH-RS-z.js.map → FileUploader-DwAl3UXI.js.map} +1 -1
  31. package/dist/{FileUploader-H4k4Cm5B.cjs → FileUploader-FMVbj7rz.cjs} +2 -2
  32. package/dist/{FileUploader-H4k4Cm5B.cjs.map → FileUploader-FMVbj7rz.cjs.map} +1 -1
  33. package/dist/{LocationPicker-CHGJkMXl.js → LocationPicker-Ce8aLubZ.js} +3 -3
  34. package/dist/{LocationPicker-CHGJkMXl.js.map → LocationPicker-Ce8aLubZ.js.map} +1 -1
  35. package/dist/{LocationPicker-CgzZnTFE.cjs → LocationPicker-D-sT4rSe.cjs} +2 -2
  36. package/dist/{LocationPicker-CgzZnTFE.cjs.map → LocationPicker-D-sT4rSe.cjs.map} +1 -1
  37. package/dist/Modal-DTnB_mGg.js +206 -0
  38. package/dist/Modal-DTnB_mGg.js.map +1 -0
  39. package/dist/Modal-DjSOhZqd.cjs +2 -0
  40. package/dist/Modal-DjSOhZqd.cjs.map +1 -0
  41. package/dist/{PageError-9tfvBssn.js → PageError-BORFaxGW.js} +2 -2
  42. package/dist/{PageError-9tfvBssn.js.map → PageError-BORFaxGW.js.map} +1 -1
  43. package/dist/{PageError-CJHOUfCa.cjs → PageError-aUV0vUfB.cjs} +2 -2
  44. package/dist/{PageError-CJHOUfCa.cjs.map → PageError-aUV0vUfB.cjs.map} +1 -1
  45. package/dist/{PaletteField-AMZpUMID.js → PaletteField-ChG2VQtS.js} +2 -2
  46. package/dist/{PaletteField-AMZpUMID.js.map → PaletteField-ChG2VQtS.js.map} +1 -1
  47. package/dist/{PaletteField-ClCvXFdN.cjs → PaletteField-DQ1OvXqe.cjs} +2 -2
  48. package/dist/{PaletteField-ClCvXFdN.cjs.map → PaletteField-DQ1OvXqe.cjs.map} +1 -1
  49. package/dist/{RemoveDialog-yEZm6JaC.cjs → RemoveDialog-B_Y18MeJ.cjs} +2 -2
  50. package/dist/{RemoveDialog-yEZm6JaC.cjs.map → RemoveDialog-B_Y18MeJ.cjs.map} +1 -1
  51. package/dist/{RemoveDialog-BfPTOs1y.js → RemoveDialog-ayAfGXpB.js} +2 -2
  52. package/dist/{RemoveDialog-BfPTOs1y.js.map → RemoveDialog-ayAfGXpB.js.map} +1 -1
  53. package/dist/{RichTextEditor-CitILCiw.cjs → RichTextEditor-DSvSaszc.cjs} +2 -2
  54. package/dist/{RichTextEditor-CitILCiw.cjs.map → RichTextEditor-DSvSaszc.cjs.map} +1 -1
  55. package/dist/{RichTextEditor-CgItVhAR.js → RichTextEditor-itYD1PfE.js} +2 -2
  56. package/dist/{RichTextEditor-CgItVhAR.js.map → RichTextEditor-itYD1PfE.js.map} +1 -1
  57. package/dist/{RootLayout-CVYEk7Wi.js → RootLayout-BlYjYAYk.js} +3 -3
  58. package/dist/{RootLayout-CVYEk7Wi.js.map → RootLayout-BlYjYAYk.js.map} +1 -1
  59. package/dist/{RootLayout-DJ2Xv35m.cjs → RootLayout-D5nlzYlH.cjs} +2 -2
  60. package/dist/{RootLayout-DJ2Xv35m.cjs.map → RootLayout-D5nlzYlH.cjs.map} +1 -1
  61. package/dist/{SpeedDial-C2hkC_8p.js → SpeedDial-CEBAWIYo.js} +2 -2
  62. package/dist/{SpeedDial-C2hkC_8p.js.map → SpeedDial-CEBAWIYo.js.map} +1 -1
  63. package/dist/{SpeedDial-DRSIilyC.cjs → SpeedDial-D6me6w_m.cjs} +2 -2
  64. package/dist/{SpeedDial-DRSIilyC.cjs.map → SpeedDial-D6me6w_m.cjs.map} +1 -1
  65. package/dist/{Table-DDPzTA1H.cjs → Table-CFl3OYlo.cjs} +2 -2
  66. package/dist/{Table-DDPzTA1H.cjs.map → Table-CFl3OYlo.cjs.map} +1 -1
  67. package/dist/{Table-AXMp0eiw.js → Table-DChIfjqj.js} +2 -2
  68. package/dist/{Table-AXMp0eiw.js.map → Table-DChIfjqj.js.map} +1 -1
  69. package/dist/Tooltip-BbT0uNzy.js +152 -0
  70. package/dist/Tooltip-BbT0uNzy.js.map +1 -0
  71. package/dist/Tooltip-DmMq5R1x.cjs +2 -0
  72. package/dist/Tooltip-DmMq5R1x.cjs.map +1 -0
  73. package/dist/components/CodeBlock/index.cjs +1 -1
  74. package/dist/components/CodeBlock/index.js +1 -1
  75. package/dist/components/ColorRamp/index.cjs +1 -1
  76. package/dist/components/ColorRamp/index.js +1 -1
  77. package/dist/components/CopyButton/CopyButton.d.cts +1 -1
  78. package/dist/components/CopyButton/CopyButton.d.ts +1 -1
  79. package/dist/components/CopyButton/index.cjs +1 -1
  80. package/dist/components/CopyButton/index.js +1 -1
  81. package/dist/components/DescriptionList/index.cjs +1 -1
  82. package/dist/components/DescriptionList/index.js +1 -1
  83. package/dist/components/ErrorState/index.cjs +1 -1
  84. package/dist/components/ErrorState/index.js +2 -2
  85. package/dist/components/FileUploader/index.cjs +1 -1
  86. package/dist/components/FileUploader/index.js +1 -1
  87. package/dist/components/LocationPicker/index.cjs +1 -1
  88. package/dist/components/LocationPicker/index.js +1 -1
  89. package/dist/components/Modal/index.cjs +1 -1
  90. package/dist/components/Modal/index.js +1 -1
  91. package/dist/components/PageError/index.cjs +1 -1
  92. package/dist/components/PageError/index.js +1 -1
  93. package/dist/components/PaletteField/index.cjs +1 -1
  94. package/dist/components/PaletteField/index.js +1 -1
  95. package/dist/components/RemoveDialog/index.cjs +1 -1
  96. package/dist/components/RemoveDialog/index.js +1 -1
  97. package/dist/components/RichTextEditor/index.cjs +1 -1
  98. package/dist/components/RichTextEditor/index.js +1 -1
  99. package/dist/components/RootLayout/index.cjs +1 -1
  100. package/dist/components/RootLayout/index.js +1 -1
  101. package/dist/components/SpeedDial/index.cjs +1 -1
  102. package/dist/components/SpeedDial/index.js +1 -1
  103. package/dist/components/Table/index.cjs +1 -1
  104. package/dist/components/Table/index.js +1 -1
  105. package/dist/components/Tooltip/Tooltip.d.cts +5 -3
  106. package/dist/components/Tooltip/Tooltip.d.ts +5 -3
  107. package/dist/components/Tooltip/index.cjs +1 -1
  108. package/dist/components/Tooltip/index.js +1 -1
  109. package/dist/entries/app.cjs +1 -1
  110. package/dist/entries/app.js +1 -1
  111. package/dist/entries/components.cjs +1 -1
  112. package/dist/entries/components.js +17 -17
  113. package/dist/index.cjs +1 -1
  114. package/dist/index.js +18 -18
  115. package/package.json +1 -1
  116. package/dist/CopyButton-BD5sN32G.js.map +0 -1
  117. package/dist/CopyButton-CUEEp_Na.cjs.map +0 -1
  118. package/dist/Modal-BkO_6afj.js +0 -195
  119. package/dist/Modal-BkO_6afj.js.map +0 -1
  120. package/dist/Modal-D8V-JZBg.cjs +0 -2
  121. package/dist/Modal-D8V-JZBg.cjs.map +0 -1
  122. package/dist/Tooltip-Bw-1Xk2Z.cjs +0 -2
  123. package/dist/Tooltip-Bw-1Xk2Z.cjs.map +0 -1
  124. package/dist/Tooltip-DsDv4NOq.js +0 -135
  125. package/dist/Tooltip-DsDv4NOq.js.map +0 -1
@@ -4,7 +4,7 @@ import { B as O } from "./Blockquote-Ma-2naET.js";
4
4
  import { B as v } from "./Button-Bst_NtPJ.js";
5
5
  import { C as S } from "./Code-DaEpXHfF.js";
6
6
  import { b as B } from "./Icon-D5TxgfCc.js";
7
- import { M as j } from "./Modal-BkO_6afj.js";
7
+ import { M as j } from "./Modal-DTnB_mGg.js";
8
8
  import { T as F } from "./TextField-0gFvIFs8.js";
9
9
  import { T as L } from "./Typography-ChSuxgkc.js";
10
10
  import { a as k } from "./ConfigProvider-DeMASTVo.js";
@@ -106,4 +106,4 @@ function H({ text: u }) {
106
106
  export {
107
107
  eo as R
108
108
  };
109
- //# sourceMappingURL=RemoveDialog-BfPTOs1y.js.map
109
+ //# sourceMappingURL=RemoveDialog-ayAfGXpB.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"RemoveDialog-BfPTOs1y.js","sources":["../src/components/RemoveDialog/RemoveDialog.tsx"],"sourcesContent":["import { forwardRef, useId, useRef, useState, type KeyboardEvent, type ReactNode } from 'react'\nimport { useT } from '../../theme'\nimport { Blockquote } from '../Blockquote'\nimport { Button } from '../Button'\nimport { Code } from '../Code'\nimport { Icon } from '../Icon'\nimport { Modal } from '../Modal'\nimport { TextField } from '../TextField'\nimport { Typography } from '../Typography'\nimport styles from './RemoveDialog.module.css'\n\nexport interface RemoveDialogProps {\n /** Whether the dialog is open. */\n open: boolean\n /** Called on Cancel, the × button, backdrop, or Escape (ignored while a confirm is in flight). */\n onClose: () => void\n /**\n * The destructive action. May be async — while its promise is pending the Delete button shows a\n * loader and the dialog locks (no dismiss); on success the dialog **auto-closes**, on rejection it\n * stays open so the user can retry (surface the error yourself, e.g. a toast).\n */\n onConfirm: () => void | Promise<void>\n /** Header title. Defaults to `\"Remove\"`. */\n title?: ReactNode\n /** Body prompt shown under the icon. Defaults to `\"Are you sure you want to delete?\"`. */\n message?: ReactNode\n /** Confirm (destructive) button label. Defaults to `\"Delete\"`. */\n confirmLabel?: string\n /** Cancel button label. Defaults to `\"Cancel\"`. */\n cancelLabel?: string\n /** External loading override — combined with the internal async-confirm state. */\n loading?: boolean\n /**\n * **Type-to-confirm** for high-risk deletes: the user must type this exact text (e.g. `\"remove user\"`)\n * into a field before Delete enables. Case-sensitive; surrounding whitespace is ignored. The field is\n * focused on open, cleared on every open, and Enter confirms once it matches.\n */\n confirmText?: string\n}\n\n/**\n * A ready-made delete confirmation — a thin convenience wrapper over `Modal` for the ubiquitous\n * \"Are you sure you want to delete?\" prompt. Hardcodes the destructive flavor (a `Trash` glyph in a\n * soft error circle + an `error` Delete button); just wire `open` / `onClose` / `onConfirm`. An async\n * `onConfirm` drives the button loader and locks dismissal, then auto-closes on success. `confirmText`\n * adds **type-to-confirm**: Delete stays disabled until the user types that exact text. Built on\n * `Modal`, so it inherits the portal, scroll-lock, focus-trap, and backdrop/Escape dismissal.\n *\n * @example\n * const { isOpen, open, close } = useDisclosure()\n * <RemoveDialog open={isOpen} onClose={close} onConfirm={() => deleteItem(id)} />\n */\nexport const RemoveDialog = forwardRef<HTMLDivElement, RemoveDialogProps>(function RemoveDialog(\n {\n open,\n onClose,\n onConfirm,\n title,\n message,\n confirmLabel,\n cancelLabel,\n loading = false,\n confirmText,\n },\n ref,\n) {\n const t = useT()\n const [submitting, setSubmitting] = useState(false)\n const busy = loading || submitting\n\n // type-to-confirm — cleared every time the dialog opens (\"adjust state on prop change\", no effect)\n const [typed, setTyped] = useState('')\n const wasOpen = useRef(open)\n if (wasOpen.current !== open) {\n wasOpen.current = open\n if (open) setTyped('')\n }\n const matches = confirmText == null || typed.trim() === confirmText.trim()\n const promptId = useId()\n\n // dismissal is blocked while the confirm is running (so the delete can't be abandoned mid-flight)\n const handleClose = () => {\n if (!busy) onClose()\n }\n\n const handleConfirm = async () => {\n if (!matches || busy) return\n try {\n setSubmitting(true)\n await onConfirm()\n onClose() // auto-close on success\n } catch {\n // keep the dialog open on failure so the user can retry; the consumer surfaces the error\n } finally {\n setSubmitting(false)\n }\n }\n\n return (\n <Modal\n ref={ref}\n open={open}\n onClose={handleClose}\n size=\"sm\"\n bodyClassName={styles.modalBody}\n title={title ?? t('removeDialog.title')}\n showCloseButton={!busy}\n closeOnBackdrop={!busy}\n closeOnEscape={!busy}\n footer={\n <>\n <Button variant=\"text\" size=\"sm\" onClick={handleClose} disabled={busy}>\n {cancelLabel ?? t('common.cancel')}\n </Button>\n <Button\n color=\"error\"\n variant=\"filled\"\n size=\"sm\"\n onClick={handleConfirm}\n loading={busy}\n disabled={!matches}\n >\n {confirmLabel ?? t('common.delete')}\n </Button>\n </>\n }\n >\n <div className={styles.body}>\n <div className={styles.iconBox} aria-hidden>\n <Icon name=\"Trash\" />\n </div>\n <Typography align=\"center\">{message ?? t('removeDialog.message')}</Typography>\n {confirmText != null && (\n <div className={styles.confirm}>\n {/* the instruction, as an error-tinted quote — it also names the field (aria-labelledby) */}\n <Blockquote id={promptId} size=\"sm\" color=\"error\">\n <TypeToConfirmLabel text={confirmText} />\n </Blockquote>\n <TextField\n aria-labelledby={promptId}\n placeholder={confirmText}\n value={typed}\n onChange={(event) => setTyped(event.target.value)}\n onKeyDown={(event: KeyboardEvent<HTMLInputElement>) => {\n if (event.key === 'Enter') {\n event.preventDefault()\n void handleConfirm()\n }\n }}\n // a green tick once the phrase matches — the field confirms itself before Delete does\n adornment={typed && matches ? <Icon name=\"TickCircle\" color=\"success\" /> : undefined}\n adornmentPosition=\"right\"\n disabled={busy}\n size=\"sm\"\n autoComplete=\"off\"\n autoCapitalize=\"off\"\n autoCorrect=\"off\"\n spellCheck={false}\n />\n </div>\n )}\n </div>\n </Modal>\n )\n})\n\n/** \"Type {text} to confirm\" with the text set as inline `Code`, so the exact phrase stands out. */\nfunction TypeToConfirmLabel({ text }: { text: string }) {\n const t = useT()\n // translate with a sentinel in place of {text}, then split around it to slot the Code element in\n const SENTINEL = '\\u0000'\n const [before, after = ''] = t('removeDialog.typeToConfirm', { text: SENTINEL }).split(SENTINEL)\n return (\n <>\n {before}\n <Code size=\"sm\" color=\"error\" className={styles.phrase}>\n {text}\n </Code>\n {after}\n </>\n )\n}\n"],"names":["RemoveDialog","forwardRef","open","onClose","onConfirm","title","message","confirmLabel","cancelLabel","loading","confirmText","ref","t","useT","submitting","setSubmitting","useState","busy","typed","setTyped","wasOpen","useRef","matches","promptId","useId","handleClose","handleConfirm","jsx","Modal","styles","jsxs","Fragment","Button","Icon","Typography","Blockquote","TypeToConfirmLabel","TextField","event","text","SENTINEL","before","after","Code"],"mappings":"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"}
1
+ {"version":3,"file":"RemoveDialog-ayAfGXpB.js","sources":["../src/components/RemoveDialog/RemoveDialog.tsx"],"sourcesContent":["import { forwardRef, useId, useRef, useState, type KeyboardEvent, type ReactNode } from 'react'\nimport { useT } from '../../theme'\nimport { Blockquote } from '../Blockquote'\nimport { Button } from '../Button'\nimport { Code } from '../Code'\nimport { Icon } from '../Icon'\nimport { Modal } from '../Modal'\nimport { TextField } from '../TextField'\nimport { Typography } from '../Typography'\nimport styles from './RemoveDialog.module.css'\n\nexport interface RemoveDialogProps {\n /** Whether the dialog is open. */\n open: boolean\n /** Called on Cancel, the × button, backdrop, or Escape (ignored while a confirm is in flight). */\n onClose: () => void\n /**\n * The destructive action. May be async — while its promise is pending the Delete button shows a\n * loader and the dialog locks (no dismiss); on success the dialog **auto-closes**, on rejection it\n * stays open so the user can retry (surface the error yourself, e.g. a toast).\n */\n onConfirm: () => void | Promise<void>\n /** Header title. Defaults to `\"Remove\"`. */\n title?: ReactNode\n /** Body prompt shown under the icon. Defaults to `\"Are you sure you want to delete?\"`. */\n message?: ReactNode\n /** Confirm (destructive) button label. Defaults to `\"Delete\"`. */\n confirmLabel?: string\n /** Cancel button label. Defaults to `\"Cancel\"`. */\n cancelLabel?: string\n /** External loading override — combined with the internal async-confirm state. */\n loading?: boolean\n /**\n * **Type-to-confirm** for high-risk deletes: the user must type this exact text (e.g. `\"remove user\"`)\n * into a field before Delete enables. Case-sensitive; surrounding whitespace is ignored. The field is\n * focused on open, cleared on every open, and Enter confirms once it matches.\n */\n confirmText?: string\n}\n\n/**\n * A ready-made delete confirmation — a thin convenience wrapper over `Modal` for the ubiquitous\n * \"Are you sure you want to delete?\" prompt. Hardcodes the destructive flavor (a `Trash` glyph in a\n * soft error circle + an `error` Delete button); just wire `open` / `onClose` / `onConfirm`. An async\n * `onConfirm` drives the button loader and locks dismissal, then auto-closes on success. `confirmText`\n * adds **type-to-confirm**: Delete stays disabled until the user types that exact text. Built on\n * `Modal`, so it inherits the portal, scroll-lock, focus-trap, and backdrop/Escape dismissal.\n *\n * @example\n * const { isOpen, open, close } = useDisclosure()\n * <RemoveDialog open={isOpen} onClose={close} onConfirm={() => deleteItem(id)} />\n */\nexport const RemoveDialog = forwardRef<HTMLDivElement, RemoveDialogProps>(function RemoveDialog(\n {\n open,\n onClose,\n onConfirm,\n title,\n message,\n confirmLabel,\n cancelLabel,\n loading = false,\n confirmText,\n },\n ref,\n) {\n const t = useT()\n const [submitting, setSubmitting] = useState(false)\n const busy = loading || submitting\n\n // type-to-confirm — cleared every time the dialog opens (\"adjust state on prop change\", no effect)\n const [typed, setTyped] = useState('')\n const wasOpen = useRef(open)\n if (wasOpen.current !== open) {\n wasOpen.current = open\n if (open) setTyped('')\n }\n const matches = confirmText == null || typed.trim() === confirmText.trim()\n const promptId = useId()\n\n // dismissal is blocked while the confirm is running (so the delete can't be abandoned mid-flight)\n const handleClose = () => {\n if (!busy) onClose()\n }\n\n const handleConfirm = async () => {\n if (!matches || busy) return\n try {\n setSubmitting(true)\n await onConfirm()\n onClose() // auto-close on success\n } catch {\n // keep the dialog open on failure so the user can retry; the consumer surfaces the error\n } finally {\n setSubmitting(false)\n }\n }\n\n return (\n <Modal\n ref={ref}\n open={open}\n onClose={handleClose}\n size=\"sm\"\n bodyClassName={styles.modalBody}\n title={title ?? t('removeDialog.title')}\n showCloseButton={!busy}\n closeOnBackdrop={!busy}\n closeOnEscape={!busy}\n footer={\n <>\n <Button variant=\"text\" size=\"sm\" onClick={handleClose} disabled={busy}>\n {cancelLabel ?? t('common.cancel')}\n </Button>\n <Button\n color=\"error\"\n variant=\"filled\"\n size=\"sm\"\n onClick={handleConfirm}\n loading={busy}\n disabled={!matches}\n >\n {confirmLabel ?? t('common.delete')}\n </Button>\n </>\n }\n >\n <div className={styles.body}>\n <div className={styles.iconBox} aria-hidden>\n <Icon name=\"Trash\" />\n </div>\n <Typography align=\"center\">{message ?? t('removeDialog.message')}</Typography>\n {confirmText != null && (\n <div className={styles.confirm}>\n {/* the instruction, as an error-tinted quote — it also names the field (aria-labelledby) */}\n <Blockquote id={promptId} size=\"sm\" color=\"error\">\n <TypeToConfirmLabel text={confirmText} />\n </Blockquote>\n <TextField\n aria-labelledby={promptId}\n placeholder={confirmText}\n value={typed}\n onChange={(event) => setTyped(event.target.value)}\n onKeyDown={(event: KeyboardEvent<HTMLInputElement>) => {\n if (event.key === 'Enter') {\n event.preventDefault()\n void handleConfirm()\n }\n }}\n // a green tick once the phrase matches — the field confirms itself before Delete does\n adornment={typed && matches ? <Icon name=\"TickCircle\" color=\"success\" /> : undefined}\n adornmentPosition=\"right\"\n disabled={busy}\n size=\"sm\"\n autoComplete=\"off\"\n autoCapitalize=\"off\"\n autoCorrect=\"off\"\n spellCheck={false}\n />\n </div>\n )}\n </div>\n </Modal>\n )\n})\n\n/** \"Type {text} to confirm\" with the text set as inline `Code`, so the exact phrase stands out. */\nfunction TypeToConfirmLabel({ text }: { text: string }) {\n const t = useT()\n // translate with a sentinel in place of {text}, then split around it to slot the Code element in\n const SENTINEL = '\\u0000'\n const [before, after = ''] = t('removeDialog.typeToConfirm', { text: SENTINEL }).split(SENTINEL)\n return (\n <>\n {before}\n <Code size=\"sm\" color=\"error\" className={styles.phrase}>\n {text}\n </Code>\n {after}\n </>\n )\n}\n"],"names":["RemoveDialog","forwardRef","open","onClose","onConfirm","title","message","confirmLabel","cancelLabel","loading","confirmText","ref","t","useT","submitting","setSubmitting","useState","busy","typed","setTyped","wasOpen","useRef","matches","promptId","useId","handleClose","handleConfirm","jsx","Modal","styles","jsxs","Fragment","Button","Icon","Typography","Blockquote","TypeToConfirmLabel","TextField","event","text","SENTINEL","before","after","Code"],"mappings":"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"}
@@ -1,2 +1,2 @@
1
- "use strict";const r=require("react/jsx-runtime"),u=require("react"),Be=require("clsx"),a=require("lexical"),Ue=require("@lexical/react/LexicalComposer"),Ee=require("@lexical/react/LexicalComposerContext"),Fe=require("@lexical/react/LexicalRichTextPlugin"),Pe=require("@lexical/react/LexicalContentEditable"),He=require("@lexical/react/LexicalErrorBoundary"),Ve=require("@lexical/react/LexicalHistoryPlugin"),ze=require("@lexical/react/LexicalListPlugin"),Ge=require("@lexical/react/LexicalCheckListPlugin"),We=require("@lexical/react/LexicalLinkPlugin"),Ke=require("@lexical/react/LexicalMarkdownShortcutPlugin"),se=require("@lexical/markdown"),w=require("@lexical/rich-text"),I=require("@lexical/list"),F=require("@lexical/link"),ve=require("@lexical/html"),Je=require("./formContext-bTWrqdEV.cjs"),je=require("./Typography-d97DdbNd.cjs"),Qe=require("./toastStore-B4Tk2Xk7.cjs"),M=require("@lexical/selection"),D=require("@lexical/utils"),K=require("./Button-CYZoF18-.cjs"),ye=require("./ColorPickerPanel-BbgujQ3X.cjs"),$=require("./Divider-CzbhdCiD.cjs"),ce=require("./Dropdown-DYYhzKSo.cjs"),Xe=require("./FloatingPanel-tGCG2nhA.cjs"),g=require("./Icon-B6lz-V0A.cjs"),q=require("./IconButton-CQ25TtBc.cjs"),J=require("./ListItem-Qo1Tt6Fi.cjs"),Ye=require("./Modal-D8V-JZBg.cjs"),Ze=require("./TextField-BL6OAJcP.cjs"),ue=require("./ConfigProvider-B_Bb6pk1.cjs"),et=/^(?:https?:|mailto:|tel:|ftp:|#|\/|\?|\.)/i,tt=/^[a-z][a-z0-9+.-]*:/i;function de(o){const e=o.trim();return e===""?"":et.test(e)||!tt.test(e)?e:"#"}function Le(o){const e=o.trim();if(/^data:(?:image|video)\//i.test(e)||/^blob:/i.test(e))return e;const i=de(e);return i==="#"?"":i}function rt(o){return o instanceof HTMLImageElement&&o.src?{node:Q(o.getAttribute("src")??o.src,o.alt)}:null}class X extends a.DecoratorNode{static getType(){return"tz-image"}static clone(e){return new X(e.__src,e.__alt,e.__key)}constructor(e,i="",n){super(n),this.__src=Le(e),this.__alt=i}static importJSON(e){return Q(e.src,e.alt)}exportJSON(){return{...super.exportJSON(),type:"tz-image",version:1,src:this.__src,alt:this.__alt}}static importDOM(){return{img:()=>({conversion:rt,priority:0})}}exportDOM(){const e=document.createElement("img");return e.setAttribute("src",this.__src),e.setAttribute("alt",this.__alt),{element:e}}createDOM(){const e=document.createElement("div");return e.style.display="contents",e}updateDOM(){return!1}getSrc(){return this.__src}getAltText(){return this.__alt}decorate(){return r.jsx("img",{src:this.__src,alt:this.__alt,draggable:!1})}}function Q(o,e=""){return a.$applyNodeReplacement(new X(o,e))}function Se(o){return/\.(mp4|webm|ogg|ogv|mov|m4v)(\?.*)?$/i.test(o)}function nt(o){const e=o.match(/(?:youtube\.com\/(?:watch\?(?:.*&)?v=|embed\/|shorts\/)|youtu\.be\/)([\w-]{11})/);if(e)return`https://www.youtube.com/embed/${e[1]}`;const i=o.match(/vimeo\.com\/(?:video\/)?(\d+)/);return i?`https://player.vimeo.com/video/${i[1]}`:o}function Ne(o){var i;const e=o.getAttribute("src")||((i=o.querySelector("source"))==null?void 0:i.getAttribute("src"));return e?{node:me(e)}:null}class Y extends a.DecoratorNode{static getType(){return"tz-video"}static clone(e){return new Y(e.__src,e.__key)}constructor(e,i){super(i),this.__src=Le(e)}static importJSON(e){return me(e.src)}exportJSON(){return{...super.exportJSON(),type:"tz-video",version:1,src:this.__src}}static importDOM(){return{iframe:()=>({conversion:Ne,priority:0}),video:()=>({conversion:Ne,priority:0})}}exportDOM(){if(Se(this.__src)){const i=document.createElement("video");return i.setAttribute("src",this.__src),i.setAttribute("controls","true"),{element:i}}const e=document.createElement("iframe");return e.setAttribute("src",this.__src),e.setAttribute("frameborder","0"),e.setAttribute("allowfullscreen","true"),e.setAttribute("allow","accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"),{element:e}}createDOM(){const e=document.createElement("div");return e.style.display="contents",e}updateDOM(){return!1}getSrc(){return this.__src}decorate(){return Se(this.__src)?r.jsx("video",{src:this.__src,controls:!0}):r.jsx(ot,{src:this.__src})}}function ot({src:o}){const e=ue.useT();return r.jsx("div",{className:"tz-rte-embed",children:r.jsx("iframe",{src:o,title:e("rte.embeddedVideo"),frameBorder:0,allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})})}function me(o){return a.$applyNodeReplacement(new Y(nt(o)))}const it="_editor_16j1l_1",lt="_label_16j1l_9",st="_required_16j1l_15",ct="_helper_16j1l_18",at="_control_16j1l_24",ut="_error_16j1l_38",dt="_disabled_16j1l_45",mt="_toolbar_16j1l_51",pt="_sm_16j1l_67",ht="_md_16j1l_71",_t="_lg_16j1l_75",ft="_colorGlyph_16j1l_81",xt="_colorBar_16j1l_89",gt="_shell_16j1l_107",jt="_content_16j1l_110",yt="_placeholder_16j1l_123",St="_paragraph_16j1l_146",Nt="_h1_16j1l_152",Tt="_h2_16j1l_153",Ct="_h3_16j1l_154",Et="_h4_16j1l_155",vt="_h5_16j1l_156",Lt="_h6_16j1l_157",bt="_quote_16j1l_176",kt="_ul_16j1l_183",Rt="_ol_16j1l_188",Mt="_li_16j1l_193",It="_nestedLi_16j1l_196",Ot="_liChecked_16j1l_200",At="_liUnchecked_16j1l_201",Dt="_link_16j1l_238",$t="_bold_16j1l_245",qt="_italic_16j1l_248",wt="_underline_16j1l_251",Bt="_strike_16j1l_254",Ut="_codeInline_16j1l_260",s={editor:it,label:lt,required:st,helper:ct,control:at,error:ut,disabled:dt,toolbar:mt,sm:pt,md:ht,lg:_t,colorGlyph:ft,colorBar:xt,shell:gt,content:jt,placeholder:yt,paragraph:St,h1:Nt,h2:Tt,h3:Ct,h4:Et,h5:vt,h6:Lt,quote:bt,ul:kt,ol:Rt,li:Mt,nestedLi:It,liChecked:Ot,liUnchecked:At,link:Dt,bold:$t,italic:qt,underline:wt,strike:Bt,codeInline:Ut},Ft={paragraph:"Paragraph",h1:"Heading 1",h2:"Heading 2",h3:"Heading 3",quote:"Quote",bullet:"Bullet List",number:"Numbered List",check:"Check List"},Pt=[{type:"paragraph",icon:"Text"},{type:"h1",icon:"Hashtag"},{type:"h2",icon:"Hashtag"},{type:"h3",icon:"Hashtag"}],Ht=[{value:"left",labelKey:"rte.alignLeft",icon:"TextalignLeft"},{value:"center",labelKey:"rte.alignCenter",icon:"TextalignCenter"},{value:"right",labelKey:"rte.alignRight",icon:"TextalignRight"}],Vt=["10px","12px","14px","16px","18px","20px"],zt={sm:"12px",md:"14px",lg:"16px"};function Gt({color:o,size:e}){return r.jsxs("span",{className:s.colorGlyph,children:[r.jsx(g.Icon,{name:"Brush",size:e}),r.jsx("span",{className:s.colorBar,style:{borderColor:`transparent transparent ${o||"currentColor"} transparent`},"aria-hidden":"true"})]})}function Wt({size:o,disabled:e,onImageUpload:i}){const n=ue.useT(),p=t=>Ft[t]??t,[l]=Ee.useLexicalComposerContext(),m=u.useRef(null),[j,d]=u.useState(!1),[_,N]=u.useState(!1),[f,x]=u.useState(!1),[y,C]=u.useState(!1),[Z,ee]=u.useState(""),[v,O]=u.useState("paragraph"),[te,E]=u.useState("left"),[T,A]=u.useState(""),[B,P]=u.useState(""),[H,V]=u.useState(!1),U=u.useRef(null),[z,re]=u.useState(!1),[S,be]=u.useState(!1),[h,ne]=u.useState(null),[pe,he]=u.useState(""),oe=u.useCallback(()=>{const t=a.$getSelection();if(!a.$isRangeSelection(t))return;d(t.hasFormat("bold")),N(t.hasFormat("italic")),x(t.hasFormat("underline")),P(M.$getSelectionStyleValueForProperty(t,"color","")),A(M.$getSelectionStyleValueForProperty(t,"font-size",""));const c=t.anchor.getNode(),k=c.getParent(),b=F.$isLinkNode(c)?c:F.$isLinkNode(k)?k:null;C(b!==null),ee((b==null?void 0:b.getURL())??"");const R=c.getKey()==="root"?c:D.$findMatchingParent(c,we=>{const ge=we.getParent();return ge===null||ge.getKey()==="root"})??c.getTopLevelElement();E(a.$isElementNode(R)&&R.getFormatType()||"left");const W=D.$getNearestNodeOfType(c,I.ListNode);W?O(W.getListType()):w.$isHeadingNode(R)?O(R.getTag()):w.$isQuoteNode(R)?O("quote"):O("paragraph")},[]);u.useEffect(()=>D.mergeRegister(l.registerUpdateListener(({editorState:t})=>t.read(oe)),l.registerCommand(a.SELECTION_CHANGE_COMMAND,()=>(oe(),!1),a.COMMAND_PRIORITY_LOW),l.registerCommand(a.CAN_UNDO_COMMAND,t=>(re(t),!1),a.COMMAND_PRIORITY_LOW),l.registerCommand(a.CAN_REDO_COMMAND,t=>(be(t),!1),a.COMMAND_PRIORITY_LOW)),[l,oe]);const ie=t=>l.dispatchCommand(a.FORMAT_TEXT_COMMAND,t),ke=t=>l.dispatchCommand(a.FORMAT_ELEMENT_COMMAND,t),Re=t=>{P(t),l.update(()=>{const c=a.$getSelection();a.$isRangeSelection(c)&&M.$patchStyleText(c,{color:t||null})})},Me=t=>{A(t),l.update(()=>{const c=a.$getSelection();a.$isRangeSelection(c)&&M.$patchStyleText(c,{"font-size":t||null})})},G=t=>{if(t==="bullet"||t==="number"||t==="check"){if(v===t)l.dispatchCommand(I.REMOVE_LIST_COMMAND,void 0);else{const c=t==="bullet"?I.INSERT_UNORDERED_LIST_COMMAND:t==="number"?I.INSERT_ORDERED_LIST_COMMAND:I.INSERT_CHECK_LIST_COMMAND;l.dispatchCommand(c,void 0)}return}l.update(()=>{const c=a.$getSelection();a.$isRangeSelection(c)&&(t==="paragraph"?M.$setBlocksType(c,()=>a.$createParagraphNode()):t==="quote"?M.$setBlocksType(c,()=>w.$createQuoteNode()):M.$setBlocksType(c,()=>w.$createHeadingNode(t)))})},Ie=()=>G(v==="quote"?"paragraph":"quote"),le=(t,c="")=>{he(c),ne(t)},_e=()=>ne(null),Oe=()=>{h==null||h.onConfirm(pe.trim()),ne(null)},Ae=()=>le({icon:"Link2",title:n("rte.linkTitle"),label:n("rte.linkUrl"),placeholder:"https://example.com",confirmLabel:n(y?"common.update":"common.insert"),onConfirm:t=>l.dispatchCommand(F.TOGGLE_LINK_COMMAND,t===""?null:de(t))},Z),De=()=>le({icon:"GalleryAdd",title:n("rte.imageTitle"),label:n("rte.imageUrl"),placeholder:"https://example.com/image.jpg",confirmLabel:n("common.insert"),onConfirm:t=>{t&&l.update(()=>D.$insertNodeToNearestRoot(Q(t)))}}),$e=async t=>{var k;const c=(k=t.target.files)==null?void 0:k[0];if(t.target.value="",!!c)try{const b=i?await i(c):await Kt(c);l.update(()=>D.$insertNodeToNearestRoot(Q(b,c.name)))}catch{Qe.toast.error(n("rte.imageError"))}},qe=()=>le({icon:"VideoSquare",title:n("rte.videoTitle"),label:n("rte.videoUrl"),placeholder:n("rte.videoUrlPlaceholder"),confirmLabel:n("common.insert"),onConfirm:t=>{t&&l.update(()=>D.$insertNodeToNearestRoot(me(t)))}}),L=(t,c,k,b,R)=>r.jsx(q.IconButton,{variant:t?"filled":"text",color:"primary",size:o,disabled:e,"aria-label":c,"aria-pressed":t,onMouseDown:W=>W.preventDefault(),onClick:k,children:b},R),fe=v.startsWith("h")?v:"paragraph",xe=T||zt[o];return r.jsxs("div",{className:s.toolbar,role:"toolbar","aria-label":n("rte.formatting"),"aria-orientation":"horizontal",children:[r.jsx(q.IconButton,{variant:"text",color:"primary",size:o,disabled:e||!z,"aria-label":n("rte.undo"),onMouseDown:t=>t.preventDefault(),onClick:()=>l.dispatchCommand(a.UNDO_COMMAND,void 0),children:r.jsx(g.Icon,{name:"UndoArrow"})}),r.jsx(q.IconButton,{variant:"text",color:"primary",size:o,disabled:e||!S,"aria-label":n("rte.redo"),onMouseDown:t=>t.preventDefault(),onClick:()=>l.dispatchCommand(a.REDO_COMMAND,void 0),children:r.jsx(g.Icon,{name:"RedoArrow"})}),r.jsx($.Divider,{orientation:"vertical"}),r.jsx(ce.Dropdown,{size:o,disabled:e,minWidth:!1,trigger:r.jsx(K.Button,{variant:"text",color:"primary",size:o,disabled:e,endIcon:r.jsx(g.Icon,{name:"ArrowDown4"}),"aria-label":n("rte.fontSize"),onMouseDown:t=>t.preventDefault(),children:xe}),children:Vt.map(t=>r.jsx(J.ListItem,{clickable:!0,selected:t===xe,onClick:()=>Me(t),children:t},t))}),r.jsx($.Divider,{orientation:"vertical"}),r.jsx(ce.Dropdown,{size:o,disabled:e,trigger:r.jsx(K.Button,{variant:"text",color:"primary",size:o,disabled:e,endIcon:r.jsx(g.Icon,{name:"ArrowDown4"}),onMouseDown:t=>t.preventDefault(),children:p(fe)}),children:Pt.map(t=>r.jsx(J.ListItem,{clickable:!0,selected:fe===t.type,icon:t.icon,onClick:()=>G(t.type),children:p(t.type)},t.type))}),r.jsx($.Divider,{orientation:"vertical"}),L(j,n("rte.bold"),()=>ie("bold"),r.jsx(g.Icon,{name:"TextBold"})),L(_,n("rte.italic"),()=>ie("italic"),r.jsx(g.Icon,{name:"TextItalic"})),L(f,n("rte.underline"),()=>ie("underline"),r.jsx(g.Icon,{name:"TextUnderline"})),r.jsx($.Divider,{orientation:"vertical"}),L(v==="bullet",n("rte.bulletList"),()=>G("bullet"),r.jsx(g.Icon,{name:"ListBullet"})),L(v==="number",n("rte.numberedList"),()=>G("number"),r.jsx(g.Icon,{name:"ListNumber"})),L(v==="quote",n("rte.quote"),Ie,r.jsx(g.Icon,{name:"QuoteUp"})),r.jsx($.Divider,{orientation:"vertical"}),Ht.map(t=>L(te===t.value,n(t.labelKey),()=>ke(t.value),r.jsx(g.Icon,{name:t.icon}),t.value)),r.jsx($.Divider,{orientation:"vertical"}),r.jsx(q.IconButton,{ref:U,variant:"text",color:"primary",size:o,disabled:e,"aria-label":n("rte.textColor"),"aria-expanded":H,onMouseDown:t=>t.preventDefault(),onClick:()=>V(t=>!t),children:r.jsx(Gt,{color:B})}),r.jsx(Xe.FloatingPanel,{open:H,triggerRef:U,onClose:t=>{var c;V(!1),t&&((c=U.current)==null||c.focus())},role:"dialog",ariaLabel:n("rte.textColor"),width:232,children:r.jsx(ye.ColorPickerPanel,{value:B||ye.DEFAULT_SWATCHES[0],onChange:Re,clearable:!1})}),L(y,n("rte.link"),Ae,r.jsx(g.Icon,{name:"Link2"})),r.jsxs(ce.Dropdown,{size:o,disabled:e,minWidth:!1,trigger:r.jsx(q.IconButton,{variant:"text",color:"primary",size:o,disabled:e,"aria-label":n("rte.insertImage"),children:r.jsx(g.Icon,{name:"GalleryAdd"})}),children:[r.jsx(J.ListItem,{clickable:!0,icon:"GalleryImport",onClick:()=>{var t;return(t=m.current)==null?void 0:t.click()},children:n("rte.uploadImage")}),r.jsx(J.ListItem,{clickable:!0,icon:"Link",onClick:De,children:n("rte.imageByUrl")})]}),r.jsx(q.IconButton,{variant:"text",color:"primary",size:o,disabled:e,"aria-label":n("rte.insertVideo"),onClick:qe,children:r.jsx(g.Icon,{name:"VideoSquare"})}),r.jsx("input",{ref:m,type:"file",accept:"image/*",hidden:!0,onChange:$e,"aria-hidden":"true",tabIndex:-1}),r.jsx(Ye.Modal,{open:h!==null,onClose:_e,size:"sm",icon:h==null?void 0:h.icon,title:h==null?void 0:h.title,footer:r.jsxs(r.Fragment,{children:[r.jsx(K.Button,{variant:"text",size:"sm",onClick:_e,children:n("common.cancel")}),r.jsx(K.Button,{type:"submit",size:"sm",form:"rte-url-form",children:(h==null?void 0:h.confirmLabel)??n("common.insert")})]}),children:r.jsx("form",{id:"rte-url-form",onSubmit:t=>{t.preventDefault(),Oe()},children:r.jsx(Ze.TextField,{label:h==null?void 0:h.label,placeholder:h==null?void 0:h.placeholder,value:pe,onChange:t=>he(t.target.value)})})})]})}function Kt(o){return new Promise((e,i)=>{const n=new FileReader;n.onload=()=>e(n.result),n.onerror=()=>i(n.error),n.readAsDataURL(o)})}const Jt={paragraph:s.paragraph,heading:{h1:s.h1,h2:s.h2,h3:s.h3,h4:s.h4,h5:s.h5,h6:s.h6},quote:s.quote,list:{ul:s.ul,ol:s.ol,listitem:s.li,listitemChecked:s.liChecked,listitemUnchecked:s.liUnchecked,nested:{listitem:s.nestedLi}},link:s.link,text:{bold:s.bold,italic:s.italic,underline:s.underline,strikethrough:s.strike,code:s.codeInline}},Qt=[w.HeadingNode,w.QuoteNode,I.ListNode,I.ListItemNode,F.LinkNode,X,Y],Xt=[...se.ELEMENT_TRANSFORMERS,...se.TEXT_FORMAT_TRANSFORMERS,...se.TEXT_MATCH_TRANSFORMERS],Yt=["color","font-size"],Zt={span:o=>{var i,n;const e=(n=(i=a.TextNode.importDOM())==null?void 0:i.span)==null?void 0:n.call(i,o);return{priority:1,conversion:p=>{const l=(e==null?void 0:e.conversion(p))??{node:null},m=Yt.flatMap(d=>{const _=p.style.getPropertyValue(d);return _?[[d,_]]:[]});if(m.length===0)return l;const j=l.forChild;return{...l,forChild:(d,_)=>{const N=j?j(d,_):d;if(a.$isTextNode(N)){const f={...a.getStyleObjectFromCSS(N.getStyle())};for(const[x,y]of m)f[x]=y;N.setStyle(Object.entries(f).map(([x,y])=>`${x}: ${y};`).join(" "))}return N}}}}}},er=new Set(["A","B","CODE","EM","I","MARK","S","SPAN","STRONG","SUB","SUP","U"]);function tr(o){const e=o.split(";").map(i=>i.trim()).filter(i=>i&&!/^white-space\s*:\s*pre-wrap$/i.test(i));return e.length?`${e.join("; ")};`:null}function rr(o){const e=document.createTreeWalker(o,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT);let i=!0,n=!1,p=null;const l=()=>{p&&p.data.endsWith(" ")&&(p.data=`${p.data.slice(0,-1)} `),p=null,i=!0,n=!1};for(let m=e.nextNode();m;m=e.nextNode()){if(m.nodeType===Node.ELEMENT_NODE){er.has(m.tagName)||l();continue}const j=m;if(!j.data)continue;let d="";for(const _ of j.data)_===" "&&(i||n)?(d+=" ",n=!1):(d+=_,n=_===" "),i=!1;j.data=d,p=j}l()}function nr(o){if(typeof document>"u")return o;const e=document.createElement("template");e.innerHTML=o;const i=e.content;return i.querySelectorAll("[class]").forEach(n=>n.removeAttribute("class")),i.querySelectorAll("[style]").forEach(n=>{var l;if((l=n.textContent)!=null&&l.includes(" "))return;const p=tr(n.getAttribute("style")??"");p?n.setAttribute("style",p):n.removeAttribute("style")}),i.querySelectorAll("span").forEach(n=>{n.attributes.length===0&&n.replaceWith(...n.childNodes)}),i.normalize(),rr(i),e.innerHTML}function or(){const o=a.$getRoot(),e=o.getFirstChild();return o.getChildrenSize()<=1&&(e===null||a.$isParagraphNode(e)&&e.getChildrenSize()===0)}function Te(o,e){const i=a.$getRoot();if(i.clear(),e){const n=new DOMParser().parseFromString(e,"text/html"),p=ve.$generateNodesFromDOM(o,n);i.select(),a.$insertNodes(p)}i.getChildrenSize()===0&&i.append(a.$createParagraphNode()),a.$setSelection(null)}const ae="tz-external-value";function Ce(o){return or()?"":nr(ve.$generateHtmlFromNodes(o,null))}function ir({value:o,defaultValue:e,onChange:i,onReady:n,disabled:p}){const[l]=Ee.useLexicalComposerContext(),m=u.useRef(void 0),j=u.useRef(i);j.current=i;const d=u.useRef(n);d.current=n;const _=u.useRef(!1),N=f=>{var x;_.current||(_.current=!0,(x=d.current)==null||x.call(d,f))};return u.useEffect(()=>l.setEditable(!p),[l,p]),u.useEffect(()=>l.registerNodeTransform(F.LinkNode,f=>{const x=f.getURL(),y=de(x);y!==x&&f.setURL(y)}),[l]),u.useEffect(()=>{if(o===void 0){if(!e){m.current="",N("");return}m.current=e,l.update(()=>Te(l,e),{tag:["history-merge",ae]})}},[]),u.useEffect(()=>{o===void 0||o===m.current||(m.current=o,l.update(()=>Te(l,o),{tag:["history-merge",ae]}))},[l,o]),u.useEffect(()=>l.registerUpdateListener(({dirtyElements:f,dirtyLeaves:x,tags:y})=>{if(y.has(ae)){l.read(()=>{const C=Ce(l);m.current=C,N(C)});return}f.size===0&&x.size===0||l.read(()=>{const C=Ce(l);C!==m.current&&(m.current=C,j.current(C))})}),[l]),null}const lr=u.forwardRef(function({label:e,size:i="md",error:n,helperText:p,required:l=!1,disabled:m=!1,placeholder:j,name:d,value:_,defaultValue:N,onChange:f,onReady:x,onImageUpload:y,minHeight:C=220,"aria-label":Z="Rich text editor",className:ee,style:v},O){const te=ue.useT(),E=Je.useFormContext(),T=E&&d?E.field(d):void 0,A=n??(T==null?void 0:T.error)??!1,B=p??(T==null?void 0:T.helperText),P=E&&d?E.values[d]:void 0,H=_!==void 0?_:E&&d?String(P??""):void 0,V=u.useCallback(S=>{E&&d&&E.setValue(d,S),f==null||f(S)},[E,d,f]),U=S=>T==null?void 0:T.onBlur(S),z=u.useRef(null);u.useEffect(()=>{const S=z.current;S&&(d?S.setAttribute("name",d):S.removeAttribute("name"))},[d]);const re={namespace:"tz-rich-text-editor",theme:Jt,nodes:Qt,html:{import:Zt},editable:!m,onError:S=>{throw S}};return r.jsxs("div",{ref:O,className:Be.clsx(s.editor,s[i],A&&s.error,m&&s.disabled,ee),style:{"--tz-rte-min-height":`${C}px`,...v},children:[e!=null&&r.jsxs("div",{className:s.label,children:[r.jsx(je.Typography,{as:"span",variant:"bodySmall",color:"muted",children:e}),l&&r.jsx("span",{className:s.required,"aria-hidden":"true",children:"*"})]}),r.jsx("div",{className:s.control,children:r.jsxs(Ue.LexicalComposer,{initialConfig:re,children:[r.jsx(Wt,{size:i,disabled:m,onImageUpload:y}),r.jsx("div",{className:s.shell,children:r.jsx(Fe.RichTextPlugin,{contentEditable:r.jsx(Pe.ContentEditable,{ref:z,className:s.content,"aria-label":Z,"aria-invalid":A||void 0,onBlur:U}),placeholder:r.jsx("div",{className:s.placeholder,children:j??te("rte.placeholder")}),ErrorBoundary:He.LexicalErrorBoundary})}),r.jsx(Ve.HistoryPlugin,{}),r.jsx(ze.ListPlugin,{}),r.jsx(Ge.CheckListPlugin,{}),r.jsx(We.LinkPlugin,{}),r.jsx(Ke.MarkdownShortcutPlugin,{transformers:Xt}),r.jsx(ir,{value:H,defaultValue:N,onChange:V,onReady:x,disabled:m})]})}),B!=null&&r.jsx(je.Typography,{as:"span",variant:"bodySmall",color:A?"error":"muted",className:s.helper,children:B})]})});exports.RichTextEditor=lr;
2
- //# sourceMappingURL=RichTextEditor-CitILCiw.cjs.map
1
+ "use strict";const r=require("react/jsx-runtime"),u=require("react"),Be=require("clsx"),a=require("lexical"),Ue=require("@lexical/react/LexicalComposer"),Ee=require("@lexical/react/LexicalComposerContext"),Fe=require("@lexical/react/LexicalRichTextPlugin"),Pe=require("@lexical/react/LexicalContentEditable"),He=require("@lexical/react/LexicalErrorBoundary"),Ve=require("@lexical/react/LexicalHistoryPlugin"),ze=require("@lexical/react/LexicalListPlugin"),Ge=require("@lexical/react/LexicalCheckListPlugin"),We=require("@lexical/react/LexicalLinkPlugin"),Ke=require("@lexical/react/LexicalMarkdownShortcutPlugin"),se=require("@lexical/markdown"),w=require("@lexical/rich-text"),I=require("@lexical/list"),F=require("@lexical/link"),ve=require("@lexical/html"),Je=require("./formContext-bTWrqdEV.cjs"),je=require("./Typography-d97DdbNd.cjs"),Qe=require("./toastStore-B4Tk2Xk7.cjs"),M=require("@lexical/selection"),D=require("@lexical/utils"),K=require("./Button-CYZoF18-.cjs"),ye=require("./ColorPickerPanel-BbgujQ3X.cjs"),$=require("./Divider-CzbhdCiD.cjs"),ce=require("./Dropdown-DYYhzKSo.cjs"),Xe=require("./FloatingPanel-tGCG2nhA.cjs"),g=require("./Icon-B6lz-V0A.cjs"),q=require("./IconButton-CQ25TtBc.cjs"),J=require("./ListItem-Qo1Tt6Fi.cjs"),Ye=require("./Modal-DjSOhZqd.cjs"),Ze=require("./TextField-BL6OAJcP.cjs"),ue=require("./ConfigProvider-B_Bb6pk1.cjs"),et=/^(?:https?:|mailto:|tel:|ftp:|#|\/|\?|\.)/i,tt=/^[a-z][a-z0-9+.-]*:/i;function de(o){const e=o.trim();return e===""?"":et.test(e)||!tt.test(e)?e:"#"}function Le(o){const e=o.trim();if(/^data:(?:image|video)\//i.test(e)||/^blob:/i.test(e))return e;const i=de(e);return i==="#"?"":i}function rt(o){return o instanceof HTMLImageElement&&o.src?{node:Q(o.getAttribute("src")??o.src,o.alt)}:null}class X extends a.DecoratorNode{static getType(){return"tz-image"}static clone(e){return new X(e.__src,e.__alt,e.__key)}constructor(e,i="",n){super(n),this.__src=Le(e),this.__alt=i}static importJSON(e){return Q(e.src,e.alt)}exportJSON(){return{...super.exportJSON(),type:"tz-image",version:1,src:this.__src,alt:this.__alt}}static importDOM(){return{img:()=>({conversion:rt,priority:0})}}exportDOM(){const e=document.createElement("img");return e.setAttribute("src",this.__src),e.setAttribute("alt",this.__alt),{element:e}}createDOM(){const e=document.createElement("div");return e.style.display="contents",e}updateDOM(){return!1}getSrc(){return this.__src}getAltText(){return this.__alt}decorate(){return r.jsx("img",{src:this.__src,alt:this.__alt,draggable:!1})}}function Q(o,e=""){return a.$applyNodeReplacement(new X(o,e))}function Se(o){return/\.(mp4|webm|ogg|ogv|mov|m4v)(\?.*)?$/i.test(o)}function nt(o){const e=o.match(/(?:youtube\.com\/(?:watch\?(?:.*&)?v=|embed\/|shorts\/)|youtu\.be\/)([\w-]{11})/);if(e)return`https://www.youtube.com/embed/${e[1]}`;const i=o.match(/vimeo\.com\/(?:video\/)?(\d+)/);return i?`https://player.vimeo.com/video/${i[1]}`:o}function Ne(o){var i;const e=o.getAttribute("src")||((i=o.querySelector("source"))==null?void 0:i.getAttribute("src"));return e?{node:me(e)}:null}class Y extends a.DecoratorNode{static getType(){return"tz-video"}static clone(e){return new Y(e.__src,e.__key)}constructor(e,i){super(i),this.__src=Le(e)}static importJSON(e){return me(e.src)}exportJSON(){return{...super.exportJSON(),type:"tz-video",version:1,src:this.__src}}static importDOM(){return{iframe:()=>({conversion:Ne,priority:0}),video:()=>({conversion:Ne,priority:0})}}exportDOM(){if(Se(this.__src)){const i=document.createElement("video");return i.setAttribute("src",this.__src),i.setAttribute("controls","true"),{element:i}}const e=document.createElement("iframe");return e.setAttribute("src",this.__src),e.setAttribute("frameborder","0"),e.setAttribute("allowfullscreen","true"),e.setAttribute("allow","accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"),{element:e}}createDOM(){const e=document.createElement("div");return e.style.display="contents",e}updateDOM(){return!1}getSrc(){return this.__src}decorate(){return Se(this.__src)?r.jsx("video",{src:this.__src,controls:!0}):r.jsx(ot,{src:this.__src})}}function ot({src:o}){const e=ue.useT();return r.jsx("div",{className:"tz-rte-embed",children:r.jsx("iframe",{src:o,title:e("rte.embeddedVideo"),frameBorder:0,allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})})}function me(o){return a.$applyNodeReplacement(new Y(nt(o)))}const it="_editor_16j1l_1",lt="_label_16j1l_9",st="_required_16j1l_15",ct="_helper_16j1l_18",at="_control_16j1l_24",ut="_error_16j1l_38",dt="_disabled_16j1l_45",mt="_toolbar_16j1l_51",pt="_sm_16j1l_67",ht="_md_16j1l_71",_t="_lg_16j1l_75",ft="_colorGlyph_16j1l_81",xt="_colorBar_16j1l_89",gt="_shell_16j1l_107",jt="_content_16j1l_110",yt="_placeholder_16j1l_123",St="_paragraph_16j1l_146",Nt="_h1_16j1l_152",Tt="_h2_16j1l_153",Ct="_h3_16j1l_154",Et="_h4_16j1l_155",vt="_h5_16j1l_156",Lt="_h6_16j1l_157",bt="_quote_16j1l_176",kt="_ul_16j1l_183",Rt="_ol_16j1l_188",Mt="_li_16j1l_193",It="_nestedLi_16j1l_196",Ot="_liChecked_16j1l_200",At="_liUnchecked_16j1l_201",Dt="_link_16j1l_238",$t="_bold_16j1l_245",qt="_italic_16j1l_248",wt="_underline_16j1l_251",Bt="_strike_16j1l_254",Ut="_codeInline_16j1l_260",s={editor:it,label:lt,required:st,helper:ct,control:at,error:ut,disabled:dt,toolbar:mt,sm:pt,md:ht,lg:_t,colorGlyph:ft,colorBar:xt,shell:gt,content:jt,placeholder:yt,paragraph:St,h1:Nt,h2:Tt,h3:Ct,h4:Et,h5:vt,h6:Lt,quote:bt,ul:kt,ol:Rt,li:Mt,nestedLi:It,liChecked:Ot,liUnchecked:At,link:Dt,bold:$t,italic:qt,underline:wt,strike:Bt,codeInline:Ut},Ft={paragraph:"Paragraph",h1:"Heading 1",h2:"Heading 2",h3:"Heading 3",quote:"Quote",bullet:"Bullet List",number:"Numbered List",check:"Check List"},Pt=[{type:"paragraph",icon:"Text"},{type:"h1",icon:"Hashtag"},{type:"h2",icon:"Hashtag"},{type:"h3",icon:"Hashtag"}],Ht=[{value:"left",labelKey:"rte.alignLeft",icon:"TextalignLeft"},{value:"center",labelKey:"rte.alignCenter",icon:"TextalignCenter"},{value:"right",labelKey:"rte.alignRight",icon:"TextalignRight"}],Vt=["10px","12px","14px","16px","18px","20px"],zt={sm:"12px",md:"14px",lg:"16px"};function Gt({color:o,size:e}){return r.jsxs("span",{className:s.colorGlyph,children:[r.jsx(g.Icon,{name:"Brush",size:e}),r.jsx("span",{className:s.colorBar,style:{borderColor:`transparent transparent ${o||"currentColor"} transparent`},"aria-hidden":"true"})]})}function Wt({size:o,disabled:e,onImageUpload:i}){const n=ue.useT(),p=t=>Ft[t]??t,[l]=Ee.useLexicalComposerContext(),m=u.useRef(null),[j,d]=u.useState(!1),[_,N]=u.useState(!1),[f,x]=u.useState(!1),[y,C]=u.useState(!1),[Z,ee]=u.useState(""),[v,O]=u.useState("paragraph"),[te,E]=u.useState("left"),[T,A]=u.useState(""),[B,P]=u.useState(""),[H,V]=u.useState(!1),U=u.useRef(null),[z,re]=u.useState(!1),[S,be]=u.useState(!1),[h,ne]=u.useState(null),[pe,he]=u.useState(""),oe=u.useCallback(()=>{const t=a.$getSelection();if(!a.$isRangeSelection(t))return;d(t.hasFormat("bold")),N(t.hasFormat("italic")),x(t.hasFormat("underline")),P(M.$getSelectionStyleValueForProperty(t,"color","")),A(M.$getSelectionStyleValueForProperty(t,"font-size",""));const c=t.anchor.getNode(),k=c.getParent(),b=F.$isLinkNode(c)?c:F.$isLinkNode(k)?k:null;C(b!==null),ee((b==null?void 0:b.getURL())??"");const R=c.getKey()==="root"?c:D.$findMatchingParent(c,we=>{const ge=we.getParent();return ge===null||ge.getKey()==="root"})??c.getTopLevelElement();E(a.$isElementNode(R)&&R.getFormatType()||"left");const W=D.$getNearestNodeOfType(c,I.ListNode);W?O(W.getListType()):w.$isHeadingNode(R)?O(R.getTag()):w.$isQuoteNode(R)?O("quote"):O("paragraph")},[]);u.useEffect(()=>D.mergeRegister(l.registerUpdateListener(({editorState:t})=>t.read(oe)),l.registerCommand(a.SELECTION_CHANGE_COMMAND,()=>(oe(),!1),a.COMMAND_PRIORITY_LOW),l.registerCommand(a.CAN_UNDO_COMMAND,t=>(re(t),!1),a.COMMAND_PRIORITY_LOW),l.registerCommand(a.CAN_REDO_COMMAND,t=>(be(t),!1),a.COMMAND_PRIORITY_LOW)),[l,oe]);const ie=t=>l.dispatchCommand(a.FORMAT_TEXT_COMMAND,t),ke=t=>l.dispatchCommand(a.FORMAT_ELEMENT_COMMAND,t),Re=t=>{P(t),l.update(()=>{const c=a.$getSelection();a.$isRangeSelection(c)&&M.$patchStyleText(c,{color:t||null})})},Me=t=>{A(t),l.update(()=>{const c=a.$getSelection();a.$isRangeSelection(c)&&M.$patchStyleText(c,{"font-size":t||null})})},G=t=>{if(t==="bullet"||t==="number"||t==="check"){if(v===t)l.dispatchCommand(I.REMOVE_LIST_COMMAND,void 0);else{const c=t==="bullet"?I.INSERT_UNORDERED_LIST_COMMAND:t==="number"?I.INSERT_ORDERED_LIST_COMMAND:I.INSERT_CHECK_LIST_COMMAND;l.dispatchCommand(c,void 0)}return}l.update(()=>{const c=a.$getSelection();a.$isRangeSelection(c)&&(t==="paragraph"?M.$setBlocksType(c,()=>a.$createParagraphNode()):t==="quote"?M.$setBlocksType(c,()=>w.$createQuoteNode()):M.$setBlocksType(c,()=>w.$createHeadingNode(t)))})},Ie=()=>G(v==="quote"?"paragraph":"quote"),le=(t,c="")=>{he(c),ne(t)},_e=()=>ne(null),Oe=()=>{h==null||h.onConfirm(pe.trim()),ne(null)},Ae=()=>le({icon:"Link2",title:n("rte.linkTitle"),label:n("rte.linkUrl"),placeholder:"https://example.com",confirmLabel:n(y?"common.update":"common.insert"),onConfirm:t=>l.dispatchCommand(F.TOGGLE_LINK_COMMAND,t===""?null:de(t))},Z),De=()=>le({icon:"GalleryAdd",title:n("rte.imageTitle"),label:n("rte.imageUrl"),placeholder:"https://example.com/image.jpg",confirmLabel:n("common.insert"),onConfirm:t=>{t&&l.update(()=>D.$insertNodeToNearestRoot(Q(t)))}}),$e=async t=>{var k;const c=(k=t.target.files)==null?void 0:k[0];if(t.target.value="",!!c)try{const b=i?await i(c):await Kt(c);l.update(()=>D.$insertNodeToNearestRoot(Q(b,c.name)))}catch{Qe.toast.error(n("rte.imageError"))}},qe=()=>le({icon:"VideoSquare",title:n("rte.videoTitle"),label:n("rte.videoUrl"),placeholder:n("rte.videoUrlPlaceholder"),confirmLabel:n("common.insert"),onConfirm:t=>{t&&l.update(()=>D.$insertNodeToNearestRoot(me(t)))}}),L=(t,c,k,b,R)=>r.jsx(q.IconButton,{variant:t?"filled":"text",color:"primary",size:o,disabled:e,"aria-label":c,"aria-pressed":t,onMouseDown:W=>W.preventDefault(),onClick:k,children:b},R),fe=v.startsWith("h")?v:"paragraph",xe=T||zt[o];return r.jsxs("div",{className:s.toolbar,role:"toolbar","aria-label":n("rte.formatting"),"aria-orientation":"horizontal",children:[r.jsx(q.IconButton,{variant:"text",color:"primary",size:o,disabled:e||!z,"aria-label":n("rte.undo"),onMouseDown:t=>t.preventDefault(),onClick:()=>l.dispatchCommand(a.UNDO_COMMAND,void 0),children:r.jsx(g.Icon,{name:"UndoArrow"})}),r.jsx(q.IconButton,{variant:"text",color:"primary",size:o,disabled:e||!S,"aria-label":n("rte.redo"),onMouseDown:t=>t.preventDefault(),onClick:()=>l.dispatchCommand(a.REDO_COMMAND,void 0),children:r.jsx(g.Icon,{name:"RedoArrow"})}),r.jsx($.Divider,{orientation:"vertical"}),r.jsx(ce.Dropdown,{size:o,disabled:e,minWidth:!1,trigger:r.jsx(K.Button,{variant:"text",color:"primary",size:o,disabled:e,endIcon:r.jsx(g.Icon,{name:"ArrowDown4"}),"aria-label":n("rte.fontSize"),onMouseDown:t=>t.preventDefault(),children:xe}),children:Vt.map(t=>r.jsx(J.ListItem,{clickable:!0,selected:t===xe,onClick:()=>Me(t),children:t},t))}),r.jsx($.Divider,{orientation:"vertical"}),r.jsx(ce.Dropdown,{size:o,disabled:e,trigger:r.jsx(K.Button,{variant:"text",color:"primary",size:o,disabled:e,endIcon:r.jsx(g.Icon,{name:"ArrowDown4"}),onMouseDown:t=>t.preventDefault(),children:p(fe)}),children:Pt.map(t=>r.jsx(J.ListItem,{clickable:!0,selected:fe===t.type,icon:t.icon,onClick:()=>G(t.type),children:p(t.type)},t.type))}),r.jsx($.Divider,{orientation:"vertical"}),L(j,n("rte.bold"),()=>ie("bold"),r.jsx(g.Icon,{name:"TextBold"})),L(_,n("rte.italic"),()=>ie("italic"),r.jsx(g.Icon,{name:"TextItalic"})),L(f,n("rte.underline"),()=>ie("underline"),r.jsx(g.Icon,{name:"TextUnderline"})),r.jsx($.Divider,{orientation:"vertical"}),L(v==="bullet",n("rte.bulletList"),()=>G("bullet"),r.jsx(g.Icon,{name:"ListBullet"})),L(v==="number",n("rte.numberedList"),()=>G("number"),r.jsx(g.Icon,{name:"ListNumber"})),L(v==="quote",n("rte.quote"),Ie,r.jsx(g.Icon,{name:"QuoteUp"})),r.jsx($.Divider,{orientation:"vertical"}),Ht.map(t=>L(te===t.value,n(t.labelKey),()=>ke(t.value),r.jsx(g.Icon,{name:t.icon}),t.value)),r.jsx($.Divider,{orientation:"vertical"}),r.jsx(q.IconButton,{ref:U,variant:"text",color:"primary",size:o,disabled:e,"aria-label":n("rte.textColor"),"aria-expanded":H,onMouseDown:t=>t.preventDefault(),onClick:()=>V(t=>!t),children:r.jsx(Gt,{color:B})}),r.jsx(Xe.FloatingPanel,{open:H,triggerRef:U,onClose:t=>{var c;V(!1),t&&((c=U.current)==null||c.focus())},role:"dialog",ariaLabel:n("rte.textColor"),width:232,children:r.jsx(ye.ColorPickerPanel,{value:B||ye.DEFAULT_SWATCHES[0],onChange:Re,clearable:!1})}),L(y,n("rte.link"),Ae,r.jsx(g.Icon,{name:"Link2"})),r.jsxs(ce.Dropdown,{size:o,disabled:e,minWidth:!1,trigger:r.jsx(q.IconButton,{variant:"text",color:"primary",size:o,disabled:e,"aria-label":n("rte.insertImage"),children:r.jsx(g.Icon,{name:"GalleryAdd"})}),children:[r.jsx(J.ListItem,{clickable:!0,icon:"GalleryImport",onClick:()=>{var t;return(t=m.current)==null?void 0:t.click()},children:n("rte.uploadImage")}),r.jsx(J.ListItem,{clickable:!0,icon:"Link",onClick:De,children:n("rte.imageByUrl")})]}),r.jsx(q.IconButton,{variant:"text",color:"primary",size:o,disabled:e,"aria-label":n("rte.insertVideo"),onClick:qe,children:r.jsx(g.Icon,{name:"VideoSquare"})}),r.jsx("input",{ref:m,type:"file",accept:"image/*",hidden:!0,onChange:$e,"aria-hidden":"true",tabIndex:-1}),r.jsx(Ye.Modal,{open:h!==null,onClose:_e,size:"sm",icon:h==null?void 0:h.icon,title:h==null?void 0:h.title,footer:r.jsxs(r.Fragment,{children:[r.jsx(K.Button,{variant:"text",size:"sm",onClick:_e,children:n("common.cancel")}),r.jsx(K.Button,{type:"submit",size:"sm",form:"rte-url-form",children:(h==null?void 0:h.confirmLabel)??n("common.insert")})]}),children:r.jsx("form",{id:"rte-url-form",onSubmit:t=>{t.preventDefault(),Oe()},children:r.jsx(Ze.TextField,{label:h==null?void 0:h.label,placeholder:h==null?void 0:h.placeholder,value:pe,onChange:t=>he(t.target.value)})})})]})}function Kt(o){return new Promise((e,i)=>{const n=new FileReader;n.onload=()=>e(n.result),n.onerror=()=>i(n.error),n.readAsDataURL(o)})}const Jt={paragraph:s.paragraph,heading:{h1:s.h1,h2:s.h2,h3:s.h3,h4:s.h4,h5:s.h5,h6:s.h6},quote:s.quote,list:{ul:s.ul,ol:s.ol,listitem:s.li,listitemChecked:s.liChecked,listitemUnchecked:s.liUnchecked,nested:{listitem:s.nestedLi}},link:s.link,text:{bold:s.bold,italic:s.italic,underline:s.underline,strikethrough:s.strike,code:s.codeInline}},Qt=[w.HeadingNode,w.QuoteNode,I.ListNode,I.ListItemNode,F.LinkNode,X,Y],Xt=[...se.ELEMENT_TRANSFORMERS,...se.TEXT_FORMAT_TRANSFORMERS,...se.TEXT_MATCH_TRANSFORMERS],Yt=["color","font-size"],Zt={span:o=>{var i,n;const e=(n=(i=a.TextNode.importDOM())==null?void 0:i.span)==null?void 0:n.call(i,o);return{priority:1,conversion:p=>{const l=(e==null?void 0:e.conversion(p))??{node:null},m=Yt.flatMap(d=>{const _=p.style.getPropertyValue(d);return _?[[d,_]]:[]});if(m.length===0)return l;const j=l.forChild;return{...l,forChild:(d,_)=>{const N=j?j(d,_):d;if(a.$isTextNode(N)){const f={...a.getStyleObjectFromCSS(N.getStyle())};for(const[x,y]of m)f[x]=y;N.setStyle(Object.entries(f).map(([x,y])=>`${x}: ${y};`).join(" "))}return N}}}}}},er=new Set(["A","B","CODE","EM","I","MARK","S","SPAN","STRONG","SUB","SUP","U"]);function tr(o){const e=o.split(";").map(i=>i.trim()).filter(i=>i&&!/^white-space\s*:\s*pre-wrap$/i.test(i));return e.length?`${e.join("; ")};`:null}function rr(o){const e=document.createTreeWalker(o,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT);let i=!0,n=!1,p=null;const l=()=>{p&&p.data.endsWith(" ")&&(p.data=`${p.data.slice(0,-1)} `),p=null,i=!0,n=!1};for(let m=e.nextNode();m;m=e.nextNode()){if(m.nodeType===Node.ELEMENT_NODE){er.has(m.tagName)||l();continue}const j=m;if(!j.data)continue;let d="";for(const _ of j.data)_===" "&&(i||n)?(d+=" ",n=!1):(d+=_,n=_===" "),i=!1;j.data=d,p=j}l()}function nr(o){if(typeof document>"u")return o;const e=document.createElement("template");e.innerHTML=o;const i=e.content;return i.querySelectorAll("[class]").forEach(n=>n.removeAttribute("class")),i.querySelectorAll("[style]").forEach(n=>{var l;if((l=n.textContent)!=null&&l.includes(" "))return;const p=tr(n.getAttribute("style")??"");p?n.setAttribute("style",p):n.removeAttribute("style")}),i.querySelectorAll("span").forEach(n=>{n.attributes.length===0&&n.replaceWith(...n.childNodes)}),i.normalize(),rr(i),e.innerHTML}function or(){const o=a.$getRoot(),e=o.getFirstChild();return o.getChildrenSize()<=1&&(e===null||a.$isParagraphNode(e)&&e.getChildrenSize()===0)}function Te(o,e){const i=a.$getRoot();if(i.clear(),e){const n=new DOMParser().parseFromString(e,"text/html"),p=ve.$generateNodesFromDOM(o,n);i.select(),a.$insertNodes(p)}i.getChildrenSize()===0&&i.append(a.$createParagraphNode()),a.$setSelection(null)}const ae="tz-external-value";function Ce(o){return or()?"":nr(ve.$generateHtmlFromNodes(o,null))}function ir({value:o,defaultValue:e,onChange:i,onReady:n,disabled:p}){const[l]=Ee.useLexicalComposerContext(),m=u.useRef(void 0),j=u.useRef(i);j.current=i;const d=u.useRef(n);d.current=n;const _=u.useRef(!1),N=f=>{var x;_.current||(_.current=!0,(x=d.current)==null||x.call(d,f))};return u.useEffect(()=>l.setEditable(!p),[l,p]),u.useEffect(()=>l.registerNodeTransform(F.LinkNode,f=>{const x=f.getURL(),y=de(x);y!==x&&f.setURL(y)}),[l]),u.useEffect(()=>{if(o===void 0){if(!e){m.current="",N("");return}m.current=e,l.update(()=>Te(l,e),{tag:["history-merge",ae]})}},[]),u.useEffect(()=>{o===void 0||o===m.current||(m.current=o,l.update(()=>Te(l,o),{tag:["history-merge",ae]}))},[l,o]),u.useEffect(()=>l.registerUpdateListener(({dirtyElements:f,dirtyLeaves:x,tags:y})=>{if(y.has(ae)){l.read(()=>{const C=Ce(l);m.current=C,N(C)});return}f.size===0&&x.size===0||l.read(()=>{const C=Ce(l);C!==m.current&&(m.current=C,j.current(C))})}),[l]),null}const lr=u.forwardRef(function({label:e,size:i="md",error:n,helperText:p,required:l=!1,disabled:m=!1,placeholder:j,name:d,value:_,defaultValue:N,onChange:f,onReady:x,onImageUpload:y,minHeight:C=220,"aria-label":Z="Rich text editor",className:ee,style:v},O){const te=ue.useT(),E=Je.useFormContext(),T=E&&d?E.field(d):void 0,A=n??(T==null?void 0:T.error)??!1,B=p??(T==null?void 0:T.helperText),P=E&&d?E.values[d]:void 0,H=_!==void 0?_:E&&d?String(P??""):void 0,V=u.useCallback(S=>{E&&d&&E.setValue(d,S),f==null||f(S)},[E,d,f]),U=S=>T==null?void 0:T.onBlur(S),z=u.useRef(null);u.useEffect(()=>{const S=z.current;S&&(d?S.setAttribute("name",d):S.removeAttribute("name"))},[d]);const re={namespace:"tz-rich-text-editor",theme:Jt,nodes:Qt,html:{import:Zt},editable:!m,onError:S=>{throw S}};return r.jsxs("div",{ref:O,className:Be.clsx(s.editor,s[i],A&&s.error,m&&s.disabled,ee),style:{"--tz-rte-min-height":`${C}px`,...v},children:[e!=null&&r.jsxs("div",{className:s.label,children:[r.jsx(je.Typography,{as:"span",variant:"bodySmall",color:"muted",children:e}),l&&r.jsx("span",{className:s.required,"aria-hidden":"true",children:"*"})]}),r.jsx("div",{className:s.control,children:r.jsxs(Ue.LexicalComposer,{initialConfig:re,children:[r.jsx(Wt,{size:i,disabled:m,onImageUpload:y}),r.jsx("div",{className:s.shell,children:r.jsx(Fe.RichTextPlugin,{contentEditable:r.jsx(Pe.ContentEditable,{ref:z,className:s.content,"aria-label":Z,"aria-invalid":A||void 0,onBlur:U}),placeholder:r.jsx("div",{className:s.placeholder,children:j??te("rte.placeholder")}),ErrorBoundary:He.LexicalErrorBoundary})}),r.jsx(Ve.HistoryPlugin,{}),r.jsx(ze.ListPlugin,{}),r.jsx(Ge.CheckListPlugin,{}),r.jsx(We.LinkPlugin,{}),r.jsx(Ke.MarkdownShortcutPlugin,{transformers:Xt}),r.jsx(ir,{value:H,defaultValue:N,onChange:V,onReady:x,disabled:m})]})}),B!=null&&r.jsx(je.Typography,{as:"span",variant:"bodySmall",color:A?"error":"muted",className:s.helper,children:B})]})});exports.RichTextEditor=lr;
2
+ //# sourceMappingURL=RichTextEditor-DSvSaszc.cjs.map