@forgedevstack/bear 1.0.5 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Calendar/Calendar.cjs +1 -1
- package/dist/components/Calendar/Calendar.const.cjs +1 -1
- package/dist/components/Calendar/Calendar.const.d.ts +1 -0
- package/dist/components/Calendar/Calendar.const.js +6 -5
- package/dist/components/Calendar/Calendar.helpers.cjs +1 -1
- package/dist/components/Calendar/Calendar.helpers.js +4 -4
- package/dist/components/Calendar/Calendar.js +128 -128
- package/dist/components/Cascader/Cascader.cjs +1 -0
- package/dist/components/Cascader/Cascader.const.cjs +1 -0
- package/dist/components/Cascader/Cascader.const.d.ts +33 -0
- package/dist/components/Cascader/Cascader.const.js +21 -0
- package/dist/components/Cascader/Cascader.d.ts +17 -0
- package/dist/components/Cascader/Cascader.js +227 -0
- package/dist/components/Cascader/Cascader.types.d.ts +94 -0
- package/dist/components/Cascader/index.d.ts +2 -0
- package/dist/components/CommandPalette/CommandPalette.cjs +1 -0
- package/dist/components/CommandPalette/CommandPalette.const.cjs +1 -0
- package/dist/components/CommandPalette/CommandPalette.const.d.ts +25 -0
- package/dist/components/CommandPalette/CommandPalette.const.js +13 -0
- package/dist/components/CommandPalette/CommandPalette.d.ts +18 -0
- package/dist/components/CommandPalette/CommandPalette.js +190 -0
- package/dist/components/CommandPalette/CommandPalette.types.d.ts +90 -0
- package/dist/components/CommandPalette/CommandPalette.utils.cjs +1 -0
- package/dist/components/CommandPalette/CommandPalette.utils.d.ts +17 -0
- package/dist/components/CommandPalette/CommandPalette.utils.js +63 -0
- package/dist/components/CommandPalette/index.d.ts +2 -0
- package/dist/components/CreditInput/CreditInput.cjs +1 -0
- package/dist/components/CreditInput/CreditInput.const.cjs +1 -0
- package/dist/components/CreditInput/CreditInput.const.d.ts +37 -0
- package/dist/components/CreditInput/CreditInput.const.js +66 -0
- package/dist/components/CreditInput/CreditInput.d.ts +15 -0
- package/dist/components/CreditInput/CreditInput.js +214 -0
- package/dist/components/CreditInput/CreditInput.types.d.ts +93 -0
- package/dist/components/CreditInput/CreditInput.utils.cjs +1 -0
- package/dist/components/CreditInput/CreditInput.utils.d.ts +48 -0
- package/dist/components/CreditInput/CreditInput.utils.js +79 -0
- package/dist/components/CreditInput/index.d.ts +2 -0
- package/dist/components/DatePicker/DatePicker.cjs +1 -1
- package/dist/components/DatePicker/DatePicker.js +108 -84
- package/dist/components/DatePicker/DatePicker.types.d.ts +2 -1
- package/dist/components/Drawer/Drawer.cjs +1 -1
- package/dist/components/Drawer/Drawer.js +75 -44
- package/dist/components/Form/Form.cjs +1 -0
- package/dist/components/Form/Form.const.cjs +1 -0
- package/dist/components/Form/Form.const.d.ts +33 -0
- package/dist/components/Form/Form.const.js +27 -0
- package/dist/components/Form/Form.context.cjs +1 -0
- package/dist/components/Form/Form.context.d.ts +13 -0
- package/dist/components/Form/Form.context.js +12 -0
- package/dist/components/Form/Form.d.ts +18 -0
- package/dist/components/Form/Form.js +230 -0
- package/dist/components/Form/Form.types.d.ts +166 -0
- package/dist/components/Form/Form.utils.cjs +1 -0
- package/dist/components/Form/Form.utils.d.ts +17 -0
- package/dist/components/Form/Form.utils.js +31 -0
- package/dist/components/Form/index.d.ts +3 -0
- package/dist/components/NotificationCenter/NotificationCenter.cjs +1 -0
- package/dist/components/NotificationCenter/NotificationCenter.const.cjs +1 -0
- package/dist/components/NotificationCenter/NotificationCenter.const.d.ts +25 -0
- package/dist/components/NotificationCenter/NotificationCenter.const.js +28 -0
- package/dist/components/NotificationCenter/NotificationCenter.d.ts +15 -0
- package/dist/components/NotificationCenter/NotificationCenter.js +223 -0
- package/dist/components/NotificationCenter/NotificationCenter.types.d.ts +117 -0
- package/dist/components/NotificationCenter/NotificationCenter.utils.cjs +1 -0
- package/dist/components/NotificationCenter/NotificationCenter.utils.d.ts +11 -0
- package/dist/components/NotificationCenter/NotificationCenter.utils.js +19 -0
- package/dist/components/NotificationCenter/index.d.ts +2 -0
- package/dist/components/PhoneInput/PhoneInput.cjs +1 -0
- package/dist/components/PhoneInput/PhoneInput.const.cjs +1 -0
- package/dist/components/PhoneInput/PhoneInput.const.d.ts +33 -0
- package/dist/components/PhoneInput/PhoneInput.const.js +82 -0
- package/dist/components/PhoneInput/PhoneInput.d.ts +16 -0
- package/dist/components/PhoneInput/PhoneInput.js +194 -0
- package/dist/components/PhoneInput/PhoneInput.types.d.ts +108 -0
- package/dist/components/PhoneInput/PhoneInput.utils.cjs +1 -0
- package/dist/components/PhoneInput/PhoneInput.utils.d.ts +25 -0
- package/dist/components/PhoneInput/PhoneInput.utils.js +39 -0
- package/dist/components/PhoneInput/index.d.ts +2 -0
- package/dist/components/SignPad/SignPad.cjs +1 -1
- package/dist/components/SignPad/SignPad.js +56 -56
- package/dist/components/TimePicker/TimePicker.cjs +1 -1
- package/dist/components/TimePicker/TimePicker.constants.cjs +1 -1
- package/dist/components/TimePicker/TimePicker.constants.d.ts +22 -1
- package/dist/components/TimePicker/TimePicker.constants.js +36 -19
- package/dist/components/TimePicker/TimePicker.js +97 -131
- package/dist/components/TimePicker/TimePicker.types.d.ts +47 -6
- package/dist/components/TimePicker/components/TimePickerColumnsDropdown/TimePickerColumnsDropdown.cjs +1 -0
- package/dist/components/TimePicker/components/TimePickerColumnsDropdown/TimePickerColumnsDropdown.d.ts +3 -0
- package/dist/components/TimePicker/components/TimePickerColumnsDropdown/TimePickerColumnsDropdown.js +81 -0
- package/dist/components/TimePicker/components/TimePickerColumnsDropdown/index.d.ts +1 -0
- package/dist/components/TimePicker/components/TimePickerDialDropdown/TimePickerDialDropdown.cjs +1 -0
- package/dist/components/TimePicker/components/TimePickerDialDropdown/TimePickerDialDropdown.d.ts +3 -0
- package/dist/components/TimePicker/components/TimePickerDialDropdown/TimePickerDialDropdown.js +84 -0
- package/dist/components/TimePicker/components/TimePickerDialDropdown/index.d.ts +1 -0
- package/dist/components/TimePicker/helpers/ClockFaceSvg.cjs +1 -0
- package/dist/components/TimePicker/helpers/ClockFaceSvg.d.ts +18 -0
- package/dist/components/TimePicker/helpers/ClockFaceSvg.js +67 -0
- package/dist/components/TimePicker/helpers/index.d.ts +2 -0
- package/dist/components/TimePicker/index.d.ts +1 -1
- package/dist/components/index.cjs +1 -1
- package/dist/components/index.d.ts +12 -2
- package/dist/components/index.js +139 -126
- package/dist/index.cjs +1 -1
- package/dist/index.js +247 -234
- package/dist/styles.css +1 -1
- package/package.json +1 -1
- package/dist/components/DateTimePicker/DateTimePicker.cjs +0 -1
- package/dist/components/DateTimePicker/DateTimePicker.d.ts +0 -3
- package/dist/components/DateTimePicker/DateTimePicker.js +0 -178
- package/dist/components/DateTimePicker/DateTimePicker.types.d.ts +0 -26
- package/dist/components/DateTimePicker/DateTimePicker.utils.cjs +0 -1
- package/dist/components/DateTimePicker/DateTimePicker.utils.d.ts +0 -2
- package/dist/components/DateTimePicker/DateTimePicker.utils.js +0 -16
- package/dist/components/DateTimePicker/index.d.ts +0 -2
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { jsxs as d, jsx as n } from "react/jsx-runtime";
|
|
2
|
+
import { useState as u, useRef as x, useMemo as _, useEffect as N, useCallback as M } from "react";
|
|
3
|
+
import { createPortal as re } from "react-dom";
|
|
4
|
+
import { cn as s } from "../../utils/cn.js";
|
|
5
|
+
import { PHONE_INPUT_DEFAULT_TRANSLATIONS as te, COUNTRIES as ae, DEFAULT_COUNTRY_CODE as ne, PHONE_INPUT_SIZE_CLASSES as Q, PHONE_INPUT_VARIANT_CLASSES as oe, PHONE_INPUT_DROPDOWN_Z_INDEX as be } from "./PhoneInput.const.js";
|
|
6
|
+
import { sortCountriesWithPreferred as ce, getCountryByCode as de, filterCountries as se, formatPhoneNumber as X, createPhoneValue as Y, parsePhoneDigits as ie } from "./PhoneInput.utils.js";
|
|
7
|
+
const xe = ({
|
|
8
|
+
value: r,
|
|
9
|
+
onChange: b,
|
|
10
|
+
defaultCountry: E = ne,
|
|
11
|
+
placeholder: Z,
|
|
12
|
+
label: S,
|
|
13
|
+
helperText: O,
|
|
14
|
+
error: m,
|
|
15
|
+
disabled: f = !1,
|
|
16
|
+
required: F = !1,
|
|
17
|
+
size: R = "md",
|
|
18
|
+
variant: q = "default",
|
|
19
|
+
onlyCountries: i,
|
|
20
|
+
excludeCountries: l,
|
|
21
|
+
preferredCountries: T = [],
|
|
22
|
+
searchable: g = !0,
|
|
23
|
+
showFlags: L = !0,
|
|
24
|
+
showDialCode: G = !0,
|
|
25
|
+
className: J,
|
|
26
|
+
testId: K,
|
|
27
|
+
translations: D,
|
|
28
|
+
icon: $
|
|
29
|
+
}) => {
|
|
30
|
+
const [c, k] = u(!1), [P, w] = u(""), [I, U] = u(""), [A, C] = u({ top: 0, left: 0 }), V = x(null), z = x(null), H = x(null), y = x(null), B = _(() => ({
|
|
31
|
+
...te,
|
|
32
|
+
...D
|
|
33
|
+
}), [D]), p = _(() => {
|
|
34
|
+
let e = [...ae];
|
|
35
|
+
if (i != null && i.length) {
|
|
36
|
+
const o = new Set(i.map((a) => a.toUpperCase()));
|
|
37
|
+
e = e.filter((a) => o.has(a.code));
|
|
38
|
+
}
|
|
39
|
+
if (l != null && l.length) {
|
|
40
|
+
const o = new Set(l.map((a) => a.toUpperCase()));
|
|
41
|
+
e = e.filter((a) => !o.has(a.code));
|
|
42
|
+
}
|
|
43
|
+
return ce(e, T);
|
|
44
|
+
}, [i, l, T]), t = _(() => {
|
|
45
|
+
const e = (r == null ? void 0 : r.countryCode) || E;
|
|
46
|
+
return de(p, e) || p[0];
|
|
47
|
+
}, [r == null ? void 0 : r.countryCode, E, p]), j = _(() => se(p, P), [p, P]);
|
|
48
|
+
N(() => {
|
|
49
|
+
if ((r == null ? void 0 : r.number) !== void 0) {
|
|
50
|
+
const e = X(r.number, t == null ? void 0 : t.format);
|
|
51
|
+
U(e);
|
|
52
|
+
}
|
|
53
|
+
}, [r == null ? void 0 : r.number, t == null ? void 0 : t.format]), N(() => {
|
|
54
|
+
if (c && z.current) {
|
|
55
|
+
const e = z.current.getBoundingClientRect(), o = window.scrollY || document.documentElement.scrollTop, a = window.scrollX || document.documentElement.scrollLeft;
|
|
56
|
+
C({
|
|
57
|
+
top: e.bottom + o + 4,
|
|
58
|
+
left: e.left + a
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}, [c]), N(() => {
|
|
62
|
+
c && g && y.current && y.current.focus();
|
|
63
|
+
}, [c, g]), N(() => {
|
|
64
|
+
const e = (o) => {
|
|
65
|
+
var h, W;
|
|
66
|
+
const a = o.target;
|
|
67
|
+
(h = V.current) != null && h.contains(a) || (W = a.closest) != null && W.call(a, "[data-bear-phone-dropdown]") || (k(!1), w(""));
|
|
68
|
+
};
|
|
69
|
+
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
70
|
+
}, []);
|
|
71
|
+
const v = M((e) => {
|
|
72
|
+
var a;
|
|
73
|
+
const o = Y(e, (r == null ? void 0 : r.number) || I);
|
|
74
|
+
b == null || b(o), k(!1), w(""), (a = H.current) == null || a.focus();
|
|
75
|
+
}, [r == null ? void 0 : r.number, I, b]), ee = M((e) => {
|
|
76
|
+
const o = ie(e.target.value), a = X(o, t == null ? void 0 : t.format);
|
|
77
|
+
if (U(a), t) {
|
|
78
|
+
const h = Y(t, o);
|
|
79
|
+
b == null || b(h);
|
|
80
|
+
}
|
|
81
|
+
}, [t, b]);
|
|
82
|
+
return /* @__PURE__ */ d(
|
|
83
|
+
"div",
|
|
84
|
+
{
|
|
85
|
+
ref: V,
|
|
86
|
+
className: s("Bear-PhoneInput bear-relative", J),
|
|
87
|
+
"data-testid": K,
|
|
88
|
+
children: [
|
|
89
|
+
S && /* @__PURE__ */ d("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: [
|
|
90
|
+
S,
|
|
91
|
+
F && /* @__PURE__ */ n("span", { className: "bear-text-red-500 bear-ml-0.5", children: "*" })
|
|
92
|
+
] }),
|
|
93
|
+
/* @__PURE__ */ d("div", { className: s(
|
|
94
|
+
"Bear-PhoneInput__wrapper bear-flex bear-items-center bear-rounded-lg bear-border bear-transition-colors",
|
|
95
|
+
oe[q],
|
|
96
|
+
m ? "bear-border-red-500" : "focus-within:bear-border-pink-500",
|
|
97
|
+
f && "bear-opacity-50 bear-cursor-not-allowed"
|
|
98
|
+
), children: [
|
|
99
|
+
/* @__PURE__ */ d(
|
|
100
|
+
"button",
|
|
101
|
+
{
|
|
102
|
+
ref: z,
|
|
103
|
+
type: "button",
|
|
104
|
+
onClick: () => !f && k(!c),
|
|
105
|
+
disabled: f,
|
|
106
|
+
className: s(
|
|
107
|
+
"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",
|
|
108
|
+
Q[R]
|
|
109
|
+
),
|
|
110
|
+
children: [
|
|
111
|
+
L && t && /* @__PURE__ */ n("span", { className: "Bear-PhoneInput__flag bear-text-lg", children: t.flag }),
|
|
112
|
+
G && t && /* @__PURE__ */ n("span", { className: "Bear-PhoneInput__dial-code bear-text-gray-600 dark:bear-text-zinc-400", children: t.dialCode }),
|
|
113
|
+
$ ?? /* @__PURE__ */ n(
|
|
114
|
+
"svg",
|
|
115
|
+
{
|
|
116
|
+
className: s(
|
|
117
|
+
"Bear-PhoneInput__chevron bear-w-4 bear-h-4 bear-text-gray-500 dark:bear-text-zinc-400 bear-transition-transform",
|
|
118
|
+
c && "bear-rotate-180"
|
|
119
|
+
),
|
|
120
|
+
fill: "none",
|
|
121
|
+
viewBox: "0 0 24 24",
|
|
122
|
+
stroke: "currentColor",
|
|
123
|
+
children: /* @__PURE__ */ n("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M19 9l-7 7-7-7" })
|
|
124
|
+
}
|
|
125
|
+
)
|
|
126
|
+
]
|
|
127
|
+
}
|
|
128
|
+
),
|
|
129
|
+
/* @__PURE__ */ n(
|
|
130
|
+
"input",
|
|
131
|
+
{
|
|
132
|
+
ref: H,
|
|
133
|
+
type: "tel",
|
|
134
|
+
value: I,
|
|
135
|
+
onChange: ee,
|
|
136
|
+
placeholder: Z || B.placeholder,
|
|
137
|
+
disabled: f,
|
|
138
|
+
className: s(
|
|
139
|
+
"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",
|
|
140
|
+
Q[R]
|
|
141
|
+
)
|
|
142
|
+
}
|
|
143
|
+
)
|
|
144
|
+
] }),
|
|
145
|
+
m && /* @__PURE__ */ n("p", { className: "Bear-PhoneInput__error bear-mt-1 bear-text-xs bear-text-red-400", children: m }),
|
|
146
|
+
O && !m && /* @__PURE__ */ n("p", { className: "Bear-PhoneInput__helper bear-mt-1 bear-text-xs bear-text-zinc-500 dark:bear-text-zinc-400", children: O }),
|
|
147
|
+
c && typeof document < "u" && re(
|
|
148
|
+
/* @__PURE__ */ d(
|
|
149
|
+
"div",
|
|
150
|
+
{
|
|
151
|
+
"data-bear-phone-dropdown": !0,
|
|
152
|
+
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",
|
|
153
|
+
style: { top: A.top, left: A.left, zIndex: be },
|
|
154
|
+
children: [
|
|
155
|
+
g && /* @__PURE__ */ n("div", { className: "Bear-PhoneInput__search bear-p-2 bear-border-b bear-border-zinc-200 dark:bear-border-zinc-700", children: /* @__PURE__ */ n(
|
|
156
|
+
"input",
|
|
157
|
+
{
|
|
158
|
+
ref: y,
|
|
159
|
+
type: "text",
|
|
160
|
+
value: P,
|
|
161
|
+
onChange: (e) => w(e.target.value),
|
|
162
|
+
placeholder: B.searchCountry,
|
|
163
|
+
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"
|
|
164
|
+
}
|
|
165
|
+
) }),
|
|
166
|
+
/* @__PURE__ */ n("div", { className: "Bear-PhoneInput__country-list bear-max-h-60 bear-overflow-y-auto", children: j.length === 0 ? /* @__PURE__ */ n("div", { className: "bear-px-3 bear-py-4 bear-text-center bear-text-sm bear-text-gray-500 dark:bear-text-zinc-500", children: B.noResults }) : j.map((e) => /* @__PURE__ */ d(
|
|
167
|
+
"button",
|
|
168
|
+
{
|
|
169
|
+
type: "button",
|
|
170
|
+
onClick: () => v(e),
|
|
171
|
+
className: s(
|
|
172
|
+
"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",
|
|
173
|
+
(t == null ? void 0 : t.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"
|
|
174
|
+
),
|
|
175
|
+
children: [
|
|
176
|
+
L && /* @__PURE__ */ n("span", { className: "Bear-PhoneInput__country-flag bear-text-lg", children: e.flag }),
|
|
177
|
+
/* @__PURE__ */ n("span", { className: "Bear-PhoneInput__country-name bear-flex-1", children: e.name }),
|
|
178
|
+
/* @__PURE__ */ n("span", { className: "Bear-PhoneInput__country-dial bear-text-gray-500 dark:bear-text-zinc-500", children: e.dialCode })
|
|
179
|
+
]
|
|
180
|
+
},
|
|
181
|
+
e.code
|
|
182
|
+
)) })
|
|
183
|
+
]
|
|
184
|
+
}
|
|
185
|
+
),
|
|
186
|
+
document.body
|
|
187
|
+
)
|
|
188
|
+
]
|
|
189
|
+
}
|
|
190
|
+
);
|
|
191
|
+
};
|
|
192
|
+
export {
|
|
193
|
+
xe as PhoneInput
|
|
194
|
+
};
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Country data interface
|
|
4
|
+
*/
|
|
5
|
+
export interface CountryData {
|
|
6
|
+
/** ISO 3166-1 alpha-2 country code (e.g., 'US', 'GB') */
|
|
7
|
+
code: string;
|
|
8
|
+
/** Country name */
|
|
9
|
+
name: string;
|
|
10
|
+
/** Dial code (e.g., '+1', '+44') */
|
|
11
|
+
dialCode: string;
|
|
12
|
+
/** Flag emoji */
|
|
13
|
+
flag: string;
|
|
14
|
+
/** Phone number format mask (e.g., '(###) ###-####') */
|
|
15
|
+
format?: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Phone number value
|
|
19
|
+
*/
|
|
20
|
+
export interface PhoneValue {
|
|
21
|
+
/** Country code */
|
|
22
|
+
countryCode: string;
|
|
23
|
+
/** Dial code */
|
|
24
|
+
dialCode: string;
|
|
25
|
+
/** Phone number (without dial code) */
|
|
26
|
+
number: string;
|
|
27
|
+
/** Full formatted phone number */
|
|
28
|
+
formattedNumber: string;
|
|
29
|
+
/** Raw phone number (digits only) */
|
|
30
|
+
rawNumber: string;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* PhoneInput size variants
|
|
34
|
+
*/
|
|
35
|
+
export type PhoneInputSize = 'sm' | 'md' | 'lg';
|
|
36
|
+
/**
|
|
37
|
+
* PhoneInput variant styles
|
|
38
|
+
*/
|
|
39
|
+
export type PhoneInputVariant = 'default' | 'filled' | 'outline';
|
|
40
|
+
/**
|
|
41
|
+
* PhoneInput translations
|
|
42
|
+
*/
|
|
43
|
+
export interface PhoneInputTranslations {
|
|
44
|
+
placeholder: string;
|
|
45
|
+
searchCountry: string;
|
|
46
|
+
noResults: string;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* PhoneInput component props
|
|
50
|
+
*/
|
|
51
|
+
export interface PhoneInputProps {
|
|
52
|
+
/** Current phone value */
|
|
53
|
+
value?: PhoneValue;
|
|
54
|
+
/** Callback when value changes */
|
|
55
|
+
onChange?: (value: PhoneValue) => void;
|
|
56
|
+
/** Default country code */
|
|
57
|
+
defaultCountry?: string;
|
|
58
|
+
/** Placeholder text */
|
|
59
|
+
placeholder?: string;
|
|
60
|
+
/** Input label */
|
|
61
|
+
label?: string;
|
|
62
|
+
/** Helper text */
|
|
63
|
+
helperText?: string;
|
|
64
|
+
/** Error message */
|
|
65
|
+
error?: string;
|
|
66
|
+
/** Whether input is disabled */
|
|
67
|
+
disabled?: boolean;
|
|
68
|
+
/** Whether input is required */
|
|
69
|
+
required?: boolean;
|
|
70
|
+
/** Size variant */
|
|
71
|
+
size?: PhoneInputSize;
|
|
72
|
+
/** Style variant */
|
|
73
|
+
variant?: PhoneInputVariant;
|
|
74
|
+
/** Only allow specific countries */
|
|
75
|
+
onlyCountries?: string[];
|
|
76
|
+
/** Exclude specific countries */
|
|
77
|
+
excludeCountries?: string[];
|
|
78
|
+
/** Preferred countries (shown at top) */
|
|
79
|
+
preferredCountries?: string[];
|
|
80
|
+
/** Whether to show country search */
|
|
81
|
+
searchable?: boolean;
|
|
82
|
+
/** Whether to show flags */
|
|
83
|
+
showFlags?: boolean;
|
|
84
|
+
/** Whether to show dial code in input */
|
|
85
|
+
showDialCode?: boolean;
|
|
86
|
+
/** Custom class name */
|
|
87
|
+
className?: string;
|
|
88
|
+
/** Test ID */
|
|
89
|
+
testId?: string;
|
|
90
|
+
/** Translation strings */
|
|
91
|
+
translations?: Partial<PhoneInputTranslations>;
|
|
92
|
+
/** Custom country selector icon */
|
|
93
|
+
icon?: ReactNode;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* CountrySelector component props
|
|
97
|
+
*/
|
|
98
|
+
export interface CountrySelectorProps {
|
|
99
|
+
countries: CountryData[];
|
|
100
|
+
selectedCountry: CountryData | null;
|
|
101
|
+
onSelect: (country: CountryData) => void;
|
|
102
|
+
isOpen: boolean;
|
|
103
|
+
onToggle: () => void;
|
|
104
|
+
searchable: boolean;
|
|
105
|
+
showFlags: boolean;
|
|
106
|
+
translations: PhoneInputTranslations;
|
|
107
|
+
disabled?: boolean;
|
|
108
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=(e,t)=>{if(!t)return e;const o=e.replace(/\D/g,"");let r="",s=0;for(const n of t){if(s>=o.length)break;n==="#"?(r+=o[s],s++):r+=n}return r},d=e=>e.replace(/\D/g,""),l=(e,t)=>{const o=i(t,e.format);return{countryCode:e.code,dialCode:e.dialCode,number:t,formattedNumber:`${e.dialCode} ${o}`,rawNumber:d(t)}},c=(e,t)=>{if(!t.trim())return e;const o=t.toLowerCase();return e.filter(r=>r.name.toLowerCase().includes(o)||r.code.toLowerCase().includes(o)||r.dialCode.includes(t))},f=(e,t)=>{if(t.length===0)return e;const o=new Set(t.map(n=>n.toUpperCase())),r=e.filter(n=>o.has(n.code)),s=e.filter(n=>!o.has(n.code));return r.sort((n,a)=>t.indexOf(n.code)-t.indexOf(a.code)),[...r,...s]},C=(e,t)=>e.find(o=>o.code.toUpperCase()===t.toUpperCase());exports.createPhoneValue=l;exports.filterCountries=c;exports.formatPhoneNumber=i;exports.getCountryByCode=C;exports.parsePhoneDigits=d;exports.sortCountriesWithPreferred=f;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { CountryData, PhoneValue } from './PhoneInput.types';
|
|
2
|
+
/**
|
|
3
|
+
* Format phone number according to country format
|
|
4
|
+
*/
|
|
5
|
+
export declare const formatPhoneNumber: (number: string, format?: string) => string;
|
|
6
|
+
/**
|
|
7
|
+
* Parse raw phone input to digits only
|
|
8
|
+
*/
|
|
9
|
+
export declare const parsePhoneDigits: (input: string) => string;
|
|
10
|
+
/**
|
|
11
|
+
* Create phone value object
|
|
12
|
+
*/
|
|
13
|
+
export declare const createPhoneValue: (country: CountryData, rawNumber: string) => PhoneValue;
|
|
14
|
+
/**
|
|
15
|
+
* Filter countries by search query
|
|
16
|
+
*/
|
|
17
|
+
export declare const filterCountries: (countries: CountryData[], query: string) => CountryData[];
|
|
18
|
+
/**
|
|
19
|
+
* Sort countries with preferred countries first
|
|
20
|
+
*/
|
|
21
|
+
export declare const sortCountriesWithPreferred: (countries: CountryData[], preferred: string[]) => CountryData[];
|
|
22
|
+
/**
|
|
23
|
+
* Get country by code
|
|
24
|
+
*/
|
|
25
|
+
export declare const getCountryByCode: (countries: CountryData[], code: string) => CountryData | undefined;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
const i = (e, t) => {
|
|
2
|
+
if (!t) return e;
|
|
3
|
+
const o = e.replace(/\D/g, "");
|
|
4
|
+
let r = "", s = 0;
|
|
5
|
+
for (const n of t) {
|
|
6
|
+
if (s >= o.length) break;
|
|
7
|
+
n === "#" ? (r += o[s], s++) : r += n;
|
|
8
|
+
}
|
|
9
|
+
return r;
|
|
10
|
+
}, a = (e) => e.replace(/\D/g, ""), l = (e, t) => {
|
|
11
|
+
const o = i(t, e.format);
|
|
12
|
+
return {
|
|
13
|
+
countryCode: e.code,
|
|
14
|
+
dialCode: e.dialCode,
|
|
15
|
+
number: t,
|
|
16
|
+
formattedNumber: `${e.dialCode} ${o}`,
|
|
17
|
+
rawNumber: a(t)
|
|
18
|
+
};
|
|
19
|
+
}, c = (e, t) => {
|
|
20
|
+
if (!t.trim()) return e;
|
|
21
|
+
const o = t.toLowerCase();
|
|
22
|
+
return e.filter(
|
|
23
|
+
(r) => r.name.toLowerCase().includes(o) || r.code.toLowerCase().includes(o) || r.dialCode.includes(t)
|
|
24
|
+
);
|
|
25
|
+
}, f = (e, t) => {
|
|
26
|
+
if (t.length === 0) return e;
|
|
27
|
+
const o = new Set(t.map((n) => n.toUpperCase())), r = e.filter((n) => o.has(n.code)), s = e.filter((n) => !o.has(n.code));
|
|
28
|
+
return r.sort(
|
|
29
|
+
(n, d) => t.indexOf(n.code) - t.indexOf(d.code)
|
|
30
|
+
), [...r, ...s];
|
|
31
|
+
}, C = (e, t) => e.find((o) => o.code.toUpperCase() === t.toUpperCase());
|
|
32
|
+
export {
|
|
33
|
+
l as createPhoneValue,
|
|
34
|
+
c as filterCountries,
|
|
35
|
+
i as formatPhoneNumber,
|
|
36
|
+
C as getCountryByCode,
|
|
37
|
+
a as parsePhoneDigits,
|
|
38
|
+
f as sortCountriesWithPreferred
|
|
39
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("react/jsx-runtime"),s=require("react"),_=require("../../utils/cn.cjs"),p=require("../Button/Button.cjs"),a=require("./SignPad.const.cjs"),V=y=>{const{onChange:r,width:P=a.SIGN_PAD_DEFAULT_WIDTH,height:A=a.SIGN_PAD_DEFAULT_HEIGHT,strokeColor:B,strokeWidth:N=a.SIGN_PAD_DEFAULT_STROKE_WIDTH,backgroundColor:O,placeholder:U=a.SIGN_PAD_DEFAULT_PLACEHOLDER,disabled:o=!1,readOnly:l=!1,showClear:I=!0,showSave:v=!1,clearText:M="Clear",saveText:j="Save",outputFormat:h=a.SIGN_PAD_DEFAULT_OUTPUT_FORMAT,outputQuality:D=a.SIGN_PAD_DEFAULT_OUTPUT_QUALITY,className:F,testId:H,id:K,...W}=y,i=s.useRef(null),[f,x]=s.useState(!1),[u,m]=s.useState(!1),[g,C]=s.useState(null),[E,q]=s.useState(!1);s.useEffect(()=>{const e=()=>{const n=document.documentElement.classList.contains("dark");q(n)};e();const t=new MutationObserver(e);return t.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>t.disconnect()},[]);const k=B||(E?a.SIGN_PAD_STROKE_DARK:a.SIGN_PAD_STROKE_LIGHT),S=O||(E?a.SIGN_PAD_BG_DARK:a.SIGN_PAD_BG_LIGHT);s.useEffect(()=>{const e=i.current;if(!e)return;const t=e.getContext("2d");t&&(e.width=P,e.height=A,t.fillStyle=S,t.fillRect(0,0,P,A))},[P,A,S,E]);const b=s.useCallback(e=>{const t=i.current;if(!t)return{x:0,y:0};const n=t.getBoundingClientRect(),d=t.width/n.width,w=t.height/n.height;if("touches"in e){const G=e.touches[0];return{x:(G.clientX-n.left)*d,y:(G.clientY-n.top)*w}}return{x:(e.clientX-n.left)*d,y:(e.clientY-n.top)*w}},[]),L=s.useCallback(e=>{if(o||l)return;const t=b(e);x(!0),C(t)},[o,l,b]),R=s.useCallback(e=>{if(!f||o||l)return;const t=i.current,n=t==null?void 0:t.getContext("2d");if(!t||!n||!g)return;const d=b(e);n.beginPath(),n.moveTo(g.x,g.y),n.lineTo(d.x,d.y),n.strokeStyle=k,n.lineWidth=N,n.lineCap="round",n.lineJoin="round",n.stroke(),C(d),m(!0)},[f,o,l,g,k,N,b]),T=s.useCallback(()=>{if(f&&u){const e=i.current;if(e&&r){const t=e.toDataURL(h,D);r(t)}}x(!1),C(null)},[f,u,r,h,D]),X=s.useCallback(()=>{const e=i.current,t=e==null?void 0:e.getContext("2d");!e||!t||(t.fillStyle=S==="transparent"?"rgba(0,0,0,0)":S,t.clearRect(0,0,e.width,e.height),t.fillRect(0,0,e.width,e.height),m(!1),r==null||r(null))},[S,r]),Y=s.useCallback(()=>{const e=i.current;if(!e||!u)return;const t=e.toDataURL(h,D);r==null||r(t)},[u,r,h,D]);return c.jsxs("div",{id:K,"data-testid":H,className:_.cn("Bear-SignPad bear-max-w-full bear-w-full",a.SIGN_PAD_ROOT_CLASSES,o&&"Bear-SignPad--disabled bear-opacity-50",l&&"Bear-SignPad--readonly",F),...W,children:[c.jsxs("div",{className:_.cn("Bear-SignPad__canvas-wrapper bear-max-w-full bear-overflow-hidden",a.SIGN_PAD_CANVAS_WRAPPER_CLASSES,!o&&!l&&a.SIGN_PAD_CANVAS_WRAPPER_HOVER,o&&"bear-cursor-not-allowed",!o&&!l&&"bear-cursor-crosshair"),children:[c.jsx("canvas",{ref:i,className:"Bear-SignPad__canvas bear-block bear-rounded-lg bear-max-w-full",style:{width:P,height:A},onMouseDown:L,onMouseMove:R,onMouseUp:T,onMouseLeave:T,onTouchStart:L,onTouchMove:R,onTouchEnd:T}),!u&&c.jsx("div",{className:_.cn("Bear-SignPad__placeholder",a.SIGN_PAD_PLACEHOLDER_CLASSES),children:U}),c.jsx("div",{className:_.cn("Bear-SignPad__line",a.SIGN_PAD_LINE_CLASSES)}),c.jsx("span",{className:_.cn("Bear-SignPad__x-mark",a.SIGN_PAD_X_MARK_CLASSES),children:"×"})]}),(I||v)&&c.jsxs("div",{className:_.cn("Bear-SignPad__actions",a.SIGN_PAD_ACTIONS_CLASSES),children:[I&&c.jsx(p.Button,{size:"sm",variant:"ghost",onClick:X,disabled:o||!u,children:M}),v&&c.jsx(p.Button,{size:"sm",variant:"primary",onClick:Y,disabled:o||!u,children:j})]})]})};exports.SignPad=V;
|
|
@@ -1,99 +1,99 @@
|
|
|
1
1
|
import { jsxs as I, jsx as l } from "react/jsx-runtime";
|
|
2
|
-
import { useRef as J, useState as
|
|
2
|
+
import { useRef as J, useState as g, useEffect as y, useCallback as d } from "react";
|
|
3
3
|
import { cn as _ } from "../../utils/cn.js";
|
|
4
4
|
import { Button as O } from "../Button/Button.js";
|
|
5
|
-
import { SIGN_PAD_DEFAULT_WIDTH as q, SIGN_PAD_DEFAULT_HEIGHT as Z, SIGN_PAD_DEFAULT_STROKE_WIDTH as $, SIGN_PAD_DEFAULT_PLACEHOLDER as tt, SIGN_PAD_DEFAULT_OUTPUT_FORMAT as et, SIGN_PAD_DEFAULT_OUTPUT_QUALITY as
|
|
6
|
-
const
|
|
5
|
+
import { SIGN_PAD_DEFAULT_WIDTH as q, SIGN_PAD_DEFAULT_HEIGHT as Z, SIGN_PAD_DEFAULT_STROKE_WIDTH as $, SIGN_PAD_DEFAULT_PLACEHOLDER as tt, SIGN_PAD_DEFAULT_OUTPUT_FORMAT as et, SIGN_PAD_DEFAULT_OUTPUT_QUALITY as rt, SIGN_PAD_BG_DARK as nt, SIGN_PAD_BG_LIGHT as at, SIGN_PAD_STROKE_DARK as ot, SIGN_PAD_STROKE_LIGHT as st, SIGN_PAD_PLACEHOLDER_CLASSES as ct, SIGN_PAD_LINE_CLASSES as it, SIGN_PAD_X_MARK_CLASSES as lt, SIGN_PAD_CANVAS_WRAPPER_HOVER as dt, SIGN_PAD_CANVAS_WRAPPER_CLASSES as _t, SIGN_PAD_ACTIONS_CLASSES as ut, SIGN_PAD_ROOT_CLASSES as St } from "./SignPad.const.js";
|
|
6
|
+
const mt = (U) => {
|
|
7
7
|
const {
|
|
8
|
-
onChange:
|
|
8
|
+
onChange: n,
|
|
9
9
|
width: S = q,
|
|
10
10
|
height: A = Z,
|
|
11
11
|
strokeColor: B,
|
|
12
|
-
strokeWidth:
|
|
12
|
+
strokeWidth: b = $,
|
|
13
13
|
backgroundColor: M,
|
|
14
14
|
placeholder: F = tt,
|
|
15
|
-
disabled:
|
|
16
|
-
readOnly:
|
|
15
|
+
disabled: a = !1,
|
|
16
|
+
readOnly: o = !1,
|
|
17
17
|
showClear: v = !0,
|
|
18
|
-
showSave:
|
|
18
|
+
showSave: p = !1,
|
|
19
19
|
clearText: H = "Clear",
|
|
20
20
|
saveText: K = "Save",
|
|
21
21
|
outputFormat: h = et,
|
|
22
|
-
outputQuality: P =
|
|
22
|
+
outputQuality: P = rt,
|
|
23
23
|
className: W,
|
|
24
24
|
testId: X,
|
|
25
25
|
id: Y,
|
|
26
26
|
...V
|
|
27
|
-
} = U, s = J(null), [
|
|
27
|
+
} = U, s = J(null), [f, C] = g(!1), [c, L] = g(!1), [D, E] = g(null), [N, j] = g(!1);
|
|
28
28
|
y(() => {
|
|
29
29
|
const t = () => {
|
|
30
|
-
const
|
|
31
|
-
j(
|
|
30
|
+
const r = document.documentElement.classList.contains("dark");
|
|
31
|
+
j(r);
|
|
32
32
|
};
|
|
33
33
|
t();
|
|
34
34
|
const e = new MutationObserver(t);
|
|
35
35
|
return e.observe(document.documentElement, { attributes: !0, attributeFilter: ["class"] }), () => e.disconnect();
|
|
36
36
|
}, []);
|
|
37
|
-
const
|
|
37
|
+
const R = B || (N ? ot : st), u = M || (N ? nt : at);
|
|
38
38
|
y(() => {
|
|
39
39
|
const t = s.current;
|
|
40
40
|
if (!t) return;
|
|
41
41
|
const e = t.getContext("2d");
|
|
42
42
|
e && (t.width = S, t.height = A, e.fillStyle = u, e.fillRect(0, 0, S, A));
|
|
43
43
|
}, [S, A, u, N]);
|
|
44
|
-
const
|
|
44
|
+
const m = d((t) => {
|
|
45
45
|
const e = s.current;
|
|
46
46
|
if (!e) return { x: 0, y: 0 };
|
|
47
|
-
const
|
|
47
|
+
const r = e.getBoundingClientRect(), i = e.width / r.width, k = e.height / r.height;
|
|
48
48
|
if ("touches" in t) {
|
|
49
49
|
const x = t.touches[0];
|
|
50
50
|
return {
|
|
51
|
-
x: (x.clientX -
|
|
52
|
-
y: (x.clientY -
|
|
51
|
+
x: (x.clientX - r.left) * i,
|
|
52
|
+
y: (x.clientY - r.top) * k
|
|
53
53
|
};
|
|
54
54
|
}
|
|
55
55
|
return {
|
|
56
|
-
x: (t.clientX -
|
|
57
|
-
y: (t.clientY -
|
|
56
|
+
x: (t.clientX - r.left) * i,
|
|
57
|
+
y: (t.clientY - r.top) * k
|
|
58
58
|
};
|
|
59
|
-
}, []),
|
|
60
|
-
if (
|
|
61
|
-
const e =
|
|
62
|
-
|
|
63
|
-
}, [
|
|
64
|
-
if (!
|
|
65
|
-
const e = s.current,
|
|
66
|
-
if (!e || !
|
|
67
|
-
const i =
|
|
68
|
-
|
|
69
|
-
}, [
|
|
70
|
-
if (
|
|
59
|
+
}, []), w = d((t) => {
|
|
60
|
+
if (a || o) return;
|
|
61
|
+
const e = m(t);
|
|
62
|
+
C(!0), E(e);
|
|
63
|
+
}, [a, o, m]), G = d((t) => {
|
|
64
|
+
if (!f || a || o) return;
|
|
65
|
+
const e = s.current, r = e == null ? void 0 : e.getContext("2d");
|
|
66
|
+
if (!e || !r || !D) return;
|
|
67
|
+
const i = m(t);
|
|
68
|
+
r.beginPath(), r.moveTo(D.x, D.y), r.lineTo(i.x, i.y), r.strokeStyle = R, r.lineWidth = b, r.lineCap = "round", r.lineJoin = "round", r.stroke(), E(i), L(!0);
|
|
69
|
+
}, [f, a, o, D, R, b, m]), T = d(() => {
|
|
70
|
+
if (f && c) {
|
|
71
71
|
const t = s.current;
|
|
72
|
-
if (t &&
|
|
72
|
+
if (t && n) {
|
|
73
73
|
const e = t.toDataURL(h, P);
|
|
74
|
-
|
|
74
|
+
n(e);
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
|
-
|
|
78
|
-
}, [
|
|
77
|
+
C(!1), E(null);
|
|
78
|
+
}, [f, c, n, h, P]), z = d(() => {
|
|
79
79
|
const t = s.current, e = t == null ? void 0 : t.getContext("2d");
|
|
80
|
-
!t || !e || (e.fillStyle = u === "transparent" ? "rgba(0,0,0,0)" : u, e.clearRect(0, 0, t.width, t.height), e.fillRect(0, 0, t.width, t.height),
|
|
81
|
-
}, [u,
|
|
80
|
+
!t || !e || (e.fillStyle = u === "transparent" ? "rgba(0,0,0,0)" : u, e.clearRect(0, 0, t.width, t.height), e.fillRect(0, 0, t.width, t.height), L(!1), n == null || n(null));
|
|
81
|
+
}, [u, n]), Q = d(() => {
|
|
82
82
|
const t = s.current;
|
|
83
83
|
if (!t || !c) return;
|
|
84
84
|
const e = t.toDataURL(h, P);
|
|
85
|
-
|
|
86
|
-
}, [c,
|
|
85
|
+
n == null || n(e);
|
|
86
|
+
}, [c, n, h, P]);
|
|
87
87
|
return /* @__PURE__ */ I(
|
|
88
88
|
"div",
|
|
89
89
|
{
|
|
90
90
|
id: Y,
|
|
91
91
|
"data-testid": X,
|
|
92
92
|
className: _(
|
|
93
|
-
"Bear-SignPad",
|
|
93
|
+
"Bear-SignPad bear-max-w-full bear-w-full",
|
|
94
94
|
St,
|
|
95
|
-
|
|
96
|
-
|
|
95
|
+
a && "Bear-SignPad--disabled bear-opacity-50",
|
|
96
|
+
o && "Bear-SignPad--readonly",
|
|
97
97
|
W
|
|
98
98
|
),
|
|
99
99
|
...V,
|
|
@@ -102,25 +102,25 @@ const gt = (U) => {
|
|
|
102
102
|
"div",
|
|
103
103
|
{
|
|
104
104
|
className: _(
|
|
105
|
-
"Bear-SignPad__canvas-wrapper",
|
|
105
|
+
"Bear-SignPad__canvas-wrapper bear-max-w-full bear-overflow-hidden",
|
|
106
106
|
_t,
|
|
107
|
-
!
|
|
108
|
-
|
|
109
|
-
!
|
|
107
|
+
!a && !o && dt,
|
|
108
|
+
a && "bear-cursor-not-allowed",
|
|
109
|
+
!a && !o && "bear-cursor-crosshair"
|
|
110
110
|
),
|
|
111
111
|
children: [
|
|
112
112
|
/* @__PURE__ */ l(
|
|
113
113
|
"canvas",
|
|
114
114
|
{
|
|
115
115
|
ref: s,
|
|
116
|
-
className: "Bear-SignPad__canvas bear-block bear-rounded-lg",
|
|
116
|
+
className: "Bear-SignPad__canvas bear-block bear-rounded-lg bear-max-w-full",
|
|
117
117
|
style: { width: S, height: A },
|
|
118
|
-
onMouseDown:
|
|
119
|
-
onMouseMove:
|
|
118
|
+
onMouseDown: w,
|
|
119
|
+
onMouseMove: G,
|
|
120
120
|
onMouseUp: T,
|
|
121
121
|
onMouseLeave: T,
|
|
122
|
-
onTouchStart:
|
|
123
|
-
onTouchMove:
|
|
122
|
+
onTouchStart: w,
|
|
123
|
+
onTouchMove: G,
|
|
124
124
|
onTouchEnd: T
|
|
125
125
|
}
|
|
126
126
|
),
|
|
@@ -130,24 +130,24 @@ const gt = (U) => {
|
|
|
130
130
|
]
|
|
131
131
|
}
|
|
132
132
|
),
|
|
133
|
-
(v ||
|
|
133
|
+
(v || p) && /* @__PURE__ */ I("div", { className: _("Bear-SignPad__actions", ut), children: [
|
|
134
134
|
v && /* @__PURE__ */ l(
|
|
135
135
|
O,
|
|
136
136
|
{
|
|
137
137
|
size: "sm",
|
|
138
138
|
variant: "ghost",
|
|
139
139
|
onClick: z,
|
|
140
|
-
disabled:
|
|
140
|
+
disabled: a || !c,
|
|
141
141
|
children: H
|
|
142
142
|
}
|
|
143
143
|
),
|
|
144
|
-
|
|
144
|
+
p && /* @__PURE__ */ l(
|
|
145
145
|
O,
|
|
146
146
|
{
|
|
147
147
|
size: "sm",
|
|
148
148
|
variant: "primary",
|
|
149
149
|
onClick: Q,
|
|
150
|
-
disabled:
|
|
150
|
+
disabled: a || !c,
|
|
151
151
|
children: K
|
|
152
152
|
}
|
|
153
153
|
)
|
|
@@ -157,5 +157,5 @@ const gt = (U) => {
|
|
|
157
157
|
);
|
|
158
158
|
};
|
|
159
159
|
export {
|
|
160
|
-
|
|
160
|
+
mt as SignPad
|
|
161
161
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),r=require("react"),V=require("../../utils/cn.cjs"),G=require("../../hooks/useMediaQuery.cjs"),J=require("./TimePicker.utils.cjs"),e=require("./TimePicker.constants.cjs"),X=require("./components/TimePickerColumnsDropdown/TimePickerColumnsDropdown.cjs"),Y=require("./components/TimePickerDialDropdown/TimePickerDialDropdown.cjs"),Z=s.jsx("svg",{className:"bear-w-5 bear-h-5 bear-text-gray-400 dark:bear-text-zinc-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"})}),g=t=>{const j={value:t.value,onChange:t.onChange,disabled:t.disabled??!1,placeholder:t.placeholder??"Select time",label:t.label,error:t.error,helperText:t.helperText,format:t.format??e.TIMEPICKER_FORMAT_12H,minuteStep:t.minuteStep??5,clearable:t.clearable??!0,className:t.className,size:t.size??"md",variant:t.variant??"default",dropdownVariant:t.dropdownVariant??e.TIMEPICKER_VARIANT_COLUMNS,dropdownVariantBreakpoint:t.dropdownVariantBreakpoint??e.TIMEPICKER_DEFAULT_BREAKPOINT,icon:t.icon,translations:t.translations},{value:y,onChange:l,disabled:T,placeholder:D,label:M,error:i,helperText:S,format:c,minuteStep:_,clearable:A,className:H,size:U,variant:q,dropdownVariant:f,dropdownVariantBreakpoint:F,icon:z,translations:b}=j,B=G.useMediaQuery(`(min-width: ${F}px)`),p=f===e.TIMEPICKER_VARIANT_AUTO?B?e.TIMEPICKER_VARIANT_DIAL:e.TIMEPICKER_VARIANT_COLUMNS:f,h=p===e.TIMEPICKER_VARIANT_DIAL&&c===e.TIMEPICKER_FORMAT_24H?e.TIMEPICKER_VARIANT_COLUMNS:p,n=y,[C,d]=r.useState(!1),[u,k]=r.useState(12),[E,N]=r.useState(0),[I,K]=r.useState("AM"),R=r.useRef(null);r.useEffect(()=>{if(n&&typeof n=="string"){const[o,a]=n.split(" "),[W,$]=o.split(":").map(Number);k(W),N($),a&&K(a)}},[n]),r.useEffect(()=>{const o=a=>{R.current&&!R.current.contains(a.target)&&d(!1)};return document.addEventListener("mousedown",o),()=>document.removeEventListener("mousedown",o)},[]);const O=r.useCallback(()=>{l==null||l(J.formatTime(u,E,I,c??e.TIMEPICKER_FORMAT_12H)),d(!1)},[l,u,E,I,c]),x=c===e.TIMEPICKER_FORMAT_12H?Array.from({length:e.TIMEPICKER_HOURS_12H},(o,a)=>a+1):Array.from({length:e.TIMEPICKER_HOURS_24H},(o,a)=>a),L=Array.from({length:e.TIMEPICKER_MINUTES_DIVISOR/(_??5)},(o,a)=>a*(_??5)),w=r.useCallback(()=>d(!1),[]),v=c??e.TIMEPICKER_FORMAT_12H,P=_??5,m=r.useMemo(()=>({selectedHour:u,setSelectedHour:k,selectedMinute:E,setSelectedMinute:N,period:I,setPeriod:K,format:v,hours:x,minutes:L,timeValue:n,clearable:A??!0,onChange:l,onConfirm:O,onClose:w,translations:b}),[u,E,I,v,x,L,n,A,l,O,w,b]),Q=r.useCallback(()=>C?h===e.TIMEPICKER_VARIANT_DIAL?s.jsx(Y.TimePickerDialDropdown,{...m,minuteStep:P}):s.jsx(X.TimePickerColumnsDropdown,{...m}):null,[C,h,m,P]);return s.jsxs("div",{ref:R,className:V.cn(e.TIMEPICKER_ROOT_CLASSES,H),children:[M&&s.jsx("label",{className:e.TIMEPICKER_LABEL_CLASSES,children:M}),s.jsxs("button",{type:"button",onClick:()=>!T&&d(!C),disabled:T,className:V.cn(e.TIMEPICKER_BUTTON_CLASSES,e.sizeClasses[U??"md"],e.variantClasses[q??"default"],i?"bear-border-red-500":"focus:bear-border-pink-500",T&&"bear-opacity-50 bear-cursor-not-allowed",n?"bear-text-gray-900 dark:bear-text-white":"bear-text-gray-400 dark:bear-text-zinc-500"),children:[s.jsx("span",{children:n||D}),z??Z]}),i&&s.jsx("p",{className:e.TIMEPICKER_ERROR_CLASSES,children:i}),S&&!i&&s.jsx("p",{className:e.TIMEPICKER_HELPER_CLASSES,children:S}),Q()]})};exports.TimePicker=g;
|