wimui 0.58.1 → 0.60.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/ai/PromptInput/PromptInput.cjs +1 -1
- package/dist/components/ai/PromptInput/PromptInput.js +30 -30
- package/dist/components/ai/SourceCitation/SourceCitation.cjs +1 -1
- package/dist/components/ai/SourceCitation/SourceCitation.d.ts +5 -1
- package/dist/components/ai/SourceCitation/SourceCitation.js +10 -8
- package/dist/components/ai/Terminal/Terminal.cjs +2 -2
- package/dist/components/ai/Terminal/Terminal.js +16 -14
- package/dist/components/data-display/DataGrid/DataGrid.cjs +1 -1
- package/dist/components/data-display/DataGrid/DataGrid.d.ts +5 -1
- package/dist/components/data-display/DataGrid/DataGrid.js +54 -53
- package/dist/components/data-display/FAQSection/FAQSection.cjs +1 -1
- package/dist/components/data-display/FAQSection/FAQSection.d.ts +5 -1
- package/dist/components/data-display/FAQSection/FAQSection.js +5 -3
- package/dist/components/data-display/TreeView/TreeView.cjs +1 -1
- package/dist/components/data-display/TreeView/TreeView.d.ts +5 -1
- package/dist/components/data-display/TreeView/TreeView.js +87 -87
- package/dist/components/data-display/VirtualList/VirtualList.cjs +1 -1
- package/dist/components/data-display/VirtualList/VirtualList.d.ts +2 -0
- package/dist/components/data-display/VirtualList/VirtualList.js +15 -14
- package/dist/components/feedback/Notification/Notification.cjs +1 -1
- package/dist/components/feedback/Notification/Notification.d.ts +5 -1
- package/dist/components/feedback/Notification/Notification.js +10 -8
- package/dist/components/feedback/Toast/Toast.cjs +1 -1
- package/dist/components/feedback/Toast/Toast.d.ts +5 -1
- package/dist/components/feedback/Toast/Toast.js +11 -9
- package/dist/components/form/CopyButton/CopyButton.cjs +1 -1
- package/dist/components/form/CopyButton/CopyButton.d.ts +5 -1
- package/dist/components/form/CopyButton/CopyButton.js +17 -15
- package/dist/components/form/Dropzone/Dropzone.cjs +1 -1
- package/dist/components/form/Dropzone/Dropzone.d.ts +7 -1
- package/dist/components/form/Dropzone/Dropzone.js +29 -28
- package/dist/components/form/FileUpload/FileUpload.cjs +1 -1
- package/dist/components/form/FileUpload/FileUpload.d.ts +7 -1
- package/dist/components/form/FileUpload/FileUpload.js +22 -17
- package/dist/components/form/ImageCropper/ImageCropper.cjs +1 -1
- package/dist/components/form/ImageCropper/ImageCropper.js +102 -100
- package/dist/components/form/QueryBuilder/QueryBuilder.cjs +1 -1
- package/dist/components/form/QueryBuilder/QueryBuilder.d.ts +7 -1
- package/dist/components/form/QueryBuilder/QueryBuilder.js +104 -102
- package/dist/components/form/SignaturePad/SignaturePad.cjs +1 -1
- package/dist/components/form/SignaturePad/SignaturePad.d.ts +5 -1
- package/dist/components/form/SignaturePad/SignaturePad.js +47 -47
- package/dist/components/form/ThemeToggle/ThemeToggle.cjs +1 -1
- package/dist/components/form/ThemeToggle/ThemeToggle.js +59 -54
- package/dist/components/media/ImageCompare/ImageCompare.cjs +1 -1
- package/dist/components/media/ImageCompare/ImageCompare.js +33 -31
- package/dist/components/navigation/BackTop/BackTop.cjs +1 -1
- package/dist/components/navigation/BackTop/BackTop.d.ts +4 -0
- package/dist/components/navigation/BackTop/BackTop.js +18 -16
- package/dist/components/navigation/CommandPalette/CommandPalette.cjs +1 -1
- package/dist/components/navigation/CommandPalette/CommandPalette.d.ts +5 -1
- package/dist/components/navigation/CommandPalette/CommandPalette.js +11 -6
- package/dist/components/navigation/Pagination/Pagination.cjs +1 -1
- package/dist/components/navigation/Pagination/Pagination.d.ts +5 -1
- package/dist/components/navigation/Pagination/Pagination.js +65 -63
- package/dist/components/overlay/Menu/Menu.cjs +1 -1
- package/dist/components/overlay/Menu/Menu.d.ts +4 -0
- package/dist/components/overlay/Menu/Menu.js +23 -21
- package/dist/llms-full.txt +33 -1
- package/dist/llms.txt +1 -1
- package/dist/wimui.umd.js +4 -4
- package/package.json +1 -1
|
@@ -4,18 +4,18 @@ import { componentsNs as t } from "../../../i18n/generated/components.js";
|
|
|
4
4
|
import { Button as n } from "../Button/Button.js";
|
|
5
5
|
import { Input as r } from "../Input/Input.js";
|
|
6
6
|
import { DatePicker as i } from "../DatePicker/DatePicker.js";
|
|
7
|
-
import { NumberInput as
|
|
8
|
-
import { SegmentedControl as
|
|
9
|
-
import { Select as
|
|
10
|
-
import { Switch as
|
|
11
|
-
import { IconButton as
|
|
12
|
-
import
|
|
13
|
-
import { warnUnknownOperator as
|
|
14
|
-
import { useCallback as
|
|
15
|
-
import
|
|
16
|
-
import { jsx as
|
|
7
|
+
import { NumberInput as ee } from "../NumberInput/NumberInput.js";
|
|
8
|
+
import { SegmentedControl as a } from "../SegmentedControl/SegmentedControl.js";
|
|
9
|
+
import { Select as o } from "../Select/Select.js";
|
|
10
|
+
import { Switch as s } from "../Switch/Switch.js";
|
|
11
|
+
import { IconButton as c } from "../IconButton/IconButton.js";
|
|
12
|
+
import l from "./querybuilder.module.js";
|
|
13
|
+
import { warnUnknownOperator as u } from "./warn-unknown-operator.js";
|
|
14
|
+
import { useCallback as d, useId as f, useRef as p, useState as m } from "react";
|
|
15
|
+
import h from "classnames";
|
|
16
|
+
import { jsx as g, jsxs as _ } from "react/jsx-runtime";
|
|
17
17
|
//#region src/components/form/QueryBuilder/QueryBuilder.tsx
|
|
18
|
-
var
|
|
18
|
+
var v = 0, y = () => typeof window < "u" && window.__VRT__ ? (v += 1, `vrt-id-${v}`) : Math.random().toString(36).substring(2, 11), b = {
|
|
19
19
|
string: [
|
|
20
20
|
{
|
|
21
21
|
value: "=",
|
|
@@ -132,19 +132,19 @@ var y = 0, b = () => typeof window < "u" && window.__VRT__ ? (y += 1, `vrt-id-${
|
|
|
132
132
|
key: "is_not_null"
|
|
133
133
|
}
|
|
134
134
|
]
|
|
135
|
-
},
|
|
136
|
-
let { t:
|
|
137
|
-
id:
|
|
135
|
+
}, x = ({ fields: v, query: x, defaultQuery: S, onChange: C, maxDepth: te = 3, className: ne, id: re, labels: ie = {}, "aria-label": w, "aria-labelledby": T, "aria-describedby": E }) => {
|
|
136
|
+
let { t: D } = e(t), { ruleAdded: O = D("query.builder.rule_added"), groupAdded: k = D("query.builder.group_added"), removed: A = D("query.builder.removed"), ruleAriaLabel: j = D("query.builder.rule"), fieldAriaLabel: M = D("query.builder.field"), operatorAriaLabel: N = D("query.builder.operator"), valueAriaLabel: P = D("query.builder.value"), trueLabel: F = D("query.builder.true"), falseLabel: I = D("query.builder.false"), removeRuleAriaLabel: L = D("query.builder.remove_rule"), removeGroupAriaLabel: R = D("query.builder.remove_group"), addRuleLabel: z = D("query.builder.add_rule"), addGroupLabel: ae = D("query.builder.add_group"), regionAriaLabel: B = D("query.builder.region_label"), combinatorAriaLabel: V = D("query.builder.combinator"), operators: H = {} } = ie, U = f(), W = re || `wim-qb-${U}`, G = p(null), [K, q] = m(S || {
|
|
137
|
+
id: y(),
|
|
138
138
|
combinator: "and",
|
|
139
139
|
not: !1,
|
|
140
140
|
rules: []
|
|
141
|
-
}), J =
|
|
141
|
+
}), J = x === void 0 ? K : x, Y = d((e) => {
|
|
142
142
|
G.current && (G.current.textContent = "", setTimeout(() => {
|
|
143
143
|
G.current && (G.current.textContent = e);
|
|
144
144
|
}, 50));
|
|
145
|
-
}, []), X =
|
|
146
|
-
|
|
147
|
-
}, [
|
|
145
|
+
}, []), X = d((e) => {
|
|
146
|
+
x === void 0 && q(e), C?.(e);
|
|
147
|
+
}, [x, C]), Z = (e, t) => {
|
|
148
148
|
let n = (r) => r.id === e ? {
|
|
149
149
|
...r,
|
|
150
150
|
...t
|
|
@@ -156,9 +156,9 @@ var y = 0, b = () => typeof window < "u" && window.__VRT__ ? (y += 1, `vrt-id-${
|
|
|
156
156
|
} : "rules" in r ? n(r) : r)
|
|
157
157
|
};
|
|
158
158
|
X(n(J));
|
|
159
|
-
},
|
|
160
|
-
let t =
|
|
161
|
-
id:
|
|
159
|
+
}, oe = (e) => {
|
|
160
|
+
let t = v[0], n = {
|
|
161
|
+
id: y(),
|
|
162
162
|
field: t?.name || "",
|
|
163
163
|
operator: "=",
|
|
164
164
|
value: t?.type !== "boolean" && ""
|
|
@@ -169,10 +169,10 @@ var y = 0, b = () => typeof window < "u" && window.__VRT__ ? (y += 1, `vrt-id-${
|
|
|
169
169
|
...t,
|
|
170
170
|
rules: t.rules.map((e) => "rules" in e ? r(e) : e)
|
|
171
171
|
};
|
|
172
|
-
X(r(J)), Y(
|
|
173
|
-
},
|
|
172
|
+
X(r(J)), Y(O);
|
|
173
|
+
}, se = (e) => {
|
|
174
174
|
let t = {
|
|
175
|
-
id:
|
|
175
|
+
id: y(),
|
|
176
176
|
combinator: "and",
|
|
177
177
|
not: !1,
|
|
178
178
|
rules: []
|
|
@@ -183,25 +183,25 @@ var y = 0, b = () => typeof window < "u" && window.__VRT__ ? (y += 1, `vrt-id-${
|
|
|
183
183
|
...r,
|
|
184
184
|
rules: r.rules.map((e) => "rules" in e ? n(e) : e)
|
|
185
185
|
};
|
|
186
|
-
X(n(J)), Y(
|
|
186
|
+
X(n(J)), Y(k);
|
|
187
187
|
}, Q = (e) => {
|
|
188
188
|
let t = (n) => ({
|
|
189
189
|
...n,
|
|
190
190
|
rules: n.rules.filter((t) => t.id !== e).map((e) => "rules" in e ? t(e) : e)
|
|
191
191
|
});
|
|
192
|
-
X(t(J)), Y(
|
|
192
|
+
X(t(J)), Y(A);
|
|
193
193
|
}, $ = (e, t, r) => {
|
|
194
194
|
let i = `${e.combinator.toUpperCase()} group`;
|
|
195
|
-
return /* @__PURE__ */
|
|
195
|
+
return /* @__PURE__ */ _("div", {
|
|
196
196
|
role: "group",
|
|
197
197
|
"aria-label": i,
|
|
198
|
-
className:
|
|
198
|
+
className: h(l.group, t > 0 && l.nested, r && l.excluded),
|
|
199
199
|
children: [
|
|
200
|
-
/* @__PURE__ */
|
|
201
|
-
className:
|
|
202
|
-
children: [/* @__PURE__ */
|
|
203
|
-
className:
|
|
204
|
-
children: [/* @__PURE__ */
|
|
200
|
+
/* @__PURE__ */ _("div", {
|
|
201
|
+
className: l.groupHeader,
|
|
202
|
+
children: [/* @__PURE__ */ _("div", {
|
|
203
|
+
className: l.groupHeaderLeft,
|
|
204
|
+
children: [/* @__PURE__ */ g(a, {
|
|
205
205
|
size: "md",
|
|
206
206
|
options: [{
|
|
207
207
|
label: "AND",
|
|
@@ -214,160 +214,162 @@ var y = 0, b = () => typeof window < "u" && window.__VRT__ ? (y += 1, `vrt-id-${
|
|
|
214
214
|
onChange: (t) => Z(e.id, { combinator: t }),
|
|
215
215
|
"aria-label": V,
|
|
216
216
|
styles: {
|
|
217
|
-
root:
|
|
218
|
-
item:
|
|
219
|
-
slider:
|
|
217
|
+
root: l.segmentedControl,
|
|
218
|
+
item: l.segmentedControlItem,
|
|
219
|
+
slider: l.segmentedControlSlider
|
|
220
220
|
}
|
|
221
|
-
}), /* @__PURE__ */
|
|
221
|
+
}), /* @__PURE__ */ g(s, {
|
|
222
222
|
size: "md",
|
|
223
223
|
checked: e.not,
|
|
224
224
|
onChange: (t) => Z(e.id, { not: t.target.checked }),
|
|
225
225
|
children: "NOT"
|
|
226
226
|
})]
|
|
227
|
-
}), t > 0 && /* @__PURE__ */
|
|
227
|
+
}), t > 0 && /* @__PURE__ */ g(c, {
|
|
228
228
|
iconName: "TrashIcon",
|
|
229
|
-
"aria-label":
|
|
229
|
+
"aria-label": R,
|
|
230
230
|
variant: "ghost",
|
|
231
231
|
size: "md",
|
|
232
232
|
intent: "danger",
|
|
233
233
|
onClick: () => Q(e.id),
|
|
234
|
-
className:
|
|
234
|
+
className: l.removeGroup
|
|
235
235
|
})]
|
|
236
236
|
}),
|
|
237
|
-
/* @__PURE__ */
|
|
238
|
-
className:
|
|
239
|
-
children: e.rules.map((e) => "rules" in e ? $(e, t + 1, r) :
|
|
237
|
+
/* @__PURE__ */ g("div", {
|
|
238
|
+
className: l.ruleList,
|
|
239
|
+
children: e.rules.map((e) => "rules" in e ? $(e, t + 1, r) : ce(e))
|
|
240
240
|
}),
|
|
241
|
-
/* @__PURE__ */
|
|
242
|
-
className:
|
|
243
|
-
children: [/* @__PURE__ */
|
|
241
|
+
/* @__PURE__ */ _("div", {
|
|
242
|
+
className: l.groupActions,
|
|
243
|
+
children: [/* @__PURE__ */ g(n, {
|
|
244
244
|
size: "md",
|
|
245
245
|
variant: "ghost",
|
|
246
246
|
icon: "PlusIcon",
|
|
247
|
-
onClick: () =>
|
|
248
|
-
children:
|
|
249
|
-
}), t <
|
|
247
|
+
onClick: () => oe(e.id),
|
|
248
|
+
children: z
|
|
249
|
+
}), t < te && /* @__PURE__ */ g(n, {
|
|
250
250
|
size: "md",
|
|
251
251
|
variant: "ghost",
|
|
252
252
|
icon: "PlusIcon",
|
|
253
|
-
onClick: () =>
|
|
254
|
-
children:
|
|
253
|
+
onClick: () => se(e.id),
|
|
254
|
+
children: ae
|
|
255
255
|
})]
|
|
256
256
|
})
|
|
257
257
|
]
|
|
258
258
|
}, e.id);
|
|
259
|
-
},
|
|
260
|
-
let t =
|
|
259
|
+
}, ce = (e) => {
|
|
260
|
+
let t = v.find((t) => t.name === e.field)?.type || "string", n = b[t].map((e) => ({
|
|
261
261
|
...e,
|
|
262
|
-
label: H[e.key] ||
|
|
263
|
-
})),
|
|
264
|
-
let n =
|
|
262
|
+
label: H[e.key] || D(`query.builder.operators.${e.key}`)
|
|
263
|
+
})), a = (t) => {
|
|
264
|
+
let n = v.find((e) => e.name === t);
|
|
265
265
|
Z(e.id, {
|
|
266
266
|
field: t,
|
|
267
267
|
operator: "=",
|
|
268
268
|
value: n?.type !== "boolean" && ""
|
|
269
269
|
});
|
|
270
270
|
};
|
|
271
|
-
n.some((t) => t.value === e.operator) ||
|
|
272
|
-
let
|
|
273
|
-
return /* @__PURE__ */
|
|
274
|
-
className:
|
|
271
|
+
n.some((t) => t.value === e.operator) || u(e.operator, t, n.map((e) => e.value));
|
|
272
|
+
let s = e.operator === "is_null" || e.operator === "is_not_null";
|
|
273
|
+
return /* @__PURE__ */ g("div", {
|
|
274
|
+
className: l.rule,
|
|
275
275
|
role: "group",
|
|
276
|
-
"aria-label":
|
|
277
|
-
children: /* @__PURE__ */
|
|
278
|
-
className:
|
|
276
|
+
"aria-label": j,
|
|
277
|
+
children: /* @__PURE__ */ _("div", {
|
|
278
|
+
className: l.ruleFields,
|
|
279
279
|
children: [
|
|
280
|
-
/* @__PURE__ */
|
|
281
|
-
className:
|
|
282
|
-
options:
|
|
280
|
+
/* @__PURE__ */ g(o, {
|
|
281
|
+
className: l.field,
|
|
282
|
+
options: v.map((e) => ({
|
|
283
283
|
label: e.label,
|
|
284
284
|
value: e.name
|
|
285
285
|
})),
|
|
286
286
|
value: e.field,
|
|
287
|
-
onChange:
|
|
288
|
-
"aria-label":
|
|
287
|
+
onChange: a,
|
|
288
|
+
"aria-label": M,
|
|
289
289
|
fullWidth: !0,
|
|
290
290
|
styles: {
|
|
291
|
-
root:
|
|
292
|
-
trigger:
|
|
293
|
-
inputBase: { root:
|
|
291
|
+
root: l.select,
|
|
292
|
+
trigger: l.selectTrigger,
|
|
293
|
+
inputBase: { root: l.inputBase }
|
|
294
294
|
}
|
|
295
295
|
}),
|
|
296
|
-
/* @__PURE__ */
|
|
297
|
-
className:
|
|
296
|
+
/* @__PURE__ */ g(o, {
|
|
297
|
+
className: l.operator,
|
|
298
298
|
options: n.map((e) => ({
|
|
299
299
|
label: e.label,
|
|
300
300
|
value: e.value
|
|
301
301
|
})),
|
|
302
302
|
value: e.operator,
|
|
303
303
|
onChange: (t) => Z(e.id, { operator: t }),
|
|
304
|
-
"aria-label":
|
|
304
|
+
"aria-label": N,
|
|
305
305
|
fullWidth: !0,
|
|
306
306
|
styles: {
|
|
307
|
-
root:
|
|
308
|
-
trigger:
|
|
309
|
-
inputBase: { root:
|
|
307
|
+
root: l.select,
|
|
308
|
+
trigger: l.selectTrigger,
|
|
309
|
+
inputBase: { root: l.inputBase }
|
|
310
310
|
}
|
|
311
311
|
}),
|
|
312
|
-
!
|
|
313
|
-
className:
|
|
314
|
-
children: t === "number" ? /* @__PURE__ */
|
|
312
|
+
!s && /* @__PURE__ */ g("div", {
|
|
313
|
+
className: l.value,
|
|
314
|
+
children: t === "number" ? /* @__PURE__ */ g(ee, {
|
|
315
315
|
value: typeof e.value == "boolean" ? void 0 : e.value ?? void 0,
|
|
316
316
|
onChange: (t) => Z(e.id, { value: t.target.value }),
|
|
317
|
-
"aria-label":
|
|
318
|
-
}) : t === "date" ? /* @__PURE__ */
|
|
317
|
+
"aria-label": P
|
|
318
|
+
}) : t === "date" ? /* @__PURE__ */ g(i, {
|
|
319
319
|
value: typeof e.value == "string" || typeof e.value == "number" ? new Date(e.value) : void 0,
|
|
320
320
|
onChange: (t) => Z(e.id, { value: t ? t.toISOString() : "" }),
|
|
321
|
-
"aria-label":
|
|
322
|
-
}) : t === "boolean" ? /* @__PURE__ */
|
|
321
|
+
"aria-label": P
|
|
322
|
+
}) : t === "boolean" ? /* @__PURE__ */ g(o, {
|
|
323
323
|
options: [{
|
|
324
|
-
label:
|
|
324
|
+
label: F,
|
|
325
325
|
value: "true"
|
|
326
326
|
}, {
|
|
327
|
-
label:
|
|
327
|
+
label: I,
|
|
328
328
|
value: "false"
|
|
329
329
|
}],
|
|
330
330
|
value: String(e.value),
|
|
331
331
|
onChange: (t) => Z(e.id, { value: t === "true" }),
|
|
332
|
-
"aria-label":
|
|
332
|
+
"aria-label": P,
|
|
333
333
|
fullWidth: !0,
|
|
334
334
|
styles: {
|
|
335
|
-
root:
|
|
336
|
-
trigger:
|
|
337
|
-
inputBase: { root:
|
|
335
|
+
root: l.select,
|
|
336
|
+
trigger: l.selectTrigger,
|
|
337
|
+
inputBase: { root: l.inputBase }
|
|
338
338
|
}
|
|
339
|
-
}) : /* @__PURE__ */
|
|
339
|
+
}) : /* @__PURE__ */ g(r, {
|
|
340
340
|
value: typeof e.value == "boolean" ? void 0 : e.value ?? void 0,
|
|
341
341
|
onChange: (t) => Z(e.id, { value: t.target.value }),
|
|
342
|
-
"aria-label":
|
|
343
|
-
styles: { root:
|
|
342
|
+
"aria-label": P,
|
|
343
|
+
styles: { root: l.inputBase }
|
|
344
344
|
})
|
|
345
345
|
}),
|
|
346
|
-
/* @__PURE__ */
|
|
346
|
+
/* @__PURE__ */ g(c, {
|
|
347
347
|
iconName: "TrashIcon",
|
|
348
|
-
"aria-label":
|
|
348
|
+
"aria-label": L,
|
|
349
349
|
variant: "ghost",
|
|
350
350
|
size: "md",
|
|
351
351
|
intent: "danger",
|
|
352
352
|
onClick: () => Q(e.id),
|
|
353
|
-
className:
|
|
353
|
+
className: l.removeRule
|
|
354
354
|
})
|
|
355
355
|
]
|
|
356
356
|
})
|
|
357
357
|
}, e.id);
|
|
358
358
|
};
|
|
359
|
-
return /* @__PURE__ */
|
|
359
|
+
return /* @__PURE__ */ _("div", {
|
|
360
360
|
id: W,
|
|
361
361
|
role: "region",
|
|
362
|
-
"aria-label": B,
|
|
363
|
-
|
|
364
|
-
|
|
362
|
+
"aria-label": T ? void 0 : w ?? B,
|
|
363
|
+
"aria-labelledby": T,
|
|
364
|
+
"aria-describedby": E,
|
|
365
|
+
className: h("wim-query-builder", l.root, ne),
|
|
366
|
+
children: [/* @__PURE__ */ g("div", {
|
|
365
367
|
ref: G,
|
|
366
368
|
"aria-live": "polite",
|
|
367
369
|
"aria-atomic": "true",
|
|
368
|
-
className:
|
|
370
|
+
className: l.srOnly
|
|
369
371
|
}), $(J, 0, !1)]
|
|
370
372
|
});
|
|
371
373
|
};
|
|
372
374
|
//#endregion
|
|
373
|
-
export {
|
|
375
|
+
export { x as QueryBuilder };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../i18n/useWimTranslation.cjs"),n=require("../../../i18n/generated/common.cjs"),r=require("../../../i18n/generated/components.cjs"),i=require("../Button/Button.cjs"),a=require("../../../i18n/generated/form.cjs"),o=require("../FieldTemplate/FieldTemplate.cjs"),s=require("./signature-pad.module.cjs");let c=require("react");c=e.__toESM(c,1);let l=require("classnames");l=e.__toESM(l,1);let u=require("react/jsx-runtime");var d=({width:e=400,height:d=200,penColor:f=`var(--wim-color-text-primary)`,penWidth:p=2,onChange:m,clearLabel:h,disabled:g=!1,className:_,style:v,label:y,error:b,required:x,layout:S=`vertical`,canvasAriaLabel:C})=>{let{t:
|
|
2
|
+
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../i18n/useWimTranslation.cjs"),n=require("../../../i18n/generated/common.cjs"),r=require("../../../i18n/generated/components.cjs"),i=require("../Button/Button.cjs"),a=require("../../../i18n/generated/form.cjs"),o=require("../FieldTemplate/FieldTemplate.cjs"),s=require("./signature-pad.module.cjs");let c=require("react");c=e.__toESM(c,1);let l=require("classnames");l=e.__toESM(l,1);let u=require("react/jsx-runtime");var d=({width:e=400,height:d=200,penColor:f=`var(--wim-color-text-primary)`,penWidth:p=2,onChange:m,clearLabel:h,disabled:g=!1,className:_,style:v,label:y,error:b,required:x,layout:S=`vertical`,canvasAriaLabel:C,"aria-label":w,"aria-labelledby":T})=>{let{t:E}=t.useWimTranslation([n.commonNs,r.componentsNs,a.formNs]),D=h??E(`signature.clear`,{ns:`components`,defaultValue:E(`button.clear`)}),O=C??E(`a11y.signature_canvas`),k=(0,c.useRef)(null),A=(0,c.useRef)(!1),[j,M]=(0,c.useState)(!0),N=`wim-signature-pad-${(0,c.useId)()}`,P=y?`${N}-label`:void 0,F=b?`${N}-error`:void 0,I=(0,c.useCallback)(e=>{if(e.startsWith(`var(`)&&k.current){let t=e.match(/var\((--[^)]+)\)/)?.[1];if(t)return getComputedStyle(k.current).getPropertyValue(t).trim()||`#000`}return e},[]);(0,c.useLayoutEffect)(()=>{if(!k.current)return;let t=k.current,n=t.getContext(`2d`);if(!n)return;let r=window.devicePixelRatio||1;t.width=e*r,t.height=d*r,n.scale(r,r),n.lineCap=`round`,n.lineJoin=`round`},[e,d]);let L=(0,c.useCallback)(t=>{if(!k.current)return null;let n=k.current.getBoundingClientRect(),r,i;if(`touches`in t){if(t.touches.length===0)return null;r=t.touches[0].clientX,i=t.touches[0].clientY}else r=t.clientX,i=t.clientY;let a=r-n.left,o=i-n.top,s=e/n.width,c=d/n.height;return{x:a*s,y:o*c}},[e,d]),R=e=>{if(g)return;let t=L(e);if(!t||!k.current)return;let n=k.current.getContext(`2d`);n&&(A.current=!0,n.beginPath(),n.moveTo(t.x,t.y),n.strokeStyle=I(f),n.lineWidth=p)},z=e=>{if(!A.current||g||!k.current)return;let t=L(e);if(!t)return;let n=k.current.getContext(`2d`);n&&(n.lineTo(t.x,t.y),n.stroke(),M(!1))},B=()=>{if(A.current&&(A.current=!1,m&&k.current)){let e=k.current,t=e.getContext(`2d`);m(!t||t.getImageData(0,0,e.width,e.height).data.every((e,t)=>t%4!=3||e===0)?null:e.toDataURL())}},V=(0,c.useRef)(B);(0,c.useLayoutEffect)(()=>{V.current=B}),(0,c.useEffect)(()=>{let e=()=>V.current();return window.addEventListener(`mouseup`,e),()=>window.removeEventListener(`mouseup`,e)},[]);let H=(0,c.useRef)(!1);return(0,u.jsx)(o.FieldTemplate,{label:y,error:b,required:x,layout:S,labelId:P,errorId:F,className:_,children:(0,u.jsxs)(`div`,{className:(0,l.default)(`wim-signature-pad`,s.default.root,g&&s.default.disabled,b&&s.default.danger),style:v,children:[(0,u.jsx)(`div`,{className:s.default.canvasContainer,style:{width:e,maxWidth:`100%`,aspectRatio:`${e} / ${d}`,height:`auto`},children:(0,u.jsx)(`canvas`,{ref:k,"data-testid":`signature-canvas`,className:s.default.canvas,style:{width:`100%`,height:`100%`,display:`block`},onMouseDown:R,onMouseMove:z,onMouseUp:B,onTouchStart:R,onTouchMove:z,onTouchEnd:B,"aria-labelledby":y?P:T,"aria-describedby":F,role:`img`,"aria-label":y||T?void 0:w??O})}),(0,u.jsx)(`div`,{className:s.default.footer,children:(0,u.jsx)(i.Button,{variant:`outline`,size:`sm`,"data-testid":`signature-clear`,onMouseDown:()=>{H.current=!0},onClick:()=>{if(!H.current||(H.current=!1,g||!k.current))return;let e=k.current,t=e.getContext(`2d`);t&&(t.clearRect(0,0,e.width,e.height),M(!0),m&&m(null))},disabled:g||j,children:D})})]})})};exports.SignaturePad=d;
|
|
@@ -28,8 +28,12 @@ export type SignaturePadProps = {
|
|
|
28
28
|
layout?: "vertical" | "horizontal";
|
|
29
29
|
/** Aria label for the canvas */
|
|
30
30
|
canvasAriaLabel?: string;
|
|
31
|
+
/** Accessible name for the canvas when no visible `label` is provided. Takes precedence over `canvasAriaLabel`. */
|
|
32
|
+
"aria-label"?: string;
|
|
33
|
+
/** ID of the element that labels the canvas when no visible `label` is provided. */
|
|
34
|
+
"aria-labelledby"?: string;
|
|
31
35
|
};
|
|
32
36
|
/**
|
|
33
37
|
* Component for entering a handwritten signature with mouse or touch.
|
|
34
38
|
*/
|
|
35
|
-
export declare const SignaturePad: ({ width, height, penColor, penWidth, onChange, clearLabel, disabled, className, style, label, error, required, layout, canvasAriaLabel, }: SignaturePadProps) => React.JSX.Element;
|
|
39
|
+
export declare const SignaturePad: ({ width, height, penColor, penWidth, onChange, clearLabel, disabled, className, style, label, error, required, layout, canvasAriaLabel, "aria-label": ariaLabelAttr, "aria-labelledby": ariaLabelledBy, }: SignaturePadProps) => React.JSX.Element;
|
|
@@ -10,31 +10,31 @@ import { useCallback as s, useEffect as c, useId as l, useLayoutEffect as u, use
|
|
|
10
10
|
import p from "classnames";
|
|
11
11
|
import { jsx as m, jsxs as h } from "react/jsx-runtime";
|
|
12
12
|
//#region src/components/form/SignaturePad/SignaturePad.tsx
|
|
13
|
-
var g = ({ width: g = 400, height: _ = 200, penColor: v = "var(--wim-color-text-primary)", penWidth: y = 2, onChange: b, clearLabel: x, disabled: S = !1, className: C, style: w, label: T, error: E, required: D, layout: O = "vertical", canvasAriaLabel: k }) => {
|
|
14
|
-
let { t:
|
|
13
|
+
var g = ({ width: g = 400, height: _ = 200, penColor: v = "var(--wim-color-text-primary)", penWidth: y = 2, onChange: b, clearLabel: x, disabled: S = !1, className: C, style: w, label: T, error: E, required: D, layout: O = "vertical", canvasAriaLabel: k, "aria-label": A, "aria-labelledby": j }) => {
|
|
14
|
+
let { t: M } = e([
|
|
15
15
|
t,
|
|
16
16
|
n,
|
|
17
17
|
i
|
|
18
|
-
]),
|
|
18
|
+
]), N = x ?? M("signature.clear", {
|
|
19
19
|
ns: "components",
|
|
20
|
-
defaultValue:
|
|
21
|
-
}),
|
|
22
|
-
if (e.startsWith("var(") &&
|
|
20
|
+
defaultValue: M("button.clear")
|
|
21
|
+
}), P = k ?? M("a11y.signature_canvas"), F = d(null), I = d(!1), [L, R] = f(!0), z = `wim-signature-pad-${l()}`, B = T ? `${z}-label` : void 0, V = E ? `${z}-error` : void 0, H = s((e) => {
|
|
22
|
+
if (e.startsWith("var(") && F.current) {
|
|
23
23
|
let t = e.match(/var\((--[^)]+)\)/)?.[1];
|
|
24
|
-
if (t) return getComputedStyle(
|
|
24
|
+
if (t) return getComputedStyle(F.current).getPropertyValue(t).trim() || "#000";
|
|
25
25
|
}
|
|
26
26
|
return e;
|
|
27
27
|
}, []);
|
|
28
28
|
u(() => {
|
|
29
|
-
if (!
|
|
30
|
-
let e =
|
|
29
|
+
if (!F.current) return;
|
|
30
|
+
let e = F.current, t = e.getContext("2d");
|
|
31
31
|
if (!t) return;
|
|
32
32
|
let n = window.devicePixelRatio || 1;
|
|
33
33
|
e.width = g * n, e.height = _ * n, t.scale(n, n), t.lineCap = "round", t.lineJoin = "round";
|
|
34
34
|
}, [g, _]);
|
|
35
|
-
let
|
|
36
|
-
if (!
|
|
37
|
-
let t =
|
|
35
|
+
let U = s((e) => {
|
|
36
|
+
if (!F.current) return null;
|
|
37
|
+
let t = F.current.getBoundingClientRect(), n, r;
|
|
38
38
|
if ("touches" in e) {
|
|
39
39
|
if (e.touches.length === 0) return null;
|
|
40
40
|
n = e.touches[0].clientX, r = e.touches[0].clientY;
|
|
@@ -44,38 +44,38 @@ var g = ({ width: g = 400, height: _ = 200, penColor: v = "var(--wim-color-text-
|
|
|
44
44
|
x: i * o,
|
|
45
45
|
y: a * s
|
|
46
46
|
};
|
|
47
|
-
}, [g, _]),
|
|
47
|
+
}, [g, _]), W = (e) => {
|
|
48
48
|
if (S) return;
|
|
49
|
-
let t =
|
|
50
|
-
if (!t || !
|
|
51
|
-
let n =
|
|
52
|
-
n && (
|
|
53
|
-
},
|
|
54
|
-
if (!
|
|
55
|
-
let t =
|
|
49
|
+
let t = U(e);
|
|
50
|
+
if (!t || !F.current) return;
|
|
51
|
+
let n = F.current.getContext("2d");
|
|
52
|
+
n && (I.current = !0, n.beginPath(), n.moveTo(t.x, t.y), n.strokeStyle = H(v), n.lineWidth = y);
|
|
53
|
+
}, G = (e) => {
|
|
54
|
+
if (!I.current || S || !F.current) return;
|
|
55
|
+
let t = U(e);
|
|
56
56
|
if (!t) return;
|
|
57
|
-
let n =
|
|
58
|
-
n && (n.lineTo(t.x, t.y), n.stroke(),
|
|
59
|
-
},
|
|
60
|
-
if (
|
|
61
|
-
let e =
|
|
57
|
+
let n = F.current.getContext("2d");
|
|
58
|
+
n && (n.lineTo(t.x, t.y), n.stroke(), R(!1));
|
|
59
|
+
}, K = () => {
|
|
60
|
+
if (I.current && (I.current = !1, b && F.current)) {
|
|
61
|
+
let e = F.current, t = e.getContext("2d");
|
|
62
62
|
b(!t || t.getImageData(0, 0, e.width, e.height).data.every((e, t) => t % 4 != 3 || e === 0) ? null : e.toDataURL());
|
|
63
63
|
}
|
|
64
|
-
},
|
|
64
|
+
}, q = d(K);
|
|
65
65
|
u(() => {
|
|
66
|
-
|
|
66
|
+
q.current = K;
|
|
67
67
|
}), c(() => {
|
|
68
|
-
let e = () =>
|
|
68
|
+
let e = () => q.current();
|
|
69
69
|
return window.addEventListener("mouseup", e), () => window.removeEventListener("mouseup", e);
|
|
70
70
|
}, []);
|
|
71
|
-
let
|
|
71
|
+
let J = d(!1);
|
|
72
72
|
return /* @__PURE__ */ m(a, {
|
|
73
73
|
label: T,
|
|
74
74
|
error: E,
|
|
75
75
|
required: D,
|
|
76
76
|
layout: O,
|
|
77
|
-
labelId:
|
|
78
|
-
errorId:
|
|
77
|
+
labelId: B,
|
|
78
|
+
errorId: V,
|
|
79
79
|
className: C,
|
|
80
80
|
children: /* @__PURE__ */ h("div", {
|
|
81
81
|
className: p("wim-signature-pad", o.root, S && o.disabled, E && o.danger),
|
|
@@ -89,7 +89,7 @@ var g = ({ width: g = 400, height: _ = 200, penColor: v = "var(--wim-color-text-
|
|
|
89
89
|
height: "auto"
|
|
90
90
|
},
|
|
91
91
|
children: /* @__PURE__ */ m("canvas", {
|
|
92
|
-
ref:
|
|
92
|
+
ref: F,
|
|
93
93
|
"data-testid": "signature-canvas",
|
|
94
94
|
className: o.canvas,
|
|
95
95
|
style: {
|
|
@@ -97,16 +97,16 @@ var g = ({ width: g = 400, height: _ = 200, penColor: v = "var(--wim-color-text-
|
|
|
97
97
|
height: "100%",
|
|
98
98
|
display: "block"
|
|
99
99
|
},
|
|
100
|
-
onMouseDown:
|
|
101
|
-
onMouseMove:
|
|
102
|
-
onMouseUp:
|
|
103
|
-
onTouchStart:
|
|
104
|
-
onTouchMove:
|
|
105
|
-
onTouchEnd:
|
|
106
|
-
"aria-labelledby": T ?
|
|
107
|
-
"aria-describedby":
|
|
100
|
+
onMouseDown: W,
|
|
101
|
+
onMouseMove: G,
|
|
102
|
+
onMouseUp: K,
|
|
103
|
+
onTouchStart: W,
|
|
104
|
+
onTouchMove: G,
|
|
105
|
+
onTouchEnd: K,
|
|
106
|
+
"aria-labelledby": T ? B : j,
|
|
107
|
+
"aria-describedby": V,
|
|
108
108
|
role: "img",
|
|
109
|
-
"aria-label": T ? void 0 :
|
|
109
|
+
"aria-label": T || j ? void 0 : A ?? P
|
|
110
110
|
})
|
|
111
111
|
}), /* @__PURE__ */ m("div", {
|
|
112
112
|
className: o.footer,
|
|
@@ -115,15 +115,15 @@ var g = ({ width: g = 400, height: _ = 200, penColor: v = "var(--wim-color-text-
|
|
|
115
115
|
size: "sm",
|
|
116
116
|
"data-testid": "signature-clear",
|
|
117
117
|
onMouseDown: () => {
|
|
118
|
-
|
|
118
|
+
J.current = !0;
|
|
119
119
|
},
|
|
120
120
|
onClick: () => {
|
|
121
|
-
if (!
|
|
122
|
-
let e =
|
|
123
|
-
t && (t.clearRect(0, 0, e.width, e.height),
|
|
121
|
+
if (!J.current || (J.current = !1, S || !F.current)) return;
|
|
122
|
+
let e = F.current, t = e.getContext("2d");
|
|
123
|
+
t && (t.clearRect(0, 0, e.width, e.height), R(!0), b && b(null));
|
|
124
124
|
},
|
|
125
|
-
disabled: S ||
|
|
126
|
-
children:
|
|
125
|
+
disabled: S || L,
|
|
126
|
+
children: N
|
|
127
127
|
})
|
|
128
128
|
})]
|
|
129
129
|
})
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../node_modules/@radix-ui/react-slot/dist/index.cjs"),n=require("../../../i18n/useWimTranslation.cjs"),r=require("../../../i18n/generated/common.cjs"),i=require("../../../icon/monitor.cjs"),a=require("../../../icon/moon.cjs"),o=require("../../../icon/sun.cjs"),s=require("../../media/Icon/Icon.cjs"),c=require("../../../theme.cjs"),l=require("./theme-toggle.module.cjs");let u=require("react");u=e.__toESM(u,1);let d=require("classnames");d=e.__toESM(d,1);let f=require("react/jsx-runtime");var p={light:o.default,dark:a.default,system:i.default},m=`wim-theme`,h=e=>e===`light`||e===`dark`||e===`system`,g=u.default.forwardRef(({value:e,defaultValue:i=`system`,onChange:a,modes:o=[`light`,`dark`],variant:g=`icon`,size:_=`md`,storageKey:v=m,applyToDocument:y=!0,labels:b,className:x,asChild:S=!1,children:C,...
|
|
2
|
+
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../node_modules/@radix-ui/react-slot/dist/index.cjs"),n=require("../../../i18n/useWimTranslation.cjs"),r=require("../../../i18n/generated/common.cjs"),i=require("../../../icon/monitor.cjs"),a=require("../../../icon/moon.cjs"),o=require("../../../icon/sun.cjs"),s=require("../../media/Icon/Icon.cjs"),c=require("../../../theme.cjs"),l=require("./theme-toggle.module.cjs");let u=require("react");u=e.__toESM(u,1);let d=require("classnames");d=e.__toESM(d,1);let f=require("react/jsx-runtime");var p={light:o.default,dark:a.default,system:i.default},m=`wim-theme`,h=e=>e===`light`||e===`dark`||e===`system`,g=u.default.forwardRef(({value:e,defaultValue:i=`system`,onChange:a,modes:o=[`light`,`dark`],variant:g=`icon`,size:_=`md`,storageKey:v=m,applyToDocument:y=!0,labels:b,className:x,asChild:S=!1,children:C,"aria-label":w,"aria-labelledby":T,"aria-describedby":E,...D},O)=>{let{t:k}=n.useWimTranslation(r.commonNs),{light:A=k(`common.light`),dark:j=k(`common.dark`),system:M=k(`theme.system`),toggle:N=k(`theme.toggle`)}=b??{},P={light:A,dark:j,system:M},F=e!==void 0,[I,L]=(0,u.useState)(()=>{if(typeof window<`u`&&v){let e=window.localStorage.getItem(v);if(h(e)&&o.includes(e))return e}return o.includes(i)?i:o[0]}),R=F?e:I;(0,u.useEffect)(()=>{y&&c.setWimTheme(R)},[R,y]);let z=(0,u.useCallback)(e=>{F||L(e),typeof window<`u`&&v&&window.localStorage.setItem(v,e),a?.(e)},[F,v,a]),B=()=>{let e=o[(o.indexOf(R)+1)%o.length];z(e)},V=(0,u.useId)(),H=S?t.Root:`div`,U=`wim-theme-toggle-${V}`;return g===`segmented`?(0,f.jsxs)(H,{ref:O,role:`group`,"aria-label":T?void 0:w??N,"aria-labelledby":T,"aria-describedby":E,className:(0,d.default)(`wim-theme-toggle`,l.default.segmented,l.default[_],x),...D,children:[o.map(e=>{let t=e===R;return(0,f.jsx)(`button`,{type:`button`,className:(0,d.default)(l.default.segment,t&&l.default.active),"aria-pressed":t,"aria-label":P[e],title:P[e],onClick:()=>z(e),children:(0,f.jsx)(s.Icon,{component:p[e],size:_})},e)}),(0,f.jsx)(t.Slottable,{children:C})]}):(0,f.jsxs)(H,{ref:O,className:(0,d.default)(`wim-theme-toggle`,l.default.root,x),...D,children:[(0,f.jsx)(`button`,{type:`button`,className:(0,d.default)(l.default.iconButton,l.default[_]),id:U,"aria-label":T?P[R]:`${w??N} (${P[R]})`,"aria-labelledby":T?`${T} ${U}`:void 0,"aria-describedby":E,title:P[R],onClick:B,children:(0,f.jsx)(s.Icon,{component:p[R],size:_})}),(0,f.jsx)(t.Slottable,{children:C})]})});g.displayName=`ThemeToggle`,exports.ThemeToggle=g;
|