@djangocfg/ui-tools 2.1.389 → 2.1.393

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 (183) hide show
  1. package/README.md +7 -10
  2. package/dist/chunk-PAWJFY3S.mjs +6 -0
  3. package/dist/{chunk-N2XQF2OL.mjs.map → chunk-PAWJFY3S.mjs.map} +1 -1
  4. package/dist/chunk-PK6SKIKE.cjs +8 -0
  5. package/dist/{chunk-OLISEQHS.cjs.map → chunk-PK6SKIKE.cjs.map} +1 -1
  6. package/dist/file-icon/index.cjs +6 -6
  7. package/dist/file-icon/index.d.cts +1 -1
  8. package/dist/file-icon/index.d.ts +1 -1
  9. package/dist/file-icon/index.mjs +1 -1
  10. package/dist/tree/index.cjs +1372 -143
  11. package/dist/tree/index.cjs.map +1 -1
  12. package/dist/tree/index.d.cts +2 -2
  13. package/dist/tree/index.d.ts +2 -2
  14. package/dist/tree/index.mjs +1322 -3
  15. package/dist/tree/index.mjs.map +1 -1
  16. package/dist/{types-CevSbyfD.d.cts → types-B_zhyAqR.d.cts} +1 -1
  17. package/dist/{types-CevSbyfD.d.ts → types-B_zhyAqR.d.ts} +1 -1
  18. package/package.json +9 -17
  19. package/src/tools/AudioPlayer/README.md +4 -4
  20. package/src/tools/Chat/README.md +6 -6
  21. package/src/tools/CronScheduler/index.tsx +1 -1
  22. package/src/tools/CronScheduler/lazy.tsx +1 -1
  23. package/src/tools/ImageViewer/README.md +1 -1
  24. package/src/tools/JsonForm/README.md +2 -2
  25. package/src/tools/MarkdownEditor/README.md +3 -3
  26. package/src/tools/MarkdownMessage/README.md +2 -2
  27. package/src/tools/OpenapiViewer/components/DocsLayout/grouping.ts +5 -1
  28. package/src/tools/SpeechRecognition/README.md +1 -1
  29. package/dist/ChatRoot-EFNXQXXN.cjs +0 -15
  30. package/dist/ChatRoot-EFNXQXXN.cjs.map +0 -1
  31. package/dist/ChatRoot-FITF5RVP.mjs +0 -6
  32. package/dist/ChatRoot-FITF5RVP.mjs.map +0 -1
  33. package/dist/ChatRoot-PNNGQCYF.css +0 -7
  34. package/dist/ChatRoot-PNNGQCYF.css.map +0 -1
  35. package/dist/CronScheduler.client-DLMXCPAJ.mjs +0 -67
  36. package/dist/CronScheduler.client-DLMXCPAJ.mjs.map +0 -1
  37. package/dist/CronScheduler.client-WEJF4PWQ.cjs +0 -72
  38. package/dist/CronScheduler.client-WEJF4PWQ.cjs.map +0 -1
  39. package/dist/DictationField-AS2F33WI.cjs +0 -13
  40. package/dist/DictationField-AS2F33WI.cjs.map +0 -1
  41. package/dist/DictationField-WPONUCYE.mjs +0 -4
  42. package/dist/DictationField-WPONUCYE.mjs.map +0 -1
  43. package/dist/DocsLayout-EKASBSP7.mjs +0 -3448
  44. package/dist/DocsLayout-EKASBSP7.mjs.map +0 -1
  45. package/dist/DocsLayout-MBFIB4NO.css +0 -7
  46. package/dist/DocsLayout-MBFIB4NO.css.map +0 -1
  47. package/dist/DocsLayout-OURFYWQE.cjs +0 -3455
  48. package/dist/DocsLayout-OURFYWQE.cjs.map +0 -1
  49. package/dist/JsonSchemaForm-DD7CLRIG.cjs +0 -13
  50. package/dist/JsonSchemaForm-DD7CLRIG.cjs.map +0 -1
  51. package/dist/JsonSchemaForm-XKUIVELK.mjs +0 -4
  52. package/dist/JsonSchemaForm-XKUIVELK.mjs.map +0 -1
  53. package/dist/JsonTree-43PQAJKY.mjs +0 -5
  54. package/dist/JsonTree-43PQAJKY.mjs.map +0 -1
  55. package/dist/JsonTree-MLET23ZA.css +0 -7
  56. package/dist/JsonTree-MLET23ZA.css.map +0 -1
  57. package/dist/JsonTree-X6W5YEVY.cjs +0 -11
  58. package/dist/JsonTree-X6W5YEVY.cjs.map +0 -1
  59. package/dist/LottiePlayer.client-2S7ISJ2S.cjs +0 -168
  60. package/dist/LottiePlayer.client-2S7ISJ2S.cjs.map +0 -1
  61. package/dist/LottiePlayer.client-5LDSSJWS.mjs +0 -161
  62. package/dist/LottiePlayer.client-5LDSSJWS.mjs.map +0 -1
  63. package/dist/MapContainer-AKIPABJK.mjs +0 -4
  64. package/dist/MapContainer-AKIPABJK.mjs.map +0 -1
  65. package/dist/MapContainer-STVDMC36.cjs +0 -17
  66. package/dist/MapContainer-STVDMC36.cjs.map +0 -1
  67. package/dist/Mermaid.client-DDXWXZXY.css +0 -7
  68. package/dist/Mermaid.client-DDXWXZXY.css.map +0 -1
  69. package/dist/Mermaid.client-NL4SVR7F.mjs +0 -481
  70. package/dist/Mermaid.client-NL4SVR7F.mjs.map +0 -1
  71. package/dist/Mermaid.client-NNTI6DFX.cjs +0 -487
  72. package/dist/Mermaid.client-NNTI6DFX.cjs.map +0 -1
  73. package/dist/Player-BRV7XTWR.mjs +0 -4
  74. package/dist/Player-BRV7XTWR.mjs.map +0 -1
  75. package/dist/Player-PM7F7DD7.cjs +0 -13
  76. package/dist/Player-PM7F7DD7.cjs.map +0 -1
  77. package/dist/Player-ZGQKKOWI.css +0 -66
  78. package/dist/Player-ZGQKKOWI.css.map +0 -1
  79. package/dist/PrettyCode.client-GWFAIVFN.css +0 -7
  80. package/dist/PrettyCode.client-GWFAIVFN.css.map +0 -1
  81. package/dist/PrettyCode.client-KOHDVPPN.cjs +0 -285
  82. package/dist/PrettyCode.client-KOHDVPPN.cjs.map +0 -1
  83. package/dist/PrettyCode.client-ZGYGKE7G.mjs +0 -283
  84. package/dist/PrettyCode.client-ZGYGKE7G.mjs.map +0 -1
  85. package/dist/TreeRoot-5COOOSWG.mjs +0 -4
  86. package/dist/TreeRoot-5COOOSWG.mjs.map +0 -1
  87. package/dist/TreeRoot-AABP2J6Y.cjs +0 -19
  88. package/dist/TreeRoot-AABP2J6Y.cjs.map +0 -1
  89. package/dist/chunk-2NG4SXEP.mjs +0 -743
  90. package/dist/chunk-2NG4SXEP.mjs.map +0 -1
  91. package/dist/chunk-4LFB7I5K.cjs +0 -1387
  92. package/dist/chunk-4LFB7I5K.cjs.map +0 -1
  93. package/dist/chunk-5D2OCOPQ.cjs +0 -222
  94. package/dist/chunk-5D2OCOPQ.cjs.map +0 -1
  95. package/dist/chunk-5I5QNGUG.cjs +0 -611
  96. package/dist/chunk-5I5QNGUG.cjs.map +0 -1
  97. package/dist/chunk-6ZX2G25W.mjs +0 -1361
  98. package/dist/chunk-6ZX2G25W.mjs.map +0 -1
  99. package/dist/chunk-76NNDZH6.cjs +0 -1061
  100. package/dist/chunk-76NNDZH6.cjs.map +0 -1
  101. package/dist/chunk-7CWGZPO3.mjs +0 -214
  102. package/dist/chunk-7CWGZPO3.mjs.map +0 -1
  103. package/dist/chunk-7EYHNP3E.cjs +0 -965
  104. package/dist/chunk-7EYHNP3E.cjs.map +0 -1
  105. package/dist/chunk-7IYXZUJO.cjs +0 -769
  106. package/dist/chunk-7IYXZUJO.cjs.map +0 -1
  107. package/dist/chunk-ADEN3UA4.cjs +0 -892
  108. package/dist/chunk-ADEN3UA4.cjs.map +0 -1
  109. package/dist/chunk-B6IR5KSC.mjs +0 -59
  110. package/dist/chunk-B6IR5KSC.mjs.map +0 -1
  111. package/dist/chunk-C6GXVH5J.mjs +0 -338
  112. package/dist/chunk-C6GXVH5J.mjs.map +0 -1
  113. package/dist/chunk-DMX7W4XZ.mjs +0 -1113
  114. package/dist/chunk-DMX7W4XZ.mjs.map +0 -1
  115. package/dist/chunk-ECONRHIG.mjs +0 -212
  116. package/dist/chunk-ECONRHIG.mjs.map +0 -1
  117. package/dist/chunk-FEN5S772.cjs +0 -1227
  118. package/dist/chunk-FEN5S772.cjs.map +0 -1
  119. package/dist/chunk-FP2RLYQZ.cjs +0 -187
  120. package/dist/chunk-FP2RLYQZ.cjs.map +0 -1
  121. package/dist/chunk-FVVF7VCD.cjs +0 -1325
  122. package/dist/chunk-FVVF7VCD.cjs.map +0 -1
  123. package/dist/chunk-GYIO7W7M.mjs +0 -1197
  124. package/dist/chunk-GYIO7W7M.mjs.map +0 -1
  125. package/dist/chunk-KNDLV4PI.cjs +0 -1356
  126. package/dist/chunk-KNDLV4PI.cjs.map +0 -1
  127. package/dist/chunk-KNEQRUBA.mjs +0 -181
  128. package/dist/chunk-KNEQRUBA.mjs.map +0 -1
  129. package/dist/chunk-N2XQF2OL.mjs +0 -14
  130. package/dist/chunk-N4MZYNR4.mjs +0 -1342
  131. package/dist/chunk-N4MZYNR4.mjs.map +0 -1
  132. package/dist/chunk-NTVBIIUD.mjs +0 -1439
  133. package/dist/chunk-NTVBIIUD.mjs.map +0 -1
  134. package/dist/chunk-OBRSGM64.mjs +0 -607
  135. package/dist/chunk-OBRSGM64.mjs.map +0 -1
  136. package/dist/chunk-ODO4GMW7.mjs +0 -79
  137. package/dist/chunk-ODO4GMW7.mjs.map +0 -1
  138. package/dist/chunk-OLISEQHS.cjs +0 -18
  139. package/dist/chunk-PVAX67JG.mjs +0 -1041
  140. package/dist/chunk-PVAX67JG.mjs.map +0 -1
  141. package/dist/chunk-QJ6GTUCO.cjs +0 -81
  142. package/dist/chunk-QJ6GTUCO.cjs.map +0 -1
  143. package/dist/chunk-T3MWM23F.cjs +0 -214
  144. package/dist/chunk-T3MWM23F.cjs.map +0 -1
  145. package/dist/chunk-TBSHZO5R.cjs +0 -1134
  146. package/dist/chunk-TBSHZO5R.cjs.map +0 -1
  147. package/dist/chunk-UNCS5V5F.mjs +0 -887
  148. package/dist/chunk-UNCS5V5F.mjs.map +0 -1
  149. package/dist/chunk-VWQ5WOIL.mjs +0 -2059
  150. package/dist/chunk-VWQ5WOIL.mjs.map +0 -1
  151. package/dist/chunk-W75B7Y6C.cjs +0 -1478
  152. package/dist/chunk-W75B7Y6C.cjs.map +0 -1
  153. package/dist/chunk-Y6UTOBF6.mjs +0 -938
  154. package/dist/chunk-Y6UTOBF6.mjs.map +0 -1
  155. package/dist/chunk-YDPDTOSP.cjs +0 -2061
  156. package/dist/chunk-YDPDTOSP.cjs.map +0 -1
  157. package/dist/chunk-YW5IVWHQ.cjs +0 -346
  158. package/dist/chunk-YW5IVWHQ.cjs.map +0 -1
  159. package/dist/chunk-YXZ6GU7H.cjs +0 -63
  160. package/dist/chunk-YXZ6GU7H.cjs.map +0 -1
  161. package/dist/chunk-ZL7FH4NW.mjs +0 -1274
  162. package/dist/chunk-ZL7FH4NW.mjs.map +0 -1
  163. package/dist/components-EHOGXATG.cjs +0 -22
  164. package/dist/components-EHOGXATG.cjs.map +0 -1
  165. package/dist/components-MQ6DR7TX.cjs +0 -26
  166. package/dist/components-MQ6DR7TX.cjs.map +0 -1
  167. package/dist/components-XRX7QGLB.mjs +0 -5
  168. package/dist/components-XRX7QGLB.mjs.map +0 -1
  169. package/dist/components-YATKRWLH.mjs +0 -5
  170. package/dist/components-YATKRWLH.mjs.map +0 -1
  171. package/dist/index.cjs +0 -3674
  172. package/dist/index.cjs.map +0 -1
  173. package/dist/index.css +0 -234
  174. package/dist/index.css.map +0 -1
  175. package/dist/index.d.cts +0 -4929
  176. package/dist/index.d.ts +0 -4929
  177. package/dist/index.mjs +0 -2912
  178. package/dist/index.mjs.map +0 -1
  179. package/dist/launcher-5Y42OBSN.mjs +0 -6
  180. package/dist/launcher-5Y42OBSN.mjs.map +0 -1
  181. package/dist/launcher-PMW2YB24.cjs +0 -59
  182. package/dist/launcher-PMW2YB24.cjs.map +0 -1
  183. package/src/index.ts +0 -157
