wimui 0.39.0 → 0.40.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/data-display/SwipeAction/SwipeAction.cjs +1 -1
- package/dist/components/data-display/SwipeAction/SwipeAction.d.ts +6 -0
- package/dist/components/data-display/SwipeAction/SwipeAction.js +78 -63
- package/dist/components/data-display/SwipeAction/swipe-action.module.cjs +1 -1
- package/dist/components/data-display/SwipeAction/swipe-action.module.js +13 -10
- package/dist/i18n/generated/keys.d.ts +1 -1
- package/dist/llms-full.txt +4 -1
- package/dist/llms.txt +1 -1
- package/dist/locales/en/common.json +3 -1
- package/dist/locales/ja/common.json +3 -1
- package/dist/locales/pt/common.json +3 -1
- package/dist/styles.css +1 -1
- package/dist/wimui.umd.css +1 -1
- package/dist/wimui.umd.js +1 -1
- package/package.json +1 -1
|
@@ -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("../../media/Icon/Icon.cjs"),r=require("./swipe-action.module.cjs"),i=require("./SwipeableList.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=a.default.forwardRef(({as:e=`div`,leftActions:c=[],rightActions:l=[],children:u,asChild:d=!1,id:f,closeOnAction:p=!0,className:
|
|
2
|
+
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../node_modules/@radix-ui/react-slot/dist/index.cjs"),n=require("../../media/Icon/Icon.cjs"),r=require("./swipe-action.module.cjs"),i=require("./SwipeableList.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=a.default.forwardRef(({as:e=`div`,leftActions:c=[],rightActions:l=[],children:u,asChild:d=!1,id:f,closeOnAction:p=!0,fullSwipe:m,className:h,...g},_)=>{let v=(0,a.useId)(),y=f||v,b=i.useSwipeableList(),[x,S]=(0,a.useState)(0),[C,w]=(0,a.useState)(!1),T=(0,a.useRef)(0),E=(0,a.useRef)(0),D=(0,a.useRef)(null);(0,a.useImperativeHandle)(_,()=>({close:()=>{S(0),b?.reportClose(y)}}));let O=(0,a.useRef)(!1);(0,a.useEffect)(()=>{if(C){O.current=!0;return}if(O.current){let e=setTimeout(()=>{O.current=!1},100);return()=>clearTimeout(e)}b?.openedId&&b.openedId!==y&&S(0)},[b?.openedId,y,C]);let k=c.length*80,A=l.length*80,j=k>0&&(m===`left`||m===`both`),M=A>0&&(m===`right`||m===`both`),N=D.current?.offsetWidth??0,P=e=>Math.max(e+40,N/2),F=C&&j&&x>=P(k)?`left`:C&&M&&-x>=P(A)?`right`:null,I=e=>{T.current=`touches`in e?e.touches[0].clientX:e.clientX,E.current=x,w(!0)},L=e=>{if(!C)return;let t=(`touches`in e?e.touches[0].clientX:e.clientX)-T.current,n=E.current+t;Math.abs(t)>5&&b?.openedId!==y&&b?.reportOpen(y),n>k&&!j&&(n=k+(n-k)*.3),n<-A&&!M&&(n=-A+(n+A)*.3),S(n)},R=(e=!0)=>{if(C){if(w(!1),F){let t=F===`left`?c[0]:l[l.length-1];if(e){W(t),p||(S(F===`left`?k:-A),b?.reportOpen(y));return}}x>k/2?(S(k),b?.reportOpen(y)):x<-A/2?(S(-A),b?.reportOpen(y)):(S(0),b?.reportClose(y))}},z=d?t.Root:`div`,B=(0,a.useRef)(null),V=k>0||A>0,H=e=>{let t=e===`left`?k:-A;x!==t&&S(t),b?.reportOpen(y)},U=e=>{let t=e.relatedTarget;t&&D.current?.contains(t)||x!==0&&!C&&(S(0),b?.reportClose(y))},W=(e,t)=>{e.onClick(),p&&(S(0),b?.reportClose(y),t&&document.activeElement===t&&B.current?.focus())},G=(e,t,i)=>{let a=e===`left`?j:M,c=e===`left`?Math.max(0,x):Math.max(0,-x),l=e===`left`?0:t.length-1;return(0,s.jsx)(`div`,{className:(0,o.default)(r.default.actions,r.default[e],a&&c>i&&r.default.stretched,F===e&&r.default.armed),style:{width:a?Math.max(i,c):i,"--_action-w":`80px`},children:t.map((t,i)=>(0,s.jsxs)(`button`,{className:(0,o.default)(r.default.action,t.intent&&r.default[t.intent],a&&i===l&&r.default.outer),style:{backgroundColor:t.color},onFocus:()=>H(e),onClick:e=>W(t,e.currentTarget),type:`button`,children:[(0,s.jsx)(n.Icon,{name:t.icon,size:`md`}),(0,s.jsx)(`span`,{className:r.default.label,children:t.label})]},i))})};return(0,s.jsxs)(e,{ref:D,className:(0,o.default)(`wim-swipe-action`,r.default.container,h),onMouseLeave:()=>R(!1),onBlur:U,...g,children:[(0,s.jsx)(z,{ref:B,className:r.default.content,tabIndex:V?-1:void 0,style:{transform:`translateX(${x}px)`,transition:C?`none`:`transform 0.4s cubic-bezier(0.16, 1, 0.3, 1)`},onTouchStart:I,onTouchMove:L,onTouchEnd:()=>R(),onMouseDown:I,onMouseMove:L,onMouseUp:()=>R(),children:u}),k>0&&G(`left`,c,k),A>0&&G(`right`,l,A)]})});c.displayName=`SwipeAction`,exports.SwipeAction=c;
|
|
@@ -27,6 +27,12 @@ export interface SwipeActionProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
|
27
27
|
id?: string;
|
|
28
28
|
/** Whether to automatically close the actions when an action is clicked. Default is true. */
|
|
29
29
|
closeOnAction?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Sides where swiping all the way across runs the outermost action without a tap
|
|
32
|
+
* (`leftActions[0]` / the last of `rightActions`), as in iOS Mail. Off by default so a
|
|
33
|
+
* destructive action is never triggered by momentum; the action stays available as a button.
|
|
34
|
+
*/
|
|
35
|
+
fullSwipe?: "left" | "right" | "both";
|
|
30
36
|
}
|
|
31
37
|
export interface SwipeActionRef {
|
|
32
38
|
/** Method to programmatically close the swipe actions */
|
|
@@ -7,88 +7,103 @@ import i, { useEffect as a, useId as o, useImperativeHandle as s, useRef as c, u
|
|
|
7
7
|
import u from "classnames";
|
|
8
8
|
import { jsx as d, jsxs as f } from "react/jsx-runtime";
|
|
9
9
|
//#region src/components/data-display/SwipeAction/SwipeAction.tsx
|
|
10
|
-
var p = i.forwardRef(({ as: i = "div", leftActions: p = [], rightActions: m = [], children: h, asChild: g = !1, id: _, closeOnAction: v = !0,
|
|
11
|
-
let
|
|
12
|
-
s(
|
|
13
|
-
|
|
10
|
+
var p = i.forwardRef(({ as: i = "div", leftActions: p = [], rightActions: m = [], children: h, asChild: g = !1, id: _, closeOnAction: v = !0, fullSwipe: y, className: b, ...x }, S) => {
|
|
11
|
+
let C = o(), w = _ || C, T = r(), [E, D] = l(0), [O, k] = l(!1), A = c(0), j = c(0), M = c(null);
|
|
12
|
+
s(S, () => ({ close: () => {
|
|
13
|
+
D(0), T?.reportClose(w);
|
|
14
14
|
} }));
|
|
15
|
-
let
|
|
15
|
+
let N = c(!1);
|
|
16
16
|
a(() => {
|
|
17
|
-
if (
|
|
18
|
-
|
|
17
|
+
if (O) {
|
|
18
|
+
N.current = !0;
|
|
19
19
|
return;
|
|
20
20
|
}
|
|
21
|
-
if (
|
|
21
|
+
if (N.current) {
|
|
22
22
|
let e = setTimeout(() => {
|
|
23
|
-
|
|
23
|
+
N.current = !1;
|
|
24
24
|
}, 100);
|
|
25
25
|
return () => clearTimeout(e);
|
|
26
26
|
}
|
|
27
|
-
|
|
27
|
+
T?.openedId && T.openedId !== w && D(0);
|
|
28
28
|
}, [
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
T?.openedId,
|
|
30
|
+
w,
|
|
31
|
+
O
|
|
32
32
|
]);
|
|
33
|
-
let
|
|
34
|
-
|
|
35
|
-
}, I = (e) => {
|
|
36
|
-
if (!D) return;
|
|
37
|
-
let t = ("touches" in e ? e.touches[0].clientX : e.clientX) - k.current, n = A.current + t;
|
|
38
|
-
Math.abs(t) > 5 && w?.openedId !== C && w?.reportOpen(C), n > N && (n = N + (n - N) * .3), n < -P && (n = -P + (n + P) * .3), E(n);
|
|
39
|
-
}, L = () => {
|
|
40
|
-
D && (O(!1), T > N / 2 ? (E(N), w?.reportOpen(C)) : T < -P / 2 ? (E(-P), w?.reportOpen(C)) : (E(0), w?.reportClose(C)));
|
|
41
|
-
}, R = g ? e : "div", z = c(null), B = N > 0 || P > 0, V = (e) => {
|
|
42
|
-
let t = e === "left" ? N : -P;
|
|
43
|
-
T !== t && E(t), w?.reportOpen(C);
|
|
33
|
+
let P = p.length * 80, F = m.length * 80, I = P > 0 && (y === "left" || y === "both"), L = F > 0 && (y === "right" || y === "both"), R = M.current?.offsetWidth ?? 0, z = (e) => Math.max(e + 40, R / 2), B = O && I && E >= z(P) ? "left" : O && L && -E >= z(F) ? "right" : null, V = (e) => {
|
|
34
|
+
A.current = "touches" in e ? e.touches[0].clientX : e.clientX, j.current = E, k(!0);
|
|
44
35
|
}, H = (e) => {
|
|
36
|
+
if (!O) return;
|
|
37
|
+
let t = ("touches" in e ? e.touches[0].clientX : e.clientX) - A.current, n = j.current + t;
|
|
38
|
+
Math.abs(t) > 5 && T?.openedId !== w && T?.reportOpen(w), n > P && !I && (n = P + (n - P) * .3), n < -F && !L && (n = -F + (n + F) * .3), D(n);
|
|
39
|
+
}, U = (e = !0) => {
|
|
40
|
+
if (O) {
|
|
41
|
+
if (k(!1), B) {
|
|
42
|
+
let t = B === "left" ? p[0] : m[m.length - 1];
|
|
43
|
+
if (e) {
|
|
44
|
+
Y(t), v || (D(B === "left" ? P : -F), T?.reportOpen(w));
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
E > P / 2 ? (D(P), T?.reportOpen(w)) : E < -F / 2 ? (D(-F), T?.reportOpen(w)) : (D(0), T?.reportClose(w));
|
|
49
|
+
}
|
|
50
|
+
}, W = g ? e : "div", G = c(null), K = P > 0 || F > 0, q = (e) => {
|
|
51
|
+
let t = e === "left" ? P : -F;
|
|
52
|
+
E !== t && D(t), T?.reportOpen(w);
|
|
53
|
+
}, J = (e) => {
|
|
45
54
|
let t = e.relatedTarget;
|
|
46
|
-
t &&
|
|
47
|
-
},
|
|
48
|
-
e.onClick(), v && (
|
|
49
|
-
},
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
children:
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
55
|
+
t && M.current?.contains(t) || E !== 0 && !O && (D(0), T?.reportClose(w));
|
|
56
|
+
}, Y = (e, t) => {
|
|
57
|
+
e.onClick(), v && (D(0), T?.reportClose(w), t && document.activeElement === t && G.current?.focus());
|
|
58
|
+
}, X = (e, r, i) => {
|
|
59
|
+
let a = e === "left" ? I : L, o = e === "left" ? Math.max(0, E) : Math.max(0, -E), s = e === "left" ? 0 : r.length - 1;
|
|
60
|
+
return /* @__PURE__ */ d("div", {
|
|
61
|
+
className: u(n.actions, n[e], a && o > i && n.stretched, B === e && n.armed),
|
|
62
|
+
style: {
|
|
63
|
+
width: a ? Math.max(i, o) : i,
|
|
64
|
+
"--_action-w": "80px"
|
|
65
|
+
},
|
|
66
|
+
children: r.map((r, i) => /* @__PURE__ */ f("button", {
|
|
67
|
+
className: u(n.action, r.intent && n[r.intent], a && i === s && n.outer),
|
|
68
|
+
style: { backgroundColor: r.color },
|
|
69
|
+
onFocus: () => q(e),
|
|
70
|
+
onClick: (e) => Y(r, e.currentTarget),
|
|
71
|
+
type: "button",
|
|
72
|
+
children: [/* @__PURE__ */ d(t, {
|
|
73
|
+
name: r.icon,
|
|
74
|
+
size: "md"
|
|
75
|
+
}), /* @__PURE__ */ d("span", {
|
|
76
|
+
className: n.label,
|
|
77
|
+
children: r.label
|
|
78
|
+
})]
|
|
79
|
+
}, i))
|
|
80
|
+
});
|
|
81
|
+
};
|
|
67
82
|
return /* @__PURE__ */ f(i, {
|
|
68
|
-
ref:
|
|
69
|
-
className: u("wim-swipe-action", n.container,
|
|
70
|
-
onMouseLeave:
|
|
71
|
-
onBlur:
|
|
72
|
-
...
|
|
83
|
+
ref: M,
|
|
84
|
+
className: u("wim-swipe-action", n.container, b),
|
|
85
|
+
onMouseLeave: () => U(!1),
|
|
86
|
+
onBlur: J,
|
|
87
|
+
...x,
|
|
73
88
|
children: [
|
|
74
|
-
/* @__PURE__ */ d(
|
|
75
|
-
ref:
|
|
89
|
+
/* @__PURE__ */ d(W, {
|
|
90
|
+
ref: G,
|
|
76
91
|
className: n.content,
|
|
77
|
-
tabIndex:
|
|
92
|
+
tabIndex: K ? -1 : void 0,
|
|
78
93
|
style: {
|
|
79
|
-
transform: `translateX(${
|
|
80
|
-
transition:
|
|
94
|
+
transform: `translateX(${E}px)`,
|
|
95
|
+
transition: O ? "none" : "transform 0.4s cubic-bezier(0.16, 1, 0.3, 1)"
|
|
81
96
|
},
|
|
82
|
-
onTouchStart:
|
|
83
|
-
onTouchMove:
|
|
84
|
-
onTouchEnd:
|
|
85
|
-
onMouseDown:
|
|
86
|
-
onMouseMove:
|
|
87
|
-
onMouseUp:
|
|
97
|
+
onTouchStart: V,
|
|
98
|
+
onTouchMove: H,
|
|
99
|
+
onTouchEnd: () => U(),
|
|
100
|
+
onMouseDown: V,
|
|
101
|
+
onMouseMove: H,
|
|
102
|
+
onMouseUp: () => U(),
|
|
88
103
|
children: h
|
|
89
104
|
}),
|
|
90
|
-
|
|
91
|
-
|
|
105
|
+
P > 0 && X("left", p, P),
|
|
106
|
+
F > 0 && X("right", m, F)
|
|
92
107
|
]
|
|
93
108
|
});
|
|
94
109
|
});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
var e=`
|
|
2
|
+
var e=`_container_13gak_3`,t=`_actions_13gak_11`,n=`_left_13gak_18`,r=`_right_13gak_21`,i=`_stretched_13gak_28`,a=`_action_13gak_11`,o=`_outer_13gak_28`,s=`_armed_13gak_35`,c=`_primary_13gak_63`,l=`_danger_13gak_66`,u=`_warning_13gak_69`,d=`_success_13gak_73`,f=`_neutral_13gak_76`,p=`_label_13gak_79`,m=`_content_13gak_82`,h={container:e,actions:t,left:n,right:r,stretched:i,action:a,outer:o,armed:s,primary:c,danger:l,warning:u,success:d,neutral:f,label:p,content:m};exports.action=a,exports.actions=t,exports.armed=s,exports.container=e,exports.content=m,exports.danger=l,exports.default=h,exports.label=p,exports.left=n,exports.neutral=f,exports.outer=o,exports.primary=c,exports.right=r,exports.stretched=i,exports.success=d,exports.warning=u;
|
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
//#region src/components/data-display/SwipeAction/swipe-action.module.scss
|
|
3
|
-
var e = "
|
|
3
|
+
var e = "_container_13gak_3", t = "_actions_13gak_11", n = "_left_13gak_18", r = "_right_13gak_21", i = "_stretched_13gak_28", a = "_action_13gak_11", o = "_outer_13gak_28", s = "_armed_13gak_35", c = "_primary_13gak_63", l = "_danger_13gak_66", u = "_warning_13gak_69", d = "_success_13gak_73", f = "_neutral_13gak_76", p = "_label_13gak_79", m = "_content_13gak_82", h = {
|
|
4
4
|
container: e,
|
|
5
5
|
actions: t,
|
|
6
6
|
left: n,
|
|
7
7
|
right: r,
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
8
|
+
stretched: i,
|
|
9
|
+
action: a,
|
|
10
|
+
outer: o,
|
|
11
|
+
armed: s,
|
|
12
|
+
primary: c,
|
|
13
|
+
danger: l,
|
|
14
|
+
warning: u,
|
|
15
|
+
success: d,
|
|
16
|
+
neutral: f,
|
|
17
|
+
label: p,
|
|
18
|
+
content: m
|
|
16
19
|
};
|
|
17
20
|
//#endregion
|
|
18
|
-
export {
|
|
21
|
+
export { a as action, t as actions, s as armed, e as container, m as content, l as danger, h as default, p as label, n as left, f as neutral, o as outer, c as primary, r as right, i as stretched, d as success, u as warning };
|