@forgedevstack/bear 1.2.0 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -0
- package/dist/components/Autocomplete/Autocomplete.cjs +1 -1
- package/dist/components/Autocomplete/Autocomplete.const.cjs +1 -0
- package/dist/components/Autocomplete/Autocomplete.const.d.ts +1 -0
- package/dist/components/Autocomplete/Autocomplete.const.js +4 -0
- package/dist/components/Autocomplete/Autocomplete.js +110 -72
- package/dist/components/BottomSheet/BottomSheet.cjs +1 -1
- package/dist/components/BottomSheet/BottomSheet.js +74 -53
- package/dist/components/BottomSheet/BottomSheet.types.d.ts +2 -0
- package/dist/components/Breadcrumbs/Breadcrumbs.cjs +1 -1
- package/dist/components/Breadcrumbs/Breadcrumbs.js +126 -46
- package/dist/components/Breadcrumbs/Breadcrumbs.types.d.ts +11 -4
- package/dist/components/Breadcrumbs/index.d.ts +1 -1
- package/dist/components/Cascader/Cascader.cjs +1 -1
- package/dist/components/Cascader/Cascader.const.cjs +1 -1
- package/dist/components/Cascader/Cascader.const.d.ts +1 -1
- package/dist/components/Cascader/Cascader.const.js +1 -1
- package/dist/components/Cascader/Cascader.js +109 -146
- package/dist/components/Cascader/components/CascaderPanel/CascaderPanel.cjs +1 -0
- package/dist/components/Cascader/components/CascaderPanel/CascaderPanel.d.ts +3 -0
- package/dist/components/Cascader/components/CascaderPanel/CascaderPanel.js +50 -0
- package/dist/components/Cascader/components/CascaderPanel/index.d.ts +1 -0
- package/dist/components/Chart/BarChart.cjs +1 -0
- package/dist/components/Chart/BarChart.d.ts +3 -0
- package/dist/components/Chart/BarChart.js +65 -0
- package/dist/components/Chart/Chart.cjs +1 -1
- package/dist/components/Chart/Chart.const.cjs +1 -1
- package/dist/components/Chart/Chart.const.d.ts +7 -0
- package/dist/components/Chart/Chart.const.js +12 -2
- package/dist/components/Chart/Chart.d.ts +1 -13
- package/dist/components/Chart/Chart.js +18 -204
- package/dist/components/Chart/Chart.types.d.ts +7 -1
- package/dist/components/Chart/LineChart.cjs +1 -0
- package/dist/components/Chart/LineChart.d.ts +3 -0
- package/dist/components/Chart/LineChart.js +73 -0
- package/dist/components/Chart/PieChart.cjs +1 -0
- package/dist/components/Chart/PieChart.d.ts +3 -0
- package/dist/components/Chart/PieChart.js +110 -0
- package/dist/components/Chart/index.d.ts +4 -1
- package/dist/components/ColorPicker/ColorPicker.cjs +1 -1
- package/dist/components/ColorPicker/ColorPicker.const.cjs +1 -1
- package/dist/components/ColorPicker/ColorPicker.const.d.ts +4 -2
- package/dist/components/ColorPicker/ColorPicker.const.js +8 -6
- package/dist/components/ColorPicker/ColorPicker.js +135 -73
- package/dist/components/ColorPicker/ColorPicker.utils.cjs +1 -0
- package/dist/components/ColorPicker/ColorPicker.utils.d.ts +17 -0
- package/dist/components/ColorPicker/ColorPicker.utils.js +43 -0
- package/dist/components/CountdownTimer/CountdownTimer.cjs +1 -1
- package/dist/components/CountdownTimer/CountdownTimer.const.cjs +1 -1
- package/dist/components/CountdownTimer/CountdownTimer.const.d.ts +2 -0
- package/dist/components/CountdownTimer/CountdownTimer.const.js +29 -17
- package/dist/components/CountdownTimer/CountdownTimer.js +91 -61
- package/dist/components/CountdownTimer/CountdownTimer.types.d.ts +11 -2
- package/dist/components/CreditInput/CreditInput.cjs +1 -1
- package/dist/components/CreditInput/CreditInput.js +80 -78
- package/dist/components/DateRangePicker/DateRangePicker.cjs +1 -1
- package/dist/components/DateRangePicker/DateRangePicker.js +89 -84
- package/dist/components/DiffSquares/DiffSquares.cjs +1 -0
- package/dist/components/DiffSquares/DiffSquares.const.cjs +1 -0
- package/dist/components/DiffSquares/DiffSquares.const.d.ts +3 -0
- package/dist/components/DiffSquares/DiffSquares.const.js +6 -0
- package/dist/components/DiffSquares/DiffSquares.d.ts +3 -0
- package/dist/components/DiffSquares/DiffSquares.js +70 -0
- package/dist/components/DiffSquares/DiffSquares.types.d.ts +23 -0
- package/dist/components/DiffSquares/DiffSquares.utils.cjs +1 -0
- package/dist/components/DiffSquares/DiffSquares.utils.d.ts +3 -0
- package/dist/components/DiffSquares/DiffSquares.utils.js +12 -0
- package/dist/components/DiffSquares/index.d.ts +2 -0
- package/dist/components/Drawer/Drawer.cjs +1 -1
- package/dist/components/Drawer/Drawer.js +41 -41
- package/dist/components/Dropdown/Dropdown.cjs +1 -1
- package/dist/components/Dropdown/Dropdown.const.cjs +1 -0
- package/dist/components/Dropdown/Dropdown.const.d.ts +7 -0
- package/dist/components/Dropdown/Dropdown.const.js +10 -0
- package/dist/components/Dropdown/Dropdown.d.ts +0 -1
- package/dist/components/Dropdown/Dropdown.js +102 -92
- package/dist/components/Dropdown/Dropdown.types.d.ts +2 -0
- package/dist/components/Gauge/Gauge.cjs +1 -1
- package/dist/components/Gauge/Gauge.js +61 -50
- package/dist/components/Gauge/Gauge.types.d.ts +2 -0
- package/dist/components/HoverCard/HoverCard.cjs +6 -6
- package/dist/components/HoverCard/HoverCard.js +72 -54
- package/dist/components/Icon/icons/status.js +1 -1
- package/dist/components/MentionsInput/MentionsInput.cjs +1 -1
- package/dist/components/MentionsInput/MentionsInput.js +106 -83
- package/dist/components/Menu/Menu.cjs +1 -1
- package/dist/components/Menu/Menu.js +91 -80
- package/dist/components/Modal/Modal.cjs +1 -1
- package/dist/components/Modal/Modal.const.cjs +1 -1
- package/dist/components/Modal/Modal.const.d.ts +1 -1
- package/dist/components/Modal/Modal.const.js +1 -1
- package/dist/components/Modal/Modal.js +50 -44
- package/dist/components/Modal/Modal.types.d.ts +6 -0
- package/dist/components/MultiSelect/MultiSelect.cjs +1 -1
- package/dist/components/MultiSelect/MultiSelect.js +123 -78
- package/dist/components/NavigableSelect/NavigableSelect.cjs +1 -1
- package/dist/components/NavigableSelect/NavigableSelect.const.cjs +1 -1
- package/dist/components/NavigableSelect/NavigableSelect.const.d.ts +1 -1
- package/dist/components/NavigableSelect/NavigableSelect.const.js +1 -1
- package/dist/components/NavigableSelect/NavigableSelect.js +167 -143
- package/dist/components/NotificationCenter/NotificationCenter.cjs +1 -1
- package/dist/components/NotificationCenter/NotificationCenter.const.cjs +1 -1
- package/dist/components/NotificationCenter/NotificationCenter.const.d.ts +1 -1
- package/dist/components/NotificationCenter/NotificationCenter.const.js +1 -1
- package/dist/components/NotificationCenter/NotificationCenter.js +87 -81
- package/dist/components/OTPInput/OTPInput.cjs +1 -1
- package/dist/components/OTPInput/OTPInput.const.cjs +1 -0
- package/dist/components/OTPInput/OTPInput.const.d.ts +6 -0
- package/dist/components/OTPInput/OTPInput.const.js +14 -0
- package/dist/components/OTPInput/OTPInput.js +99 -65
- package/dist/components/OTPInput/OTPInput.types.d.ts +7 -0
- package/dist/components/PhoneInput/PhoneInput.cjs +1 -1
- package/dist/components/PhoneInput/PhoneInput.const.cjs +1 -1
- package/dist/components/PhoneInput/PhoneInput.const.d.ts +1 -1
- package/dist/components/PhoneInput/PhoneInput.const.js +1 -1
- package/dist/components/PhoneInput/PhoneInput.js +88 -83
- package/dist/components/Popconfirm/Popconfirm.cjs +1 -1
- package/dist/components/Popconfirm/Popconfirm.const.cjs +1 -1
- package/dist/components/Popconfirm/Popconfirm.const.d.ts +1 -3
- package/dist/components/Popconfirm/Popconfirm.const.js +12 -18
- package/dist/components/Popconfirm/Popconfirm.js +71 -51
- package/dist/components/Popover/Popover.cjs +1 -1
- package/dist/components/Popover/Popover.js +36 -31
- package/dist/components/Portal/Portal.cjs +1 -1
- package/dist/components/Portal/Portal.d.ts +0 -3
- package/dist/components/Portal/Portal.js +4 -10
- package/dist/components/Select/Select.cjs +1 -1
- package/dist/components/Select/Select.js +71 -51
- package/dist/components/Stepper/Stepper.cjs +1 -1
- package/dist/components/Stepper/Stepper.const.cjs +1 -1
- package/dist/components/Stepper/Stepper.const.d.ts +3 -2
- package/dist/components/Stepper/Stepper.const.js +15 -14
- package/dist/components/Stepper/Stepper.d.ts +0 -7
- package/dist/components/Stepper/Stepper.js +164 -117
- package/dist/components/Stepper/Stepper.types.d.ts +3 -0
- package/dist/components/Tabs/TabList.cjs +1 -1
- package/dist/components/Tabs/TabList.js +72 -57
- package/dist/components/Tabs/Tabs.types.d.ts +4 -2
- package/dist/components/Tabs/index.d.ts +2 -2
- package/dist/components/TimePicker/components/TimePickerDialDropdown/TimePickerDialDropdown.cjs +1 -1
- package/dist/components/TimePicker/components/TimePickerDialDropdown/TimePickerDialDropdown.js +26 -26
- package/dist/components/TimePicker/helpers/ClockFaceSvg.cjs +1 -1
- package/dist/components/TimePicker/helpers/ClockFaceSvg.js +17 -17
- package/dist/components/Toast/Toast.cjs +1 -1
- package/dist/components/Toast/Toast.js +86 -82
- package/dist/components/Toast/Toast.types.d.ts +2 -0
- package/dist/components/Tooltip/Tooltip.cjs +1 -1
- package/dist/components/Tooltip/Tooltip.js +52 -44
- package/dist/components/TreeSelect/TreeSelect.cjs +1 -1
- package/dist/components/TreeSelect/TreeSelect.const.cjs +1 -1
- package/dist/components/TreeSelect/TreeSelect.const.d.ts +1 -1
- package/dist/components/TreeSelect/TreeSelect.const.js +3 -3
- package/dist/components/TreeSelect/TreeSelect.js +120 -88
- package/dist/components/Watermark/Watermark.cjs +1 -1
- package/dist/components/Watermark/Watermark.const.cjs +1 -1
- package/dist/components/Watermark/Watermark.const.d.ts +6 -3
- package/dist/components/Watermark/Watermark.const.js +13 -11
- package/dist/components/Watermark/Watermark.js +87 -61
- package/dist/components/Watermark/Watermark.types.d.ts +2 -0
- package/dist/components/index.cjs +1 -1
- package/dist/components/index.d.ts +5 -3
- package/dist/components/index.js +292 -286
- package/dist/hooks/index.cjs +1 -1
- package/dist/hooks/index.d.ts +1 -1
- package/dist/hooks/index.js +55 -54
- package/dist/hooks/useClickOutside.cjs +1 -1
- package/dist/hooks/useClickOutside.d.ts +4 -11
- package/dist/hooks/useClickOutside.js +26 -7
- package/dist/index.cjs +1 -1
- package/dist/index.js +386 -379
- package/dist/styles/_effects.css +17 -0
- package/dist/styles.css +1 -1
- package/dist/utils/maxVisible.utils.cjs +1 -0
- package/dist/utils/maxVisible.utils.d.ts +12 -0
- package/dist/utils/maxVisible.utils.js +15 -0
- package/package.json +1 -1
- package/dist/components/HoverCard/HoverCard.utils.cjs +0 -1
- package/dist/components/HoverCard/HoverCard.utils.js +0 -23
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useState as
|
|
3
|
-
import { createPortal as
|
|
1
|
+
import { jsxs as t, jsx as r } from "react/jsx-runtime";
|
|
2
|
+
import { useState as C, useRef as M, useMemo as _, useEffect as j, useCallback as Y } from "react";
|
|
3
|
+
import { createPortal as Z } from "react-dom";
|
|
4
4
|
import { cn as c } from "../../utils/cn.js";
|
|
5
|
-
import { NOTIFICATION_CENTER_DEFAULT_TRANSLATIONS as
|
|
6
|
-
import { formatRelativeTime as
|
|
7
|
-
const
|
|
5
|
+
import { NOTIFICATION_CENTER_DEFAULT_TRANSLATIONS as q, NOTIFICATION_CENTER_MAX_VISIBLE as G, NOTIFICATION_CENTER_Z_INDEX as J, NOTIFICATION_TYPE_COLORS as A } from "./NotificationCenter.const.js";
|
|
6
|
+
import { formatRelativeTime as K } from "./NotificationCenter.utils.js";
|
|
7
|
+
const Q = ({
|
|
8
8
|
notification: e,
|
|
9
|
-
onRead:
|
|
9
|
+
onRead: h,
|
|
10
10
|
onDismiss: p,
|
|
11
|
-
onClick:
|
|
11
|
+
onClick: l,
|
|
12
12
|
translations: k
|
|
13
|
-
}) => /* @__PURE__ */
|
|
13
|
+
}) => /* @__PURE__ */ t(
|
|
14
14
|
"div",
|
|
15
15
|
{
|
|
16
16
|
onClick: () => {
|
|
17
|
-
e.read ||
|
|
17
|
+
e.read || h == null || h(e.id), l == null || l(e);
|
|
18
18
|
},
|
|
19
19
|
className: c(
|
|
20
20
|
"Bear-NotificationCenter__item bear-flex bear-gap-3 bear-p-3 bear-border-b bear-border-gray-200 dark:bear-border-zinc-700 last:bear-border-b-0 bear-cursor-pointer bear-transition-colors hover:bear-bg-gray-100 dark:hover:bear-bg-zinc-700/50",
|
|
@@ -30,18 +30,18 @@ const J = ({
|
|
|
30
30
|
}
|
|
31
31
|
) : e.icon ? /* @__PURE__ */ r("div", { className: c(
|
|
32
32
|
"bear-w-10 bear-h-10 bear-rounded-full bear-flex bear-items-center bear-justify-center",
|
|
33
|
-
|
|
34
|
-
), children: e.icon }) : /* @__PURE__ */
|
|
33
|
+
A[e.type]
|
|
34
|
+
), children: e.icon }) : /* @__PURE__ */ t("div", { className: c(
|
|
35
35
|
"bear-w-10 bear-h-10 bear-rounded-full bear-flex bear-items-center bear-justify-center",
|
|
36
|
-
|
|
36
|
+
A[e.type]
|
|
37
37
|
), children: [
|
|
38
38
|
e.type === "success" && /* @__PURE__ */ r("svg", { className: "bear-w-5 bear-h-5", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ r("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M5 13l4 4L19 7" }) }),
|
|
39
39
|
e.type === "error" && /* @__PURE__ */ r("svg", { className: "bear-w-5 bear-h-5", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ r("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M6 18L18 6M6 6l12 12" }) }),
|
|
40
40
|
e.type === "warning" && /* @__PURE__ */ r("svg", { className: "bear-w-5 bear-h-5", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ r("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z" }) }),
|
|
41
41
|
e.type === "info" && /* @__PURE__ */ r("svg", { className: "bear-w-5 bear-h-5", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ r("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" }) })
|
|
42
42
|
] }) }),
|
|
43
|
-
/* @__PURE__ */
|
|
44
|
-
/* @__PURE__ */
|
|
43
|
+
/* @__PURE__ */ t("div", { className: "Bear-NotificationCenter__item-content bear-flex-1 bear-min-w-0", children: [
|
|
44
|
+
/* @__PURE__ */ t("div", { className: "bear-flex bear-items-start bear-justify-between bear-gap-2", children: [
|
|
45
45
|
/* @__PURE__ */ r("p", { className: c(
|
|
46
46
|
"Bear-NotificationCenter__item-title bear-text-sm bear-font-medium bear-truncate",
|
|
47
47
|
e.read ? "bear-text-gray-600 dark:bear-text-zinc-300" : "bear-text-gray-900 dark:bear-text-white"
|
|
@@ -49,13 +49,13 @@ const J = ({
|
|
|
49
49
|
!e.read && /* @__PURE__ */ r("span", { className: "Bear-NotificationCenter__item-badge bear-w-2 bear-h-2 bear-rounded-full bear-bg-pink-500 bear-shrink-0 bear-mt-1.5" })
|
|
50
50
|
] }),
|
|
51
51
|
e.description && /* @__PURE__ */ r("p", { className: "Bear-NotificationCenter__item-description bear-text-xs bear-text-gray-500 dark:bear-text-zinc-400 bear-mt-0.5 bear-line-clamp-2", children: e.description }),
|
|
52
|
-
/* @__PURE__ */ r("p", { className: "Bear-NotificationCenter__item-time bear-text-xs bear-text-gray-400 dark:bear-text-zinc-500 bear-mt-1", children:
|
|
53
|
-
e.actions && e.actions.length > 0 && /* @__PURE__ */ r("div", { className: "Bear-NotificationCenter__item-actions bear-flex bear-gap-2 bear-mt-2", children: e.actions.map((a,
|
|
52
|
+
/* @__PURE__ */ r("p", { className: "Bear-NotificationCenter__item-time bear-text-xs bear-text-gray-400 dark:bear-text-zinc-500 bear-mt-1", children: K(e.timestamp, k) }),
|
|
53
|
+
e.actions && e.actions.length > 0 && /* @__PURE__ */ r("div", { className: "Bear-NotificationCenter__item-actions bear-flex bear-gap-2 bear-mt-2", children: e.actions.map((a, z) => /* @__PURE__ */ r(
|
|
54
54
|
"button",
|
|
55
55
|
{
|
|
56
56
|
type: "button",
|
|
57
|
-
onClick: (
|
|
58
|
-
|
|
57
|
+
onClick: (u) => {
|
|
58
|
+
u.stopPropagation(), a.onClick();
|
|
59
59
|
},
|
|
60
60
|
className: c(
|
|
61
61
|
"bear-px-2 bear-py-1 bear-text-xs bear-rounded bear-transition-colors",
|
|
@@ -66,7 +66,7 @@ const J = ({
|
|
|
66
66
|
),
|
|
67
67
|
children: a.label
|
|
68
68
|
},
|
|
69
|
-
|
|
69
|
+
z
|
|
70
70
|
)) })
|
|
71
71
|
] }),
|
|
72
72
|
p && /* @__PURE__ */ r(
|
|
@@ -82,124 +82,130 @@ const J = ({
|
|
|
82
82
|
)
|
|
83
83
|
]
|
|
84
84
|
}
|
|
85
|
-
),
|
|
85
|
+
), ne = ({
|
|
86
86
|
notifications: e,
|
|
87
|
-
onNotificationClick:
|
|
87
|
+
onNotificationClick: h,
|
|
88
88
|
onMarkAsRead: p,
|
|
89
|
-
onMarkAllAsRead:
|
|
89
|
+
onMarkAllAsRead: l,
|
|
90
90
|
onDismiss: k,
|
|
91
|
-
onClearAll:
|
|
92
|
-
maxVisible: a =
|
|
93
|
-
groupByCategory:
|
|
94
|
-
position:
|
|
95
|
-
trigger:
|
|
96
|
-
open:
|
|
97
|
-
onOpenChange:
|
|
98
|
-
className:
|
|
99
|
-
testId:
|
|
100
|
-
translations:
|
|
101
|
-
icon:
|
|
91
|
+
onClearAll: v,
|
|
92
|
+
maxVisible: a = G,
|
|
93
|
+
groupByCategory: z = !1,
|
|
94
|
+
position: u = "top-right",
|
|
95
|
+
trigger: B,
|
|
96
|
+
open: W,
|
|
97
|
+
onOpenChange: R,
|
|
98
|
+
className: P,
|
|
99
|
+
testId: S,
|
|
100
|
+
translations: L,
|
|
101
|
+
icon: F
|
|
102
102
|
}) => {
|
|
103
|
-
const [
|
|
104
|
-
...
|
|
105
|
-
...
|
|
106
|
-
}), [
|
|
107
|
-
() => e.filter((
|
|
103
|
+
const [H, D] = C(!1), [I, X] = C({ top: 0, left: 0 }), [N, U] = C(!1), E = M(null), f = M(null), m = W ?? H, g = R ?? D, b = _(() => ({
|
|
104
|
+
...q,
|
|
105
|
+
...L
|
|
106
|
+
}), [L]), d = _(
|
|
107
|
+
() => e.filter((n) => !n.read).length,
|
|
108
108
|
[e]
|
|
109
|
-
),
|
|
110
|
-
|
|
111
|
-
if (m
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
109
|
+
), T = _(() => N ? e : e.slice(0, a), [e, a, N]);
|
|
110
|
+
j(() => {
|
|
111
|
+
if (!m || !f.current) return;
|
|
112
|
+
const n = 360, x = 400, i = 8, o = () => {
|
|
113
|
+
const s = f.current.getBoundingClientRect();
|
|
114
|
+
let y = u.includes("left") ? s.left : s.right - n;
|
|
115
|
+
y = Math.max(8, Math.min(y, window.innerWidth - n - 8));
|
|
116
|
+
let w = s.bottom + i;
|
|
117
|
+
w + x > window.innerHeight - 8 && (w = Math.max(8, s.top - x - i)), X({ top: w, left: y });
|
|
118
|
+
};
|
|
119
|
+
return o(), window.addEventListener("resize", o), window.addEventListener("scroll", o, !0), () => {
|
|
120
|
+
window.removeEventListener("resize", o), window.removeEventListener("scroll", o, !0);
|
|
121
|
+
};
|
|
122
|
+
}, [m, u]), j(() => {
|
|
123
|
+
const n = (x) => {
|
|
124
|
+
var o, s;
|
|
125
|
+
const i = x.target;
|
|
126
|
+
(o = E.current) != null && o.contains(i) || (s = i.closest) != null && s.call(i, "[data-bear-notification-center]") || g(!1);
|
|
121
127
|
};
|
|
122
|
-
return document.addEventListener("mousedown",
|
|
128
|
+
return document.addEventListener("mousedown", n), () => document.removeEventListener("mousedown", n);
|
|
123
129
|
}, [g]);
|
|
124
|
-
const
|
|
130
|
+
const O = Y(() => {
|
|
125
131
|
g(!m);
|
|
126
132
|
}, [m, g]);
|
|
127
|
-
return /* @__PURE__ */
|
|
133
|
+
return /* @__PURE__ */ t(
|
|
128
134
|
"div",
|
|
129
135
|
{
|
|
130
|
-
ref:
|
|
131
|
-
className: c("Bear-NotificationCenter bear-relative bear-inline-block",
|
|
132
|
-
"data-testid":
|
|
136
|
+
ref: E,
|
|
137
|
+
className: c("Bear-NotificationCenter bear-relative bear-inline-block", P),
|
|
138
|
+
"data-testid": S,
|
|
133
139
|
children: [
|
|
134
|
-
|
|
140
|
+
B ? /* @__PURE__ */ r("div", { onClick: O, children: B }) : /* @__PURE__ */ t(
|
|
135
141
|
"button",
|
|
136
142
|
{
|
|
137
143
|
ref: f,
|
|
138
144
|
type: "button",
|
|
139
|
-
onClick:
|
|
145
|
+
onClick: O,
|
|
140
146
|
className: "Bear-NotificationCenter__trigger bear-relative bear-p-2 bear-rounded-lg bear-text-gray-500 dark:bear-text-zinc-400 hover:bear-text-gray-900 dark:hover:bear-text-white hover:bear-bg-gray-100 dark:hover:bear-bg-zinc-800 bear-transition-colors",
|
|
141
147
|
children: [
|
|
142
|
-
|
|
143
|
-
|
|
148
|
+
F ?? /* @__PURE__ */ r("svg", { className: "bear-w-6 bear-h-6", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ r("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M15 17h5l-1.405-1.405A2.032 2.032 0 0118 14.158V11a6.002 6.002 0 00-4-5.659V5a2 2 0 10-4 0v.341C7.67 6.165 6 8.388 6 11v3.159c0 .538-.214 1.055-.595 1.436L4 17h5m6 0v1a3 3 0 11-6 0v-1m6 0H9" }) }),
|
|
149
|
+
d > 0 && /* @__PURE__ */ r("span", { className: "Bear-NotificationCenter__badge bear-absolute bear-top-0 bear-right-0 bear-w-5 bear-h-5 bear-flex bear-items-center bear-justify-center bear-text-xs bear-font-medium bear-text-white bear-bg-pink-500 bear-rounded-full", children: d > 99 ? "99+" : d })
|
|
144
150
|
]
|
|
145
151
|
}
|
|
146
152
|
),
|
|
147
|
-
m && typeof document < "u" &&
|
|
148
|
-
/* @__PURE__ */
|
|
153
|
+
m && typeof document < "u" && Z(
|
|
154
|
+
/* @__PURE__ */ t(
|
|
149
155
|
"div",
|
|
150
156
|
{
|
|
151
157
|
"data-bear-notification-center": !0,
|
|
152
158
|
className: "Bear-NotificationCenter__dropdown bear-fixed bear-w-[360px] bear-bg-white dark:bear-bg-zinc-800 bear-border bear-border-gray-200 dark:bear-border-zinc-700 bear-rounded-lg bear-shadow-xl bear-overflow-hidden",
|
|
153
|
-
style: { top:
|
|
159
|
+
style: { top: I.top, left: I.left, zIndex: J },
|
|
154
160
|
children: [
|
|
155
|
-
/* @__PURE__ */
|
|
156
|
-
/* @__PURE__ */
|
|
161
|
+
/* @__PURE__ */ t("div", { className: "Bear-NotificationCenter__header bear-flex bear-items-center bear-justify-between bear-px-4 bear-py-3 bear-border-b bear-border-gray-200 dark:bear-border-zinc-700", children: [
|
|
162
|
+
/* @__PURE__ */ t("h3", { className: "Bear-NotificationCenter__title bear-text-sm bear-font-semibold bear-text-gray-900 dark:bear-text-white", children: [
|
|
157
163
|
b.title,
|
|
158
|
-
|
|
164
|
+
d > 0 && /* @__PURE__ */ t("span", { className: "bear-ml-2 bear-text-xs bear-font-normal bear-text-gray-500 dark:bear-text-zinc-400", children: [
|
|
159
165
|
"(",
|
|
160
|
-
|
|
166
|
+
d,
|
|
161
167
|
" ",
|
|
162
168
|
b.new.toLowerCase(),
|
|
163
169
|
")"
|
|
164
170
|
] })
|
|
165
171
|
] }),
|
|
166
|
-
/* @__PURE__ */
|
|
167
|
-
|
|
172
|
+
/* @__PURE__ */ t("div", { className: "bear-flex bear-gap-2", children: [
|
|
173
|
+
l && d > 0 && /* @__PURE__ */ r(
|
|
168
174
|
"button",
|
|
169
175
|
{
|
|
170
176
|
type: "button",
|
|
171
|
-
onClick:
|
|
177
|
+
onClick: l,
|
|
172
178
|
className: "Bear-NotificationCenter__mark-all bear-text-xs bear-text-pink-400 hover:bear-text-pink-300 bear-transition-colors",
|
|
173
179
|
children: b.markAllRead
|
|
174
180
|
}
|
|
175
181
|
),
|
|
176
|
-
|
|
182
|
+
v && e.length > 0 && /* @__PURE__ */ r(
|
|
177
183
|
"button",
|
|
178
184
|
{
|
|
179
185
|
type: "button",
|
|
180
|
-
onClick:
|
|
186
|
+
onClick: v,
|
|
181
187
|
className: "Bear-NotificationCenter__clear-all bear-text-xs bear-text-gray-500 dark:bear-text-zinc-400 hover:bear-text-gray-700 dark:hover:bear-text-zinc-300 bear-transition-colors",
|
|
182
188
|
children: b.clearAll
|
|
183
189
|
}
|
|
184
190
|
)
|
|
185
191
|
] })
|
|
186
192
|
] }),
|
|
187
|
-
/* @__PURE__ */ r("div", { className: "Bear-NotificationCenter__list bear-max-h-[400px] bear-overflow-y-auto", children:
|
|
188
|
-
|
|
193
|
+
/* @__PURE__ */ r("div", { className: "Bear-NotificationCenter__list bear-max-h-[400px] bear-overflow-y-auto", children: T.length === 0 ? /* @__PURE__ */ r("div", { className: "Bear-NotificationCenter__empty bear-py-8 bear-text-center bear-text-sm bear-text-gray-500 dark:bear-text-zinc-500", children: b.noNotifications }) : T.map((n) => /* @__PURE__ */ r(
|
|
194
|
+
Q,
|
|
189
195
|
{
|
|
190
|
-
notification:
|
|
196
|
+
notification: n,
|
|
191
197
|
onRead: p,
|
|
192
198
|
onDismiss: k,
|
|
193
|
-
onClick:
|
|
199
|
+
onClick: h,
|
|
194
200
|
translations: b
|
|
195
201
|
},
|
|
196
|
-
|
|
202
|
+
n.id
|
|
197
203
|
)) }),
|
|
198
|
-
!
|
|
204
|
+
!N && e.length > a && /* @__PURE__ */ r("div", { className: "Bear-NotificationCenter__footer bear-border-t bear-border-gray-200 dark:bear-border-zinc-700", children: /* @__PURE__ */ t(
|
|
199
205
|
"button",
|
|
200
206
|
{
|
|
201
207
|
type: "button",
|
|
202
|
-
onClick: () =>
|
|
208
|
+
onClick: () => U(!0),
|
|
203
209
|
className: "bear-w-full bear-py-2 bear-text-sm bear-text-pink-500 dark:bear-text-pink-400 hover:bear-bg-gray-100 dark:hover:bear-bg-zinc-700/50 bear-transition-colors",
|
|
204
210
|
children: [
|
|
205
211
|
b.showMore,
|
|
@@ -219,5 +225,5 @@ const J = ({
|
|
|
219
225
|
);
|
|
220
226
|
};
|
|
221
227
|
export {
|
|
222
|
-
|
|
228
|
+
ne as NotificationCenter
|
|
223
229
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const x=require("react/jsx-runtime"),f=require("react"),T=require("./OTPInput.const.cjs"),y=require("../../utils/cn.cjs"),M=({length:t=6,value:i,onChange:o,onComplete:n,onFinish:m,disabled:j=!1,error:d=!1,autoFocus:g=!0,mask:D=!1,size:S="md",separator:A,className:E,variant:w="boxed",layout:v="horizontal",stackOnNarrow:O=!0,cancelAutoJump:_=!1})=>{const[b,k]=f.useState(Array(t).fill("")),s=f.useRef([]);f.useEffect(()=>{i!==void 0&&k(i.split("").concat(Array(t-i.length).fill("")).slice(0,t))},[i,t]),f.useEffect(()=>{g&&s.current[0]&&s.current[0].focus()},[g]);const P=f.useCallback(e=>{n==null||n(e),m==null||m(e)},[n,m]),p=f.useCallback(e=>{k(e);const r=e.join("");o==null||o(r),r.length===t&&e.every(a=>a!=="")&&P(r)},[o,P,t]),z=(e,r)=>{var l;const a=r.target.value.slice(-1);if(!/^\d*$/.test(a)&&a!=="")return;const c=[...b];c[e]=a,p(c),a&&e<t-1&&!_&&((l=s.current[e+1])==null||l.focus())},L=(e,r)=>{var a,c,l;if(r.key==="Backspace")if(b[e]===""&&e>0){(a=s.current[e-1])==null||a.focus();const u=[...b];u[e-1]="",p(u)}else{const u=[...b];u[e]="",p(u)}else r.key==="ArrowLeft"&&e>0?(c=s.current[e-1])==null||c.focus():r.key==="ArrowRight"&&e<t-1&&((l=s.current[e+1])==null||l.focus())},N=e=>{var c;e.preventDefault();const r=e.clipboardData.getData("text").replace(/\D/g,"").slice(0,t),a=r.split("").concat(Array(t-r.length).fill(""));p(a),(c=s.current[Math.min(r.length,t-1)])==null||c.focus()},q=T.OTP_VARIANT_FRAME[w],R=T.OTP_CELL_RECT_CLASSES[S],I=w==="circle"?R.circle:R.rect;return x.jsx("div",{className:y.cn(v==="vertical"?"bear-flex bear-flex-col bear-items-center bear-gap-2":w==="circle"?"bear-flex bear-flex-row bear-flex-wrap bear-justify-center bear-gap-2":O?"max-sm:bear-grid max-sm:bear-grid-cols-3 max-sm:bear-gap-2 max-sm:bear-justify-items-center sm:bear-flex sm:bear-flex-row sm:bear-flex-wrap sm:bear-justify-center sm:bear-gap-2":"bear-flex bear-flex-row bear-flex-wrap bear-justify-center bear-gap-2",E),children:b.map((e,r)=>x.jsxs("div",{className:y.cn("bear-flex bear-items-center",v==="vertical"?"bear-flex-col":"bear-flex-row"),children:[x.jsx("input",{ref:a=>{s.current[r]=a},type:D?"password":"text",inputMode:"numeric",maxLength:1,value:e,onChange:a=>z(r,a),onKeyDown:a=>L(r,a),onPaste:N,disabled:j,className:y.cn("bear-text-center bear-font-semibold bear-outline-none bear-transition-all",I,q,"bear-bg-[var(--bear-bg-primary,#18181b)] bear-text-[var(--bear-text-primary,#fafafa)]",d?"bear-border-red-500":"bear-border-zinc-600 focus:bear-border-pink-500 focus:bear-ring-2 focus:bear-ring-pink-500/30",j&&"bear-opacity-50 bear-cursor-not-allowed")}),A&&(r+1)%A===0&&r<t-1&&x.jsx("span",{className:y.cn("bear-text-zinc-500 bear-text-xl",v==="vertical"?"bear-my-1":"bear-mx-2"),children:"—"})]},r))})};exports.OTPInput=M;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e={sm:{rect:"bear-w-8 bear-h-10 bear-text-lg",circle:"bear-w-10 bear-h-10 bear-text-lg"},md:{rect:"bear-w-10 bear-h-12 bear-text-xl",circle:"bear-w-12 bear-h-12 bear-text-xl"},lg:{rect:"bear-w-12 bear-h-14 bear-text-2xl",circle:"bear-w-14 bear-h-14 bear-text-2xl"}},r={boxed:"bear-border bear-rounded-lg",outline:"bear-border-2 bear-rounded-lg",underline:"bear-border-0 bear-border-b-2 bear-rounded-none",circle:"bear-border bear-rounded-full"};exports.OTP_CELL_RECT_CLASSES=e;exports.OTP_VARIANT_FRAME=r;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const e = {
|
|
2
|
+
sm: { rect: "bear-w-8 bear-h-10 bear-text-lg", circle: "bear-w-10 bear-h-10 bear-text-lg" },
|
|
3
|
+
md: { rect: "bear-w-10 bear-h-12 bear-text-xl", circle: "bear-w-12 bear-h-12 bear-text-xl" },
|
|
4
|
+
lg: { rect: "bear-w-12 bear-h-14 bear-text-2xl", circle: "bear-w-14 bear-h-14 bear-text-2xl" }
|
|
5
|
+
}, r = {
|
|
6
|
+
boxed: "bear-border bear-rounded-lg",
|
|
7
|
+
outline: "bear-border-2 bear-rounded-lg",
|
|
8
|
+
underline: "bear-border-0 bear-border-b-2 bear-rounded-none",
|
|
9
|
+
circle: "bear-border bear-rounded-full"
|
|
10
|
+
};
|
|
11
|
+
export {
|
|
12
|
+
e as OTP_CELL_RECT_CLASSES,
|
|
13
|
+
r as OTP_VARIANT_FRAME
|
|
14
|
+
};
|
|
@@ -1,83 +1,117 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useState as
|
|
3
|
-
import {
|
|
4
|
-
|
|
1
|
+
import { jsx as w, jsxs as K } from "react/jsx-runtime";
|
|
2
|
+
import { useState as V, useRef as B, useEffect as R, useCallback as d } from "react";
|
|
3
|
+
import { OTP_CELL_RECT_CLASSES as $, OTP_VARIANT_FRAME as q } from "./OTPInput.const.js";
|
|
4
|
+
import { cn as n } from "../../utils/cn.js";
|
|
5
|
+
const U = ({
|
|
5
6
|
length: t = 6,
|
|
6
7
|
value: o,
|
|
7
8
|
onChange: i,
|
|
8
|
-
onComplete:
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
onComplete: u,
|
|
10
|
+
onFinish: m,
|
|
11
|
+
disabled: v = !1,
|
|
12
|
+
error: z = !1,
|
|
13
|
+
autoFocus: A = !0,
|
|
14
|
+
mask: E = !1,
|
|
15
|
+
size: L = "md",
|
|
16
|
+
separator: g,
|
|
17
|
+
className: N,
|
|
18
|
+
variant: x = "boxed",
|
|
19
|
+
layout: y = "horizontal",
|
|
20
|
+
stackOnNarrow: P = !0,
|
|
21
|
+
cancelAutoJump: S = !1
|
|
16
22
|
}) => {
|
|
17
|
-
const [
|
|
18
|
-
|
|
19
|
-
o !== void 0 &&
|
|
20
|
-
}, [o, t]),
|
|
21
|
-
|
|
22
|
-
}, [
|
|
23
|
-
const
|
|
24
|
-
|
|
23
|
+
const [f, j] = V(Array(t).fill("")), s = B([]);
|
|
24
|
+
R(() => {
|
|
25
|
+
o !== void 0 && j(o.split("").concat(Array(t - o.length).fill("")).slice(0, t));
|
|
26
|
+
}, [o, t]), R(() => {
|
|
27
|
+
A && s.current[0] && s.current[0].focus();
|
|
28
|
+
}, [A]);
|
|
29
|
+
const k = d((e) => {
|
|
30
|
+
u == null || u(e), m == null || m(e);
|
|
31
|
+
}, [u, m]), p = d((e) => {
|
|
32
|
+
j(e);
|
|
25
33
|
const r = e.join("");
|
|
26
|
-
i == null || i(r), r.length === t && e.every((a) => a !== "") && (
|
|
27
|
-
}, [i,
|
|
28
|
-
var
|
|
34
|
+
i == null || i(r), r.length === t && e.every((a) => a !== "") && k(r);
|
|
35
|
+
}, [i, k, t]), T = (e, r) => {
|
|
36
|
+
var b;
|
|
29
37
|
const a = r.target.value.slice(-1);
|
|
30
38
|
if (!/^\d*$/.test(a) && a !== "") return;
|
|
31
|
-
const c = [...
|
|
32
|
-
c[e] = a,
|
|
33
|
-
},
|
|
34
|
-
var a, c,
|
|
39
|
+
const c = [...f];
|
|
40
|
+
c[e] = a, p(c), a && e < t - 1 && !S && ((b = s.current[e + 1]) == null || b.focus());
|
|
41
|
+
}, _ = (e, r) => {
|
|
42
|
+
var a, c, b;
|
|
35
43
|
if (r.key === "Backspace")
|
|
36
|
-
if (
|
|
44
|
+
if (f[e] === "" && e > 0) {
|
|
37
45
|
(a = s.current[e - 1]) == null || a.focus();
|
|
38
|
-
const
|
|
39
|
-
|
|
46
|
+
const l = [...f];
|
|
47
|
+
l[e - 1] = "", p(l);
|
|
40
48
|
} else {
|
|
41
|
-
const
|
|
42
|
-
|
|
49
|
+
const l = [...f];
|
|
50
|
+
l[e] = "", p(l);
|
|
43
51
|
}
|
|
44
|
-
else r.key === "ArrowLeft" && e > 0 ? (c = s.current[e - 1]) == null || c.focus() : r.key === "ArrowRight" && e < t - 1 && ((
|
|
45
|
-
},
|
|
52
|
+
else r.key === "ArrowLeft" && e > 0 ? (c = s.current[e - 1]) == null || c.focus() : r.key === "ArrowRight" && e < t - 1 && ((b = s.current[e + 1]) == null || b.focus());
|
|
53
|
+
}, M = (e) => {
|
|
46
54
|
var c;
|
|
47
55
|
e.preventDefault();
|
|
48
56
|
const r = e.clipboardData.getData("text").replace(/\D/g, "").slice(0, t), a = r.split("").concat(Array(t - r.length).fill(""));
|
|
49
|
-
|
|
50
|
-
},
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
57
|
+
p(a), (c = s.current[Math.min(r.length, t - 1)]) == null || c.focus();
|
|
58
|
+
}, O = q[x], D = $[L], I = x === "circle" ? D.circle : D.rect;
|
|
59
|
+
return /* @__PURE__ */ w(
|
|
60
|
+
"div",
|
|
61
|
+
{
|
|
62
|
+
className: n(
|
|
63
|
+
y === "vertical" ? "bear-flex bear-flex-col bear-items-center bear-gap-2" : x === "circle" ? "bear-flex bear-flex-row bear-flex-wrap bear-justify-center bear-gap-2" : P ? "max-sm:bear-grid max-sm:bear-grid-cols-3 max-sm:bear-gap-2 max-sm:bear-justify-items-center sm:bear-flex sm:bear-flex-row sm:bear-flex-wrap sm:bear-justify-center sm:bear-gap-2" : "bear-flex bear-flex-row bear-flex-wrap bear-justify-center bear-gap-2",
|
|
64
|
+
N
|
|
65
|
+
),
|
|
66
|
+
children: f.map((e, r) => /* @__PURE__ */ K(
|
|
67
|
+
"div",
|
|
68
|
+
{
|
|
69
|
+
className: n(
|
|
70
|
+
"bear-flex bear-items-center",
|
|
71
|
+
y === "vertical" ? "bear-flex-col" : "bear-flex-row"
|
|
72
|
+
),
|
|
73
|
+
children: [
|
|
74
|
+
/* @__PURE__ */ w(
|
|
75
|
+
"input",
|
|
76
|
+
{
|
|
77
|
+
ref: (a) => {
|
|
78
|
+
s.current[r] = a;
|
|
79
|
+
},
|
|
80
|
+
type: E ? "password" : "text",
|
|
81
|
+
inputMode: "numeric",
|
|
82
|
+
maxLength: 1,
|
|
83
|
+
value: e,
|
|
84
|
+
onChange: (a) => T(r, a),
|
|
85
|
+
onKeyDown: (a) => _(r, a),
|
|
86
|
+
onPaste: M,
|
|
87
|
+
disabled: v,
|
|
88
|
+
className: n(
|
|
89
|
+
"bear-text-center bear-font-semibold bear-outline-none bear-transition-all",
|
|
90
|
+
I,
|
|
91
|
+
O,
|
|
92
|
+
"bear-bg-[var(--bear-bg-primary,#18181b)] bear-text-[var(--bear-text-primary,#fafafa)]",
|
|
93
|
+
z ? "bear-border-red-500" : "bear-border-zinc-600 focus:bear-border-pink-500 focus:bear-ring-2 focus:bear-ring-pink-500/30",
|
|
94
|
+
v && "bear-opacity-50 bear-cursor-not-allowed"
|
|
95
|
+
)
|
|
96
|
+
}
|
|
97
|
+
),
|
|
98
|
+
g && (r + 1) % g === 0 && r < t - 1 && /* @__PURE__ */ w(
|
|
99
|
+
"span",
|
|
100
|
+
{
|
|
101
|
+
className: n(
|
|
102
|
+
"bear-text-zinc-500 bear-text-xl",
|
|
103
|
+
y === "vertical" ? "bear-my-1" : "bear-mx-2"
|
|
104
|
+
),
|
|
105
|
+
children: "—"
|
|
106
|
+
}
|
|
107
|
+
)
|
|
108
|
+
]
|
|
61
109
|
},
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
onChange: (a) => x(r, a),
|
|
67
|
-
onKeyDown: (a) => z(r, a),
|
|
68
|
-
onPaste: N,
|
|
69
|
-
disabled: m,
|
|
70
|
-
className: k(
|
|
71
|
-
"bear-text-center bear-font-semibold bear-rounded-lg bear-border bear-bg-zinc-800 bear-text-white bear-outline-none bear-transition-all",
|
|
72
|
-
P[h],
|
|
73
|
-
D ? "bear-border-red-500" : "bear-border-zinc-600 focus:bear-border-pink-500 focus:bear-ring-2 focus:bear-ring-pink-500/30",
|
|
74
|
-
m && "bear-opacity-50 bear-cursor-not-allowed"
|
|
75
|
-
)
|
|
76
|
-
}
|
|
77
|
-
),
|
|
78
|
-
y && (r + 1) % y === 0 && r < t - 1 && /* @__PURE__ */ p("span", { className: "bear-mx-2 bear-text-zinc-500 bear-text-xl", children: "-" })
|
|
79
|
-
] }, r)) });
|
|
110
|
+
r
|
|
111
|
+
))
|
|
112
|
+
}
|
|
113
|
+
);
|
|
80
114
|
};
|
|
81
115
|
export {
|
|
82
|
-
|
|
116
|
+
U as OTPInput
|
|
83
117
|
};
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
export type OTPInputVariant = 'boxed' | 'outline' | 'underline' | 'circle';
|
|
2
|
+
export type OTPInputLayout = 'horizontal' | 'vertical';
|
|
1
3
|
export interface OTPInputProps {
|
|
2
4
|
length?: number;
|
|
3
5
|
value?: string;
|
|
4
6
|
onChange?: (value: string) => void;
|
|
5
7
|
onComplete?: (value: string) => void;
|
|
8
|
+
onFinish?: (value: string) => void;
|
|
6
9
|
disabled?: boolean;
|
|
7
10
|
error?: boolean;
|
|
8
11
|
autoFocus?: boolean;
|
|
@@ -10,4 +13,8 @@ export interface OTPInputProps {
|
|
|
10
13
|
size?: 'sm' | 'md' | 'lg';
|
|
11
14
|
separator?: number;
|
|
12
15
|
className?: string;
|
|
16
|
+
variant?: OTPInputVariant;
|
|
17
|
+
layout?: OTPInputLayout;
|
|
18
|
+
stackOnNarrow?: boolean;
|
|
19
|
+
cancelAutoJump?: boolean;
|
|
13
20
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),o=require("react"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),o=require("react"),G=require("react-dom"),p=require("../../utils/cn.cjs"),l=require("./PhoneInput.const.cjs"),i=require("./PhoneInput.utils.cjs"),J=({value:a,onChange:c,defaultCountry:E=l.DEFAULT_COUNTRY_CODE,placeholder:V,label:j,helperText:z,error:m,disabled:x=!1,required:q=!1,size:y="md",variant:H="default",onlyCountries:u,excludeCountries:f,preferredCountries:B=[],searchable:_=!0,showFlags:R=!0,showDialCode:W=!0,className:Z,testId:Q,translations:O,icon:F})=>{const[d,P]=o.useState(!1),[N,w]=o.useState(""),[g,L]=o.useState(""),[T,X]=o.useState({top:0,left:0}),D=o.useRef(null),I=o.useRef(null),U=o.useRef(null),k=o.useRef(null),S=o.useMemo(()=>({...l.PHONE_INPUT_DEFAULT_TRANSLATIONS,...O}),[O]),h=o.useMemo(()=>{let e=[...l.COUNTRIES];if(u!=null&&u.length){const s=new Set(u.map(t=>t.toUpperCase()));e=e.filter(t=>s.has(t.code))}if(f!=null&&f.length){const s=new Set(f.map(t=>t.toUpperCase()));e=e.filter(t=>!s.has(t.code))}return i.sortCountriesWithPreferred(e,B)},[u,f,B]),n=o.useMemo(()=>{const e=(a==null?void 0:a.countryCode)||E;return i.getCountryByCode(h,e)||h[0]},[a==null?void 0:a.countryCode,E,h]),A=o.useMemo(()=>i.filterCountries(h,N),[h,N]);o.useEffect(()=>{if((a==null?void 0:a.number)!==void 0){const e=i.formatPhoneNumber(a.number,n==null?void 0:n.format);L(e)}},[a==null?void 0:a.number,n==null?void 0:n.format]),o.useEffect(()=>{if(!d||!I.current)return;const e=256,s=()=>{const t=I.current.getBoundingClientRect();let b=t.left;b=Math.max(8,Math.min(b,window.innerWidth-e-8)),X({top:t.bottom+4,left:b})};return s(),window.addEventListener("resize",s),window.addEventListener("scroll",s,!0),()=>{window.removeEventListener("resize",s),window.removeEventListener("scroll",s,!0)}},[d]),o.useEffect(()=>{d&&_&&k.current&&k.current.focus()},[d,_]),o.useEffect(()=>{const e=s=>{var b,M;const t=s.target;(b=D.current)!=null&&b.contains(t)||(M=t.closest)!=null&&M.call(t,"[data-bear-phone-dropdown]")||(P(!1),w(""))};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]);const Y=o.useCallback(e=>{var t;const s=i.createPhoneValue(e,(a==null?void 0:a.number)||g);c==null||c(s),P(!1),w(""),(t=U.current)==null||t.focus()},[a==null?void 0:a.number,g,c]),v=o.useCallback(e=>{const s=i.parsePhoneDigits(e.target.value),t=i.formatPhoneNumber(s,n==null?void 0:n.format);if(L(t),n){const b=i.createPhoneValue(n,s);c==null||c(b)}},[n,c]);return r.jsxs("div",{ref:D,className:p.cn("Bear-PhoneInput bear-relative",Z),"data-testid":Q,children:[j&&r.jsxs("label",{className:"Bear-PhoneInput__label bear-block bear-text-sm bear-font-medium bear-text-zinc-700 dark:bear-text-zinc-300 bear-mb-1.5",children:[j,q&&r.jsx("span",{className:"bear-text-red-500 bear-ml-0.5",children:"*"})]}),r.jsxs("div",{className:p.cn("Bear-PhoneInput__wrapper bear-flex bear-items-center bear-rounded-lg bear-border bear-transition-colors",l.PHONE_INPUT_VARIANT_CLASSES[H],m?"bear-border-red-500":"focus-within:bear-border-pink-500",x&&"bear-opacity-50 bear-cursor-not-allowed"),children:[r.jsxs("button",{ref:I,type:"button",onClick:()=>!x&&P(!d),disabled:x,className:p.cn("Bear-PhoneInput__country-trigger bear-flex bear-items-center bear-gap-1 bear-border-r bear-border-zinc-300 dark:bear-border-zinc-600 bear-shrink-0 bear-text-gray-900 dark:bear-text-white",l.PHONE_INPUT_SIZE_CLASSES[y]),children:[R&&n&&r.jsx("span",{className:"Bear-PhoneInput__flag bear-text-lg",children:n.flag}),W&&n&&r.jsx("span",{className:"Bear-PhoneInput__dial-code bear-text-gray-600 dark:bear-text-zinc-400",children:n.dialCode}),F??r.jsx("svg",{className:p.cn("Bear-PhoneInput__chevron bear-w-4 bear-h-4 bear-text-gray-500 dark:bear-text-zinc-400 bear-transition-transform",d&&"bear-rotate-180"),fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),r.jsx("input",{ref:U,type:"tel",value:g,onChange:v,placeholder:V||S.placeholder,disabled:x,className:p.cn("Bear-PhoneInput__input bear-flex-1 bear-bg-transparent bear-border-0 bear-outline-none bear-text-gray-900 dark:bear-text-white placeholder:bear-text-gray-400 dark:placeholder:bear-text-zinc-500",l.PHONE_INPUT_SIZE_CLASSES[y])})]}),m&&r.jsx("p",{className:"Bear-PhoneInput__error bear-mt-1 bear-text-xs bear-text-red-400",children:m}),z&&!m&&r.jsx("p",{className:"Bear-PhoneInput__helper bear-mt-1 bear-text-xs bear-text-zinc-500 dark:bear-text-zinc-400",children:z}),d&&typeof document<"u"&&G.createPortal(r.jsxs("div",{"data-bear-phone-dropdown":!0,className:"Bear-PhoneInput__dropdown bear-fixed bear-w-64 bear-bg-white dark:bear-bg-zinc-800 bear-border bear-border-zinc-200 dark:bear-border-zinc-700 bear-rounded-lg bear-shadow-xl bear-overflow-hidden",style:{top:T.top,left:T.left,zIndex:l.PHONE_INPUT_DROPDOWN_Z_INDEX},children:[_&&r.jsx("div",{className:"Bear-PhoneInput__search bear-p-2 bear-border-b bear-border-zinc-200 dark:bear-border-zinc-700",children:r.jsx("input",{ref:k,type:"text",value:N,onChange:e=>w(e.target.value),placeholder:S.searchCountry,className:"bear-w-full bear-px-3 bear-py-2 bear-bg-gray-50 dark:bear-bg-zinc-700 bear-border bear-border-zinc-200 dark:bear-border-zinc-600 bear-rounded bear-text-sm bear-text-gray-900 dark:bear-text-white placeholder:bear-text-gray-400 dark:placeholder:bear-text-zinc-500 bear-outline-none focus:bear-border-pink-500"})}),r.jsx("div",{className:"Bear-PhoneInput__country-list bear-max-h-60 bear-overflow-y-auto",children:A.length===0?r.jsx("div",{className:"bear-px-3 bear-py-4 bear-text-center bear-text-sm bear-text-gray-500 dark:bear-text-zinc-500",children:S.noResults}):A.map(e=>r.jsxs("button",{type:"button",onClick:()=>Y(e),className:p.cn("Bear-PhoneInput__country-option bear-w-full bear-flex bear-items-center bear-gap-3 bear-px-3 bear-py-2 bear-text-left bear-text-sm bear-transition-colors",(n==null?void 0:n.code)===e.code?"bear-bg-pink-500/20 bear-text-pink-600 dark:bear-text-pink-400":"bear-text-gray-700 dark:bear-text-zinc-300 hover:bear-bg-gray-100 dark:hover:bear-bg-zinc-700"),children:[R&&r.jsx("span",{className:"Bear-PhoneInput__country-flag bear-text-lg",children:e.flag}),r.jsx("span",{className:"Bear-PhoneInput__country-name bear-flex-1",children:e.name}),r.jsx("span",{className:"Bear-PhoneInput__country-dial bear-text-gray-500 dark:bear-text-zinc-500",children:e.dialCode})]},e.code))})]}),document.body)]})};exports.PhoneInput=J;
|