wimui 0.63.0 → 0.63.1
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/_internal/OverlayBase.cjs +1 -1
- package/dist/components/_internal/OverlayBase.js +31 -30
- package/dist/components/_internal/composeEventHandlers.cjs +2 -0
- package/dist/components/_internal/composeEventHandlers.d.ts +25 -0
- package/dist/components/_internal/composeEventHandlers.js +8 -0
- package/dist/components/ai/ChatUI/ChatUI.cjs +1 -1
- package/dist/components/ai/ChatUI/ChatUI.js +83 -82
- package/dist/components/data-display/Accordion/Accordion.cjs +1 -1
- package/dist/components/data-display/Accordion/Accordion.js +79 -78
- package/dist/components/data-display/PullToRefresh/PullToRefresh.cjs +1 -1
- package/dist/components/data-display/PullToRefresh/PullToRefresh.js +73 -72
- package/dist/components/data-display/SortableList/SortableList.cjs +1 -1
- package/dist/components/data-display/SortableList/SortableList.js +54 -53
- package/dist/components/data-display/SwipeAction/SwipeAction.cjs +1 -1
- package/dist/components/data-display/SwipeAction/SwipeAction.js +77 -76
- package/dist/components/form/Cascader/Cascader.cjs +1 -1
- package/dist/components/form/Cascader/Cascader.js +99 -98
- package/dist/components/form/DatePicker/DatePicker.cjs +1 -1
- package/dist/components/form/DatePicker/DatePicker.js +53 -52
- package/dist/components/form/RangeSlider/RangeSlider.cjs +1 -1
- package/dist/components/form/RangeSlider/RangeSlider.js +109 -108
- package/dist/components/form/Rating/Rating.cjs +1 -1
- package/dist/components/form/Rating/Rating.js +75 -74
- package/dist/components/form/Slider/Slider.cjs +1 -1
- package/dist/components/form/Slider/Slider.js +58 -57
- package/dist/components/form/SmartSearchInput/SmartSearchInput.cjs +1 -1
- package/dist/components/form/SmartSearchInput/SmartSearchInput.js +65 -64
- package/dist/components/form/TimePicker/TimePicker.cjs +1 -1
- package/dist/components/form/TimePicker/TimePicker.js +31 -30
- package/dist/components/layout/InteractiveArea/InteractiveArea.cjs +1 -1
- package/dist/components/layout/InteractiveArea/InteractiveArea.js +1 -1
- package/dist/components/layout/Navbar/Navbar.cjs +1 -1
- package/dist/components/layout/Navbar/Navbar.js +68 -67
- package/dist/components/layout/Splitter/Splitter.cjs +1 -1
- package/dist/components/layout/Splitter/Splitter.js +47 -46
- package/dist/components/layout/Transition/Transition.cjs +1 -1
- package/dist/components/layout/Transition/Transition.js +25 -24
- package/dist/components/media/Audio/Audio.cjs +1 -1
- package/dist/components/media/Audio/Audio.js +39 -38
- package/dist/components/media/Image/Image.cjs +2 -2
- package/dist/components/media/Image/Image.js +96 -95
- package/dist/components/media/ImageCompare/ImageCompare.cjs +1 -1
- package/dist/components/media/ImageCompare/ImageCompare.js +75 -74
- package/dist/components/media/Video/Video.cjs +1 -1
- package/dist/components/media/Video/Video.js +114 -113
- package/dist/components/navigation/SpeedDial/SpeedDial.cjs +1 -1
- package/dist/components/navigation/SpeedDial/SpeedDial.js +47 -46
- package/dist/components/navigation/Tabs/Tabs.cjs +1 -1
- package/dist/components/navigation/Tabs/Tabs.js +87 -86
- package/dist/components/overlay/Popover/Popover.cjs +1 -1
- package/dist/components/overlay/Popover/Popover.js +1 -1
- package/dist/llms-full.txt +1 -1
- package/dist/llms.txt +1 -1
- package/dist/wimui.umd.js +5 -5
- package/package.json +1 -1
|
@@ -1,112 +1,113 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { Root as e } from "../../../node_modules/@radix-ui/react-slot/dist/index.js";
|
|
3
|
-
import {
|
|
4
|
-
import n from "
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import u from "
|
|
8
|
-
import
|
|
3
|
+
import { composeEventHandlers as t } from "../../_internal/composeEventHandlers.js";
|
|
4
|
+
import { Icon as n } from "../../media/Icon/Icon.js";
|
|
5
|
+
import r from "./swipe-action.module.js";
|
|
6
|
+
import { useSwipeableList as i } from "./SwipeableList.js";
|
|
7
|
+
import a, { useEffect as o, useId as s, useImperativeHandle as c, useRef as l, useState as u } from "react";
|
|
8
|
+
import d from "classnames";
|
|
9
|
+
import { jsx as f, jsxs as p } from "react/jsx-runtime";
|
|
9
10
|
//#region src/components/data-display/SwipeAction/SwipeAction.tsx
|
|
10
|
-
var
|
|
11
|
-
let
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
var m = a.forwardRef(({ as: a = "div", leftActions: m = [], rightActions: h = [], children: g, asChild: _ = !1, id: v, closeOnAction: y = !0, fullSwipe: b, className: x, ...S }, C) => {
|
|
12
|
+
let w = s(), T = v || w, E = i(), [D, O] = u(0), [k, A] = u(!1), j = l(0), M = l(0), N = l(null);
|
|
13
|
+
c(C, () => ({ close: () => {
|
|
14
|
+
O(0), E?.reportClose(T);
|
|
14
15
|
} }));
|
|
15
|
-
let
|
|
16
|
-
|
|
17
|
-
if (
|
|
18
|
-
|
|
16
|
+
let P = l(!1);
|
|
17
|
+
o(() => {
|
|
18
|
+
if (k) {
|
|
19
|
+
P.current = !0;
|
|
19
20
|
return;
|
|
20
21
|
}
|
|
21
|
-
if (
|
|
22
|
+
if (P.current) {
|
|
22
23
|
let e = setTimeout(() => {
|
|
23
|
-
|
|
24
|
+
P.current = !1;
|
|
24
25
|
}, 100);
|
|
25
26
|
return () => clearTimeout(e);
|
|
26
27
|
}
|
|
27
|
-
|
|
28
|
+
E?.openedId && E.openedId !== T && O(0);
|
|
28
29
|
}, [
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
E?.openedId,
|
|
31
|
+
T,
|
|
32
|
+
k
|
|
32
33
|
]);
|
|
33
|
-
let
|
|
34
|
-
|
|
35
|
-
},
|
|
36
|
-
if (!
|
|
37
|
-
let t = ("touches" in e ? e.touches[0].clientX : e.clientX) -
|
|
38
|
-
Math.abs(t) > 5 &&
|
|
39
|
-
},
|
|
40
|
-
if (
|
|
41
|
-
if (
|
|
42
|
-
let t =
|
|
34
|
+
let F = m.length * 80, I = h.length * 80, L = F > 0 && (b === "left" || b === "both"), R = I > 0 && (b === "right" || b === "both"), z = N.current?.offsetWidth ?? 0, B = (e) => Math.max(e + 40, z / 2), V = k && L && D >= B(F) ? "left" : k && R && -D >= B(I) ? "right" : null, H = (e) => {
|
|
35
|
+
j.current = "touches" in e ? e.touches[0].clientX : e.clientX, M.current = D, A(!0);
|
|
36
|
+
}, U = (e) => {
|
|
37
|
+
if (!k) return;
|
|
38
|
+
let t = ("touches" in e ? e.touches[0].clientX : e.clientX) - j.current, n = M.current + t;
|
|
39
|
+
Math.abs(t) > 5 && E?.openedId !== T && E?.reportOpen(T), n > F && !L && (n = F + (n - F) * .3), n < -I && !R && (n = -I + (n + I) * .3), O(n);
|
|
40
|
+
}, W = (e = !0) => {
|
|
41
|
+
if (k) {
|
|
42
|
+
if (A(!1), V) {
|
|
43
|
+
let t = V === "left" ? m[0] : h[h.length - 1];
|
|
43
44
|
if (e) {
|
|
44
|
-
|
|
45
|
+
X(t), y || (O(V === "left" ? F : -I), E?.reportOpen(T));
|
|
45
46
|
return;
|
|
46
47
|
}
|
|
47
48
|
}
|
|
48
|
-
|
|
49
|
+
D > F / 2 ? (O(F), E?.reportOpen(T)) : D < -I / 2 ? (O(-I), E?.reportOpen(T)) : (O(0), E?.reportClose(T));
|
|
49
50
|
}
|
|
50
|
-
},
|
|
51
|
-
let t = e === "left" ?
|
|
52
|
-
|
|
53
|
-
},
|
|
51
|
+
}, G = _ ? e : "div", K = l(null), q = F > 0 || I > 0, J = (e) => {
|
|
52
|
+
let t = e === "left" ? F : -I;
|
|
53
|
+
D !== t && O(t), E?.reportOpen(T);
|
|
54
|
+
}, Y = (e) => {
|
|
54
55
|
let t = e.relatedTarget;
|
|
55
|
-
t &&
|
|
56
|
-
},
|
|
57
|
-
e.onClick(),
|
|
58
|
-
},
|
|
59
|
-
let a = e === "left" ?
|
|
60
|
-
return /* @__PURE__ */
|
|
61
|
-
className:
|
|
56
|
+
t && N.current?.contains(t) || D !== 0 && !k && (O(0), E?.reportClose(T));
|
|
57
|
+
}, X = (e, t) => {
|
|
58
|
+
e.onClick(), y && (O(0), E?.reportClose(T), t && document.activeElement === t && K.current?.focus());
|
|
59
|
+
}, Z = (e, t, i) => {
|
|
60
|
+
let a = e === "left" ? L : R, o = e === "left" ? Math.max(0, D) : Math.max(0, -D), s = e === "left" ? 0 : t.length - 1;
|
|
61
|
+
return /* @__PURE__ */ f("div", {
|
|
62
|
+
className: d(r.actions, r[e], a && o > i && r.stretched, V === e && r.armed),
|
|
62
63
|
style: {
|
|
63
64
|
width: a ? Math.max(i, o) : i,
|
|
64
65
|
"--_action-w": "80px"
|
|
65
66
|
},
|
|
66
|
-
children:
|
|
67
|
-
className:
|
|
68
|
-
style: { backgroundColor:
|
|
69
|
-
onFocus: () =>
|
|
70
|
-
onClick: (e) =>
|
|
67
|
+
children: t.map((t, i) => /* @__PURE__ */ p("button", {
|
|
68
|
+
className: d(r.action, t.intent && r[t.intent], a && i === s && r.outer),
|
|
69
|
+
style: { backgroundColor: t.color },
|
|
70
|
+
onFocus: () => J(e),
|
|
71
|
+
onClick: (e) => X(t, e.currentTarget),
|
|
71
72
|
type: "button",
|
|
72
|
-
children: [/* @__PURE__ */
|
|
73
|
-
name:
|
|
73
|
+
children: [/* @__PURE__ */ f(n, {
|
|
74
|
+
name: t.icon,
|
|
74
75
|
size: "md"
|
|
75
|
-
}), /* @__PURE__ */
|
|
76
|
-
className:
|
|
77
|
-
children:
|
|
76
|
+
}), /* @__PURE__ */ f("span", {
|
|
77
|
+
className: r.label,
|
|
78
|
+
children: t.label
|
|
78
79
|
})]
|
|
79
80
|
}, i))
|
|
80
81
|
});
|
|
81
82
|
};
|
|
82
|
-
return /* @__PURE__ */
|
|
83
|
-
ref:
|
|
84
|
-
className:
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
83
|
+
return /* @__PURE__ */ p(a, {
|
|
84
|
+
ref: N,
|
|
85
|
+
className: d("wim-swipe-action", r.container, x),
|
|
86
|
+
...S,
|
|
87
|
+
onMouseLeave: t(S.onMouseLeave, () => W(!1)),
|
|
88
|
+
onBlur: t(S.onBlur, Y),
|
|
88
89
|
children: [
|
|
89
|
-
/* @__PURE__ */
|
|
90
|
-
ref:
|
|
91
|
-
className:
|
|
92
|
-
tabIndex:
|
|
90
|
+
/* @__PURE__ */ f(G, {
|
|
91
|
+
ref: K,
|
|
92
|
+
className: r.content,
|
|
93
|
+
tabIndex: q ? -1 : void 0,
|
|
93
94
|
style: {
|
|
94
|
-
transform: `translateX(${
|
|
95
|
-
transition:
|
|
95
|
+
transform: `translateX(${D}px)`,
|
|
96
|
+
transition: k ? "none" : "transform 0.4s cubic-bezier(0.16, 1, 0.3, 1)"
|
|
96
97
|
},
|
|
97
|
-
onTouchStart:
|
|
98
|
-
onTouchMove:
|
|
99
|
-
onTouchEnd: () =>
|
|
100
|
-
onMouseDown:
|
|
101
|
-
onMouseMove:
|
|
102
|
-
onMouseUp: () =>
|
|
103
|
-
children:
|
|
98
|
+
onTouchStart: H,
|
|
99
|
+
onTouchMove: U,
|
|
100
|
+
onTouchEnd: () => W(),
|
|
101
|
+
onMouseDown: H,
|
|
102
|
+
onMouseMove: U,
|
|
103
|
+
onMouseUp: () => W(),
|
|
104
|
+
children: g
|
|
104
105
|
}),
|
|
105
|
-
|
|
106
|
-
|
|
106
|
+
F > 0 && Z("left", m, F),
|
|
107
|
+
I > 0 && Z("right", h, I)
|
|
107
108
|
]
|
|
108
109
|
});
|
|
109
110
|
});
|
|
110
|
-
|
|
111
|
+
m.displayName = "SwipeAction";
|
|
111
112
|
//#endregion
|
|
112
|
-
export {
|
|
113
|
+
export { m as SwipeAction };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../hooks/useMergedRef.cjs"),n=require("../../layout/Transition/Transition.cjs"),
|
|
2
|
+
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../hooks/useMergedRef.cjs"),n=require("../../_internal/composeEventHandlers.cjs"),r=require("../../layout/Transition/Transition.cjs"),i=require("../../../icon/chevron-right.cjs"),a=require("../../media/Icon/Icon.cjs"),o=require("../../_internal/BaseListItem/BaseListItem.cjs"),s=require("../InputBase/InputBase.cjs"),c=require("../../_internal/useInlineFloating.cjs"),l=require("./cascader.module.cjs"),u=require("../FieldTemplate/FieldTemplate.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");function m(e){return typeof e==`string`?e:typeof e==`number`?String(e):``}var h=({options:e=[],value:h,onChange:g,placeholder:_,label:v,error:y,required:b,layout:x,className:ee,disabled:S=!1,defaultValue:te,id:C,expandTrigger:w=`click`,separator:T=` / `,allowClear:ne=!1,"aria-label":E,"aria-labelledby":re,"aria-describedby":ie,width:ae,fullWidth:oe=!1,...D})=>{let se=(0,d.useId)(),O=C||`wim-cascader-${se}`,k=v?`${O}-label`:void 0,A=y?`${O}-error`:void 0,j=k??re,ce=`${O}-trigger`,M=`${O}-popup`,[N,P]=(0,d.useState)(!1),[le,F]=(0,d.useState)(te||[]),[I,L]=(0,d.useState)([]),[R,z]=(0,d.useState)(-1),[B,V]=(0,d.useState)([]),[H,U]=(0,d.useState)(!1),W=(0,d.useRef)(null),G=(0,d.useRef)(null),K=h!==void 0,q=K?h:le;(0,d.useEffect)(()=>{let e=e=>{W.current&&!W.current.contains(e.target)&&P(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[]),(0,d.useEffect)(()=>{if(N&&R>=0){let e=B[R],t=`${O}-menu-${R}-option-${e}`,n=W.current?.querySelector(`#${t}`);n&&n.scrollIntoView({block:`nearest`,behavior:`smooth`})}},[R,B,N,O]);let J=()=>{if(!S){let e=!N;P(e),e?(L(q||[]),z(0),V([0])):z(-1)}},ue=()=>{if(!q||q.length===0)return null;let t=[],n=e;for(let e of q){let r=n.find(t=>t.value===e);if(r)t.push(r.label),n=r.children||[];else break}return t.length===0?null:t.map((e,n)=>(0,p.jsxs)(d.default.Fragment,{children:[e,n<t.length-1&&(0,p.jsx)(`span`,{children:T})]},n))},Y=(t,n)=>{if(t.disabled)return;let r=[...I.slice(0,n),t.value];if(L(r),!t.children||t.children.length===0){if(K||F(r),g){let t=[],n=e;for(let e of r){let r=n.find(t=>t.value===e);r&&(t.push(r),n=r.children||[])}g(r,t)}P(!1),G.current?.focus()}},de=e=>{e?.stopPropagation(),!S&&(K||F([]),g&&g([],[]))},fe=(e,t)=>{w===`hover`&&!e.disabled&&L([...I.slice(0,t),e.value])},pe=t=>{if(U(!0),S)return;if(!N){(t.key===`Enter`||t.key===` `||t.key===`ArrowDown`||t.key===`ArrowDown`&&t.altKey)&&(t.preventDefault(),J());return}let n=[e],r=e;for(let e=0;e<I.length;e++){let t=I[e],i=r.find(e=>e.value===t);if(i&&i.children&&i.children.length>0)n.push(i.children),r=i.children;else break}let i=n[R]||[],a=B[R]||0;switch(t.key){case`ArrowDown`:t.preventDefault(),V(e=>{let t=[...e];return t[R]=Math.min(a+1,i.length-1),t});break;case`ArrowUp`:t.preventDefault(),V(e=>{let t=[...e];return t[R]=Math.max(a-1,0),t});break;case`ArrowRight`:{t.preventDefault();let e=i[a];e&&e.children&&e.children.length>0&&(L([...I.slice(0,R),e.value]),z(R+1),V(e=>[...e.slice(0,R+1),0]));break}case`ArrowLeft`:t.preventDefault(),R>0&&(z(R-1),V(e=>e.slice(0,R)));break;case`Enter`:case` `:{t.preventDefault();let e=i[a];e&&Y(e,R);break}case`Escape`:t.preventDefault(),P(!1),z(-1),G.current?.focus();break;case`Home`:t.preventDefault(),V(e=>{let t=[...e];return t[R]=0,t});break;case`End`:t.preventDefault(),V(e=>{let t=[...e];return t[R]=i.length-1,t});break;case`Tab`:N&&(P(!1),z(-1))}},X=[e],Z=e;for(let e=0;e<I.length;e++){let t=I[e],n=Z.find(e=>e.value===t);if(n&&n.children&&n.children.length>0)X.push(n.children),Z=n.children;else break}let Q=ue(),$=()=>{if(!q||q.length===0)return``;let t=[],n=e;for(let e of q){let r=n.find(t=>t.value===e);if(r)t.push(m(r.label)),n=r.children||[];else break}return t.join(T)},{setReference:me,setFloating:he,floatingProps:ge}=c.useInlineFloating({open:N&&!S}),_e=t.useMergedRef(W,me);return(0,p.jsx)(u.FieldTemplate,{label:v,error:y,required:b,layout:x,labelId:k,errorId:A,className:(0,f.default)(`wim-cascader`,ee),children:(0,p.jsxs)(`div`,{className:l.default.root,ref:_e,"data-keyboard-nav":H,...D,onMouseMove:n.composeEventHandlers(D.onMouseMove,()=>U(!1)),children:[(0,p.jsx)(s.InputBase,{disabled:S,allowClear:ne,hasValue:!!Q,onClear:de,intent:y?`danger`:`default`,width:ae,fullWidth:oe,rightIcons:[{name:`ChevronDownIcon`,rotated:N}],className:(0,f.default)(N&&l.default.open),children:(0,p.jsx)(`div`,{id:ce,ref:G,className:(0,f.default)(l.default.trigger,S&&l.default.disabled),onClick:J,onKeyDown:pe,tabIndex:S?-1:0,role:`combobox`,"aria-expanded":N,"aria-controls":N?M:void 0,"aria-haspopup":`listbox`,"aria-disabled":S,"aria-labelledby":j,"aria-label":j?void 0:E||$()||m(_),"aria-describedby":[ie,A].filter(Boolean).join(` `)||void 0,"aria-required":b,"aria-invalid":!!y,"aria-activedescendant":N&&R>=0?`${O}-menu-${R}-option-${B[R]}`:void 0,children:(0,p.jsx)(`div`,{className:(0,f.default)(l.default.value,!Q&&l.default.placeholder),children:Q||_})})}),(0,p.jsx)(r.Transition,{show:N&&!S,preset:`fade`,id:M,className:l.default.dropdown,ref:he,...ge,children:X.map((e,t)=>(0,p.jsx)(`div`,{className:l.default.menu,role:`listbox`,"aria-labelledby":j,"aria-label":j?void 0:E||$()||m(_),children:e.map((e,n)=>{let r=I[t]===e.value,s=R===t&&B[t]===n,c=q[t]===e.value,u=e.children&&e.children.length>0;return(0,p.jsx)(o.BaseListItem,{className:(0,f.default)(l.default.menuItem,c&&l.default.selected),active:s||r,disabled:e.disabled,onClick:n=>{n.stopPropagation(),Y(e,t)},onMouseEnter:()=>{fe(e,t),z(t),V(e=>[...e.slice(0,t),n])},rightSection:u?(0,p.jsx)(a.Icon,{component:i.default,size:`sm`}):void 0,role:`option`,id:`${O}-menu-${t}-option-${n}`,"aria-selected":c,tabIndex:-1,children:e.label},e.value)})},t))})]})})};h.displayName=`Cascader`,exports.Cascader=h;
|
|
@@ -1,60 +1,61 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { useMergedRef as e } from "../../../hooks/useMergedRef.js";
|
|
3
|
-
import {
|
|
4
|
-
import n from "
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
3
|
+
import { composeEventHandlers as t } from "../../_internal/composeEventHandlers.js";
|
|
4
|
+
import { Transition as n } from "../../layout/Transition/Transition.js";
|
|
5
|
+
import r from "../../../icon/chevron-right.js";
|
|
6
|
+
import { Icon as i } from "../../media/Icon/Icon.js";
|
|
7
|
+
import { BaseListItem as ee } from "../../_internal/BaseListItem/BaseListItem.js";
|
|
7
8
|
import { InputBase as a } from "../InputBase/InputBase.js";
|
|
8
9
|
import { useInlineFloating as o } from "../../_internal/useInlineFloating.js";
|
|
9
10
|
import s from "./cascader.module.js";
|
|
10
11
|
import { FieldTemplate as c } from "../FieldTemplate/FieldTemplate.js";
|
|
11
|
-
import l, { useEffect as u, useId as
|
|
12
|
+
import l, { useEffect as u, useId as te, useRef as d, useState as f } from "react";
|
|
12
13
|
import p from "classnames";
|
|
13
14
|
import { jsx as m, jsxs as h } from "react/jsx-runtime";
|
|
14
15
|
//#region src/components/form/Cascader/Cascader.tsx
|
|
15
16
|
function g(e) {
|
|
16
17
|
return typeof e == "string" ? e : typeof e == "number" ? String(e) : "";
|
|
17
18
|
}
|
|
18
|
-
var _ = ({ options: _ = [], value: v, onChange: y, placeholder: b, label: x, error: S, required: C, layout:
|
|
19
|
-
let
|
|
19
|
+
var _ = ({ options: _ = [], value: v, onChange: y, placeholder: b, label: x, error: S, required: C, layout: ne, className: re, disabled: w = !1, defaultValue: ie, id: ae, expandTrigger: oe = "click", separator: T = " / ", allowClear: se = !1, "aria-label": E, "aria-labelledby": ce, "aria-describedby": le, width: ue, fullWidth: de = !1, ...D }) => {
|
|
20
|
+
let fe = te(), O = ae || `wim-cascader-${fe}`, k = x ? `${O}-label` : void 0, A = S ? `${O}-error` : void 0, j = k ?? ce, pe = `${O}-trigger`, M = `${O}-popup`, [N, P] = f(!1), [me, F] = f(ie || []), [I, L] = f([]), [R, z] = f(-1), [B, V] = f([]), [he, H] = f(!1), U = d(null), W = d(null), G = v !== void 0, K = G ? v : me;
|
|
20
21
|
u(() => {
|
|
21
22
|
let e = (e) => {
|
|
22
|
-
|
|
23
|
+
U.current && !U.current.contains(e.target) && P(!1);
|
|
23
24
|
};
|
|
24
25
|
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
25
26
|
}, []), u(() => {
|
|
26
|
-
if (
|
|
27
|
-
let e =
|
|
27
|
+
if (N && R >= 0) {
|
|
28
|
+
let e = B[R], t = `${O}-menu-${R}-option-${e}`, n = U.current?.querySelector(`#${t}`);
|
|
28
29
|
n && n.scrollIntoView({
|
|
29
30
|
block: "nearest",
|
|
30
31
|
behavior: "smooth"
|
|
31
32
|
});
|
|
32
33
|
}
|
|
33
34
|
}, [
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
R,
|
|
36
|
+
B,
|
|
37
|
+
N,
|
|
38
|
+
O
|
|
38
39
|
]);
|
|
39
|
-
let
|
|
40
|
+
let q = () => {
|
|
40
41
|
if (!w) {
|
|
41
|
-
let e = !
|
|
42
|
-
|
|
42
|
+
let e = !N;
|
|
43
|
+
P(e), e ? (L(K || []), z(0), V([0])) : z(-1);
|
|
43
44
|
}
|
|
44
|
-
},
|
|
45
|
-
if (!
|
|
45
|
+
}, ge = () => {
|
|
46
|
+
if (!K || K.length === 0) return null;
|
|
46
47
|
let e = [], t = _;
|
|
47
|
-
for (let n of
|
|
48
|
+
for (let n of K) {
|
|
48
49
|
let r = t.find((e) => e.value === n);
|
|
49
50
|
if (r) e.push(r.label), t = r.children || [];
|
|
50
51
|
else break;
|
|
51
52
|
}
|
|
52
|
-
return e.length === 0 ? null : e.map((t, n) => /* @__PURE__ */ h(l.Fragment, { children: [t, n < e.length - 1 && /* @__PURE__ */ m("span", { children:
|
|
53
|
-
},
|
|
53
|
+
return e.length === 0 ? null : e.map((t, n) => /* @__PURE__ */ h(l.Fragment, { children: [t, n < e.length - 1 && /* @__PURE__ */ m("span", { children: T })] }, n));
|
|
54
|
+
}, J = (e, t) => {
|
|
54
55
|
if (e.disabled) return;
|
|
55
|
-
let n = [...
|
|
56
|
-
if (
|
|
57
|
-
if (
|
|
56
|
+
let n = [...I.slice(0, t), e.value];
|
|
57
|
+
if (L(n), !e.children || e.children.length === 0) {
|
|
58
|
+
if (G || F(n), y) {
|
|
58
59
|
let e = [], t = _;
|
|
59
60
|
for (let r of n) {
|
|
60
61
|
let n = t.find((e) => e.value === r);
|
|
@@ -62,168 +63,168 @@ var _ = ({ options: _ = [], value: v, onChange: y, placeholder: b, label: x, err
|
|
|
62
63
|
}
|
|
63
64
|
y(n, e);
|
|
64
65
|
}
|
|
65
|
-
|
|
66
|
+
P(!1), W.current?.focus();
|
|
66
67
|
}
|
|
67
|
-
}, he = (e) => {
|
|
68
|
-
e?.stopPropagation(), !w && (K || I([]), y && y([], []));
|
|
69
|
-
}, ge = (e, t) => {
|
|
70
|
-
ie === "hover" && !e.disabled && R([...L.slice(0, t), e.value]);
|
|
71
68
|
}, _e = (e) => {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
69
|
+
e?.stopPropagation(), !w && (G || F([]), y && y([], []));
|
|
70
|
+
}, Y = (e, t) => {
|
|
71
|
+
oe === "hover" && !e.disabled && L([...I.slice(0, t), e.value]);
|
|
72
|
+
}, ve = (e) => {
|
|
73
|
+
if (H(!0), w) return;
|
|
74
|
+
if (!N) {
|
|
75
|
+
(e.key === "Enter" || e.key === " " || e.key === "ArrowDown" || e.key === "ArrowDown" && e.altKey) && (e.preventDefault(), q());
|
|
75
76
|
return;
|
|
76
77
|
}
|
|
77
78
|
let t = [_], n = _;
|
|
78
|
-
for (let e = 0; e <
|
|
79
|
-
let r =
|
|
79
|
+
for (let e = 0; e < I.length; e++) {
|
|
80
|
+
let r = I[e], i = n.find((e) => e.value === r);
|
|
80
81
|
if (i && i.children && i.children.length > 0) t.push(i.children), n = i.children;
|
|
81
82
|
else break;
|
|
82
83
|
}
|
|
83
|
-
let r = t[
|
|
84
|
+
let r = t[R] || [], i = B[R] || 0;
|
|
84
85
|
switch (e.key) {
|
|
85
86
|
case "ArrowDown":
|
|
86
|
-
e.preventDefault(),
|
|
87
|
+
e.preventDefault(), V((e) => {
|
|
87
88
|
let t = [...e];
|
|
88
|
-
return t[
|
|
89
|
+
return t[R] = Math.min(i + 1, r.length - 1), t;
|
|
89
90
|
});
|
|
90
91
|
break;
|
|
91
92
|
case "ArrowUp":
|
|
92
|
-
e.preventDefault(),
|
|
93
|
+
e.preventDefault(), V((e) => {
|
|
93
94
|
let t = [...e];
|
|
94
|
-
return t[
|
|
95
|
+
return t[R] = Math.max(i - 1, 0), t;
|
|
95
96
|
});
|
|
96
97
|
break;
|
|
97
98
|
case "ArrowRight": {
|
|
98
99
|
e.preventDefault();
|
|
99
100
|
let t = r[i];
|
|
100
|
-
t && t.children && t.children.length > 0 && (
|
|
101
|
+
t && t.children && t.children.length > 0 && (L([...I.slice(0, R), t.value]), z(R + 1), V((e) => [...e.slice(0, R + 1), 0]));
|
|
101
102
|
break;
|
|
102
103
|
}
|
|
103
104
|
case "ArrowLeft":
|
|
104
|
-
e.preventDefault(),
|
|
105
|
+
e.preventDefault(), R > 0 && (z(R - 1), V((e) => e.slice(0, R)));
|
|
105
106
|
break;
|
|
106
107
|
case "Enter":
|
|
107
108
|
case " ": {
|
|
108
109
|
e.preventDefault();
|
|
109
110
|
let t = r[i];
|
|
110
|
-
t &&
|
|
111
|
+
t && J(t, R);
|
|
111
112
|
break;
|
|
112
113
|
}
|
|
113
114
|
case "Escape":
|
|
114
|
-
e.preventDefault(),
|
|
115
|
+
e.preventDefault(), P(!1), z(-1), W.current?.focus();
|
|
115
116
|
break;
|
|
116
117
|
case "Home":
|
|
117
|
-
e.preventDefault(),
|
|
118
|
+
e.preventDefault(), V((e) => {
|
|
118
119
|
let t = [...e];
|
|
119
|
-
return t[
|
|
120
|
+
return t[R] = 0, t;
|
|
120
121
|
});
|
|
121
122
|
break;
|
|
122
123
|
case "End":
|
|
123
|
-
e.preventDefault(),
|
|
124
|
+
e.preventDefault(), V((e) => {
|
|
124
125
|
let t = [...e];
|
|
125
|
-
return t[
|
|
126
|
+
return t[R] = r.length - 1, t;
|
|
126
127
|
});
|
|
127
128
|
break;
|
|
128
|
-
case "Tab":
|
|
129
|
+
case "Tab": N && (P(!1), z(-1));
|
|
129
130
|
}
|
|
130
131
|
}, X = [_], Z = _;
|
|
131
|
-
for (let e = 0; e <
|
|
132
|
-
let t =
|
|
132
|
+
for (let e = 0; e < I.length; e++) {
|
|
133
|
+
let t = I[e], n = Z.find((e) => e.value === t);
|
|
133
134
|
if (n && n.children && n.children.length > 0) X.push(n.children), Z = n.children;
|
|
134
135
|
else break;
|
|
135
136
|
}
|
|
136
|
-
let Q =
|
|
137
|
-
if (!
|
|
137
|
+
let Q = ge(), $ = () => {
|
|
138
|
+
if (!K || K.length === 0) return "";
|
|
138
139
|
let e = [], t = _;
|
|
139
|
-
for (let n of
|
|
140
|
+
for (let n of K) {
|
|
140
141
|
let r = t.find((e) => e.value === n);
|
|
141
142
|
if (r) e.push(g(r.label)), t = r.children || [];
|
|
142
143
|
else break;
|
|
143
144
|
}
|
|
144
|
-
return e.join(
|
|
145
|
-
}, { setReference:
|
|
145
|
+
return e.join(T);
|
|
146
|
+
}, { setReference: ye, setFloating: be, floatingProps: xe } = o({ open: N && !w }), Se = e(U, ye);
|
|
146
147
|
return /* @__PURE__ */ m(c, {
|
|
147
148
|
label: x,
|
|
148
149
|
error: S,
|
|
149
150
|
required: C,
|
|
150
|
-
layout:
|
|
151
|
-
labelId:
|
|
152
|
-
errorId:
|
|
153
|
-
className: p("wim-cascader",
|
|
151
|
+
layout: ne,
|
|
152
|
+
labelId: k,
|
|
153
|
+
errorId: A,
|
|
154
|
+
className: p("wim-cascader", re),
|
|
154
155
|
children: /* @__PURE__ */ h("div", {
|
|
155
156
|
className: s.root,
|
|
156
|
-
ref:
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
157
|
+
ref: Se,
|
|
158
|
+
"data-keyboard-nav": he,
|
|
159
|
+
...D,
|
|
160
|
+
onMouseMove: t(D.onMouseMove, () => H(!1)),
|
|
160
161
|
children: [/* @__PURE__ */ m(a, {
|
|
161
162
|
disabled: w,
|
|
162
|
-
allowClear:
|
|
163
|
+
allowClear: se,
|
|
163
164
|
hasValue: !!Q,
|
|
164
|
-
onClear:
|
|
165
|
+
onClear: _e,
|
|
165
166
|
intent: S ? "danger" : "default",
|
|
166
|
-
width:
|
|
167
|
-
fullWidth:
|
|
167
|
+
width: ue,
|
|
168
|
+
fullWidth: de,
|
|
168
169
|
rightIcons: [{
|
|
169
170
|
name: "ChevronDownIcon",
|
|
170
|
-
rotated:
|
|
171
|
+
rotated: N
|
|
171
172
|
}],
|
|
172
|
-
className: p(
|
|
173
|
+
className: p(N && s.open),
|
|
173
174
|
children: /* @__PURE__ */ m("div", {
|
|
174
|
-
id:
|
|
175
|
-
ref:
|
|
175
|
+
id: pe,
|
|
176
|
+
ref: W,
|
|
176
177
|
className: p(s.trigger, w && s.disabled),
|
|
177
|
-
onClick:
|
|
178
|
-
onKeyDown:
|
|
178
|
+
onClick: q,
|
|
179
|
+
onKeyDown: ve,
|
|
179
180
|
tabIndex: w ? -1 : 0,
|
|
180
181
|
role: "combobox",
|
|
181
|
-
"aria-expanded":
|
|
182
|
-
"aria-controls":
|
|
182
|
+
"aria-expanded": N,
|
|
183
|
+
"aria-controls": N ? M : void 0,
|
|
183
184
|
"aria-haspopup": "listbox",
|
|
184
185
|
"aria-disabled": w,
|
|
185
|
-
"aria-labelledby":
|
|
186
|
-
"aria-label":
|
|
187
|
-
"aria-describedby": [
|
|
186
|
+
"aria-labelledby": j,
|
|
187
|
+
"aria-label": j ? void 0 : E || $() || g(b),
|
|
188
|
+
"aria-describedby": [le, A].filter(Boolean).join(" ") || void 0,
|
|
188
189
|
"aria-required": C,
|
|
189
190
|
"aria-invalid": !!S,
|
|
190
|
-
"aria-activedescendant":
|
|
191
|
+
"aria-activedescendant": N && R >= 0 ? `${O}-menu-${R}-option-${B[R]}` : void 0,
|
|
191
192
|
children: /* @__PURE__ */ m("div", {
|
|
192
193
|
className: p(s.value, !Q && s.placeholder),
|
|
193
194
|
children: Q || b
|
|
194
195
|
})
|
|
195
196
|
})
|
|
196
|
-
}), /* @__PURE__ */ m(
|
|
197
|
-
show:
|
|
197
|
+
}), /* @__PURE__ */ m(n, {
|
|
198
|
+
show: N && !w,
|
|
198
199
|
preset: "fade",
|
|
199
|
-
id:
|
|
200
|
+
id: M,
|
|
200
201
|
className: s.dropdown,
|
|
201
|
-
ref:
|
|
202
|
-
...
|
|
202
|
+
ref: be,
|
|
203
|
+
...xe,
|
|
203
204
|
children: X.map((e, t) => /* @__PURE__ */ m("div", {
|
|
204
205
|
className: s.menu,
|
|
205
206
|
role: "listbox",
|
|
206
|
-
"aria-labelledby":
|
|
207
|
-
"aria-label":
|
|
208
|
-
children: e.map((e,
|
|
209
|
-
let
|
|
210
|
-
return /* @__PURE__ */ m(
|
|
211
|
-
className: p(s.menuItem,
|
|
212
|
-
active:
|
|
207
|
+
"aria-labelledby": j,
|
|
208
|
+
"aria-label": j ? void 0 : E || $() || g(b),
|
|
209
|
+
children: e.map((e, n) => {
|
|
210
|
+
let a = I[t] === e.value, o = R === t && B[t] === n, c = K[t] === e.value, l = e.children && e.children.length > 0;
|
|
211
|
+
return /* @__PURE__ */ m(ee, {
|
|
212
|
+
className: p(s.menuItem, c && s.selected),
|
|
213
|
+
active: o || a,
|
|
213
214
|
disabled: e.disabled,
|
|
214
215
|
onClick: (n) => {
|
|
215
|
-
n.stopPropagation(),
|
|
216
|
+
n.stopPropagation(), J(e, t);
|
|
216
217
|
},
|
|
217
218
|
onMouseEnter: () => {
|
|
218
|
-
|
|
219
|
+
Y(e, t), z(t), V((e) => [...e.slice(0, t), n]);
|
|
219
220
|
},
|
|
220
|
-
rightSection:
|
|
221
|
-
component:
|
|
221
|
+
rightSection: l ? /* @__PURE__ */ m(i, {
|
|
222
|
+
component: r,
|
|
222
223
|
size: "sm"
|
|
223
224
|
}) : void 0,
|
|
224
225
|
role: "option",
|
|
225
|
-
id: `${
|
|
226
|
-
"aria-selected":
|
|
226
|
+
id: `${O}-menu-${t}-option-${n}`,
|
|
227
|
+
"aria-selected": c,
|
|
227
228
|
tabIndex: -1,
|
|
228
229
|
children: e.label
|
|
229
230
|
}, e.value);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../node_modules/@radix-ui/react-slot/dist/index.cjs"),n=require("../../../i18n/useWimTranslation.cjs"),r=require("../../../hooks/useMergedRef.cjs"),i=require("../../layout/Transition/Transition.cjs"),a=require("../../overlay/FocusTrap/FocusTrap.cjs"),o=require("../../../i18n/generated/components.cjs"),
|
|
2
|
+
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../node_modules/@radix-ui/react-slot/dist/index.cjs"),n=require("../../../i18n/useWimTranslation.cjs"),r=require("../../../hooks/useMergedRef.cjs"),i=require("../../_internal/composeEventHandlers.cjs"),ee=require("../../layout/Transition/Transition.cjs"),a=require("../../overlay/FocusTrap/FocusTrap.cjs"),o=require("../../../i18n/generated/components.cjs"),te=require("../InputBase/InputBase.cjs"),s=require("../../_internal/useInlineFloating.cjs"),c=require("../FieldTemplate/FieldTemplate.cjs"),l=require("../Input/input.module.cjs"),u=require("../../data-display/Calendar/Calendar.cjs"),d=require("./date-picker.module.cjs");let f=require("react");f=e.__toESM(f,1);let p=require("classnames");p=e.__toESM(p,1);let m=require("react/jsx-runtime");var h=(0,f.forwardRef)(({intent:e=`default`,variant:h=`outline`,fullWidth:g=!1,className:_,disabled:v,value:y,defaultValue:b,onChange:x,format:ne=`YYYY-MM-DD`,clearable:S=!0,placeholder:C,minDate:re,maxDate:ie,disabledDates:ae,label:w,error:T,required:E,layout:D,id:O,labels:k,width:A,asChild:j=!1,children:M,...N},P)=>{let[F,I]=(0,f.useState)(!1),[L,R]=(0,f.useState)(b||null),z=(0,f.useRef)(null),B=(0,f.useRef)(null),{t:V}=n.useWimTranslation(o.componentsNs),H=(0,f.useId)(),U=O||`wim-datepicker-${H}`,W=`${U}-dropdown`,G=w?`${U}-label`:void 0,K=T?`${U}-error`:void 0,q=y!==void 0,J=q?y:L,Y=C??k?.placeholder,X=v,Z=T?`danger`:e;(0,f.useEffect)(()=>{let e=e=>{z.current&&!z.current.contains(e.target)&&I(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[]),(0,f.useEffect)(()=>{let e=e=>{e.key===`Escape`&&F&&(I(!1),B.current?.focus())};return F&&document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[F]);let oe=e=>{if(!e)return``;let t=e.getFullYear(),n=String(e.getMonth()+1).padStart(2,`0`),r=String(e.getDate()).padStart(2,`0`);return ne.replace(`YYYY`,String(t)).replace(`MM`,n).replace(`DD`,r)},se=e=>{q||R(e),x?.(e),I(!1),B.current?.focus()},ce=e=>{e?.stopPropagation(),X||(q||R(null),x?.(null))},Q=()=>{X||I(!F)},$=e=>{X||(e.key===`Escape`?(I(!1),B.current?.focus()):(e.key===`Enter`||e.key===` `||e.key===`ArrowDown`&&(e.altKey||!F))&&(e.preventDefault(),I(!F)))};(0,f.useEffect)(()=>{if(F){let e=setTimeout(()=>{let e=z.current?.querySelector(`[data-calendar-day][tabindex="0"]:not(:disabled), [data-calendar-day][data-selected]:not(:disabled), [data-calendar-day]:focus`);e?e.focus():z.current?.querySelector(`[data-calendar-day]:not([data-other-month]):not(:disabled)`)?.focus()},50);return()=>clearTimeout(e)}},[F]);let le=j?t.Root:`div`,{setReference:ue,setFloating:de,floatingProps:fe}=s.useInlineFloating({open:F&&!v}),pe=r.useMergedRef(z,P,ue);return(0,m.jsx)(c.FieldTemplate,{label:w,error:T,required:E,layout:D,labelId:G,htmlFor:U,errorId:K,className:_,children:(0,m.jsxs)(le,{ref:pe,className:(0,p.default)(`wim-date-picker`,d.default.root,g&&d.default.fullWidth),children:[(0,m.jsx)(te.InputBase,{intent:Z,variant:h,width:A,fullWidth:g,disabled:X,allowClear:S,hasValue:!!J,onClear:ce,rightIcons:[{name:`ChevronDownIcon`,rotated:F,onClick:Q,decorative:!0}],children:(0,m.jsx)(`input`,{id:U,ref:B,type:`text`,readOnly:!0,role:`combobox`,className:(0,p.default)(l.default.root,d.default.input),value:oe(J),placeholder:Y,disabled:X,"aria-haspopup":`dialog`,"aria-expanded":F,"aria-controls":F?W:void 0,"aria-invalid":Z===`danger`,"aria-describedby":K,"aria-labelledby":G,"aria-required":E,...N,onClick:i.composeEventHandlers(N.onClick,Q),onKeyDown:i.composeEventHandlers(N.onKeyDown,$)})}),(0,m.jsx)(ee.Transition,{show:F&&!v,preset:`fade`,id:W,className:d.default.dropdown,ref:de,...fe,children:(0,m.jsx)(a.FocusTrap,{active:F,initialFocus:!1,children:(0,m.jsx)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-labelledby":G,"aria-label":G?void 0:N[`aria-label`]??V(`datepicker.dialog`),children:(0,m.jsx)(u.Calendar,{value:J??void 0,onChange:se})})})}),(0,m.jsx)(t.Slottable,{children:M})]})})});h.displayName=`DatePicker`,exports.DatePicker=h,exports.default=h;
|