reaxify 0.0.98 → 1.2.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/axios/useAxios.cjs.js +1 -1
- package/dist/axios/useAxios.es.js +7 -7
- package/dist/components/Accordion/index.cjs.js +1 -1
- package/dist/components/Accordion/index.d.ts +2 -2
- package/dist/components/Accordion/index.d.ts.map +1 -1
- package/dist/components/Accordion/index.es.js +78 -97
- package/dist/components/Alert/index.cjs.js +1 -1
- package/dist/components/Alert/index.d.ts +1 -6
- package/dist/components/Alert/index.d.ts.map +1 -1
- package/dist/components/Alert/index.es.js +111 -95
- package/dist/components/Avatar/index.cjs.js +1 -1
- package/dist/components/Avatar/index.d.ts.map +1 -1
- package/dist/components/Avatar/index.es.js +62 -55
- package/dist/components/Badge/index.cjs.js +1 -1
- package/dist/components/Badge/index.d.ts +1 -1
- package/dist/components/Badge/index.d.ts.map +1 -1
- package/dist/components/Badge/index.es.js +33 -34
- package/dist/components/Button/index.cjs.js +1 -1
- package/dist/components/Button/index.d.ts +1 -1
- package/dist/components/Button/index.d.ts.map +1 -1
- package/dist/components/Button/index.es.js +95 -98
- package/dist/components/ButtonGroup/index.cjs.js +1 -1
- package/dist/components/ButtonGroup/index.d.ts +0 -4
- package/dist/components/ButtonGroup/index.d.ts.map +1 -1
- package/dist/components/ButtonGroup/index.es.js +40 -37
- package/dist/components/Card/index.cjs.js +1 -1
- package/dist/components/Card/index.d.ts.map +1 -1
- package/dist/components/Card/index.es.js +48 -38
- package/dist/components/Collapse/index.cjs.js +1 -0
- package/dist/components/Collapse/index.d.ts +14 -0
- package/dist/components/Collapse/index.d.ts.map +1 -0
- package/dist/components/Collapse/index.es.js +56 -0
- package/dist/components/Divider/index.cjs.js +1 -1
- package/dist/components/Divider/index.d.ts.map +1 -1
- package/dist/components/Divider/index.es.js +16 -14
- package/dist/components/Drawer/index.cjs.js +1 -1
- package/dist/components/Drawer/index.d.ts +1 -0
- package/dist/components/Drawer/index.d.ts.map +1 -1
- package/dist/components/Drawer/index.es.js +72 -56
- package/dist/components/Fill/index.cjs.js +1 -1
- package/dist/components/Fill/index.d.ts.map +1 -1
- package/dist/components/Fill/index.es.js +14 -8
- package/dist/components/InputGroup/index.cjs.js +1 -1
- package/dist/components/InputGroup/index.d.ts.map +1 -1
- package/dist/components/InputGroup/index.es.js +49 -38
- package/dist/components/Menu/index.cjs.js +1 -1
- package/dist/components/Menu/index.d.ts +3 -2
- package/dist/components/Menu/index.d.ts.map +1 -1
- package/dist/components/Menu/index.es.js +115 -99
- package/dist/components/Modal/index.cjs.js +1 -1
- package/dist/components/Modal/index.d.ts +2 -0
- package/dist/components/Modal/index.d.ts.map +1 -1
- package/dist/components/Modal/index.es.js +83 -59
- package/dist/components/Portal/index.cjs.js +1 -1
- package/dist/components/Portal/index.d.ts.map +1 -1
- package/dist/components/Portal/index.es.js +5 -4
- package/dist/components/Progress/index.cjs.js +1 -1
- package/dist/components/Progress/index.d.ts +1 -1
- package/dist/components/Progress/index.d.ts.map +1 -1
- package/dist/components/Progress/index.es.js +27 -22
- package/dist/components/Skeleton/index.cjs.js +1 -1
- package/dist/components/Skeleton/index.d.ts.map +1 -1
- package/dist/components/Skeleton/index.es.js +8 -8
- package/dist/components/Spacer/index.cjs.js +1 -1
- package/dist/components/Spacer/index.d.ts.map +1 -1
- package/dist/components/Spacer/index.es.js +5 -5
- package/dist/components/Spinner/index.cjs.js +1 -1
- package/dist/components/Spinner/index.d.ts +3 -2
- package/dist/components/Spinner/index.d.ts.map +1 -1
- package/dist/components/Spinner/index.es.js +17 -16
- package/dist/components/Stack/index.cjs.js +1 -1
- package/dist/components/Stack/index.d.ts.map +1 -1
- package/dist/components/Stack/index.es.js +25 -24
- package/dist/components/Switch/index.cjs.js +1 -1
- package/dist/components/Switch/index.d.ts.map +1 -1
- package/dist/components/Switch/index.es.js +17 -13
- package/dist/components/Table/index.cjs.js +1 -1
- package/dist/components/Table/index.d.ts.map +1 -1
- package/dist/components/Table/index.es.js +72 -58
- package/dist/components/Tabs/index.cjs.js +1 -1
- package/dist/components/Tabs/index.d.ts +1 -1
- package/dist/components/Tabs/index.d.ts.map +1 -1
- package/dist/components/Tabs/index.es.js +58 -48
- package/dist/components/Toggle/index.cjs.js +1 -0
- package/dist/components/Toggle/index.d.ts +48 -0
- package/dist/components/Toggle/index.d.ts.map +1 -0
- package/dist/components/Toggle/index.es.js +115 -0
- package/dist/components/Tooltip/index.cjs.js +1 -1
- package/dist/components/Tooltip/index.d.ts +16 -9
- package/dist/components/Tooltip/index.d.ts.map +1 -1
- package/dist/components/Tooltip/index.es.js +191 -114
- package/dist/components/Typography/index.cjs.js +1 -1
- package/dist/components/Typography/index.d.ts +2 -2
- package/dist/components/Typography/index.d.ts.map +1 -1
- package/dist/components/Typography/index.es.js +13 -12
- package/dist/components/index.cjs.js +1 -1
- package/dist/components/index.d.ts +3 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.es.js +48 -43
- package/dist/helpers/anchorPointer.cjs.js +1 -0
- package/dist/helpers/anchorPointer.d.ts +8 -0
- package/dist/helpers/anchorPointer.d.ts.map +1 -0
- package/dist/helpers/anchorPointer.es.js +12 -0
- package/dist/helpers/index.cjs.js +1 -1
- package/dist/helpers/index.d.ts +1 -0
- package/dist/helpers/index.d.ts.map +1 -1
- package/dist/helpers/index.es.js +25 -22
- package/dist/hooks/index.cjs.js +1 -1
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.es.js +6 -4
- package/dist/hooks/usePreventableClose.cjs.js +1 -0
- package/dist/hooks/usePreventableClose.d.ts +8 -0
- package/dist/hooks/usePreventableClose.d.ts.map +1 -0
- package/dist/hooks/usePreventableClose.es.js +21 -0
- package/dist/node_modules/prop-types/factoryWithTypeCheckers.es.js +1 -1
- package/dist/node_modules/prop-types/index.es.js +1 -1
- package/dist/node_modules/prop-types/node_modules/react-is/index.es.js +1 -1
- package/dist/providers/ThemeProvider.d.ts +13 -1
- package/dist/providers/ThemeProvider.d.ts.map +1 -1
- package/dist/providers/index.cjs.js +1 -1
- package/dist/providers/index.d.ts.map +1 -1
- package/dist/providers/index.es.js +3 -2
- package/dist/stores/portalElement.cjs.js +1 -1
- package/dist/stores/portalElement.d.ts.map +1 -1
- package/dist/stores/portalElement.es.js +13 -9
- package/dist/style.css +1 -0
- package/package.json +7 -3
- package/dist/reaxify.css +0 -1
|
@@ -1,142 +1,156 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as n } from "react/jsx-runtime";
|
|
3
|
-
import i from "../../hooks/useClasses.es.js";
|
|
4
3
|
import { createContext as p, useContext as x } from "react";
|
|
5
|
-
import { twMerge as
|
|
4
|
+
import { twMerge as l } from "../../node_modules/tailwind-merge/dist/bundle-mjs.es.js";
|
|
5
|
+
import i from "../../hooks/useClasses.es.js";
|
|
6
6
|
const f = p({
|
|
7
7
|
striped: !1,
|
|
8
8
|
bordered: !1,
|
|
9
9
|
hover: !1
|
|
10
10
|
});
|
|
11
11
|
function w({
|
|
12
|
-
className:
|
|
13
|
-
children:
|
|
14
|
-
...
|
|
12
|
+
className: a,
|
|
13
|
+
children: r,
|
|
14
|
+
...o
|
|
15
15
|
}) {
|
|
16
16
|
const e = i((t) => t.table.container.base);
|
|
17
17
|
return /* @__PURE__ */ n(
|
|
18
18
|
"div",
|
|
19
19
|
{
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
"data-name": "table-container",
|
|
21
|
+
className: l("w-full overflow-auto", e, a),
|
|
22
|
+
...o,
|
|
23
|
+
children: r
|
|
23
24
|
}
|
|
24
25
|
);
|
|
25
26
|
}
|
|
26
|
-
function
|
|
27
|
-
striped:
|
|
28
|
-
bordered:
|
|
29
|
-
hover:
|
|
27
|
+
function s({
|
|
28
|
+
striped: a = !1,
|
|
29
|
+
bordered: r = !1,
|
|
30
|
+
hover: o = !1,
|
|
30
31
|
className: e,
|
|
31
32
|
children: t,
|
|
32
|
-
...
|
|
33
|
+
...d
|
|
33
34
|
}) {
|
|
34
35
|
const b = i((c) => c.table.base);
|
|
35
36
|
return /* @__PURE__ */ n(
|
|
36
37
|
"table",
|
|
37
38
|
{
|
|
38
|
-
|
|
39
|
+
"data-name": "table",
|
|
40
|
+
className: l(
|
|
39
41
|
"min-w-full border-collapse border-spacing-0",
|
|
40
42
|
b,
|
|
41
43
|
e
|
|
42
44
|
),
|
|
43
|
-
...
|
|
44
|
-
children: /* @__PURE__ */ n(f.Provider, { value: { bordered:
|
|
45
|
+
...d,
|
|
46
|
+
children: /* @__PURE__ */ n(f.Provider, { value: { bordered: r, hover: o, striped: a }, children: t })
|
|
45
47
|
}
|
|
46
48
|
);
|
|
47
49
|
}
|
|
48
50
|
function y({
|
|
49
|
-
sticky:
|
|
50
|
-
className:
|
|
51
|
-
children:
|
|
51
|
+
sticky: a = !1,
|
|
52
|
+
className: r,
|
|
53
|
+
children: o,
|
|
52
54
|
...e
|
|
53
55
|
}) {
|
|
54
|
-
const t = i((
|
|
56
|
+
const t = i((d) => d.table.header);
|
|
55
57
|
return /* @__PURE__ */ n(
|
|
56
58
|
"thead",
|
|
57
59
|
{
|
|
58
|
-
|
|
60
|
+
"data-name": "table-header",
|
|
61
|
+
className: l(
|
|
59
62
|
t == null ? void 0 : t.base,
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
+
a && "sticky top-0 left-0 right-0 z-[2]",
|
|
64
|
+
a && (t == null ? void 0 : t.sticky),
|
|
65
|
+
r
|
|
63
66
|
),
|
|
64
67
|
...e,
|
|
65
|
-
children:
|
|
68
|
+
children: o
|
|
66
69
|
}
|
|
67
70
|
);
|
|
68
71
|
}
|
|
69
|
-
function g({ className:
|
|
72
|
+
function g({ className: a, children: r, ...o }) {
|
|
70
73
|
const e = i((t) => t.table.body.base);
|
|
71
|
-
return /* @__PURE__ */ n(
|
|
74
|
+
return /* @__PURE__ */ n(
|
|
75
|
+
"tbody",
|
|
76
|
+
{
|
|
77
|
+
"data-name": "table-body",
|
|
78
|
+
className: l(e, a),
|
|
79
|
+
...o,
|
|
80
|
+
children: r
|
|
81
|
+
}
|
|
82
|
+
);
|
|
72
83
|
}
|
|
73
|
-
function v({ className:
|
|
74
|
-
const e = i((h) => h.table.row), { bordered: t, hover:
|
|
84
|
+
function v({ className: a, children: r, ...o }) {
|
|
85
|
+
const e = i((h) => h.table.row), { bordered: t, hover: d, striped: b } = x(f), c = !!t, m = t === "dashed", u = t === "solid";
|
|
75
86
|
return /* @__PURE__ */ n(
|
|
76
87
|
"tr",
|
|
77
88
|
{
|
|
78
|
-
|
|
89
|
+
"data-name": "table-row",
|
|
90
|
+
className: l(
|
|
79
91
|
"bg-white",
|
|
80
92
|
e == null ? void 0 : e.base,
|
|
81
93
|
c && "border-b border-solid border-border",
|
|
82
|
-
|
|
83
|
-
|
|
94
|
+
m && "border-dashed",
|
|
95
|
+
u && "border-solid",
|
|
84
96
|
c && (e == null ? void 0 : e.bordered),
|
|
85
|
-
|
|
86
|
-
|
|
97
|
+
d && "cursor-pointer transition-colors hover:bg-gray-200",
|
|
98
|
+
d && (e == null ? void 0 : e.hover),
|
|
87
99
|
b && "even:bg-gray-100",
|
|
88
100
|
b && (e == null ? void 0 : e.hover),
|
|
89
|
-
|
|
101
|
+
a
|
|
90
102
|
),
|
|
91
|
-
...
|
|
92
|
-
children:
|
|
103
|
+
...o,
|
|
104
|
+
children: r
|
|
93
105
|
}
|
|
94
106
|
);
|
|
95
107
|
}
|
|
96
108
|
function C({
|
|
97
|
-
sticky:
|
|
98
|
-
className:
|
|
99
|
-
children:
|
|
109
|
+
sticky: a = !1,
|
|
110
|
+
className: r,
|
|
111
|
+
children: o,
|
|
100
112
|
...e
|
|
101
113
|
}) {
|
|
102
114
|
return /* @__PURE__ */ n(
|
|
103
115
|
"th",
|
|
104
116
|
{
|
|
105
|
-
|
|
117
|
+
"data-name": "table-header-cell",
|
|
118
|
+
className: l(
|
|
106
119
|
"font-medium text-sm py-2 px-4 whitespace-nowrap text-center first:text-start last:text-end",
|
|
107
|
-
|
|
108
|
-
|
|
120
|
+
a && "bg-inherit sticky inset-e-0 z-1",
|
|
121
|
+
r
|
|
109
122
|
),
|
|
110
123
|
...e,
|
|
111
|
-
children:
|
|
124
|
+
children: o
|
|
112
125
|
}
|
|
113
126
|
);
|
|
114
127
|
}
|
|
115
128
|
function T({
|
|
116
|
-
sticky:
|
|
117
|
-
className:
|
|
118
|
-
children:
|
|
129
|
+
sticky: a = !1,
|
|
130
|
+
className: r,
|
|
131
|
+
children: o,
|
|
119
132
|
...e
|
|
120
133
|
}) {
|
|
121
134
|
return /* @__PURE__ */ n(
|
|
122
135
|
"td",
|
|
123
136
|
{
|
|
124
|
-
|
|
137
|
+
"data-name": "table-data-cell",
|
|
138
|
+
className: l(
|
|
125
139
|
"font-normal text-sm py-2 px-4 whitespace-nowrap text-center first:text-start last:text-end",
|
|
126
|
-
|
|
127
|
-
|
|
140
|
+
a && "bg-inherit sticky inset-e-0 z-1",
|
|
141
|
+
r
|
|
128
142
|
),
|
|
129
143
|
...e,
|
|
130
|
-
children:
|
|
144
|
+
children: o
|
|
131
145
|
}
|
|
132
146
|
);
|
|
133
147
|
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
148
|
+
s.Container = w;
|
|
149
|
+
s.Header = y;
|
|
150
|
+
s.Body = g;
|
|
151
|
+
s.Row = v;
|
|
152
|
+
s.HeaderCell = C;
|
|
153
|
+
s.DataCell = T;
|
|
140
154
|
export {
|
|
141
|
-
|
|
155
|
+
s as default
|
|
142
156
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
1
|
+
"use client";"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const l=require("react/jsx-runtime"),o=require("react"),j=require("../../node_modules/tailwind-merge/dist/bundle-mjs.cjs.js"),q=require("../Button/index.cjs.js"),T=require("../ButtonGroup/index.cjs.js"),g=require("../../hooks/useClasses.cjs.js"),C=require("../../helpers/cn.cjs.js"),f=o.createContext({active:null,onChange:()=>{}});function p({active:n=null,onChange:t=()=>{},children:a}){return l.jsx(f.Provider,{value:{active:n,onChange:t},children:a})}function I({className:n,...t}){const[a,u]=o.useState(!1),d=g(e=>e.tabs.indicator.base),{active:h}=o.useContext(f),x=o.useRef(null),m=o.useCallback(()=>{const e=x.current,c=e==null?void 0:e.parentElement,s=c==null?void 0:c.querySelector("button[data-active='true']");if(!c||!s||!e)return;const b=(s==null?void 0:s.offsetLeft)??0,r=window.getComputedStyle(s).paddingInline,v=(s==null?void 0:s.getBoundingClientRect().width)??0,y=b,i=v;e.style.setProperty("--left",`${y}px`),e.style.setProperty("--width",`${i}px`),e.style.setProperty("--padding-x",`${r}`)},[]);return o.useEffect(()=>{m(),requestAnimationFrame(()=>u(!0))},[m,h]),l.jsx("span",{ref:x,"data-button-group-skip":!0,"data-name":"tabs-indicator",className:j.twMerge("absolute bottom-0 left-(--left,0px) rtl:left-(--left,100%) w-(--width,0px) px-(--padding-x,0px) h-px overflow-hidden",a?"transition-[width,left,padding]":"",d,n),...t,children:l.jsx("span",{className:"block size-full rounded-full bg-primary"})})}function P({className:n,children:t,...a}){const u=g(d=>d.tabs.buttonGroup.base);return l.jsx(T,{as:"div","data-name":"tabs-button-group",className:C("relative flex items-center",u,n),...a,children:t})}function M({eventKey:n,className:t,children:a,onClick:u,variant:d="text",color:h,size:x,loading:m,...e}){const c=g(i=>i.tabs.button.base),w=g(i=>i.tabs.button.active),{active:s,onChange:b}=o.useContext(f),r=n===s,v=o.useMemo(()=>typeof t=="function"?t({isActive:r}):t,[r,t]),y=i=>{r||b==null||b(n),u==null||u(i)};return l.jsx(q,{as:"button",type:"button","data-active":r,"data-name":"tabs-button",variant:d,color:h??(r?"primary":"dark"),size:x,loading:m,className:C("shadow-none border-none",c,r&&w,v),onClick:y,...e,children:a})}function R({eventKey:n,children:t}){const{active:a}=o.useContext(f);return a!==n?null:l.jsx(o.Fragment,{children:t})}p.Indicator=I;p.ButtonGroup=P;p.Button=M;p.Item=R;exports.TabsContext=f;exports.default=p;
|
|
@@ -34,7 +34,7 @@ declare namespace Tabs {
|
|
|
34
34
|
}
|
|
35
35
|
declare function TabIndicator({ className, ...props }: Omit<ComponentProps<"span">, "children">): import("react/jsx-runtime").JSX.Element;
|
|
36
36
|
declare function TabButtonGroup({ className, children, ...props }: ComponentPropsWithoutAs<typeof ButtonGroup<"div">, TabButtonGroupProps>): import("react/jsx-runtime").JSX.Element;
|
|
37
|
-
declare function TabButton({ eventKey, className, children, onClick, ...props }: ComponentPropsWithoutAs<typeof Button<"button">, TabButtonProps>): import("react/jsx-runtime").JSX.Element;
|
|
37
|
+
declare function TabButton({ eventKey, className, children, onClick, variant, color, size, loading, ...props }: ComponentPropsWithoutAs<typeof Button<"button">, TabButtonProps>): import("react/jsx-runtime").JSX.Element;
|
|
38
38
|
declare function TabItem({ eventKey, children }: TabItemProps): import("react/jsx-runtime").JSX.Element | null;
|
|
39
39
|
export default Tabs;
|
|
40
40
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Tabs/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AACjE,OAAO,EACL,cAAc,EAEd,QAAQ,EAST,MAAM,OAAO,CAAC;AAIf,OAAO,MAAM,MAAM,WAAW,CAAC;AAC/B,OAAO,WAAW,MAAM,gBAAgB,CAAC;AAEzC,KAAK,SAAS,GAAG;IACf,MAAM,CAAC,EAAE,IAAI,GAAG,MAAM,CAAC;IACvB,QAAQ,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;CAC7B,GAAG,aAAa,CAAC;AAClB,KAAK,mBAAmB,GAAG;IACzB,EAAE,CAAC,EAAE,KAAK,CAAC;CACZ,CAAC;AACF,KAAK,cAAc,GAAG;IACpB,EAAE,CAAC,EAAE,KAAK,CAAC;IACX,IAAI,CAAC,EAAE,KAAK,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,OAAO,EAAE;QAAE,QAAQ,EAAE,OAAO,CAAA;KAAE,KAAK,MAAM,GAAG,SAAS,CAAC,CAAC;CAC/E,CAAC;AACF,KAAK,YAAY,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,GAAG,aAAa,CAAC;AACzD,KAAK,eAAe,GAAG;IACrB,MAAM,EAAE,IAAI,GAAG,MAAM,CAAC;IACtB,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;CAC5B,CAAC;AAEF,eAAO,MAAM,WAAW,0CAGtB,CAAC;AAEH,iBAAS,IAAI,CAAC,EAAE,MAAa,EAAE,QAAmB,EAAE,QAAQ,EAAE,EAAE,SAAS,2CAMxE;kBANQ,IAAI;;;;;;AAOb,iBAAS,YAAY,CAAC,EACpB,SAAS,EACT,GAAG,KAAK,EACT,EAAE,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE,UAAU,CAAC,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Tabs/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AACjE,OAAO,EACL,cAAc,EAEd,QAAQ,EAST,MAAM,OAAO,CAAC;AAIf,OAAO,MAAM,MAAM,WAAW,CAAC;AAC/B,OAAO,WAAW,MAAM,gBAAgB,CAAC;AAEzC,KAAK,SAAS,GAAG;IACf,MAAM,CAAC,EAAE,IAAI,GAAG,MAAM,CAAC;IACvB,QAAQ,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;CAC7B,GAAG,aAAa,CAAC;AAClB,KAAK,mBAAmB,GAAG;IACzB,EAAE,CAAC,EAAE,KAAK,CAAC;CACZ,CAAC;AACF,KAAK,cAAc,GAAG;IACpB,EAAE,CAAC,EAAE,KAAK,CAAC;IACX,IAAI,CAAC,EAAE,KAAK,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,OAAO,EAAE;QAAE,QAAQ,EAAE,OAAO,CAAA;KAAE,KAAK,MAAM,GAAG,SAAS,CAAC,CAAC;CAC/E,CAAC;AACF,KAAK,YAAY,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,GAAG,aAAa,CAAC;AACzD,KAAK,eAAe,GAAG;IACrB,MAAM,EAAE,IAAI,GAAG,MAAM,CAAC;IACtB,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;CAC5B,CAAC;AAEF,eAAO,MAAM,WAAW,0CAGtB,CAAC;AAEH,iBAAS,IAAI,CAAC,EAAE,MAAa,EAAE,QAAmB,EAAE,QAAQ,EAAE,EAAE,SAAS,2CAMxE;kBANQ,IAAI;;;;;;AAOb,iBAAS,YAAY,CAAC,EACpB,SAAS,EACT,GAAG,KAAK,EACT,EAAE,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE,UAAU,CAAC,2CAyC1C;AACD,iBAAS,cAAc,CAAC,EACtB,SAAS,EACT,QAAQ,EACR,GAAG,KAAK,EACT,EAAE,uBAAuB,CAAC,OAAO,WAAW,CAAC,KAAK,CAAC,EAAE,mBAAmB,CAAC,2CAYzE;AACD,iBAAS,SAAS,CAAC,EACjB,QAAQ,EACR,SAAS,EACT,QAAQ,EACR,OAAO,EACP,OAAgB,EAChB,KAAK,EACL,IAAI,EACJ,OAAO,EACP,GAAG,KAAK,EACT,EAAE,uBAAuB,CAAC,OAAO,MAAM,CAAC,QAAQ,CAAC,EAAE,cAAc,CAAC,2CAqClE;AACD,iBAAS,OAAO,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,YAAY,kDAIpD;AAOD,eAAe,IAAI,CAAC"}
|
|
@@ -1,102 +1,112 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as
|
|
3
|
-
import { createContext as I, useState as T, useContext as
|
|
2
|
+
import { jsx as c } from "react/jsx-runtime";
|
|
3
|
+
import { createContext as I, useState as T, useContext as y, useRef as P, useCallback as A, useEffect as B, useMemo as G, Fragment as R } from "react";
|
|
4
4
|
import { twMerge as S } from "../../node_modules/tailwind-merge/dist/bundle-mjs.es.js";
|
|
5
|
-
import g from "../../helpers/cn.es.js";
|
|
6
|
-
import f from "../../hooks/useClasses.es.js";
|
|
7
5
|
import $ from "../Button/index.es.js";
|
|
8
6
|
import k from "../ButtonGroup/index.es.js";
|
|
9
|
-
|
|
7
|
+
import b from "../../hooks/useClasses.es.js";
|
|
8
|
+
import C from "../../helpers/cn.es.js";
|
|
9
|
+
const m = I({
|
|
10
10
|
active: null,
|
|
11
11
|
onChange: () => {
|
|
12
12
|
}
|
|
13
13
|
});
|
|
14
|
-
function
|
|
14
|
+
function x({ active: n = null, onChange: t = () => {
|
|
15
15
|
}, children: s }) {
|
|
16
|
-
return /* @__PURE__ */
|
|
16
|
+
return /* @__PURE__ */ c(m.Provider, { value: { active: n, onChange: t }, children: s });
|
|
17
17
|
}
|
|
18
18
|
function q({
|
|
19
|
-
className:
|
|
19
|
+
className: n,
|
|
20
20
|
...t
|
|
21
21
|
}) {
|
|
22
|
-
const [s,
|
|
23
|
-
const e =
|
|
24
|
-
if (!
|
|
25
|
-
const
|
|
26
|
-
e.style.setProperty("--left", `${
|
|
22
|
+
const [s, r] = T(!1), l = b((e) => e.tabs.indicator.base), { active: h } = y(m), f = P(null), p = A(() => {
|
|
23
|
+
const e = f.current, u = e == null ? void 0 : e.parentElement, o = u == null ? void 0 : u.querySelector("button[data-active='true']");
|
|
24
|
+
if (!u || !o || !e) return;
|
|
25
|
+
const d = (o == null ? void 0 : o.offsetLeft) ?? 0, a = window.getComputedStyle(o).paddingInline, g = (o == null ? void 0 : o.getBoundingClientRect().width) ?? 0, w = d, i = g;
|
|
26
|
+
e.style.setProperty("--left", `${w}px`), e.style.setProperty("--width", `${i}px`), e.style.setProperty("--padding-x", `${a}`);
|
|
27
27
|
}, []);
|
|
28
28
|
return B(() => {
|
|
29
|
-
|
|
30
|
-
}, [
|
|
29
|
+
p(), requestAnimationFrame(() => r(!0));
|
|
30
|
+
}, [p, h]), /* @__PURE__ */ c(
|
|
31
31
|
"span",
|
|
32
32
|
{
|
|
33
|
-
ref:
|
|
33
|
+
ref: f,
|
|
34
|
+
"data-button-group-skip": !0,
|
|
35
|
+
"data-name": "tabs-indicator",
|
|
34
36
|
className: S(
|
|
35
37
|
"absolute bottom-0 left-(--left,0px) rtl:left-(--left,100%) w-(--width,0px) px-(--padding-x,0px) h-px overflow-hidden",
|
|
36
38
|
s ? "transition-[width,left,padding]" : "",
|
|
37
|
-
|
|
38
|
-
|
|
39
|
+
l,
|
|
40
|
+
n
|
|
39
41
|
),
|
|
40
42
|
...t,
|
|
41
|
-
children: /* @__PURE__ */
|
|
43
|
+
children: /* @__PURE__ */ c("span", { className: "block size-full rounded-full bg-primary" })
|
|
42
44
|
}
|
|
43
45
|
);
|
|
44
46
|
}
|
|
45
47
|
function E({
|
|
46
|
-
className:
|
|
48
|
+
className: n,
|
|
47
49
|
children: t,
|
|
48
50
|
...s
|
|
49
51
|
}) {
|
|
50
|
-
const
|
|
51
|
-
return /* @__PURE__ */
|
|
52
|
+
const r = b((l) => l.tabs.buttonGroup.base);
|
|
53
|
+
return /* @__PURE__ */ c(
|
|
52
54
|
k,
|
|
53
55
|
{
|
|
54
56
|
as: "div",
|
|
55
|
-
|
|
57
|
+
"data-name": "tabs-button-group",
|
|
58
|
+
className: C("relative flex items-center", r, n),
|
|
56
59
|
...s,
|
|
57
60
|
children: t
|
|
58
61
|
}
|
|
59
62
|
);
|
|
60
63
|
}
|
|
61
64
|
function F({
|
|
62
|
-
eventKey:
|
|
65
|
+
eventKey: n,
|
|
63
66
|
className: t,
|
|
64
67
|
children: s,
|
|
65
|
-
onClick:
|
|
66
|
-
|
|
68
|
+
onClick: r,
|
|
69
|
+
variant: l = "text",
|
|
70
|
+
color: h,
|
|
71
|
+
size: f,
|
|
72
|
+
loading: p,
|
|
73
|
+
...e
|
|
67
74
|
}) {
|
|
68
|
-
const
|
|
69
|
-
|
|
75
|
+
const u = b((i) => i.tabs.button.base), v = b((i) => i.tabs.button.active), { active: o, onChange: d } = y(m), a = n === o, g = G(() => typeof t == "function" ? t({ isActive: a }) : t, [a, t]), w = (i) => {
|
|
76
|
+
a || d == null || d(n), r == null || r(i);
|
|
77
|
+
};
|
|
78
|
+
return /* @__PURE__ */ c(
|
|
70
79
|
$,
|
|
71
80
|
{
|
|
72
81
|
as: "button",
|
|
73
82
|
type: "button",
|
|
74
|
-
"data-active":
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
className:
|
|
83
|
+
"data-active": a,
|
|
84
|
+
"data-name": "tabs-button",
|
|
85
|
+
variant: l,
|
|
86
|
+
color: h ?? (a ? "primary" : "dark"),
|
|
87
|
+
size: f,
|
|
88
|
+
loading: p,
|
|
89
|
+
className: C(
|
|
81
90
|
"shadow-none border-none",
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
91
|
+
u,
|
|
92
|
+
a && v,
|
|
93
|
+
g
|
|
85
94
|
),
|
|
86
|
-
|
|
95
|
+
onClick: w,
|
|
96
|
+
...e,
|
|
87
97
|
children: s
|
|
88
98
|
}
|
|
89
99
|
);
|
|
90
100
|
}
|
|
91
|
-
function L({ eventKey:
|
|
92
|
-
const { active: s } =
|
|
93
|
-
return s !==
|
|
101
|
+
function L({ eventKey: n, children: t }) {
|
|
102
|
+
const { active: s } = y(m);
|
|
103
|
+
return s !== n ? null : /* @__PURE__ */ c(R, { children: t });
|
|
94
104
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
105
|
+
x.Indicator = q;
|
|
106
|
+
x.ButtonGroup = E;
|
|
107
|
+
x.Button = F;
|
|
108
|
+
x.Item = L;
|
|
99
109
|
export {
|
|
100
|
-
|
|
101
|
-
|
|
110
|
+
m as TabsContext,
|
|
111
|
+
x as default
|
|
102
112
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const b=require("react/jsx-runtime"),e=require("react"),P=require("../../helpers/anchorPointer.cjs.js"),M=e.createContext(null),h=e.createContext(null);function E(...t){return l=>{t.forEach(r=>{typeof r=="function"?r(l):r&&(r.current=l)})}}function j(){const t=e.useContext(M),l=e.useContext(h);if(!t||!l)throw new Error("useToggleContext must be used within Toggle");return{...t,...l}}function k(){const t=e.useContext(M);if(!t)throw new Error("Toggle subcomponents must be used within Toggle");return t}function w(){const t=e.useContext(h);if(!t)throw new Error("Toggle subcomponents must be used within Toggle");return t}function v({defaultOpen:t=!1,open:l,onOpenChange:r,anchor:i=!1,triggerOn:u="click",ref:a,children:g}){const[s,x]=e.useState(t),[p,d]=e.useState(null),f=l!==void 0,n=f?l:s,o=e.useCallback(m=>{f||x(m),m||d(null),r==null||r(m)},[f,r]),c=e.useCallback(()=>{o(!0)},[o]),C=e.useCallback(()=>{o(!1)},[o]),T=e.useCallback(()=>{o(!n)},[n,o]);e.useImperativeHandle(a,()=>({open:c,close:C,toggle:T}));const S=e.useMemo(()=>({open:n,anchorEl:p,anchor:i,triggerOn:u}),[n,p,i,u]),A=e.useMemo(()=>({open:c,close:C,toggle:T,setAnchorEl:d}),[c,C,T]);return b.jsx(h.Provider,{value:A,children:b.jsx(M.Provider,{value:S,children:g})})}function y({children:t}){const{open:l,triggerOn:r}=k(),{toggle:i,setAnchorEl:u,open:a,close:g}=w();if(!e.isValidElement(t))return t;const s=e.Children.only(t),x=n=>{var o,c;(c=(o=s.props).onClick)==null||c.call(o,n),u(n.currentTarget),i()},p=n=>{var o,c;n.preventDefault(),(c=(o=s.props).onContextMenu)==null||c.call(o,n),P.setAnchorPointer(n.currentTarget,n.clientX,n.clientY),u(n.currentTarget),a()},d=n=>{var o,c;(c=(o=s.props).onMouseEnter)==null||c.call(o,n),u(n.currentTarget),a()},f=n=>{var o,c;(c=(o=s.props).onMouseLeave)==null||c.call(o,n),g()};return r==="contextMenu"?e.cloneElement(s,{"aria-expanded":l,onContextMenu:p,ref:E(s.props.ref)}):r==="hover"?e.cloneElement(s,{"aria-expanded":l,onMouseEnter:d,onMouseLeave:f,ref:E(s.props.ref)}):r==="click"?e.cloneElement(s,{"aria-expanded":l,onClick:x,ref:E(s.props.ref)}):s}function V({children:t}){const{open:l,anchorEl:r,anchor:i,triggerOn:u}=k(),{close:a}=w();if(!e.isValidElement(t))return t;const g=u==="contextMenu",s=e.Children.only(t);return e.cloneElement(s,{open:l,onClose:a,...i&&{anchorEl:r},...g&&{anchorPointer:!0}})}v.Trigger=y;v.Content=V;exports.default=v;exports.useToggleContext=j;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { ChildrenProps } from '../../types';
|
|
2
|
+
import { MouseEvent, ReactElement, Ref } from 'react';
|
|
3
|
+
type TriggerOn = "hover" | "click" | "contextMenu";
|
|
4
|
+
export type ToggleRef = {
|
|
5
|
+
open: VoidFunction;
|
|
6
|
+
close: VoidFunction;
|
|
7
|
+
toggle: VoidFunction;
|
|
8
|
+
};
|
|
9
|
+
type ToggleProps = {
|
|
10
|
+
defaultOpen?: boolean;
|
|
11
|
+
open?: boolean;
|
|
12
|
+
onOpenChange?: (open: boolean) => void;
|
|
13
|
+
anchor?: boolean;
|
|
14
|
+
triggerOn?: TriggerOn;
|
|
15
|
+
ref?: Ref<ToggleRef>;
|
|
16
|
+
} & ChildrenProps;
|
|
17
|
+
type ToggleTriggerProps = ChildrenProps;
|
|
18
|
+
type ToggleContentProps = ChildrenProps;
|
|
19
|
+
export declare function useToggleContext(): {
|
|
20
|
+
open: VoidFunction;
|
|
21
|
+
close: VoidFunction;
|
|
22
|
+
toggle: VoidFunction;
|
|
23
|
+
setAnchorEl: (el: HTMLElement | null) => void;
|
|
24
|
+
anchorEl: HTMLElement | null;
|
|
25
|
+
anchor: boolean;
|
|
26
|
+
triggerOn: TriggerOn;
|
|
27
|
+
};
|
|
28
|
+
declare function Toggle({ defaultOpen, open: openProp, onOpenChange, anchor, triggerOn, ref, children, }: ToggleProps): import("react/jsx-runtime").JSX.Element;
|
|
29
|
+
declare namespace Toggle {
|
|
30
|
+
var Trigger: typeof ToggleTrigger;
|
|
31
|
+
var Content: typeof ToggleContent;
|
|
32
|
+
}
|
|
33
|
+
declare function ToggleTrigger({ children }: ToggleTriggerProps): string | number | bigint | boolean | Iterable<import('react').ReactNode> | Promise<string | number | bigint | boolean | import('react').ReactPortal | ReactElement<unknown, string | import('react').JSXElementConstructor<any>> | Iterable<import('react').ReactNode> | null | undefined> | ReactElement<{
|
|
34
|
+
onClick?: (e: MouseEvent<HTMLElement>) => void;
|
|
35
|
+
onContextMenu?: (e: MouseEvent<HTMLElement>) => void;
|
|
36
|
+
onMouseEnter?: (e: MouseEvent<HTMLElement>) => void;
|
|
37
|
+
onMouseLeave?: (e: MouseEvent<HTMLElement>) => void;
|
|
38
|
+
ref?: Ref<HTMLElement>;
|
|
39
|
+
"aria-expanded"?: boolean;
|
|
40
|
+
}, string | import('react').JSXElementConstructor<any>> | null | undefined;
|
|
41
|
+
declare function ToggleContent({ children }: ToggleContentProps): string | number | bigint | boolean | Iterable<import('react').ReactNode> | Promise<string | number | bigint | boolean | import('react').ReactPortal | ReactElement<unknown, string | import('react').JSXElementConstructor<any>> | Iterable<import('react').ReactNode> | null | undefined> | ReactElement<{
|
|
42
|
+
open?: boolean;
|
|
43
|
+
onClose?: VoidFunction;
|
|
44
|
+
anchorEl?: HTMLElement | null;
|
|
45
|
+
anchorPointer?: boolean;
|
|
46
|
+
}, string | import('react').JSXElementConstructor<any>> | null | undefined;
|
|
47
|
+
export default Toggle;
|
|
48
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Toggle/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAKL,UAAU,EACV,YAAY,EACZ,GAAG,EAMJ,MAAM,OAAO,CAAC;AAEf,KAAK,SAAS,GAAG,OAAO,GAAG,OAAO,GAAG,aAAa,CAAC;AAgBnD,MAAM,MAAM,SAAS,GAAG;IACtB,IAAI,EAAE,YAAY,CAAC;IACnB,KAAK,EAAE,YAAY,CAAC;IACpB,MAAM,EAAE,YAAY,CAAC;CACtB,CAAC;AAEF,KAAK,WAAW,GAAG;IACjB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACvC,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,GAAG,CAAC,EAAE,GAAG,CAAC,SAAS,CAAC,CAAC;CACtB,GAAG,aAAa,CAAC;AAElB,KAAK,kBAAkB,GAAG,aAAa,CAAC;AAExC,KAAK,kBAAkB,GAAG,aAAa,CAAC;AAgBxC,wBAAgB,gBAAgB;UAvCxB,YAAY;WACX,YAAY;YACX,YAAY;iBACP,CAAC,EAAE,EAAE,WAAW,GAAG,IAAI,KAAK,IAAI;cATnC,WAAW,GAAG,IAAI;YACpB,OAAO;eACJ,SAAS;EAkDrB;AAkBD,iBAAS,MAAM,CAAC,EACd,WAAmB,EACnB,IAAI,EAAE,QAAQ,EACd,YAAY,EACZ,MAAc,EACd,SAAmB,EACnB,GAAG,EACH,QAAQ,GACT,EAAE,WAAW,2CAkDb;kBA1DQ,MAAM;;;;AA4Df,iBAAS,aAAa,CAAC,EAAE,QAAQ,EAAE,EAAE,kBAAkB;cAOzC,CAAC,CAAC,EAAE,UAAU,CAAC,WAAW,CAAC,KAAK,IAAI;oBAC9B,CAAC,CAAC,EAAE,UAAU,CAAC,WAAW,CAAC,KAAK,IAAI;mBACrC,CAAC,CAAC,EAAE,UAAU,CAAC,WAAW,CAAC,KAAK,IAAI;mBACpC,CAAC,CAAC,EAAE,UAAU,CAAC,WAAW,CAAC,KAAK,IAAI;UAC7C,GAAG,CAAC,WAAW,CAAC;sBACJ,OAAO;2EAsD5B;AAED,iBAAS,aAAa,CAAC,EAAE,QAAQ,EAAE,EAAE,kBAAkB;WAS5C,OAAO;cACJ,YAAY;eACX,WAAW,GAAG,IAAI;oBACb,OAAO;2EAS1B;AAKD,eAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as b } from "react/jsx-runtime";
|
|
3
|
+
import { useState as k, useCallback as d, useImperativeHandle as H, useMemo as A, useContext as x, createContext as y, isValidElement as L, Children as P, cloneElement as T } from "react";
|
|
4
|
+
import { setAnchorPointer as I } from "../../helpers/anchorPointer.es.js";
|
|
5
|
+
const v = y(null), w = y(
|
|
6
|
+
null
|
|
7
|
+
);
|
|
8
|
+
function M(...e) {
|
|
9
|
+
return (c) => {
|
|
10
|
+
e.forEach((n) => {
|
|
11
|
+
typeof n == "function" ? n(c) : n && (n.current = c);
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
function z() {
|
|
16
|
+
const e = x(v), c = x(w);
|
|
17
|
+
if (!e || !c)
|
|
18
|
+
throw new Error("useToggleContext must be used within Toggle");
|
|
19
|
+
return { ...e, ...c };
|
|
20
|
+
}
|
|
21
|
+
function S() {
|
|
22
|
+
const e = x(v);
|
|
23
|
+
if (!e)
|
|
24
|
+
throw new Error("Toggle subcomponents must be used within Toggle");
|
|
25
|
+
return e;
|
|
26
|
+
}
|
|
27
|
+
function V() {
|
|
28
|
+
const e = x(w);
|
|
29
|
+
if (!e)
|
|
30
|
+
throw new Error("Toggle subcomponents must be used within Toggle");
|
|
31
|
+
return e;
|
|
32
|
+
}
|
|
33
|
+
function F({
|
|
34
|
+
defaultOpen: e = !1,
|
|
35
|
+
open: c,
|
|
36
|
+
onOpenChange: n,
|
|
37
|
+
anchor: u = !1,
|
|
38
|
+
triggerOn: l = "click",
|
|
39
|
+
ref: i,
|
|
40
|
+
children: a
|
|
41
|
+
}) {
|
|
42
|
+
const [r, m] = k(e), [f, p] = k(null), g = c !== void 0, t = g ? c : r, o = d(
|
|
43
|
+
(E) => {
|
|
44
|
+
g || m(E), E || p(null), n == null || n(E);
|
|
45
|
+
},
|
|
46
|
+
[g, n]
|
|
47
|
+
), s = d(() => {
|
|
48
|
+
o(!0);
|
|
49
|
+
}, [o]), C = d(() => {
|
|
50
|
+
o(!1);
|
|
51
|
+
}, [o]), h = d(() => {
|
|
52
|
+
o(!t);
|
|
53
|
+
}, [t, o]);
|
|
54
|
+
H(i, () => ({
|
|
55
|
+
open: s,
|
|
56
|
+
close: C,
|
|
57
|
+
toggle: h
|
|
58
|
+
}));
|
|
59
|
+
const j = A(
|
|
60
|
+
() => ({ open: t, anchorEl: f, anchor: u, triggerOn: l }),
|
|
61
|
+
[t, f, u, l]
|
|
62
|
+
), D = A(
|
|
63
|
+
() => ({ open: s, close: C, toggle: h, setAnchorEl: p }),
|
|
64
|
+
[s, C, h]
|
|
65
|
+
);
|
|
66
|
+
return /* @__PURE__ */ b(w.Provider, { value: D, children: /* @__PURE__ */ b(v.Provider, { value: j, children: a }) });
|
|
67
|
+
}
|
|
68
|
+
function R({ children: e }) {
|
|
69
|
+
const { open: c, triggerOn: n } = S(), { toggle: u, setAnchorEl: l, open: i, close: a } = V();
|
|
70
|
+
if (!L(e)) return e;
|
|
71
|
+
const r = P.only(e), m = (t) => {
|
|
72
|
+
var o, s;
|
|
73
|
+
(s = (o = r.props).onClick) == null || s.call(o, t), l(t.currentTarget), u();
|
|
74
|
+
}, f = (t) => {
|
|
75
|
+
var o, s;
|
|
76
|
+
t.preventDefault(), (s = (o = r.props).onContextMenu) == null || s.call(o, t), I(t.currentTarget, t.clientX, t.clientY), l(t.currentTarget), i();
|
|
77
|
+
}, p = (t) => {
|
|
78
|
+
var o, s;
|
|
79
|
+
(s = (o = r.props).onMouseEnter) == null || s.call(o, t), l(t.currentTarget), i();
|
|
80
|
+
}, g = (t) => {
|
|
81
|
+
var o, s;
|
|
82
|
+
(s = (o = r.props).onMouseLeave) == null || s.call(o, t), a();
|
|
83
|
+
};
|
|
84
|
+
return n === "contextMenu" ? T(r, {
|
|
85
|
+
"aria-expanded": c,
|
|
86
|
+
onContextMenu: f,
|
|
87
|
+
ref: M(r.props.ref)
|
|
88
|
+
}) : n === "hover" ? T(r, {
|
|
89
|
+
"aria-expanded": c,
|
|
90
|
+
onMouseEnter: p,
|
|
91
|
+
onMouseLeave: g,
|
|
92
|
+
ref: M(r.props.ref)
|
|
93
|
+
}) : n === "click" ? T(r, {
|
|
94
|
+
"aria-expanded": c,
|
|
95
|
+
onClick: m,
|
|
96
|
+
ref: M(r.props.ref)
|
|
97
|
+
}) : r;
|
|
98
|
+
}
|
|
99
|
+
function U({ children: e }) {
|
|
100
|
+
const { open: c, anchorEl: n, anchor: u, triggerOn: l } = S(), { close: i } = V();
|
|
101
|
+
if (!L(e)) return e;
|
|
102
|
+
const a = l === "contextMenu", r = P.only(e);
|
|
103
|
+
return T(r, {
|
|
104
|
+
open: c,
|
|
105
|
+
onClose: i,
|
|
106
|
+
...u && { anchorEl: n },
|
|
107
|
+
...a && { anchorPointer: !0 }
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
F.Trigger = R;
|
|
111
|
+
F.Content = U;
|
|
112
|
+
export {
|
|
113
|
+
F as default,
|
|
114
|
+
z as useToggleContext
|
|
115
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";const
|
|
1
|
+
"use client";"use strict";const v=require("react/jsx-runtime"),s=require("react"),L=require("../../node_modules/tailwind-merge/dist/bundle-mjs.cjs.js"),F=require("../Portal/index.cjs.js"),E=require("../../hooks/useClasses.cjs.js"),G=require("../../helpers/anchorPointer.cjs.js"),I=require("../../node_modules/react-transition-group/esm/Transition.cjs.js"),N=s.createContext({placement:"top",color:"dark",transitionState:"unmounted"});function W(){return s.useContext(N)}function H({open:l=!1,anchorEl:u=null,anchorPointer:r=!1,placement:t="top",color:g="dark",duration:w=300,onEnter:b,onEntering:n,onEntered:p,onExit:$,onExiting:B,onExited:S,className:O,children:A}){const c=E(e=>e.tooltip),d=s.useRef(null),y=0,C=16,X={entering:"scale-100 opacity-100",entered:"scale-100 opacity-100",exiting:"scale-75 opacity-0",exited:"scale-75 opacity-0",unmounted:""},Y=s.useMemo(()=>{var f;return[t==="top"||t==="bottom"?"flex-col":"flex-row",{top:"flex-col origin-bottom",bottom:"flex-col-reverse origin-top",start:"flex-row origin-right rtl:origin-left",end:"flex-row-reverse origin-left rtl:origin-right"}[t],(f=c==null?void 0:c.placement)==null?void 0:f[t]]},[t,c==null?void 0:c.placement]),D=s.useCallback(e=>{var a,f,i;(a=d.current)==null||a.style.setProperty("--left",`${e.left}px`),(f=d.current)==null||f.style.setProperty("--right",`${e.right}px`),(i=d.current)==null||i.style.setProperty("--top",`${e.top}px`)},[]),M=s.useCallback(()=>{if(!l||!u||!d.current)return;const e=d.current,a=window.innerWidth,f=window.innerHeight,i=e.offsetWidth,j=e.offsetHeight;let P,R,z,T,k,q;if(r){const o=G.getAnchorPointer(u);if(!o)return;P=o.x,R=o.x,z=o.y,T=o.y,k=o.x,q=o.y}else{const o=u.getBoundingClientRect();P=o.left,R=o.right,z=o.top,T=o.bottom,k=o.left+o.width/2,q=o.top+o.height/2}let h,x,m;switch(t){case"top":h=k-i/2,x=a-k-i/2,m=z-j-y;break;case"bottom":h=k-i/2,x=a-k-i/2,m=T+y;break;case"start":h=P-i-y,x=a-R-y-i,m=q-j/2;break;case"end":h=R+y,x=a-P+y,m=q-j/2;break}h=Math.min(Math.max(h,C),a-i-C),x=Math.min(Math.max(x,C),a-i-C),m=Math.min(Math.max(m,C),f-j-C),D({left:h,right:x,top:m})},[l,u,r,t,D]);return s.useEffect(()=>{M()},[M,A]),s.useEffect(()=>{const e=()=>M();return window.addEventListener("scroll",e),window.addEventListener("resize",e),()=>{window.removeEventListener("scroll",e),window.removeEventListener("resize",e)}},[M]),v.jsx(F,{children:v.jsx(I.default,{nodeRef:d,in:l,timeout:w,unmountOnExit:!0,onEnter:b,onEntering:n,onEntered:p,onExit:$,onExiting:B,onExited:S,children:e=>v.jsx(N.Provider,{value:{placement:t,color:g,transitionState:e},children:v.jsx("div",{ref:d,"data-name":"tooltip","data-open":l,style:{transitionDuration:`${w}ms`},className:L.twMerge("flex items-center justify-center fixed z-1 pointer-events-none top-(--top) left-(--left) right-auto origin-top-left rtl:left-auto rtl:right-(--right) rtl:origin-top-right transition-[scale,opacity]",c==null?void 0:c.base,Y,X[e],O),children:A})})})})}function J({className:l,children:u,...r}){const t=E(b=>{var n;return(n=b.tooltip)==null?void 0:n.content}),{color:g}=W(),w=s.useMemo(()=>{var n;return[{primary:"bg-primary text-white",secondary:"bg-secondary text-white",success:"bg-success text-white",info:"bg-info text-white",warning:"bg-warning text-white",danger:"bg-danger text-white",dark:"bg-dark text-white",light:"bg-light text-dark"}[g],(n=t==null?void 0:t.color)==null?void 0:n[g]]},[g,t==null?void 0:t.color]);return v.jsx("span",{role:"tooltip","data-name":"tooltip-content",className:L.twMerge("relative block size-fit min-w-fit min-h-fit text-sm rounded px-2 py-px whitespace-nowrap z-1",t==null?void 0:t.base,w,l),...r,children:u})}function K({className:l,...u}){const r=E(n=>{var p;return(p=n.tooltip)==null?void 0:p.arrow}),{color:t,placement:g}=W(),w=s.useMemo(()=>({top:"-translate-y-2/3",bottom:"translate-y-2/3",start:"-translate-x-2/3 rtl:translate-x-2/3",end:"translate-x-2/3 rtl:-translate-x-2/3"})[g],[g]),b=s.useMemo(()=>{var p;return[{primary:"bg-primary",secondary:"bg-secondary",success:"bg-success",info:"bg-info",warning:"bg-warning",danger:"bg-danger",dark:"bg-dark",light:"bg-light"}[t],(p=r==null?void 0:r.color)==null?void 0:p[t]]},[t,r==null?void 0:r.color]);return v.jsx("span",{"data-name":"tooltip-arrow",className:L.twMerge("block size-3 min-w-3 min-h-3 rotate-45 shrink-0",r==null?void 0:r.base,w,b,l),...u})}H.Content=J;H.Arrow=K;module.exports=H;
|