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
|
@@ -6,75 +6,75 @@ import { Button as r } from "../Button/Button.js";
|
|
|
6
6
|
import { formNs as i } from "../../../i18n/generated/form.js";
|
|
7
7
|
import { Slider as a } from "../Slider/Slider.js";
|
|
8
8
|
import { IconButton as o } from "../IconButton/IconButton.js";
|
|
9
|
-
import { Dialog as s, DialogClose as c, DialogContent as l, DialogDescription as u, DialogFooter as
|
|
10
|
-
import { cropImage as
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import { jsx as
|
|
9
|
+
import { Dialog as s, DialogClose as c, DialogContent as l, DialogDescription as u, DialogFooter as d, DialogHeader as ee, DialogTitle as f } from "../../overlay/Dialog/Dialog.js";
|
|
10
|
+
import { cropImage as p, resolveCropDetail as m } from "./cropImage.js";
|
|
11
|
+
import h from "./image-cropper.module.js";
|
|
12
|
+
import g, { useCallback as _, useEffect as v, useId as y, useRef as b, useState as x } from "react";
|
|
13
|
+
import S from "classnames";
|
|
14
|
+
import { jsx as C, jsxs as w } from "react/jsx-runtime";
|
|
15
15
|
//#region src/components/form/ImageCropper/ImageCropper.tsx
|
|
16
|
-
var
|
|
17
|
-
let { t:
|
|
16
|
+
var T = 10, E = 50, D = g.forwardRef(({ src: g, aspectRatio: D = 1, circular: te = !1, onCrop: ne, showRotation: re = !0, showZoom: ie = !0, showApplyButton: ae = !0, applyLabel: oe, onApply: O, onCropError: k, maxOutputSize: A, outputType: j = "image/png", outputQuality: M = .92, crossOrigin: N, className: P, ...F }, I) => {
|
|
17
|
+
let L = F.role ?? (F["aria-label"] || F["aria-labelledby"] ? "group" : void 0), { t: R } = e([i, t]), [z, B] = x(1), [V, H] = x(0), [U, W] = x({
|
|
18
18
|
x: 0,
|
|
19
19
|
y: 0
|
|
20
|
-
}), [
|
|
20
|
+
}), [G, K] = x(!1), [q, se] = x({
|
|
21
21
|
x: 0,
|
|
22
22
|
y: 0
|
|
23
|
-
}), [
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
}), [ce, J] = x(!1), Y = b(null), le = b(null), X = b(null), Z = y();
|
|
24
|
+
v(() => {
|
|
25
|
+
W({
|
|
26
26
|
x: 0,
|
|
27
27
|
y: 0
|
|
28
|
-
}),
|
|
29
|
-
}, [
|
|
30
|
-
let
|
|
31
|
-
(e.pointerType !== "mouse" || e.button === 0) && (
|
|
32
|
-
x: e.clientX -
|
|
33
|
-
y: e.clientY -
|
|
28
|
+
}), B(1), H(0);
|
|
29
|
+
}, [g]);
|
|
30
|
+
let ue = (e) => {
|
|
31
|
+
(e.pointerType !== "mouse" || e.button === 0) && (K(!0), se({
|
|
32
|
+
x: e.clientX - U.x,
|
|
33
|
+
y: e.clientY - U.y
|
|
34
34
|
}));
|
|
35
|
-
}, Q =
|
|
36
|
-
|
|
37
|
-
x: e.clientX -
|
|
38
|
-
y: e.clientY -
|
|
35
|
+
}, Q = _((e) => {
|
|
36
|
+
G && W({
|
|
37
|
+
x: e.clientX - q.x,
|
|
38
|
+
y: e.clientY - q.y
|
|
39
39
|
});
|
|
40
|
-
}, [
|
|
41
|
-
|
|
40
|
+
}, [G, q]), $ = _(() => {
|
|
41
|
+
K(!1);
|
|
42
42
|
}, []);
|
|
43
|
-
|
|
44
|
-
if (
|
|
43
|
+
v(() => {
|
|
44
|
+
if (G) return window.addEventListener("pointermove", Q), window.addEventListener("pointerup", $), window.addEventListener("pointercancel", $), () => {
|
|
45
45
|
window.removeEventListener("pointermove", Q), window.removeEventListener("pointerup", $), window.removeEventListener("pointercancel", $);
|
|
46
46
|
};
|
|
47
47
|
}, [
|
|
48
|
-
|
|
48
|
+
G,
|
|
49
49
|
Q,
|
|
50
50
|
$
|
|
51
51
|
]);
|
|
52
|
-
let
|
|
53
|
-
let t = e.shiftKey ?
|
|
52
|
+
let de = (e) => {
|
|
53
|
+
let t = e.shiftKey ? E : T, n = {
|
|
54
54
|
ArrowLeft: [-t, 0],
|
|
55
55
|
ArrowRight: [t, 0],
|
|
56
56
|
ArrowUp: [0, -t],
|
|
57
57
|
ArrowDown: [0, t]
|
|
58
58
|
}[e.key];
|
|
59
|
-
n ? (e.preventDefault(),
|
|
59
|
+
n ? (e.preventDefault(), W((e) => ({
|
|
60
60
|
x: e.x + n[0],
|
|
61
61
|
y: e.y + n[1]
|
|
62
|
-
}))) : e.key === "Home" && (e.preventDefault(),
|
|
62
|
+
}))) : e.key === "Home" && (e.preventDefault(), W({
|
|
63
63
|
x: 0,
|
|
64
64
|
y: 0
|
|
65
65
|
}));
|
|
66
|
-
}, de = () => {
|
|
67
|
-
V((e) => (e + 90) % 360);
|
|
68
66
|
}, fe = () => {
|
|
69
|
-
|
|
67
|
+
H((e) => (e + 90) % 360);
|
|
70
68
|
}, pe = () => {
|
|
69
|
+
J(!0);
|
|
70
|
+
}, me = () => {
|
|
71
71
|
let e = Y.current, t = X.current;
|
|
72
72
|
if (J(!1), !e || !t) return;
|
|
73
73
|
let n = {
|
|
74
|
-
x:
|
|
75
|
-
y:
|
|
76
|
-
zoom:
|
|
77
|
-
rotation:
|
|
74
|
+
x: U.x,
|
|
75
|
+
y: U.y,
|
|
76
|
+
zoom: z,
|
|
77
|
+
rotation: V,
|
|
78
78
|
frameWidth: t.clientWidth,
|
|
79
79
|
frameHeight: t.clientHeight,
|
|
80
80
|
layoutWidth: e.offsetWidth,
|
|
@@ -84,119 +84,121 @@ var w = 10, T = 50, E = h.forwardRef(({ src: h, aspectRatio: E = 1, circular: ne
|
|
|
84
84
|
maxOutputSize: A
|
|
85
85
|
};
|
|
86
86
|
try {
|
|
87
|
-
let { dataUrl: t, detail: r } =
|
|
88
|
-
|
|
87
|
+
let { dataUrl: t, detail: r } = p(e, n, j, M);
|
|
88
|
+
ne?.(t, r), O?.(t, r);
|
|
89
89
|
} catch (e) {
|
|
90
|
-
k?.(e instanceof Error ? e : Error(String(e)),
|
|
90
|
+
k?.(e instanceof Error ? e : Error(String(e)), m(n).detail);
|
|
91
91
|
}
|
|
92
92
|
};
|
|
93
|
-
return
|
|
93
|
+
return g ? /* @__PURE__ */ w("div", {
|
|
94
94
|
ref: I,
|
|
95
|
-
|
|
95
|
+
role: L,
|
|
96
|
+
className: S("wim-image-cropper", h.root, P),
|
|
96
97
|
...F,
|
|
97
98
|
children: [
|
|
98
|
-
/* @__PURE__ */
|
|
99
|
-
ref:
|
|
100
|
-
className:
|
|
101
|
-
onPointerDown:
|
|
102
|
-
onKeyDown:
|
|
99
|
+
/* @__PURE__ */ w("div", {
|
|
100
|
+
ref: le,
|
|
101
|
+
className: h.viewer,
|
|
102
|
+
onPointerDown: ue,
|
|
103
|
+
onKeyDown: de,
|
|
103
104
|
role: "application",
|
|
104
105
|
tabIndex: 0,
|
|
105
|
-
"aria-label":
|
|
106
|
+
"aria-label": R("image_cropper.position_label"),
|
|
106
107
|
"aria-describedby": Z,
|
|
107
108
|
children: [
|
|
108
|
-
/* @__PURE__ */
|
|
109
|
+
/* @__PURE__ */ C(n, {
|
|
109
110
|
id: Z,
|
|
110
|
-
children:
|
|
111
|
+
children: R("image_cropper.position_hint")
|
|
111
112
|
}),
|
|
112
|
-
/* @__PURE__ */
|
|
113
|
-
className:
|
|
114
|
-
children: /* @__PURE__ */
|
|
113
|
+
/* @__PURE__ */ C("div", {
|
|
114
|
+
className: h.imageContainer,
|
|
115
|
+
children: /* @__PURE__ */ C("img", {
|
|
115
116
|
ref: Y,
|
|
116
|
-
src:
|
|
117
|
-
alt:
|
|
117
|
+
src: g,
|
|
118
|
+
alt: R("a11y.crop_target"),
|
|
118
119
|
crossOrigin: N,
|
|
119
|
-
className:
|
|
120
|
-
style: { transform: `translate(${
|
|
120
|
+
className: h.image,
|
|
121
|
+
style: { transform: `translate(${U.x}px, ${U.y}px) rotate(${V}deg) scale(${z})` },
|
|
121
122
|
draggable: !1
|
|
122
123
|
})
|
|
123
124
|
}),
|
|
124
|
-
/* @__PURE__ */
|
|
125
|
-
className:
|
|
126
|
-
children: /* @__PURE__ */
|
|
125
|
+
/* @__PURE__ */ C("div", {
|
|
126
|
+
className: h.overlay,
|
|
127
|
+
children: /* @__PURE__ */ C("div", {
|
|
127
128
|
ref: X,
|
|
128
|
-
className:
|
|
129
|
-
style: { aspectRatio:
|
|
129
|
+
className: S(h.cropArea, { [h.circular]: te }),
|
|
130
|
+
style: { aspectRatio: D }
|
|
130
131
|
})
|
|
131
132
|
})
|
|
132
133
|
]
|
|
133
134
|
}),
|
|
134
|
-
/* @__PURE__ */
|
|
135
|
-
className:
|
|
135
|
+
/* @__PURE__ */ w("div", {
|
|
136
|
+
className: h.controls,
|
|
136
137
|
children: [
|
|
137
|
-
|
|
138
|
-
className:
|
|
139
|
-
children: /* @__PURE__ */
|
|
138
|
+
ie && /* @__PURE__ */ C("div", {
|
|
139
|
+
className: h.zoomControl,
|
|
140
|
+
children: /* @__PURE__ */ C(a, {
|
|
140
141
|
min: 1,
|
|
141
142
|
max: 3,
|
|
142
143
|
step: .1,
|
|
143
|
-
value:
|
|
144
|
-
onChange: (e) =>
|
|
145
|
-
label:
|
|
146
|
-
styles: { root:
|
|
144
|
+
value: z,
|
|
145
|
+
onChange: (e) => B(e),
|
|
146
|
+
label: R("image_cropper.zoom"),
|
|
147
|
+
styles: { root: h.zoomSlider }
|
|
147
148
|
})
|
|
148
149
|
}),
|
|
149
|
-
|
|
150
|
-
className:
|
|
151
|
-
children: /* @__PURE__ */
|
|
150
|
+
re && /* @__PURE__ */ C("div", {
|
|
151
|
+
className: h.rotationControl,
|
|
152
|
+
children: /* @__PURE__ */ C(o, {
|
|
152
153
|
iconName: "RefreshIcon",
|
|
153
|
-
onClick:
|
|
154
|
-
"aria-label":
|
|
154
|
+
onClick: fe,
|
|
155
|
+
"aria-label": R("image_cropper.rotate"),
|
|
155
156
|
variant: "outline",
|
|
156
157
|
size: "sm"
|
|
157
158
|
})
|
|
158
159
|
}),
|
|
159
|
-
|
|
160
|
-
className:
|
|
161
|
-
children: /* @__PURE__ */
|
|
162
|
-
onClick:
|
|
160
|
+
ae && /* @__PURE__ */ C("div", {
|
|
161
|
+
className: h.applyControl,
|
|
162
|
+
children: /* @__PURE__ */ C(r, {
|
|
163
|
+
onClick: pe,
|
|
163
164
|
size: "sm",
|
|
164
165
|
variant: "solid",
|
|
165
|
-
children:
|
|
166
|
+
children: oe || R("image_cropper.apply")
|
|
166
167
|
})
|
|
167
168
|
})
|
|
168
169
|
]
|
|
169
170
|
}),
|
|
170
|
-
/* @__PURE__ */
|
|
171
|
-
open:
|
|
171
|
+
/* @__PURE__ */ C(s, {
|
|
172
|
+
open: ce,
|
|
172
173
|
onOpenChange: J,
|
|
173
|
-
children: /* @__PURE__ */
|
|
174
|
-
/* @__PURE__ */
|
|
175
|
-
/* @__PURE__ */
|
|
176
|
-
/* @__PURE__ */
|
|
174
|
+
children: /* @__PURE__ */ w(l, { children: [
|
|
175
|
+
/* @__PURE__ */ C(ee, { children: /* @__PURE__ */ C(f, { children: R("image_cropper.confirm_title") }) }),
|
|
176
|
+
/* @__PURE__ */ C(u, { children: R("image_cropper.confirm_message") }),
|
|
177
|
+
/* @__PURE__ */ w(d, { children: [/* @__PURE__ */ C(c, {
|
|
177
178
|
asChild: !0,
|
|
178
|
-
children: /* @__PURE__ */
|
|
179
|
+
children: /* @__PURE__ */ C(r, {
|
|
179
180
|
variant: "ghost",
|
|
180
|
-
children:
|
|
181
|
+
children: R("image_cropper.cancel")
|
|
181
182
|
})
|
|
182
|
-
}), /* @__PURE__ */
|
|
183
|
-
onClick:
|
|
183
|
+
}), /* @__PURE__ */ C(r, {
|
|
184
|
+
onClick: me,
|
|
184
185
|
variant: "solid",
|
|
185
|
-
children:
|
|
186
|
+
children: R("image_cropper.confirm")
|
|
186
187
|
})] })
|
|
187
188
|
] })
|
|
188
189
|
})
|
|
189
190
|
]
|
|
190
|
-
}) : /* @__PURE__ */
|
|
191
|
+
}) : /* @__PURE__ */ C("div", {
|
|
191
192
|
ref: I,
|
|
192
|
-
|
|
193
|
+
role: L,
|
|
194
|
+
className: S("wim-image-cropper", h.root, h.empty, P),
|
|
193
195
|
...F,
|
|
194
|
-
children: /* @__PURE__ */
|
|
195
|
-
className:
|
|
196
|
-
children:
|
|
196
|
+
children: /* @__PURE__ */ C("div", {
|
|
197
|
+
className: h.emptyContent,
|
|
198
|
+
children: R("image_cropper.no_image")
|
|
197
199
|
})
|
|
198
200
|
});
|
|
199
201
|
});
|
|
200
|
-
|
|
202
|
+
D.displayName = "ImageCropper";
|
|
201
203
|
//#endregion
|
|
202
|
-
export {
|
|
204
|
+
export { D as ImageCropper };
|
|
@@ -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/components.cjs"),r=require("../Button/Button.cjs"),i=require("../Input/Input.cjs"),a=require("../DatePicker/DatePicker.cjs"),o=require("../NumberInput/NumberInput.cjs"),s=require("../SegmentedControl/SegmentedControl.cjs"),c=require("../Select/Select.cjs"),l=require("../Switch/Switch.cjs"),u=require("../IconButton/IconButton.cjs"),d=require("./querybuilder.module.cjs"),f=require("./warn-unknown-operator.cjs");let p=require("react");p=e.__toESM(p,1);let m=require("classnames");m=e.__toESM(m,1);let h=require("react/jsx-runtime");var g=0,_=()=>typeof window<`u`&&window.__VRT__?(g+=1,`vrt-id-${g}`):Math.random().toString(36).substring(2,11),
|
|
2
|
+
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../i18n/useWimTranslation.cjs"),n=require("../../../i18n/generated/components.cjs"),r=require("../Button/Button.cjs"),i=require("../Input/Input.cjs"),a=require("../DatePicker/DatePicker.cjs"),o=require("../NumberInput/NumberInput.cjs"),s=require("../SegmentedControl/SegmentedControl.cjs"),c=require("../Select/Select.cjs"),l=require("../Switch/Switch.cjs"),u=require("../IconButton/IconButton.cjs"),d=require("./querybuilder.module.cjs"),f=require("./warn-unknown-operator.cjs");let p=require("react");p=e.__toESM(p,1);let m=require("classnames");m=e.__toESM(m,1);let h=require("react/jsx-runtime");var g=0,_=()=>typeof window<`u`&&window.__VRT__?(g+=1,`vrt-id-${g}`):Math.random().toString(36).substring(2,11),ee={string:[{value:`=`,key:`equal`},{value:`!=`,key:`not_equal`},{value:`contains`,key:`contains`},{value:`starts_with`,key:`starts_with`},{value:`ends_with`,key:`ends_with`},{value:`is_null`,key:`is_null`},{value:`is_not_null`,key:`is_not_null`}],number:[{value:`=`,key:`equal`},{value:`!=`,key:`not_equal`},{value:`>`,key:`greater_than`},{value:`<`,key:`less_than`},{value:`>=`,key:`greater_than_or_equal`},{value:`<=`,key:`less_than_or_equal`},{value:`is_null`,key:`is_null`},{value:`is_not_null`,key:`is_not_null`}],date:[{value:`=`,key:`equal`},{value:`!=`,key:`not_equal`},{value:`>`,key:`after`},{value:`<`,key:`before`},{value:`>=`,key:`after_or_on`},{value:`<=`,key:`before_or_on`},{value:`is_null`,key:`is_null`},{value:`is_not_null`,key:`is_not_null`}],boolean:[{value:`=`,key:`equal`},{value:`!=`,key:`not_equal`},{value:`is_null`,key:`is_null`},{value:`is_not_null`,key:`is_not_null`}]},v=({fields:e,query:g,defaultQuery:v,onChange:y,maxDepth:b=3,className:x,id:S,labels:C={},"aria-label":w,"aria-labelledby":T,"aria-describedby":te})=>{let{t:E}=t.useWimTranslation(n.componentsNs),{ruleAdded:D=E(`query.builder.rule_added`),groupAdded:O=E(`query.builder.group_added`),removed:k=E(`query.builder.removed`),ruleAriaLabel:A=E(`query.builder.rule`),fieldAriaLabel:j=E(`query.builder.field`),operatorAriaLabel:M=E(`query.builder.operator`),valueAriaLabel:N=E(`query.builder.value`),trueLabel:P=E(`query.builder.true`),falseLabel:F=E(`query.builder.false`),removeRuleAriaLabel:I=E(`query.builder.remove_rule`),removeGroupAriaLabel:L=E(`query.builder.remove_group`),addRuleLabel:R=E(`query.builder.add_rule`),addGroupLabel:z=E(`query.builder.add_group`),regionAriaLabel:B=E(`query.builder.region_label`),combinatorAriaLabel:V=E(`query.builder.combinator`),operators:H={}}=C,U=(0,p.useId)(),W=S||`wim-qb-${U}`,G=(0,p.useRef)(null),[K,q]=(0,p.useState)(v||{id:_(),combinator:`and`,not:!1,rules:[]}),J=g===void 0?K:g,Y=(0,p.useCallback)(e=>{G.current&&(G.current.textContent=``,setTimeout(()=>{G.current&&(G.current.textContent=e)},50))},[]),X=(0,p.useCallback)(e=>{g===void 0&&q(e),y?.(e)},[g,y]),Z=(e,t)=>{let n=r=>r.id===e?{...r,...t}:{...r,rules:r.rules.map(r=>r.id===e?{...r,...t}:`rules`in r?n(r):r)};X(n(J))},ne=t=>{let n=e[0],r={id:_(),field:n?.name||``,operator:`=`,value:n?.type!==`boolean`&&``},i=e=>e.id===t?{...e,rules:[...e.rules,r]}:{...e,rules:e.rules.map(e=>`rules`in e?i(e):e)};X(i(J)),Y(D)},re=e=>{let t={id:_(),combinator:`and`,not:!1,rules:[]},n=r=>r.id===e?{...r,rules:[...r.rules,t]}:{...r,rules:r.rules.map(e=>`rules`in e?n(e):e)};X(n(J)),Y(O)},Q=e=>{let t=n=>({...n,rules:n.rules.filter(t=>t.id!==e).map(e=>`rules`in e?t(e):e)});X(t(J)),Y(k)},$=(e,t,n)=>{let i=`${e.combinator.toUpperCase()} group`;return(0,h.jsxs)(`div`,{role:`group`,"aria-label":i,className:(0,m.default)(d.default.group,t>0&&d.default.nested,n&&d.default.excluded),children:[(0,h.jsxs)(`div`,{className:d.default.groupHeader,children:[(0,h.jsxs)(`div`,{className:d.default.groupHeaderLeft,children:[(0,h.jsx)(s.SegmentedControl,{size:`md`,options:[{label:`AND`,value:`and`},{label:`OR`,value:`or`}],value:e.combinator,onChange:t=>Z(e.id,{combinator:t}),"aria-label":V,styles:{root:d.default.segmentedControl,item:d.default.segmentedControlItem,slider:d.default.segmentedControlSlider}}),(0,h.jsx)(l.Switch,{size:`md`,checked:e.not,onChange:t=>Z(e.id,{not:t.target.checked}),children:`NOT`})]}),t>0&&(0,h.jsx)(u.IconButton,{iconName:`TrashIcon`,"aria-label":L,variant:`ghost`,size:`md`,intent:`danger`,onClick:()=>Q(e.id),className:d.default.removeGroup})]}),(0,h.jsx)(`div`,{className:d.default.ruleList,children:e.rules.map(e=>`rules`in e?$(e,t+1,n):ie(e))}),(0,h.jsxs)(`div`,{className:d.default.groupActions,children:[(0,h.jsx)(r.Button,{size:`md`,variant:`ghost`,icon:`PlusIcon`,onClick:()=>ne(e.id),children:R}),t<b&&(0,h.jsx)(r.Button,{size:`md`,variant:`ghost`,icon:`PlusIcon`,onClick:()=>re(e.id),children:z})]})]},e.id)},ie=t=>{let n=e.find(e=>e.name===t.field)?.type||`string`,r=ee[n].map(e=>({...e,label:H[e.key]||E(`query.builder.operators.${e.key}`)})),s=n=>{let r=e.find(e=>e.name===n);Z(t.id,{field:n,operator:`=`,value:r?.type!==`boolean`&&``})};r.some(e=>e.value===t.operator)||f.warnUnknownOperator(t.operator,n,r.map(e=>e.value));let l=t.operator===`is_null`||t.operator===`is_not_null`;return(0,h.jsx)(`div`,{className:d.default.rule,role:`group`,"aria-label":A,children:(0,h.jsxs)(`div`,{className:d.default.ruleFields,children:[(0,h.jsx)(c.Select,{className:d.default.field,options:e.map(e=>({label:e.label,value:e.name})),value:t.field,onChange:s,"aria-label":j,fullWidth:!0,styles:{root:d.default.select,trigger:d.default.selectTrigger,inputBase:{root:d.default.inputBase}}}),(0,h.jsx)(c.Select,{className:d.default.operator,options:r.map(e=>({label:e.label,value:e.value})),value:t.operator,onChange:e=>Z(t.id,{operator:e}),"aria-label":M,fullWidth:!0,styles:{root:d.default.select,trigger:d.default.selectTrigger,inputBase:{root:d.default.inputBase}}}),!l&&(0,h.jsx)(`div`,{className:d.default.value,children:n===`number`?(0,h.jsx)(o.NumberInput,{value:typeof t.value==`boolean`?void 0:t.value??void 0,onChange:e=>Z(t.id,{value:e.target.value}),"aria-label":N}):n===`date`?(0,h.jsx)(a.DatePicker,{value:typeof t.value==`string`||typeof t.value==`number`?new Date(t.value):void 0,onChange:e=>Z(t.id,{value:e?e.toISOString():``}),"aria-label":N}):n===`boolean`?(0,h.jsx)(c.Select,{options:[{label:P,value:`true`},{label:F,value:`false`}],value:String(t.value),onChange:e=>Z(t.id,{value:e===`true`}),"aria-label":N,fullWidth:!0,styles:{root:d.default.select,trigger:d.default.selectTrigger,inputBase:{root:d.default.inputBase}}}):(0,h.jsx)(i.Input,{value:typeof t.value==`boolean`?void 0:t.value??void 0,onChange:e=>Z(t.id,{value:e.target.value}),"aria-label":N,styles:{root:d.default.inputBase}})}),(0,h.jsx)(u.IconButton,{iconName:`TrashIcon`,"aria-label":I,variant:`ghost`,size:`md`,intent:`danger`,onClick:()=>Q(t.id),className:d.default.removeRule})]})},t.id)};return(0,h.jsxs)(`div`,{id:W,role:`region`,"aria-label":T?void 0:w??B,"aria-labelledby":T,"aria-describedby":te,className:(0,m.default)(`wim-query-builder`,d.default.root,x),children:[(0,h.jsx)(`div`,{ref:G,"aria-live":`polite`,"aria-atomic":`true`,className:d.default.srOnly}),$(J,0,!1)]})};exports.QueryBuilder=v;
|
|
@@ -68,6 +68,12 @@ export interface QueryBuilderProps {
|
|
|
68
68
|
* Labels for internationalization
|
|
69
69
|
*/
|
|
70
70
|
labels?: QueryBuilderLabels;
|
|
71
|
+
/** Accessible name for the query builder region. Takes precedence over `labels.regionAriaLabel`. */
|
|
72
|
+
"aria-label"?: string;
|
|
73
|
+
/** ID of the element that labels the query builder region. Takes precedence over `aria-label`. */
|
|
74
|
+
"aria-labelledby"?: string;
|
|
75
|
+
/** ID of the element that describes the query builder region. */
|
|
76
|
+
"aria-describedby"?: string;
|
|
71
77
|
}
|
|
72
78
|
/**
|
|
73
79
|
* 演算子の語彙。**利用者が `QueryRule.operator` に渡すのは `value`(記号)**で、
|
|
@@ -167,5 +173,5 @@ export type QueryOperator = (typeof DEFAULT_OPERATORS)[QueryFieldType][number]["
|
|
|
167
173
|
/**
|
|
168
174
|
* 複雑な検索条件をネスト状に組み立てるためのクエリビルダーコンポーネント。
|
|
169
175
|
*/
|
|
170
|
-
export declare const QueryBuilder: ({ fields, query, defaultQuery, onChange, maxDepth, className, id: customId, labels, }: QueryBuilderProps) => React.JSX.Element;
|
|
176
|
+
export declare const QueryBuilder: ({ fields, query, defaultQuery, onChange, maxDepth, className, id: customId, labels, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, }: QueryBuilderProps) => React.JSX.Element;
|
|
171
177
|
export {};
|