@namroodinc/liquid-editorial 0.2.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (179) hide show
  1. package/README.md +26 -1
  2. package/UPGRADING.md +75 -0
  3. package/dist/chunks/{FormEditor-DuW8x78Y.js → FormEditor-DRmPFe2E.js} +100 -102
  4. package/dist/chunks/FormEditor-DRmPFe2E.js.map +1 -0
  5. package/dist/chunks/FormEditor-PVkvKep1.cjs +2 -0
  6. package/dist/chunks/FormEditor-PVkvKep1.cjs.map +1 -0
  7. package/dist/chunks/{RichTextEditor-BxtlbjXj.cjs → RichTextEditor-C7nMfDmE.cjs} +2 -2
  8. package/dist/chunks/RichTextEditor-C7nMfDmE.cjs.map +1 -0
  9. package/dist/chunks/{RichTextEditor-Dnx4i7bQ.js → RichTextEditor-DjR10XJ-.js} +55 -53
  10. package/dist/chunks/RichTextEditor-DjR10XJ-.js.map +1 -0
  11. package/dist/chunks/binding-Bshy43sG.js +33 -0
  12. package/dist/chunks/binding-Bshy43sG.js.map +1 -0
  13. package/dist/chunks/binding-tMjrUzkU.cjs +2 -0
  14. package/dist/chunks/binding-tMjrUzkU.cjs.map +1 -0
  15. package/dist/chunks/context-BONPXF-V.cjs +2 -0
  16. package/dist/chunks/context-BONPXF-V.cjs.map +1 -0
  17. package/dist/chunks/context-CXvOl4Kt.js +7 -0
  18. package/dist/chunks/context-CXvOl4Kt.js.map +1 -0
  19. package/dist/chunks/frame-Bs_jaQRw.js +70 -0
  20. package/dist/chunks/frame-Bs_jaQRw.js.map +1 -0
  21. package/dist/chunks/frame-CNxvbg0D.cjs +2 -0
  22. package/dist/chunks/frame-CNxvbg0D.cjs.map +1 -0
  23. package/dist/chunks/group-CzbacuAY.js +29 -0
  24. package/dist/chunks/group-CzbacuAY.js.map +1 -0
  25. package/dist/chunks/group-pKDQtq-9.cjs +2 -0
  26. package/dist/chunks/group-pKDQtq-9.cjs.map +1 -0
  27. package/dist/components/Badge/index.cjs +1 -1
  28. package/dist/components/Badge/index.cjs.map +1 -1
  29. package/dist/components/Badge/index.d.cts +2 -0
  30. package/dist/components/Badge/index.d.cts.map +1 -1
  31. package/dist/components/Badge/index.d.ts +2 -0
  32. package/dist/components/Badge/index.d.ts.map +1 -1
  33. package/dist/components/Badge/index.js +8 -8
  34. package/dist/components/Badge/index.js.map +1 -1
  35. package/dist/components/Choice/index.cjs +1 -1
  36. package/dist/components/Choice/index.cjs.map +1 -1
  37. package/dist/components/Choice/index.d.cts +3 -3
  38. package/dist/components/Choice/index.d.cts.map +1 -1
  39. package/dist/components/Choice/index.d.ts +3 -3
  40. package/dist/components/Choice/index.d.ts.map +1 -1
  41. package/dist/components/Choice/index.js +27 -27
  42. package/dist/components/Choice/index.js.map +1 -1
  43. package/dist/components/Choice/style.css +0 -7
  44. package/dist/components/DatePicker/index.cjs +1 -1
  45. package/dist/components/DatePicker/index.cjs.map +1 -1
  46. package/dist/components/DatePicker/index.d.cts +5 -9
  47. package/dist/components/DatePicker/index.d.cts.map +1 -1
  48. package/dist/components/DatePicker/index.d.ts +5 -9
  49. package/dist/components/DatePicker/index.d.ts.map +1 -1
  50. package/dist/components/DatePicker/index.js +124 -120
  51. package/dist/components/DatePicker/index.js.map +1 -1
  52. package/dist/components/DatePicker/style.css +15 -1
  53. package/dist/components/EntryPicker/index.cjs +1 -1
  54. package/dist/components/EntryPicker/index.cjs.map +1 -1
  55. package/dist/components/EntryPicker/index.d.cts +3 -2
  56. package/dist/components/EntryPicker/index.d.cts.map +1 -1
  57. package/dist/components/EntryPicker/index.d.ts +3 -2
  58. package/dist/components/EntryPicker/index.d.ts.map +1 -1
  59. package/dist/components/EntryPicker/index.js +39 -46
  60. package/dist/components/EntryPicker/index.js.map +1 -1
  61. package/dist/components/EntryPicker/style.css +0 -11
  62. package/dist/components/Field/binding.d.cts +18 -0
  63. package/dist/components/Field/binding.d.cts.map +1 -0
  64. package/dist/components/Field/binding.d.ts +18 -0
  65. package/dist/components/Field/binding.d.ts.map +1 -0
  66. package/dist/components/Field/context.d.cts +9 -0
  67. package/dist/components/Field/context.d.cts.map +1 -0
  68. package/dist/components/Field/context.d.ts +9 -0
  69. package/dist/components/Field/context.d.ts.map +1 -0
  70. package/dist/components/Field/frame.d.cts +12 -0
  71. package/dist/components/Field/frame.d.cts.map +1 -0
  72. package/dist/components/Field/frame.d.ts +12 -0
  73. package/dist/components/Field/frame.d.ts.map +1 -0
  74. package/dist/components/Field/group.d.cts +12 -0
  75. package/dist/components/Field/group.d.cts.map +1 -0
  76. package/dist/components/Field/group.d.ts +12 -0
  77. package/dist/components/Field/group.d.ts.map +1 -0
  78. package/dist/components/Field/index.cjs +1 -1
  79. package/dist/components/Field/index.cjs.map +1 -1
  80. package/dist/components/Field/index.d.cts +4 -22
  81. package/dist/components/Field/index.d.cts.map +1 -1
  82. package/dist/components/Field/index.d.ts +4 -22
  83. package/dist/components/Field/index.d.ts.map +1 -1
  84. package/dist/components/Field/index.js +5 -42
  85. package/dist/components/Field/index.js.map +1 -1
  86. package/dist/components/Field/style.css +5 -0
  87. package/dist/components/Field/types.d.cts +31 -0
  88. package/dist/components/Field/types.d.cts.map +1 -0
  89. package/dist/components/Field/types.d.ts +31 -0
  90. package/dist/components/Field/types.d.ts.map +1 -0
  91. package/dist/components/FormEditor/control.d.cts +5 -3
  92. package/dist/components/FormEditor/control.d.cts.map +1 -1
  93. package/dist/components/FormEditor/control.d.ts +5 -3
  94. package/dist/components/FormEditor/control.d.ts.map +1 -1
  95. package/dist/components/FormEditor/index.cjs +1 -1
  96. package/dist/components/FormEditor/index.d.cts.map +1 -1
  97. package/dist/components/FormEditor/index.d.ts.map +1 -1
  98. package/dist/components/FormEditor/index.js +1 -1
  99. package/dist/components/FormEditor/model.d.cts +8 -5
  100. package/dist/components/FormEditor/model.d.cts.map +1 -1
  101. package/dist/components/FormEditor/model.d.ts +8 -5
  102. package/dist/components/FormEditor/model.d.ts.map +1 -1
  103. package/dist/components/ImageCropper/index.cjs +1 -1
  104. package/dist/components/ImageCropper/index.cjs.map +1 -1
  105. package/dist/components/ImageCropper/index.d.cts.map +1 -1
  106. package/dist/components/ImageCropper/index.d.ts.map +1 -1
  107. package/dist/components/ImageCropper/index.js +113 -112
  108. package/dist/components/ImageCropper/index.js.map +1 -1
  109. package/dist/components/NumberField/index.cjs +1 -1
  110. package/dist/components/NumberField/index.cjs.map +1 -1
  111. package/dist/components/NumberField/index.d.cts +4 -3
  112. package/dist/components/NumberField/index.d.cts.map +1 -1
  113. package/dist/components/NumberField/index.d.ts +4 -3
  114. package/dist/components/NumberField/index.d.ts.map +1 -1
  115. package/dist/components/NumberField/index.js +57 -53
  116. package/dist/components/NumberField/index.js.map +1 -1
  117. package/dist/components/NumberField/style.css +16 -1
  118. package/dist/components/RichTextEditor/index.cjs +1 -1
  119. package/dist/components/RichTextEditor/index.d.cts +3 -7
  120. package/dist/components/RichTextEditor/index.d.cts.map +1 -1
  121. package/dist/components/RichTextEditor/index.d.ts +3 -7
  122. package/dist/components/RichTextEditor/index.d.ts.map +1 -1
  123. package/dist/components/RichTextEditor/index.js +1 -1
  124. package/dist/components/Select/index.cjs +1 -1
  125. package/dist/components/Select/index.cjs.map +1 -1
  126. package/dist/components/Select/index.d.cts +1 -0
  127. package/dist/components/Select/index.d.cts.map +1 -1
  128. package/dist/components/Select/index.d.ts +1 -0
  129. package/dist/components/Select/index.d.ts.map +1 -1
  130. package/dist/components/Select/index.js +53 -52
  131. package/dist/components/Select/index.js.map +1 -1
  132. package/dist/components/SelectionCard/index.cjs +1 -1
  133. package/dist/components/SelectionCard/index.cjs.map +1 -1
  134. package/dist/components/SelectionCard/index.d.cts +3 -2
  135. package/dist/components/SelectionCard/index.d.cts.map +1 -1
  136. package/dist/components/SelectionCard/index.d.ts +3 -2
  137. package/dist/components/SelectionCard/index.d.ts.map +1 -1
  138. package/dist/components/SelectionCard/index.js +28 -28
  139. package/dist/components/SelectionCard/index.js.map +1 -1
  140. package/dist/components/SelectionCard/style.css +1 -8
  141. package/dist/components/Slider/index.cjs +1 -1
  142. package/dist/components/Slider/index.cjs.map +1 -1
  143. package/dist/components/Slider/index.d.cts +3 -2
  144. package/dist/components/Slider/index.d.cts.map +1 -1
  145. package/dist/components/Slider/index.d.ts +3 -2
  146. package/dist/components/Slider/index.d.ts.map +1 -1
  147. package/dist/components/Slider/index.js +60 -56
  148. package/dist/components/Slider/index.js.map +1 -1
  149. package/dist/components/Slider/style.css +14 -0
  150. package/dist/components/Switch/index.cjs +1 -1
  151. package/dist/components/Switch/index.cjs.map +1 -1
  152. package/dist/components/Switch/index.d.cts +2 -0
  153. package/dist/components/Switch/index.d.cts.map +1 -1
  154. package/dist/components/Switch/index.d.ts +2 -0
  155. package/dist/components/Switch/index.d.ts.map +1 -1
  156. package/dist/components/Switch/index.js +13 -12
  157. package/dist/components/Switch/index.js.map +1 -1
  158. package/dist/components/Switch/style.css +4 -0
  159. package/dist/components/TagsInput/index.cjs +1 -1
  160. package/dist/components/TagsInput/index.cjs.map +1 -1
  161. package/dist/components/TagsInput/index.d.cts +2 -5
  162. package/dist/components/TagsInput/index.d.cts.map +1 -1
  163. package/dist/components/TagsInput/index.d.ts +2 -5
  164. package/dist/components/TagsInput/index.d.ts.map +1 -1
  165. package/dist/components/TagsInput/index.js +19 -17
  166. package/dist/components/TagsInput/index.js.map +1 -1
  167. package/dist/index.cjs +1 -1
  168. package/dist/index.d.cts +1 -1
  169. package/dist/index.d.cts.map +1 -1
  170. package/dist/index.d.ts +1 -1
  171. package/dist/index.d.ts.map +1 -1
  172. package/dist/index.js +7 -7
  173. package/dist/styles.css +1 -1
  174. package/package.json +1 -1
  175. package/dist/chunks/FormEditor-8bz3pOdP.cjs +0 -2
  176. package/dist/chunks/FormEditor-8bz3pOdP.cjs.map +0 -1
  177. package/dist/chunks/FormEditor-DuW8x78Y.js.map +0 -1
  178. package/dist/chunks/RichTextEditor-BxtlbjXj.cjs.map +0 -1
  179. package/dist/chunks/RichTextEditor-Dnx4i7bQ.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["useId","_Fragment","react","react_jsx_runtime","Field","id","hintId","errorId","describedBy","error","hint","labelId","Wrapper","isGroup","labelContent","label","isRequired","children"],"sources":["../../../src/components/Field/index.tsx"],"sourcesContent":["import { useId, type ReactNode } from \"react\";\nimport \"../Field/style.css\";\n\nexport type FieldSize = \"sm\" | \"md\" | \"lg\";\n\nexport interface FieldProps {\n label: string;\n /** Supporting text or inline content, hidden while an error is present. */\n hint?: ReactNode;\n /** Present means invalid: the message renders and the control is marked. */\n error?: string;\n isRequired?: boolean;\n /** Use a legend for a field containing a group of controls. */\n isGroup?: boolean;\n /** Receives the ids and invalid flag the control must carry. */\n children: (props: {\n id: string;\n \"aria-describedby\"?: string;\n \"aria-labelledby\": string;\n \"aria-invalid\"?: true;\n required?: boolean;\n }) => ReactNode;\n}\n\n/** Label, hint, error and required marker around any control wearing the field skin. */\nexport function Field({ label, hint, error, isRequired, isGroup = false, children }: FieldProps) {\n const id = useId();\n const hintId = `${id}-hint`;\n const errorId = `${id}-error`;\n const describedBy = error ? errorId : hint ? hintId : undefined;\n const labelId = `${id}-label`;\n const Wrapper = isGroup ? \"fieldset\" : \"div\";\n const labelContent = (\n <>\n {label}\n {isRequired && (\n <span\n className=\"ds-field__required\"\n aria-hidden=\"true\"\n >\n *\n </span>\n )}\n </>\n );\n\n return (\n <Wrapper className=\"ds-field\">\n {isGroup ? (\n <legend\n id={labelId}\n className=\"ds-field__label\"\n >\n {labelContent}\n </legend>\n ) : (\n <label\n id={labelId}\n className=\"ds-field__label\"\n htmlFor={id}\n >\n {labelContent}\n </label>\n )}\n {children({\n id,\n \"aria-describedby\": describedBy,\n \"aria-labelledby\": labelId,\n \"aria-invalid\": error ? true : undefined,\n required: isRequired,\n })}\n {hint && !error ? (\n <span\n className=\"ds-field__hint\"\n id={hintId}\n >\n {hint}\n </span>\n ) : null}\n {error && (\n <span\n className=\"ds-field__error\"\n id={errorId}\n >\n {error}\n </span>\n )}\n </Wrapper>\n );\n}\n"],"mappings":"A,oKAyBA,SAAgBI,EAAM,CAAE,QAAO,OAAM,QAAO,aAAY,UAAU,GAAO,YAAwB,CAC/F,IAAMC,GAAA,EAAKL,EAAAA,MAAAA,CAAM,EACXM,EAAS,GAAGD,EAAG,OACfE,EAAU,GAAGF,EAAG,QAChBG,EAAcC,EAAQF,EAAUG,EAAOJ,EAAS,IAAA,GAChDK,EAAU,GAAGN,EAAG,QAChBO,EAAUC,EAAU,WAAa,MACjCC,GACJ,EAAAX,EAAA,KAAA,CAAAF,EAAAA,SAAA,CAAA,SAAA,CACGc,EACAC,IACC,EAAAb,EAAA,IAAA,CAAC,OAAD,CACE,UAAU,qBACV,cAAY,OACb,SAAA,GAEK,CAAA,CAER,CAAA,CAAA,EAGJ,OACE,EAAAA,EAAA,KAAA,CAACS,EAAD,CAAS,UAAU,WAAnB,SAAA,CACGC,GACC,EAAAV,EAAA,IAAA,CAAC,SAAD,CACE,GAAIQ,EACJ,UAAU,kBAET,SAAAG,CACK,CAAA,GAER,EAAAX,EAAA,IAAA,CAAC,QAAD,CACE,GAAIQ,EACJ,UAAU,kBACV,QAASN,EAER,SAAAS,CACI,CAAA,EAERG,EAAS,CACR,KACA,mBAAoBT,EACpB,kBAAmBG,EACnB,eAAgBF,EAAQ,GAAO,IAAA,GAC/B,SAAUO,CACZ,CAAC,EACAN,GAAQ,CAACD,GACR,EAAAN,EAAA,IAAA,CAAC,OAAD,CACE,UAAU,iBACV,GAAIG,EAEH,SAAAI,CACG,CAAA,EACJ,KACHD,IACC,EAAAN,EAAA,IAAA,CAAC,OAAD,CACE,UAAU,kBACV,GAAII,EAEH,SAAAE,CACG,CAAA,CAED,C,EAEb,C"}
