wimui 0.58.1 → 0.60.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/ai/PromptInput/PromptInput.cjs +1 -1
- package/dist/components/ai/PromptInput/PromptInput.js +30 -30
- package/dist/components/ai/SourceCitation/SourceCitation.cjs +1 -1
- package/dist/components/ai/SourceCitation/SourceCitation.d.ts +5 -1
- package/dist/components/ai/SourceCitation/SourceCitation.js +10 -8
- package/dist/components/ai/Terminal/Terminal.cjs +2 -2
- package/dist/components/ai/Terminal/Terminal.js +16 -14
- package/dist/components/data-display/DataGrid/DataGrid.cjs +1 -1
- package/dist/components/data-display/DataGrid/DataGrid.d.ts +5 -1
- package/dist/components/data-display/DataGrid/DataGrid.js +54 -53
- package/dist/components/data-display/FAQSection/FAQSection.cjs +1 -1
- package/dist/components/data-display/FAQSection/FAQSection.d.ts +5 -1
- package/dist/components/data-display/FAQSection/FAQSection.js +5 -3
- package/dist/components/data-display/TreeView/TreeView.cjs +1 -1
- package/dist/components/data-display/TreeView/TreeView.d.ts +5 -1
- package/dist/components/data-display/TreeView/TreeView.js +87 -87
- package/dist/components/data-display/VirtualList/VirtualList.cjs +1 -1
- package/dist/components/data-display/VirtualList/VirtualList.d.ts +2 -0
- package/dist/components/data-display/VirtualList/VirtualList.js +15 -14
- package/dist/components/feedback/Notification/Notification.cjs +1 -1
- package/dist/components/feedback/Notification/Notification.d.ts +5 -1
- package/dist/components/feedback/Notification/Notification.js +10 -8
- package/dist/components/feedback/Toast/Toast.cjs +1 -1
- package/dist/components/feedback/Toast/Toast.d.ts +5 -1
- package/dist/components/feedback/Toast/Toast.js +11 -9
- package/dist/components/form/CopyButton/CopyButton.cjs +1 -1
- package/dist/components/form/CopyButton/CopyButton.d.ts +5 -1
- package/dist/components/form/CopyButton/CopyButton.js +17 -15
- package/dist/components/form/Dropzone/Dropzone.cjs +1 -1
- package/dist/components/form/Dropzone/Dropzone.d.ts +7 -1
- package/dist/components/form/Dropzone/Dropzone.js +29 -28
- package/dist/components/form/FileUpload/FileUpload.cjs +1 -1
- package/dist/components/form/FileUpload/FileUpload.d.ts +7 -1
- package/dist/components/form/FileUpload/FileUpload.js +22 -17
- package/dist/components/form/ImageCropper/ImageCropper.cjs +1 -1
- package/dist/components/form/ImageCropper/ImageCropper.js +102 -100
- package/dist/components/form/QueryBuilder/QueryBuilder.cjs +1 -1
- package/dist/components/form/QueryBuilder/QueryBuilder.d.ts +7 -1
- package/dist/components/form/QueryBuilder/QueryBuilder.js +104 -102
- package/dist/components/form/SignaturePad/SignaturePad.cjs +1 -1
- package/dist/components/form/SignaturePad/SignaturePad.d.ts +5 -1
- package/dist/components/form/SignaturePad/SignaturePad.js +47 -47
- package/dist/components/form/ThemeToggle/ThemeToggle.cjs +1 -1
- package/dist/components/form/ThemeToggle/ThemeToggle.js +59 -54
- package/dist/components/media/ImageCompare/ImageCompare.cjs +1 -1
- package/dist/components/media/ImageCompare/ImageCompare.js +33 -31
- package/dist/components/navigation/BackTop/BackTop.cjs +1 -1
- package/dist/components/navigation/BackTop/BackTop.d.ts +4 -0
- package/dist/components/navigation/BackTop/BackTop.js +18 -16
- package/dist/components/navigation/CommandPalette/CommandPalette.cjs +1 -1
- package/dist/components/navigation/CommandPalette/CommandPalette.d.ts +5 -1
- package/dist/components/navigation/CommandPalette/CommandPalette.js +11 -6
- package/dist/components/navigation/Pagination/Pagination.cjs +1 -1
- package/dist/components/navigation/Pagination/Pagination.d.ts +5 -1
- package/dist/components/navigation/Pagination/Pagination.js +65 -63
- package/dist/components/overlay/Menu/Menu.cjs +1 -1
- package/dist/components/overlay/Menu/Menu.d.ts +4 -0
- package/dist/components/overlay/Menu/Menu.js +23 -21
- package/dist/llms-full.txt +33 -1
- package/dist/llms.txt +1 -1
- package/dist/wimui.umd.js +4 -4
- package/package.json +1 -1
|
@@ -37,11 +37,15 @@ export type ToastProps = {
|
|
|
37
37
|
* Additional CSS class name.
|
|
38
38
|
*/
|
|
39
39
|
className?: string;
|
|
40
|
+
/** Accessible name for the toast. */
|
|
41
|
+
"aria-label"?: string;
|
|
42
|
+
/** ID of the element that labels the toast. Takes precedence over `aria-label`. */
|
|
43
|
+
"aria-labelledby"?: string;
|
|
40
44
|
};
|
|
41
45
|
/**
|
|
42
46
|
* Toast for communicating notifications and feedback to the user.
|
|
43
47
|
*/
|
|
44
|
-
export declare const Toast: ({ id, title, description, intent, duration, open, onClose, className, }: ToastProps) => React.JSX.Element;
|
|
48
|
+
export declare const Toast: ({ id, title, description, intent, duration, open, onClose, className, "aria-label": ariaLabelAttr, "aria-labelledby": ariaLabelledBy, }: ToastProps) => React.JSX.Element;
|
|
45
49
|
type ToastItem = {
|
|
46
50
|
id: string;
|
|
47
51
|
title?: string;
|
|
@@ -7,14 +7,14 @@ import { createContext as i, useCallback as a, useContext as o, useEffect as s,
|
|
|
7
7
|
import l from "classnames";
|
|
8
8
|
import { jsx as u, jsxs as d } from "react/jsx-runtime";
|
|
9
9
|
//#region src/components/feedback/Toast/Toast.tsx
|
|
10
|
-
var f = ({ id: i, title: o, description: f, intent: p = "default", duration: m = 3e3, open: h = !0, onClose: g, className: _ }) => {
|
|
11
|
-
let [
|
|
12
|
-
|
|
10
|
+
var f = ({ id: i, title: o, description: f, intent: p = "default", duration: m = 3e3, open: h = !0, onClose: g, className: _, "aria-label": v, "aria-labelledby": y }) => {
|
|
11
|
+
let [b, x] = c(!0), S = a(() => {
|
|
12
|
+
x(!1), g && g(i);
|
|
13
13
|
}, [g, i]);
|
|
14
14
|
return s(() => {
|
|
15
|
-
if (h && m > 0 &&
|
|
15
|
+
if (h && m > 0 && b) {
|
|
16
16
|
let e = setTimeout(() => {
|
|
17
|
-
|
|
17
|
+
S();
|
|
18
18
|
}, m + 300);
|
|
19
19
|
return () => clearTimeout(e);
|
|
20
20
|
}
|
|
@@ -23,10 +23,10 @@ var f = ({ id: i, title: o, description: f, intent: p = "default", duration: m =
|
|
|
23
23
|
m,
|
|
24
24
|
i,
|
|
25
25
|
g,
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
b,
|
|
27
|
+
S
|
|
28
28
|
]), /* @__PURE__ */ d(e, {
|
|
29
|
-
show: h &&
|
|
29
|
+
show: h && b,
|
|
30
30
|
enter: r.enter,
|
|
31
31
|
enterFrom: r.enterFrom,
|
|
32
32
|
enterTo: r.enterTo,
|
|
@@ -36,6 +36,8 @@ var f = ({ id: i, title: o, description: f, intent: p = "default", duration: m =
|
|
|
36
36
|
className: l("wim-toast", r.root, r[p], _),
|
|
37
37
|
role: "status",
|
|
38
38
|
"aria-live": "polite",
|
|
39
|
+
"aria-label": y ? void 0 : v,
|
|
40
|
+
"aria-labelledby": y,
|
|
39
41
|
children: [
|
|
40
42
|
(p === "success" || p === "warning" || p === "danger" || p === "info") && /* @__PURE__ */ u("div", {
|
|
41
43
|
className: r.icon,
|
|
@@ -55,7 +57,7 @@ var f = ({ id: i, title: o, description: f, intent: p = "default", duration: m =
|
|
|
55
57
|
})]
|
|
56
58
|
}),
|
|
57
59
|
/* @__PURE__ */ u(n, {
|
|
58
|
-
onClose: g ?
|
|
60
|
+
onClose: g ? S : void 0,
|
|
59
61
|
id: i,
|
|
60
62
|
className: r.closeButton,
|
|
61
63
|
size: "md"
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../i18n/useWimTranslation.cjs"),n=require("../../../i18n/generated/common.cjs"),r=require("../Button/Button.cjs"),i=require("../../overlay/Tooltip/Tooltip.cjs");let a=require("react");a=e.__toESM(a,1);let o=require("classnames");o=e.__toESM(o,1);let s=require("react/jsx-runtime");var c=({value:e,size:c=`md`,className:l,"aria-label":u,
|
|
2
|
+
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../i18n/useWimTranslation.cjs"),n=require("../../../i18n/generated/common.cjs"),r=require("../Button/Button.cjs"),i=require("../../overlay/Tooltip/Tooltip.cjs");let a=require("react");a=e.__toESM(a,1);let o=require("classnames");o=e.__toESM(o,1);let s=require("react/jsx-runtime");var c=({value:e,size:c=`md`,className:l,"aria-label":u,"aria-labelledby":d,"aria-describedby":f,copyLabel:p,copiedLabel:m,asChild:h=!1,children:g})=>{let{t:_}=t.useWimTranslation(n.commonNs),[v,y]=(0,a.useState)(!1);(0,a.useEffect)(()=>{if(v){let e=setTimeout(()=>{y(!1)},2e3);return()=>clearTimeout(e)}},[v]);let b=async()=>{try{await navigator.clipboard.writeText(e),y(!0)}catch{}},x=v?m??_(`copied`):p??_(`copy.to_clipboard`);return(0,s.jsxs)(i.Tooltip,{children:[(0,s.jsx)(i.TooltipTrigger,{asChild:!0,children:(0,s.jsx)(r.Button,{asChild:h,variant:`ghost`,size:c,icon:h?void 0:v?`CheckIcon`:`CopyIcon`,intent:v?`success`:`default`,onClick:b,className:(0,o.default)(`wim-copy-button`,l),"aria-label":u||x,"aria-labelledby":d,"aria-describedby":f,children:h?g:void 0})}),(0,s.jsx)(i.TooltipContent,{children:x})]})};exports.CopyButton=c;
|
|
@@ -9,6 +9,10 @@ type CopyButtonProps = {
|
|
|
9
9
|
className?: string;
|
|
10
10
|
/** Accessible label for the button */
|
|
11
11
|
"aria-label"?: string;
|
|
12
|
+
/** ID of the element that labels the button. Takes precedence over `aria-label`. */
|
|
13
|
+
"aria-labelledby"?: string;
|
|
14
|
+
/** ID of the element that describes the button. */
|
|
15
|
+
"aria-describedby"?: string;
|
|
12
16
|
/** Tooltip label before copying */
|
|
13
17
|
copyLabel?: string;
|
|
14
18
|
/** Tooltip label after copying */
|
|
@@ -18,5 +22,5 @@ type CopyButtonProps = {
|
|
|
18
22
|
/** Trigger content when `asChild` is true */
|
|
19
23
|
children?: React.ReactNode;
|
|
20
24
|
};
|
|
21
|
-
export declare const CopyButton: ({ value, size, className, "aria-label": ariaLabel, copyLabel, copiedLabel, asChild, children, }: CopyButtonProps) => React.JSX.Element;
|
|
25
|
+
export declare const CopyButton: ({ value, size, className, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, copyLabel, copiedLabel, asChild, children, }: CopyButtonProps) => React.JSX.Element;
|
|
22
26
|
export {};
|
|
@@ -7,35 +7,37 @@ import { useEffect as o, useState as s } from "react";
|
|
|
7
7
|
import c from "classnames";
|
|
8
8
|
import { jsx as l, jsxs as u } from "react/jsx-runtime";
|
|
9
9
|
//#region src/components/form/CopyButton/CopyButton.tsx
|
|
10
|
-
var d = ({ value: d, size: f = "md", className: p, "aria-label": m,
|
|
11
|
-
let { t:
|
|
10
|
+
var d = ({ value: d, size: f = "md", className: p, "aria-label": m, "aria-labelledby": h, "aria-describedby": g, copyLabel: _, copiedLabel: v, asChild: y = !1, children: b }) => {
|
|
11
|
+
let { t: x } = e(t), [S, C] = s(!1);
|
|
12
12
|
o(() => {
|
|
13
|
-
if (
|
|
13
|
+
if (S) {
|
|
14
14
|
let e = setTimeout(() => {
|
|
15
|
-
|
|
15
|
+
C(!1);
|
|
16
16
|
}, 2e3);
|
|
17
17
|
return () => clearTimeout(e);
|
|
18
18
|
}
|
|
19
|
-
}, [
|
|
20
|
-
let
|
|
19
|
+
}, [S]);
|
|
20
|
+
let w = async () => {
|
|
21
21
|
try {
|
|
22
|
-
await navigator.clipboard.writeText(d),
|
|
22
|
+
await navigator.clipboard.writeText(d), C(!0);
|
|
23
23
|
} catch {}
|
|
24
|
-
},
|
|
24
|
+
}, T = S ? v ?? x("copied") : _ ?? x("copy.to_clipboard");
|
|
25
25
|
return /* @__PURE__ */ u(r, { children: [/* @__PURE__ */ l(a, {
|
|
26
26
|
asChild: !0,
|
|
27
27
|
children: /* @__PURE__ */ l(n, {
|
|
28
|
-
asChild:
|
|
28
|
+
asChild: y,
|
|
29
29
|
variant: "ghost",
|
|
30
30
|
size: f,
|
|
31
|
-
icon:
|
|
32
|
-
intent:
|
|
33
|
-
onClick:
|
|
31
|
+
icon: y ? void 0 : S ? "CheckIcon" : "CopyIcon",
|
|
32
|
+
intent: S ? "success" : "default",
|
|
33
|
+
onClick: w,
|
|
34
34
|
className: c("wim-copy-button", p),
|
|
35
|
-
"aria-label": m ||
|
|
36
|
-
|
|
35
|
+
"aria-label": m || T,
|
|
36
|
+
"aria-labelledby": h,
|
|
37
|
+
"aria-describedby": g,
|
|
38
|
+
children: y ? b : void 0
|
|
37
39
|
})
|
|
38
|
-
}), /* @__PURE__ */ l(i, { children:
|
|
40
|
+
}), /* @__PURE__ */ l(i, { children: T })] });
|
|
39
41
|
};
|
|
40
42
|
//#endregion
|
|
41
43
|
export { d as CopyButton };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../layout/InteractiveArea/InteractiveArea.cjs"),n=require("../../../i18n/useWimTranslation.cjs"),r=require("../../media/Icon/Icon.cjs"),i=require("../../../i18n/generated/form.cjs"),a=require("../FieldTemplate/FieldTemplate.cjs"),o=require("./dropzone.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=({label:e,description:u,accept:d,multiple:f=!1,disabled:p=!1,value:m,onChange:h,className:g,iconName:_=`UploadIcon`,error:v,required:y,layout:b=`vertical`,size:x=`md
|
|
2
|
+
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../layout/InteractiveArea/InteractiveArea.cjs"),n=require("../../../i18n/useWimTranslation.cjs"),r=require("../../media/Icon/Icon.cjs"),i=require("../../../i18n/generated/form.cjs"),a=require("../FieldTemplate/FieldTemplate.cjs"),o=require("./dropzone.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=({label:e,description:u,accept:d,multiple:f=!1,disabled:p=!1,value:m,onChange:h,className:g,iconName:_=`UploadIcon`,error:v,required:y,layout:b=`vertical`,size:x=`md`,"aria-label":S,"aria-labelledby":C,"aria-describedby":w})=>{let{t:T}=n.useWimTranslation(i.formNs),E=u??T(`dropzone.description`),D=`wim-dropzone-${s.default.useId()}`,O=e?`${D}-label`:void 0,k=v?`${D}-error`:void 0,A=(0,s.useRef)(null),[j,M]=(0,s.useState)(!1),[N,P]=(0,s.useState)(null),F=()=>{p||A.current?.click()},I=e=>{e.preventDefault(),!p&&M(!0)},L=()=>{M(!1)},R=e=>{if(e.preventDefault(),M(!1),p)return;let t=e.dataTransfer.files;P(t),h&&h(t)},z=e=>{let t=e.target.files;P(t),h&&h(t)},B=m===void 0?N?Array.from(N).map(e=>e.name):[]:m;return(0,l.jsxs)(a.FieldTemplate,{label:e,error:v,required:y,layout:b,labelId:O,errorId:k,className:(0,c.default)(`wim-dropzone`,o.default.container,g),children:[(0,l.jsx)(`input`,{type:`file`,ref:A,accept:d,multiple:f,disabled:p,onChange:z,style:{display:`none`},"aria-hidden":`true`,tabIndex:-1}),(0,l.jsx)(t.InteractiveArea,{size:x,isDragging:j,disabled:p,isClickable:!p,onClick:F,onDragOver:I,onDragLeave:L,onDrop:R,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&F()},"aria-labelledby":O??C,"aria-label":O||C?void 0:S,"aria-describedby":[w,k].filter(Boolean).join(` `)||void 0,"aria-required":y,"aria-invalid":!!v,icon:_&&(0,l.jsx)(r.Icon,{name:_,color:p?`disabled`:`primary`}),description:E,children:B.length>0?(0,l.jsx)(`div`,{className:o.default.fileList,children:B.map((e,t)=>(0,l.jsx)(`span`,{className:o.default.fileName,children:e},t))}):null})]})};exports.Dropzone=u;
|
|
@@ -35,9 +35,15 @@ type DropzoneProps = {
|
|
|
35
35
|
layout?: "vertical" | "horizontal";
|
|
36
36
|
/** Size of the drop area */
|
|
37
37
|
size?: InteractiveAreaProps["size"];
|
|
38
|
+
/** Accessible name for the drop area when no visible `label` is provided. */
|
|
39
|
+
"aria-label"?: string;
|
|
40
|
+
/** ID of the element that labels the drop area when no visible `label` is provided. */
|
|
41
|
+
"aria-labelledby"?: string;
|
|
42
|
+
/** ID of the element that describes the drop area. Announced together with the error message. */
|
|
43
|
+
"aria-describedby"?: string;
|
|
38
44
|
};
|
|
39
45
|
/**
|
|
40
46
|
* Component for uploading files by drag and drop or by clicking.
|
|
41
47
|
*/
|
|
42
|
-
export declare const Dropzone: ({ label, description, accept, multiple, disabled, value, onChange, className, iconName, error, required, layout, size, }: DropzoneProps) => React.JSX.Element;
|
|
48
|
+
export declare const Dropzone: ({ label, description, accept, multiple, disabled, value, onChange, className, iconName, error, required, layout, size, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, }: DropzoneProps) => React.JSX.Element;
|
|
43
49
|
export {};
|
|
@@ -9,63 +9,64 @@ import o, { useRef as s, useState as c } from "react";
|
|
|
9
9
|
import l from "classnames";
|
|
10
10
|
import { jsx as u, jsxs as d } from "react/jsx-runtime";
|
|
11
11
|
//#region src/components/form/Dropzone/Dropzone.tsx
|
|
12
|
-
var f = ({ label: f, description: p, accept: m, multiple: h = !1, disabled: g = !1, value: _, onChange: v, className: y, iconName: b = "UploadIcon", error: x, required: S, layout: C = "vertical", size: w = "md" }) => {
|
|
13
|
-
let { t:
|
|
14
|
-
g ||
|
|
15
|
-
}, I = (e) => {
|
|
16
|
-
e.preventDefault(), !g && M(!0);
|
|
17
|
-
}, L = () => {
|
|
18
|
-
M(!1);
|
|
19
|
-
}, R = (e) => {
|
|
20
|
-
if (e.preventDefault(), M(!1), g) return;
|
|
21
|
-
let t = e.dataTransfer.files;
|
|
22
|
-
P(t), v && v(t);
|
|
12
|
+
var f = ({ label: f, description: p, accept: m, multiple: h = !1, disabled: g = !1, value: _, onChange: v, className: y, iconName: b = "UploadIcon", error: x, required: S, layout: C = "vertical", size: w = "md", "aria-label": T, "aria-labelledby": E, "aria-describedby": D }) => {
|
|
13
|
+
let { t: O } = t(r), k = p ?? O("dropzone.description"), A = `wim-dropzone-${o.useId()}`, j = f ? `${A}-label` : void 0, M = x ? `${A}-error` : void 0, N = s(null), [P, F] = c(!1), [I, L] = c(null), R = () => {
|
|
14
|
+
g || N.current?.click();
|
|
23
15
|
}, z = (e) => {
|
|
16
|
+
e.preventDefault(), !g && F(!0);
|
|
17
|
+
}, B = () => {
|
|
18
|
+
F(!1);
|
|
19
|
+
}, V = (e) => {
|
|
20
|
+
if (e.preventDefault(), F(!1), g) return;
|
|
21
|
+
let t = e.dataTransfer.files;
|
|
22
|
+
L(t), v && v(t);
|
|
23
|
+
}, H = (e) => {
|
|
24
24
|
let t = e.target.files;
|
|
25
|
-
|
|
26
|
-
},
|
|
25
|
+
L(t), v && v(t);
|
|
26
|
+
}, U = _ === void 0 ? I ? Array.from(I).map((e) => e.name) : [] : _;
|
|
27
27
|
return /* @__PURE__ */ d(i, {
|
|
28
28
|
label: f,
|
|
29
29
|
error: x,
|
|
30
30
|
required: S,
|
|
31
31
|
layout: C,
|
|
32
|
-
labelId:
|
|
33
|
-
errorId:
|
|
32
|
+
labelId: j,
|
|
33
|
+
errorId: M,
|
|
34
34
|
className: l("wim-dropzone", a.container, y),
|
|
35
35
|
children: [/* @__PURE__ */ u("input", {
|
|
36
36
|
type: "file",
|
|
37
|
-
ref:
|
|
37
|
+
ref: N,
|
|
38
38
|
accept: m,
|
|
39
39
|
multiple: h,
|
|
40
40
|
disabled: g,
|
|
41
|
-
onChange:
|
|
41
|
+
onChange: H,
|
|
42
42
|
style: { display: "none" },
|
|
43
43
|
"aria-hidden": "true",
|
|
44
44
|
tabIndex: -1
|
|
45
45
|
}), /* @__PURE__ */ u(e, {
|
|
46
46
|
size: w,
|
|
47
|
-
isDragging:
|
|
47
|
+
isDragging: P,
|
|
48
48
|
disabled: g,
|
|
49
49
|
isClickable: !g,
|
|
50
|
-
onClick:
|
|
51
|
-
onDragOver:
|
|
52
|
-
onDragLeave:
|
|
53
|
-
onDrop:
|
|
50
|
+
onClick: R,
|
|
51
|
+
onDragOver: z,
|
|
52
|
+
onDragLeave: B,
|
|
53
|
+
onDrop: V,
|
|
54
54
|
onKeyDown: (e) => {
|
|
55
|
-
(e.key === "Enter" || e.key === " ") &&
|
|
55
|
+
(e.key === "Enter" || e.key === " ") && R();
|
|
56
56
|
},
|
|
57
|
-
"aria-labelledby":
|
|
58
|
-
"aria-
|
|
57
|
+
"aria-labelledby": j ?? E,
|
|
58
|
+
"aria-label": j || E ? void 0 : T,
|
|
59
|
+
"aria-describedby": [D, M].filter(Boolean).join(" ") || void 0,
|
|
59
60
|
"aria-required": S,
|
|
60
61
|
"aria-invalid": !!x,
|
|
61
62
|
icon: b && /* @__PURE__ */ u(n, {
|
|
62
63
|
name: b,
|
|
63
64
|
color: g ? "disabled" : "primary"
|
|
64
65
|
}),
|
|
65
|
-
description:
|
|
66
|
-
children:
|
|
66
|
+
description: k,
|
|
67
|
+
children: U.length > 0 ? /* @__PURE__ */ u("div", {
|
|
67
68
|
className: a.fileList,
|
|
68
|
-
children:
|
|
69
|
+
children: U.map((e, t) => /* @__PURE__ */ u("span", {
|
|
69
70
|
className: a.fileName,
|
|
70
71
|
children: e
|
|
71
72
|
}, t))
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../i18n/useWimTranslation.cjs"),n=require("../../layout/VisuallyHidden/VisuallyHidden.cjs"),r=require("../Button/Button.cjs"),i=require("../../../i18n/generated/form.cjs"),a=require("../FieldTemplate/FieldTemplate.cjs"),o=require("./file-upload.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=({label:e,buttonLabel:u,noFileLabel:d,accept:f,multiple:p=!1,disabled:m=!1,value:h,onChange:g,className:_,iconName:v,iconPosition:y,size:b=`md`,error:x,required:S,layout:C=`vertical
|
|
2
|
+
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../i18n/useWimTranslation.cjs"),n=require("../../layout/VisuallyHidden/VisuallyHidden.cjs"),r=require("../Button/Button.cjs"),i=require("../../../i18n/generated/form.cjs"),a=require("../FieldTemplate/FieldTemplate.cjs"),o=require("./file-upload.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=({label:e,buttonLabel:u,noFileLabel:d,accept:f,multiple:p=!1,disabled:m=!1,value:h,onChange:g,className:_,iconName:v,iconPosition:y,size:b=`md`,error:x,required:S,layout:C=`vertical`,"aria-label":w,"aria-labelledby":T,"aria-describedby":E})=>{let{t:D}=t.useWimTranslation(i.formNs),O=`wim-fileupload-${s.default.useId()}`,k=e?`${O}-label`:void 0,A=x?`${O}-error`:void 0,j=S?`${O}-required`:void 0,M=[E,A,j].filter(Boolean).join(` `)||void 0,N=(0,s.useRef)(null),[P,F]=(0,s.useState)(null),I=()=>{N.current?.click()},L=e=>{let t=e.target.files;F(t),g&&g(t)},R=h===void 0?P?Array.from(P).map(e=>e.name):[]:h,z=R.length>0?R.join(`, `):d??D(`fileupload.no_file`);return(0,l.jsx)(a.FieldTemplate,{label:e,error:x,required:S,layout:C,labelId:k,errorId:A,className:(0,c.default)(`wim-file-upload`,o.default.root,o.default[b],_),children:(0,l.jsxs)(`div`,{className:o.default.controls,children:[(0,l.jsx)(`input`,{type:`file`,ref:N,accept:f,multiple:p,disabled:m,onChange:L,className:o.default.input,"aria-hidden":`true`,tabIndex:-1}),(0,l.jsx)(r.Button,{onClick:I,disabled:m,variant:`outline`,icon:v,iconPosition:y,size:b,"aria-labelledby":k??T,"aria-label":k||T?void 0:w,"aria-describedby":M,"aria-invalid":x?!0:void 0,children:u??D(`fileupload.button`)}),S&&(0,l.jsx)(n.VisuallyHidden,{id:j,children:D(`form.required`)}),(0,l.jsx)(`span`,{className:(0,c.default)(o.default.fileNames,o.default[b],m&&o.default.disabled),"aria-disabled":m||void 0,children:z})]})})};exports.FileUpload=u;
|
|
@@ -39,9 +39,15 @@ type FileUploadProps = {
|
|
|
39
39
|
required?: boolean;
|
|
40
40
|
/** Layout direction of label and field */
|
|
41
41
|
layout?: "vertical" | "horizontal";
|
|
42
|
+
/** Accessible name for the choose-file button when no visible `label` is provided. */
|
|
43
|
+
"aria-label"?: string;
|
|
44
|
+
/** ID of the element that labels the choose-file button when no visible `label` is provided. */
|
|
45
|
+
"aria-labelledby"?: string;
|
|
46
|
+
/** ID of the element that describes the choose-file button. Announced together with the error message. */
|
|
47
|
+
"aria-describedby"?: string;
|
|
42
48
|
};
|
|
43
49
|
/**
|
|
44
50
|
* Component for selecting and uploading files.
|
|
45
51
|
*/
|
|
46
|
-
export declare const FileUpload: ({ label, buttonLabel, noFileLabel, accept, multiple, disabled, value, onChange, className, iconName, iconPosition, size, error, required, layout, }: FileUploadProps) => React.JSX.Element;
|
|
52
|
+
export declare const FileUpload: ({ label, buttonLabel, noFileLabel, accept, multiple, disabled, value, onChange, className, iconName, iconPosition, size, error, required, layout, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, }: FileUploadProps) => React.JSX.Element;
|
|
47
53
|
export {};
|
|
@@ -9,55 +9,60 @@ import o, { useRef as s, useState as c } from "react";
|
|
|
9
9
|
import l from "classnames";
|
|
10
10
|
import { jsx as u, jsxs as d } from "react/jsx-runtime";
|
|
11
11
|
//#region src/components/form/FileUpload/FileUpload.tsx
|
|
12
|
-
var f = ({ label: f, buttonLabel: p, noFileLabel: m, accept: h, multiple: g = !1, disabled: _ = !1, value: v, onChange: y, className: b, iconName: x, iconPosition: S, size: C = "md", error: w, required: T, layout: E = "vertical" }) => {
|
|
13
|
-
let { t:
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
var f = ({ label: f, buttonLabel: p, noFileLabel: m, accept: h, multiple: g = !1, disabled: _ = !1, value: v, onChange: y, className: b, iconName: x, iconPosition: S, size: C = "md", error: w, required: T, layout: E = "vertical", "aria-label": D, "aria-labelledby": O, "aria-describedby": k }) => {
|
|
13
|
+
let { t: A } = e(r), j = `wim-fileupload-${o.useId()}`, M = f ? `${j}-label` : void 0, N = w ? `${j}-error` : void 0, P = T ? `${j}-required` : void 0, F = [
|
|
14
|
+
k,
|
|
15
|
+
N,
|
|
16
|
+
P
|
|
17
|
+
].filter(Boolean).join(" ") || void 0, I = s(null), [L, R] = c(null), z = () => {
|
|
18
|
+
I.current?.click();
|
|
19
|
+
}, B = (e) => {
|
|
16
20
|
let t = e.target.files;
|
|
17
|
-
|
|
18
|
-
},
|
|
21
|
+
R(t), y && y(t);
|
|
22
|
+
}, V = v === void 0 ? L ? Array.from(L).map((e) => e.name) : [] : v, H = V.length > 0 ? V.join(", ") : m ?? A("fileupload.no_file");
|
|
19
23
|
return /* @__PURE__ */ u(i, {
|
|
20
24
|
label: f,
|
|
21
25
|
error: w,
|
|
22
26
|
required: T,
|
|
23
27
|
layout: E,
|
|
24
|
-
labelId:
|
|
25
|
-
errorId:
|
|
28
|
+
labelId: M,
|
|
29
|
+
errorId: N,
|
|
26
30
|
className: l("wim-file-upload", a.root, a[C], b),
|
|
27
31
|
children: /* @__PURE__ */ d("div", {
|
|
28
32
|
className: a.controls,
|
|
29
33
|
children: [
|
|
30
34
|
/* @__PURE__ */ u("input", {
|
|
31
35
|
type: "file",
|
|
32
|
-
ref:
|
|
36
|
+
ref: I,
|
|
33
37
|
accept: h,
|
|
34
38
|
multiple: g,
|
|
35
39
|
disabled: _,
|
|
36
|
-
onChange:
|
|
40
|
+
onChange: B,
|
|
37
41
|
className: a.input,
|
|
38
42
|
"aria-hidden": "true",
|
|
39
43
|
tabIndex: -1
|
|
40
44
|
}),
|
|
41
45
|
/* @__PURE__ */ u(n, {
|
|
42
|
-
onClick:
|
|
46
|
+
onClick: z,
|
|
43
47
|
disabled: _,
|
|
44
48
|
variant: "outline",
|
|
45
49
|
icon: x,
|
|
46
50
|
iconPosition: S,
|
|
47
51
|
size: C,
|
|
48
|
-
"aria-labelledby":
|
|
49
|
-
"aria-
|
|
52
|
+
"aria-labelledby": M ?? O,
|
|
53
|
+
"aria-label": M || O ? void 0 : D,
|
|
54
|
+
"aria-describedby": F,
|
|
50
55
|
"aria-invalid": w ? !0 : void 0,
|
|
51
|
-
children: p ??
|
|
56
|
+
children: p ?? A("fileupload.button")
|
|
52
57
|
}),
|
|
53
58
|
T && /* @__PURE__ */ u(t, {
|
|
54
|
-
id:
|
|
55
|
-
children:
|
|
59
|
+
id: P,
|
|
60
|
+
children: A("form.required")
|
|
56
61
|
}),
|
|
57
62
|
/* @__PURE__ */ u("span", {
|
|
58
63
|
className: l(a.fileNames, a[C], _ && a.disabled),
|
|
59
64
|
"aria-disabled": _ || void 0,
|
|
60
|
-
children:
|
|
65
|
+
children: H
|
|
61
66
|
})
|
|
62
67
|
]
|
|
63
68
|
})
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../i18n/useWimTranslation.cjs"),n=require("../../../i18n/generated/common.cjs"),r=require("../../layout/VisuallyHidden/VisuallyHidden.cjs"),i=require("../Button/Button.cjs"),a=require("../../../i18n/generated/form.cjs"),o=require("../Slider/Slider.cjs"),s=require("../IconButton/IconButton.cjs"),c=require("../../overlay/Dialog/Dialog.cjs"),l=require("./cropImage.cjs"),u=require("./image-cropper.module.cjs");let d=require("react");d=e.__toESM(d,1);let f=require("classnames");f=e.__toESM(f,1);let p=require("react/jsx-runtime");var m=10,h=50,g=d.default.forwardRef(({src:e,aspectRatio:g=1,circular:_=!1,onCrop:v,showRotation:y=!0,showZoom:b=!0,showApplyButton:x=!0,applyLabel:S,onApply:C,onCropError:w,maxOutputSize:T,outputType:E=`image/png`,outputQuality:D=.92,crossOrigin:O,className:k,...A},j)=>{let{t:
|
|
2
|
+
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../i18n/useWimTranslation.cjs"),n=require("../../../i18n/generated/common.cjs"),r=require("../../layout/VisuallyHidden/VisuallyHidden.cjs"),i=require("../Button/Button.cjs"),a=require("../../../i18n/generated/form.cjs"),o=require("../Slider/Slider.cjs"),s=require("../IconButton/IconButton.cjs"),c=require("../../overlay/Dialog/Dialog.cjs"),l=require("./cropImage.cjs"),u=require("./image-cropper.module.cjs");let d=require("react");d=e.__toESM(d,1);let f=require("classnames");f=e.__toESM(f,1);let p=require("react/jsx-runtime");var m=10,h=50,g=d.default.forwardRef(({src:e,aspectRatio:g=1,circular:_=!1,onCrop:v,showRotation:y=!0,showZoom:b=!0,showApplyButton:x=!0,applyLabel:S,onApply:C,onCropError:w,maxOutputSize:T,outputType:E=`image/png`,outputQuality:D=.92,crossOrigin:O,className:k,...A},j)=>{let M=A.role??(A[`aria-label`]||A[`aria-labelledby`]?`group`:void 0),{t:N}=t.useWimTranslation([a.formNs,n.commonNs]),[P,F]=(0,d.useState)(1),[I,L]=(0,d.useState)(0),[R,z]=(0,d.useState)({x:0,y:0}),[B,V]=(0,d.useState)(!1),[H,U]=(0,d.useState)({x:0,y:0}),[W,G]=(0,d.useState)(!1),K=(0,d.useRef)(null),q=(0,d.useRef)(null),J=(0,d.useRef)(null),Y=(0,d.useId)();(0,d.useEffect)(()=>{z({x:0,y:0}),F(1),L(0)},[e]);let X=e=>{(e.pointerType!==`mouse`||e.button===0)&&(V(!0),U({x:e.clientX-R.x,y:e.clientY-R.y}))},Z=(0,d.useCallback)(e=>{B&&z({x:e.clientX-H.x,y:e.clientY-H.y})},[B,H]),Q=(0,d.useCallback)(()=>{V(!1)},[]);(0,d.useEffect)(()=>{if(B)return window.addEventListener(`pointermove`,Z),window.addEventListener(`pointerup`,Q),window.addEventListener(`pointercancel`,Q),()=>{window.removeEventListener(`pointermove`,Z),window.removeEventListener(`pointerup`,Q),window.removeEventListener(`pointercancel`,Q)}},[B,Z,Q]);let $=e=>{let t=e.shiftKey?h:m,n={ArrowLeft:[-t,0],ArrowRight:[t,0],ArrowUp:[0,-t],ArrowDown:[0,t]}[e.key];n?(e.preventDefault(),z(e=>({x:e.x+n[0],y:e.y+n[1]}))):e.key===`Home`&&(e.preventDefault(),z({x:0,y:0}))},ee=()=>{L(e=>(e+90)%360)},te=()=>{G(!0)},ne=()=>{let e=K.current,t=J.current;if(G(!1),!e||!t)return;let n={x:R.x,y:R.y,zoom:P,rotation:I,frameWidth:t.clientWidth,frameHeight:t.clientHeight,layoutWidth:e.offsetWidth,layoutHeight:e.offsetHeight,naturalWidth:e.naturalWidth,naturalHeight:e.naturalHeight,maxOutputSize:T};try{let{dataUrl:t,detail:r}=l.cropImage(e,n,E,D);v?.(t,r),C?.(t,r)}catch(e){w?.(e instanceof Error?e:Error(String(e)),l.resolveCropDetail(n).detail)}};return e?(0,p.jsxs)(`div`,{ref:j,role:M,className:(0,f.default)(`wim-image-cropper`,u.default.root,k),...A,children:[(0,p.jsxs)(`div`,{ref:q,className:u.default.viewer,onPointerDown:X,onKeyDown:$,role:`application`,tabIndex:0,"aria-label":N(`image_cropper.position_label`),"aria-describedby":Y,children:[(0,p.jsx)(r.VisuallyHidden,{id:Y,children:N(`image_cropper.position_hint`)}),(0,p.jsx)(`div`,{className:u.default.imageContainer,children:(0,p.jsx)(`img`,{ref:K,src:e,alt:N(`a11y.crop_target`),crossOrigin:O,className:u.default.image,style:{transform:`translate(${R.x}px, ${R.y}px) rotate(${I}deg) scale(${P})`},draggable:!1})}),(0,p.jsx)(`div`,{className:u.default.overlay,children:(0,p.jsx)(`div`,{ref:J,className:(0,f.default)(u.default.cropArea,{[u.default.circular]:_}),style:{aspectRatio:g}})})]}),(0,p.jsxs)(`div`,{className:u.default.controls,children:[b&&(0,p.jsx)(`div`,{className:u.default.zoomControl,children:(0,p.jsx)(o.Slider,{min:1,max:3,step:.1,value:P,onChange:e=>F(e),label:N(`image_cropper.zoom`),styles:{root:u.default.zoomSlider}})}),y&&(0,p.jsx)(`div`,{className:u.default.rotationControl,children:(0,p.jsx)(s.IconButton,{iconName:`RefreshIcon`,onClick:ee,"aria-label":N(`image_cropper.rotate`),variant:`outline`,size:`sm`})}),x&&(0,p.jsx)(`div`,{className:u.default.applyControl,children:(0,p.jsx)(i.Button,{onClick:te,size:`sm`,variant:`solid`,children:S||N(`image_cropper.apply`)})})]}),(0,p.jsx)(c.Dialog,{open:W,onOpenChange:G,children:(0,p.jsxs)(c.DialogContent,{children:[(0,p.jsx)(c.DialogHeader,{children:(0,p.jsx)(c.DialogTitle,{children:N(`image_cropper.confirm_title`)})}),(0,p.jsx)(c.DialogDescription,{children:N(`image_cropper.confirm_message`)}),(0,p.jsxs)(c.DialogFooter,{children:[(0,p.jsx)(c.DialogClose,{asChild:!0,children:(0,p.jsx)(i.Button,{variant:`ghost`,children:N(`image_cropper.cancel`)})}),(0,p.jsx)(i.Button,{onClick:ne,variant:`solid`,children:N(`image_cropper.confirm`)})]})]})})]}):(0,p.jsx)(`div`,{ref:j,role:M,className:(0,f.default)(`wim-image-cropper`,u.default.root,u.default.empty,k),...A,children:(0,p.jsx)(`div`,{className:u.default.emptyContent,children:N(`image_cropper.no_image`)})})});g.displayName=`ImageCropper`,exports.ImageCropper=g;
|