wimui 0.58.0 → 0.59.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/Terminal/Terminal.cjs +2 -2
- package/dist/components/ai/Terminal/Terminal.js +16 -14
- 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/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/InlineEdit/InlineEdit.cjs +1 -1
- package/dist/components/form/InlineEdit/InlineEdit.js +62 -60
- 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/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/llms-full.txt +15 -1
- package/dist/llms.txt +1 -1
- package/dist/wimui.umd.js +4 -4
- package/package.json +1 -1
|
@@ -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 {};
|
|
@@ -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("../../../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;
|
|
@@ -8,77 +8,82 @@ import o from "../../../icon/sun.js";
|
|
|
8
8
|
import { Icon as s } from "../../media/Icon/Icon.js";
|
|
9
9
|
import { setWimTheme as c } from "../../../theme.js";
|
|
10
10
|
import l from "./theme-toggle.module.js";
|
|
11
|
-
import u, { useCallback as d, useEffect as f,
|
|
12
|
-
import
|
|
13
|
-
import { jsx as
|
|
11
|
+
import u, { useCallback as d, useEffect as f, useId as p, useState as m } from "react";
|
|
12
|
+
import h from "classnames";
|
|
13
|
+
import { jsx as g, jsxs as _ } from "react/jsx-runtime";
|
|
14
14
|
//#region src/components/form/ThemeToggle/ThemeToggle.tsx
|
|
15
|
-
var
|
|
15
|
+
var v = {
|
|
16
16
|
light: o,
|
|
17
17
|
dark: a,
|
|
18
18
|
system: i
|
|
19
|
-
},
|
|
20
|
-
let { t:
|
|
21
|
-
light:
|
|
22
|
-
dark:
|
|
23
|
-
system:
|
|
24
|
-
},
|
|
25
|
-
if (typeof window < "u" &&
|
|
26
|
-
let e = window.localStorage.getItem(
|
|
27
|
-
if (
|
|
19
|
+
}, y = "wim-theme", b = (e) => e === "light" || e === "dark" || e === "system", x = u.forwardRef(({ value: i, defaultValue: a = "system", onChange: o, modes: u = ["light", "dark"], variant: x = "icon", size: S = "md", storageKey: C = y, applyToDocument: w = !0, labels: T, className: E, asChild: D = !1, children: O, "aria-label": k, "aria-labelledby": A, "aria-describedby": j, ...M }, N) => {
|
|
20
|
+
let { t: P } = n(r), { light: F = P("common.light"), dark: I = P("common.dark"), system: L = P("theme.system"), toggle: R = P("theme.toggle") } = T ?? {}, z = {
|
|
21
|
+
light: F,
|
|
22
|
+
dark: I,
|
|
23
|
+
system: L
|
|
24
|
+
}, B = i !== void 0, [V, H] = m(() => {
|
|
25
|
+
if (typeof window < "u" && C) {
|
|
26
|
+
let e = window.localStorage.getItem(C);
|
|
27
|
+
if (b(e) && u.includes(e)) return e;
|
|
28
28
|
}
|
|
29
29
|
return u.includes(a) ? a : u[0];
|
|
30
|
-
}),
|
|
30
|
+
}), U = B ? i : V;
|
|
31
31
|
f(() => {
|
|
32
|
-
|
|
33
|
-
}, [
|
|
34
|
-
let
|
|
35
|
-
|
|
32
|
+
w && c(U);
|
|
33
|
+
}, [U, w]);
|
|
34
|
+
let W = d((e) => {
|
|
35
|
+
B || H(e), typeof window < "u" && C && window.localStorage.setItem(C, e), o?.(e);
|
|
36
36
|
}, [
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
B,
|
|
38
|
+
C,
|
|
39
39
|
o
|
|
40
|
-
]),
|
|
41
|
-
let e = u[(u.indexOf(
|
|
42
|
-
|
|
43
|
-
},
|
|
44
|
-
return
|
|
45
|
-
ref:
|
|
40
|
+
]), G = () => {
|
|
41
|
+
let e = u[(u.indexOf(U) + 1) % u.length];
|
|
42
|
+
W(e);
|
|
43
|
+
}, K = p(), q = D ? e : "div", J = `wim-theme-toggle-${K}`;
|
|
44
|
+
return x === "segmented" ? /* @__PURE__ */ _(q, {
|
|
45
|
+
ref: N,
|
|
46
46
|
role: "group",
|
|
47
|
-
"aria-label":
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
"aria-label": A ? void 0 : k ?? R,
|
|
48
|
+
"aria-labelledby": A,
|
|
49
|
+
"aria-describedby": j,
|
|
50
|
+
className: h("wim-theme-toggle", l.segmented, l[S], E),
|
|
51
|
+
...M,
|
|
50
52
|
children: [u.map((e) => {
|
|
51
|
-
let t = e ===
|
|
52
|
-
return /* @__PURE__ */
|
|
53
|
+
let t = e === U;
|
|
54
|
+
return /* @__PURE__ */ g("button", {
|
|
53
55
|
type: "button",
|
|
54
|
-
className:
|
|
56
|
+
className: h(l.segment, t && l.active),
|
|
55
57
|
"aria-pressed": t,
|
|
56
|
-
"aria-label":
|
|
57
|
-
title:
|
|
58
|
-
onClick: () =>
|
|
59
|
-
children: /* @__PURE__ */
|
|
60
|
-
component:
|
|
61
|
-
size:
|
|
58
|
+
"aria-label": z[e],
|
|
59
|
+
title: z[e],
|
|
60
|
+
onClick: () => W(e),
|
|
61
|
+
children: /* @__PURE__ */ g(s, {
|
|
62
|
+
component: v[e],
|
|
63
|
+
size: S
|
|
62
64
|
})
|
|
63
65
|
}, e);
|
|
64
|
-
}), /* @__PURE__ */
|
|
65
|
-
}) : /* @__PURE__ */
|
|
66
|
-
ref:
|
|
67
|
-
className:
|
|
68
|
-
...
|
|
69
|
-
children: [/* @__PURE__ */
|
|
66
|
+
}), /* @__PURE__ */ g(t, { children: O })]
|
|
67
|
+
}) : /* @__PURE__ */ _(q, {
|
|
68
|
+
ref: N,
|
|
69
|
+
className: h("wim-theme-toggle", l.root, E),
|
|
70
|
+
...M,
|
|
71
|
+
children: [/* @__PURE__ */ g("button", {
|
|
70
72
|
type: "button",
|
|
71
|
-
className:
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
73
|
+
className: h(l.iconButton, l[S]),
|
|
74
|
+
id: J,
|
|
75
|
+
"aria-label": A ? z[U] : `${k ?? R} (${z[U]})`,
|
|
76
|
+
"aria-labelledby": A ? `${A} ${J}` : void 0,
|
|
77
|
+
"aria-describedby": j,
|
|
78
|
+
title: z[U],
|
|
79
|
+
onClick: G,
|
|
80
|
+
children: /* @__PURE__ */ g(s, {
|
|
81
|
+
component: v[U],
|
|
82
|
+
size: S
|
|
78
83
|
})
|
|
79
|
-
}), /* @__PURE__ */
|
|
84
|
+
}), /* @__PURE__ */ g(t, { children: O })]
|
|
80
85
|
});
|
|
81
86
|
});
|
|
82
|
-
|
|
87
|
+
x.displayName = "ThemeToggle";
|
|
83
88
|
//#endregion
|
|
84
|
-
export {
|
|
89
|
+
export { x as ThemeToggle };
|
|
@@ -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("../../../icon/chevron-left.cjs"),i=require("../../../icon/chevron-right.cjs"),a=require("../Icon/Icon.cjs"),o=require("./image-compare.module.cjs");let s=require("react");s=e.__toESM(s,1);let c=require("classnames");c=e.__toESM(c,1);let l=require("react/jsx-runtime");var u=e=>Math.max(0,Math.min(100,e)),d=s.default.forwardRef(({before:e,after:d,beforeAlt:f=``,afterAlt:p=``,beforeLabel:m,afterLabel:h,defaultPosition:g=50,position:_,onPositionChange:v,orientation:y=`horizontal`,width:b,height:x,radius:S=`md`,labels:C,className:w,...
|
|
2
|
+
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../i18n/useWimTranslation.cjs"),n=require("../../../i18n/generated/common.cjs"),r=require("../../../icon/chevron-left.cjs"),i=require("../../../icon/chevron-right.cjs"),a=require("../Icon/Icon.cjs"),o=require("./image-compare.module.cjs");let s=require("react");s=e.__toESM(s,1);let c=require("classnames");c=e.__toESM(c,1);let l=require("react/jsx-runtime");var u=e=>Math.max(0,Math.min(100,e)),d=s.default.forwardRef(({before:e,after:d,beforeAlt:f=``,afterAlt:p=``,beforeLabel:m,afterLabel:h,defaultPosition:g=50,position:_,onPositionChange:v,orientation:y=`horizontal`,width:b,height:x,radius:S=`md`,labels:C,className:w,"aria-label":T,"aria-labelledby":E,"aria-describedby":D,...O},k)=>{let{t:A}=t.useWimTranslation(n.commonNs),{handleAriaLabel:j=A(`imageCompare.handle`)}=C??{},M=_!==void 0,[N,P]=(0,s.useState)(u(g)),F=u(M?_:N),I=y===`vertical`,L=(0,s.useRef)(null),R=(0,s.useRef)(!1),z=(0,s.useCallback)(e=>{L.current=e,typeof k==`function`?k(e):k&&(k.current=e)},[k]),B=(0,s.useCallback)(e=>{let t=u(e);M||P(t),v?.(t)},[M,v]),V=(0,s.useCallback)((e,t)=>{let n=L.current?.getBoundingClientRect();if(!n)return;let r=I?(t-n.top)/n.height*100:(e-n.left)/n.width*100;B(r)},[I,B]),H=e=>{R.current=!0,e.currentTarget.setPointerCapture(e.pointerId),V(e.clientX,e.clientY)},U=e=>{R.current&&V(e.clientX,e.clientY)},W=e=>{R.current=!1,e.currentTarget.releasePointerCapture?.(e.pointerId)},G=e=>{let t=e.shiftKey?10:2,n=I?`ArrowUp`:`ArrowLeft`,r=I?`ArrowDown`:`ArrowRight`;e.key===n?(e.preventDefault(),B(F-t)):e.key===r?(e.preventDefault(),B(F+t)):e.key===`Home`?(e.preventDefault(),B(0)):e.key===`End`&&(e.preventDefault(),B(100))},K=I?{clipPath:`inset(0 0 ${100-F}% 0)`}:{clipPath:`inset(0 ${100-F}% 0 0)`},q=I?{top:`${F}%`}:{left:`${F}%`};return(0,l.jsxs)(`div`,{ref:z,className:(0,c.default)(`wim-image-compare`,o.default.root,I&&o.default.vertical,o.default[`radius-${S}`],w),style:{width:b,height:x},onPointerDown:H,onPointerMove:U,onPointerUp:W,...O,children:[(0,l.jsx)(`img`,{className:o.default.image,src:d,alt:p,draggable:!1}),h&&(0,l.jsx)(`span`,{className:(0,c.default)(o.default.label,o.default.afterLabel),children:h}),(0,l.jsxs)(`div`,{className:o.default.beforeLayer,style:K,children:[(0,l.jsx)(`img`,{className:o.default.image,src:e,alt:f,draggable:!1}),m&&(0,l.jsx)(`span`,{className:(0,c.default)(o.default.label,o.default.beforeLabel),children:m})]}),(0,l.jsxs)(`div`,{className:o.default.divider,style:q,children:[(0,l.jsx)(`span`,{className:o.default.line,"aria-hidden":`true`}),(0,l.jsxs)(`button`,{type:`button`,className:o.default.handle,role:`slider`,"aria-label":E?void 0:T??j,"aria-labelledby":E,"aria-describedby":D,"aria-orientation":y,"aria-valuenow":Math.round(F),"aria-valuemin":0,"aria-valuemax":100,onKeyDown:G,onPointerDown:H,children:[(0,l.jsx)(a.Icon,{component:r.default,size:`sm`,className:o.default.arrow}),(0,l.jsx)(a.Icon,{component:i.default,size:`sm`,className:o.default.arrow})]})]})]})});d.displayName=`ImageCompare`,exports.ImageCompare=d;
|