1
+ {"version":3,"file":"index.cjs","names":["FieldFrame","require_frame","react_jsx_runtime","Field","props"],"sources":["../../../src/components/Field/index.tsx"],"sourcesContent":["import { FieldFrame } from \"./frame\";\nimport type { FieldProps } from \"./types\";\n\nexport type { FieldBinding, FieldProps, FieldRenderProps, FieldSize } from \"./types\";\n\n/** Label, count, hint, error and required marker around a control or group. */\nexport function Field(props: FieldProps) {\n return <FieldFrame {...props} />;\n}\n"],"mappings":"A,yJAMA,SAAgBG,EAAM,EAAmB,CACvC,OAAO,EAAAD,EAAA,IAAA,CAACF,EAAAA,EAAD,CAAY,GAAII,CAAQ,CAAA,CACjC,C"}
@@ -1,23 +1,5 @@
1
- import { type ReactNode } from "react";
2
- export type FieldSize = "sm" | "md" | "lg";
3
- export interface FieldProps {
4
- label: string;
5
- /** Supporting text or inline content, hidden while an error is present. */
6
- hint?: ReactNode;
7
- /** Present means invalid: the message renders and the control is marked. */
8
- error?: string;
9
- isRequired?: boolean;
10
- /** Use a legend for a field containing a group of controls. */
11
- isGroup?: boolean;
12
- /** Receives the ids and invalid flag the control must carry. */
13
- children: (props: {
14
- id: string;
15
- "aria-describedby"?: string;
16
- "aria-labelledby": string;
17
- "aria-invalid"?: true;
18
- required?: boolean;
19
- }) => ReactNode;
20
- }
21
- /** Label, hint, error and required marker around any control wearing the field skin. */
22
- export declare function Field({ label, hint, error, isRequired, isGroup, children }: FieldProps): import("react").JSX.Element;
1
+ import type { FieldProps } from "./types.cjs";
2
+ export type { FieldBinding, FieldProps, FieldRenderProps, FieldSize } from "./types.cjs";
3
+ /** Label, count, hint, error and required marker around a control or group. */
4
+ export declare function Field(props: FieldProps): import("react").JSX.Element;
23
5
  //# sourceMappingURL=index.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../../src/components/Field/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAS,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAC9C,OAAO,oBAAoB,CAAC;AAE5B,MAAM,MAAM,SAAS,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAE3C,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,2EAA2E;IAC3E,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,4EAA4E;IAC5E,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,+DAA+D;IAC/D,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,gEAAgE;IAChE,QAAQ,EAAE,CAAC,KAAK,EAAE;QAChB,EAAE,EAAE,MAAM,CAAC;QACX,kBAAkB,CAAC,EAAE,MAAM,CAAC;QAC5B,iBAAiB,EAAE,MAAM,CAAC;QAC1B,cAAc,CAAC,EAAE,IAAI,CAAC;QACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;KACpB,KAAK,SAAS,CAAC;CACjB;AAED,wFAAwF;AACxF,wBAAgB,KAAK,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,UAAU,EAAE,OAAe,EAAE,QAAQ,EAAE,EAAE,UAAU,+BAgE9F"}
1
+ {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../../src/components/Field/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE1C,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAErF,+EAA+E;AAC/E,wBAAgB,KAAK,CAAC,KAAK,EAAE,UAAU,+BAEtC"}
@@ -1,23 +1,5 @@
1
- import { type ReactNode } from "react";
2
- export type FieldSize = "sm" | "md" | "lg";
3
- export interface FieldProps {
4
- label: string;
5
- /** Supporting text or inline content, hidden while an error is present. */
6
- hint?: ReactNode;
7
- /** Present means invalid: the message renders and the control is marked. */
8
- error?: string;
9
- isRequired?: boolean;
10
- /** Use a legend for a field containing a group of controls. */
11
- isGroup?: boolean;
12
- /** Receives the ids and invalid flag the control must carry. */
13
- children: (props: {
14
- id: string;
15
- "aria-describedby"?: string;
16
- "aria-labelledby": string;
17
- "aria-invalid"?: true;
18
- required?: boolean;
19
- }) => ReactNode;
20
- }
21
- /** Label, hint, error and required marker around any control wearing the field skin. */
22
- export declare function Field({ label, hint, error, isRequired, isGroup, children }: FieldProps): import("react").JSX.Element;
1
+ import type { FieldProps } from "./types.js";
2
+ export type { FieldBinding, FieldProps, FieldRenderProps, FieldSize } from "./types.js";
3
+ /** Label, count, hint, error and required marker around a control or group. */
4
+ export declare function Field(props: FieldProps): import("react").JSX.Element;
23
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Field/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAS,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAC9C,OAAO,oBAAoB,CAAC;AAE5B,MAAM,MAAM,SAAS,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAE3C,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,2EAA2E;IAC3E,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,4EAA4E;IAC5E,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,+DAA+D;IAC/D,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,gEAAgE;IAChE,QAAQ,EAAE,CAAC,KAAK,EAAE;QAChB,EAAE,EAAE,MAAM,CAAC;QACX,kBAAkB,CAAC,EAAE,MAAM,CAAC;QAC5B,iBAAiB,EAAE,MAAM,CAAC;QAC1B,cAAc,CAAC,EAAE,IAAI,CAAC;QACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;KACpB,KAAK,SAAS,CAAC;CACjB;AAED,wFAAwF;AACxF,wBAAgB,KAAK,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,UAAU,EAAE,OAAe,EAAE,QAAQ,EAAE,EAAE,UAAU,+BAgE9F"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Field/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE1C,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAErF,+EAA+E;AAC/E,wBAAgB,KAAK,CAAC,KAAK,EAAE,UAAU,+BAEtC"}
@@ -1,47 +1,10 @@
1
- /* empty css */
2
- import { useId as e } from "react";
3
- import { Fragment as t, jsx as n, jsxs as r } from "react/jsx-runtime";
1
+ import { t as e } from "../../chunks/frame-Bs_jaQRw.js";
2
+ import { jsx as t } from "react/jsx-runtime";
4
3
  //#region src/components/Field/index.tsx
5
- function i({ label: i, hint: a, error: o, isRequired: s, isGroup: c = !1, children: l }) {
6
- let u = e(), d = `${u}-hint`, f = `${u}-error`, p = o ? f : a ? d : void 0, m = `${u}-label`, h = c ? "fieldset" : "div", g = /* @__PURE__ */ r(t, { children: [i, s && /* @__PURE__ */ n("span", {
7
- className: "ds-field__required",
8
- "aria-hidden": "true",
9
- children: "*"
10
- })] });
11
- return /* @__PURE__ */ r(h, {
12
- className: "ds-field",
13
- children: [
14
- c ? /* @__PURE__ */ n("legend", {
15
- id: m,
16
- className: "ds-field__label",
17
- children: g
18
- }) : /* @__PURE__ */ n("label", {
19
- id: m,
20
- className: "ds-field__label",
21
- htmlFor: u,
22
- children: g
23
- }),
24
- l({
25
- id: u,
26
- "aria-describedby": p,
27
- "aria-labelledby": m,
28
- "aria-invalid": o ? !0 : void 0,
29
- required: s
30
- }),
31
- a && !o ? /* @__PURE__ */ n("span", {
32
- className: "ds-field__hint",
33
- id: d,
34
- children: a
35
- }) : null,
36
- o && /* @__PURE__ */ n("span", {
37
- className: "ds-field__error",
38
- id: f,
39
- children: o
40
- })
41
- ]
42
- });
4
+ function n(n) {
5
+ return /* @__PURE__ */ t(e, { ...n });
43
6
  }
44
7
  //#endregion
45
- export { i as Field };
8
+ export { n as Field };
46
9
 
47
10
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["_Fragment","Fragment$1","Field","id","useId","hintId","errorId","describedBy","error","hint","labelId","Wrapper","isGroup","labelContent","label","isRequired","children"],"sources":["../../../src/components/Field/index.tsx"],"sourcesContent":["import { useId, type ReactNode } from \"react\";\nimport \"../Field/style.css\";\n\nexport type FieldSize = \"sm\" | \"md\" | \"lg\";\n\nexport interface FieldProps {\n label: string;\n /** Supporting text or inline content, hidden while an error is present. */\n hint?: ReactNode;\n /** Present means invalid: the message renders and the control is marked. */\n error?: string;\n isRequired?: boolean;\n /** Use a legend for a field containing a group of controls. */\n isGroup?: boolean;\n /** Receives the ids and invalid flag the control must carry. */\n children: (props: {\n id: string;\n \"aria-describedby\"?: string;\n \"aria-labelledby\": string;\n \"aria-invalid\"?: true;\n required?: boolean;\n }) => ReactNode;\n}\n\n/** Label, hint, error and required marker around any control wearing the field skin. */\nexport function Field({ label, hint, error, isRequired, isGroup = false, children }: FieldProps) {\n const id = useId();\n const hintId = `${id}-hint`;\n const errorId = `${id}-error`;\n const describedBy = error ? errorId : hint ? hintId : undefined;\n const labelId = `${id}-label`;\n const Wrapper = isGroup ? \"fieldset\" : \"div\";\n const labelContent = (\n <>\n {label}\n {isRequired && (\n <span\n className=\"ds-field__required\"\n aria-hidden=\"true\"\n >\n *\n </span>\n )}\n </>\n );\n\n return (\n <Wrapper className=\"ds-field\">\n {isGroup ? (\n <legend\n id={labelId}\n className=\"ds-field__label\"\n >\n {labelContent}\n </legend>\n ) : (\n <label\n id={labelId}\n className=\"ds-field__label\"\n htmlFor={id}\n >\n {labelContent}\n </label>\n )}\n {children({\n id,\n \"aria-describedby\": describedBy,\n \"aria-labelledby\": labelId,\n \"aria-invalid\": error ? true : undefined,\n required: isRequired,\n })}\n {hint && !error ? (\n <span\n className=\"ds-field__hint\"\n id={hintId}\n >\n {hint}\n </span>\n ) : null}\n {error && (\n <span\n className=\"ds-field__error\"\n id={errorId}\n >\n {error}\n </span>\n )}\n </Wrapper>\n );\n}\n"],"mappings":";;;;AAyBA,SAAgBE,EAAM,EAAE,UAAO,SAAM,UAAO,eAAY,aAAU,IAAO,eAAwB;CAC/F,IAAMC,IAAKC,EAAM,GACXC,IAAS,GAAGF,EAAG,QACfG,IAAU,GAAGH,EAAG,SAChBI,IAAcC,IAAQF,IAAUG,IAAOJ,IAAS,KAAA,GAChDK,IAAU,GAAGP,EAAG,SAChBQ,IAAUC,IAAU,aAAa,OACjCC,IACJ,kBAAAb,GAAA,EAAA,UAAA,CACGc,GACAC,KACC,kBAAC,QAAD;EACE,WAAU;EACV,eAAY;EACb,UAAA;CAEK,CAAA,CAER,EAAA,CAAA;CAGJ,OACE,kBAACJ,GAAD;EAAS,WAAU;EAAnB,UAAA;GACGC,IACC,kBAAC,UAAD;IACE,IAAIF;IACJ,WAAU;IAET,UAAAG;GACK,CAAA,IAER,kBAAC,SAAD;IACE,IAAIH;IACJ,WAAU;IACV,SAASP;IAER,UAAAU;GACI,CAAA;GAERG,EAAS;IACR;IACA,oBAAoBT;IACpB,mBAAmBG;IACnB,gBAAgBF,IAAQ,KAAO,KAAA;IAC/B,UAAUO;GACZ,CAAC;GACAN,KAAQ,CAACD,IACR,kBAAC,QAAD;IACE,WAAU;IACV,IAAIH;IAEH,UAAAI;GACG,CAAA,IACJ;GACHD,KACC,kBAAC,QAAD;IACE,WAAU;IACV,IAAIF;IAEH,UAAAE;GACG,CAAA;EAED;;AAEb"}
1
+ {"version":3,"file":"index.js","names":["FieldFrame","Field","props"],"sources":["../../../src/components/Field/index.tsx"],"sourcesContent":["import { FieldFrame } from \"./frame\";\nimport type { FieldProps } from \"./types\";\n\nexport type { FieldBinding, FieldProps, FieldRenderProps, FieldSize } from \"./types\";\n\n/** Label, count, hint, error and required marker around a control or group. */\nexport function Field(props: FieldProps) {\n return <FieldFrame {...props} />;\n}\n"],"mappings":";;;AAMA,SAAgBC,EAAM,GAAmB;CACvC,OAAO,kBAACD,GAAD,EAAY,GAAIE,EAAQ,CAAA;AACjC"}
@@ -102,6 +102,11 @@
102
102
  margin-block-end: var(--space-2);
