wimui 0.64.4 → 0.64.5
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/ai/code-diff-viewer.js +1 -2
- package/dist/ai/interactive-graph.js +1 -2
- package/dist/ai/markdown-renderer.js +1 -2
- package/dist/ai/streaming-text.js +1 -2
- package/dist/components/_internal/observeMove.cjs +1 -1
- package/dist/components/_internal/observeMove.js +9 -10
- package/dist/components/ai/SourceCitation/SourceCitation.cjs +1 -1
- package/dist/components/ai/SourceCitation/SourceCitation.js +1 -1
- package/dist/components/charts/SankeyChart/SankeyChart.cjs +1 -1
- package/dist/components/charts/SankeyChart/SankeyChart.js +1 -5
- package/dist/components/data-display/Accordion/Accordion.cjs +1 -1
- package/dist/components/data-display/Accordion/Accordion.js +1 -5
- package/dist/components/data-display/Carousel/Carousel.cjs +1 -1
- package/dist/components/data-display/Carousel/Carousel.js +2 -14
- package/dist/components/data-display/NodeGraph/NodeGraph.cjs +1 -1
- package/dist/components/data-display/NodeGraph/NodeGraph.js +1 -7
- package/dist/components/data-display/ScheduleView/ScheduleView.cjs +1 -1
- package/dist/components/data-display/ScheduleView/ScheduleView.js +3 -1
- package/dist/components/data-display/SwipeAction/SwipeAction.cjs +1 -1
- package/dist/components/data-display/SwipeAction/SwipeAction.js +9 -10
- package/dist/components/data-display/TreeDiagram/TreeDiagram.cjs +1 -1
- package/dist/components/data-display/TreeDiagram/TreeDiagram.js +94 -73
- package/dist/components/feedback/Tour/Tour.cjs +1 -1
- package/dist/components/feedback/Tour/Tour.js +2 -6
- package/dist/components/form/Button/Button.cjs +1 -1
- package/dist/components/form/Button/Button.js +58 -55
- package/dist/components/form/Combobox/Combobox.cjs +1 -1
- package/dist/components/form/Combobox/Combobox.js +2 -5
- package/dist/components/form/Dropzone/Dropzone.cjs +1 -1
- package/dist/components/form/Dropzone/Dropzone.js +83 -68
- package/dist/components/form/FileUpload/FileUpload.cjs +1 -1
- package/dist/components/form/FileUpload/FileUpload.js +19 -15
- package/dist/components/form/FloatButton/FloatButton.cjs +1 -1
- package/dist/components/form/FloatButton/FloatButton.js +7 -6
- package/dist/components/form/InlineEdit/InlineEdit.cjs +1 -1
- package/dist/components/form/InlineEdit/InlineEdit.js +76 -73
- package/dist/components/form/RichTextEditor/RichTextEditor.cjs +1 -1
- package/dist/components/form/RichTextEditor/RichTextEditor.js +117 -129
- package/dist/components/form/SegmentedControl/SegmentedControl.cjs +1 -1
- package/dist/components/form/SegmentedControl/SegmentedControl.js +1 -1
- package/dist/components/form/ToggleGroup/ToggleGroup.cjs +1 -1
- package/dist/components/form/ToggleGroup/ToggleGroup.js +1 -1
- package/dist/components/form/TreeSelect/TreeSelect.cjs +1 -1
- package/dist/components/form/TreeSelect/TreeSelect.js +1 -7
- package/dist/components/layout/InteractiveArea/InteractiveArea.cjs +1 -1
- package/dist/components/layout/InteractiveArea/InteractiveArea.js +1 -5
- package/dist/components/media/Audio/hooks/useAudioPlayer.cjs +1 -1
- package/dist/components/media/Audio/hooks/useAudioPlayer.js +1 -9
- package/dist/components/media/Lightbox/Lightbox.cjs +1 -1
- package/dist/components/media/Lightbox/Lightbox.js +5 -9
- package/dist/components/navigation/CommandPalette/CommandPalette.cjs +1 -1
- package/dist/components/navigation/CommandPalette/CommandPalette.js +1 -8
- package/dist/components/navigation/TabNavigation/TabNavigation.cjs +1 -1
- package/dist/components/navigation/TabNavigation/TabNavigation.js +1 -5
- package/dist/data-display/json-diff-viewer.js +1 -2
- package/dist/data-display/markdown.js +1 -2
- package/dist/data-display/node-graph.js +1 -2
- package/dist/data-display/qr-code.js +1 -2
- package/dist/data-display/schedule-view.js +1 -2
- package/dist/form/rich-text-editor.js +1 -2
- package/dist/llms-full.txt +1 -1
- package/dist/llms.txt +1 -1
- package/dist/node_modules/@radix-ui/react-slot/dist/index.cjs +1 -1
- package/dist/node_modules/@radix-ui/react-slot/dist/index.js +18 -17
- package/dist/rhf/zod.js +1 -2
- package/dist/wimui.umd.js +5 -5
- package/package.json +44 -44
|
@@ -17,18 +17,18 @@ import { FieldTemplate as ae } from "../FieldTemplate/FieldTemplate.js";
|
|
|
17
17
|
import { Input as l } from "../Input/Input.js";
|
|
18
18
|
import { Dialog as oe, DialogClose as se, DialogContent as ce, DialogFooter as le, DialogHeader as ue, DialogTitle as de } from "../../overlay/Dialog/Dialog.js";
|
|
19
19
|
import { isSafeImageUrl as u, isSafeLinkUrl as fe } from "./safeUrl.js";
|
|
20
|
-
import { createMarkdownExtensions as d, markdownToHtml as
|
|
21
|
-
import
|
|
22
|
-
import
|
|
23
|
-
import
|
|
24
|
-
import { Fragment as
|
|
25
|
-
import { EditorContent as
|
|
26
|
-
import { createDocument as
|
|
27
|
-
import { StarterKit as
|
|
28
|
-
import { Placeholder as
|
|
29
|
-
import { Image as
|
|
20
|
+
import { createMarkdownExtensions as d, markdownToHtml as pe } from "./markdown.js";
|
|
21
|
+
import f from "./rich-text-editor.module.js";
|
|
22
|
+
import p from "react";
|
|
23
|
+
import me from "classnames";
|
|
24
|
+
import { Fragment as he, jsx as m, jsxs as h } from "react/jsx-runtime";
|
|
25
|
+
import { EditorContent as ge, useEditor as _e, useEditorState as ve } from "@tiptap/react";
|
|
26
|
+
import { createDocument as ye } from "@tiptap/core";
|
|
27
|
+
import { StarterKit as g } from "@tiptap/starter-kit";
|
|
28
|
+
import { Placeholder as _ } from "@tiptap/extensions";
|
|
29
|
+
import { Image as be } from "@tiptap/extension-image";
|
|
30
30
|
//#region src/components/form/RichTextEditor/RichTextEditor.tsx
|
|
31
|
-
var
|
|
31
|
+
var xe = [
|
|
32
32
|
"bold",
|
|
33
33
|
"italic",
|
|
34
34
|
"underline",
|
|
@@ -45,13 +45,13 @@ var be = [
|
|
|
45
45
|
"unlink",
|
|
46
46
|
"separator",
|
|
47
47
|
"removeFormat"
|
|
48
|
-
],
|
|
48
|
+
], Se = be.extend({ parseHTML() {
|
|
49
49
|
return [{
|
|
50
50
|
tag: "img[src]",
|
|
51
51
|
getAttrs: (e) => u(e.getAttribute("src")) ? null : !1
|
|
52
52
|
}];
|
|
53
|
-
} }),
|
|
54
|
-
|
|
53
|
+
} }), Ce = (e, t, n) => [
|
|
54
|
+
g.configure({
|
|
55
55
|
heading: { levels: [
|
|
56
56
|
1,
|
|
57
57
|
2,
|
|
@@ -74,47 +74,47 @@ var be = [
|
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
76
|
}),
|
|
77
|
-
|
|
77
|
+
Se.configure({
|
|
78
78
|
inline: !1,
|
|
79
79
|
allowBase64: !1
|
|
80
80
|
}),
|
|
81
|
-
|
|
81
|
+
_.configure({ placeholder: e }),
|
|
82
82
|
...t === "markdown" ? d(n) : []
|
|
83
|
-
],
|
|
84
|
-
ref:
|
|
83
|
+
], we = (e, t) => e.isEmpty ? "" : t === "markdown" ? e.getMarkdown() : e.getHTML(), Te = (e, t, n) => n === "markdown" ? pe(e, t) : t, Ee = p.memo(({ onClick: e, active: t, disabled: n, title: r, label: i, tabIndex: a, onFocus: o, buttonRef: ee, children: te }) => /* @__PURE__ */ m("button", {
|
|
84
|
+
ref: ee,
|
|
85
85
|
type: "button",
|
|
86
|
-
className:
|
|
86
|
+
className: me(f.toolbarBtn, t && f.active),
|
|
87
87
|
onClick: e,
|
|
88
|
-
onFocus:
|
|
88
|
+
onFocus: o,
|
|
89
89
|
disabled: n,
|
|
90
90
|
title: r,
|
|
91
|
-
"aria-label": r,
|
|
91
|
+
"aria-label": i ? `${i} ${r}` : r,
|
|
92
92
|
"aria-pressed": t,
|
|
93
|
-
tabIndex:
|
|
94
|
-
children:
|
|
93
|
+
tabIndex: a,
|
|
94
|
+
children: te
|
|
95
95
|
}));
|
|
96
|
-
|
|
97
|
-
var
|
|
98
|
-
let { t: O } = e(t), { bold: Ne = O("a11y.rte_bold"), italic: Pe = O("a11y.rte_italic"), underline: Fe = O("a11y.rte_underline"), strikethrough: Ie = O("a11y.rte_strikethrough"), h1: Le = O("a11y.rte_h1"), h2: Re = O("a11y.rte_h2"), h3: ze = O("a11y.rte_h3"), ul: Be = O("a11y.rte_ul"), ol: Ve = O("a11y.rte_ol"), link: He = O("a11y.rte_link"), unlink: Ue = O("a11y.rte_unlink"), removeFormat: We = O("a11y.rte_remove_format"), toolbar: Ge = O("a11y.rte_toolbar"), linkPrompt: Ke = O("a11y.rte_link_prompt"), linkApply: qe = O("a11y.rte_link_apply"), linkCancel: Je = O("a11y.rte_link_cancel"), linkInvalid: Ye = O("a11y.rte_link_invalid"), image: Xe = O("a11y.rte_image"), imageUrl: Ze = O("a11y.rte_image_url"), imageAlt: Qe = O("a11y.rte_image_alt"), imageAltHint: $e = O("a11y.rte_image_alt_hint"), imageUpload: et = O("a11y.rte_image_upload"), imageUploadFailed: k = O("a11y.rte_image_upload_failed"), imageInvalid: tt = O("a11y.rte_image_invalid") } = Ae, nt =
|
|
96
|
+
Ee.displayName = "ToolbarButton";
|
|
97
|
+
var v = ({ value: d, defaultValue: pe = "", onChange: g, placeholder: _, disabled: be, intent: Se = "default", variant: v = "outline", fullWidth: y = !1, width: b, minHeight: x = 200, label: S, error: C, required: w, layout: De, className: Oe, id: ke, toolbar: T = xe, labels: Ae = {}, "aria-label": je, "aria-labelledby": E, onImageUpload: D, format: Me = "html" }) => {
|
|
98
|
+
let { t: O } = e(t), { bold: Ne = O("a11y.rte_bold"), italic: Pe = O("a11y.rte_italic"), underline: Fe = O("a11y.rte_underline"), strikethrough: Ie = O("a11y.rte_strikethrough"), h1: Le = O("a11y.rte_h1"), h2: Re = O("a11y.rte_h2"), h3: ze = O("a11y.rte_h3"), ul: Be = O("a11y.rte_ul"), ol: Ve = O("a11y.rte_ol"), link: He = O("a11y.rte_link"), unlink: Ue = O("a11y.rte_unlink"), removeFormat: We = O("a11y.rte_remove_format"), toolbar: Ge = O("a11y.rte_toolbar"), linkPrompt: Ke = O("a11y.rte_link_prompt"), linkApply: qe = O("a11y.rte_link_apply"), linkCancel: Je = O("a11y.rte_link_cancel"), linkInvalid: Ye = O("a11y.rte_link_invalid"), image: Xe = O("a11y.rte_image"), imageUrl: Ze = O("a11y.rte_image_url"), imageAlt: Qe = O("a11y.rte_image_alt"), imageAltHint: $e = O("a11y.rte_image_alt_hint"), imageUpload: et = O("a11y.rte_image_upload"), imageUploadFailed: k = O("a11y.rte_image_upload_failed"), imageInvalid: tt = O("a11y.rte_image_invalid") } = Ae, nt = p.useId(), A = ke || `wim-rte-${nt}`, j = C ? `${A}-error` : void 0, M = S ? `${A}-label` : void 0, N = !!be, P = C ? "danger" : Se, rt = typeof b == "string" && [
|
|
99
99
|
"xs",
|
|
100
100
|
"sm",
|
|
101
101
|
"md",
|
|
102
102
|
"lg",
|
|
103
103
|
"xl"
|
|
104
|
-
].includes(b), it = b !== void 0 && !rt && !
|
|
105
|
-
|
|
106
|
-
ot.current =
|
|
107
|
-
}, [
|
|
108
|
-
let st =
|
|
104
|
+
].includes(b), it = b !== void 0 && !rt && !y, F = rt && !y ? b : void 0, at = F ? f[`width${F.charAt(0).toUpperCase()}${F.slice(1)}`] : void 0, I = p.useRef(d ?? pe), ot = p.useRef(g);
|
|
105
|
+
p.useEffect(() => {
|
|
106
|
+
ot.current = g;
|
|
107
|
+
}, [g]);
|
|
108
|
+
let st = p.useMemo(() => {
|
|
109
109
|
let e = {
|
|
110
110
|
id: A,
|
|
111
|
-
class:
|
|
111
|
+
class: f.content,
|
|
112
112
|
role: "textbox",
|
|
113
113
|
"aria-multiline": "true",
|
|
114
114
|
style: `min-height: ${typeof x == "number" ? `${x}px` : x}`,
|
|
115
115
|
tabindex: N ? "-1" : "0"
|
|
116
116
|
}, t = je ?? (S || E ? void 0 : O("a11y.rte_editor")), n = E ?? (S ? M : void 0);
|
|
117
|
-
return t && (e["aria-label"] = t), n && (e["aria-labelledby"] = n), P === "danger" && (e["aria-invalid"] = "true"), j && (e["aria-describedby"] = j), w && (e["aria-required"] = "true"), N && (e["aria-disabled"] = "true"),
|
|
117
|
+
return t && (e["aria-label"] = t), n && (e["aria-labelledby"] = n), P === "danger" && (e["aria-invalid"] = "true"), j && (e["aria-describedby"] = j), w && (e["aria-required"] = "true"), N && (e["aria-disabled"] = "true"), _ && (e["aria-placeholder"] = _), e;
|
|
118
118
|
}, [
|
|
119
119
|
A,
|
|
120
120
|
x,
|
|
@@ -126,17 +126,17 @@ var y = ({ value: d, defaultValue: f = "", onChange: _, placeholder: v, disabled
|
|
|
126
126
|
P,
|
|
127
127
|
j,
|
|
128
128
|
w,
|
|
129
|
-
|
|
129
|
+
_,
|
|
130
130
|
O
|
|
131
|
-
]), L =
|
|
132
|
-
|
|
131
|
+
]), L = p.useRef(D);
|
|
132
|
+
p.useEffect(() => {
|
|
133
133
|
L.current = D;
|
|
134
134
|
}, [D]);
|
|
135
|
-
let [ct, lt] =
|
|
136
|
-
|
|
135
|
+
let [ct, lt] = p.useState(void 0), ut = p.useRef(k);
|
|
136
|
+
p.useEffect(() => {
|
|
137
137
|
ut.current = k;
|
|
138
138
|
}, [k]);
|
|
139
|
-
let R =
|
|
139
|
+
let R = p.useCallback(async (e, t, n) => {
|
|
140
140
|
let r = L.current;
|
|
141
141
|
if (r) {
|
|
142
142
|
lt(void 0);
|
|
@@ -153,10 +153,10 @@ var y = ({ value: d, defaultValue: f = "", onChange: _, placeholder: v, disabled
|
|
|
153
153
|
lt(ut.current);
|
|
154
154
|
}
|
|
155
155
|
}
|
|
156
|
-
}, []), dt = (e) => Array.from(e ?? []).filter((e) => e.type.startsWith("image/")), z =
|
|
156
|
+
}, []), dt = (e) => Array.from(e ?? []).filter((e) => e.type.startsWith("image/")), z = p.useRef({ ed: null }), ft = p.useCallback((e, t) => {
|
|
157
157
|
let n = dt(t.clipboardData?.files), r = z.current.ed;
|
|
158
158
|
return !L.current || n.length === 0 || !r ? !1 : (t.preventDefault(), R(r, n), !0);
|
|
159
|
-
}, [R]), pt =
|
|
159
|
+
}, [R]), pt = p.useCallback((e, t, n, r) => {
|
|
160
160
|
let i = dt(t.dataTransfer?.files), a = z.current.ed;
|
|
161
161
|
if (r || !L.current || i.length === 0 || !a) return !1;
|
|
162
162
|
t.preventDefault();
|
|
@@ -165,7 +165,7 @@ var y = ({ value: d, defaultValue: f = "", onChange: _, placeholder: v, disabled
|
|
|
165
165
|
top: t.clientY
|
|
166
166
|
});
|
|
167
167
|
return R(a, i, o?.pos), !0;
|
|
168
|
-
}, [R]), B =
|
|
168
|
+
}, [R]), B = p.useMemo(() => ({
|
|
169
169
|
attributes: st,
|
|
170
170
|
handlePaste: ft,
|
|
171
171
|
handleDrop: pt
|
|
@@ -173,38 +173,38 @@ var y = ({ value: d, defaultValue: f = "", onChange: _, placeholder: v, disabled
|
|
|
173
173
|
st,
|
|
174
174
|
ft,
|
|
175
175
|
pt
|
|
176
|
-
]), [V] =
|
|
177
|
-
extensions:
|
|
176
|
+
]), [V] = p.useState(Me), mt = d ?? pe, H = _e({
|
|
177
|
+
extensions: Ce(_ ?? "", V, V === "markdown" ? mt : void 0),
|
|
178
178
|
content: V === "markdown" ? "" : mt,
|
|
179
179
|
editable: !N,
|
|
180
180
|
immediatelyRender: !1,
|
|
181
181
|
editorProps: B,
|
|
182
182
|
onUpdate: ({ editor: e }) => {
|
|
183
|
-
let t =
|
|
183
|
+
let t = we(e, V);
|
|
184
184
|
t !== I.current && (I.current = t, ot.current?.(t));
|
|
185
185
|
}
|
|
186
186
|
});
|
|
187
|
-
|
|
187
|
+
p.useEffect(() => {
|
|
188
188
|
H && !H.isDestroyed && H.setOptions({ editorProps: B });
|
|
189
|
-
}, [H, B]),
|
|
189
|
+
}, [H, B]), p.useEffect(() => {
|
|
190
190
|
z.current.ed = H;
|
|
191
|
-
}, [H]),
|
|
191
|
+
}, [H]), p.useEffect(() => {
|
|
192
192
|
H && !H.isDestroyed && H.setEditable(!N, !1);
|
|
193
|
-
}, [H, N]),
|
|
193
|
+
}, [H, N]), p.useEffect(() => {
|
|
194
194
|
if (!H || H.isDestroyed) return;
|
|
195
195
|
let e = H.extensionManager.extensions.find((e) => e.name === "placeholder");
|
|
196
|
-
e && e.options.placeholder !== (
|
|
197
|
-
}, [H,
|
|
198
|
-
if (!H || H.isDestroyed || d === void 0 || d === I.current || d ===
|
|
196
|
+
e && e.options.placeholder !== (_ ?? "") && (e.options.placeholder = _ ?? "", H.view.dispatch(H.state.tr));
|
|
197
|
+
}, [H, _]), p.useEffect(() => {
|
|
198
|
+
if (!H || H.isDestroyed || d === void 0 || d === I.current || d === we(H, V)) return;
|
|
199
199
|
I.current = d;
|
|
200
|
-
let e =
|
|
200
|
+
let e = ye(Te(H, d, V), H.schema);
|
|
201
201
|
e.eq(H.state.doc) || H.commands.setContent(e.toJSON(), { emitUpdate: !1 });
|
|
202
202
|
}, [
|
|
203
203
|
H,
|
|
204
204
|
d,
|
|
205
205
|
V
|
|
206
206
|
]);
|
|
207
|
-
let ht =
|
|
207
|
+
let ht = ve({
|
|
208
208
|
editor: H,
|
|
209
209
|
selector: ({ editor: e }) => ({
|
|
210
210
|
bold: !!e?.isActive("bold"),
|
|
@@ -218,13 +218,13 @@ var y = ({ value: d, defaultValue: f = "", onChange: _, placeholder: v, disabled
|
|
|
218
218
|
ol: !!e?.isActive("orderedList"),
|
|
219
219
|
image: !!e?.isActive("image")
|
|
220
220
|
})
|
|
221
|
-
}), U =
|
|
221
|
+
}), U = p.useCallback((e) => {
|
|
222
222
|
if (N || !H) return;
|
|
223
223
|
let t = document.activeElement;
|
|
224
224
|
e(H), t instanceof HTMLElement && t.closest("[role=\"toolbar\"]") && requestAnimationFrame(() => {
|
|
225
225
|
t.isConnected && document.activeElement !== t && t.focus({ preventScroll: !0 });
|
|
226
226
|
});
|
|
227
|
-
}, [H, N]), gt =
|
|
227
|
+
}, [H, N]), gt = p.useCallback(() => {
|
|
228
228
|
U((e) => {
|
|
229
229
|
let { from: t, to: n, empty: r } = e.state.selection, i = e.chain().focus();
|
|
230
230
|
r && i.selectAll(), i.unsetBold().unsetItalic().unsetStrike().clearNodes(), e.schema.marks.underline && i.unsetUnderline(), r && i.setTextSelection({
|
|
@@ -232,21 +232,13 @@ var y = ({ value: d, defaultValue: f = "", onChange: _, placeholder: v, disabled
|
|
|
232
232
|
to: n
|
|
233
233
|
}), i.run();
|
|
234
234
|
});
|
|
235
|
-
}, [U]), [_t, W] =
|
|
235
|
+
}, [U]), [_t, W] = p.useState(!1), [G, vt] = p.useState("https://"), [yt, K] = p.useState(void 0), bt = p.useCallback(() => {
|
|
236
236
|
if (N || !H) return;
|
|
237
237
|
let { from: e, to: t } = H.state.selection, n = H.state.doc.textBetween(e, t, " "), r = H.getAttributes("link").href;
|
|
238
238
|
vt(r ?? (n.startsWith("http") ? n : "https://")), K(void 0), W(!0);
|
|
239
|
-
}, [H, N]), xt =
|
|
239
|
+
}, [H, N]), xt = p.useCallback(() => {
|
|
240
240
|
let e = G.trim();
|
|
241
|
-
|
|
242
|
-
W(!1);
|
|
243
|
-
return;
|
|
244
|
-
}
|
|
245
|
-
if (!fe(e)) {
|
|
246
|
-
K(Ye);
|
|
247
|
-
return;
|
|
248
|
-
}
|
|
249
|
-
W(!1), U((t) => {
|
|
241
|
+
e ? fe(e) ? (W(!1), U((t) => {
|
|
250
242
|
t.state.selection.empty && !t.isActive("link") ? t.chain().focus().insertContent({
|
|
251
243
|
type: "text",
|
|
252
244
|
text: e,
|
|
@@ -255,35 +247,27 @@ var y = ({ value: d, defaultValue: f = "", onChange: _, placeholder: v, disabled
|
|
|
255
247
|
attrs: { href: e }
|
|
256
248
|
}]
|
|
257
249
|
}).run() : t.chain().focus().extendMarkRange("link").setLink({ href: e }).run();
|
|
258
|
-
});
|
|
250
|
+
})) : K(Ye) : W(!1);
|
|
259
251
|
}, [
|
|
260
252
|
G,
|
|
261
253
|
Ye,
|
|
262
254
|
U
|
|
263
|
-
]), [St, q] =
|
|
255
|
+
]), [St, q] = p.useState(!1), [J, Y] = p.useState(""), [X, Ct] = p.useState(""), [wt, Z] = p.useState(void 0), [Tt, Et] = p.useState(!1), Dt = p.useRef(null), Ot = `${A}-image-alt-hint`, kt = p.useCallback(() => {
|
|
264
256
|
if (N || !H) return;
|
|
265
257
|
let e = H.isActive("image") ? H.getAttributes("image") : {};
|
|
266
258
|
Y(e.src ?? ""), Ct(e.alt ?? ""), Z(void 0), q(!0);
|
|
267
|
-
}, [H, N]), At =
|
|
259
|
+
}, [H, N]), At = p.useCallback(() => {
|
|
268
260
|
let e = J.trim();
|
|
269
|
-
|
|
270
|
-
q(!1);
|
|
271
|
-
return;
|
|
272
|
-
}
|
|
273
|
-
if (!u(e)) {
|
|
274
|
-
Z(tt);
|
|
275
|
-
return;
|
|
276
|
-
}
|
|
277
|
-
q(!1), U((t) => t.chain().focus().setImage({
|
|
261
|
+
e ? u(e) ? (q(!1), U((t) => t.chain().focus().setImage({
|
|
278
262
|
src: e,
|
|
279
263
|
alt: X.trim()
|
|
280
|
-
}).run());
|
|
264
|
+
}).run())) : Z(tt) : q(!1);
|
|
281
265
|
}, [
|
|
282
266
|
J,
|
|
283
267
|
X,
|
|
284
268
|
tt,
|
|
285
269
|
U
|
|
286
|
-
]), jt =
|
|
270
|
+
]), jt = p.useCallback(async (e) => {
|
|
287
271
|
let t = e.target.files?.[0];
|
|
288
272
|
if (e.target.value = "", t && D) {
|
|
289
273
|
Et(!0), Z(void 0);
|
|
@@ -297,20 +281,20 @@ var y = ({ value: d, defaultValue: f = "", onChange: _, placeholder: v, disabled
|
|
|
297
281
|
Et(!1);
|
|
298
282
|
}
|
|
299
283
|
}
|
|
300
|
-
}, [D, k]), Mt =
|
|
284
|
+
}, [D, k]), Mt = p.useRef([]), [Q, Nt] = p.useState(0), $ = p.useMemo(() => {
|
|
301
285
|
let e = V === "markdown" ? T.filter((e) => e !== "underline") : T;
|
|
302
286
|
return e.filter((t, n) => t !== "separator" || n > 0 && n < e.length - 1 && e[n - 1] !== "separator");
|
|
303
|
-
}, [T, V]), Pt =
|
|
287
|
+
}, [T, V]), Pt = p.useMemo(() => $.filter((e) => e !== "separator"), [$]), Ft = p.useMemo(() => $.map((e, t) => e === "separator" ? -1 : $.slice(0, t).filter((e) => e !== "separator").length), [$]), It = p.useCallback((e) => {
|
|
304
288
|
let t = Pt.length;
|
|
305
289
|
if (t === 0) return;
|
|
306
290
|
let n;
|
|
307
291
|
e.key === "ArrowRight" ? n = (Q + 1) % t : e.key === "ArrowLeft" ? n = (Q - 1 + t) % t : e.key === "Home" ? n = 0 : e.key === "End" && (n = t - 1), n !== void 0 && (e.preventDefault(), Nt(n), Mt.current[n]?.focus());
|
|
308
|
-
}, [Pt.length, Q]), Lt =
|
|
292
|
+
}, [Pt.length, Q]), Lt = p.useCallback((e) => {
|
|
309
293
|
e.preventDefault();
|
|
310
294
|
}, []), Rt = {
|
|
311
295
|
bold: {
|
|
312
296
|
title: Ne,
|
|
313
|
-
icon: /* @__PURE__ */
|
|
297
|
+
icon: /* @__PURE__ */ m(s, {
|
|
314
298
|
component: n,
|
|
315
299
|
size: "sm"
|
|
316
300
|
}),
|
|
@@ -318,7 +302,7 @@ var y = ({ value: d, defaultValue: f = "", onChange: _, placeholder: v, disabled
|
|
|
318
302
|
},
|
|
319
303
|
italic: {
|
|
320
304
|
title: Pe,
|
|
321
|
-
icon: /* @__PURE__ */
|
|
305
|
+
icon: /* @__PURE__ */ m(s, {
|
|
322
306
|
component: a,
|
|
323
307
|
size: "sm"
|
|
324
308
|
}),
|
|
@@ -326,7 +310,7 @@ var y = ({ value: d, defaultValue: f = "", onChange: _, placeholder: v, disabled
|
|
|
326
310
|
},
|
|
327
311
|
underline: {
|
|
328
312
|
title: Fe,
|
|
329
|
-
icon: /* @__PURE__ */
|
|
313
|
+
icon: /* @__PURE__ */ m(s, {
|
|
330
314
|
component: re,
|
|
331
315
|
size: "sm"
|
|
332
316
|
}),
|
|
@@ -334,7 +318,7 @@ var y = ({ value: d, defaultValue: f = "", onChange: _, placeholder: v, disabled
|
|
|
334
318
|
},
|
|
335
319
|
strikethrough: {
|
|
336
320
|
title: Ie,
|
|
337
|
-
icon: /* @__PURE__ */
|
|
321
|
+
icon: /* @__PURE__ */ m(s, {
|
|
338
322
|
component: ne,
|
|
339
323
|
size: "sm"
|
|
340
324
|
}),
|
|
@@ -342,7 +326,8 @@ var y = ({ value: d, defaultValue: f = "", onChange: _, placeholder: v, disabled
|
|
|
342
326
|
},
|
|
343
327
|
h1: {
|
|
344
328
|
title: Le,
|
|
345
|
-
|
|
329
|
+
label: "H1",
|
|
330
|
+
icon: /* @__PURE__ */ m("span", {
|
|
346
331
|
"aria-hidden": "true",
|
|
347
332
|
children: "H1"
|
|
348
333
|
}),
|
|
@@ -350,7 +335,8 @@ var y = ({ value: d, defaultValue: f = "", onChange: _, placeholder: v, disabled
|
|
|
350
335
|
},
|
|
351
336
|
h2: {
|
|
352
337
|
title: Re,
|
|
353
|
-
|
|
338
|
+
label: "H2",
|
|
339
|
+
icon: /* @__PURE__ */ m("span", {
|
|
354
340
|
"aria-hidden": "true",
|
|
355
341
|
children: "H2"
|
|
356
342
|
}),
|
|
@@ -358,7 +344,8 @@ var y = ({ value: d, defaultValue: f = "", onChange: _, placeholder: v, disabled
|
|
|
358
344
|
},
|
|
359
345
|
h3: {
|
|
360
346
|
title: ze,
|
|
361
|
-
|
|
347
|
+
label: "H3",
|
|
348
|
+
icon: /* @__PURE__ */ m("span", {
|
|
362
349
|
"aria-hidden": "true",
|
|
363
350
|
children: "H3"
|
|
364
351
|
}),
|
|
@@ -366,7 +353,7 @@ var y = ({ value: d, defaultValue: f = "", onChange: _, placeholder: v, disabled
|
|
|
366
353
|
},
|
|
367
354
|
ul: {
|
|
368
355
|
title: Be,
|
|
369
|
-
icon: /* @__PURE__ */
|
|
356
|
+
icon: /* @__PURE__ */ m(s, {
|
|
370
357
|
component: te,
|
|
371
358
|
size: "sm"
|
|
372
359
|
}),
|
|
@@ -374,7 +361,7 @@ var y = ({ value: d, defaultValue: f = "", onChange: _, placeholder: v, disabled
|
|
|
374
361
|
},
|
|
375
362
|
ol: {
|
|
376
363
|
title: Ve,
|
|
377
|
-
icon: /* @__PURE__ */
|
|
364
|
+
icon: /* @__PURE__ */ m(s, {
|
|
378
365
|
component: ee,
|
|
379
366
|
size: "sm"
|
|
380
367
|
}),
|
|
@@ -382,7 +369,7 @@ var y = ({ value: d, defaultValue: f = "", onChange: _, placeholder: v, disabled
|
|
|
382
369
|
},
|
|
383
370
|
link: {
|
|
384
371
|
title: He,
|
|
385
|
-
icon: /* @__PURE__ */
|
|
372
|
+
icon: /* @__PURE__ */ m(s, {
|
|
386
373
|
component: o,
|
|
387
374
|
size: "sm"
|
|
388
375
|
}),
|
|
@@ -390,7 +377,7 @@ var y = ({ value: d, defaultValue: f = "", onChange: _, placeholder: v, disabled
|
|
|
390
377
|
},
|
|
391
378
|
unlink: {
|
|
392
379
|
title: Ue,
|
|
393
|
-
icon: /* @__PURE__ */
|
|
380
|
+
icon: /* @__PURE__ */ m(s, {
|
|
394
381
|
component: ie,
|
|
395
382
|
size: "sm"
|
|
396
383
|
}),
|
|
@@ -398,7 +385,7 @@ var y = ({ value: d, defaultValue: f = "", onChange: _, placeholder: v, disabled
|
|
|
398
385
|
},
|
|
399
386
|
image: {
|
|
400
387
|
title: Xe,
|
|
401
|
-
icon: /* @__PURE__ */
|
|
388
|
+
icon: /* @__PURE__ */ m(s, {
|
|
402
389
|
component: i,
|
|
403
390
|
size: "sm"
|
|
404
391
|
}),
|
|
@@ -406,14 +393,14 @@ var y = ({ value: d, defaultValue: f = "", onChange: _, placeholder: v, disabled
|
|
|
406
393
|
},
|
|
407
394
|
removeFormat: {
|
|
408
395
|
title: We,
|
|
409
|
-
icon: /* @__PURE__ */
|
|
396
|
+
icon: /* @__PURE__ */ m(s, {
|
|
410
397
|
component: r,
|
|
411
398
|
size: "sm"
|
|
412
399
|
}),
|
|
413
400
|
onClick: gt
|
|
414
401
|
}
|
|
415
402
|
};
|
|
416
|
-
return /* @__PURE__ */
|
|
403
|
+
return /* @__PURE__ */ m(ae, {
|
|
417
404
|
label: S,
|
|
418
405
|
error: C,
|
|
419
406
|
required: w,
|
|
@@ -421,24 +408,24 @@ var y = ({ value: d, defaultValue: f = "", onChange: _, placeholder: v, disabled
|
|
|
421
408
|
labelId: M,
|
|
422
409
|
errorId: j,
|
|
423
410
|
className: Oe,
|
|
424
|
-
children: /* @__PURE__ */
|
|
425
|
-
className:
|
|
411
|
+
children: /* @__PURE__ */ h("div", {
|
|
412
|
+
className: me("wim-rich-text-editor", f.root, f[P], N && f.disabled, f[v], y && f.fullWidth, it && f.hasCustomWidth, at),
|
|
426
413
|
style: it ? { "--wim-input-width": typeof b == "number" ? `${b}px` : b } : void 0,
|
|
427
414
|
children: [
|
|
428
|
-
/* @__PURE__ */
|
|
429
|
-
className:
|
|
415
|
+
/* @__PURE__ */ m("div", {
|
|
416
|
+
className: f.toolbar,
|
|
430
417
|
role: "toolbar",
|
|
431
418
|
"aria-label": Ge,
|
|
432
419
|
"aria-controls": A,
|
|
433
420
|
onMouseDown: Lt,
|
|
434
421
|
onKeyDown: It,
|
|
435
422
|
children: $.map((e, t) => {
|
|
436
|
-
if (e === "separator") return /* @__PURE__ */
|
|
437
|
-
className:
|
|
423
|
+
if (e === "separator") return /* @__PURE__ */ m("span", {
|
|
424
|
+
className: f.toolbarSep,
|
|
438
425
|
"aria-hidden": "true"
|
|
439
426
|
}, `sep-${t}`);
|
|
440
427
|
let n = Ft[t], r = Rt[e], i = e === "link" || e === "unlink" || e === "removeFormat" ? void 0 : ht?.[e] ?? !1;
|
|
441
|
-
return /* @__PURE__ */
|
|
428
|
+
return /* @__PURE__ */ m(Ee, {
|
|
442
429
|
buttonRef: (e) => {
|
|
443
430
|
Mt.current[n] = e;
|
|
444
431
|
},
|
|
@@ -447,28 +434,29 @@ var y = ({ value: d, defaultValue: f = "", onChange: _, placeholder: v, disabled
|
|
|
447
434
|
disabled: N,
|
|
448
435
|
active: i,
|
|
449
436
|
title: r.title,
|
|
437
|
+
label: r.label,
|
|
450
438
|
onClick: r.onClick,
|
|
451
439
|
children: r.icon
|
|
452
440
|
}, `${e}-${t}`);
|
|
453
441
|
})
|
|
454
442
|
}),
|
|
455
|
-
/* @__PURE__ */
|
|
443
|
+
/* @__PURE__ */ m(ge, {
|
|
456
444
|
editor: H,
|
|
457
|
-
className:
|
|
445
|
+
className: f.contentHost
|
|
458
446
|
}),
|
|
459
|
-
ct && /* @__PURE__ */
|
|
447
|
+
ct && /* @__PURE__ */ m("p", {
|
|
460
448
|
role: "alert",
|
|
461
|
-
className:
|
|
449
|
+
className: f.uploadError,
|
|
462
450
|
children: ct
|
|
463
451
|
}),
|
|
464
|
-
/* @__PURE__ */
|
|
452
|
+
/* @__PURE__ */ m(oe, {
|
|
465
453
|
open: _t,
|
|
466
454
|
onOpenChange: W,
|
|
467
|
-
children: /* @__PURE__ */
|
|
455
|
+
children: /* @__PURE__ */ h(ce, { children: [/* @__PURE__ */ m(ue, { children: /* @__PURE__ */ m(de, { children: He }) }), /* @__PURE__ */ h("form", {
|
|
468
456
|
onSubmit: (e) => {
|
|
469
457
|
e.preventDefault(), xt();
|
|
470
458
|
},
|
|
471
|
-
children: [/* @__PURE__ */
|
|
459
|
+
children: [/* @__PURE__ */ m(l, {
|
|
472
460
|
label: Ke,
|
|
473
461
|
type: "url",
|
|
474
462
|
value: G,
|
|
@@ -477,30 +465,30 @@ var y = ({ value: d, defaultValue: f = "", onChange: _, placeholder: v, disabled
|
|
|
477
465
|
vt(e.target.value), K(void 0);
|
|
478
466
|
},
|
|
479
467
|
fullWidth: !0
|
|
480
|
-
}), /* @__PURE__ */
|
|
468
|
+
}), /* @__PURE__ */ h(le, { children: [/* @__PURE__ */ m(se, {
|
|
481
469
|
asChild: !0,
|
|
482
|
-
children: /* @__PURE__ */
|
|
470
|
+
children: /* @__PURE__ */ m(c, {
|
|
483
471
|
variant: "ghost",
|
|
484
472
|
type: "button",
|
|
485
473
|
children: Je
|
|
486
474
|
})
|
|
487
|
-
}), /* @__PURE__ */
|
|
475
|
+
}), /* @__PURE__ */ m(c, {
|
|
488
476
|
variant: "solid",
|
|
489
477
|
type: "submit",
|
|
490
478
|
children: qe
|
|
491
479
|
})] })]
|
|
492
480
|
})] })
|
|
493
481
|
}),
|
|
494
|
-
/* @__PURE__ */
|
|
482
|
+
/* @__PURE__ */ m(oe, {
|
|
495
483
|
open: St,
|
|
496
484
|
onOpenChange: q,
|
|
497
|
-
children: /* @__PURE__ */
|
|
498
|
-
className:
|
|
485
|
+
children: /* @__PURE__ */ h(ce, { children: [/* @__PURE__ */ m(ue, { children: /* @__PURE__ */ m(de, { children: Xe }) }), /* @__PURE__ */ h("form", {
|
|
486
|
+
className: f.imageForm,
|
|
499
487
|
onSubmit: (e) => {
|
|
500
488
|
e.preventDefault(), At();
|
|
501
489
|
},
|
|
502
490
|
children: [
|
|
503
|
-
/* @__PURE__ */
|
|
491
|
+
/* @__PURE__ */ m(l, {
|
|
504
492
|
label: Ze,
|
|
505
493
|
type: "url",
|
|
506
494
|
value: J,
|
|
@@ -510,38 +498,38 @@ var y = ({ value: d, defaultValue: f = "", onChange: _, placeholder: v, disabled
|
|
|
510
498
|
},
|
|
511
499
|
fullWidth: !0
|
|
512
500
|
}),
|
|
513
|
-
D && /* @__PURE__ */
|
|
501
|
+
D && /* @__PURE__ */ h(he, { children: [/* @__PURE__ */ m("input", {
|
|
514
502
|
ref: Dt,
|
|
515
503
|
type: "file",
|
|
516
504
|
accept: "image/*",
|
|
517
505
|
hidden: !0,
|
|
518
506
|
onChange: jt
|
|
519
|
-
}), /* @__PURE__ */
|
|
507
|
+
}), /* @__PURE__ */ m(c, {
|
|
520
508
|
type: "button",
|
|
521
509
|
variant: "outline",
|
|
522
510
|
loading: Tt,
|
|
523
511
|
onClick: () => Dt.current?.click(),
|
|
524
512
|
children: et
|
|
525
513
|
})] }),
|
|
526
|
-
/* @__PURE__ */
|
|
514
|
+
/* @__PURE__ */ h("div", { children: [/* @__PURE__ */ m(l, {
|
|
527
515
|
label: Qe,
|
|
528
516
|
"aria-describedby": Ot,
|
|
529
517
|
value: X,
|
|
530
518
|
onChange: (e) => Ct(e.target.value),
|
|
531
519
|
fullWidth: !0
|
|
532
|
-
}), /* @__PURE__ */
|
|
520
|
+
}), /* @__PURE__ */ m("p", {
|
|
533
521
|
id: Ot,
|
|
534
|
-
className:
|
|
522
|
+
className: f.imageHint,
|
|
535
523
|
children: $e
|
|
536
524
|
})] }),
|
|
537
|
-
/* @__PURE__ */
|
|
525
|
+
/* @__PURE__ */ h(le, { children: [/* @__PURE__ */ m(se, {
|
|
538
526
|
asChild: !0,
|
|
539
|
-
children: /* @__PURE__ */
|
|
527
|
+
children: /* @__PURE__ */ m(c, {
|
|
540
528
|
variant: "ghost",
|
|
541
529
|
type: "button",
|
|
542
530
|
children: Je
|
|
543
531
|
})
|
|
544
|
-
}), /* @__PURE__ */
|
|
532
|
+
}), /* @__PURE__ */ m(c, {
|
|
545
533
|
variant: "solid",
|
|
546
534
|
type: "submit",
|
|
547
535
|
disabled: Tt,
|
|
@@ -554,6 +542,6 @@ var y = ({ value: d, defaultValue: f = "", onChange: _, placeholder: v, disabled
|
|
|
554
542
|
})
|
|
555
543
|
});
|
|
556
544
|
};
|
|
557
|
-
|
|
545
|
+
v.displayName = "RichTextEditor";
|
|
558
546
|
//#endregion
|
|
559
|
-
export {
|
|
547
|
+
export { v as RichTextEditor };
|
|
@@ -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("../../../hooks/useMergedRef.cjs"),r=require("../../media/Icon/Icon.cjs"),i=require("../FieldTemplate/FieldTemplate.cjs"),a=require("../../_internal/useIndicator.cjs"),o=require("./segmented-control.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=(0,s.forwardRef)(({options:e,value:u,onChange:d,size:f=`md`,fullWidth:p=!1,className:m,label:h,error:g,required:_,layout:v=`vertical`,disabled:y=!1,asChild:b=!1,children:x,id:S,styles:C,"aria-label":w,"aria-labelledby":T,"aria-describedby":E},D)=>{let O=(0,s.useRef)([]),k=(0,s.useId)(),A=S||`wim-segmented-${k}`,j=`${A}-label`,M=`${A}-error`,{containerRef:N,sliderStyle:P,isReady:F}=a.useIndicator({activeSelector:`.${o.default.active}`,dependence:e.length}),I=e.findIndex(e=>e.value===u),L=(t,n)=>{let r;switch(t.key){case`ArrowLeft`:case`ArrowUp`:r=n-1,r<0&&(r=e.length-1);break;case`ArrowRight`:case`ArrowDown`:r=n+1,r>=e.length&&(r=0);break;case`Home`:r=0;break;case`End`:r=e.length-1;break;default:return}t.preventDefault(),d(e[r].value),O.current[r]?.focus()},R=`${A}-item-0`;return(0,l.jsx)(i.FieldTemplate,{label:h,error:g,required:_,layout:v,labelId:j,htmlFor:R,errorId:M,className:m,children:(0,l.jsxs)(b?t.Root:`div`,{ref:n.useMergedRef(N,D),id:A,className:(0,c.default)(`wim-segmented-control`,o.default.root,o.default[f],p&&o.default.fullWidth,F&&o.default.ready,g&&o.default.danger,C?.root),role:`radiogroup`,"aria-labelledby":h?j:T,"aria-label":h||T?void 0:w,"aria-required":_,"aria-invalid":g?!0:void 0,"aria-describedby":[E,g?M:void 0].filter(Boolean).join(` `)||void 0,children:[(0,l.jsx)(`div`,{className:(0,c.default)(o.default.slider,C?.slider),style:P,"aria-hidden":`true`}),e.map((e,t)=>{let n=e.value===u,i=n||I===-1&&t===0,a=`${A}-item-${t}`;return(0,l.jsxs)(`button`,{id:a,ref:e=>{O.current[t]=e},type:`button`,className:(0,c.default)(o.default.item,n&&o.default.active,!e.label&&e.iconName&&o.default.iconOnly,C?.item),onClick:()=>d(e.value),onKeyDown:e=>L(e,t),onFocus:()=>{},onBlur:()=>{},role:`radio`,"aria-checked":n,tabIndex:i?0:-1,"aria-label":e.label
|
|
2
|
+
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../node_modules/@radix-ui/react-slot/dist/index.cjs"),n=require("../../../hooks/useMergedRef.cjs"),r=require("../../media/Icon/Icon.cjs"),i=require("../FieldTemplate/FieldTemplate.cjs"),a=require("../../_internal/useIndicator.cjs"),o=require("./segmented-control.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=(0,s.forwardRef)(({options:e,value:u,onChange:d,size:f=`md`,fullWidth:p=!1,className:m,label:h,error:g,required:_,layout:v=`vertical`,disabled:y=!1,asChild:b=!1,children:x,id:S,styles:C,"aria-label":w,"aria-labelledby":T,"aria-describedby":E},D)=>{let O=(0,s.useRef)([]),k=(0,s.useId)(),A=S||`wim-segmented-${k}`,j=`${A}-label`,M=`${A}-error`,{containerRef:N,sliderStyle:P,isReady:F}=a.useIndicator({activeSelector:`.${o.default.active}`,dependence:e.length}),I=e.findIndex(e=>e.value===u),L=(t,n)=>{let r;switch(t.key){case`ArrowLeft`:case`ArrowUp`:r=n-1,r<0&&(r=e.length-1);break;case`ArrowRight`:case`ArrowDown`:r=n+1,r>=e.length&&(r=0);break;case`Home`:r=0;break;case`End`:r=e.length-1;break;default:return}t.preventDefault(),d(e[r].value),O.current[r]?.focus()},R=`${A}-item-0`;return(0,l.jsx)(i.FieldTemplate,{label:h,error:g,required:_,layout:v,labelId:j,htmlFor:R,errorId:M,className:m,children:(0,l.jsxs)(b?t.Root:`div`,{ref:n.useMergedRef(N,D),id:A,className:(0,c.default)(`wim-segmented-control`,o.default.root,o.default[f],p&&o.default.fullWidth,F&&o.default.ready,g&&o.default.danger,C?.root),role:`radiogroup`,"aria-labelledby":h?j:T,"aria-label":h||T?void 0:w,"aria-required":_,"aria-invalid":g?!0:void 0,"aria-describedby":[E,g?M:void 0].filter(Boolean).join(` `)||void 0,children:[(0,l.jsx)(`div`,{className:(0,c.default)(o.default.slider,C?.slider),style:P,"aria-hidden":`true`}),e.map((e,t)=>{let n=e.value===u,i=n||I===-1&&t===0,a=`${A}-item-${t}`;return(0,l.jsxs)(`button`,{id:a,ref:e=>{O.current[t]=e},type:`button`,className:(0,c.default)(o.default.item,n&&o.default.active,!e.label&&e.iconName&&o.default.iconOnly,C?.item),onClick:()=>d(e.value),onKeyDown:e=>L(e,t),onFocus:()=>{},onBlur:()=>{},role:`radio`,"aria-checked":n,tabIndex:i?0:-1,"aria-label":e.label?void 0:e.value,disabled:y,children:[e.iconName&&(0,l.jsx)(r.Icon,{name:e.iconName,size:f,className:o.default.icon}),e.label&&(0,l.jsx)(`span`,{className:(0,c.default)(o.default.label,C?.label),children:e.label})]},e.value)}),(0,l.jsx)(t.Slottable,{children:x})]})})});u.displayName=`SegmentedControl`,exports.SegmentedControl=u;
|
|
@@ -75,7 +75,7 @@ var p = s(({ options: s, value: p, onChange: m, size: h = "md", fullWidth: g = !
|
|
|
75
75
|
role: "radio",
|
|
76
76
|
"aria-checked": n,
|
|
77
77
|
tabIndex: i ? 0 : -1,
|
|
78
|
-
"aria-label": e.label
|
|
78
|
+
"aria-label": e.label ? void 0 : e.value,
|
|
79
79
|
disabled: S,
|
|
80
80
|
children: [e.iconName && /* @__PURE__ */ d(r, {
|
|
81
81
|
name: e.iconName,
|
|
@@ -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("../../../hooks/useMergedRef.cjs"),r=require("../../media/Icon/Icon.cjs"),i=require("../FieldTemplate/FieldTemplate.cjs"),a=require("../../_internal/useIndicator.cjs"),o=require("./toggle-group.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=(0,s.forwardRef)(({options:e,value:u,defaultValue:d,onChange:f,selectionMode:p=`single`,size:m=`md`,fullWidth:h=!1,className:g,"aria-label":_,"aria-labelledby":v,"aria-describedby":y,disabled:b=!1,label:x,error:S,required:C,layout:w=`vertical`,id:T,asChild:E=!1,children:D},O)=>{let k=s.default.useId(),A=T||`wim-toggle-group-${k}`,j=`${A}-label`,M=`${A}-error`,N=u!==void 0,[P,F]=(0,s.useState)(d??(p===`multiple`?[]:``)),I=N?u:P,{containerRef:L,sliderStyle:R,isReady:z}=a.useIndicator({activeSelector:`.${o.default.active}`,dependence:e.length}),B=(0,s.useRef)([]),V=e.findIndex(e=>!e.disabled),[H,U]=(0,s.useState)(()=>{if(p===`single`){let t=N?u:d;if(typeof t==`string`){let n=e.findIndex(e=>!e.disabled&&e.value===t);if(n>=0)return n}}return V>=0?V:0});(0,s.useEffect)(()=>{if(p===`single`&&N&&typeof u==`string`){let t=e.findIndex(e=>!e.disabled&&e.value===u);t>=0&&U(t)}},[u,p,N,e]);let W=e=>{let t;if(p===`multiple`){let n=Array.isArray(I)?I:[];t=n.includes(e)?n.filter(t=>t!==e):[...n,e]}else t=I===e?``:e;N||F(t),f?.(t)},G=e=>p===`multiple`?(Array.isArray(I)?I:[]).includes(e):I===e,K=(t,n)=>{for(let r=1;r<=e.length;r++){let i=(t+n*r+e.length)%e.length;if(!e[i].disabled)return i}return t},q=(t,n)=>{let r=null;if(n.key===`ArrowRight`||n.key===`ArrowDown`)n.preventDefault(),r=K(t,1);else if(n.key===`ArrowLeft`||n.key===`ArrowUp`)n.preventDefault(),r=K(t,-1);else if(n.key===`Home`)n.preventDefault(),r=V>=0?V:null;else if(n.key===`End`){n.preventDefault();for(let t=e.length-1;t>=0;t--)if(!e[t].disabled){r=t;break}}r!==null&&r!==t&&(U(r),B.current[r]?.focus(),p===`single`&&W(e[r].value))},J=p===`single`?`radiogroup`:`toolbar`,Y=`${A}-item-0`;return(0,l.jsx)(i.FieldTemplate,{label:x,error:S,required:C,layout:w,labelId:j,htmlFor:Y,errorId:M,className:g,children:(0,l.jsxs)(E?t.Root:`div`,{ref:n.useMergedRef(L,O),id:A,className:(0,c.default)(`wim-toggle-group`,o.default.root,o.default[m],o.default[p],h&&o.default.fullWidth,z&&o.default.ready,S&&o.default.danger),role:J,"aria-label":_,"aria-labelledby":x?j:v,"aria-orientation":`horizontal`,"aria-invalid":S?!0:void 0,"aria-describedby":[y,S?M:void 0].filter(Boolean).join(` `)||void 0,children:[(0,l.jsx)(`div`,{className:(0,c.default)(o.default.slider,o.default[p],z&&o.default.ready),style:R,"aria-hidden":`true`}),e.map((e,t)=>{let n=`${A}-item-${t}`;return(0,l.jsxs)(`button`,{id:n,ref:e=>{B.current[t]=e},type:`button`,className:(0,c.default)(o.default.item,o.default[p],G(e.value)&&o.default.active,!e.label&&e.iconName&&o.default.iconOnly),onClick:()=>{U(t),W(e.value)},onKeyDown:e=>q(t,e),disabled:b||e.disabled,role:p===`single`?`radio`:`button`,"aria-checked":p===`single`?G(e.value):void 0,"aria-pressed":p===`multiple`?G(e.value):void 0,"aria-label":e.label
|
|
2
|
+
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../node_modules/@radix-ui/react-slot/dist/index.cjs"),n=require("../../../hooks/useMergedRef.cjs"),r=require("../../media/Icon/Icon.cjs"),i=require("../FieldTemplate/FieldTemplate.cjs"),a=require("../../_internal/useIndicator.cjs"),o=require("./toggle-group.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=(0,s.forwardRef)(({options:e,value:u,defaultValue:d,onChange:f,selectionMode:p=`single`,size:m=`md`,fullWidth:h=!1,className:g,"aria-label":_,"aria-labelledby":v,"aria-describedby":y,disabled:b=!1,label:x,error:S,required:C,layout:w=`vertical`,id:T,asChild:E=!1,children:D},O)=>{let k=s.default.useId(),A=T||`wim-toggle-group-${k}`,j=`${A}-label`,M=`${A}-error`,N=u!==void 0,[P,F]=(0,s.useState)(d??(p===`multiple`?[]:``)),I=N?u:P,{containerRef:L,sliderStyle:R,isReady:z}=a.useIndicator({activeSelector:`.${o.default.active}`,dependence:e.length}),B=(0,s.useRef)([]),V=e.findIndex(e=>!e.disabled),[H,U]=(0,s.useState)(()=>{if(p===`single`){let t=N?u:d;if(typeof t==`string`){let n=e.findIndex(e=>!e.disabled&&e.value===t);if(n>=0)return n}}return V>=0?V:0});(0,s.useEffect)(()=>{if(p===`single`&&N&&typeof u==`string`){let t=e.findIndex(e=>!e.disabled&&e.value===u);t>=0&&U(t)}},[u,p,N,e]);let W=e=>{let t;if(p===`multiple`){let n=Array.isArray(I)?I:[];t=n.includes(e)?n.filter(t=>t!==e):[...n,e]}else t=I===e?``:e;N||F(t),f?.(t)},G=e=>p===`multiple`?(Array.isArray(I)?I:[]).includes(e):I===e,K=(t,n)=>{for(let r=1;r<=e.length;r++){let i=(t+n*r+e.length)%e.length;if(!e[i].disabled)return i}return t},q=(t,n)=>{let r=null;if(n.key===`ArrowRight`||n.key===`ArrowDown`)n.preventDefault(),r=K(t,1);else if(n.key===`ArrowLeft`||n.key===`ArrowUp`)n.preventDefault(),r=K(t,-1);else if(n.key===`Home`)n.preventDefault(),r=V>=0?V:null;else if(n.key===`End`){n.preventDefault();for(let t=e.length-1;t>=0;t--)if(!e[t].disabled){r=t;break}}r!==null&&r!==t&&(U(r),B.current[r]?.focus(),p===`single`&&W(e[r].value))},J=p===`single`?`radiogroup`:`toolbar`,Y=`${A}-item-0`;return(0,l.jsx)(i.FieldTemplate,{label:x,error:S,required:C,layout:w,labelId:j,htmlFor:Y,errorId:M,className:g,children:(0,l.jsxs)(E?t.Root:`div`,{ref:n.useMergedRef(L,O),id:A,className:(0,c.default)(`wim-toggle-group`,o.default.root,o.default[m],o.default[p],h&&o.default.fullWidth,z&&o.default.ready,S&&o.default.danger),role:J,"aria-label":_,"aria-labelledby":x?j:v,"aria-orientation":`horizontal`,"aria-invalid":S?!0:void 0,"aria-describedby":[y,S?M:void 0].filter(Boolean).join(` `)||void 0,children:[(0,l.jsx)(`div`,{className:(0,c.default)(o.default.slider,o.default[p],z&&o.default.ready),style:R,"aria-hidden":`true`}),e.map((e,t)=>{let n=`${A}-item-${t}`;return(0,l.jsxs)(`button`,{id:n,ref:e=>{B.current[t]=e},type:`button`,className:(0,c.default)(o.default.item,o.default[p],G(e.value)&&o.default.active,!e.label&&e.iconName&&o.default.iconOnly),onClick:()=>{U(t),W(e.value)},onKeyDown:e=>q(t,e),disabled:b||e.disabled,role:p===`single`?`radio`:`button`,"aria-checked":p===`single`?G(e.value):void 0,"aria-pressed":p===`multiple`?G(e.value):void 0,"aria-label":e.label?void 0:e.value,tabIndex:!e.disabled&&t===H?0:-1,children:[e.iconName&&(0,l.jsx)(r.Icon,{name:e.iconName,size:m,className:o.default.icon}),e.label&&(0,l.jsx)(`span`,{children:e.label})]},e.value)}),(0,l.jsx)(t.Slottable,{children:D})]})})});u.displayName=`ToggleGroup`,exports.ToggleGroup=u;
|
|
@@ -103,7 +103,7 @@ var h = c(({ options: c, value: h, defaultValue: g, onChange: _, selectionMode:
|
|
|
103
103
|
role: v === "single" ? "radio" : "button",
|
|
104
104
|
"aria-checked": v === "single" ? X(e.value) : void 0,
|
|
105
105
|
"aria-pressed": v === "multiple" ? X(e.value) : void 0,
|
|
106
|
-
"aria-label": e.label
|
|
106
|
+
"aria-label": e.label ? void 0 : e.value,
|
|
107
107
|
tabIndex: !e.disabled && t === q ? 0 : -1,
|
|
108
108
|
children: [e.iconName && /* @__PURE__ */ p(r, {
|
|
109
109
|
name: e.iconName,
|