@forgedevstack/bear 1.1.4 → 1.1.9
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/README.md +21 -2
- package/dist/components/Anchor/Anchor.cjs +1 -1
- package/dist/components/Anchor/Anchor.js +37 -45
- package/dist/components/Anchor/Anchor.utils.cjs +1 -0
- package/dist/components/Anchor/Anchor.utils.d.ts +2 -0
- package/dist/components/Anchor/Anchor.utils.js +12 -0
- package/dist/components/Autocomplete/Autocomplete.cjs +1 -1
- package/dist/components/Autocomplete/Autocomplete.js +60 -67
- package/dist/components/Autocomplete/Autocomplete.utils.cjs +1 -0
- package/dist/components/Autocomplete/Autocomplete.utils.d.ts +2 -0
- package/dist/components/Autocomplete/Autocomplete.utils.js +12 -0
- package/dist/components/BackTop/BackTop.cjs +1 -1
- package/dist/components/BackTop/BackTop.js +10 -11
- package/dist/components/BearLogo/BearLogo.d.ts +2 -7
- package/dist/components/BearLogo/BearLogo.types.d.ts +15 -0
- package/dist/components/BearLogo/EmberLogo.d.ts +1 -8
- package/dist/components/BearLogo/index.d.ts +1 -2
- package/dist/components/Biometric/Biometric.cjs +1 -0
- package/dist/components/Biometric/Biometric.d.ts +3 -0
- package/dist/components/Biometric/Biometric.js +123 -0
- package/dist/components/Biometric/Biometric.types.d.ts +35 -0
- package/dist/components/Biometric/BiometricIcon.cjs +1 -0
- package/dist/components/Biometric/BiometricIcon.d.ts +3 -0
- package/dist/components/Biometric/BiometricIcon.js +45 -0
- package/dist/components/Biometric/index.d.ts +3 -0
- package/dist/components/Biometric/useBiometric.cjs +1 -0
- package/dist/components/Biometric/useBiometric.d.ts +2 -0
- package/dist/components/Biometric/useBiometric.js +21 -0
- package/dist/components/Button/Button.cjs +1 -1
- package/dist/components/Button/Button.constants.cjs +2 -2
- package/dist/components/Button/Button.constants.d.ts +1 -0
- package/dist/components/Button/Button.constants.js +12 -5
- package/dist/components/Button/Button.d.ts +0 -27
- package/dist/components/Button/Button.js +93 -105
- package/dist/components/Button/Button.types.d.ts +1 -0
- package/dist/components/Button/Button.utils.cjs +1 -0
- package/dist/components/Button/Button.utils.d.ts +2 -0
- package/dist/components/Button/Button.utils.js +5 -0
- package/dist/components/Button/useSpotlight.cjs +1 -0
- package/dist/components/Button/useSpotlight.d.ts +21 -0
- package/dist/components/Button/useSpotlight.js +28 -0
- package/dist/components/Chart/Chart.cjs +1 -1
- package/dist/components/Chart/Chart.const.cjs +1 -0
- package/dist/components/Chart/Chart.const.js +21 -0
- package/dist/components/Chart/Chart.js +55 -71
- package/dist/components/Chart/Chart.utils.cjs +1 -0
- package/dist/components/Chart/Chart.utils.js +5 -0
- package/dist/components/Confetti/Confetti.cjs +1 -1
- package/dist/components/Confetti/Confetti.js +37 -34
- package/dist/components/ContextMenu/ContextMenu.cjs +1 -1
- package/dist/components/ContextMenu/ContextMenu.js +31 -30
- package/dist/components/ContextMenu/ContextMenu.utils.cjs +1 -0
- package/dist/components/ContextMenu/ContextMenu.utils.d.ts +5 -0
- package/dist/components/ContextMenu/ContextMenu.utils.js +4 -0
- package/dist/components/CountdownTimer/CountdownTimer.cjs +1 -1
- package/dist/components/CountdownTimer/CountdownTimer.js +62 -71
- package/dist/components/CountdownTimer/CountdownTimer.utils.cjs +1 -0
- package/dist/components/CountdownTimer/CountdownTimer.utils.d.ts +3 -0
- package/dist/components/CountdownTimer/CountdownTimer.utils.js +16 -0
- package/dist/components/DateRangePicker/DateRangePicker.cjs +1 -1
- package/dist/components/DateRangePicker/DateRangePicker.const.cjs +1 -1
- package/dist/components/DateRangePicker/DateRangePicker.const.js +12 -13
- package/dist/components/DateRangePicker/DateRangePicker.js +107 -81
- package/dist/components/Dock/Dock.cjs +1 -1
- package/dist/components/Dock/Dock.js +38 -43
- package/dist/components/Dock/Dock.utils.cjs +1 -0
- package/dist/components/Dock/Dock.utils.d.ts +1 -0
- package/dist/components/Dock/Dock.utils.js +10 -0
- package/dist/components/Dropdown/Dropdown.cjs +1 -1
- package/dist/components/Dropdown/Dropdown.js +77 -74
- package/dist/components/FileTree/FileTree.cjs +1 -1
- package/dist/components/FileTree/FileTree.js +20 -32
- package/dist/components/FileTree/FileTree.utils.cjs +1 -0
- package/dist/components/FileTree/FileTree.utils.d.ts +4 -0
- package/dist/components/FileTree/FileTree.utils.js +15 -0
- package/dist/components/GradientText/GradientText.cjs +1 -1
- package/dist/components/GradientText/GradientText.js +27 -29
- package/dist/components/Icon/icons/bear.cjs +1 -0
- package/dist/components/Icon/icons/bear.d.ts +12 -0
- package/dist/components/Icon/icons/bear.js +47 -0
- package/dist/components/Icon/index.cjs +1 -1
- package/dist/components/Icon/index.d.ts +18 -0
- package/dist/components/Icon/index.js +17 -15
- package/dist/components/InfiniteScroll/InfiniteScroll.cjs +1 -1
- package/dist/components/InfiniteScroll/InfiniteScroll.const.cjs +1 -1
- package/dist/components/InfiniteScroll/InfiniteScroll.const.js +6 -7
- package/dist/components/InfiniteScroll/InfiniteScroll.js +41 -41
- package/dist/components/Input/Input.cjs +1 -1
- package/dist/components/Input/Input.js +153 -101
- package/dist/components/Input/Input.types.d.ts +8 -2
- package/dist/components/Input/index.d.ts +1 -1
- package/dist/components/MentionsInput/MentionsInput.cjs +1 -1
- package/dist/components/MentionsInput/MentionsInput.js +64 -68
- package/dist/components/MentionsInput/MentionsInput.utils.cjs +1 -0
- package/dist/components/MentionsInput/MentionsInput.utils.d.ts +2 -0
- package/dist/components/MentionsInput/MentionsInput.utils.js +9 -0
- package/dist/components/PageNav/PageNav.cjs +1 -0
- package/dist/components/PageNav/PageNav.const.cjs +1 -0
- package/dist/components/PageNav/PageNav.const.d.ts +22 -0
- package/dist/components/PageNav/PageNav.const.js +42 -0
- package/dist/components/PageNav/PageNav.d.ts +3 -0
- package/dist/components/PageNav/PageNav.js +81 -0
- package/dist/components/PageNav/PageNav.types.d.ts +17 -0
- package/dist/components/PageNav/index.d.ts +2 -0
- package/dist/components/Popover/Popover.cjs +1 -1
- package/dist/components/Popover/Popover.js +76 -76
- package/dist/components/Progress/Progress.cjs +1 -1
- package/dist/components/Progress/Progress.js +6 -6
- package/dist/components/PropsPlayground/PropsPlayground.cjs +1 -0
- package/dist/components/PropsPlayground/PropsPlayground.const.cjs +1 -0
- package/dist/components/PropsPlayground/PropsPlayground.const.d.ts +11 -0
- package/dist/components/PropsPlayground/PropsPlayground.const.js +23 -0
- package/dist/components/PropsPlayground/PropsPlayground.d.ts +3 -0
- package/dist/components/PropsPlayground/PropsPlayground.js +221 -0
- package/dist/components/PropsPlayground/PropsPlayground.types.d.ts +29 -0
- package/dist/components/PropsPlayground/PropsPlayground.utils.cjs +1 -0
- package/dist/components/PropsPlayground/PropsPlayground.utils.d.ts +2 -0
- package/dist/components/PropsPlayground/PropsPlayground.utils.js +9 -0
- package/dist/components/PropsPlayground/index.d.ts +2 -0
- package/dist/components/Select/Select.cjs +1 -1
- package/dist/components/Select/Select.js +54 -53
- package/dist/components/SignPad/SignPad.cjs +1 -1
- package/dist/components/SignPad/SignPad.js +24 -24
- package/dist/components/Skeleton/Skeleton.cjs +1 -1
- package/dist/components/Skeleton/Skeleton.js +89 -94
- package/dist/components/Skeleton/Skeleton.utils.cjs +1 -0
- package/dist/components/Skeleton/Skeleton.utils.d.ts +1 -0
- package/dist/components/Skeleton/Skeleton.utils.js +10 -0
- package/dist/components/SliderRange/SliderRange.cjs +1 -1
- package/dist/components/SliderRange/SliderRange.js +61 -63
- package/dist/components/SliderRange/SliderRange.utils.cjs +1 -0
- package/dist/components/SliderRange/SliderRange.utils.d.ts +1 -0
- package/dist/components/SliderRange/SliderRange.utils.js +7 -0
- package/dist/components/Spotlight/Spotlight.cjs +1 -1
- package/dist/components/Spotlight/Spotlight.js +62 -73
- package/dist/components/Spotlight/Spotlight.utils.cjs +1 -0
- package/dist/components/Spotlight/Spotlight.utils.d.ts +3 -0
- package/dist/components/Spotlight/Spotlight.utils.js +18 -0
- package/dist/components/Tabs/TabList.cjs +1 -0
- package/dist/components/Tabs/TabList.d.ts +3 -0
- package/dist/components/Tabs/TabList.js +69 -0
- package/dist/components/Tabs/TabPanel.cjs +1 -0
- package/dist/components/Tabs/TabPanel.d.ts +3 -0
- package/dist/components/Tabs/TabPanel.js +13 -0
- package/dist/components/Tabs/Tabs.cjs +1 -1
- package/dist/components/Tabs/Tabs.d.ts +2 -27
- package/dist/components/Tabs/Tabs.js +43 -61
- package/dist/components/Tabs/Tabs.types.d.ts +7 -1
- package/dist/components/Tabs/index.d.ts +3 -1
- package/dist/components/Toast/Toast.cjs +1 -1
- package/dist/components/Toast/Toast.js +18 -17
- package/dist/components/Toast/Toast.utils.cjs +1 -0
- package/dist/components/Toast/Toast.utils.d.ts +1 -0
- package/dist/components/Toast/Toast.utils.js +4 -0
- package/dist/components/Tooltip/Tooltip.cjs +1 -1
- package/dist/components/Tooltip/Tooltip.js +10 -11
- package/dist/components/Tour/Tour.cjs +1 -1
- package/dist/components/Tour/Tour.js +1 -2
- package/dist/components/VirtualList/VirtualList.cjs +1 -1
- package/dist/components/VirtualList/VirtualList.js +38 -43
- package/dist/components/index.cjs +1 -1
- package/dist/components/index.d.ts +9 -2
- package/dist/components/index.js +311 -300
- package/dist/hooks/index.cjs +1 -1
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/index.js +60 -58
- package/dist/hooks/useResizeObserver/index.d.ts +2 -0
- package/dist/hooks/useResizeObserver/useResizeObserver.cjs +1 -0
- package/dist/hooks/useResizeObserver/useResizeObserver.d.ts +3 -0
- package/dist/hooks/useResizeObserver/useResizeObserver.js +20 -0
- package/dist/hooks/useResizeObserver/useResizeObserver.types.d.ts +8 -0
- package/dist/icons.cjs +1 -0
- package/dist/icons.d.ts +2 -0
- package/dist/icons.js +6 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +397 -384
- package/dist/styles/_base.css +7 -3
- package/dist/styles.css +1 -1
- package/package.json +6 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const C=require("react/jsx-runtime"),a=require("react"),R=require("../../utils/cn.cjs"),r=require("./Confetti.const.cjs"),v=({active:c=!1,count:E=r.CONFETTI_DEFAULTS.COUNT,duration:h=r.CONFETTI_DEFAULTS.DURATION,colors:T=r.CONFETTI_COLORS,originX:f=r.CONFETTI_DEFAULTS.ORIGIN_X,originY:I=r.CONFETTI_DEFAULTS.ORIGIN_Y,spread:F=r.CONFETTI_DEFAULTS.SPREAD,velocity:S=r.CONFETTI_DEFAULTS.VELOCITY,gravity:N=r.CONFETTI_DEFAULTS.GRAVITY,autoHide:O=r.CONFETTI_DEFAULTS.AUTO_HIDE,onComplete:o,className:x,testId:y})=>{const[m,d]=a.useState([]),[M,A]=a.useState(!1),n=a.useRef(),i=a.useRef(0),_=a.useCallback(()=>{const t=[],l=F*Math.PI/180;for(let s=0;s<E;s++){const e=-Math.PI/2+(Math.random()-.5)*l,b=S*(.5+Math.random()*.5);t.push({id:s,x:f*100,y:I*100,rotation:Math.random()*360,color:T[Math.floor(Math.random()*T.length)],size:r.CONFETTI_SIZE_RANGE.min+Math.random()*(r.CONFETTI_SIZE_RANGE.max-r.CONFETTI_SIZE_RANGE.min),velocity:{x:Math.cos(e)*b,y:Math.sin(e)*b},rotationSpeed:(Math.random()-.5)*20,shape:r.CONFETTI_SHAPES[Math.floor(Math.random()*r.CONFETTI_SHAPES.length)]})}return t},[E,T,f,I,F,S]),u=a.useCallback(t=>{if(i.current||(i.current=t),t-i.current>=h&&O){A(!1),d([]),o==null||o();return}d(s=>s.map(e=>({...e,x:e.x+e.velocity.x*.1,y:e.y+e.velocity.y*.1,rotation:e.rotation+e.rotationSpeed,velocity:{x:e.velocity.x*.99,y:e.velocity.y+N}}))),n.current=requestAnimationFrame(u)},[h,N,O,o]);a.useEffect(()=>(c?(A(!0),d(_()),i.current=0,n.current=requestAnimationFrame(u)):n.current&&cancelAnimationFrame(n.current),()=>{n.current&&cancelAnimationFrame(n.current)}),[c,_,u]);const g=t=>{const l={left:`${t.x}%`,top:`${t.y}%`,width:t.size,height:t.size,transform:`rotate(${t.rotation}deg)`,backgroundColor:t.shape!=="triangle"?t.color:"transparent",borderLeft:t.shape==="triangle"?`${t.size/2}px solid transparent`:void 0,borderRight:t.shape==="triangle"?`${t.size/2}px solid transparent`:void 0,borderBottom:t.shape==="triangle"?`${t.size}px solid ${t.color}`:void 0};return C.jsx("div",{className:R.cn("bear-absolute bear-opacity-90",t.shape==="circle"&&"bear-rounded-full"),style:l},t.id)};return!M||m.length===0?null:C.jsx("div",{className:R.cn("Bear-Confetti","bear-fixed bear-inset-0 bear-pointer-events-none bear-overflow-hidden bear-z-[99999]",x),"data-testid":y,children:m.map(g)})};exports.Confetti=v;
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useState as
|
|
3
|
-
import { cn as
|
|
4
|
-
import { CONFETTI_DEFAULTS as a, CONFETTI_SHAPES as
|
|
1
|
+
import { jsx as N } from "react/jsx-runtime";
|
|
2
|
+
import { useState as g, useRef as v, useCallback as S, useEffect as D } from "react";
|
|
3
|
+
import { cn as F } from "../../utils/cn.js";
|
|
4
|
+
import { CONFETTI_DEFAULTS as a, CONFETTI_SHAPES as _, CONFETTI_COLORS as G, CONFETTI_SIZE_RANGE as f } from "./Confetti.const.js";
|
|
5
5
|
const k = ({
|
|
6
6
|
active: m = !1,
|
|
7
7
|
count: u = a.COUNT,
|
|
8
8
|
duration: c = a.DURATION,
|
|
9
9
|
colors: l = G,
|
|
10
|
-
originX:
|
|
11
|
-
originY:
|
|
12
|
-
spread:
|
|
10
|
+
originX: b = a.ORIGIN_X,
|
|
11
|
+
originY: I = a.ORIGIN_Y,
|
|
12
|
+
spread: x = a.SPREAD,
|
|
13
13
|
velocity: T = a.VELOCITY,
|
|
14
|
-
gravity:
|
|
14
|
+
gravity: y = a.GRAVITY,
|
|
15
15
|
autoHide: M = a.AUTO_HIDE,
|
|
16
16
|
onComplete: o,
|
|
17
|
-
className:
|
|
18
|
-
testId:
|
|
17
|
+
className: z,
|
|
18
|
+
testId: P
|
|
19
19
|
}) => {
|
|
20
|
-
const [
|
|
21
|
-
const t = [], i =
|
|
20
|
+
const [E, d] = g([]), [$, O] = g(!1), n = v(), s = v(0), R = S(() => {
|
|
21
|
+
const t = [], i = x * Math.PI / 180;
|
|
22
22
|
for (let e = 0; e < u; e++) {
|
|
23
23
|
const r = -Math.PI / 2 + (Math.random() - 0.5) * i, A = T * (0.5 + Math.random() * 0.5);
|
|
24
24
|
t.push({
|
|
25
25
|
id: e,
|
|
26
|
-
x:
|
|
27
|
-
y:
|
|
26
|
+
x: b * 100,
|
|
27
|
+
y: I * 100,
|
|
28
28
|
rotation: Math.random() * 360,
|
|
29
29
|
color: l[Math.floor(Math.random() * l.length)],
|
|
30
30
|
size: f.min + Math.random() * (f.max - f.min),
|
|
@@ -33,13 +33,13 @@ const k = ({
|
|
|
33
33
|
y: Math.sin(r) * A
|
|
34
34
|
},
|
|
35
35
|
rotationSpeed: (Math.random() - 0.5) * 20,
|
|
36
|
-
shape:
|
|
36
|
+
shape: _[Math.floor(Math.random() * _.length)]
|
|
37
37
|
});
|
|
38
38
|
}
|
|
39
39
|
return t;
|
|
40
|
-
}, [u, l, I, x,
|
|
40
|
+
}, [u, l, b, I, x, T]), h = S((t) => {
|
|
41
41
|
if (s.current || (s.current = t), t - s.current >= c && M) {
|
|
42
|
-
|
|
42
|
+
O(!1), d([]), o == null || o();
|
|
43
43
|
return;
|
|
44
44
|
}
|
|
45
45
|
d(
|
|
@@ -50,42 +50,45 @@ const k = ({
|
|
|
50
50
|
rotation: r.rotation + r.rotationSpeed,
|
|
51
51
|
velocity: {
|
|
52
52
|
x: r.velocity.x * 0.99,
|
|
53
|
-
y: r.velocity.y +
|
|
53
|
+
y: r.velocity.y + y
|
|
54
54
|
}
|
|
55
55
|
}))
|
|
56
56
|
), n.current = requestAnimationFrame(h);
|
|
57
|
-
}, [c,
|
|
58
|
-
|
|
57
|
+
}, [c, y, M, o]);
|
|
58
|
+
D(() => (m ? (O(!0), d(R()), s.current = 0, n.current = requestAnimationFrame(h)) : n.current && cancelAnimationFrame(n.current), () => {
|
|
59
59
|
n.current && cancelAnimationFrame(n.current);
|
|
60
|
-
}), [m,
|
|
61
|
-
const
|
|
60
|
+
}), [m, R, h]);
|
|
61
|
+
const C = (t) => {
|
|
62
62
|
const i = {
|
|
63
|
-
position: "absolute",
|
|
64
63
|
left: `${t.x}%`,
|
|
65
64
|
top: `${t.y}%`,
|
|
66
65
|
width: t.size,
|
|
67
66
|
height: t.size,
|
|
68
67
|
transform: `rotate(${t.rotation}deg)`,
|
|
69
68
|
backgroundColor: t.shape !== "triangle" ? t.color : "transparent",
|
|
70
|
-
borderRadius: t.shape === "circle" ? "50%" : 0,
|
|
71
69
|
borderLeft: t.shape === "triangle" ? `${t.size / 2}px solid transparent` : void 0,
|
|
72
70
|
borderRight: t.shape === "triangle" ? `${t.size / 2}px solid transparent` : void 0,
|
|
73
|
-
borderBottom: t.shape === "triangle" ? `${t.size}px solid ${t.color}` : void 0
|
|
74
|
-
opacity: 0.9
|
|
71
|
+
borderBottom: t.shape === "triangle" ? `${t.size}px solid ${t.color}` : void 0
|
|
75
72
|
};
|
|
76
|
-
return /* @__PURE__ */
|
|
73
|
+
return /* @__PURE__ */ N(
|
|
74
|
+
"div",
|
|
75
|
+
{
|
|
76
|
+
className: F("bear-absolute bear-opacity-90", t.shape === "circle" && "bear-rounded-full"),
|
|
77
|
+
style: i
|
|
78
|
+
},
|
|
79
|
+
t.id
|
|
80
|
+
);
|
|
77
81
|
};
|
|
78
|
-
return
|
|
82
|
+
return !$ || E.length === 0 ? null : /* @__PURE__ */ N(
|
|
79
83
|
"div",
|
|
80
84
|
{
|
|
81
|
-
className:
|
|
85
|
+
className: F(
|
|
82
86
|
"Bear-Confetti",
|
|
83
|
-
"bear-fixed bear-inset-0 bear-pointer-events-none bear-overflow-hidden",
|
|
84
|
-
|
|
87
|
+
"bear-fixed bear-inset-0 bear-pointer-events-none bear-overflow-hidden bear-z-[99999]",
|
|
88
|
+
z
|
|
85
89
|
),
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
children: R.map($)
|
|
90
|
+
"data-testid": P,
|
|
91
|
+
children: E.map(C)
|
|
89
92
|
}
|
|
90
93
|
);
|
|
91
94
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),r=require("react"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),r=require("react"),_=require("../../utils/cn.cjs"),l=require("./ContextMenu.const.cjs"),j=require("./ContextMenu.utils.cjs"),b=({items:S,position:a,onClose:i})=>{const[c,o]=r.useState(null),[u,d]=r.useState({x:0,y:0}),x=r.useRef(null),E=r.useCallback(s=>{var e;s.disabled||s.children||((e=s.onClick)==null||e.call(s),i())},[i]),f=r.useCallback((s,e)=>{if(s.children){const n=e.currentTarget.getBoundingClientRect();d({x:n.right+l.SUB_MENU_OFFSET,y:n.top}),o(s.id)}else o(null)},[]);return t.jsx("div",{ref:x,className:l.MENU_CLASSES,style:{left:a.x,top:a.y},role:"menu",children:S.map(s=>{if(j.isDivider(s))return t.jsx("div",{className:l.DIVIDER_CLASSES,role:"separator"},s.id);const e=s;return t.jsxs("div",{children:[t.jsxs("div",{className:_.cn(l.ITEM_CLASSES,e.disabled&&l.ITEM_DISABLED_CLASSES,e.danger&&l.ITEM_DANGER_CLASSES),onClick:()=>E(e),onMouseEnter:n=>f(e,n),role:"menuitem","aria-disabled":e.disabled,children:[t.jsxs("span",{className:"bear-flex bear-items-center",children:[e.icon&&t.jsx("span",{className:l.ICON_CLASSES,children:e.icon}),e.label]}),t.jsxs("span",{className:"bear-flex bear-items-center",children:[e.shortcut&&t.jsx("span",{className:l.SHORTCUT_CLASSES,children:e.shortcut}),e.children&&t.jsx("span",{className:l.SUB_INDICATOR_CLASSES,children:"▸"})]})]}),e.children&&c===e.id&&t.jsx(b,{items:e.children,position:u,onClose:i})]},e.id)})})},v=({items:S,children:a,disabled:i=!1,onOpenChange:c,testId:o})=>{const[u,d]=r.useState(!1),[x,E]=r.useState({x:0,y:0}),f=r.useRef(null),s=r.useCallback(()=>{d(!1),c==null||c(!1)},[c]),e=r.useCallback(n=>{i||(n.preventDefault(),E({x:n.clientX,y:n.clientY}),d(!0),c==null||c(!0))},[i,c]);return r.useEffect(()=>{if(!u)return;const n=()=>s(),m=M=>{M.key==="Escape"&&s()};return document.addEventListener("mousedown",n),document.addEventListener("keydown",m),()=>{document.removeEventListener("mousedown",n),document.removeEventListener("keydown",m)}},[u,s]),t.jsxs("div",{ref:f,onContextMenu:e,"data-testid":o,children:[a,u&&t.jsx(b,{items:S,position:x,onClose:s})]})};exports.ContextMenu=v;
|
|
@@ -1,23 +1,24 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useState as
|
|
1
|
+
import { jsxs as i, jsx as n } from "react/jsx-runtime";
|
|
2
|
+
import { useState as u, useRef as b, useCallback as S, useEffect as N } from "react";
|
|
3
3
|
import { cn as _ } from "../../utils/cn.js";
|
|
4
|
-
import { SUB_MENU_OFFSET as h, MENU_CLASSES as A, DIVIDER_CLASSES as I, ICON_CLASSES as M, SHORTCUT_CLASSES as
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
import { SUB_MENU_OFFSET as h, MENU_CLASSES as A, DIVIDER_CLASSES as I, ICON_CLASSES as M, SHORTCUT_CLASSES as k, SUB_INDICATOR_CLASSES as y, ITEM_DANGER_CLASSES as C, ITEM_DISABLED_CLASSES as D, ITEM_CLASSES as R } from "./ContextMenu.const.js";
|
|
5
|
+
import { isDivider as T } from "./ContextMenu.utils.js";
|
|
6
|
+
const v = ({ items: m, position: o, onClose: c }) => {
|
|
7
|
+
const [r, d] = u(null), [l, a] = u({ x: 0, y: 0 }), f = b(null), E = S((s) => {
|
|
7
8
|
var e;
|
|
8
|
-
s.disabled || s.children || ((e = s.onClick) == null || e.call(s),
|
|
9
|
-
}, [
|
|
9
|
+
s.disabled || s.children || ((e = s.onClick) == null || e.call(s), c());
|
|
10
|
+
}, [c]), p = S((s, e) => {
|
|
10
11
|
if (s.children) {
|
|
11
12
|
const t = e.currentTarget.getBoundingClientRect();
|
|
12
|
-
|
|
13
|
+
a({ x: t.right + h, y: t.top }), d(s.id);
|
|
13
14
|
} else
|
|
14
|
-
|
|
15
|
+
d(null);
|
|
15
16
|
}, []);
|
|
16
|
-
return /* @__PURE__ */ n("div", { ref: f, className: A, style: { left: o.x, top: o.y }, role: "menu", children:
|
|
17
|
+
return /* @__PURE__ */ n("div", { ref: f, className: A, style: { left: o.x, top: o.y }, role: "menu", children: m.map((s) => {
|
|
17
18
|
if (T(s)) return /* @__PURE__ */ n("div", { className: I, role: "separator" }, s.id);
|
|
18
19
|
const e = s;
|
|
19
|
-
return /* @__PURE__ */
|
|
20
|
-
/* @__PURE__ */
|
|
20
|
+
return /* @__PURE__ */ i("div", { children: [
|
|
21
|
+
/* @__PURE__ */ i(
|
|
21
22
|
"div",
|
|
22
23
|
{
|
|
23
24
|
className: _(R, e.disabled && D, e.danger && C),
|
|
@@ -26,39 +27,39 @@ const T = (c) => "type" in c && c.type === "divider", b = ({ items: c, position:
|
|
|
26
27
|
role: "menuitem",
|
|
27
28
|
"aria-disabled": e.disabled,
|
|
28
29
|
children: [
|
|
29
|
-
/* @__PURE__ */
|
|
30
|
+
/* @__PURE__ */ i("span", { className: "bear-flex bear-items-center", children: [
|
|
30
31
|
e.icon && /* @__PURE__ */ n("span", { className: M, children: e.icon }),
|
|
31
32
|
e.label
|
|
32
33
|
] }),
|
|
33
|
-
/* @__PURE__ */
|
|
34
|
-
e.shortcut && /* @__PURE__ */ n("span", { className:
|
|
35
|
-
e.children && /* @__PURE__ */ n("span", { className:
|
|
34
|
+
/* @__PURE__ */ i("span", { className: "bear-flex bear-items-center", children: [
|
|
35
|
+
e.shortcut && /* @__PURE__ */ n("span", { className: k, children: e.shortcut }),
|
|
36
|
+
e.children && /* @__PURE__ */ n("span", { className: y, children: "▸" })
|
|
36
37
|
] })
|
|
37
38
|
]
|
|
38
39
|
}
|
|
39
40
|
),
|
|
40
|
-
e.children && r === e.id && /* @__PURE__ */ n(
|
|
41
|
+
e.children && r === e.id && /* @__PURE__ */ n(v, { items: e.children, position: l, onClose: c })
|
|
41
42
|
] }, e.id);
|
|
42
43
|
}) });
|
|
43
|
-
},
|
|
44
|
-
const [
|
|
45
|
-
|
|
46
|
-
}, [r]), e =
|
|
47
|
-
|
|
48
|
-
}, [
|
|
44
|
+
}, F = ({ items: m, children: o, disabled: c = !1, onOpenChange: r, testId: d }) => {
|
|
45
|
+
const [l, a] = u(!1), [f, E] = u({ x: 0, y: 0 }), p = b(null), s = S(() => {
|
|
46
|
+
a(!1), r == null || r(!1);
|
|
47
|
+
}, [r]), e = S((t) => {
|
|
48
|
+
c || (t.preventDefault(), E({ x: t.clientX, y: t.clientY }), a(!0), r == null || r(!0));
|
|
49
|
+
}, [c, r]);
|
|
49
50
|
return N(() => {
|
|
50
|
-
if (!
|
|
51
|
-
const t = () => s(),
|
|
51
|
+
if (!l) return;
|
|
52
|
+
const t = () => s(), L = (x) => {
|
|
52
53
|
x.key === "Escape" && s();
|
|
53
54
|
};
|
|
54
|
-
return document.addEventListener("mousedown", t), document.addEventListener("keydown",
|
|
55
|
-
document.removeEventListener("mousedown", t), document.removeEventListener("keydown",
|
|
55
|
+
return document.addEventListener("mousedown", t), document.addEventListener("keydown", L), () => {
|
|
56
|
+
document.removeEventListener("mousedown", t), document.removeEventListener("keydown", L);
|
|
56
57
|
};
|
|
57
|
-
}, [
|
|
58
|
+
}, [l, s]), /* @__PURE__ */ i("div", { ref: p, onContextMenu: e, "data-testid": d, children: [
|
|
58
59
|
o,
|
|
59
|
-
|
|
60
|
+
l && /* @__PURE__ */ n(v, { items: m, position: f, onClose: s })
|
|
60
61
|
] });
|
|
61
62
|
};
|
|
62
63
|
export {
|
|
63
|
-
|
|
64
|
+
F as ContextMenu
|
|
64
65
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=i=>"type"in i&&i.type==="divider";exports.isDivider=e;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),t=require("react"),d=require("../../utils/cn.cjs"),e=require("./CountdownTimer.const.cjs"),s=require("./CountdownTimer.utils.cjs"),G=y=>{const{targetDate:c,duration:b,variant:w="default",size:m="md",showDays:A=!0,showHours:L=!0,showMinutes:v=!0,showSeconds:I=!0,showLabels:D=!0,showSeparator:R=!0,separator:N=e.DEFAULT_SEPARATOR,labels:E,onComplete:o,onTick:l,paused:C=!1,render:h,className:j,style:k,testId:B}=y,u=t.useMemo(()=>({...e.DEFAULT_LABELS,...E}),[E]),x=t.useRef(!1),P=t.useCallback(()=>c?new Date(c).getTime():b?Date.now()+b*e.MS_PER_SECOND:Date.now(),[c,b]),[S]=t.useState(P),[n,Z]=t.useState(()=>s.calcRemaining(S,Date.now()));if(t.useEffect(()=>{if(C)return;const a=()=>{const p=s.calcRemaining(S,Date.now());Z(p),l==null||l(p),p.isComplete&&!x.current&&(x.current=!0,o==null||o())};a();const _=setInterval(a,e.UPDATE_INTERVAL);return()=>clearInterval(_)},[S,C,o,l]),h)return r.jsx(r.Fragment,{children:h(n)});const f=e.SIZE_DIGIT_CLASSES[m]??e.SIZE_DIGIT_CLASSES.md,q=e.SIZE_LABEL_CLASSES[m]??e.SIZE_LABEL_CLASSES.md,F=e.SIZE_GAP_CLASSES[m]??e.SIZE_GAP_CLASSES.md,i=[];A&&i.push({value:s.pad(n.days),label:u.days}),L&&i.push({value:s.pad(n.hours),label:u.hours}),v&&i.push({value:s.pad(n.minutes),label:u.minutes}),I&&i.push({value:s.pad(n.seconds),label:u.seconds});const g=w==="card",T=w==="flip";return r.jsx("div",{className:d.cn("Bear-CountdownTimer","bear-flex bear-items-center",F,j),style:k,"data-testid":B,role:"timer","aria-label":"Countdown timer",children:i.map((a,_)=>r.jsxs("div",{className:"Bear-CountdownTimer__segment bear-flex bear-items-center",children:[_>0&&R&&!g&&r.jsx("span",{className:d.cn("Bear-CountdownTimer__separator",f,e.SEPARATOR_MARGIN,"bear-text-gray-400 dark:bear-text-gray-500"),"aria-hidden":"true",children:N}),r.jsxs("div",{className:"Bear-CountdownTimer__unit bear-flex bear-flex-col bear-items-center",children:[r.jsx("div",{className:d.cn("Bear-CountdownTimer__digit",f,"bear-tabular-nums bear-tracking-wider",g&&["bear-px-3 bear-py-2 bear-rounded-lg","bear-bg-gray-100 dark:bear-bg-gray-800","bear-border bear-border-gray-200 dark:bear-border-gray-700"],T&&["bear-px-3 bear-py-2 bear-rounded-lg","bear-bg-gray-900 dark:bear-bg-gray-100","bear-text-white dark:bear-text-gray-900","bear-shadow-lg"],!g&&!T&&"bear-text-[var(--bear-text-primary)]"),children:a.value}),D&&r.jsx("span",{className:d.cn("Bear-CountdownTimer__label",q,"bear-mt-1 bear-uppercase bear-tracking-widest","bear-text-gray-500 dark:bear-text-gray-400"),children:a.label})]})]},a.label))})};exports.CountdownTimer=G;
|
|
@@ -1,115 +1,106 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useMemo as
|
|
3
|
-
import { cn as
|
|
4
|
-
import { DEFAULT_SEPARATOR as
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
return {
|
|
8
|
-
days: Math.floor(e / N),
|
|
9
|
-
hours: Math.floor(e % N / L),
|
|
10
|
-
minutes: Math.floor(e % L / R),
|
|
11
|
-
seconds: Math.floor(e % R / h),
|
|
12
|
-
totalSeconds: Math.floor(e / h),
|
|
13
|
-
isComplete: e <= 0
|
|
14
|
-
};
|
|
15
|
-
}, ie = (a) => {
|
|
1
|
+
import { jsx as t, Fragment as H, jsxs as C } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo as V, useRef as q, useCallback as J, useState as E, useEffect as K } from "react";
|
|
3
|
+
import { cn as o } from "../../utils/cn.js";
|
|
4
|
+
import { DEFAULT_SEPARATOR as Q, DEFAULT_LABELS as W, MS_PER_SECOND as X, UPDATE_INTERVAL as Y, SEPARATOR_MARGIN as $, SIZE_DIGIT_CLASSES as T, SIZE_LABEL_CLASSES as A, SIZE_GAP_CLASSES as v } from "./CountdownTimer.const.js";
|
|
5
|
+
import { calcRemaining as D, pad as l } from "./CountdownTimer.utils.js";
|
|
6
|
+
const ne = (L) => {
|
|
16
7
|
const {
|
|
17
|
-
targetDate:
|
|
18
|
-
duration:
|
|
19
|
-
variant:
|
|
20
|
-
size:
|
|
21
|
-
showDays:
|
|
22
|
-
showHours:
|
|
23
|
-
showMinutes:
|
|
24
|
-
showSeconds:
|
|
25
|
-
showLabels:
|
|
26
|
-
showSeparator:
|
|
27
|
-
separator:
|
|
28
|
-
labels:
|
|
29
|
-
onComplete:
|
|
30
|
-
onTick:
|
|
31
|
-
paused:
|
|
32
|
-
render:
|
|
33
|
-
className:
|
|
34
|
-
style:
|
|
35
|
-
testId:
|
|
36
|
-
} =
|
|
37
|
-
if (
|
|
38
|
-
if (
|
|
39
|
-
const
|
|
40
|
-
const p =
|
|
41
|
-
|
|
8
|
+
targetDate: d,
|
|
9
|
+
duration: b,
|
|
10
|
+
variant: f = "default",
|
|
11
|
+
size: u = "md",
|
|
12
|
+
showDays: I = !0,
|
|
13
|
+
showHours: N = !0,
|
|
14
|
+
showMinutes: k = !0,
|
|
15
|
+
showSeconds: R = !0,
|
|
16
|
+
showLabels: B = !0,
|
|
17
|
+
showSeparator: P = !0,
|
|
18
|
+
separator: F = Q,
|
|
19
|
+
labels: w,
|
|
20
|
+
onComplete: s,
|
|
21
|
+
onTick: n,
|
|
22
|
+
paused: h = !1,
|
|
23
|
+
render: _,
|
|
24
|
+
className: M,
|
|
25
|
+
style: G,
|
|
26
|
+
testId: O
|
|
27
|
+
} = L, i = V(() => ({ ...W, ...w }), [w]), S = q(!1), U = J(() => d ? new Date(d).getTime() : b ? Date.now() + b * X : Date.now(), [d, b]), [c] = E(U), [r, Z] = E(() => D(c, Date.now()));
|
|
28
|
+
if (K(() => {
|
|
29
|
+
if (h) return;
|
|
30
|
+
const e = () => {
|
|
31
|
+
const p = D(c, Date.now());
|
|
32
|
+
Z(p), n == null || n(p), p.isComplete && !S.current && (S.current = !0, s == null || s());
|
|
42
33
|
};
|
|
43
|
-
|
|
44
|
-
const
|
|
45
|
-
return () => clearInterval(
|
|
46
|
-
}, [
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
const
|
|
50
|
-
return /* @__PURE__ */
|
|
34
|
+
e();
|
|
35
|
+
const g = setInterval(e, Y);
|
|
36
|
+
return () => clearInterval(g);
|
|
37
|
+
}, [c, h, s, n]), _) return /* @__PURE__ */ t(H, { children: _(r) });
|
|
38
|
+
const y = T[u] ?? T.md, j = A[u] ?? A.md, z = v[u] ?? v.md, a = [];
|
|
39
|
+
I && a.push({ value: l(r.days), label: i.days }), N && a.push({ value: l(r.hours), label: i.hours }), k && a.push({ value: l(r.minutes), label: i.minutes }), R && a.push({ value: l(r.seconds), label: i.seconds });
|
|
40
|
+
const m = f === "card", x = f === "flip";
|
|
41
|
+
return /* @__PURE__ */ t(
|
|
51
42
|
"div",
|
|
52
43
|
{
|
|
53
|
-
className:
|
|
54
|
-
style:
|
|
55
|
-
"data-testid":
|
|
44
|
+
className: o("Bear-CountdownTimer", "bear-flex bear-items-center", z, M),
|
|
45
|
+
style: G,
|
|
46
|
+
"data-testid": O,
|
|
56
47
|
role: "timer",
|
|
57
48
|
"aria-label": "Countdown timer",
|
|
58
|
-
children:
|
|
59
|
-
|
|
49
|
+
children: a.map((e, g) => /* @__PURE__ */ C("div", { className: "Bear-CountdownTimer__segment bear-flex bear-items-center", children: [
|
|
50
|
+
g > 0 && P && !m && /* @__PURE__ */ t(
|
|
60
51
|
"span",
|
|
61
52
|
{
|
|
62
|
-
className:
|
|
53
|
+
className: o(
|
|
63
54
|
"Bear-CountdownTimer__separator",
|
|
64
|
-
|
|
65
|
-
|
|
55
|
+
y,
|
|
56
|
+
$,
|
|
66
57
|
"bear-text-gray-400 dark:bear-text-gray-500"
|
|
67
58
|
),
|
|
68
59
|
"aria-hidden": "true",
|
|
69
|
-
children:
|
|
60
|
+
children: F
|
|
70
61
|
}
|
|
71
62
|
),
|
|
72
|
-
/* @__PURE__ */
|
|
73
|
-
/* @__PURE__ */
|
|
63
|
+
/* @__PURE__ */ C("div", { className: "Bear-CountdownTimer__unit bear-flex bear-flex-col bear-items-center", children: [
|
|
64
|
+
/* @__PURE__ */ t(
|
|
74
65
|
"div",
|
|
75
66
|
{
|
|
76
|
-
className:
|
|
67
|
+
className: o(
|
|
77
68
|
"Bear-CountdownTimer__digit",
|
|
78
|
-
|
|
69
|
+
y,
|
|
79
70
|
"bear-tabular-nums bear-tracking-wider",
|
|
80
|
-
|
|
71
|
+
m && [
|
|
81
72
|
"bear-px-3 bear-py-2 bear-rounded-lg",
|
|
82
73
|
"bear-bg-gray-100 dark:bear-bg-gray-800",
|
|
83
74
|
"bear-border bear-border-gray-200 dark:bear-border-gray-700"
|
|
84
75
|
],
|
|
85
|
-
|
|
76
|
+
x && [
|
|
86
77
|
"bear-px-3 bear-py-2 bear-rounded-lg",
|
|
87
78
|
"bear-bg-gray-900 dark:bear-bg-gray-100",
|
|
88
79
|
"bear-text-white dark:bear-text-gray-900",
|
|
89
80
|
"bear-shadow-lg"
|
|
90
81
|
],
|
|
91
|
-
!
|
|
82
|
+
!m && !x && "bear-text-[var(--bear-text-primary)]"
|
|
92
83
|
),
|
|
93
|
-
children:
|
|
84
|
+
children: e.value
|
|
94
85
|
}
|
|
95
86
|
),
|
|
96
|
-
|
|
87
|
+
B && /* @__PURE__ */ t(
|
|
97
88
|
"span",
|
|
98
89
|
{
|
|
99
|
-
className:
|
|
90
|
+
className: o(
|
|
100
91
|
"Bear-CountdownTimer__label",
|
|
101
|
-
|
|
92
|
+
j,
|
|
102
93
|
"bear-mt-1 bear-uppercase bear-tracking-widest",
|
|
103
94
|
"bear-text-gray-500 dark:bear-text-gray-400"
|
|
104
95
|
),
|
|
105
|
-
children:
|
|
96
|
+
children: e.label
|
|
106
97
|
}
|
|
107
98
|
)
|
|
108
99
|
] })
|
|
109
|
-
] },
|
|
100
|
+
] }, e.label))
|
|
110
101
|
}
|
|
111
102
|
);
|
|
112
103
|
};
|
|
113
104
|
export {
|
|
114
|
-
|
|
105
|
+
ne as CountdownTimer
|
|
115
106
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./CountdownTimer.const.cjs"),n=a=>String(a).padStart(o.PAD_LENGTH,"0"),_=(a,e)=>{const t=Math.max(0,a-e);return{days:Math.floor(t/o.MS_PER_DAY),hours:Math.floor(t%o.MS_PER_DAY/o.MS_PER_HOUR),minutes:Math.floor(t%o.MS_PER_HOUR/o.MS_PER_MINUTE),seconds:Math.floor(t%o.MS_PER_MINUTE/o.MS_PER_SECOND),totalSeconds:Math.floor(t/o.MS_PER_SECOND),isComplete:t<=0}};exports.calcRemaining=_;exports.pad=n;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { MS_PER_SECOND as a, MS_PER_MINUTE as r, MS_PER_HOUR as M, MS_PER_DAY as n, PAD_LENGTH as _ } from "./CountdownTimer.const.js";
|
|
2
|
+
const f = (t) => String(t).padStart(_, "0"), l = (t, s) => {
|
|
3
|
+
const o = Math.max(0, t - s);
|
|
4
|
+
return {
|
|
5
|
+
days: Math.floor(o / n),
|
|
6
|
+
hours: Math.floor(o % n / M),
|
|
7
|
+
minutes: Math.floor(o % M / r),
|
|
8
|
+
seconds: Math.floor(o % r / a),
|
|
9
|
+
totalSeconds: Math.floor(o / a),
|
|
10
|
+
isComplete: o <= 0
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
export {
|
|
14
|
+
l as calcRemaining,
|
|
15
|
+
f as pad
|
|
16
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("react"),X=require("react-dom"),h=require("../../utils/cn.cjs"),r=require("./DateRangePicker.const.cjs"),b=require("./DateRangePicker.utils.cjs"),O=({year:E,month:d,range:a,onDayClick:k,onNav:L,minDate:u,maxDate:A})=>{const C=b.getCalendarDays(E,d),x=new Date;return x.setHours(0,0,0,0),e.jsxs("div",{className:"bear-w-64",children:[e.jsxs("div",{className:r.CALENDAR_HEADER_CLASSES,children:[e.jsx("button",{type:"button",onClick:()=>L(-1),className:r.NAV_BTN_CLASSES,"aria-label":"Previous month",children:e.jsx("svg",{className:"bear-w-4 bear-h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})}),e.jsxs("span",{className:"bear-text-sm bear-font-semibold bear-text-gray-900 dark:bear-text-white",children:[r.MONTH_LABELS[d]," ",E]}),e.jsx("button",{type:"button",onClick:()=>L(1),className:r.NAV_BTN_CLASSES,"aria-label":"Next month",children:e.jsx("svg",{className:"bear-w-4 bear-h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})})]}),e.jsx("div",{className:"bear-grid bear-grid-cols-7 bear-gap-0.5 bear-mb-1",children:r.DAY_LABELS.map(n=>e.jsx("div",{className:"bear-text-xs bear-text-center bear-font-medium bear-text-gray-400 dark:bear-text-zinc-500 bear-py-1",children:n},n))}),e.jsx("div",{className:"bear-grid bear-grid-cols-7 bear-gap-0.5",children:C.map((n,_)=>{if(!n)return e.jsx("div",{},`e-${_}`);const p=u&&n<u||A&&n>A,i=b.isSameDay(n,a.start)||b.isSameDay(n,a.end),S=b.isInRange(n,a.start,a.end),D=b.isSameDay(n,x);return e.jsx("button",{type:"button",disabled:!!p,onClick:()=>k(n),className:h.cn(r.DAY_BASE_CLASSES,p?r.DAY_DISABLED_CLASSES:r.DAY_HOVER_CLASSES,i&&r.DAY_SELECTED_CLASSES,!i&&S&&r.DAY_IN_RANGE_CLASSES,!i&&!S&&D&&r.DAY_TODAY_CLASSES,!i&&!S&&!p&&"bear-text-gray-700 dark:bear-text-zinc-300"),children:n.getDate()},n.getTime())})})]})},ee=E=>{const{value:d,onChange:a,label:k,placeholder:L="Select date range",disabled:u=!1,clearable:A=!0,minDate:C,maxDate:x,presets:n,showPresets:_=!0,size:p="md",error:i,helperText:S,className:D,testId:I,...q}=E,[N,w]=s.useState(!1),[P,V]=s.useState({top:0,left:0}),[c,f]=s.useState(d??{start:null,end:null}),[T,j]=s.useState("start"),B=s.useRef(null),R=s.useRef(null),Y=s.useRef(null),M=new Date,[m,$]=s.useState(M.getMonth()),[g,G]=s.useState(M.getFullYear()),W=m===11?0:m+1,F=m===11?g+1:g;s.useEffect(()=>{d&&f(d)},[d]),s.useEffect(()=>{if(N&&R.current){const t=R.current.getBoundingClientRect(),o=8,l=400,U=window.innerHeight-t.bottom<l&&t.top>l;V({top:U?t.top-l-o:t.bottom+o,left:t.left})}},[N]),s.useEffect(()=>{const t=o=>{var v,y;const l=o.target;(v=B.current)!=null&&v.contains(l)||(y=Y.current)!=null&&y.contains(l)||w(!1)};return document.addEventListener("mousedown",t),()=>document.removeEventListener("mousedown",t)},[]);const H=s.useCallback(t=>{if(T==="start")f({start:t,end:null}),j("end");else{const o=t>=(c.start??t)?{start:c.start,end:t}:{start:t,end:c.start};f(o),j("start"),a==null||a(o)}},[T,c.start,a]),Z=s.useCallback(t=>{f(t),a==null||a(t),w(!1),j("start")},[a]),J=s.useCallback(()=>{const t={start:null,end:null};f(t),a==null||a(t),j("start")},[a]),K=s.useCallback(t=>{let o=m+t,l=g;o<0&&(o=11,l--),o>11&&(o=0,l++),$(o),G(l)},[m,g]),z=n??(_?r.getDefaultPresets():[]),Q=c.start?`${b.formatDate(c.start)}${c.end?` – ${b.formatDate(c.end)}`:""}`:L;return e.jsxs("div",{ref:B,className:h.cn(r.ROOT_CLASSES,D),"data-testid":I,...q,children:[k&&e.jsx("label",{className:r.LABEL_CLASSES,children:k}),e.jsxs("button",{ref:R,type:"button",disabled:u,onClick:()=>!u&&w(!N),className:h.cn(r.TRIGGER_CLASSES,r.SIZE_CLASSES[p],u&&"bear-opacity-50 bear-cursor-not-allowed"),children:[e.jsx("span",{className:h.cn(!c.start&&"bear-text-gray-400 dark:bear-text-zinc-500"),children:Q}),e.jsx("svg",{className:"bear-w-4 bear-h-4 bear-ml-2 bear-text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"})})]}),N&&typeof document<"u"&&X.createPortal(e.jsx("div",{ref:Y,"data-bear-daterangepicker-dropdown":!0,className:h.cn("bear-fixed bear-z-[9999] bear-bg-white dark:bear-bg-zinc-800 bear-border bear-border-gray-200 dark:bear-border-zinc-700 bear-rounded-xl bear-shadow-xl bear-p-4"),style:{top:P.top,left:P.left},children:e.jsxs("div",{className:"bear-flex bear-gap-4",children:[z.length>0&&e.jsxs("div",{className:"bear-border-r bear-border-gray-200 dark:bear-border-zinc-700 bear-pr-3 bear-space-y-1 bear-min-w-[120px]",children:[z.map(t=>e.jsx("button",{type:"button",onClick:()=>Z(t.range()),className:r.PRESET_BTN_CLASSES,children:t.label},t.label)),A&&c.start&&e.jsx("button",{type:"button",onClick:J,className:h.cn(r.PRESET_BTN_CLASSES,"bear-text-red-500"),children:"Clear"})]}),e.jsx(O,{year:g,month:m,range:c,onDayClick:H,onNav:K,minDate:C,maxDate:x}),e.jsx(O,{year:F,month:W,range:c,onDayClick:H,onNav:()=>{},minDate:C,maxDate:x})]})}),document.body),i&&e.jsx("p",{className:r.ERROR_CLASSES,children:i}),!i&&S&&e.jsx("p",{className:r.HELPER_CLASSES,children:S})]})};exports.DateRangePicker=ee;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=7,b=6,S=["Su","Mo","Tu","We","Th","Fr","Sa"],n=["January","February","March","April","May","June","July","August","September","October","November","December"],E={sm:"bear-py-1.5 bear-px-3 bear-text-sm",md:"bear-py-2 bear-px-4 bear-text-base",lg:"bear-py-2.5 bear-px-5 bear-text-lg"},o="Bear-DateRangePicker bear-relative bear-inline-block",A="bear-w-full bear-flex bear-items-center bear-justify-between bear-rounded-lg bear-border bear-border-gray-300 dark:bear-border-zinc-600 bear-bg-white dark:bear-bg-zinc-800 bear-text-gray-900 dark:bear-text-white bear-transition-colors focus:bear-ring-2 focus:bear-ring-pink-500 bear-outline-none",s="bear-flex bear-items-center bear-justify-between bear-mb-2",_="bear-p-1 bear-rounded hover:bear-bg-gray-100 dark:hover:bear-bg-zinc-700 bear-text-gray-500 dark:bear-text-zinc-400",L="bear-w-8 bear-h-8 bear-text-sm bear-rounded-full bear-transition-colors bear-cursor-pointer",c="bear-bg-pink-500 bear-text-white",D="bear-bg-pink-100 dark:bear-bg-pink-900/30 bear-text-pink-800 dark:bear-text-pink-200",i="hover:bear-bg-gray-100 dark:hover:bear-bg-zinc-700",g="bear-text-gray-300 dark:bear-text-zinc-600 bear-cursor-not-allowed",l="bear-ring-1 bear-ring-pink-400",d="bear-w-full bear-text-left bear-px-3 bear-py-1.5 bear-text-sm bear-rounded bear-transition-colors hover:bear-bg-pink-50 dark:hover:bear-bg-pink-900/20 bear-text-gray-700 dark:bear-text-zinc-300",u="Bear-DateRangePicker__label bear-block bear-text-sm bear-font-medium bear-text-gray-700 dark:bear-text-zinc-300 bear-mb-1.5",C="bear-mt-1 bear-text-xs bear-text-red-500",x="bear-mt-1 bear-text-xs bear-text-gray-500 dark:bear-text-zinc-500",R=()=>{const e=new Date;return e.setHours(0,0,0,0),[{label:"Today",range:()=>({start:new Date(e),end:new Date(e)})},{label:"Last 7 days",range:()=>{const r=new Date(e);return r.setDate(r.getDate()-6),{start:r,end:new Date(e)}}},{label:"Last 30 days",range:()=>{const r=new Date(e);return r.setDate(r.getDate()-29),{start:r,end:new Date(e)}}},{label:"This month",range:()=>({start:new Date(e.getFullYear(),e.getMonth(),1),end:new Date(e)})},{label:"Last month",range:()=>{const r=new Date(e.getFullYear(),e.getMonth()-1,1),t=new Date(e.getFullYear(),e.getMonth(),0);return{start:r,end:t}}}]};exports.CALENDAR_HEADER_CLASSES=s;exports.CALENDAR_ROWS=b;exports.DAYS_IN_WEEK=a;exports.DAY_BASE_CLASSES=L;exports.DAY_DISABLED_CLASSES=g;exports.DAY_HOVER_CLASSES=i;exports.DAY_IN_RANGE_CLASSES=D;exports.DAY_LABELS=S;exports.DAY_SELECTED_CLASSES=c;exports.DAY_TODAY_CLASSES=l;exports.ERROR_CLASSES=C;exports.HELPER_CLASSES=x;exports.LABEL_CLASSES=u;exports.MONTH_LABELS=n;exports.NAV_BTN_CLASSES=_;exports.PRESET_BTN_CLASSES=d;exports.ROOT_CLASSES=o;exports.SIZE_CLASSES=E;exports.TRIGGER_CLASSES=A;exports.getDefaultPresets=R;
|
|
@@ -15,7 +15,7 @@ const t = 7, b = 6, n = ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"], o = [
|
|
|
15
15
|
sm: "bear-py-1.5 bear-px-3 bear-text-sm",
|
|
16
16
|
md: "bear-py-2 bear-px-4 bear-text-base",
|
|
17
17
|
lg: "bear-py-2.5 bear-px-5 bear-text-lg"
|
|
18
|
-
}, S = "Bear-DateRangePicker bear-relative bear-inline-block", c = "bear-w-full bear-flex bear-items-center bear-justify-between bear-rounded-lg bear-border bear-border-gray-300 dark:bear-border-zinc-600 bear-bg-white dark:bear-bg-zinc-800 bear-text-gray-900 dark:bear-text-white bear-transition-colors focus:bear-ring-2 focus:bear-ring-pink-500 bear-outline-none", i = "bear-
|
|
18
|
+
}, S = "Bear-DateRangePicker bear-relative bear-inline-block", c = "bear-w-full bear-flex bear-items-center bear-justify-between bear-rounded-lg bear-border bear-border-gray-300 dark:bear-border-zinc-600 bear-bg-white dark:bear-bg-zinc-800 bear-text-gray-900 dark:bear-text-white bear-transition-colors focus:bear-ring-2 focus:bear-ring-pink-500 bear-outline-none", i = "bear-flex bear-items-center bear-justify-between bear-mb-2", g = "bear-p-1 bear-rounded hover:bear-bg-gray-100 dark:hover:bear-bg-zinc-700 bear-text-gray-500 dark:bear-text-zinc-400", l = "bear-w-8 bear-h-8 bear-text-sm bear-rounded-full bear-transition-colors bear-cursor-pointer", A = "bear-bg-pink-500 bear-text-white", E = "bear-bg-pink-100 dark:bear-bg-pink-900/30 bear-text-pink-800 dark:bear-text-pink-200", d = "hover:bear-bg-gray-100 dark:hover:bear-bg-zinc-700", x = "bear-text-gray-300 dark:bear-text-zinc-600 bear-cursor-not-allowed", D = "bear-ring-1 bear-ring-pink-400", u = "bear-w-full bear-text-left bear-px-3 bear-py-1.5 bear-text-sm bear-rounded bear-transition-colors hover:bear-bg-pink-50 dark:hover:bear-bg-pink-900/20 bear-text-gray-700 dark:bear-text-zinc-300", _ = "Bear-DateRangePicker__label bear-block bear-text-sm bear-font-medium bear-text-gray-700 dark:bear-text-zinc-300 bear-mb-1.5", L = "bear-mt-1 bear-text-xs bear-text-red-500", k = "bear-mt-1 bear-text-xs bear-text-gray-500 dark:bear-text-zinc-500", y = () => {
|
|
19
19
|
const e = /* @__PURE__ */ new Date();
|
|
20
20
|
return e.setHours(0, 0, 0, 0), [
|
|
21
21
|
{
|
|
@@ -50,25 +50,24 @@ const t = 7, b = 6, n = ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"], o = [
|
|
|
50
50
|
];
|
|
51
51
|
};
|
|
52
52
|
export {
|
|
53
|
-
|
|
53
|
+
i as CALENDAR_HEADER_CLASSES,
|
|
54
54
|
b as CALENDAR_ROWS,
|
|
55
55
|
t as DAYS_IN_WEEK,
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
56
|
+
l as DAY_BASE_CLASSES,
|
|
57
|
+
x as DAY_DISABLED_CLASSES,
|
|
58
|
+
d as DAY_HOVER_CLASSES,
|
|
59
59
|
E as DAY_IN_RANGE_CLASSES,
|
|
60
60
|
n as DAY_LABELS,
|
|
61
61
|
A as DAY_SELECTED_CLASSES,
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
k as
|
|
65
|
-
|
|
66
|
-
L as LABEL_CLASSES,
|
|
62
|
+
D as DAY_TODAY_CLASSES,
|
|
63
|
+
L as ERROR_CLASSES,
|
|
64
|
+
k as HELPER_CLASSES,
|
|
65
|
+
_ as LABEL_CLASSES,
|
|
67
66
|
o as MONTH_LABELS,
|
|
68
|
-
|
|
69
|
-
|
|
67
|
+
g as NAV_BTN_CLASSES,
|
|
68
|
+
u as PRESET_BTN_CLASSES,
|
|
70
69
|
S as ROOT_CLASSES,
|
|
71
70
|
s as SIZE_CLASSES,
|
|
72
71
|
c as TRIGGER_CLASSES,
|
|
73
|
-
|
|
72
|
+
y as getDefaultPresets
|
|
74
73
|
};
|