103
103
  }
104
104
 
105
+ .ds-field__count {
106
+ margin-inline-start: var(--space-1);
107
+ vertical-align: middle;
108
+ }
109
+
105
110
  .ds-field__required {
106
111
  margin-inline-start: var(--space-1);
107
112
  color: var(--color-danger);
@@ -0,0 +1,31 @@
1
+ import type { AriaAttributes, ReactNode } from "react";
2
+ export type FieldSize = "sm" | "md" | "lg";
3
+ /** Attributes connecting a control or group to its owning Field. */
4
+ export interface FieldBinding {
5
+ /** Native controls use required; compound controls keep it off their container. */
6
+ required?: boolean;
7
+ id?: string;
8
+ "aria-label"?: string;
9
+ "aria-labelledby"?: string;
10
+ "aria-describedby"?: string;
11
+ "aria-invalid"?: AriaAttributes["aria-invalid"];
12
+ }
13
+ export interface FieldRenderProps extends FieldBinding {
14
+ id: string;
15
+ "aria-labelledby": string;
16
+ "aria-invalid"?: true;
17
+ }
18
+ export interface FieldProps {
19
+ label: string;
20
+ /** Supporting text or inline content, hidden while an error is present. */
21
+ hint?: ReactNode;
22
+ /** Present means invalid: the message renders and the control is marked. */
23
+ error?: string;
24
+ isRequired?: boolean;
25
+ /** Supplemental count badge; not part of the control's accessible name. */
26
+ count?: number;
27
+ /** Use a legend for a field containing a group of controls. */
28
+ isGroup?: boolean;
29
+ children: (props: FieldRenderProps) => ReactNode;
30
+ }
31
+ //# sourceMappingURL=types.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.cts","sourceRoot":"","sources":["../../../src/components/Field/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvD,MAAM,MAAM,SAAS,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAE3C,oEAAoE;AACpE,MAAM,WAAW,YAAY;IAC3B,mFAAmF;IACnF,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,cAAc,CAAC,EAAE,cAAc,CAAC,cAAc,CAAC,CAAC;CACjD;AAED,MAAM,WAAW,gBAAiB,SAAQ,YAAY;IACpD,EAAE,EAAE,MAAM,CAAC;IACX,iBAAiB,EAAE,MAAM,CAAC;IAC1B,cAAc,CAAC,EAAE,IAAI,CAAC;CACvB;AAED,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,2EAA2E;IAC3E,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,4EAA4E;IAC5E,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,2EAA2E;IAC3E,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,+DAA+D;IAC/D,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,CAAC,KAAK,EAAE,gBAAgB,KAAK,SAAS,CAAC;CAClD"}
@@ -0,0 +1,31 @@
1
+ import type { AriaAttributes, ReactNode } from "react";
2
+ export type FieldSize = "sm" | "md" | "lg";
3
+ /** Attributes connecting a control or group to its owning Field. */
4
+ export interface FieldBinding {
5
+ /** Native controls use required; compound controls keep it off their container. */
6
+ required?: boolean;
7
+ id?: string;
8
+ "aria-label"?: string;
9
+ "aria-labelledby"?: string;
10
+ "aria-describedby"?: string;
11
+ "aria-invalid"?: AriaAttributes["aria-invalid"];
12
+ }
13
+ export interface FieldRenderProps extends FieldBinding {
14
+ id: string;
15
+ "aria-labelledby": string;
16
+ "aria-invalid"?: true;
17
+ }
18
+ export interface FieldProps {
19
+ label: string;
20
+ /** Supporting text or inline content, hidden while an error is present. */
21
+ hint?: ReactNode;
22
+ /** Present means invalid: the message renders and the control is marked. */
23
+ error?: string;
24
+ isRequired?: boolean;
25
+ /** Supplemental count badge; not part of the control's accessible name. */
26
+ count?: number;
27
+ /** Use a legend for a field containing a group of controls. */
28
+ isGroup?: boolean;
29
+ children: (props: FieldRenderProps) => ReactNode;
30
+ }
31
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/Field/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvD,MAAM,MAAM,SAAS,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAE3C,oEAAoE;AACpE,MAAM,WAAW,YAAY;IAC3B,mFAAmF;IACnF,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,cAAc,CAAC,EAAE,cAAc,CAAC,cAAc,CAAC,CAAC;CACjD;AAED,MAAM,WAAW,gBAAiB,SAAQ,YAAY;IACpD,EAAE,EAAE,MAAM,CAAC;IACX,iBAAiB,EAAE,MAAM,CAAC;IAC1B,cAAc,CAAC,EAAE,IAAI,CAAC;CACvB;AAED,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,2EAA2E;IAC3E,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,4EAA4E;IAC5E,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,2EAA2E;IAC3E,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,+DAA+D;IAC/D,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,CAAC,KAAK,EAAE,gBAAgB,KAAK,SAAS,CAAC;CAClD"}
@@ -1,15 +1,17 @@
1
1
  import { type EntryItem } from "../EntryPicker/index.cjs";
2
- import type { FieldProps } from "../Field/index.cjs";
2
+ import type { FieldRenderProps } from "../Field/index.cjs";
3
3
  import { type FormField, type FormFieldValue } from "./model.cjs";
4
- type Accessibility = Parameters<FieldProps["children"]>[0];
4
+ type Accessibility = FieldRenderProps;
5
5
  interface FormControlProps {
6
6
  field: FormField;
7
7
  stored: FormFieldValue | undefined;
8
+ /** Picker fields' stored IDs, derived once by the owning field. */
9
+ selected: string[] | undefined;
8
10
  items: EntryItem[];
9
11
  isDisabled: boolean;
10
12
  accessibility: Accessibility;
11
13
  onChange: (value: FormFieldValue | undefined) => void;
12
14
  }
13
- export declare function FormControl({ field, stored, items, isDisabled, accessibility: { required, ...accessibility }, onChange, }: FormControlProps): import("react").JSX.Element;
15
+ export declare function FormControl({ field, stored, selected, items, isDisabled, accessibility: { required, ...accessibility }, onChange, }: FormControlProps): import("react").JSX.Element;
14
16
  export {};
15
17
  //# sourceMappingURL=control.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"control.d.cts","sourceRoot":"","sources":["../../../src/components/FormEditor/control.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAe,KAAK,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAO3C,OAAO,EAIL,KAAK,SAAS,EACd,KAAK,cAAc,EACpB,MAAM,SAAS,CAAC;AAqBjB,KAAK,aAAa,GAAG,UAAU,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AA8F3D,UAAU,gBAAgB;IACxB,KAAK,EAAE,SAAS,CAAC;IACjB,MAAM,EAAE,cAAc,GAAG,SAAS,CAAC;IACnC,KAAK,EAAE,SAAS,EAAE,CAAC;IACnB,UAAU,EAAE,OAAO,CAAC;IACpB,aAAa,EAAE,aAAa,CAAC;IAC7B,QAAQ,EAAE,CAAC,KAAK,EAAE,cAAc,GAAG,SAAS,KAAK,IAAI,CAAC;CACvD;AAED,wBAAgB,WAAW,CAAC,EAC1B,KAAK,EACL,MAAM,EACN,KAAK,EACL,UAAU,EACV,aAAa,EAAE,EAAE,QAAQ,EAAE,GAAG,aAAa,EAAE,EAC7C,QAAQ,GACT,EAAE,gBAAgB,+BA6FlB"}
1
+ {"version":3,"file":"control.d.cts","sourceRoot":"","sources":["../../../src/components/FormEditor/control.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAe,KAAK,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAOjD,OAAO,EAIL,KAAK,SAAS,EACd,KAAK,cAAc,EACpB,MAAM,SAAS,CAAC;AAWjB,KAAK,aAAa,GAAG,gBAAgB,CAAC;AA0FtC,UAAU,gBAAgB;IACxB,KAAK,EAAE,SAAS,CAAC;IACjB,MAAM,EAAE,cAAc,GAAG,SAAS,CAAC;IACnC,mEAAmE;IACnE,QAAQ,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;IAC/B,KAAK,EAAE,SAAS,EAAE,CAAC;IACnB,UAAU,EAAE,OAAO,CAAC;IACpB,aAAa,EAAE,aAAa,CAAC;IAC7B,QAAQ,EAAE,CAAC,KAAK,EAAE,cAAc,GAAG,SAAS,KAAK,IAAI,CAAC;CACvD;AAED,wBAAgB,WAAW,CAAC,EAC1B,KAAK,EACL,MAAM,EACN,QAAQ,EACR,KAAK,EACL,UAAU,EACV,aAAa,EAAE,EAAE,QAAQ,EAAE,GAAG,aAAa,EAAE,EAC7C,QAAQ,GACT,EAAE,gBAAgB,+BA8FlB"}
@@ -1,15 +1,17 @@
1
1
  import { type EntryItem } from "../EntryPicker/index.js";
2
- import type { FieldProps } from "../Field/index.js";
2
+ import type { FieldRenderProps } from "../Field/index.js";
3
3
  import { type FormField, type FormFieldValue } from "./model.js";
4
- type Accessibility = Parameters<FieldProps["children"]>[0];
4
+ type Accessibility = FieldRenderProps;
5
5
  interface FormControlProps {
6
6
  field: FormField;
7
7
  stored: FormFieldValue | undefined;
8
+ /** Picker fields' stored IDs, derived once by the owning field. */
9
+ selected: string[] | undefined;
8
10
  items: EntryItem[];
9
11
  isDisabled: boolean;
10
12
  accessibility: Accessibility;
11
13
  onChange: (value: FormFieldValue | undefined) => void;
12
14
  }
13
- export declare function FormControl({ field, stored, items, isDisabled, accessibility: { required, ...accessibility }, onChange, }: FormControlProps): import("react").JSX.Element;
15
+ export declare function FormControl({ field, stored, selected, items, isDisabled, accessibility: { required, ...accessibility }, onChange, }: FormControlProps): import("react").JSX.Element;
14
16
  export {};
15
17
  //# sourceMappingURL=control.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"control.d.ts","sourceRoot":"","sources":["../../../src/components/FormEditor/control.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAe,KAAK,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAO3C,OAAO,EAIL,KAAK,SAAS,EACd,KAAK,cAAc,EACpB,MAAM,SAAS,CAAC;AAqBjB,KAAK,aAAa,GAAG,UAAU,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AA8F3D,UAAU,gBAAgB;IACxB,KAAK,EAAE,SAAS,CAAC;IACjB,MAAM,EAAE,cAAc,GAAG,SAAS,CAAC;IACnC,KAAK,EAAE,SAAS,EAAE,CAAC;IACnB,UAAU,EAAE,OAAO,CAAC;IACpB,aAAa,EAAE,aAAa,CAAC;IAC7B,QAAQ,EAAE,CAAC,KAAK,EAAE,cAAc,GAAG,SAAS,KAAK,IAAI,CAAC;CACvD;AAED,wBAAgB,WAAW,CAAC,EAC1B,KAAK,EACL,MAAM,EACN,KAAK,EACL,UAAU,EACV,aAAa,EAAE,EAAE,QAAQ,EAAE,GAAG,aAAa,EAAE,EAC7C,QAAQ,GACT,EAAE,gBAAgB,+BA6FlB"}
1
+ {"version":3,"file":"control.d.ts","sourceRoot":"","sources":["../../../src/components/FormEditor/control.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAe,KAAK,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAOjD,OAAO,EAIL,KAAK,SAAS,EACd,KAAK,cAAc,EACpB,MAAM,SAAS,CAAC;AAWjB,KAAK,aAAa,GAAG,gBAAgB,CAAC;AA0FtC,UAAU,gBAAgB;IACxB,KAAK,EAAE,SAAS,CAAC;IACjB,MAAM,EAAE,cAAc,GAAG,SAAS,CAAC;IACnC,mEAAmE;IACnE,QAAQ,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;IAC/B,KAAK,EAAE,SAAS,EAAE,CAAC;IACnB,UAAU,EAAE,OAAO,CAAC;IACpB,aAAa,EAAE,aAAa,CAAC;IAC7B,QAAQ,EAAE,CAAC,KAAK,EAAE,cAAc,GAAG,SAAS,KAAK,IAAI,CAAC;CACvD;AAED,wBAAgB,WAAW,CAAC,EAC1B,KAAK,EACL,MAAM,EACN,QAAQ,EACR,KAAK,EACL,UAAU,EACV,aAAa,EAAE,EAAE,QAAQ,EAAE,GAAG,aAAa,EAAE,EAC7C,QAAQ,GACT,EAAE,gBAAgB,+BA8FlB"}
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require("../Field/index.cjs");const e=require("../../chunks/FormEditor-8bz3pOdP.cjs");exports.FormEditor=e.t,exports.validateFormValues=e.n;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require("../Field/index.cjs");const e=require("../../chunks/FormEditor-PVkvKep1.cjs");exports.FormEditor=e.t,exports.validateFormValues=e.n;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../../src/components/FormEditor/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAyC,KAAK,cAAc,EAAE,MAAM,OAAO,CAAC;AACnF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBA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wBAAgB,UAAU,CAAC,EACzB,MAAM,EACN,KAAK,EACL,YAAiB,EACjB,aAAa,EACb,WAAgB,EAChB,MAAW,EACX,UAAkB,EAClB,aAAqB,EACrB,OAAW,EACX,cAAwB,EACxB,SAAS,EACT,KAAK,EACL,GAAG,IAAI,EACR,EAAE,eAAe,+BAsDjB"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/FormEditor/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAyC,KAAK,cAAc,EAAE,MAAM,OAAO,CAAC;AACnF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C,OAAO,EAIL,KAAK,UAAU,EACf,KAAK,UAAU,EAEf,KAAK,UAAU,EAChB,MAAM,SAAS,CAAC;AACjB,OAAO,aAAa,CAAC;AAErB,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAC7C,YAAY,EACV,UAAU,EACV,SAAS,EACT,UAAU,EACV,UAAU,EACV,cAAc,EACd,UAAU,EACV,cAAc,GACf,MAAM,SAAS,CAAC;AAEjB,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,eAAgB,SAAQ,IAAI,CAC3C,cAAc,CAAC,cAAc,CAAC,EAC9B,cAAc,GAAG,UAAU,CAC5B;IACC,MAAM,EAAE,UAAU,CAAC;IACnB,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,YAAY,CAAC,EAAE,UAAU,CAAC;IAC1B,aAAa,CAAC,EAAE,CAAC,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,KAAK,IAAI,CAAC;IACjE,kFAAkF;IAClF,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC;IAC1C,sEAAsE;IACtE,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,0GAA0G;IAC1G,OAAO,CAAC,EAAE,WAAW,CAAC;IACtB,gEAAgE;IAChE,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAiDD,qFAAqF;AACrF,wBAAgB,UAAU,CAAC,EACzB,MAAM,EACN,KAAK,EACL,YAAiB,EACjB,aAAa,EACb,WAAgB,EAChB,MAAW,EACX,UAAkB,EAClB,aAAqB,EACrB,OAAW,EACX,cAAwB,EACxB,SAAS,EACT,KAAK,EACL,GAAG,IAAI,EACR,EAAE,eAAe,+BAsDjB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/FormEditor/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAyC,KAAK,cAAc,EAAE,MAAM,OAAO,CAAC;AACnF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C,OAAO,EAML,KAAK,UAAU,EACf,KAAK,UAAU,EAEf,KAAK,UAAU,EAChB,MAAM,SAAS,CAAC;AACjB,OAAO,aAAa,CAAC;AAErB,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAC7C,YAAY,EACV,UAAU,EACV,SAAS,EACT,UAAU,EACV,UAAU,EACV,cAAc,EACd,UAAU,EACV,cAAc,GACf,MAAM,SAAS,CAAC;AAEjB,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,eAAgB,SAAQ,IAAI,CAC3C,cAAc,CAAC,cAAc,CAAC,EAC9B,cAAc,GAAG,UAAU,CAC5B;IACC,MAAM,EAAE,UAAU,CAAC;IACnB,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,YAAY,CAAC,EAAE,UAAU,CAAC;IAC1B,aAAa,CAAC,EAAE,CAAC,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,KAAK,IAAI,CAAC;IACjE,kFAAkF;IAClF,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC;IAC1C,sEAAsE;IACtE,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,0GAA0G;IAC1G,OAAO,CAAC,EAAE,WAAW,CAAC;IACtB,gEAAgE;IAChE,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAuDD,qFAAqF;AACrF,wBAAgB,UAAU,CAAC,EACzB,MAAM,EACN,KAAK,EACL,YAAiB,EACjB,aAAa,EACb,WAAgB,EAChB,MAAW,EACX,UAAkB,EAClB,aAAqB,EACrB,OAAW,EACX,cAAwB,EACxB,SAAS,EACT,KAAK,EACL,GAAG,IAAI,EACR,EAAE,eAAe,+BAsDjB"}
@@ -1,2 +1,2 @@
1
1
  import "../Field/index.js";
2
- export { t as FormEditor, n as validateFormValues } from "../../chunks/FormEditor-DuW8x78Y.js";
2
+ export { t as FormEditor, n as validateFormValues } from "../../chunks/FormEditor-DRmPFe2E.js";
@@ -67,16 +67,19 @@ export type FormFieldValue = string | number | boolean | RichTextDocument | Asse
67
67
  export type FormValues = Record<string, FormFieldValue | undefined>;
68
68
  export type FormErrors = Partial<Record<string, string>>;
69
69
  export declare function assertModel(model: FormSchema): void;
70
- /** Picker copy, with asset or entry wording for any option the field leaves out or sets to undefined. */
70
+ /** The field's visible and accessible name. A picker's `label` overrides it. */
71
+ export declare function fieldLabel(field: FormField): string;
72
+ /** Picker action and item copy, with asset or entry wording for any option left out or undefined. */
71
73
  export declare function pickerCopy(field: FieldOf<"asset" | "reference">): {
72
- label: string;
73
74
  addLabel: string;
75
+ emptyLabel: string | undefined;
74
76
  itemLabel: string;
75
77
  itemsLabel: string;
76
- max?: number | undefined;
77
- emptyLabel?: string | undefined;
78
- isReorderable?: boolean | undefined;
78
+ max: number | undefined;
79
+ isReorderable: boolean | undefined;
79
80
  };
81
+ /** The picked IDs, in stored order, skipping anything that isn't a link. */
82
+ export declare function selectedIds(field: FieldOf<"asset" | "reference">, value: unknown): string[];
80
83
  /** Accept UTC ISO strings without rolling invalid dates into the next month. */
81
84
  export declare function parseUtcDateTime(value: unknown): string | undefined;
82
85
  export declare function fieldError(field: FormField, value: unknown): string | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"model.d.cts","sourceRoot":"","sources":["../../../src/components/FormEditor/model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAGvD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAE1D,UAAU,aAAa;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,MAAM,MAAM,SAAS,GAAG,aAAa,GACnC,CACI;IACE,IAAI,EAAE,WAAW,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,KAAK,CAAC;CAClB,GACD;IACE,IAAI,EAAE,UAAU,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,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AqG;AACrG,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,CAAC,OAAO,GAAG,WAAW,CAAC;;;;;;;EAW/D;AAED,4EAA4E;AAC5E,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,CAAC,OAAO,GAAG,WAAW,CAAC,EAAE,KAAK,EAAE,OAAO,GAAG,MAAM,EAAE,CAM3F;AAED,gFAAgF;AAChF,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CASnE;AAsFD,wBAAgB,UAAU,CAAC,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAG/E;AAED,8EAA8E;AAC9E,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,UAAU,CAWjG"}
@@ -67,16 +67,19 @@ export type FormFieldValue = string | number | boolean | RichTextDocument | Asse
67
67
  export type FormValues = Record<string, FormFieldValue | undefined>;
68
68
  export type FormErrors = Partial<Record<string, string>>;
69
69
  export declare function assertModel(model: FormSchema): void;
70
- /** Picker copy, with asset or entry wording for any option the field leaves out or sets to undefined. */
70
+ /** The field's visible and accessible name. A picker's `label` overrides it. */
71
+ export declare function fieldLabel(field: FormField): string;
72
+ /** Picker action and item copy, with asset or entry wording for any option left out or undefined. */
71
73
  export declare function pickerCopy(field: FieldOf<"asset" | "reference">): {
72
- label: string;
73
74
  addLabel: string;
75
+ emptyLabel: string | undefined;
74
76
  itemLabel: string;
75
77
  itemsLabel: string;
76
- max?: number | undefined;
77
- emptyLabel?: string | undefined;
78
- isReorderable?: boolean | undefined;
78
+ max: number | undefined;
79
+ isReorderable: boolean | undefined;
79
80
  };
81
+ /** The picked IDs, in stored order, skipping anything that isn't a link. */
82
+ export declare function selectedIds(field: FieldOf<"asset" | "reference">, value: unknown): string[];
80
83
  /** Accept UTC ISO strings without rolling invalid dates into the next month. */
81
84
  export declare function parseUtcDateTime(value: unknown): string | undefined;
82
85
  export declare function fieldError(field: FormField, value: unknown): string | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../../src/components/FormEditor/model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAGvD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAE1D,UAAU,aAAa;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,MAAM,MAAM,SAAS,GAAG,aAAa,GACnC,CACI;IACE,IAAI,EAAE,WAAW,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,KAAK,CAAC;CAClB,GACD;IACE,IAAI,EAAE,UAAU,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,KAAK,CAAC;CAClB,GACD;IAAE,IAAI,EAAE,SAAS,GAAG,UAAU,CAAC;IAAC,SAAS,CAAC,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,EAAE,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,GAAG,MAAM,EAAE,CAM3F;AAED,gFAAgF;AAChF,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CASnE;AAsFD,wBAAgB,UAAU,CAAC,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAG/E;AAED,8EAA8E;AAC9E,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,UAAU,CAWjG"}
@@ -1,2 +1,2 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../Button/index.cjs"),t=require("../ButtonGroup/index.cjs"),n=require("../Field/index.cjs"),r=require("../Grid/index.cjs"),i=require("../Slider/index.cjs");let a=require("react"),o=require("react/jsx-runtime");var s=1,c={zoom:1,rotation:0,x:.5,y:.5};function l(e,t,n){let r=[e,t];for(let e=Math.round(n/90)%4;e>0;e--)r=[1-r[1],r[0]];return r}function u(e,t,n,r){let i=n%180!=0,a=i?e.height:e.width,o=i?e.width:e.height;return{width:a,height:o,scale:Math.max(t.width/a,t.height/o)*r}}function d(e){let t=(e,t)=>e!=null&&Number.isFinite(e)?e:t,n=e=>Math.min(1,Math.max(0,t(e,.5))),r=(Math.round(t(e?.rotation,0)/90)*90%360+360)%360,[i,a]=l(n(e?.cx),n(e?.cy),r);return{zoom:t(e?.zoom,1),rotation:r,x:i,y:a}}var f=(0,a.forwardRef)(function({src:f,alt:p=``,aspect:m,maxZoom:h=3,rotatable:g=!0,onChange:_,defaultState:v,className:y,...b},x){let S=(0,a.useRef)(null),C=(0,a.useRef)(null),w=(0,a.useRef)(null),[T,E]=(0,a.useState)({width:0,height:0}),[D,O]=(0,a.useState)(null),[k,A]=(0,a.useState)(()=>d(v)),[j,M]=(0,a.useState)({src:f,aspect:m});(j.src!==f||j.aspect!==m)&&(M({src:f,aspect:m}),A(e=>j.src===f?{...c,rotation:e.rotation}:d(v)));let N=(0,a.useCallback)(e=>{let{naturalWidth:t,naturalHeight:n}=e;t&&n&&O(e=>e?.src===f&&e.width===t&&e.height===n?e:{src:f,width:t,height:n})},[f]);(0,a.useEffect)(()=>{let e=C.current;e?.complete&&N(e)},[N]),(0,a.useLayoutEffect)(()=>{let e=S.current;if(!e)return;let t=()=>{let t=e.clientWidth,n=e.clientHeight;E(e=>e.width===t&&e.height===n?e:{width:t,height:n})};t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[m]);let P=D?.src===f&&T.width>0&&T.height>0?D:null,F=(0,a.useCallback)(e=>{let t=Math.min(Math.max(s,h),Math.max(s,e.zoom)),{x:n,y:r}=e;if(P){let i=u(P,T,e.rotation,t),a=Math.min(.5,T.width/i.scale/i.width/2),o=Math.min(.5,T.height/i.scale/i.height/2);n=Math.min(1-a,Math.max(a,n)),r=Math.min(1-o,Math.max(o,r))}return t===e.zoom&&n===e.x&&r===e.y?e:{...e,zoom:t,x:n,y:r}},[T,h,P]),I=(0,a.useMemo)(()=>F(k),[F,k]);(0,a.useEffect)(()=>{A(I)},[I]);let L=(0,a.useMemo)(()=>P?u(P,T,I.rotation,I.zoom):null,[P,T,I.rotation,I.zoom]),R=L?.scale??0,z=L?(.5-I.x)*L.width*R:0,B=L?(.5-I.y)*L.height*R:0,V=L?Math.max(0,(L.width*R-T.width)/2):0,H=L?Math.max(0,(L.height*R-T.height)/2):0,U=`Drag the picture to reposition it. Nothing is written until you save — ${V===0&&H===0?`at this zoom the whole picture is in frame.`:`the veiled edges are what gets trimmed.`}`;(0,a.useEffect)(()=>{if(!L)return;let e=Math.min(L.width,Math.round(T.width/L.scale)),t=Math.min(L.height,Math.round(T.height/L.scale)),[n,r]=l(I.x,I.y,360-I.rotation);_?.({x:Math.max(0,Math.min(L.width-e,Math.round(I.x*L.width-T.width/L.scale/2))),y:Math.max(0,Math.min(L.height-t,Math.round(I.y*L.height-T.height/L.scale/2))),width:e,height:t},{offsetX:z,offsetY:B,zoom:I.zoom,rotation:I.rotation,cx:n,cy:r})},[L,I,T,z,B]);let W=(e,t)=>A(n=>{if(!P)return n;let{width:r,height:i,scale:a}=u(P,T,n.rotation,n.zoom);return F({...n,x:n.x-e/(r*a),y:n.y-t/(i*a)})}),G=e=>A(t=>({...c,rotation:(t.rotation+e+360)%360})),K=e=>{e.button===0&&(w.current={pointerId:e.pointerId,x:e.clientX,y:e.clientY},e.currentTarget.setPointerCapture(e.pointerId))},q=e=>{let t=w.current;if(!t||t.pointerId!==e.pointerId)return;let n=e.clientX-t.x,r=e.clientY-t.y;w.current={...t,x:e.clientX,y:e.clientY},W(n,r)},J=e=>{w.current?.pointerId===e.pointerId&&(w.current=null,e.currentTarget.releasePointerCapture?.(e.pointerId))};return(0,o.jsxs)(r.Stack,{ref:x,className:[`ds-cropper`,y].filter(Boolean).join(` `),...b,children:[(0,o.jsxs)(`div`,{role:`application`,"aria-label":`Crop area — drag to reposition, arrow keys to nudge`,tabIndex:0,className:`ds-cropper__stage`,style:{"--cropper-aspect":String(m)},onPointerDown:K,onPointerMove:q,onPointerUp:J,onPointerCancel:J,onKeyDown:e=>{let t=e.shiftKey?24:8,n={ArrowLeft:[-t,0],ArrowRight:[t,0],ArrowUp:[0,-t],ArrowDown:[0,t]}[e.key];n&&(e.preventDefault(),W(n[0],n[1]))},children:[(0,o.jsx)(`img`,{ref:C,src:f,alt:p,draggable:!1,className:`ds-cropper__image`,onLoad:e=>N(e.currentTarget),style:{inlineSize:P?P.width*R:void 0,blockSize:P?P.height*R:void 0,transform:`translate(calc(-50% + ${z}px), calc(-50% + ${B}px)) rotate(${I.rotation}deg)`}}),(0,o.jsx)(`div`,{className:`ds-cropper__frame`,ref:S,"aria-hidden":`true`,children:(0,o.jsx)(`div`,{className:`ds-cropper__guides`})})]}),(0,o.jsx)(n.Field,{label:`Zoom`,hint:U,children:n=>(0,o.jsxs)(r.Stack,{direction:`horizontal`,gap:`md`,align:`center`,wrap:!0,children:[(0,o.jsx)(r.Stack,{style:{flex:`1 1 50%`,minInlineSize:0},children:(0,o.jsx)(i.Slider,{...n,min:s,max:Math.max(s,h),step:.01,value:I.zoom,suffix:`×`,onValueChange:e=>A(t=>F({...t,zoom:e}))})}),(0,o.jsxs)(t.ButtonGroup,{"aria-label":`Crop actions`,children:[g&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(e.Button,{size:`sm`,iconStart:`rotate-ccw`,"aria-label":`Rotate left`,onClick:()=>G(-90)}),(0,o.jsx)(e.Button,{size:`sm`,iconStart:`rotate-cw`,"aria-label":`Rotate right`,onClick:()=>G(90)})]}),(0,o.jsx)(e.Button,{size:`sm`,onClick:()=>A(c),children:`Reset`})]})]})})]})});async function p(e,t,{outputWidth:n,rotation:r=0,type:i=`image/png`,quality:a=.92}={}){let o=new Image;o.crossOrigin=`anonymous`,o.src=e,await o.decode();let s=r%180!=0,c=document.createElement(`canvas`);c.width=s?o.naturalHeight:o.naturalWidth,c.height=s?o.naturalWidth:o.naturalHeight;let l=c.getContext(`2d`);if(!l)throw Error(`Canvas 2D context unavailable`);l.translate(c.width/2,c.height/2),l.rotate(r*Math.PI/180),l.drawImage(o,-o.naturalWidth/2,-o.naturalHeight/2);let u=n??t.width,d=Math.round(t.height/t.width*u),f=document.createElement(`canvas`);f.width=u,f.height=d;let p=f.getContext(`2d`);if(!p)throw Error(`Canvas 2D context unavailable`);return p.drawImage(c,t.x,t.y,t.width,t.height,0,0,u,d),new Promise((e,t)=>{f.toBlob(n=>n?e(n):t(Error(`Could not encode the crop`)),i,a)})}exports.ImageCropper=f,exports.cropToBlob=p;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../Button/index.cjs"),t=require("../ButtonGroup/index.cjs"),n=require("../Field/index.cjs"),r=require("../../chunks/binding-tMjrUzkU.cjs"),i=require("../Grid/index.cjs"),a=require("../Slider/index.cjs");let o=require("react"),s=require("react/jsx-runtime");var c=1,l={zoom:1,rotation:0,x:.5,y:.5};function u(e,t,n){let r=[e,t];for(let e=Math.round(n/90)%4;e>0;e--)r=[1-r[1],r[0]];return r}function d(e,t,n,r){let i=n%180!=0,a=i?e.height:e.width,o=i?e.width:e.height;return{width:a,height:o,scale:Math.max(t.width/a,t.height/o)*r}}function f(e){let t=(e,t)=>e!=null&&Number.isFinite(e)?e:t,n=e=>Math.min(1,Math.max(0,t(e,.5))),r=(Math.round(t(e?.rotation,0)/90)*90%360+360)%360,[i,a]=u(n(e?.cx),n(e?.cy),r);return{zoom:t(e?.zoom,1),rotation:r,x:i,y:a}}var p=(0,o.forwardRef)(function({src:p,alt:m=``,aspect:h,maxZoom:g=3,rotatable:_=!0,onChange:v,defaultState:y,className:b,...x},S){let C=(0,o.useRef)(null),w=(0,o.useRef)(null),T=(0,o.useRef)(null),[E,D]=(0,o.useState)({width:0,height:0}),[O,k]=(0,o.useState)(null),[A,j]=(0,o.useState)(()=>f(y)),[M,N]=(0,o.useState)({src:p,aspect:h});(M.src!==p||M.aspect!==h)&&(N({src:p,aspect:h}),j(e=>M.src===p?{...l,rotation:e.rotation}:f(y)));let P=(0,o.useCallback)(e=>{let{naturalWidth:t,naturalHeight:n}=e;t&&n&&k(e=>e?.src===p&&e.width===t&&e.height===n?e:{src:p,width:t,height:n})},[p]);(0,o.useEffect)(()=>{let e=w.current;e?.complete&&P(e)},[P]),(0,o.useLayoutEffect)(()=>{let e=C.current;if(!e)return;let t=()=>{let t=e.clientWidth,n=e.clientHeight;D(e=>e.width===t&&e.height===n?e:{width:t,height:n})};t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[h]);let F=O?.src===p&&E.width>0&&E.height>0?O:null,I=(0,o.useCallback)(e=>{let t=Math.min(Math.max(c,g),Math.max(c,e.zoom)),{x:n,y:r}=e;if(F){let i=d(F,E,e.rotation,t),a=Math.min(.5,E.width/i.scale/i.width/2),o=Math.min(.5,E.height/i.scale/i.height/2);n=Math.min(1-a,Math.max(a,n)),r=Math.min(1-o,Math.max(o,r))}return t===e.zoom&&n===e.x&&r===e.y?e:{...e,zoom:t,x:n,y:r}},[E,g,F]),L=(0,o.useMemo)(()=>I(A),[I,A]);(0,o.useEffect)(()=>{j(L)},[L]);let R=(0,o.useMemo)(()=>F?d(F,E,L.rotation,L.zoom):null,[F,E,L.rotation,L.zoom]),z=R?.scale??0,B=R?(.5-L.x)*R.width*z:0,V=R?(.5-L.y)*R.height*z:0,H=R?Math.max(0,(R.width*z-E.width)/2):0,U=R?Math.max(0,(R.height*z-E.height)/2):0,W=`Drag the picture to reposition it. Nothing is written until you save — ${H===0&&U===0?`at this zoom the whole picture is in frame.`:`the veiled edges are what gets trimmed.`}`;(0,o.useEffect)(()=>{if(!R)return;let e=Math.min(R.width,Math.round(E.width/R.scale)),t=Math.min(R.height,Math.round(E.height/R.scale)),[n,r]=u(L.x,L.y,360-L.rotation);v?.({x:Math.max(0,Math.min(R.width-e,Math.round(L.x*R.width-E.width/R.scale/2))),y:Math.max(0,Math.min(R.height-t,Math.round(L.y*R.height-E.height/R.scale/2))),width:e,height:t},{offsetX:B,offsetY:V,zoom:L.zoom,rotation:L.rotation,cx:n,cy:r})},[R,L,E,B,V]);let G=(e,t)=>j(n=>{if(!F)return n;let{width:r,height:i,scale:a}=d(F,E,n.rotation,n.zoom);return I({...n,x:n.x-e/(r*a),y:n.y-t/(i*a)})}),K=e=>j(t=>({...l,rotation:(t.rotation+e+360)%360})),q=e=>{e.button===0&&(T.current={pointerId:e.pointerId,x:e.clientX,y:e.clientY},e.currentTarget.setPointerCapture(e.pointerId))},J=e=>{let t=T.current;if(!t||t.pointerId!==e.pointerId)return;let n=e.clientX-t.x,r=e.clientY-t.y;T.current={...t,x:e.clientX,y:e.clientY},G(n,r)},Y=e=>{T.current?.pointerId===e.pointerId&&(T.current=null,e.currentTarget.releasePointerCapture?.(e.pointerId))};return(0,s.jsxs)(i.Stack,{ref:S,className:[`ds-cropper`,b].filter(Boolean).join(` `),...r.n(x),children:[(0,s.jsxs)(`div`,{role:`application`,"aria-label":`Crop area — drag to reposition, arrow keys to nudge`,tabIndex:0,className:`ds-cropper__stage`,style:{"--cropper-aspect":String(h)},onPointerDown:q,onPointerMove:J,onPointerUp:Y,onPointerCancel:Y,onKeyDown:e=>{let t=e.shiftKey?24:8,n={ArrowLeft:[-t,0],ArrowRight:[t,0],ArrowUp:[0,-t],ArrowDown:[0,t]}[e.key];n&&(e.preventDefault(),G(n[0],n[1]))},children:[(0,s.jsx)(`img`,{ref:w,src:p,alt:m,draggable:!1,className:`ds-cropper__image`,onLoad:e=>P(e.currentTarget),style:{inlineSize:F?F.width*z:void 0,blockSize:F?F.height*z:void 0,transform:`translate(calc(-50% + ${B}px), calc(-50% + ${V}px)) rotate(${L.rotation}deg)`}}),(0,s.jsx)(`div`,{className:`ds-cropper__frame`,ref:C,"aria-hidden":`true`,children:(0,s.jsx)(`div`,{className:`ds-cropper__guides`})})]}),(0,s.jsx)(n.Field,{label:`Zoom`,hint:W,children:n=>(0,s.jsxs)(i.Stack,{direction:`horizontal`,gap:`md`,align:`center`,wrap:!0,children:[(0,s.jsx)(i.Stack,{style:{flex:`1 1 50%`,minInlineSize:0},children:(0,s.jsx)(a.Slider,{...n,min:c,max:Math.max(c,g),step:.01,value:L.zoom,suffix:`×`,onValueChange:e=>j(t=>I({...t,zoom:e}))})}),(0,s.jsxs)(t.ButtonGroup,{"aria-label":`Crop actions`,children:[_&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(e.Button,{size:`sm`,iconStart:`rotate-ccw`,"aria-label":`Rotate left`,onClick:()=>K(-90)}),(0,s.jsx)(e.Button,{size:`sm`,iconStart:`rotate-cw`,"aria-label":`Rotate right`,onClick:()=>K(90)})]}),(0,s.jsx)(e.Button,{size:`sm`,onClick:()=>j(l),children:`Reset`})]})]})})]})});async function m(e,t,{outputWidth:n,rotation:r=0,type:i=`image/png`,quality:a=.92}={}){let o=new Image;o.crossOrigin=`anonymous`,o.src=e,await o.decode();let s=r%180!=0,c=document.createElement(`canvas`);c.width=s?o.naturalHeight:o.naturalWidth,c.height=s?o.naturalWidth:o.naturalHeight;let l=c.getContext(`2d`);if(!l)throw Error(`Canvas 2D context unavailable`);l.translate(c.width/2,c.height/2),l.rotate(r*Math.PI/180),l.drawImage(o,-o.naturalWidth/2,-o.naturalHeight/2);let u=n??t.width,d=Math.round(t.height/t.width*u),f=document.createElement(`canvas`);f.width=u,f.height=d;let p=f.getContext(`2d`);if(!p)throw Error(`Canvas 2D context unavailable`);return p.drawImage(c,t.x,t.y,t.width,t.height,0,0,u,d),new Promise((e,t)=>{f.toBlob(n=>n?e(n):t(Error(`Could not encode the crop`)),i,a)})}exports.ImageCropper=p,exports.cropToBlob=m;
2
2
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["forwardRef","useRef","useState","useCallback","useMemo","Stack","Field","Slider","ButtonGroup","_Fragment","Button","require_components_Button_index","require_components_ButtonGroup_index","require_components_Field_index","require_components_Grid_index","require_components_Slider_index","react","react_jsx_runtime","MIN_ZOOM","CENTRED","turnPoint","point","x","y","turns","degrees","project","quarter","rotation","width","picture","height","frame","zoom","seed","finite","value","fallback","fraction","saved","ImageCropper","rest","frameRef","imageRef","dragRef","setFrame","natural","setNatural","framing","setFraming","defaultState","shown","setShown","src","aspect","prev","adopt","img","node","measure","observer","clamp","maxZoom","next","view","halfX","halfY","bounded","scale","offsetX","offsetY","maxOffsetX","maxOffsetY","hint","cx","cy","onChange","pan","at","dx","dy","turn","by","onPointerDown","event","onPointerMove","drag","endDrag","className","step","move","props","rotatable","cropToBlob","image","turned","turnedContext","outputWidth","crop","canvas","context","blob","resolve","reject","type","quality"],"sources":["../../../src/components/ImageCropper/index.tsx"],"sourcesContent":["import {\n forwardRef,\n useCallback,\n useEffect,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n type CSSProperties,\n type HTMLAttributes,\n type PointerEvent as ReactPointerEvent,\n} from \"react\";\nimport { Button } from \"../Button\";\nimport { ButtonGroup } from \"../ButtonGroup\";\nimport { Field } from \"../Field\";\nimport { Stack } from \"../Grid\";\nimport { Slider } from \"../Slider\";\nimport \"./style.css\";\n\nexport interface CropRect {\n /** Left edge of the crop, in the (rotated) image's own pixels. */\n x: number;\n /** Top edge of the crop, in the (rotated) image's own pixels. */\n y: number;\n width: number;\n height: number;\n}\n\nexport interface CropState {\n /** Pan, in stage pixels, from the centre. Follows the stage size, so save `cx`/`cy`. */\n offsetX: number;\n offsetY: number;\n /** 1 is \"cover the crop window exactly\". */\n zoom: number;\n /** Quarter turns applied to the picture, clockwise: 0, 90, 180 or 270. */\n rotation: number;\n /** Crop centre as fractions of the unrotated source image. */\n cx: number;\n cy: number;\n}\n\n/** A saved selection. Every emitted `CropState` is one, so it can be passed straight back. */\nexport interface ImageCropperDefaultState {\n /** Zoom at initialization; clamped to the supported range. */\n zoom: number;\n /** Crop centre as fractions of the unrotated source image. */\n cx: number;\n cy: number;\n /** Clockwise quarter turns, snapped to 0, 90, 180 or 270. Defaults to 0. */\n rotation?: number;\n}\n\nexport interface ImageCropperProps extends Omit<HTMLAttributes<HTMLDivElement>, \"onChange\"> {\n src: string;\n /** Uncontrolled initial selection. Applied again whenever `src` changes. */\n defaultState?: ImageCropperDefaultState;\n /** Describes the picture for people who cannot see the stage. */\n alt?: string;\n /** Required output shape, width / height. Must be positive and finite. */\n aspect: number;\n /** Highest allowed zoom. Past 3 the result is mush on most uploads. */\n maxZoom?: number;\n /** Offer the quarter-turn controls. */\n rotatable?: boolean;\n /** Fires on every pan, zoom, turn and reset, with the crop in image pixels. */\n onChange?: (crop: CropRect, state: CropState) => void;\n}\n\ninterface Size {\n width: number;\n height: number;\n}\n\n/** The selection as the engine keeps it, independent of the stage's size. */\ninterface Framing {\n zoom: number;\n rotation: number;\n /** Frame centre as fractions of the picture as turned. */\n x: number;\n y: number;\n}\n\nconst MIN_ZOOM = 1;\nconst CENTRED: Framing = { zoom: 1, rotation: 0, x: 0.5, y: 0.5 };\n\n/** Carries a point, in fractions of a picture, through clockwise quarter turns of it. */\nfunction turnPoint(x: number, y: number, degrees: number): [number, number] {\n let point: [number, number] = [x, y];\n for (let turns = Math.round(degrees / 90) % 4; turns > 0; turns--) {\n point = [1 - point[1], point[0]];\n }\n return point;\n}\n\n/** The turned picture's size, and the stage scale at which it covers the frame at this zoom. */\nfunction project(picture: Size, frame: Size, rotation: number, zoom: number) {\n const quarter = rotation % 180 !== 0;\n const width = quarter ? picture.height : picture.width;\n const height = quarter ? picture.width : picture.height;\n return {\n width,\n height,\n scale: Math.max(frame.width / width, frame.height / height) * zoom,\n };\n}\n\n/** Reads a saved selection, falling back to the centre for anything unusable. */\nfunction seed(saved: ImageCropperDefaultState | undefined): Framing {\n const finite = (value: number | undefined, fallback: number) =>\n value != null && Number.isFinite(value) ? value : fallback;\n const fraction = (value: number | undefined) => Math.min(1, Math.max(0, finite(value, 0.5)));\n const rotation = (((Math.round(finite(saved?.rotation, 0) / 90) * 90) % 360) + 360) % 360;\n const [x, y] = turnPoint(fraction(saved?.cx), fraction(saved?.cy), rotation);\n return { zoom: finite(saved?.zoom, 1), rotation, x, y };\n}\n\n/**\n * Pan-and-zoom cropping over a fixed frame. The frame never moves — the\n * picture does — and the parts that fall outside it stay visible under a\n * veil, so the reader can see what they are trimming away.\n * Drag with a pointer, or focus the stage and use the arrow keys.\n */\nexport const ImageCropper = forwardRef<HTMLDivElement, ImageCropperProps>(function ImageCropper(\n {\n src,\n alt = \"\",\n aspect,\n maxZoom = 3,\n rotatable = true,\n onChange,\n defaultState,\n className,\n ...rest\n },\n ref,\n) {\n const frameRef = useRef<HTMLDivElement | null>(null);\n const imageRef = useRef<HTMLImageElement | null>(null);\n const dragRef = useRef<{ pointerId: number; x: number; y: number } | null>(null);\n const [frame, setFrame] = useState<Size>({ width: 0, height: 0 });\n const [natural, setNatural] = useState<(Size & { src: string }) | null>(null);\n const [framing, setFraming] = useState(() => seed(defaultState));\n const [shown, setShown] = useState({ src, aspect });\n\n // A new source starts again from the saved selection; a new shape starts\n // centred and keeps the turn. Adjusting while rendering means no commit\n // pairs the previous selection with the new picture or frame.\n if (shown.src !== src || shown.aspect !== aspect) {\n setShown({ src, aspect });\n setFraming((prev) =>\n shown.src !== src ? seed(defaultState) : { ...CENTRED, rotation: prev.rotation },\n );\n }\n\n /** Take the picture's own pixels. Repeated load events for it change nothing. */\n const adopt = useCallback(\n (img: HTMLImageElement) => {\n const { naturalWidth: width, naturalHeight: height } = img;\n if (!width || !height) return;\n setNatural((prev) =>\n prev?.src === src && prev.width === width && prev.height === height\n ? prev\n : { src, width, height },\n );\n },\n [src],\n );\n\n // A cached or server-rendered image can already be decoded before React\n // attaches onLoad, and then that event never fires.\n useEffect(() => {\n const img = imageRef.current;\n if (img?.complete) adopt(img);\n }, [adopt]);\n\n useLayoutEffect(() => {\n const node = frameRef.current;\n if (!node) return;\n const measure = () => {\n const width = node.clientWidth;\n const height = node.clientHeight;\n setFrame((prev) =>\n prev.width === width && prev.height === height ? prev : { width, height },\n );\n };\n measure();\n const observer = new ResizeObserver(measure);\n observer.observe(node);\n return () => observer.disconnect();\n }, [aspect]);\n\n // Nothing is measured or reported until this source has loaded into a sized frame.\n const picture = natural?.src === src && frame.width > 0 && frame.height > 0 ? natural : null;\n\n const clamp = useCallback(\n (next: Framing): Framing => {\n const zoom = Math.min(Math.max(MIN_ZOOM, maxZoom), Math.max(MIN_ZOOM, next.zoom));\n let { x, y } = next;\n if (picture) {\n // The frame's half-width and half-height, as shares of the picture.\n const view = project(picture, frame, next.rotation, zoom);\n const halfX = Math.min(0.5, frame.width / view.scale / view.width / 2);\n const halfY = Math.min(0.5, frame.height / view.scale / view.height / 2);\n x = Math.min(1 - halfX, Math.max(halfX, x));\n y = Math.min(1 - halfY, Math.max(halfY, y));\n }\n if (zoom === next.zoom && x === next.x && y === next.y) return next;\n return { ...next, zoom, x, y };\n },\n [frame, maxZoom, picture],\n );\n\n // Keep the rendered transform bounded when the frame or zoom limit changes too.\n const bounded = useMemo(() => clamp(framing), [clamp, framing]);\n useEffect(() => {\n setFraming(bounded);\n }, [bounded]);\n\n const view = useMemo(\n () => (picture ? project(picture, frame, bounded.rotation, bounded.zoom) : null),\n [picture, frame, bounded.rotation, bounded.zoom],\n );\n const scale = view?.scale ?? 0;\n const offsetX = view ? (0.5 - bounded.x) * view.width * scale : 0;\n const offsetY = view ? (0.5 - bounded.y) * view.height * scale : 0;\n const maxOffsetX = view ? Math.max(0, (view.width * scale - frame.width) / 2) : 0;\n const maxOffsetY = view ? Math.max(0, (view.height * scale - frame.height) / 2) : 0;\n const hint = `Drag the picture to reposition it. Nothing is written until you save — ${\n maxOffsetX === 0 && maxOffsetY === 0\n ? \"at this zoom the whole picture is in frame.\"\n : \"the veiled edges are what gets trimmed.\"\n }`;\n\n // A passive effect, so a parent that re-renders on every report never\n // delays the frame that paints a drag.\n useEffect(() => {\n if (!view) return;\n const width = Math.min(view.width, Math.round(frame.width / view.scale));\n const height = Math.min(view.height, Math.round(frame.height / view.scale));\n const [cx, cy] = turnPoint(bounded.x, bounded.y, 360 - bounded.rotation);\n onChange?.(\n {\n x: Math.max(\n 0,\n Math.min(\n view.width - width,\n Math.round(bounded.x * view.width - frame.width / view.scale / 2),\n ),\n ),\n y: Math.max(\n 0,\n Math.min(\n view.height - height,\n Math.round(bounded.y * view.height - frame.height / view.scale / 2),\n ),\n ),\n width,\n height,\n },\n {\n offsetX,\n offsetY,\n zoom: bounded.zoom,\n rotation: bounded.rotation,\n cx,\n cy,\n },\n );\n // onChange is intentionally not a dependency: callers pass inline handlers.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [view, bounded, frame, offsetX, offsetY]);\n\n /** Move the picture by stage pixels; the frame centre travels the other way. */\n const pan = (dx: number, dy: number) =>\n setFraming((prev) => {\n if (!picture) return prev;\n const { width, height, scale: at } = project(picture, frame, prev.rotation, prev.zoom);\n return clamp({\n ...prev,\n x: prev.x - dx / (width * at),\n y: prev.y - dy / (height * at),\n });\n });\n\n const turn = (by: number) =>\n setFraming((prev) => ({\n ...CENTRED,\n rotation: (prev.rotation + by + 360) % 360,\n }));\n\n const onPointerDown = (event: ReactPointerEvent<HTMLDivElement>) => {\n if (event.button !== 0) return;\n dragRef.current = {\n pointerId: event.pointerId,\n x: event.clientX,\n y: event.clientY,\n };\n event.currentTarget.setPointerCapture(event.pointerId);\n };\n\n const onPointerMove = (event: ReactPointerEvent<HTMLDivElement>) => {\n const drag = dragRef.current;\n if (!drag || drag.pointerId !== event.pointerId) return;\n const dx = event.clientX - drag.x;\n const dy = event.clientY - drag.y;\n dragRef.current = { ...drag, x: event.clientX, y: event.clientY };\n pan(dx, dy);\n };\n\n const endDrag = (event: ReactPointerEvent<HTMLDivElement>) => {\n if (dragRef.current?.pointerId !== event.pointerId) return;\n dragRef.current = null;\n event.currentTarget.releasePointerCapture?.(event.pointerId);\n };\n\n return (\n <Stack\n ref={ref}\n className={[\"ds-cropper\", className].filter(Boolean).join(\" \")}\n {...rest}\n >\n <div\n role=\"application\"\n aria-label=\"Crop area — drag to reposition, arrow keys to nudge\"\n tabIndex={0}\n className=\"ds-cropper__stage\"\n style={{ \"--cropper-aspect\": String(aspect) } as CSSProperties}\n onPointerDown={onPointerDown}\n onPointerMove={onPointerMove}\n onPointerUp={endDrag}\n onPointerCancel={endDrag}\n onKeyDown={(event) => {\n const step = event.shiftKey ? 24 : 8;\n const moves: Record<string, [number, number]> = {\n ArrowLeft: [-step, 0],\n ArrowRight: [step, 0],\n ArrowUp: [0, -step],\n ArrowDown: [0, step],\n };\n const move = moves[event.key];\n if (!move) return;\n event.preventDefault();\n pan(move[0], move[1]);\n }}\n >\n <img\n ref={imageRef}\n src={src}\n alt={alt}\n draggable={false}\n className=\"ds-cropper__image\"\n onLoad={(event) => adopt(event.currentTarget)}\n style={{\n inlineSize: picture ? picture.width * scale : undefined,\n blockSize: picture ? picture.height * scale : undefined,\n transform: `translate(calc(-50% + ${offsetX}px), calc(-50% + ${offsetY}px)) rotate(${bounded.rotation}deg)`,\n }}\n />\n {/* The window: everything outside it is veiled, not hidden. */}\n <div\n className=\"ds-cropper__frame\"\n ref={frameRef}\n aria-hidden=\"true\"\n >\n <div className=\"ds-cropper__guides\" />\n </div>\n </div>\n\n <Field\n label=\"Zoom\"\n hint={hint}\n >\n {(props) => (\n <Stack\n direction=\"horizontal\"\n gap=\"md\"\n align=\"center\"\n wrap\n >\n <Stack style={{ flex: \"1 1 50%\", minInlineSize: 0 }}>\n <Slider\n {...props}\n min={MIN_ZOOM}\n max={Math.max(MIN_ZOOM, maxZoom)}\n step={0.01}\n value={bounded.zoom}\n suffix=\"×\"\n onValueChange={(zoom) => setFraming((prev) => clamp({ ...prev, zoom }))}\n />\n </Stack>\n <ButtonGroup aria-label=\"Crop actions\">\n {rotatable && (\n <>\n <Button\n size=\"sm\"\n iconStart=\"rotate-ccw\"\n aria-label=\"Rotate left\"\n onClick={() => turn(-90)}\n />\n <Button\n size=\"sm\"\n iconStart=\"rotate-cw\"\n aria-label=\"Rotate right\"\n onClick={() => turn(90)}\n />\n </>\n )}\n <Button\n size=\"sm\"\n onClick={() => setFraming(CENTRED)}\n >\n Reset\n </Button>\n </ButtonGroup>\n </Stack>\n )}\n </Field>\n </Stack>\n );\n});\n\nexport interface CropToBlobOptions {\n /** Width of the output in pixels; the height follows the crop's aspect. */\n outputWidth?: number;\n /** Quarter turns applied before cropping — pass `state.rotation`. */\n rotation?: number;\n type?: \"image/png\" | \"image/jpeg\" | \"image/webp\";\n quality?: number;\n}\n\n/**\n * Renders a `CropRect` to an image blob in the browser. Same-origin or\n * CORS-enabled sources only — a tainted canvas cannot be exported.\n */\nexport async function cropToBlob(\n src: string,\n crop: CropRect,\n { outputWidth, rotation = 0, type = \"image/png\", quality = 0.92 }: CropToBlobOptions = {},\n): Promise<Blob> {\n const image = new Image();\n image.crossOrigin = \"anonymous\";\n image.src = src;\n await image.decode();\n\n // The crop is expressed against the turned picture, so turn it first.\n const quarter = rotation % 180 !== 0;\n const turned = document.createElement(\"canvas\");\n turned.width = quarter ? image.naturalHeight : image.naturalWidth;\n turned.height = quarter ? image.naturalWidth : image.naturalHeight;\n const turnedContext = turned.getContext(\"2d\");\n if (!turnedContext) throw new Error(\"Canvas 2D context unavailable\");\n turnedContext.translate(turned.width / 2, turned.height / 2);\n turnedContext.rotate((rotation * Math.PI) / 180);\n turnedContext.drawImage(image, -image.naturalWidth / 2, -image.naturalHeight / 2);\n\n const width = outputWidth ?? crop.width;\n const height = Math.round((crop.height / crop.width) * width);\n const canvas = document.createElement(\"canvas\");\n canvas.width = width;\n canvas.height = height;\n const context = canvas.getContext(\"2d\");\n if (!context) throw new Error(\"Canvas 2D context unavailable\");\n context.drawImage(turned, crop.x, crop.y, crop.width, crop.height, 0, 0, width, height);\n\n return new Promise((resolve, reject) => {\n canvas.toBlob(\n (blob) => (blob ? resolve(blob) : reject(new Error(\"Could not encode the crop\"))),\n type,\n quality,\n );\n });\n}\n"],"mappings":"A,sSAkFA,IAAMkB,EAAW,EACXC,EAAmB,CAAE,KAAM,EAAG,SAAU,EAAG,EAAG,GAAK,EAAG,EAAI,EAGhE,SAASC,EAAU,EAAW,EAAW,EAAmC,CAC1E,IAAIC,EAA0B,CAACC,EAAGC,CAAC,EACnC,IAAK,IAAIC,EAAQ,KAAK,MAAMC,EAAU,EAAE,EAAI,EAAGD,EAAQ,EAAG,IACxD,EAAQ,CAAC,EAAIH,EAAM,GAAIA,EAAM,EAAE,EAEjC,OAAOA,CACT,CAGA,SAASK,EAAQ,EAAe,EAAa,EAAkB,EAAc,CAC3E,IAAMC,EAAUC,EAAW,KAAQ,EAC7BC,EAAQF,EAAUG,EAAQ,OAASA,EAAQ,MAC3CC,EAASJ,EAAUG,EAAQ,MAAQA,EAAQ,OACjD,MAAO,CACL,QACA,SACA,MAAO,KAAK,IAAIE,EAAM,MAAQH,EAAOG,EAAM,OAASD,CAAM,EAAIE,CAChE,CACF,CAGA,SAASC,EAAK,EAAsD,CAClE,IAAMC,GAAU,EAA2B,IACzCC,G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2BAA2B,CAAC,EAC/EC,EACAC,CACF,CACF,CAAC,CACH,C"}
1
+ {"version":3,"file":"index.cjs","names":["forwardRef","useRef","useState","useCallback","useMemo","Stack","omitRequired","Field","Slider","ButtonGroup","_Fragment","Button","require_components_Button_index","require_components_ButtonGroup_index","require_components_Field_index","require_binding","require_components_Grid_index","require_components_Slider_index","react","react_jsx_runtime","MIN_ZOOM","CENTRED","turnPoint","point","x","y","turns","degrees","project","quarter","rotation","width","picture","height","frame","zoom","seed","finite","value","fallback","fraction","saved","ImageCropper","rest","frameRef","imageRef","dragRef","setFrame","natural","setNatural","framing","setFraming","defaultState","shown","setShown","src","aspect","prev","adopt","img","node","measure","observer","clamp","maxZoom","next","view","halfX","halfY","bounded","scale","offsetX","offsetY","maxOffsetX","maxOffsetY","hint","cx","cy","onChange","pan","at","dx","dy","turn","by","onPointerDown","event","onPointerMove","drag","endDrag","className","step","move","props","rotatable","cropToBlob","image","turned","turnedContext","outputWidth","crop","canvas","context","blob","resolve","reject","type","quality"],"sources":["../../../src/components/ImageCropper/index.tsx"],"sourcesContent":["import {\n forwardRef,\n useCallback,\n useEffect,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n type CSSProperties,\n type HTMLAttributes,\n type PointerEvent as ReactPointerEvent,\n} from \"react\";\nimport { Button } from \"../Button\";\nimport { ButtonGroup } from \"../ButtonGroup\";\nimport { Field } from \"../Field\";\nimport { omitRequired } from \"../Field/binding\";\nimport { Stack } from \"../Grid\";\nimport { Slider } from \"../Slider\";\nimport \"./style.css\";\n\nexport interface CropRect {\n /** Left edge of the crop, in the (rotated) image's own pixels. */\n x: number;\n /** Top edge of the crop, in the (rotated) image's own pixels. */\n y: number;\n width: number;\n height: number;\n}\n\nexport interface CropState {\n /** Pan, in stage pixels, from the centre. Follows the stage size, so save `cx`/`cy`. */\n offsetX: number;\n offsetY: number;\n /** 1 is \"cover the crop window exactly\". */\n zoom: number;\n /** Quarter turns applied to the picture, clockwise: 0, 90, 180 or 270. */\n rotation: number;\n /** Crop centre as fractions of the unrotated source image. */\n cx: number;\n cy: number;\n}\n\n/** A saved selection. Every emitted `CropState` is one, so it can be passed straight back. */\nexport interface ImageCropperDefaultState {\n /** Zoom at initialization; clamped to the supported range. */\n zoom: number;\n /** Crop centre as fractions of the unrotated source image. */\n cx: number;\n cy: number;\n /** Clockwise quarter turns, snapped to 0, 90, 180 or 270. Defaults to 0. */\n rotation?: number;\n}\n\nexport interface ImageCropperProps extends Omit<HTMLAttributes<HTMLDivElement>, \"onChange\"> {\n src: string;\n /** Uncontrolled initial selection. Applied again whenever `src` changes. */\n defaultState?: ImageCropperDefaultState;\n /** Describes the picture for people who cannot see the stage. */\n alt?: string;\n /** Required output shape, width / height. Must be positive and finite. */\n aspect: number;\n /** Highest allowed zoom. Past 3 the result is mush on most uploads. */\n maxZoom?: number;\n /** Offer the quarter-turn controls. */\n rotatable?: boolean;\n /** Fires on every pan, zoom, turn and reset, with the crop in image pixels. */\n onChange?: (crop: CropRect, state: CropState) => void;\n}\n\ninterface Size {\n width: number;\n height: number;\n}\n\n/** The selection as the engine keeps it, independent of the stage's size. */\ninterface Framing {\n zoom: number;\n rotation: number;\n /** Frame centre as fractions of the picture as turned. */\n x: number;\n y: number;\n}\n\nconst MIN_ZOOM = 1;\nconst CENTRED: Framing = { zoom: 1, rotation: 0, x: 0.5, y: 0.5 };\n\n/** Carries a point, in fractions of a picture, through clockwise quarter turns of it. */\nfunction turnPoint(x: number, y: number, degrees: number): [number, number] {\n let point: [number, number] = [x, y];\n for (let turns = Math.round(degrees / 90) % 4; turns > 0; turns--) {\n point = [1 - point[1], point[0]];\n }\n return point;\n}\n\n/** The turned picture's size, and the stage scale at which it covers the frame at this zoom. */\nfunction project(picture: Size, frame: Size, rotation: number, zoom: number) {\n const quarter = rotation % 180 !== 0;\n const width = quarter ? picture.height : picture.width;\n const height = quarter ? picture.width : picture.height;\n return {\n width,\n height,\n scale: Math.max(frame.width / width, frame.height / height) * zoom,\n };\n}\n\n/** Reads a saved selection, falling back to the centre for anything unusable. */\nfunction seed(saved: ImageCropperDefaultState | undefined): Framing {\n const finite = (value: number | undefined, fallback: number) =>\n value != null && Number.isFinite(value) ? value : fallback;\n const fraction = (value: number | undefined) => Math.min(1, Math.max(0, finite(value, 0.5)));\n const rotation = (((Math.round(finite(saved?.rotation, 0) / 90) * 90) % 360) + 360) % 360;\n const [x, y] = turnPoint(fraction(saved?.cx), fraction(saved?.cy), rotation);\n return { zoom: finite(saved?.zoom, 1), rotation, x, y };\n}\n\n/**\n * Pan-and-zoom cropping over a fixed frame. The frame never moves — the\n * picture does — and the parts that fall outside it stay visible under a\n * veil, so the reader can see what they are trimming away.\n * Drag with a pointer, or focus the stage and use the arrow keys.\n */\nexport const ImageCropper = forwardRef<HTMLDivElement, ImageCropperProps>(function ImageCropper(\n {\n src,\n alt = \"\",\n aspect,\n maxZoom = 3,\n rotatable = true,\n onChange,\n defaultState,\n className,\n ...rest\n },\n ref,\n) {\n const frameRef = useRef<HTMLDivElement | null>(null);\n const imageRef = useRef<HTMLImageElement | null>(null);\n const dragRef = useRef<{ pointerId: number; x: number; y: number } | null>(null);\n const [frame, setFrame] = useState<Size>({ width: 0, height: 0 });\n const [natural, setNatural] = useState<(Size & { src: string }) | null>(null);\n const [framing, setFraming] = useState(() => seed(defaultState));\n const [shown, setShown] = useState({ src, aspect });\n\n // A new source starts again from the saved selection; a new shape starts\n // centred and keeps the turn. Adjusting while rendering means no commit\n // pairs the previous selection with the new picture or frame.\n if (shown.src !== src || shown.aspect !== aspect) {\n setShown({ src, aspect });\n setFraming((prev) =>\n shown.src !== src ? seed(defaultState) : { ...CENTRED, rotation: prev.rotation },\n );\n }\n\n /** Take the picture's own pixels. Repeated load events for it change nothing. */\n const adopt = useCallback(\n (img: HTMLImageElement) => {\n const { naturalWidth: width, naturalHeight: height } = img;\n if (!width || !height) return;\n setNatural((prev) =>\n prev?.src === src && prev.width === width && prev.height === height\n ? prev\n : { src, width, height },\n );\n },\n [src],\n );\n\n // A cached or server-rendered image can already be decoded before React\n // attaches onLoad, and then that event never fires.\n useEffect(() => {\n const img = imageRef.current;\n if (img?.complete) adopt(img);\n }, [adopt]);\n\n useLayoutEffect(() => {\n const node = frameRef.current;\n if (!node) return;\n const measure = () => {\n const width = node.clientWidth;\n const height = node.clientHeight;\n setFrame((prev) =>\n prev.width === width && prev.height === height ? prev : { width, height },\n );\n };\n measure();\n const observer = new ResizeObserver(measure);\n observer.observe(node);\n return () => observer.disconnect();\n }, [aspect]);\n\n // Nothing is measured or reported until this source has loaded into a sized frame.\n const picture = natural?.src === src && frame.width > 0 && frame.height > 0 ? natural : null;\n\n const clamp = useCallback(\n (next: Framing): Framing => {\n const zoom = Math.min(Math.max(MIN_ZOOM, maxZoom), Math.max(MIN_ZOOM, next.zoom));\n let { x, y } = next;\n if (picture) {\n // The frame's half-width and half-height, as shares of the picture.\n const view = project(picture, frame, next.rotation, zoom);\n const halfX = Math.min(0.5, frame.width / view.scale / view.width / 2);\n const halfY = Math.min(0.5, frame.height / view.scale / view.height / 2);\n x = Math.min(1 - halfX, Math.max(halfX, x));\n y = Math.min(1 - halfY, Math.max(halfY, y));\n }\n if (zoom === next.zoom && x === next.x && y === next.y) return next;\n return { ...next, zoom, x, y };\n },\n [frame, maxZoom, picture],\n );\n\n // Keep the rendered transform bounded when the frame or zoom limit changes too.\n const bounded = useMemo(() => clamp(framing), [clamp, framing]);\n useEffect(() => {\n setFraming(bounded);\n }, [bounded]);\n\n const view = useMemo(\n () => (picture ? project(picture, frame, bounded.rotation, bounded.zoom) : null),\n [picture, frame, bounded.rotation, bounded.zoom],\n );\n const scale = view?.scale ?? 0;\n const offsetX = view ? (0.5 - bounded.x) * view.width * scale : 0;\n const offsetY = view ? (0.5 - bounded.y) * view.height * scale : 0;\n const maxOffsetX = view ? Math.max(0, (view.width * scale - frame.width) / 2) : 0;\n const maxOffsetY = view ? Math.max(0, (view.height * scale - frame.height) / 2) : 0;\n const hint = `Drag the picture to reposition it. Nothing is written until you save — ${\n maxOffsetX === 0 && maxOffsetY === 0\n ? \"at this zoom the whole picture is in frame.\"\n : \"the veiled edges are what gets trimmed.\"\n }`;\n\n // A passive effect, so a parent that re-renders on every report never\n // delays the frame that paints a drag.\n useEffect(() => {\n if (!view) return;\n const width = Math.min(view.width, Math.round(frame.width / view.scale));\n const height = Math.min(view.height, Math.round(frame.height / view.scale));\n const [cx, cy] = turnPoint(bounded.x, bounded.y, 360 - bounded.rotation);\n onChange?.(\n {\n x: Math.max(\n 0,\n Math.min(\n view.width - width,\n Math.round(bounded.x * view.width - frame.width / view.scale / 2),\n ),\n ),\n y: Math.max(\n 0,\n Math.min(\n view.height - height,\n Math.round(bounded.y * view.height - frame.height / view.scale / 2),\n ),\n ),\n width,\n height,\n },\n {\n offsetX,\n offsetY,\n zoom: bounded.zoom,\n rotation: bounded.rotation,\n cx,\n cy,\n },\n );\n // onChange is intentionally not a dependency: callers pass inline handlers.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [view, bounded, frame, offsetX, offsetY]);\n\n /** Move the picture by stage pixels; the frame centre travels the other way. */\n const pan = (dx: number, dy: number) =>\n setFraming((prev) => {\n if (!picture) return prev;\n const { width, height, scale: at } = project(picture, frame, prev.rotation, prev.zoom);\n return clamp({\n ...prev,\n x: prev.x - dx / (width * at),\n y: prev.y - dy / (height * at),\n });\n });\n\n const turn = (by: number) =>\n setFraming((prev) => ({\n ...CENTRED,\n rotation: (prev.rotation + by + 360) % 360,\n }));\n\n const onPointerDown = (event: ReactPointerEvent<HTMLDivElement>) => {\n if (event.button !== 0) return;\n dragRef.current = {\n pointerId: event.pointerId,\n x: event.clientX,\n y: event.clientY,\n };\n event.currentTarget.setPointerCapture(event.pointerId);\n };\n\n const onPointerMove = (event: ReactPointerEvent<HTMLDivElement>) => {\n const drag = dragRef.current;\n if (!drag || drag.pointerId !== event.pointerId) return;\n const dx = event.clientX - drag.x;\n const dy = event.clientY - drag.y;\n dragRef.current = { ...drag, x: event.clientX, y: event.clientY };\n pan(dx, dy);\n };\n\n const endDrag = (event: ReactPointerEvent<HTMLDivElement>) => {\n if (dragRef.current?.pointerId !== event.pointerId) return;\n dragRef.current = null;\n event.currentTarget.releasePointerCapture?.(event.pointerId);\n };\n\n return (\n <Stack\n ref={ref}\n className={[\"ds-cropper\", className].filter(Boolean).join(\" \")}\n {...omitRequired(rest)}\n >\n <div\n role=\"application\"\n aria-label=\"Crop area — drag to reposition, arrow keys to nudge\"\n tabIndex={0}\n className=\"ds-cropper__stage\"\n style={{ \"--cropper-aspect\": String(aspect) } as CSSProperties}\n onPointerDown={onPointerDown}\n onPointerMove={onPointerMove}\n onPointerUp={endDrag}\n onPointerCancel={endDrag}\n onKeyDown={(event) => {\n const step = event.shiftKey ? 24 : 8;\n const moves: Record<string, [number, number]> = {\n ArrowLeft: [-step, 0],\n ArrowRight: [step, 0],\n ArrowUp: [0, -step],\n ArrowDown: [0, step],\n };\n const move = moves[event.key];\n if (!move) return;\n event.preventDefault();\n pan(move[0], move[1]);\n }}\n >\n <img\n ref={imageRef}\n src={src}\n alt={alt}\n draggable={false}\n className=\"ds-cropper__image\"\n onLoad={(event) => adopt(event.currentTarget)}\n style={{\n inlineSize: picture ? picture.width * scale : undefined,\n blockSize: picture ? picture.height * scale : undefined,\n transform: `translate(calc(-50% + ${offsetX}px), calc(-50% + ${offsetY}px)) rotate(${bounded.rotation}deg)`,\n }}\n />\n {/* The window: everything outside it is veiled, not hidden. */}\n <div\n className=\"ds-cropper__frame\"\n ref={frameRef}\n aria-hidden=\"true\"\n >\n <div className=\"ds-cropper__guides\" />\n </div>\n </div>\n\n <Field\n label=\"Zoom\"\n hint={hint}\n >\n {(props) => (\n <Stack\n direction=\"horizontal\"\n gap=\"md\"\n align=\"center\"\n wrap\n >\n <Stack style={{ flex: \"1 1 50%\", minInlineSize: 0 }}>\n <Slider\n {...props}\n min={MIN_ZOOM}\n max={Math.max(MIN_ZOOM, maxZoom)}\n step={0.01}\n value={bounded.zoom}\n suffix=\"×\"\n onValueChange={(zoom) => setFraming((prev) => clamp({ ...prev, zoom }))}\n />\n </Stack>\n <ButtonGroup aria-label=\"Crop actions\">\n {rotatable && (\n <>\n <Button\n size=\"sm\"\n iconStart=\"rotate-ccw\"\n aria-label=\"Rotate left\"\n onClick={() => turn(-90)}\n />\n <Button\n size=\"sm\"\n iconStart=\"rotate-cw\"\n aria-label=\"Rotate right\"\n onClick={() => turn(90)}\n />\n </>\n )}\n <Button\n size=\"sm\"\n onClick={() => setFraming(CENTRED)}\n >\n Reset\n </Button>\n </ButtonGroup>\n </Stack>\n )}\n </Field>\n </Stack>\n );\n});\n\nexport interface CropToBlobOptions {\n /** Width of the output in pixels; the height follows the crop's aspect. */\n outputWidth?: number;\n /** Quarter turns applied before cropping — pass `state.rotation`. */\n rotation?: number;\n type?: \"image/png\" | \"image/jpeg\" | \"image/webp\";\n quality?: number;\n}\n\n/**\n * Renders a `CropRect` to an image blob in the browser. Same-origin or\n * CORS-enabled sources only — a tainted canvas cannot be exported.\n */\nexport async function cropToBlob(\n src: string,\n crop: CropRect,\n { outputWidth, rotation = 0, type = \"image/png\", quality = 0.92 }: CropToBlobOptions = {},\n): Promise<Blob> {\n const image = new Image();\n image.crossOrigin = \"anonymous\";\n image.src = src;\n await image.decode();\n\n // The crop is expressed against the turned picture, so turn it first.\n const quarter = rotation % 180 !== 0;\n const turned = document.createElement(\"canvas\");\n turned.width = quarter ? image.naturalHeight : image.naturalWidth;\n turned.height = quarter ? image.naturalWidth : image.naturalHeight;\n const turnedContext = turned.getContext(\"2d\");\n if (!turnedContext) throw new Error(\"Canvas 2D context unavailable\");\n turnedContext.translate(turned.width / 2, turned.height / 2);\n turnedContext.rotate((rotation * Math.PI) / 180);\n turnedContext.drawImage(image, -image.naturalWidth / 2, -image.naturalHeight / 2);\n\n const width = outputWidth ?? crop.width;\n const height = Math.round((crop.height / crop.width) * width);\n const canvas = document.createElement(\"canvas\");\n canvas.width = width;\n canvas.height = height;\n const context = canvas.getContext(\"2d\");\n if (!context) throw new Error(\"Canvas 2D context unavailable\");\n context.drawImage(turned, crop.x, crop.y, crop.width, crop.height, 0, 0, width, height);\n\n return new Promise((resolve, reject) => {\n canvas.toBlob(\n (blob) => (blob ? resolve(blob) : reject(new Error(\"Could not encode the crop\"))),\n type,\n quality,\n );\n });\n}\n"],"mappings":"A,qVAmFA,IAAMoB,EAAW,EACXC,EAAmB,CAAE,KAAM,EAAG,SAAU,EAAG,EAAG,GAAK,EAAG,EAAI,EAGhE,SAASC,EAAU,EAAW,EAAW,EAAmC,CAC1E,IAAIC,EAA0B,CAACC,EAAGC,CAAC,EACnC,IAAK,IAAIC,EAAQ,KAAK,MAAMC,EAAU,EAAE,EAAI,EAAGD,EAAQ,EAAG,IACxD,EAAQ,CAAC,EAAIH,EAAM,GAAIA,EAAM,EAAE,EAEjC,OAAOA,CACT,CAGA,SAASK,EAAQ,EAAe,EAAa,EAAkB,EAAc,CAC3E,IAAMC,EAAUC,EAAW,KAAQ,EAC7BC,EAAQF,EAAUG,EAAQ,OAASA,EAAQ,MAC3CC,EAASJ,EAAUG,EAAQ,MAAQA,EAAQ,OACjD,MAAO,CACL,QACA,SACA,MAAO,KAAK,IAAIE,EAAM,MAAQH,EAAOG,EAAM,OAASD,CAAM,EAAIE,CAChE,CACF,CAGA,SAASC,EAAK,EAAsD,CAClE,IAAMC,GAAU,EAA2B,IACzCC,GAAS,MAAQ,OAAO,SAASA,CAAK,EAAIA,EAAQC,EAC9CC,EAAY,GAA8B,KAAK,IAAI,EAAG,KAAK,IAAI,EAAGH,EAAOC,EAAO,EAAG,CAAC,CAAC,EACrFR,GAAc,KAAK,MAAMO,EAAOI,GAAO,SAAU,CAAC,EAAI,EAAE,EAAI,GAAM,IAAO,KAAO,IAChF,CAACjB,EAAGC,GAAKH,EAAUkB,EAASC,GAAO,EAAE,EAAGD,EAASC,GAAO,EAAE,EAAGX,CAAQ,EAC3E,MAAO,CAAE,KAAMO,EAAOI,GAAO,KAAM,CAAC,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