@@ -1,1227 +0,0 @@
1
- 'use strict';
2
-
3
- var chunkOLISEQHS_cjs = require('./chunk-OLISEQHS.cjs');
4
- var consola2 = require('consola');
5
- var lib = require('@djangocfg/ui-core/lib');
6
- var lucideReact = require('lucide-react');
7
- var react = require('react');
8
- var components = require('@djangocfg/ui-core/components');
9
- var Form = require('@rjsf/core');
10
- var validator = require('@rjsf/validator-ajv8');
11
- var jsxRuntime = require('react/jsx-runtime');
12
- var utils = require('@rjsf/utils');
13
- var i18n = require('@djangocfg/i18n');
14
-
15
- function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
16
-
17
- var consola2__default = /*#__PURE__*/_interopDefault(consola2);
18
- var Form__default = /*#__PURE__*/_interopDefault(Form);
19
- var validator__default = /*#__PURE__*/_interopDefault(validator);
20
-
21
- function FieldTemplate(props) {
22
- const {
23
- id,
24
- classNames,
25
- style,
26
- label,
27
- help,
28
- required,
29
- description,
30
- errors,
31
- children,
32
- displayLabel,
33
- hidden,
34
- rawErrors
35
- } = props;
36
- const formContext = props.formContext;
37
- if (hidden) {
38
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "hidden", children });
39
- }
40
- const hasError = rawErrors && rawErrors.length > 0;
41
- const density = formContext?.density ?? "comfortable";
42
- const compact = density === "compact";
43
- const descriptionText = typeof description === "string" ? description : void 0;
44
- const labelTitle = compact ? descriptionText : void 0;
45
- const showDescription = !compact && Boolean(description);
46
- return /* @__PURE__ */ jsxRuntime.jsxs(
47
- "div",
48
- {
49
- className: lib.cn(compact ? "space-y-1" : "space-y-2", classNames),
50
- style,
51
- children: [
52
- displayLabel && label && /* @__PURE__ */ jsxRuntime.jsxs(
53
- components.Label,
54
- {
55
- htmlFor: id,
56
- className: lib.cn(
57
- hasError && "text-destructive",
58
- compact && "text-[10px] font-semibold uppercase tracking-wide text-muted-foreground/70"
59
- ),
60
- title: labelTitle,
61
- children: [
62
- label,
63
- required && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-destructive ml-1", children: "*" })
64
- ]
65
- }
66
- ),
67
- showDescription && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-sm text-muted-foreground", children: description }),
68
- /* @__PURE__ */ jsxRuntime.jsx("div", { children }),
69
- errors && /* @__PURE__ */ jsxRuntime.jsx("div", { className: compact ? "text-xs text-destructive" : "text-sm text-destructive", children: errors }),
70
- help && !compact && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-sm text-muted-foreground", children: help })
71
- ]
72
- }
73
- );
74
- }
75
- chunkOLISEQHS_cjs.__name(FieldTemplate, "FieldTemplate");
76
- function ObjectFieldTemplate(props) {
77
- const {
78
- title,
79
- description,
80
- properties,
81
- required,
82
- uiSchema
83
- } = props;
84
- const formContext = props.formContext;
85
- const isCollapsible = uiSchema?.["ui:collapsible"] === true;
86
- const defaultCollapsed = uiSchema?.["ui:collapsed"] === true;
87
- const gridCols = uiSchema?.["ui:grid"];
88
- const className = uiSchema?.["ui:className"];
89
- const uiGroups = uiSchema?.["ui:groups"];
90
- const density = formContext?.density ?? "comfortable";
91
- const compact = density === "compact";
92
- const [isOpen, setIsOpen] = react.useState(!defaultCollapsed);
93
- const isRoot = !title;
94
- const gridClass = gridCols ? `grid gap-4 grid-cols-${gridCols}` : compact ? "space-y-2" : "space-y-4";
95
- const groupedContent = uiGroups ? renderUiGroups({ properties, uiGroups, gridClass, className, compact }) : null;
96
- const content = groupedContent ?? /* @__PURE__ */ jsxRuntime.jsx("div", { className: lib.cn(gridClass, className), children: properties.map((element) => /* @__PURE__ */ jsxRuntime.jsx("div", { className: "property-wrapper", children: element.content }, element.name)) });
97
- if (isRoot) {
98
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-6", children: content });
99
- }
100
- if (isCollapsible) {
101
- return /* @__PURE__ */ jsxRuntime.jsxs(components.Collapsible, { open: isOpen, onOpenChange: setIsOpen, className: "space-y-2", children: [
102
- /* @__PURE__ */ jsxRuntime.jsxs(components.CollapsibleTrigger, { className: "flex w-full items-center justify-between rounded-lg border bg-muted/50 px-4 py-3 text-left hover:bg-muted transition-colors", children: [
103
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
104
- /* @__PURE__ */ jsxRuntime.jsxs("h3", { className: "text-sm font-semibold", children: [
105
- title,
106
- required && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-destructive ml-1", children: "*" })
107
- ] }),
108
- description && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-muted-foreground mt-0.5", children: description })
109
- ] }),
110
- /* @__PURE__ */ jsxRuntime.jsx(
111
- lucideReact.ChevronDown,
112
- {
113
- className: lib.cn(
114
- "h-4 w-4 text-muted-foreground transition-transform duration-200",
115
- isOpen && "rotate-180"
116
- )
117
- }
118
- )
119
- ] }),
120
- /* @__PURE__ */ jsxRuntime.jsx(components.CollapsibleContent, { className: "pl-1 pr-1 pt-2", children: content })
121
- ] });
122
- }
123
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-4", children: [
124
- title && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "border-b pb-2", children: [
125
- /* @__PURE__ */ jsxRuntime.jsxs("h3", { className: "text-sm font-semibold", children: [
126
- title,
127
- required && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-destructive ml-1", children: "*" })
128
- ] }),
129
- description && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-muted-foreground mt-1", children: description })
130
- ] }),
131
- content
132
- ] });
133
- }
134
- chunkOLISEQHS_cjs.__name(ObjectFieldTemplate, "ObjectFieldTemplate");
135
- function renderUiGroups({
136
- properties,
137
- uiGroups,
138
- gridClass,
139
- className,
140
- compact
141
- }) {
142
- const propsByName = new Map(properties.map((p) => [p.name, p]));
143
- const groupedFieldNames = new Set(uiGroups.flatMap((g) => g.fields));
144
- const ungrouped = properties.filter((p) => !groupedFieldNames.has(p.name));
145
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: lib.cn(compact ? "space-y-2" : "space-y-3", className), children: [
146
- ungrouped.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: gridClass, children: ungrouped.map((element) => /* @__PURE__ */ jsxRuntime.jsx("div", { className: "property-wrapper", children: element.content }, element.name)) }) : null,
147
- uiGroups.map((group) => {
148
- const groupProps = group.fields.map((name) => propsByName.get(name)).filter((p) => Boolean(p));
149
- if (groupProps.length === 0) return null;
150
- return /* @__PURE__ */ jsxRuntime.jsx(
151
- UiGroupSection,
152
- {
153
- group,
154
- gridClass,
155
- compact,
156
- children: groupProps.map((element) => /* @__PURE__ */ jsxRuntime.jsx("div", { className: "property-wrapper", children: element.content }, element.name))
157
- },
158
- group.title
159
- );
160
- })
161
- ] });
162
- }
163
- chunkOLISEQHS_cjs.__name(renderUiGroups, "renderUiGroups");
164
- function UiGroupSection({ group, gridClass, compact, children }) {
165
- const [open, setOpen] = react.useState(group.defaultOpen ?? true);
166
- return /* @__PURE__ */ jsxRuntime.jsxs(components.Collapsible, { open, onOpenChange: setOpen, children: [
167
- /* @__PURE__ */ jsxRuntime.jsxs(
168
- components.CollapsibleTrigger,
169
- {
170
- className: lib.cn(
171
- "flex w-full items-center gap-1.5 py-1 transition-colors hover:text-foreground",
172
- compact ? "text-[10px] font-semibold uppercase tracking-wide text-muted-foreground/70" : "text-xs font-semibold uppercase tracking-wide text-muted-foreground"
173
- ),
174
- children: [
175
- /* @__PURE__ */ jsxRuntime.jsx(
176
- lucideReact.ChevronRight,
177
- {
178
- className: lib.cn(
179
- "h-3 w-3 shrink-0 transition-transform duration-200",
180
- open && "rotate-90"
181
- ),
182
- "aria-hidden": true
183
- }
184
- ),
185
- /* @__PURE__ */ jsxRuntime.jsx("span", { children: group.title })
186
- ]
187
- }
188
- ),
189
- /* @__PURE__ */ jsxRuntime.jsx(components.CollapsibleContent, { className: "overflow-hidden data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: lib.cn("border-l border-border/40 pl-3 pb-2 pt-1", gridClass), children }) })
190
- ] });
191
- }
192
- chunkOLISEQHS_cjs.__name(UiGroupSection, "UiGroupSection");
193
- function ArrayFieldTemplate(props) {
194
- const {
195
- title,
196
- items,
197
- canAdd,
198
- onAddClick,
199
- required
200
- } = props;
201
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-4", children: [
202
- title && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between", children: [
203
- /* @__PURE__ */ jsxRuntime.jsxs("h3", { className: "text-lg font-semibold", children: [
204
- title,
205
- required && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-destructive ml-1", children: "*" })
206
- ] }),
207
- canAdd && /* @__PURE__ */ jsxRuntime.jsxs(
208
- components.Button,
209
- {
210
- type: "button",
211
- variant: "outline",
212
- size: "sm",
213
- onClick: onAddClick,
214
- className: "gap-2",
215
- children: [
216
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Plus, { className: "h-4 w-4" }),
217
- "Add Item"
218
- ]
219
- }
220
- )
221
- ] }),
222
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-3", children: items }),
223
- items.length === 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-center py-8 text-muted-foreground border-2 border-dashed rounded-md", children: [
224
- "No items added yet.",
225
- canAdd && /* @__PURE__ */ jsxRuntime.jsxs(
226
- components.Button,
227
- {
228
- type: "button",
229
- variant: "ghost",
230
- size: "sm",
231
- onClick: onAddClick,
232
- className: "mt-2 gap-2",
233
- children: [
234
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Plus, { className: "h-4 w-4" }),
235
- "Add First Item"
236
- ]
237
- }
238
- )
239
- ] })
240
- ] });
241
- }
242
- chunkOLISEQHS_cjs.__name(ArrayFieldTemplate, "ArrayFieldTemplate");
243
- function ArrayFieldItemTemplate(props) {
244
- const {
245
- children,
246
- className,
247
- buttonsProps,
248
- hasToolbar,
249
- registry,
250
- uiSchema
251
- } = props;
252
- const uiOptions = utils.getUiOptions(uiSchema);
253
- const ArrayFieldItemButtonsTemplate = utils.getTemplate(
254
- "ArrayFieldItemButtonsTemplate",
255
- registry,
256
- uiOptions
257
- );
258
- return /* @__PURE__ */ jsxRuntime.jsxs(
259
- "div",
260
- {
261
- className: lib.cn(
262
- "flex gap-2 items-start p-4 rounded-md border bg-card",
263
- className
264
- ),
265
- children: [
266
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1", children }),
267
- hasToolbar && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center gap-1", children: /* @__PURE__ */ jsxRuntime.jsx(ArrayFieldItemButtonsTemplate, { ...buttonsProps }) })
268
- ]
269
- }
270
- );
271
- }
272
- chunkOLISEQHS_cjs.__name(ArrayFieldItemTemplate, "ArrayFieldItemTemplate");
273
- function ErrorListTemplate(props) {
274
- const { errors } = props;
275
- if (!errors || errors.length === 0) {
276
- return null;
277
- }
278
- return /* @__PURE__ */ jsxRuntime.jsxs(components.Alert, { variant: "destructive", className: "mb-6", children: [
279
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.AlertCircle, { className: "h-4 w-4" }),
280
- /* @__PURE__ */ jsxRuntime.jsx(components.AlertTitle, { children: "Validation Errors" }),
281
- /* @__PURE__ */ jsxRuntime.jsx(components.AlertDescription, { children: /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "list-disc list-inside space-y-1 mt-2", children: errors.map((error, index) => /* @__PURE__ */ jsxRuntime.jsx("li", { className: "text-sm", children: error.stack }, index)) }) })
282
- ] });
283
- }
284
- chunkOLISEQHS_cjs.__name(ErrorListTemplate, "ErrorListTemplate");
285
- function BaseInputTemplate(props) {
286
- const {
287
- id,
288
- type,
289
- value,
290
- readonly,
291
- disabled,
292
- autofocus,
293
- onBlur,
294
- onFocus,
295
- onChange,
296
- options,
297
- schema,
298
- rawErrors,
299
- placeholder
300
- } = props;
301
- const inputProps = react.useMemo(() => {
302
- return utils.getInputProps(schema, type, options);
303
- }, [schema, type, options]);
304
- const safeValue = react.useMemo(() => {
305
- if (value === null || value === void 0) return "";
306
- return String(value);
307
- }, [value]);
308
- const hasError = react.useMemo(() => {
309
- return rawErrors && rawErrors.length > 0;
310
- }, [rawErrors]);
311
- const handleChange = react.useCallback((event) => {
312
- const val = event.target.value;
313
- if (val === "") {
314
- onChange(options?.emptyValue ?? "");
315
- return;
316
- }
317
- if (inputProps.type === "number" || schema.type === "number" || schema.type === "integer") {
318
- const num = Number(val);
319
- onChange(isNaN(num) ? val : num);
320
- return;
321
- }
322
- onChange(val);
323
- }, [onChange, inputProps.type, schema.type, options?.emptyValue]);
324
- const handleBlur = react.useCallback((event) => {
325
- onBlur(id, event.target.value);
326
- }, [id, onBlur]);
327
- const handleFocus = react.useCallback((event) => {
328
- onFocus(id, event.target.value);
329
- }, [id, onFocus]);
330
- const inputType = react.useMemo(() => {
331
- if (inputProps.type) return inputProps.type;
332
- if (schema.type === "number" || schema.type === "integer") return "number";
333
- return "text";
334
- }, [inputProps.type, schema.type]);
335
- return /* @__PURE__ */ jsxRuntime.jsx(
336
- components.Input,
337
- {
338
- id,
339
- type: inputType,
340
- value: safeValue,
341
- disabled,
342
- readOnly: readonly,
343
- autoFocus: autofocus,
344
- onChange: handleChange,
345
- onBlur: handleBlur,
346
- onFocus: handleFocus,
347
- placeholder,
348
- className: hasError ? "border-destructive" : "",
349
- step: inputProps.step,
350
- min: inputProps.min,
351
- max: inputProps.max
352
- }
353
- );
354
- }
355
- chunkOLISEQHS_cjs.__name(BaseInputTemplate, "BaseInputTemplate");
356
- function validateSchema(schema) {
357
- if (!schema || typeof schema !== "object") {
358
- if (lib.isDev) {
359
- consola2__default.default.error("[JsonSchemaForm] Invalid schema: must be an object", schema);
360
- }
361
- return null;
362
- }
363
- const hasValidStructure = schema.type || schema.properties || schema.$ref || schema.$schema;
364
- if (!hasValidStructure) {
365
- if (lib.isDev) {
366
- consola2__default.default.error("[JsonSchemaForm] Invalid schema: missing type, properties, $ref, or $schema", schema);
367
- }
368
- return null;
369
- }
370
- if (lib.isDev) {
371
- consola2__default.default.success("[JsonSchemaForm] Schema validated successfully:", {
372
- type: schema.type,
373
- title: schema.title,
374
- hasProperties: !!schema.properties,
375
- hasRequired: !!schema.required
376
- });
377
- }
378
- return schema;
379
- }
380
- chunkOLISEQHS_cjs.__name(validateSchema, "validateSchema");
381
- function normalizeFormData(formData, schema) {
382
- if (formData === null || formData === void 0) {
383
- return schema.type === "object" ? {} : schema.type === "array" ? [] : null;
384
- }
385
- const normalized = JSON.parse(JSON.stringify(formData));
386
- return removeUndefined(normalized);
387
- }
388
- chunkOLISEQHS_cjs.__name(normalizeFormData, "normalizeFormData");
389
- function removeUndefined(obj) {
390
- if (obj === null || obj === void 0) {
391
- return obj;
392
- }
393
- if (Array.isArray(obj)) {
394
- return obj.map(removeUndefined).filter((item) => item !== void 0);
395
- }
396
- if (typeof obj === "object") {
397
- const cleaned = {};
398
- for (const key in obj) {
399
- if (obj[key] !== void 0) {
400
- cleaned[key] = removeUndefined(obj[key]);
401
- }
402
- }
403
- return cleaned;
404
- }
405
- return obj;
406
- }
407
- chunkOLISEQHS_cjs.__name(removeUndefined, "removeUndefined");
408
- function mergeDefaults(formData, schema) {
409
- if (!schema) return formData;
410
- const result = { ...formData };
411
- if (schema.type === "object" && schema.properties) {
412
- for (const [key, propSchema] of Object.entries(schema.properties)) {
413
- const prop = propSchema;
414
- if (result[key] === void 0 && prop.default !== void 0) {
415
- result[key] = prop.default;
416
- }
417
- if (prop.type === "object" && result[key]) {
418
- result[key] = mergeDefaults(result[key], prop);
419
- }
420
- }
421
- }
422
- return result;
423
- }
424
- chunkOLISEQHS_cjs.__name(mergeDefaults, "mergeDefaults");
425
- function safeJsonParse(jsonString, fallback) {
426
- try {
427
- return JSON.parse(jsonString);
428
- } catch (error) {
429
- consola2__default.default.error("[JsonSchemaForm] JSON parse error:", error);
430
- return fallback;
431
- }
432
- }
433
- chunkOLISEQHS_cjs.__name(safeJsonParse, "safeJsonParse");
434
- function safeJsonStringify(obj, pretty = true) {
435
- try {
436
- return JSON.stringify(obj, null, pretty ? 2 : 0);
437
- } catch (error) {
438
- consola2__default.default.error("[JsonSchemaForm] JSON stringify error:", error);
439
- return "{}";
440
- }
441
- }
442
- chunkOLISEQHS_cjs.__name(safeJsonStringify, "safeJsonStringify");
443
- function hasRequiredFields(schema) {
444
- return Array.isArray(schema.required) && schema.required.length > 0;
445
- }
446
- chunkOLISEQHS_cjs.__name(hasRequiredFields, "hasRequiredFields");
447
- function getRequiredFields(schema, prefix = "") {
448
- const required = [];
449
- if (schema.required && Array.isArray(schema.required)) {
450
- required.push(...schema.required.map(
451
- (field) => prefix ? `${prefix}.${field}` : field
452
- ));
453
- }
454
- if (schema.type === "object" && schema.properties) {
455
- for (const [key, propSchema] of Object.entries(schema.properties)) {
456
- const prop = propSchema;
457
- const fieldPath = prefix ? `${prefix}.${key}` : key;
458
- required.push(...getRequiredFields(prop, fieldPath));
459
- }
460
- }
461
- return required;
462
- }
463
- chunkOLISEQHS_cjs.__name(getRequiredFields, "getRequiredFields");
464
- function validateRequiredFields(formData, schema) {
465
- const requiredFields = getRequiredFields(schema);
466
- const missing = [];
467
- for (const field of requiredFields) {
468
- const value = getNestedValue(formData, field);
469
- if (value === void 0 || value === null || value === "") {
470
- missing.push(field);
471
- }
472
- }
473
- return {
474
- valid: missing.length === 0,
475
- missing
476
- };
477
- }
478
- chunkOLISEQHS_cjs.__name(validateRequiredFields, "validateRequiredFields");
479
- function getNestedValue(obj, path) {
480
- return path.split(".").reduce((current, key) => current?.[key], obj);
481
- }
482
- chunkOLISEQHS_cjs.__name(getNestedValue, "getNestedValue");
483
- function evaluateDisabledWhen(rule, formData) {
484
- if (!rule) return false;
485
- const value = getNestedValue(formData, rule.path);
486
- if ("eq" in rule) return value === rule.eq;
487
- if ("notEq" in rule) return value !== rule.notEq;
488
- if ("in" in rule) return rule.in.includes(value);
489
- if ("notIn" in rule) return !rule.notIn.includes(value);
490
- if ("truthy" in rule) return Boolean(value);
491
- if ("falsy" in rule) return !value;
492
- return false;
493
- }
494
- chunkOLISEQHS_cjs.__name(evaluateDisabledWhen, "evaluateDisabledWhen");
495
- function TextWidget(props) {
496
- const {
497
- id,
498
- placeholder,
499
- required,
500
- disabled,
501
- readonly,
502
- autofocus,
503
- value,
504
- onChange,
505
- onBlur,
506
- onFocus,
507
- options,
508
- schema,
509
- rawErrors
510
- } = props;
511
- const config = react.useMemo(() => ({
512
- isTextarea: options?.widget === "textarea",
513
- rows: options?.rows || 3,
514
- emptyValue: options?.emptyValue
515
- }), [options]);
516
- const safeValue = react.useMemo(() => {
517
- if (value === null || value === void 0) return "";
518
- return String(value);
519
- }, [value]);
520
- const hasError = react.useMemo(() => {
521
- return rawErrors && rawErrors.length > 0;
522
- }, [rawErrors]);
523
- const handleChange = react.useCallback((event) => {
524
- const newValue = event.target.value;
525
- onChange(newValue === "" ? config.emptyValue : newValue);
526
- }, [onChange, config.emptyValue]);
527
- const handleBlur = react.useCallback((event) => {
528
- onBlur(id, event.target.value);
529
- }, [id, onBlur]);
530
- const handleFocus = react.useCallback((event) => {
531
- onFocus(id, event.target.value);
532
- }, [id, onFocus]);
533
- if (config.isTextarea) {
534
- return /* @__PURE__ */ jsxRuntime.jsx(
535
- "textarea",
536
- {
537
- id,
538
- className: `flex min-h-[80px] w-full rounded-md border ${hasError ? "border-destructive" : "border-input"} bg-transparent px-3 py-2 text-base shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm`,
539
- placeholder,
540
- disabled: disabled || readonly,
541
- readOnly: readonly,
542
- autoFocus: autofocus,
543
- value: safeValue,
544
- required,
545
- onChange: handleChange,
546
- onBlur: handleBlur,
547
- onFocus: handleFocus,
548
- rows: config.rows
549
- }
550
- );
551
- }
552
- return /* @__PURE__ */ jsxRuntime.jsx(
553
- components.Input,
554
- {
555
- id,
556
- type: "text",
557
- placeholder,
558
- disabled,
559
- readOnly: readonly,
560
- autoFocus: autofocus,
561
- value: safeValue,
562
- required,
563
- onChange: handleChange,
564
- onBlur: handleBlur,
565
- onFocus: handleFocus,
566
- className: hasError ? "border-destructive" : ""
567
- }
568
- );
569
- }
570
- chunkOLISEQHS_cjs.__name(TextWidget, "TextWidget");
571
- function NumberWidget(props) {
572
- const {
573
- id,
574
- placeholder,
575
- required,
576
- disabled,
577
- readonly,
578
- autofocus,
579
- value,
580
- onChange,
581
- onBlur,
582
- onFocus,
583
- options,
584
- schema,
585
- rawErrors
586
- } = props;
587
- const config = react.useMemo(() => ({
588
- isInteger: schema.type === "integer",
589
- step: schema.type === "integer" ? "1" : "any",
590
- min: schema.minimum,
591
- max: schema.maximum,
592
- emptyValue: options?.emptyValue
593
- }), [schema, options]);
594
- const safeValue = react.useMemo(() => {
595
- if (value === null || value === void 0 || value === "") return "";
596
- if (typeof value === "number" && !isNaN(value)) return value;
597
- return "";
598
- }, [value]);
599
- const hasError = react.useMemo(() => {
600
- return rawErrors && rawErrors.length > 0;
601
- }, [rawErrors]);
602
- const handleChange = react.useCallback((event) => {
603
- const newValue = event.target.value;
604
- if (newValue === "") {
605
- onChange(config.emptyValue);
606
- } else {
607
- const parsedValue = config.isInteger ? parseInt(newValue, 10) : parseFloat(newValue);
608
- onChange(isNaN(parsedValue) ? config.emptyValue : parsedValue);
609
- }
610
- }, [onChange, config]);
611
- const handleBlur = react.useCallback((event) => {
612
- onBlur(id, event.target.value);
613
- }, [id, onBlur]);
614
- const handleFocus = react.useCallback((event) => {
615
- onFocus(id, event.target.value);
616
- }, [id, onFocus]);
617
- return /* @__PURE__ */ jsxRuntime.jsx(
618
- components.Input,
619
- {
620
- id,
621
- type: "number",
622
- placeholder,
623
- disabled,
624
- readOnly: readonly,
625
- autoFocus: autofocus,
626
- value: safeValue,
627
- required,
628
- onChange: handleChange,
629
- onBlur: handleBlur,
630
- onFocus: handleFocus,
631
- step: config.step,
632
- min: config.min,
633
- max: config.max,
634
- className: hasError ? "border-destructive" : ""
635
- }
636
- );
637
- }
638
- chunkOLISEQHS_cjs.__name(NumberWidget, "NumberWidget");
639
-
640
- // src/tools/JsonForm/widgets/_useWidgetEnv.ts
641
- function useWidgetEnv(props) {
642
- const { disabled, readonly, formContext, uiSchema, schema } = props;
643
- const density = formContext?.density ?? "comfortable";
644
- const compact = density === "compact";
645
- const disabledWhen = uiSchema?.["ui:disabledWhen"];
646
- const disabledByRule = evaluateDisabledWhen(disabledWhen, formContext?.formData);
647
- const tooltipText = compact ? uiSchema?.["ui:description"] ?? schema?.description : void 0;
648
- return {
649
- density,
650
- compact,
651
- disabled: Boolean(disabled || readonly || disabledByRule),
652
- tooltipText
653
- };
654
- }
655
- chunkOLISEQHS_cjs.__name(useWidgetEnv, "useWidgetEnv");
656
- function CheckboxWidget(props) {
657
- const { id, value, autofocus, onChange, onBlur, onFocus } = props;
658
- const { disabled, tooltipText } = useWidgetEnv(props);
659
- const handleChange = /* @__PURE__ */ chunkOLISEQHS_cjs.__name((checked) => {
660
- onChange(checked);
661
- }, "handleChange");
662
- return /* @__PURE__ */ jsxRuntime.jsx(
663
- components.Checkbox,
664
- {
665
- id,
666
- checked: value || false,
667
- disabled,
668
- autoFocus: autofocus,
669
- onCheckedChange: handleChange,
670
- onBlur: () => onBlur(id, value),
671
- onFocus: () => onFocus(id, value),
672
- title: tooltipText
673
- }
674
- );
675
- }
676
- chunkOLISEQHS_cjs.__name(CheckboxWidget, "CheckboxWidget");
677
- function SelectWidget(props) {
678
- const {
679
- id,
680
- options,
681
- value,
682
- required,
683
- autofocus,
684
- onChange,
685
- onBlur,
686
- onFocus,
687
- placeholder,
688
- rawErrors
689
- } = props;
690
- const { disabled, compact, tooltipText } = useWidgetEnv(props);
691
- const enumOptions = react.useMemo(() => {
692
- const opts = options?.enumOptions;
693
- if (!Array.isArray(opts)) return [];
694
- return opts.filter((opt) => opt && opt.value !== void 0);
695
- }, [options]);
696
- const hasError = react.useMemo(() => {
697
- return rawErrors && rawErrors.length > 0;
698
- }, [rawErrors]);
699
- const safeValue = react.useMemo(() => {
700
- if (value === null || value === void 0) return "";
701
- return String(value);
702
- }, [value]);
703
- const handleChange = react.useCallback((newValue) => {
704
- onChange(newValue);
705
- onBlur(id, newValue);
706
- }, [onChange, onBlur, id]);
707
- if (enumOptions.length === 0) {
708
- return /* @__PURE__ */ jsxRuntime.jsx(
709
- "input",
710
- {
711
- id,
712
- type: "text",
713
- value: safeValue,
714
- onChange: (e) => onChange(e.target.value),
715
- onBlur: (e) => onBlur(id, e.target.value),
716
- onFocus: (e) => onFocus(id, e.target.value),
717
- disabled,
718
- readOnly: disabled,
719
- title: tooltipText,
720
- className: `flex h-10 w-full rounded-md border ${hasError ? "border-destructive" : "border-input"} bg-transparent px-3 py-2 text-base shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm`,
721
- placeholder
722
- }
723
- );
724
- }
725
- return /* @__PURE__ */ jsxRuntime.jsxs(
726
- components.Select,
727
- {
728
- value: safeValue,
729
- onValueChange: handleChange,
730
- disabled,
731
- required,
732
- children: [
733
- /* @__PURE__ */ jsxRuntime.jsx(
734
- components.SelectTrigger,
735
- {
736
- id,
737
- className: `${hasError ? "border-destructive" : ""} ${compact ? "h-7 text-xs" : ""}`.trim(),
738
- autoFocus: autofocus,
739
- onFocus: () => onFocus(id, value),
740
- title: tooltipText,
741
- children: /* @__PURE__ */ jsxRuntime.jsx(components.SelectValue, { placeholder: placeholder || "Select an option" })
742
- }
743
- ),
744
- /* @__PURE__ */ jsxRuntime.jsx(components.SelectContent, { children: enumOptions.map((option) => {
745
- const optValue = String(option.value);
746
- return /* @__PURE__ */ jsxRuntime.jsx(components.SelectItem, { value: optValue, children: option.label || optValue }, optValue || "__empty__");
747
- }) })
748
- ]
749
- }
750
- );
751
- }
752
- chunkOLISEQHS_cjs.__name(SelectWidget, "SelectWidget");
753
- function SwitchWidget(props) {
754
- const { id, value, onChange, onBlur, onFocus } = props;
755
- const { disabled, tooltipText } = useWidgetEnv(props);
756
- const handleChange = /* @__PURE__ */ chunkOLISEQHS_cjs.__name((checked) => {
757
- onChange(checked);
758
- }, "handleChange");
759
- return /* @__PURE__ */ jsxRuntime.jsx(
760
- components.Switch,
761
- {
762
- id,
763
- checked: value || false,
764
- disabled,
765
- onCheckedChange: handleChange,
766
- onBlur: () => onBlur(id, value),
767
- onFocus: () => onFocus(id, value),
768
- title: tooltipText
769
- }
770
- );
771
- }
772
- chunkOLISEQHS_cjs.__name(SwitchWidget, "SwitchWidget");
773
- function ColorWidget(props) {
774
- const {
775
- id,
776
- placeholder,
777
- required,
778
- disabled,
779
- readonly,
780
- autofocus,
781
- value,
782
- onChange,
783
- onBlur,
784
- onFocus,
785
- options,
786
- rawErrors
787
- } = props;
788
- const t = i18n.useAppT();
789
- const pickColorLabel = react.useMemo(() => t("tools.color.pick"), [t]);
790
- const colorInputRef = react.useRef(null);
791
- const format = react.useMemo(() => {
792
- if (options?.format) return options.format;
793
- if (typeof value === "string" && value.startsWith("#")) return "hex";
794
- return "hsl";
795
- }, [options?.format, value]);
796
- const safeValue = react.useMemo(() => {
797
- if (value === null || value === void 0) return "";
798
- return String(value);
799
- }, [value]);
800
- const hslToCss = react.useCallback((hslValue) => {
801
- if (!hslValue) return "transparent";
802
- if (hslValue.startsWith("#")) return hslValue;
803
- if (hslValue.startsWith("hsl")) return hslValue;
804
- const parts = hslValue.split(" ");
805
- if (parts.length === 3) {
806
- return `hsl(${parts[0]}, ${parts[1]}, ${parts[2]})`;
807
- }
808
- return "transparent";
809
- }, []);
810
- const previewColor = react.useMemo(() => {
811
- return hslToCss(safeValue);
812
- }, [safeValue, hslToCss]);
813
- const hexToHsl = react.useCallback((hex) => {
814
- hex = hex.replace("#", "");
815
- const r = parseInt(hex.substring(0, 2), 16) / 255;
816
- const g = parseInt(hex.substring(2, 4), 16) / 255;
817
- const b = parseInt(hex.substring(4, 6), 16) / 255;
818
- const max = Math.max(r, g, b);
819
- const min = Math.min(r, g, b);
820
- let h = 0;
821
- let s = 0;
822
- const l = (max + min) / 2;
823
- if (max !== min) {
824
- const d = max - min;
825
- s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
826
- switch (max) {
827
- case r:
828
- h = ((g - b) / d + (g < b ? 6 : 0)) / 6;
829
- break;
830
- case g:
831
- h = ((b - r) / d + 2) / 6;
832
- break;
833
- case b:
834
- h = ((r - g) / d + 4) / 6;
835
- break;
836
- }
837
- }
838
- return `${Math.round(h * 360)} ${Math.round(s * 100)}% ${Math.round(l * 100)}%`;
839
- }, []);
840
- const hslToHex = react.useCallback((hslValue) => {
841
- if (!hslValue || hslValue.startsWith("#")) return hslValue || "#000000";
842
- const parts = hslValue.split(" ");
843
- if (parts.length !== 3) return "#000000";
844
- const h = parseInt(parts[0]) / 360;
845
- const s = parseInt(parts[1].replace("%", "")) / 100;
846
- const l = parseInt(parts[2].replace("%", "")) / 100;
847
- const hue2rgb = /* @__PURE__ */ chunkOLISEQHS_cjs.__name((p, q, t2) => {
848
- if (t2 < 0) t2 += 1;
849
- if (t2 > 1) t2 -= 1;
850
- if (t2 < 1 / 6) return p + (q - p) * 6 * t2;
851
- if (t2 < 1 / 2) return q;
852
- if (t2 < 2 / 3) return p + (q - p) * (2 / 3 - t2) * 6;
853
- return p;
854
- }, "hue2rgb");
855
- let r, g, b;
856
- if (s === 0) {
857
- r = g = b = l;
858
- } else {
859
- const q = l < 0.5 ? l * (1 + s) : l + s - l * s;
860
- const p = 2 * l - q;
861
- r = hue2rgb(p, q, h + 1 / 3);
862
- g = hue2rgb(p, q, h);
863
- b = hue2rgb(p, q, h - 1 / 3);
864
- }
865
- const toHex = /* @__PURE__ */ chunkOLISEQHS_cjs.__name((x) => {
866
- const hex = Math.round(x * 255).toString(16);
867
- return hex.length === 1 ? "0" + hex : hex;
868
- }, "toHex");
869
- return `#${toHex(r)}${toHex(g)}${toHex(b)}`;
870
- }, []);
871
- const hasError = react.useMemo(() => {
872
- return rawErrors && rawErrors.length > 0;
873
- }, [rawErrors]);
874
- const handleChange = react.useCallback((event) => {
875
- const newValue = event.target.value;
876
- onChange(newValue);
877
- }, [onChange]);
878
- const handleColorPickerChange = react.useCallback((event) => {
879
- const hexValue2 = event.target.value;
880
- if (format === "hsl") {
881
- onChange(hexToHsl(hexValue2));
882
- } else {
883
- onChange(hexValue2);
884
- }
885
- }, [onChange, format, hexToHsl]);
886
- const handleBlur = react.useCallback((event) => {
887
- onBlur(id, event.target.value);
888
- }, [id, onBlur]);
889
- const handleFocus = react.useCallback((event) => {
890
- onFocus(id, event.target.value);
891
- }, [id, onFocus]);
892
- const hexValue = react.useMemo(() => {
893
- if (format === "hex" || safeValue.startsWith("#")) {
894
- return safeValue || "#000000";
895
- }
896
- return hslToHex(safeValue);
897
- }, [safeValue, format, hslToHex]);
898
- const handleColorBoxClick = react.useCallback(() => {
899
- if (!disabled && !readonly) {
900
- colorInputRef.current?.click();
901
- }
902
- }, [disabled, readonly]);
903
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
904
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative", children: [
905
- /* @__PURE__ */ jsxRuntime.jsx(
906
- "button",
907
- {
908
- type: "button",
909
- onClick: handleColorBoxClick,
910
- disabled: disabled || readonly,
911
- className: "h-10 w-10 shrink-0 rounded-md border-2 border-input cursor-pointer hover:border-ring focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
912
- style: { backgroundColor: previewColor },
913
- "aria-label": pickColorLabel
914
- }
915
- ),
916
- /* @__PURE__ */ jsxRuntime.jsx(
917
- "input",
918
- {
919
- ref: colorInputRef,
920
- type: "color",
921
- value: hexValue,
922
- onChange: handleColorPickerChange,
923
- className: "absolute inset-0 opacity-0 w-full h-full cursor-pointer",
924
- disabled: disabled || readonly,
925
- tabIndex: -1
926
- }
927
- )
928
- ] }),
929
- /* @__PURE__ */ jsxRuntime.jsx(
930
- components.Input,
931
- {
932
- id,
933
- type: "text",
934
- placeholder: placeholder || (format === "hsl" ? "217 91% 60%" : "#3b82f6"),
935
- disabled,
936
- readOnly: readonly,
937
- autoFocus: autofocus,
938
- value: safeValue,
939
- required,
940
- onChange: handleChange,
941
- onBlur: handleBlur,
942
- onFocus: handleFocus,
943
- className: `flex-1 font-mono text-sm ${hasError ? "border-destructive" : ""}`
944
- }
945
- )
946
- ] });
947
- }
948
- chunkOLISEQHS_cjs.__name(ColorWidget, "ColorWidget");
949
- function SliderWidget(props) {
950
- const {
951
- id,
952
- value,
953
- onChange,
954
- schema,
955
- options,
956
- rawErrors
957
- } = props;
958
- const { disabled, tooltipText } = useWidgetEnv(props);
959
- const config = react.useMemo(() => {
960
- const min = schema.minimum ?? options?.min ?? 0;
961
- const max = schema.maximum ?? options?.max ?? 100;
962
- const step = options?.step ?? (schema.type === "integer" ? 1 : 0.1);
963
- const unit = options?.unit;
964
- const showInput = options?.showInput !== false;
965
- return { min, max, step, unit, showInput };
966
- }, [schema, options]);
967
- const numericValue = react.useMemo(() => {
968
- if (value === null || value === void 0 || value === "") {
969
- return config.min;
970
- }
971
- if (typeof value === "number") {
972
- return value;
973
- }
974
- if (typeof value === "string") {
975
- const parsed = parseFloat(value);
976
- return isNaN(parsed) ? config.min : parsed;
977
- }
978
- return config.min;
979
- }, [value, config.min]);
980
- const hasError = react.useMemo(() => {
981
- return rawErrors && rawErrors.length > 0;
982
- }, [rawErrors]);
983
- const handleSliderChange = react.useCallback((values) => {
984
- const newValue = values[0];
985
- if (config.unit) {
986
- onChange(`${newValue}${config.unit}`);
987
- } else {
988
- onChange(newValue);
989
- }
990
- }, [onChange, config.unit]);
991
- const handleInputChange = react.useCallback((event) => {
992
- const inputValue = event.target.value;
993
- if (config.unit) {
994
- const cleanValue = inputValue.replace(config.unit, "").trim();
995
- const parsed = parseFloat(cleanValue);
996
- if (!isNaN(parsed)) {
997
- onChange(`${parsed}${config.unit}`);
998
- } else if (inputValue === "") {
999
- onChange(`${config.min}${config.unit}`);
1000
- }
1001
- } else {
1002
- const parsed = parseFloat(inputValue);
1003
- onChange(isNaN(parsed) ? config.min : parsed);
1004
- }
1005
- }, [onChange, config.unit, config.min]);
1006
- const displayValue = react.useMemo(() => {
1007
- if (config.unit) {
1008
- return `${numericValue}${config.unit}`;
1009
- }
1010
- return String(numericValue);
1011
- }, [numericValue, config.unit]);
1012
- return /* @__PURE__ */ jsxRuntime.jsxs(
1013
- "div",
1014
- {
1015
- className: lib.cn("flex items-center gap-3", hasError && "text-destructive"),
1016
- title: tooltipText,
1017
- children: [
1018
- /* @__PURE__ */ jsxRuntime.jsx(
1019
- components.Slider,
1020
- {
1021
- id,
1022
- disabled,
1023
- value: [numericValue],
1024
- onValueChange: handleSliderChange,
1025
- min: config.min,
1026
- max: config.max,
1027
- step: config.step,
1028
- className: "flex-1"
1029
- }
1030
- ),
1031
- config.showInput ? /* @__PURE__ */ jsxRuntime.jsx(
1032
- components.Input,
1033
- {
1034
- type: "text",
1035
- value: displayValue,
1036
- onChange: handleInputChange,
1037
- disabled,
1038
- readOnly: disabled,
1039
- className: lib.cn(
1040
- "w-20 text-center font-mono text-sm",
1041
- hasError && "border-destructive"
1042
- )
1043
- }
1044
- ) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "w-16 text-right font-mono text-sm text-muted-foreground", children: displayValue })
1045
- ]
1046
- }
1047
- );
1048
- }
1049
- chunkOLISEQHS_cjs.__name(SliderWidget, "SliderWidget");
1050
- function JsonSchemaForm(props) {
1051
- const {
1052
- schema,
1053
- uiSchema,
1054
- formData,
1055
- onSubmit,
1056
- onChange,
1057
- onError,
1058
- showErrorList = "top",
1059
- liveValidate = false,
1060
- disabled = false,
1061
- readonly = false,
1062
- className,
1063
- showSubmitButton = true,
1064
- submitButtonText = "Submit",
1065
- density = "comfortable",
1066
- formContext: callerFormContext,
1067
- ...restProps
1068
- } = props;
1069
- const validatedSchema = react.useMemo(() => {
1070
- if (lib.isDev) {
1071
- consola2__default.default.info("[JsonSchemaForm] Validating schema...", schema);
1072
- }
1073
- const result = validateSchema(schema);
1074
- if (!result && lib.isDev) {
1075
- consola2__default.default.error("[JsonSchemaForm] Schema validation failed");
1076
- }
1077
- return result;
1078
- }, [schema]);
1079
- const normalizedFormData = react.useMemo(() => {
1080
- if (!validatedSchema) {
1081
- if (lib.isDev) {
1082
- consola2__default.default.warn("[JsonSchemaForm] Cannot normalize formData - invalid schema");
1083
- }
1084
- return null;
1085
- }
1086
- if (lib.isDev) {
1087
- consola2__default.default.info("[JsonSchemaForm] Normalizing formData...", formData);
1088
- }
1089
- const normalized = normalizeFormData(formData, validatedSchema);
1090
- if (lib.isDev) {
1091
- consola2__default.default.info("[JsonSchemaForm] Normalized formData:", normalized);
1092
- }
1093
- return normalized;
1094
- }, [formData, validatedSchema]);
1095
- const widgets = react.useMemo(() => ({
1096
- // Standard widget names (PascalCase) - used by RJSF internally
1097
- TextWidget,
1098
- NumberWidget,
1099
- CheckboxWidget,
1100
- SelectWidget,
1101
- SwitchWidget,
1102
- ColorWidget,
1103
- SliderWidget,
1104
- // Lowercase aliases - for uiSchema 'ui:widget' references
1105
- text: TextWidget,
1106
- number: NumberWidget,
1107
- checkbox: CheckboxWidget,
1108
- select: SelectWidget,
1109
- switch: SwitchWidget,
1110
- color: ColorWidget,
1111
- slider: SliderWidget,
1112
- range: SliderWidget
1113
- // alias
1114
- }), []);
1115
- const safeUiSchema = react.useMemo(() => {
1116
- if (!uiSchema) return uiSchema;
1117
- const known = new Set(Object.keys(widgets));
1118
- let dirty = false;
1119
- function walk(node) {
1120
- if (!node || typeof node !== "object") return node;
1121
- if (Array.isArray(node)) return node.map(walk);
1122
- const out = {};
1123
- for (const [k, v] of Object.entries(node)) {
1124
- if (k === "ui:widget" && typeof v === "string" && !known.has(v)) {
1125
- dirty = true;
1126
- if (lib.isDev) {
1127
- consola2__default.default.error(
1128
- `[JsonSchemaForm] Unknown widget "${v}" \u2014 falling back to default. Available: ${[...known].filter((w) => w[0]?.toLowerCase() === w[0]).join(", ")}`
1129
- );
1130
- }
1131
- continue;
1132
- }
1133
- out[k] = walk(v);
1134
- }
1135
- return out;
1136
- }
1137
- chunkOLISEQHS_cjs.__name(walk, "walk");
1138
- const cleaned = walk(uiSchema);
1139
- return dirty ? cleaned : uiSchema;
1140
- }, [uiSchema, widgets]);
1141
- const templates = react.useMemo(() => ({
1142
- FieldTemplate,
1143
- ObjectFieldTemplate,
1144
- ArrayFieldTemplate,
1145
- ArrayFieldItemTemplate,
1146
- ErrorListTemplate,
1147
- BaseInputTemplate
1148
- }), []);
1149
- const handleSubmit = react.useCallback((data) => {
1150
- if (onSubmit) {
1151
- const cleanData = {
1152
- ...data,
1153
- formData: normalizeFormData(data.formData, validatedSchema)
1154
- };
1155
- onSubmit(cleanData);
1156
- }
1157
- }, [onSubmit, validatedSchema]);
1158
- const handleChange = react.useCallback((data) => {
1159
- if (onChange) {
1160
- onChange(data);
1161
- }
1162
- }, [onChange]);
1163
- const handleError = react.useCallback((errors) => {
1164
- if (onError) {
1165
- onError(errors);
1166
- }
1167
- }, [onError]);
1168
- if (!validatedSchema) {
1169
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className, children: /* @__PURE__ */ jsxRuntime.jsxs(components.Alert, { variant: "destructive", children: [
1170
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.AlertCircle, { className: "h-4 w-4" }),
1171
- /* @__PURE__ */ jsxRuntime.jsx(components.AlertDescription, { children: "Invalid schema provided. Please check the schema format." })
1172
- ] }) });
1173
- }
1174
- const formContext = react.useMemo(() => ({
1175
- ...callerFormContext,
1176
- density,
1177
- formData: normalizedFormData
1178
- }), [callerFormContext, density, normalizedFormData]);
1179
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className, "data-jsonform-density": density, children: /* @__PURE__ */ jsxRuntime.jsx(
1180
- Form__default.default,
1181
- {
1182
- schema: validatedSchema,
1183
- uiSchema: safeUiSchema,
1184
- formData: normalizedFormData,
1185
- validator: validator__default.default,
1186
- widgets,
1187
- templates,
1188
- formContext,
1189
- onSubmit: handleSubmit,
1190
- onChange: handleChange,
1191
- onError: handleError,
1192
- showErrorList,
1193
- liveValidate,
1194
- disabled,
1195
- readonly,
1196
- ...restProps,
1197
- children: showSubmitButton && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-6 flex gap-2", children: /* @__PURE__ */ jsxRuntime.jsx(components.Button, { type: "submit", disabled, children: submitButtonText }) })
1198
- }
1199
- ) });
1200
- }
1201
- chunkOLISEQHS_cjs.__name(JsonSchemaForm, "JsonSchemaForm");
1202
-
1203
- exports.ArrayFieldItemTemplate = ArrayFieldItemTemplate;
1204
- exports.ArrayFieldTemplate = ArrayFieldTemplate;
1205
- exports.BaseInputTemplate = BaseInputTemplate;
1206
- exports.CheckboxWidget = CheckboxWidget;
1207
- exports.ColorWidget = ColorWidget;
1208
- exports.ErrorListTemplate = ErrorListTemplate;
1209
- exports.FieldTemplate = FieldTemplate;
1210
- exports.JsonSchemaForm = JsonSchemaForm;
1211
- exports.NumberWidget = NumberWidget;
1212
- exports.ObjectFieldTemplate = ObjectFieldTemplate;
1213
- exports.SelectWidget = SelectWidget;
1214
- exports.SliderWidget = SliderWidget;
1215
- exports.SwitchWidget = SwitchWidget;
1216
- exports.TextWidget = TextWidget;
1217
- exports.evaluateDisabledWhen = evaluateDisabledWhen;
1218
- exports.getRequiredFields = getRequiredFields;
1219
- exports.hasRequiredFields = hasRequiredFields;
1220
- exports.mergeDefaults = mergeDefaults;
1221
- exports.normalizeFormData = normalizeFormData;
1222
- exports.safeJsonParse = safeJsonParse;
1223
- exports.safeJsonStringify = safeJsonStringify;
1224
- exports.validateRequiredFields = validateRequiredFields;
1225
- exports.validateSchema = validateSchema;
1226
- //# sourceMappingURL=chunk-FEN5S772.cjs.map
1227
- //# sourceMappingURL=chunk-FEN5S772.cjs.map