wimui 0.64.0 → 0.64.2
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/feedback/Snackbar/Snackbar.cjs +1 -1
- package/dist/components/feedback/Snackbar/Snackbar.d.ts +1 -1
- package/dist/components/feedback/Snackbar/Snackbar.js +81 -79
- package/dist/components/feedback/Toast/Toast.cjs +1 -1
- package/dist/components/feedback/Toast/Toast.js +85 -66
- package/dist/components/feedback/Toast/toast.module.cjs +1 -1
- package/dist/components/feedback/Toast/toast.module.js +27 -26
- package/dist/components/form/RichTextEditor/RichTextEditor.cjs +1 -1
- package/dist/components/form/RichTextEditor/RichTextEditor.js +5 -1
- package/dist/llms-full.txt +1 -1
- package/dist/llms.txt +1 -1
- package/dist/styles.css +1 -1
- package/dist/wimui.umd.css +1 -1
- package/dist/wimui.umd.js +5 -5
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../form/Button/Button.cjs"),
|
|
2
|
+
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../layout/VisuallyHidden/VisuallyHidden.cjs"),n=require("../../form/Button/Button.cjs"),r=require("../../_internal/FeedbackIcon.cjs"),i=require("../../_internal/FeedbackCloseButton.cjs"),a=require("./snackbar.module.cjs");let o=require("react");o=e.__toESM(o,1);let s=require("classnames");s=e.__toESM(s,1);let c=require("react/jsx-runtime");var l=({message:e,open:l=!1,intent:u=`default`,position:d=`bottom-center`,autoHideDuration:f=5e3,showCloseButton:p=!1,actionLabel:m,onAction:h,onClose:g,className:_})=>{let[v,y]=(0,o.useState)(!1),[b,x]=(0,o.useState)(!1),[S,C]=(0,o.useState)(l);l!==S&&(C(l),l?x(!0):y(!1)),(0,o.useEffect)(()=>{if(l){let e=setTimeout(()=>y(!0),10);return()=>clearTimeout(e)}{let e=setTimeout(()=>x(!1),300);return()=>clearTimeout(e)}},[l]);let w=(0,o.useCallback)(()=>{y(!1),setTimeout(()=>{g&&g()},300)},[g]),[T,E]=(0,o.useState)(f),[D,O]=(0,o.useState)(()=>Date.now()),[k,A]=(0,o.useState)(!1);(0,o.useEffect)(()=>{if(l&&f>0&&!k){let e=setTimeout(()=>{w()},T);return O(Date.now()),()=>clearTimeout(e)}},[l,f,w,k,T]);let j=()=>{if(f>0){A(!0);let e=Date.now()-D;E(t=>Math.max(0,t-e))}},M=()=>{f>0&&(O(Date.now()),A(!1))},N=()=>{h&&h()},P=u===`danger`||u===`warning`?`alert`:`status`;return(0,c.jsxs)(`div`,{className:(0,s.default)(a.default.wrapper,a.default[d]),children:[(0,c.jsx)(t.VisuallyHidden,{role:P,"aria-atomic":`true`,children:l?e:``}),(b||l)&&(0,c.jsxs)(`div`,{className:(0,s.default)(`wim-snackbar`,a.default.root,u&&a.default[u],v&&a.default.visible,p&&a.default.hasCloseButton,_),onMouseEnter:j,onMouseLeave:M,onFocus:j,onBlur:M,children:[(0,c.jsxs)(`div`,{className:a.default.content,children:[(u===`success`||u===`warning`||u===`danger`)&&(0,c.jsx)(`div`,{className:a.default.icon,children:(0,c.jsx)(r.FeedbackIcon,{intent:u,size:`sm`})}),(0,c.jsx)(`span`,{className:a.default.message,children:e})]}),(0,c.jsxs)(`div`,{className:a.default.actions,children:[m&&(0,c.jsx)(n.Button,{variant:`ghost`,size:`sm`,onClick:N,className:a.default.actionButton,children:m}),(0,c.jsx)(i.FeedbackCloseButton,{onClose:p?w:void 0,className:a.default.closeButton,size:`sm`})]})]})]})},u=(0,o.createContext)(void 0),d=({children:e})=>{let[t,n]=(0,o.useState)(null),[r,i]=(0,o.useState)(!1),a=(0,o.useCallback)(e=>{let r=Math.random().toString(36).substr(2,9),a=typeof e==`string`?{message:e}:e;i(!1),setTimeout(()=>{n({...a,id:r}),i(!0)},t?300:0)},[t]),s=(0,o.useCallback)(()=>{i(!1)},[]);return(0,c.jsxs)(u.Provider,{value:{showMessage:a,hideMessage:s},children:[e,(0,c.jsx)(l,{message:``,...t,open:r&&t!==null,onClose:()=>{i(!1),t?.onClose&&t.onClose()}})]})},f=()=>{let e=(0,o.useContext)(u);if(!e)throw Error(`useSnackbar must be used within a SnackbarProvider`);return e};exports.Snackbar=l,exports.SnackbarProvider=d,exports.useSnackbar=f;
|
|
@@ -41,7 +41,7 @@ export interface SnackbarProps {
|
|
|
41
41
|
/**
|
|
42
42
|
* Snackbar for notifying the user with a short message.
|
|
43
43
|
*/
|
|
44
|
-
export declare const Snackbar: ({ message, open, intent, position, autoHideDuration, showCloseButton, actionLabel, onAction, onClose, className, }: SnackbarProps) => React.JSX.Element
|
|
44
|
+
export declare const Snackbar: ({ message, open, intent, position, autoHideDuration, showCloseButton, actionLabel, onAction, onClose, className, }: SnackbarProps) => React.JSX.Element;
|
|
45
45
|
type SnackbarContextType = {
|
|
46
46
|
showMessage: (props: string | Omit<SnackbarProps, "open" | "onClose">) => void;
|
|
47
47
|
hideMessage: () => void;
|
|
@@ -1,96 +1,97 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import r from "
|
|
6
|
-
import
|
|
7
|
-
import l from "
|
|
8
|
-
import
|
|
2
|
+
import { VisuallyHidden as e } from "../../layout/VisuallyHidden/VisuallyHidden.js";
|
|
3
|
+
import { Button as t } from "../../form/Button/Button.js";
|
|
4
|
+
import { FeedbackIcon as n } from "../../_internal/FeedbackIcon.js";
|
|
5
|
+
import { FeedbackCloseButton as r } from "../../_internal/FeedbackCloseButton.js";
|
|
6
|
+
import i from "./snackbar.module.js";
|
|
7
|
+
import { createContext as a, useCallback as o, useContext as s, useEffect as c, useState as l } from "react";
|
|
8
|
+
import u from "classnames";
|
|
9
|
+
import { jsx as d, jsxs as f } from "react/jsx-runtime";
|
|
9
10
|
//#region src/components/feedback/Snackbar/Snackbar.tsx
|
|
10
|
-
var
|
|
11
|
-
let [
|
|
12
|
-
|
|
13
|
-
if (
|
|
14
|
-
let e = setTimeout(() =>
|
|
11
|
+
var p = ({ message: a, open: s = !1, intent: p = "default", position: m = "bottom-center", autoHideDuration: h = 5e3, showCloseButton: g = !1, actionLabel: _, onAction: v, onClose: y, className: b }) => {
|
|
12
|
+
let [x, S] = l(!1), [C, w] = l(!1), [T, E] = l(s);
|
|
13
|
+
s !== T && (E(s), s ? w(!0) : S(!1)), c(() => {
|
|
14
|
+
if (s) {
|
|
15
|
+
let e = setTimeout(() => S(!0), 10);
|
|
15
16
|
return () => clearTimeout(e);
|
|
16
17
|
}
|
|
17
18
|
{
|
|
18
|
-
let e = setTimeout(() =>
|
|
19
|
+
let e = setTimeout(() => w(!1), 300);
|
|
19
20
|
return () => clearTimeout(e);
|
|
20
21
|
}
|
|
21
|
-
}, [
|
|
22
|
-
let
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
}, [s]);
|
|
23
|
+
let D = o(() => {
|
|
24
|
+
S(!1), setTimeout(() => {
|
|
25
|
+
y && y();
|
|
25
26
|
}, 300);
|
|
26
|
-
}, [
|
|
27
|
-
|
|
28
|
-
if (
|
|
27
|
+
}, [y]), [O, k] = l(h), [A, j] = l(() => Date.now()), [M, N] = l(!1);
|
|
28
|
+
c(() => {
|
|
29
|
+
if (s && h > 0 && !M) {
|
|
29
30
|
let e = setTimeout(() => {
|
|
30
|
-
|
|
31
|
-
},
|
|
32
|
-
return
|
|
31
|
+
D();
|
|
32
|
+
}, O);
|
|
33
|
+
return j(Date.now()), () => clearTimeout(e);
|
|
33
34
|
}
|
|
34
35
|
}, [
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
s,
|
|
37
|
+
h,
|
|
38
|
+
D,
|
|
39
|
+
M,
|
|
40
|
+
O
|
|
40
41
|
]);
|
|
41
|
-
let
|
|
42
|
-
if (
|
|
43
|
-
|
|
44
|
-
let e = Date.now() -
|
|
45
|
-
|
|
42
|
+
let P = () => {
|
|
43
|
+
if (h > 0) {
|
|
44
|
+
N(!0);
|
|
45
|
+
let e = Date.now() - A;
|
|
46
|
+
k((t) => Math.max(0, t - e));
|
|
46
47
|
}
|
|
47
|
-
}, P = () => {
|
|
48
|
-
m > 0 && (A(Date.now()), M(!1));
|
|
49
48
|
}, F = () => {
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
return /* @__PURE__ */
|
|
55
|
-
className:
|
|
56
|
-
children: /* @__PURE__ */ d(
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
"
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
49
|
+
h > 0 && (j(Date.now()), N(!1));
|
|
50
|
+
}, I = () => {
|
|
51
|
+
v && v();
|
|
52
|
+
}, L = p === "danger" || p === "warning" ? "alert" : "status";
|
|
53
|
+
return /* @__PURE__ */ f("div", {
|
|
54
|
+
className: u(i.wrapper, i[m]),
|
|
55
|
+
children: [/* @__PURE__ */ d(e, {
|
|
56
|
+
role: L,
|
|
57
|
+
"aria-atomic": "true",
|
|
58
|
+
children: s ? a : ""
|
|
59
|
+
}), (C || s) && /* @__PURE__ */ f("div", {
|
|
60
|
+
className: u("wim-snackbar", i.root, p && i[p], x && i.visible, g && i.hasCloseButton, b),
|
|
61
|
+
onMouseEnter: P,
|
|
62
|
+
onMouseLeave: F,
|
|
63
|
+
onFocus: P,
|
|
64
|
+
onBlur: F,
|
|
65
|
+
children: [/* @__PURE__ */ f("div", {
|
|
66
|
+
className: i.content,
|
|
67
|
+
children: [(p === "success" || p === "warning" || p === "danger") && /* @__PURE__ */ d("div", {
|
|
68
|
+
className: i.icon,
|
|
69
|
+
children: /* @__PURE__ */ d(n, {
|
|
70
|
+
intent: p,
|
|
70
71
|
size: "sm"
|
|
71
72
|
})
|
|
72
|
-
}), /* @__PURE__ */
|
|
73
|
-
className:
|
|
74
|
-
children:
|
|
73
|
+
}), /* @__PURE__ */ d("span", {
|
|
74
|
+
className: i.message,
|
|
75
|
+
children: a
|
|
75
76
|
})]
|
|
76
|
-
}), /* @__PURE__ */
|
|
77
|
-
className:
|
|
78
|
-
children: [
|
|
77
|
+
}), /* @__PURE__ */ f("div", {
|
|
78
|
+
className: i.actions,
|
|
79
|
+
children: [_ && /* @__PURE__ */ d(t, {
|
|
79
80
|
variant: "ghost",
|
|
80
81
|
size: "sm",
|
|
81
|
-
onClick:
|
|
82
|
-
className:
|
|
83
|
-
children:
|
|
84
|
-
}), /* @__PURE__ */
|
|
85
|
-
onClose:
|
|
86
|
-
className:
|
|
82
|
+
onClick: I,
|
|
83
|
+
className: i.actionButton,
|
|
84
|
+
children: _
|
|
85
|
+
}), /* @__PURE__ */ d(r, {
|
|
86
|
+
onClose: g ? D : void 0,
|
|
87
|
+
className: i.closeButton,
|
|
87
88
|
size: "sm"
|
|
88
89
|
})]
|
|
89
90
|
})]
|
|
90
|
-
})
|
|
91
|
+
})]
|
|
91
92
|
});
|
|
92
|
-
},
|
|
93
|
-
let [t, n] =
|
|
93
|
+
}, m = a(void 0), h = ({ children: e }) => {
|
|
94
|
+
let [t, n] = l(null), [r, i] = l(!1), a = o((e) => {
|
|
94
95
|
let r = Math.random().toString(36).substr(2, 9), a = typeof e == "string" ? { message: e } : e;
|
|
95
96
|
i(!1), setTimeout(() => {
|
|
96
97
|
n({
|
|
@@ -98,26 +99,27 @@ var f = ({ message: i, open: o = !1, intent: f = "default", position: p = "botto
|
|
|
98
99
|
id: r
|
|
99
100
|
}), i(!0);
|
|
100
101
|
}, t ? 300 : 0);
|
|
101
|
-
}, [t]), s =
|
|
102
|
+
}, [t]), s = o(() => {
|
|
102
103
|
i(!1);
|
|
103
104
|
}, []);
|
|
104
|
-
return /* @__PURE__ */
|
|
105
|
+
return /* @__PURE__ */ f(m.Provider, {
|
|
105
106
|
value: {
|
|
106
|
-
showMessage:
|
|
107
|
+
showMessage: a,
|
|
107
108
|
hideMessage: s
|
|
108
109
|
},
|
|
109
|
-
children: [e,
|
|
110
|
+
children: [e, /* @__PURE__ */ d(p, {
|
|
111
|
+
message: "",
|
|
110
112
|
...t,
|
|
111
|
-
open: r,
|
|
113
|
+
open: r && t !== null,
|
|
112
114
|
onClose: () => {
|
|
113
|
-
i(!1), t
|
|
115
|
+
i(!1), t?.onClose && t.onClose();
|
|
114
116
|
}
|
|
115
117
|
})]
|
|
116
118
|
});
|
|
117
|
-
},
|
|
118
|
-
let e =
|
|
119
|
+
}, g = () => {
|
|
120
|
+
let e = s(m);
|
|
119
121
|
if (!e) throw Error("useSnackbar must be used within a SnackbarProvider");
|
|
120
122
|
return e;
|
|
121
123
|
};
|
|
122
124
|
//#endregion
|
|
123
|
-
export {
|
|
125
|
+
export { p as Snackbar, h as SnackbarProvider, g as useSnackbar };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../layout/Transition/Transition.cjs"),n=require("../../_internal/FeedbackIcon.cjs"),
|
|
2
|
+
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../layout/Transition/Transition.cjs"),n=require("../../layout/VisuallyHidden/VisuallyHidden.cjs"),r=require("../../_internal/FeedbackIcon.cjs"),i=require("../../_internal/FeedbackCloseButton.cjs"),a=require("./toast.module.cjs");let o=require("react");o=e.__toESM(o,1);let s=require("classnames");s=e.__toESM(s,1);let c=require("react/jsx-runtime");var l=({id:e,title:l,description:d,intent:p=`default`,duration:m=3e3,open:h=!0,onClose:g,className:_,"aria-label":v,"aria-labelledby":y})=>{let[b,x]=(0,o.useState)(!0),S=(0,o.useCallback)(()=>{x(!1),g&&g(e)},[g,e]);(0,o.useEffect)(()=>{if(h&&m>0&&b){let e=setTimeout(()=>{S()},m+300);return()=>clearTimeout(e)}},[h,m,e,g,b,S]);let C=(0,o.useContext)(f),w=(0,c.jsxs)(t.Transition,{show:h&&b,enter:a.default.enter,enterFrom:a.default.enterFrom,enterTo:a.default.enterTo,leave:a.default.leave,leaveFrom:a.default.leaveFrom,leaveTo:a.default.leaveTo,className:(0,s.default)(`wim-toast`,a.default.root,a.default[p],_),role:v||y?`group`:void 0,"aria-label":y?void 0:v,"aria-labelledby":y,children:[(p===`success`||p===`warning`||p===`danger`||p===`info`)&&(0,c.jsx)(`div`,{className:a.default.icon,children:(0,c.jsx)(r.FeedbackIcon,{intent:p,size:`sm`})}),(0,c.jsxs)(`div`,{className:a.default.content,children:[l&&(0,c.jsx)(`div`,{className:a.default.title,children:l}),d&&(0,c.jsx)(`p`,{className:a.default.description,children:d})]}),(0,c.jsx)(i.FeedbackCloseButton,{onClose:g?S:void 0,id:e,className:a.default.closeButton,size:`md`})]});return C?w:(0,c.jsxs)(`div`,{className:a.default.live,children:[(0,c.jsx)(n.VisuallyHidden,{role:`status`,"aria-atomic":`true`,children:h&&b?u(l,d):``}),w]})},u=(e,t)=>[e,t].filter(Boolean).join(`: `),d=(0,o.createContext)(void 0),f=(0,o.createContext)(!1),p=({children:e,position:t=`top-right`})=>{let[r,i]=(0,o.useState)([]),[p,m]=(0,o.useState)(null),h=(0,o.useCallback)(e=>{let t=Math.random().toString(36).substr(2,9);i(n=>[...n,{...e,id:t}]),m({...e,id:t})},[]),g=(0,o.useCallback)(e=>{i(t=>t.filter(t=>t.id!==e)),m(t=>t?.id===e?null:t)},[]);return(0,c.jsxs)(d.Provider,{value:{show:h,remove:g},children:[e,(0,c.jsxs)(`div`,{className:(0,s.default)(a.default.container,a.default[t]),children:[(0,c.jsx)(n.VisuallyHidden,{role:`status`,"aria-atomic":`true`,children:p?u(p.title,p.description):``}),(0,c.jsx)(f.Provider,{value:!0,children:r.map(e=>(0,c.jsx)(l,{...e,onClose:()=>g(e.id)},e.id))})]})]})},m=()=>{let e=(0,o.useContext)(d);if(!e)throw Error(`useToast must be used within a ToastProvider`);return e};exports.Toast=l,exports.ToastProvider=p,exports.useToast=m;
|
|
@@ -1,96 +1,115 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { Transition as e } from "../../layout/Transition/Transition.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import r from "
|
|
6
|
-
import
|
|
7
|
-
import l from "
|
|
8
|
-
import
|
|
3
|
+
import { VisuallyHidden as t } from "../../layout/VisuallyHidden/VisuallyHidden.js";
|
|
4
|
+
import { FeedbackIcon as n } from "../../_internal/FeedbackIcon.js";
|
|
5
|
+
import { FeedbackCloseButton as r } from "../../_internal/FeedbackCloseButton.js";
|
|
6
|
+
import i from "./toast.module.js";
|
|
7
|
+
import { createContext as a, useCallback as o, useContext as s, useEffect as c, useState as l } from "react";
|
|
8
|
+
import u from "classnames";
|
|
9
|
+
import { jsx as d, jsxs as f } from "react/jsx-runtime";
|
|
9
10
|
//#region src/components/feedback/Toast/Toast.tsx
|
|
10
|
-
var
|
|
11
|
-
let [
|
|
12
|
-
|
|
13
|
-
}, [
|
|
14
|
-
|
|
15
|
-
if (
|
|
11
|
+
var p = ({ id: a, title: p, description: h, intent: _ = "default", duration: v = 3e3, open: y = !0, onClose: b, className: x, "aria-label": S, "aria-labelledby": C }) => {
|
|
12
|
+
let [w, T] = l(!0), E = o(() => {
|
|
13
|
+
T(!1), b && b(a);
|
|
14
|
+
}, [b, a]);
|
|
15
|
+
c(() => {
|
|
16
|
+
if (y && v > 0 && w) {
|
|
16
17
|
let e = setTimeout(() => {
|
|
17
|
-
|
|
18
|
-
},
|
|
18
|
+
E();
|
|
19
|
+
}, v + 300);
|
|
19
20
|
return () => clearTimeout(e);
|
|
20
21
|
}
|
|
21
22
|
}, [
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
g,
|
|
23
|
+
y,
|
|
24
|
+
v,
|
|
25
|
+
a,
|
|
26
26
|
b,
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
"aria-
|
|
27
|
+
w,
|
|
28
|
+
E
|
|
29
|
+
]);
|
|
30
|
+
let D = s(g), O = /* @__PURE__ */ f(e, {
|
|
31
|
+
show: y && w,
|
|
32
|
+
enter: i.enter,
|
|
33
|
+
enterFrom: i.enterFrom,
|
|
34
|
+
enterTo: i.enterTo,
|
|
35
|
+
leave: i.leave,
|
|
36
|
+
leaveFrom: i.leaveFrom,
|
|
37
|
+
leaveTo: i.leaveTo,
|
|
38
|
+
className: u("wim-toast", i.root, i[_], x),
|
|
39
|
+
role: S || C ? "group" : void 0,
|
|
40
|
+
"aria-label": C ? void 0 : S,
|
|
41
|
+
"aria-labelledby": C,
|
|
41
42
|
children: [
|
|
42
|
-
(
|
|
43
|
-
className:
|
|
44
|
-
children: /* @__PURE__ */
|
|
45
|
-
intent:
|
|
43
|
+
(_ === "success" || _ === "warning" || _ === "danger" || _ === "info") && /* @__PURE__ */ d("div", {
|
|
44
|
+
className: i.icon,
|
|
45
|
+
children: /* @__PURE__ */ d(n, {
|
|
46
|
+
intent: _,
|
|
46
47
|
size: "sm"
|
|
47
48
|
})
|
|
48
49
|
}),
|
|
49
|
-
/* @__PURE__ */
|
|
50
|
-
className:
|
|
51
|
-
children: [
|
|
52
|
-
className:
|
|
53
|
-
children:
|
|
54
|
-
}),
|
|
55
|
-
className:
|
|
56
|
-
children:
|
|
50
|
+
/* @__PURE__ */ f("div", {
|
|
51
|
+
className: i.content,
|
|
52
|
+
children: [p && /* @__PURE__ */ d("div", {
|
|
53
|
+
className: i.title,
|
|
54
|
+
children: p
|
|
55
|
+
}), h && /* @__PURE__ */ d("p", {
|
|
56
|
+
className: i.description,
|
|
57
|
+
children: h
|
|
57
58
|
})]
|
|
58
59
|
}),
|
|
59
|
-
/* @__PURE__ */
|
|
60
|
-
onClose:
|
|
61
|
-
id:
|
|
62
|
-
className:
|
|
60
|
+
/* @__PURE__ */ d(r, {
|
|
61
|
+
onClose: b ? E : void 0,
|
|
62
|
+
id: a,
|
|
63
|
+
className: i.closeButton,
|
|
63
64
|
size: "md"
|
|
64
65
|
})
|
|
65
66
|
]
|
|
66
67
|
});
|
|
67
|
-
|
|
68
|
-
|
|
68
|
+
return D ? O : /* @__PURE__ */ f("div", {
|
|
69
|
+
className: i.live,
|
|
70
|
+
children: [/* @__PURE__ */ d(t, {
|
|
71
|
+
role: "status",
|
|
72
|
+
"aria-atomic": "true",
|
|
73
|
+
children: y && w ? m(p, h) : ""
|
|
74
|
+
}), O]
|
|
75
|
+
});
|
|
76
|
+
}, m = (e, t) => [e, t].filter(Boolean).join(": "), h = a(void 0), g = a(!1), _ = ({ children: e, position: n = "top-right" }) => {
|
|
77
|
+
let [r, a] = l([]), [s, c] = l(null), _ = o((e) => {
|
|
69
78
|
let t = Math.random().toString(36).substr(2, 9);
|
|
70
|
-
|
|
79
|
+
a((n) => [...n, {
|
|
80
|
+
...e,
|
|
81
|
+
id: t
|
|
82
|
+
}]), c({
|
|
71
83
|
...e,
|
|
72
84
|
id: t
|
|
73
|
-
}
|
|
74
|
-
}, []),
|
|
75
|
-
|
|
85
|
+
});
|
|
86
|
+
}, []), v = o((e) => {
|
|
87
|
+
a((t) => t.filter((t) => t.id !== e)), c((t) => t?.id === e ? null : t);
|
|
76
88
|
}, []);
|
|
77
|
-
return /* @__PURE__ */
|
|
89
|
+
return /* @__PURE__ */ f(h.Provider, {
|
|
78
90
|
value: {
|
|
79
|
-
show:
|
|
80
|
-
remove:
|
|
91
|
+
show: _,
|
|
92
|
+
remove: v
|
|
81
93
|
},
|
|
82
|
-
children: [e, /* @__PURE__ */
|
|
83
|
-
className:
|
|
84
|
-
children:
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
94
|
+
children: [e, /* @__PURE__ */ f("div", {
|
|
95
|
+
className: u(i.container, i[n]),
|
|
96
|
+
children: [/* @__PURE__ */ d(t, {
|
|
97
|
+
role: "status",
|
|
98
|
+
"aria-atomic": "true",
|
|
99
|
+
children: s ? m(s.title, s.description) : ""
|
|
100
|
+
}), /* @__PURE__ */ d(g.Provider, {
|
|
101
|
+
value: !0,
|
|
102
|
+
children: r.map((e) => /* @__PURE__ */ d(p, {
|
|
103
|
+
...e,
|
|
104
|
+
onClose: () => v(e.id)
|
|
105
|
+
}, e.id))
|
|
106
|
+
})]
|
|
88
107
|
})]
|
|
89
108
|
});
|
|
90
|
-
},
|
|
91
|
-
let e =
|
|
109
|
+
}, v = () => {
|
|
110
|
+
let e = s(h);
|
|
92
111
|
if (!e) throw Error("useToast must be used within a ToastProvider");
|
|
93
112
|
return e;
|
|
94
113
|
};
|
|
95
114
|
//#endregion
|
|
96
|
-
export {
|
|
115
|
+
export { p as Toast, _ as ToastProvider, v as useToast };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
var e=`
|
|
2
|
+
var e=`_live_1j80a_4`,t=`_container_1j80a_7`,n=`_root_1j80a_42`,r=`_icon_1j80a_57`,i=`_title_1j80a_68`,a=`_content_1j80a_71`,o=`_description_1j80a_92`,s=`_closeButton_1j80a_100`,c=`_info_1j80a_137`,l=`_success_1j80a_144`,u=`_warning_1j80a_151`,d=`_danger_1j80a_158`,f=`_enter_1j80a_165`,p=`_enterFrom_1j80a_168`,m=`_enterTo_1j80a_172`,h=`_leave_1j80a_176`,g=`_leaveFrom_1j80a_179`,_=`_leaveTo_1j80a_183`,v={live:e,container:t,"top-right":`_top-right_1j80a_16`,"top-left":`_top-left_1j80a_20`,"top-center":`_top-center_1j80a_24`,"bottom-right":`_bottom-right_1j80a_29`,"bottom-left":`_bottom-left_1j80a_33`,"bottom-center":`_bottom-center_1j80a_37`,root:n,icon:r,title:i,content:a,description:o,closeButton:s,default:`_default_1j80a_130`,info:c,success:l,warning:u,danger:d,enter:f,enterFrom:p,enterTo:m,leave:h,leaveFrom:g,leaveTo:_};exports.closeButton=s,exports.container=t,exports.content=a,exports.danger=d,exports.default=v,exports.description=o,exports.enter=f,exports.enterFrom=p,exports.enterTo=m,exports.icon=r,exports.info=c,exports.leave=h,exports.leaveFrom=g,exports.leaveTo=_,exports.live=e,exports.root=n,exports.success=l,exports.title=i,exports.warning=u;
|
|
@@ -1,30 +1,31 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
//#region src/components/feedback/Toast/toast.module.scss
|
|
3
|
-
var e = "
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
"top-
|
|
7
|
-
"top-
|
|
8
|
-
"
|
|
9
|
-
"bottom-
|
|
10
|
-
"bottom-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
3
|
+
var e = "_live_1j80a_4", t = "_container_1j80a_7", n = "_root_1j80a_42", r = "_icon_1j80a_57", i = "_title_1j80a_68", a = "_content_1j80a_71", o = "_description_1j80a_92", s = "_closeButton_1j80a_100", c = "_info_1j80a_137", l = "_success_1j80a_144", u = "_warning_1j80a_151", d = "_danger_1j80a_158", f = "_enter_1j80a_165", p = "_enterFrom_1j80a_168", m = "_enterTo_1j80a_172", h = "_leave_1j80a_176", g = "_leaveFrom_1j80a_179", _ = "_leaveTo_1j80a_183", v = {
|
|
4
|
+
live: e,
|
|
5
|
+
container: t,
|
|
6
|
+
"top-right": "_top-right_1j80a_16",
|
|
7
|
+
"top-left": "_top-left_1j80a_20",
|
|
8
|
+
"top-center": "_top-center_1j80a_24",
|
|
9
|
+
"bottom-right": "_bottom-right_1j80a_29",
|
|
10
|
+
"bottom-left": "_bottom-left_1j80a_33",
|
|
11
|
+
"bottom-center": "_bottom-center_1j80a_37",
|
|
12
|
+
root: n,
|
|
13
|
+
icon: r,
|
|
14
|
+
title: i,
|
|
15
|
+
content: a,
|
|
16
|
+
description: o,
|
|
17
|
+
closeButton: s,
|
|
18
|
+
default: "_default_1j80a_130",
|
|
19
|
+
info: c,
|
|
20
|
+
success: l,
|
|
21
|
+
warning: u,
|
|
22
|
+
danger: d,
|
|
23
|
+
enter: f,
|
|
24
|
+
enterFrom: p,
|
|
25
|
+
enterTo: m,
|
|
26
|
+
leave: h,
|
|
27
|
+
leaveFrom: g,
|
|
28
|
+
leaveTo: _
|
|
28
29
|
};
|
|
29
30
|
//#endregion
|
|
30
|
-
export {
|
|
31
|
+
export { s as closeButton, t as container, a as content, d as danger, v as default, o as description, f as enter, p as enterFrom, m as enterTo, r as icon, c as info, h as leave, g as leaveFrom, _ as leaveTo, e as live, n as root, l as success, i as title, u as warning };
|
|
@@ -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("../../../icon/bold.cjs"),i=require("../../../icon/eraser.cjs"),a=require("../../../icon/image.cjs"),o=require("../../../icon/italic.cjs"),ee=require("../../../icon/link.cjs"),te=require("../../../icon/list-ordered.cjs"),ne=require("../../../icon/list.cjs"),re=require("../../../icon/strikethrough.cjs"),ie=require("../../../icon/underline.cjs"),ae=require("../../../icon/unlink.cjs"),s=require("../../media/Icon/Icon.cjs"),c=require("../Button/Button.cjs"),oe=require("../FieldTemplate/FieldTemplate.cjs"),l=require("../Input/Input.cjs"),u=require("../../overlay/Dialog/Dialog.cjs"),d=require("./safeUrl.cjs"),f=require("./markdown.cjs"),p=require("./rich-text-editor.module.cjs");let m=require("react");m=e.__toESM(m,1);let h=require("classnames");h=e.__toESM(h,1);let g=require("react/jsx-runtime"),_=require("@tiptap/react"),se=require("@tiptap/core"),v=require("@tiptap/starter-kit"),y=require("@tiptap/extensions"),ce=require("@tiptap/extension-image");var le=[`bold`,`italic`,`underline`,`strikethrough`,`separator`,`h1`,`h2`,`h3`,`separator`,`ul`,`ol`,`separator`,`link`,`unlink`,`separator`,`removeFormat`],ue=ce.Image.extend({parseHTML(){return[{tag:`img[src]`,getAttrs:e=>d.isSafeImageUrl(e.getAttribute(`src`))?null:!1}]}}),de=(e,t,n)=>[v.StarterKit.configure({heading:{levels:[1,2,3]},blockquote:!1,code:!1,codeBlock:!1,horizontalRule:!1,trailingNode:!1,...t===`markdown`?{underline:!1}:{},link:{openOnClick:!1,autolink:!1,linkOnPaste:!1,isAllowedUri:e=>d.isSafeLinkUrl(e),HTMLAttributes:{target:null,rel:null}}}),ue.configure({inline:!1,allowBase64:!1}),y.Placeholder.configure({placeholder:e}),...t===`markdown`?f.createMarkdownExtensions(n):[]],fe=(e,t)=>e.isEmpty?``:t===`markdown`?e.getMarkdown():e.getHTML(),pe=(e,t,n)=>n===`markdown`?f.markdownToHtml(e,t):t,me=m.default.memo(({onClick:e,active:t,disabled:n,title:r,tabIndex:i,onFocus:a,buttonRef:o,children:ee})=>(0,g.jsx)(`button`,{ref:o,type:`button`,className:(0,h.default)(p.default.toolbarBtn,t&&p.default.active),onClick:e,onFocus:a,disabled:n,title:r,"aria-label":r,"aria-pressed":t,tabIndex:i,children:ee}));me.displayName=`ToolbarButton`;var he=({value:e,defaultValue:f=``,onChange:v,placeholder:y,disabled:ce,intent:ue=`default`,variant:he=`outline`,fullWidth:b=!1,width:x,minHeight:S=200,label:C,error:w,required:T,layout:ge,className:_e,id:ve,toolbar:E=le,labels:ye={},"aria-label":be,"aria-labelledby":D,onImageUpload:O,format:xe=`html`})=>{let{t:k}=t.useWimTranslation(n.componentsNs),{bold:Se=k(`a11y.rte_bold`),italic:Ce=k(`a11y.rte_italic`),underline:we=k(`a11y.rte_underline`),strikethrough:Te=k(`a11y.rte_strikethrough`),h1:Ee=k(`a11y.rte_h1`),h2:De=k(`a11y.rte_h2`),h3:Oe=k(`a11y.rte_h3`),ul:ke=k(`a11y.rte_ul`),ol:Ae=k(`a11y.rte_ol`),link:je=k(`a11y.rte_link`),unlink:Me=k(`a11y.rte_unlink`),removeFormat:Ne=k(`a11y.rte_remove_format`),toolbar:Pe=k(`a11y.rte_toolbar`),linkPrompt:Fe=k(`a11y.rte_link_prompt`),linkApply:Ie=k(`a11y.rte_link_apply`),linkCancel:Le=k(`a11y.rte_link_cancel`),linkInvalid:Re=k(`a11y.rte_link_invalid`),image:ze=k(`a11y.rte_image`),imageUrl:Be=k(`a11y.rte_image_url`),imageAlt:Ve=k(`a11y.rte_image_alt`),imageAltHint:He=k(`a11y.rte_image_alt_hint`),imageUpload:Ue=k(`a11y.rte_image_upload`),imageUploadFailed:A=k(`a11y.rte_image_upload_failed`),imageInvalid:We=k(`a11y.rte_image_invalid`)}=ye,Ge=m.default.useId(),j=ve||`wim-rte-${Ge}`,M=w?`${j}-error`:void 0,N=C?`${j}-label`:void 0,P=!!ce,F=w?`danger`:ue,Ke=typeof x==`string`&&[`xs`,`sm`,`md`,`lg`,`xl`].includes(x),qe=x!==void 0&&!Ke&&!b,Je=Ke&&!b?x:void 0,Ye=Je?p.default[`width${Je.charAt(0).toUpperCase()}${Je.slice(1)}`]:void 0,I=m.default.useRef(e??f),Xe=m.default.useRef(v);m.default.useEffect(()=>{Xe.current=v},[v]);let Ze=m.default.useMemo(()=>{let e={id:j,class:p.default.content,role:`textbox`,"aria-multiline":`true`,style:`min-height: ${typeof S==`number`?`${S}px`:S}`,tabindex:P?`-1`:`0`},t=be??(C||D?void 0:k(`a11y.rte_editor`)),n=D??(C?N:void 0);return t&&(e[`aria-label`]=t),n&&(e[`aria-labelledby`]=n),F===`danger`&&(e[`aria-invalid`]=`true`),M&&(e[`aria-describedby`]=M),T&&(e[`aria-required`]=`true`),P&&(e[`aria-disabled`]=`true`),y&&(e[`aria-placeholder`]=y),e},[j,S,P,be,C,D,N,F,M,T,y,k]),L=m.default.useRef(O);m.default.useEffect(()=>{L.current=O},[O]);let[Qe,$e]=m.default.useState(void 0),et=m.default.useRef(A);m.default.useEffect(()=>{et.current=A},[A]);let R=m.default.useCallback(async(e,t,n)=>{let r=L.current;if(r){$e(void 0);for(let i of t)try{let t=await r(i);if(!d.isSafeImageUrl(t))throw Error(`URL not allowed`);if(e.isDestroyed)return;let a=e.chain().focus();(n===void 0?a:a.setTextSelection(n)).setImage({src:t,alt:``}).run()}catch{$e(et.current)}}},[]),tt=e=>Array.from(e??[]).filter(e=>e.type.startsWith(`image/`)),z=m.default.useRef({ed:null}),nt=m.default.useCallback((e,t)=>{let n=tt(t.clipboardData?.files),r=z.current.ed;return!L.current||n.length===0||!r?!1:(t.preventDefault(),R(r,n),!0)},[R]),rt=m.default.useCallback((e,t,n,r)=>{let i=tt(t.dataTransfer?.files),a=z.current.ed;if(r||!L.current||i.length===0||!a)return!1;t.preventDefault();let o=e.posAtCoords({left:t.clientX,top:t.clientY});return R(a,i,o?.pos),!0},[R]),B=m.default.useMemo(()=>({attributes:Ze,handlePaste:nt,handleDrop:rt}),[Ze,nt,rt]),[V]=m.default.useState(xe),it=e??f,H=(0,_.useEditor)({extensions:de(y??``,V,V===`markdown`?it:void 0),content:V===`markdown`?``:it,editable:!P,immediatelyRender:!1,editorProps:B,onUpdate:({editor:e})=>{let t=fe(e,V);t!==I.current&&(I.current=t,Xe.current?.(t))}});m.default.useEffect(()=>{H&&!H.isDestroyed&&H.setOptions({editorProps:B})},[H,B]),m.default.useEffect(()=>{z.current.ed=H},[H]),m.default.useEffect(()=>{H&&!H.isDestroyed&&H.setEditable(!P,!1)},[H,P]),m.default.useEffect(()=>{if(!H||H.isDestroyed)return;let e=H.extensionManager.extensions.find(e=>e.name===`placeholder`);e&&e.options.placeholder!==(y??``)&&(e.options.placeholder=y??``,H.view.dispatch(H.state.tr))},[H,y]),m.default.useEffect(()=>{if(!H||H.isDestroyed||e===void 0||e===I.current||e===fe(H,V))return;I.current=e;let t=(0,se.createDocument)(pe(H,e,V),H.schema);t.eq(H.state.doc)||H.commands.setContent(t.toJSON(),{emitUpdate:!1})},[H,e,V]);let at=(0,_.useEditorState)({editor:H,selector:({editor:e})=>({bold:!!e?.isActive(`bold`),italic:!!e?.isActive(`italic`),underline:!!e?.schema.marks.underline&&e.isActive(`underline`),strikethrough:!!e?.isActive(`strike`),h1:!!e?.isActive(`heading`,{level:1}),h2:!!e?.isActive(`heading`,{level:2}),h3:!!e?.isActive(`heading`,{level:3}),ul:!!e?.isActive(`bulletList`),ol:!!e?.isActive(`orderedList`),image:!!e?.isActive(`image`)})}),U=m.default.useCallback(e=>{!P&&H&&e(H)},[H,P]),ot=m.default.useCallback(()=>{U(e=>{let{from:t,to:n,empty:r}=e.state.selection,i=e.chain().focus();r&&i.selectAll(),i.unsetBold().unsetItalic().unsetStrike().clearNodes(),e.schema.marks.underline&&i.unsetUnderline(),r&&i.setTextSelection({from:t,to:n}),i.run()})},[U]),[st,W]=m.default.useState(!1),[G,ct]=m.default.useState(`https://`),[lt,K]=m.default.useState(void 0),ut=m.default.useCallback(()=>{if(P||!H)return;let{from:e,to:t}=H.state.selection,n=H.state.doc.textBetween(e,t,` `),r=H.getAttributes(`link`).href;ct(r??(n.startsWith(`http`)?n:`https://`)),K(void 0),W(!0)},[H,P]),dt=m.default.useCallback(()=>{let e=G.trim();if(!e){W(!1);return}if(!d.isSafeLinkUrl(e)){K(Re);return}W(!1),U(t=>{t.state.selection.empty&&!t.isActive(`link`)?t.chain().focus().insertContent({type:`text`,text:e,marks:[{type:`link`,attrs:{href:e}}]}).run():t.chain().focus().extendMarkRange(`link`).setLink({href:e}).run()})},[G,Re,U]),[ft,q]=m.default.useState(!1),[J,Y]=m.default.useState(``),[X,pt]=m.default.useState(``),[mt,Z]=m.default.useState(void 0),[ht,gt]=m.default.useState(!1),_t=m.default.useRef(null),vt=`${j}-image-alt-hint`,yt=m.default.useCallback(()=>{if(P||!H)return;let e=H.isActive(`image`)?H.getAttributes(`image`):{};Y(e.src??``),pt(e.alt??``),Z(void 0),q(!0)},[H,P]),bt=m.default.useCallback(()=>{let e=J.trim();if(!e){q(!1);return}if(!d.isSafeImageUrl(e)){Z(We);return}q(!1),U(t=>t.chain().focus().setImage({src:e,alt:X.trim()}).run())},[J,X,We,U]),xt=m.default.useCallback(async e=>{let t=e.target.files?.[0];if(e.target.value=``,t&&O){gt(!0),Z(void 0);try{let e=await O(t);if(!d.isSafeImageUrl(e))throw Error(`URL not allowed`);Y(e)}catch{Z(A)}finally{gt(!1)}}},[O,A]),St=m.default.useRef([]),[Q,Ct]=m.default.useState(0),$=m.default.useMemo(()=>{let e=V===`markdown`?E.filter(e=>e!==`underline`):E;return e.filter((t,n)=>t!==`separator`||n>0&&n<e.length-1&&e[n-1]!==`separator`)},[E,V]),wt=m.default.useMemo(()=>$.filter(e=>e!==`separator`),[$]),Tt=m.default.useMemo(()=>$.map((e,t)=>e===`separator`?-1:$.slice(0,t).filter(e=>e!==`separator`).length),[$]),Et=m.default.useCallback(e=>{let t=wt.length;if(t===0)return;let n;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(),Ct(n),St.current[n]?.focus())},[wt.length,Q]),Dt=m.default.useCallback(e=>{e.preventDefault()},[]),Ot={bold:{title:Se,icon:(0,g.jsx)(s.Icon,{component:r.default,size:`sm`}),onClick:()=>U(e=>e.chain().focus().toggleBold().run())},italic:{title:Ce,icon:(0,g.jsx)(s.Icon,{component:o.default,size:`sm`}),onClick:()=>U(e=>e.chain().focus().toggleItalic().run())},underline:{title:we,icon:(0,g.jsx)(s.Icon,{component:ie.default,size:`sm`}),onClick:()=>U(e=>e.chain().focus().toggleUnderline().run())},strikethrough:{title:Te,icon:(0,g.jsx)(s.Icon,{component:re.default,size:`sm`}),onClick:()=>U(e=>e.chain().focus().toggleStrike().run())},h1:{title:Ee,icon:(0,g.jsx)(`span`,{"aria-hidden":`true`,children:`H1`}),onClick:()=>U(e=>e.chain().focus().toggleHeading({level:1}).run())},h2:{title:De,icon:(0,g.jsx)(`span`,{"aria-hidden":`true`,children:`H2`}),onClick:()=>U(e=>e.chain().focus().toggleHeading({level:2}).run())},h3:{title:Oe,icon:(0,g.jsx)(`span`,{"aria-hidden":`true`,children:`H3`}),onClick:()=>U(e=>e.chain().focus().toggleHeading({level:3}).run())},ul:{title:ke,icon:(0,g.jsx)(s.Icon,{component:ne.default,size:`sm`}),onClick:()=>U(e=>e.chain().focus().toggleBulletList().run())},ol:{title:Ae,icon:(0,g.jsx)(s.Icon,{component:te.default,size:`sm`}),onClick:()=>U(e=>e.chain().focus().toggleOrderedList().run())},link:{title:je,icon:(0,g.jsx)(s.Icon,{component:ee.default,size:`sm`}),onClick:ut},unlink:{title:Me,icon:(0,g.jsx)(s.Icon,{component:ae.default,size:`sm`}),onClick:()=>U(e=>e.chain().focus().extendMarkRange(`link`).unsetLink().run())},image:{title:ze,icon:(0,g.jsx)(s.Icon,{component:a.default,size:`sm`}),onClick:yt},removeFormat:{title:Ne,icon:(0,g.jsx)(s.Icon,{component:i.default,size:`sm`}),onClick:ot}};return(0,g.jsx)(oe.FieldTemplate,{label:C,error:w,required:T,layout:ge,labelId:N,errorId:M,className:_e,children:(0,g.jsxs)(`div`,{className:(0,h.default)(`wim-rich-text-editor`,p.default.root,p.default[F],P&&p.default.disabled,p.default[he],b&&p.default.fullWidth,qe&&p.default.hasCustomWidth,Ye),style:qe?{"--wim-input-width":typeof x==`number`?`${x}px`:x}:void 0,children:[(0,g.jsx)(`div`,{className:p.default.toolbar,role:`toolbar`,"aria-label":Pe,"aria-controls":j,onMouseDown:Dt,onKeyDown:Et,children:$.map((e,t)=>{if(e===`separator`)return(0,g.jsx)(`span`,{className:p.default.toolbarSep,"aria-hidden":`true`},`sep-${t}`);let n=Tt[t],r=Ot[e],i=e===`link`||e===`unlink`||e===`removeFormat`?void 0:at?.[e]??!1;return(0,g.jsx)(me,{buttonRef:e=>{St.current[n]=e},tabIndex:n===Math.min(Q,wt.length-1)?0:-1,onFocus:()=>Ct(n),disabled:P,active:i,title:r.title,onClick:r.onClick,children:r.icon},`${e}-${t}`)})}),(0,g.jsx)(_.EditorContent,{editor:H,className:p.default.contentHost}),Qe&&(0,g.jsx)(`p`,{role:`alert`,className:p.default.uploadError,children:Qe}),(0,g.jsx)(u.Dialog,{open:st,onOpenChange:W,children:(0,g.jsxs)(u.DialogContent,{children:[(0,g.jsx)(u.DialogHeader,{children:(0,g.jsx)(u.DialogTitle,{children:je})}),(0,g.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),dt()},children:[(0,g.jsx)(l.Input,{label:Fe,type:`url`,value:G,error:lt,onChange:e=>{ct(e.target.value),K(void 0)},fullWidth:!0}),(0,g.jsxs)(u.DialogFooter,{children:[(0,g.jsx)(u.DialogClose,{asChild:!0,children:(0,g.jsx)(c.Button,{variant:`ghost`,type:`button`,children:Le})}),(0,g.jsx)(c.Button,{variant:`solid`,type:`submit`,children:Ie})]})]})]})}),(0,g.jsx)(u.Dialog,{open:ft,onOpenChange:q,children:(0,g.jsxs)(u.DialogContent,{children:[(0,g.jsx)(u.DialogHeader,{children:(0,g.jsx)(u.DialogTitle,{children:ze})}),(0,g.jsxs)(`form`,{className:p.default.imageForm,onSubmit:e=>{e.preventDefault(),bt()},children:[(0,g.jsx)(l.Input,{label:Be,type:`url`,value:J,error:mt,onChange:e=>{Y(e.target.value),Z(void 0)},fullWidth:!0}),O&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(`input`,{ref:_t,type:`file`,accept:`image/*`,hidden:!0,onChange:xt}),(0,g.jsx)(c.Button,{type:`button`,variant:`outline`,loading:ht,onClick:()=>_t.current?.click(),children:Ue})]}),(0,g.jsxs)(`div`,{children:[(0,g.jsx)(l.Input,{label:Ve,"aria-describedby":vt,value:X,onChange:e=>pt(e.target.value),fullWidth:!0}),(0,g.jsx)(`p`,{id:vt,className:p.default.imageHint,children:He})]}),(0,g.jsxs)(u.DialogFooter,{children:[(0,g.jsx)(u.DialogClose,{asChild:!0,children:(0,g.jsx)(c.Button,{variant:`ghost`,type:`button`,children:Le})}),(0,g.jsx)(c.Button,{variant:`solid`,type:`submit`,disabled:ht,children:Ie})]})]})]})})]})})};he.displayName=`RichTextEditor`,exports.RichTextEditor=he;
|
|
2
|
+
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../i18n/useWimTranslation.cjs"),n=require("../../../i18n/generated/components.cjs"),r=require("../../../icon/bold.cjs"),i=require("../../../icon/eraser.cjs"),a=require("../../../icon/image.cjs"),o=require("../../../icon/italic.cjs"),ee=require("../../../icon/link.cjs"),te=require("../../../icon/list-ordered.cjs"),ne=require("../../../icon/list.cjs"),re=require("../../../icon/strikethrough.cjs"),ie=require("../../../icon/underline.cjs"),ae=require("../../../icon/unlink.cjs"),s=require("../../media/Icon/Icon.cjs"),c=require("../Button/Button.cjs"),oe=require("../FieldTemplate/FieldTemplate.cjs"),l=require("../Input/Input.cjs"),u=require("../../overlay/Dialog/Dialog.cjs"),d=require("./safeUrl.cjs"),f=require("./markdown.cjs"),p=require("./rich-text-editor.module.cjs");let m=require("react");m=e.__toESM(m,1);let h=require("classnames");h=e.__toESM(h,1);let g=require("react/jsx-runtime"),_=require("@tiptap/react"),se=require("@tiptap/core"),v=require("@tiptap/starter-kit"),y=require("@tiptap/extensions"),ce=require("@tiptap/extension-image");var le=[`bold`,`italic`,`underline`,`strikethrough`,`separator`,`h1`,`h2`,`h3`,`separator`,`ul`,`ol`,`separator`,`link`,`unlink`,`separator`,`removeFormat`],ue=ce.Image.extend({parseHTML(){return[{tag:`img[src]`,getAttrs:e=>d.isSafeImageUrl(e.getAttribute(`src`))?null:!1}]}}),de=(e,t,n)=>[v.StarterKit.configure({heading:{levels:[1,2,3]},blockquote:!1,code:!1,codeBlock:!1,horizontalRule:!1,trailingNode:!1,...t===`markdown`?{underline:!1}:{},link:{openOnClick:!1,autolink:!1,linkOnPaste:!1,isAllowedUri:e=>d.isSafeLinkUrl(e),HTMLAttributes:{target:null,rel:null}}}),ue.configure({inline:!1,allowBase64:!1}),y.Placeholder.configure({placeholder:e}),...t===`markdown`?f.createMarkdownExtensions(n):[]],fe=(e,t)=>e.isEmpty?``:t===`markdown`?e.getMarkdown():e.getHTML(),pe=(e,t,n)=>n===`markdown`?f.markdownToHtml(e,t):t,me=m.default.memo(({onClick:e,active:t,disabled:n,title:r,tabIndex:i,onFocus:a,buttonRef:o,children:ee})=>(0,g.jsx)(`button`,{ref:o,type:`button`,className:(0,h.default)(p.default.toolbarBtn,t&&p.default.active),onClick:e,onFocus:a,disabled:n,title:r,"aria-label":r,"aria-pressed":t,tabIndex:i,children:ee}));me.displayName=`ToolbarButton`;var he=({value:e,defaultValue:f=``,onChange:v,placeholder:y,disabled:ce,intent:ue=`default`,variant:he=`outline`,fullWidth:b=!1,width:x,minHeight:S=200,label:C,error:w,required:T,layout:ge,className:_e,id:ve,toolbar:E=le,labels:ye={},"aria-label":be,"aria-labelledby":D,onImageUpload:O,format:xe=`html`})=>{let{t:k}=t.useWimTranslation(n.componentsNs),{bold:Se=k(`a11y.rte_bold`),italic:Ce=k(`a11y.rte_italic`),underline:we=k(`a11y.rte_underline`),strikethrough:Te=k(`a11y.rte_strikethrough`),h1:Ee=k(`a11y.rte_h1`),h2:De=k(`a11y.rte_h2`),h3:Oe=k(`a11y.rte_h3`),ul:ke=k(`a11y.rte_ul`),ol:Ae=k(`a11y.rte_ol`),link:je=k(`a11y.rte_link`),unlink:Me=k(`a11y.rte_unlink`),removeFormat:Ne=k(`a11y.rte_remove_format`),toolbar:Pe=k(`a11y.rte_toolbar`),linkPrompt:Fe=k(`a11y.rte_link_prompt`),linkApply:Ie=k(`a11y.rte_link_apply`),linkCancel:Le=k(`a11y.rte_link_cancel`),linkInvalid:Re=k(`a11y.rte_link_invalid`),image:ze=k(`a11y.rte_image`),imageUrl:Be=k(`a11y.rte_image_url`),imageAlt:Ve=k(`a11y.rte_image_alt`),imageAltHint:He=k(`a11y.rte_image_alt_hint`),imageUpload:Ue=k(`a11y.rte_image_upload`),imageUploadFailed:A=k(`a11y.rte_image_upload_failed`),imageInvalid:We=k(`a11y.rte_image_invalid`)}=ye,Ge=m.default.useId(),j=ve||`wim-rte-${Ge}`,M=w?`${j}-error`:void 0,N=C?`${j}-label`:void 0,P=!!ce,F=w?`danger`:ue,Ke=typeof x==`string`&&[`xs`,`sm`,`md`,`lg`,`xl`].includes(x),qe=x!==void 0&&!Ke&&!b,Je=Ke&&!b?x:void 0,Ye=Je?p.default[`width${Je.charAt(0).toUpperCase()}${Je.slice(1)}`]:void 0,I=m.default.useRef(e??f),Xe=m.default.useRef(v);m.default.useEffect(()=>{Xe.current=v},[v]);let Ze=m.default.useMemo(()=>{let e={id:j,class:p.default.content,role:`textbox`,"aria-multiline":`true`,style:`min-height: ${typeof S==`number`?`${S}px`:S}`,tabindex:P?`-1`:`0`},t=be??(C||D?void 0:k(`a11y.rte_editor`)),n=D??(C?N:void 0);return t&&(e[`aria-label`]=t),n&&(e[`aria-labelledby`]=n),F===`danger`&&(e[`aria-invalid`]=`true`),M&&(e[`aria-describedby`]=M),T&&(e[`aria-required`]=`true`),P&&(e[`aria-disabled`]=`true`),y&&(e[`aria-placeholder`]=y),e},[j,S,P,be,C,D,N,F,M,T,y,k]),L=m.default.useRef(O);m.default.useEffect(()=>{L.current=O},[O]);let[Qe,$e]=m.default.useState(void 0),et=m.default.useRef(A);m.default.useEffect(()=>{et.current=A},[A]);let R=m.default.useCallback(async(e,t,n)=>{let r=L.current;if(r){$e(void 0);for(let i of t)try{let t=await r(i);if(!d.isSafeImageUrl(t))throw Error(`URL not allowed`);if(e.isDestroyed)return;let a=e.chain().focus();(n===void 0?a:a.setTextSelection(n)).setImage({src:t,alt:``}).run()}catch{$e(et.current)}}},[]),tt=e=>Array.from(e??[]).filter(e=>e.type.startsWith(`image/`)),z=m.default.useRef({ed:null}),nt=m.default.useCallback((e,t)=>{let n=tt(t.clipboardData?.files),r=z.current.ed;return!L.current||n.length===0||!r?!1:(t.preventDefault(),R(r,n),!0)},[R]),rt=m.default.useCallback((e,t,n,r)=>{let i=tt(t.dataTransfer?.files),a=z.current.ed;if(r||!L.current||i.length===0||!a)return!1;t.preventDefault();let o=e.posAtCoords({left:t.clientX,top:t.clientY});return R(a,i,o?.pos),!0},[R]),B=m.default.useMemo(()=>({attributes:Ze,handlePaste:nt,handleDrop:rt}),[Ze,nt,rt]),[V]=m.default.useState(xe),it=e??f,H=(0,_.useEditor)({extensions:de(y??``,V,V===`markdown`?it:void 0),content:V===`markdown`?``:it,editable:!P,immediatelyRender:!1,editorProps:B,onUpdate:({editor:e})=>{let t=fe(e,V);t!==I.current&&(I.current=t,Xe.current?.(t))}});m.default.useEffect(()=>{H&&!H.isDestroyed&&H.setOptions({editorProps:B})},[H,B]),m.default.useEffect(()=>{z.current.ed=H},[H]),m.default.useEffect(()=>{H&&!H.isDestroyed&&H.setEditable(!P,!1)},[H,P]),m.default.useEffect(()=>{if(!H||H.isDestroyed)return;let e=H.extensionManager.extensions.find(e=>e.name===`placeholder`);e&&e.options.placeholder!==(y??``)&&(e.options.placeholder=y??``,H.view.dispatch(H.state.tr))},[H,y]),m.default.useEffect(()=>{if(!H||H.isDestroyed||e===void 0||e===I.current||e===fe(H,V))return;I.current=e;let t=(0,se.createDocument)(pe(H,e,V),H.schema);t.eq(H.state.doc)||H.commands.setContent(t.toJSON(),{emitUpdate:!1})},[H,e,V]);let at=(0,_.useEditorState)({editor:H,selector:({editor:e})=>({bold:!!e?.isActive(`bold`),italic:!!e?.isActive(`italic`),underline:!!e?.schema.marks.underline&&e.isActive(`underline`),strikethrough:!!e?.isActive(`strike`),h1:!!e?.isActive(`heading`,{level:1}),h2:!!e?.isActive(`heading`,{level:2}),h3:!!e?.isActive(`heading`,{level:3}),ul:!!e?.isActive(`bulletList`),ol:!!e?.isActive(`orderedList`),image:!!e?.isActive(`image`)})}),U=m.default.useCallback(e=>{if(P||!H)return;let t=document.activeElement;e(H),t instanceof HTMLElement&&t.closest(`[role="toolbar"]`)&&requestAnimationFrame(()=>{t.isConnected&&document.activeElement!==t&&t.focus({preventScroll:!0})})},[H,P]),ot=m.default.useCallback(()=>{U(e=>{let{from:t,to:n,empty:r}=e.state.selection,i=e.chain().focus();r&&i.selectAll(),i.unsetBold().unsetItalic().unsetStrike().clearNodes(),e.schema.marks.underline&&i.unsetUnderline(),r&&i.setTextSelection({from:t,to:n}),i.run()})},[U]),[st,W]=m.default.useState(!1),[G,ct]=m.default.useState(`https://`),[lt,K]=m.default.useState(void 0),ut=m.default.useCallback(()=>{if(P||!H)return;let{from:e,to:t}=H.state.selection,n=H.state.doc.textBetween(e,t,` `),r=H.getAttributes(`link`).href;ct(r??(n.startsWith(`http`)?n:`https://`)),K(void 0),W(!0)},[H,P]),dt=m.default.useCallback(()=>{let e=G.trim();if(!e){W(!1);return}if(!d.isSafeLinkUrl(e)){K(Re);return}W(!1),U(t=>{t.state.selection.empty&&!t.isActive(`link`)?t.chain().focus().insertContent({type:`text`,text:e,marks:[{type:`link`,attrs:{href:e}}]}).run():t.chain().focus().extendMarkRange(`link`).setLink({href:e}).run()})},[G,Re,U]),[ft,q]=m.default.useState(!1),[J,Y]=m.default.useState(``),[X,pt]=m.default.useState(``),[mt,Z]=m.default.useState(void 0),[ht,gt]=m.default.useState(!1),_t=m.default.useRef(null),vt=`${j}-image-alt-hint`,yt=m.default.useCallback(()=>{if(P||!H)return;let e=H.isActive(`image`)?H.getAttributes(`image`):{};Y(e.src??``),pt(e.alt??``),Z(void 0),q(!0)},[H,P]),bt=m.default.useCallback(()=>{let e=J.trim();if(!e){q(!1);return}if(!d.isSafeImageUrl(e)){Z(We);return}q(!1),U(t=>t.chain().focus().setImage({src:e,alt:X.trim()}).run())},[J,X,We,U]),xt=m.default.useCallback(async e=>{let t=e.target.files?.[0];if(e.target.value=``,t&&O){gt(!0),Z(void 0);try{let e=await O(t);if(!d.isSafeImageUrl(e))throw Error(`URL not allowed`);Y(e)}catch{Z(A)}finally{gt(!1)}}},[O,A]),St=m.default.useRef([]),[Q,Ct]=m.default.useState(0),$=m.default.useMemo(()=>{let e=V===`markdown`?E.filter(e=>e!==`underline`):E;return e.filter((t,n)=>t!==`separator`||n>0&&n<e.length-1&&e[n-1]!==`separator`)},[E,V]),wt=m.default.useMemo(()=>$.filter(e=>e!==`separator`),[$]),Tt=m.default.useMemo(()=>$.map((e,t)=>e===`separator`?-1:$.slice(0,t).filter(e=>e!==`separator`).length),[$]),Et=m.default.useCallback(e=>{let t=wt.length;if(t===0)return;let n;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(),Ct(n),St.current[n]?.focus())},[wt.length,Q]),Dt=m.default.useCallback(e=>{e.preventDefault()},[]),Ot={bold:{title:Se,icon:(0,g.jsx)(s.Icon,{component:r.default,size:`sm`}),onClick:()=>U(e=>e.chain().focus().toggleBold().run())},italic:{title:Ce,icon:(0,g.jsx)(s.Icon,{component:o.default,size:`sm`}),onClick:()=>U(e=>e.chain().focus().toggleItalic().run())},underline:{title:we,icon:(0,g.jsx)(s.Icon,{component:ie.default,size:`sm`}),onClick:()=>U(e=>e.chain().focus().toggleUnderline().run())},strikethrough:{title:Te,icon:(0,g.jsx)(s.Icon,{component:re.default,size:`sm`}),onClick:()=>U(e=>e.chain().focus().toggleStrike().run())},h1:{title:Ee,icon:(0,g.jsx)(`span`,{"aria-hidden":`true`,children:`H1`}),onClick:()=>U(e=>e.chain().focus().toggleHeading({level:1}).run())},h2:{title:De,icon:(0,g.jsx)(`span`,{"aria-hidden":`true`,children:`H2`}),onClick:()=>U(e=>e.chain().focus().toggleHeading({level:2}).run())},h3:{title:Oe,icon:(0,g.jsx)(`span`,{"aria-hidden":`true`,children:`H3`}),onClick:()=>U(e=>e.chain().focus().toggleHeading({level:3}).run())},ul:{title:ke,icon:(0,g.jsx)(s.Icon,{component:ne.default,size:`sm`}),onClick:()=>U(e=>e.chain().focus().toggleBulletList().run())},ol:{title:Ae,icon:(0,g.jsx)(s.Icon,{component:te.default,size:`sm`}),onClick:()=>U(e=>e.chain().focus().toggleOrderedList().run())},link:{title:je,icon:(0,g.jsx)(s.Icon,{component:ee.default,size:`sm`}),onClick:ut},unlink:{title:Me,icon:(0,g.jsx)(s.Icon,{component:ae.default,size:`sm`}),onClick:()=>U(e=>e.chain().focus().extendMarkRange(`link`).unsetLink().run())},image:{title:ze,icon:(0,g.jsx)(s.Icon,{component:a.default,size:`sm`}),onClick:yt},removeFormat:{title:Ne,icon:(0,g.jsx)(s.Icon,{component:i.default,size:`sm`}),onClick:ot}};return(0,g.jsx)(oe.FieldTemplate,{label:C,error:w,required:T,layout:ge,labelId:N,errorId:M,className:_e,children:(0,g.jsxs)(`div`,{className:(0,h.default)(`wim-rich-text-editor`,p.default.root,p.default[F],P&&p.default.disabled,p.default[he],b&&p.default.fullWidth,qe&&p.default.hasCustomWidth,Ye),style:qe?{"--wim-input-width":typeof x==`number`?`${x}px`:x}:void 0,children:[(0,g.jsx)(`div`,{className:p.default.toolbar,role:`toolbar`,"aria-label":Pe,"aria-controls":j,onMouseDown:Dt,onKeyDown:Et,children:$.map((e,t)=>{if(e===`separator`)return(0,g.jsx)(`span`,{className:p.default.toolbarSep,"aria-hidden":`true`},`sep-${t}`);let n=Tt[t],r=Ot[e],i=e===`link`||e===`unlink`||e===`removeFormat`?void 0:at?.[e]??!1;return(0,g.jsx)(me,{buttonRef:e=>{St.current[n]=e},tabIndex:n===Math.min(Q,wt.length-1)?0:-1,onFocus:()=>Ct(n),disabled:P,active:i,title:r.title,onClick:r.onClick,children:r.icon},`${e}-${t}`)})}),(0,g.jsx)(_.EditorContent,{editor:H,className:p.default.contentHost}),Qe&&(0,g.jsx)(`p`,{role:`alert`,className:p.default.uploadError,children:Qe}),(0,g.jsx)(u.Dialog,{open:st,onOpenChange:W,children:(0,g.jsxs)(u.DialogContent,{children:[(0,g.jsx)(u.DialogHeader,{children:(0,g.jsx)(u.DialogTitle,{children:je})}),(0,g.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),dt()},children:[(0,g.jsx)(l.Input,{label:Fe,type:`url`,value:G,error:lt,onChange:e=>{ct(e.target.value),K(void 0)},fullWidth:!0}),(0,g.jsxs)(u.DialogFooter,{children:[(0,g.jsx)(u.DialogClose,{asChild:!0,children:(0,g.jsx)(c.Button,{variant:`ghost`,type:`button`,children:Le})}),(0,g.jsx)(c.Button,{variant:`solid`,type:`submit`,children:Ie})]})]})]})}),(0,g.jsx)(u.Dialog,{open:ft,onOpenChange:q,children:(0,g.jsxs)(u.DialogContent,{children:[(0,g.jsx)(u.DialogHeader,{children:(0,g.jsx)(u.DialogTitle,{children:ze})}),(0,g.jsxs)(`form`,{className:p.default.imageForm,onSubmit:e=>{e.preventDefault(),bt()},children:[(0,g.jsx)(l.Input,{label:Be,type:`url`,value:J,error:mt,onChange:e=>{Y(e.target.value),Z(void 0)},fullWidth:!0}),O&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(`input`,{ref:_t,type:`file`,accept:`image/*`,hidden:!0,onChange:xt}),(0,g.jsx)(c.Button,{type:`button`,variant:`outline`,loading:ht,onClick:()=>_t.current?.click(),children:Ue})]}),(0,g.jsxs)(`div`,{children:[(0,g.jsx)(l.Input,{label:Ve,"aria-describedby":vt,value:X,onChange:e=>pt(e.target.value),fullWidth:!0}),(0,g.jsx)(`p`,{id:vt,className:p.default.imageHint,children:He})]}),(0,g.jsxs)(u.DialogFooter,{children:[(0,g.jsx)(u.DialogClose,{asChild:!0,children:(0,g.jsx)(c.Button,{variant:`ghost`,type:`button`,children:Le})}),(0,g.jsx)(c.Button,{variant:`solid`,type:`submit`,disabled:ht,children:Ie})]})]})]})})]})})};he.displayName=`RichTextEditor`,exports.RichTextEditor=he;
|
|
@@ -219,7 +219,11 @@ var y = ({ value: d, defaultValue: f = "", onChange: _, placeholder: v, disabled
|
|
|
219
219
|
image: !!e?.isActive("image")
|
|
220
220
|
})
|
|
221
221
|
}), U = m.useCallback((e) => {
|
|
222
|
-
|
|
222
|
+
if (N || !H) return;
|
|
223
|
+
let t = document.activeElement;
|
|
224
|
+
e(H), t instanceof HTMLElement && t.closest("[role=\"toolbar\"]") && requestAnimationFrame(() => {
|
|
225
|
+
t.isConnected && document.activeElement !== t && t.focus({ preventScroll: !0 });
|
|
226
|
+
});
|
|
223
227
|
}, [H, N]), gt = m.useCallback(() => {
|
|
224
228
|
U((e) => {
|
|
225
229
|
let { from: t, to: n, empty: r } = e.state.selection, i = e.chain().focus();
|
package/dist/llms-full.txt
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
## What this is
|
|
6
6
|
|
|
7
|
-
**wimui** v0.64.
|
|
7
|
+
**wimui** v0.64.2 — a React 19 component library: 228 documented components across 10 categories, with design tokens, dark mode, i18n (en/ja/pt-BR) and WAI-ARIA compliant a11y. Peer deps: react ^19, react-dom ^19 (plus optional peers for specific components — see package.json).
|
|
8
8
|
|
|
9
9
|
## Install & required setup
|
|
10
10
|
|
package/dist/llms.txt
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
## What this is
|
|
6
6
|
|
|
7
|
-
**wimui** v0.64.
|
|
7
|
+
**wimui** v0.64.2 — a React 19 component library: 228 documented components across 10 categories, with design tokens, dark mode, i18n (en/ja/pt-BR) and WAI-ARIA compliant a11y. Peer deps: react ^19, react-dom ^19 (plus optional peers for specific components — see package.json).
|
|
8
8
|
|
|
9
9
|
## Install & required setup
|
|
10
10
|
|