@forgedevstack/bear 1.0.4 → 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/AppBar/AppBar.cjs +1 -1
- package/dist/components/AppBar/AppBar.js +8 -8
- package/dist/components/Button/Button.constants.cjs +1 -1
- package/dist/components/Button/Button.constants.js +1 -1
- package/dist/components/Button/Button.d.ts +5 -3
- 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/Input/Input.cjs +1 -1
- package/dist/components/Input/Input.js +36 -36
- 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/Select/Select.cjs +1 -1
- package/dist/components/Select/Select.js +37 -37
- package/dist/components/Sidebar/Sidebar.cjs +1 -1
- package/dist/components/Sidebar/Sidebar.const.cjs +1 -1
- package/dist/components/Sidebar/Sidebar.const.d.ts +6 -2
- package/dist/components/Sidebar/Sidebar.const.js +24 -17
- package/dist/components/Sidebar/Sidebar.js +36 -31
- package/dist/components/Sidebar/Sidebar.types.d.ts +9 -0
- package/dist/components/Sidebar/components/SidebarItem/SidebarItem.cjs +1 -1
- package/dist/components/Sidebar/components/SidebarItem/SidebarItem.js +30 -29
- 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 +13 -3
- package/dist/components/index.js +139 -126
- package/dist/context/BearProvider.cjs +1 -1
- package/dist/context/BearProvider.js +25 -25
- 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,82 @@
|
|
|
1
|
+
const a = {
|
|
2
|
+
placeholder: "Phone number",
|
|
3
|
+
searchCountry: "Search country...",
|
|
4
|
+
noResults: "No countries found"
|
|
5
|
+
}, e = {
|
|
6
|
+
sm: "bear-py-1.5 bear-px-3 bear-text-sm",
|
|
7
|
+
md: "bear-py-2 bear-px-4 bear-text-sm",
|
|
8
|
+
lg: "bear-py-2.5 bear-px-5 bear-text-base"
|
|
9
|
+
}, o = {
|
|
10
|
+
default: "bear-bg-white dark:bear-bg-zinc-800 bear-border-zinc-300 dark:bear-border-zinc-600",
|
|
11
|
+
filled: "bear-bg-zinc-100 dark:bear-bg-zinc-700 bear-border-transparent",
|
|
12
|
+
outline: "bear-bg-transparent bear-border-zinc-300 dark:bear-border-zinc-500"
|
|
13
|
+
}, d = 9999, l = [
|
|
14
|
+
{ code: "US", name: "United States", dialCode: "+1", flag: "🇺🇸", format: "(###) ###-####" },
|
|
15
|
+
{ code: "GB", name: "United Kingdom", dialCode: "+44", flag: "🇬🇧", format: "#### ### ####" },
|
|
16
|
+
{ code: "CA", name: "Canada", dialCode: "+1", flag: "🇨🇦", format: "(###) ###-####" },
|
|
17
|
+
{ code: "AU", name: "Australia", dialCode: "+61", flag: "🇦🇺", format: "#### ### ###" },
|
|
18
|
+
{ code: "DE", name: "Germany", dialCode: "+49", flag: "🇩🇪", format: "#### #######" },
|
|
19
|
+
{ code: "FR", name: "France", dialCode: "+33", flag: "🇫🇷", format: "## ## ## ## ##" },
|
|
20
|
+
{ code: "IT", name: "Italy", dialCode: "+39", flag: "🇮🇹", format: "### ### ####" },
|
|
21
|
+
{ code: "ES", name: "Spain", dialCode: "+34", flag: "🇪🇸", format: "### ## ## ##" },
|
|
22
|
+
{ code: "NL", name: "Netherlands", dialCode: "+31", flag: "🇳🇱", format: "## ### ####" },
|
|
23
|
+
{ code: "BE", name: "Belgium", dialCode: "+32", flag: "🇧🇪", format: "### ## ## ##" },
|
|
24
|
+
{ code: "CH", name: "Switzerland", dialCode: "+41", flag: "🇨🇭", format: "## ### ## ##" },
|
|
25
|
+
{ code: "AT", name: "Austria", dialCode: "+43", flag: "🇦🇹", format: "### #######" },
|
|
26
|
+
{ code: "SE", name: "Sweden", dialCode: "+46", flag: "🇸🇪", format: "##-### ## ##" },
|
|
27
|
+
{ code: "NO", name: "Norway", dialCode: "+47", flag: "🇳🇴", format: "### ## ###" },
|
|
28
|
+
{ code: "DK", name: "Denmark", dialCode: "+45", flag: "🇩🇰", format: "## ## ## ##" },
|
|
29
|
+
{ code: "FI", name: "Finland", dialCode: "+358", flag: "🇫🇮", format: "## ### ####" },
|
|
30
|
+
{ code: "PL", name: "Poland", dialCode: "+48", flag: "🇵🇱", format: "### ### ###" },
|
|
31
|
+
{ code: "PT", name: "Portugal", dialCode: "+351", flag: "🇵🇹", format: "### ### ###" },
|
|
32
|
+
{ code: "IE", name: "Ireland", dialCode: "+353", flag: "🇮🇪", format: "## ### ####" },
|
|
33
|
+
{ code: "GR", name: "Greece", dialCode: "+30", flag: "🇬🇷", format: "### ### ####" },
|
|
34
|
+
{ code: "CZ", name: "Czech Republic", dialCode: "+420", flag: "🇨🇿", format: "### ### ###" },
|
|
35
|
+
{ code: "HU", name: "Hungary", dialCode: "+36", flag: "🇭🇺", format: "## ### ####" },
|
|
36
|
+
{ code: "RO", name: "Romania", dialCode: "+40", flag: "🇷🇴", format: "### ### ###" },
|
|
37
|
+
{ code: "BG", name: "Bulgaria", dialCode: "+359", flag: "🇧🇬", format: "### ### ###" },
|
|
38
|
+
{ code: "HR", name: "Croatia", dialCode: "+385", flag: "🇭🇷", format: "## ### ####" },
|
|
39
|
+
{ code: "SK", name: "Slovakia", dialCode: "+421", flag: "🇸🇰", format: "### ### ###" },
|
|
40
|
+
{ code: "SI", name: "Slovenia", dialCode: "+386", flag: "🇸🇮", format: "## ### ###" },
|
|
41
|
+
{ code: "LT", name: "Lithuania", dialCode: "+370", flag: "🇱🇹", format: "### #####" },
|
|
42
|
+
{ code: "LV", name: "Latvia", dialCode: "+371", flag: "🇱🇻", format: "## ### ###" },
|
|
43
|
+
{ code: "EE", name: "Estonia", dialCode: "+372", flag: "🇪🇪", format: "### ####" },
|
|
44
|
+
{ code: "JP", name: "Japan", dialCode: "+81", flag: "🇯🇵", format: "##-####-####" },
|
|
45
|
+
{ code: "KR", name: "South Korea", dialCode: "+82", flag: "🇰🇷", format: "##-####-####" },
|
|
46
|
+
{ code: "CN", name: "China", dialCode: "+86", flag: "🇨🇳", format: "### #### ####" },
|
|
47
|
+
{ code: "IN", name: "India", dialCode: "+91", flag: "🇮🇳", format: "##### #####" },
|
|
48
|
+
{ code: "SG", name: "Singapore", dialCode: "+65", flag: "🇸🇬", format: "#### ####" },
|
|
49
|
+
{ code: "HK", name: "Hong Kong", dialCode: "+852", flag: "🇭🇰", format: "#### ####" },
|
|
50
|
+
{ code: "TW", name: "Taiwan", dialCode: "+886", flag: "🇹🇼", format: "### ### ###" },
|
|
51
|
+
{ code: "TH", name: "Thailand", dialCode: "+66", flag: "🇹🇭", format: "## ### ####" },
|
|
52
|
+
{ code: "MY", name: "Malaysia", dialCode: "+60", flag: "🇲🇾", format: "##-### ####" },
|
|
53
|
+
{ code: "ID", name: "Indonesia", dialCode: "+62", flag: "🇮🇩", format: "### ### ####" },
|
|
54
|
+
{ code: "PH", name: "Philippines", dialCode: "+63", flag: "🇵🇭", format: "### ### ####" },
|
|
55
|
+
{ code: "VN", name: "Vietnam", dialCode: "+84", flag: "🇻🇳", format: "### ### ####" },
|
|
56
|
+
{ code: "RU", name: "Russia", dialCode: "+7", flag: "🇷🇺", format: "### ###-##-##" },
|
|
57
|
+
{ code: "UA", name: "Ukraine", dialCode: "+380", flag: "🇺🇦", format: "## ### ## ##" },
|
|
58
|
+
{ code: "TR", name: "Turkey", dialCode: "+90", flag: "🇹🇷", format: "### ### ## ##" },
|
|
59
|
+
{ code: "IL", name: "Israel", dialCode: "+972", flag: "🇮🇱", format: "##-###-####" },
|
|
60
|
+
{ code: "AE", name: "United Arab Emirates", dialCode: "+971", flag: "🇦🇪", format: "## ### ####" },
|
|
61
|
+
{ code: "SA", name: "Saudi Arabia", dialCode: "+966", flag: "🇸🇦", format: "## ### ####" },
|
|
62
|
+
{ code: "EG", name: "Egypt", dialCode: "+20", flag: "🇪🇬", format: "### ### ####" },
|
|
63
|
+
{ code: "ZA", name: "South Africa", dialCode: "+27", flag: "🇿🇦", format: "## ### ####" },
|
|
64
|
+
{ code: "NG", name: "Nigeria", dialCode: "+234", flag: "🇳🇬", format: "### ### ####" },
|
|
65
|
+
{ code: "KE", name: "Kenya", dialCode: "+254", flag: "🇰🇪", format: "### ### ###" },
|
|
66
|
+
{ code: "BR", name: "Brazil", dialCode: "+55", flag: "🇧🇷", format: "(##) #####-####" },
|
|
67
|
+
{ code: "MX", name: "Mexico", dialCode: "+52", flag: "🇲🇽", format: "## #### ####" },
|
|
68
|
+
{ code: "AR", name: "Argentina", dialCode: "+54", flag: "🇦🇷", format: "## ####-####" },
|
|
69
|
+
{ code: "CO", name: "Colombia", dialCode: "+57", flag: "🇨🇴", format: "### ### ####" },
|
|
70
|
+
{ code: "CL", name: "Chile", dialCode: "+56", flag: "🇨🇱", format: "# #### ####" },
|
|
71
|
+
{ code: "PE", name: "Peru", dialCode: "+51", flag: "🇵🇪", format: "### ### ###" },
|
|
72
|
+
{ code: "VE", name: "Venezuela", dialCode: "+58", flag: "🇻🇪", format: "### ### ####" },
|
|
73
|
+
{ code: "NZ", name: "New Zealand", dialCode: "+64", flag: "🇳🇿", format: "## ### ####" }
|
|
74
|
+
], m = "US";
|
|
75
|
+
export {
|
|
76
|
+
l as COUNTRIES,
|
|
77
|
+
m as DEFAULT_COUNTRY_CODE,
|
|
78
|
+
a as PHONE_INPUT_DEFAULT_TRANSLATIONS,
|
|
79
|
+
d as PHONE_INPUT_DROPDOWN_Z_INDEX,
|
|
80
|
+
e as PHONE_INPUT_SIZE_CLASSES,
|
|
81
|
+
o as PHONE_INPUT_VARIANT_CLASSES
|
|
82
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { PhoneInputProps } from './PhoneInput.types';
|
|
3
|
+
/**
|
|
4
|
+
* PhoneInput - International phone number input
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```tsx
|
|
8
|
+
* <PhoneInput
|
|
9
|
+
* value={phoneValue}
|
|
10
|
+
* onChange={setPhoneValue}
|
|
11
|
+
* defaultCountry="US"
|
|
12
|
+
* preferredCountries={['US', 'GB', 'CA']}
|
|
13
|
+
* />
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export declare const PhoneInput: FC<PhoneInputProps>;
|
|
@@ -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 r=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),i=require("react"),a=require("../../utils/cn.cjs"),f=require("../Icon/index.cjs"),j={sm:"bear-h-8 bear-text-sm bear-px-3",md:"bear-h-10 bear-text-base bear-px-4",lg:"bear-h-12 bear-text-lg bear-px-5"},N=({options:u,value:t,onChange:s,placeholder:g="Select an option",label:x,error:l,disabled:n=!1,size:m="md",fullWidth:y=!1,className:h})=>{const[c,d]=i.useState(!1),o=i.useRef(null),k=!!l,b=u.find(e=>e.value===t);i.useEffect(()=>{const e=v=>{o.current&&!o.current.contains(v.target)&&d(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]);const w=e=>{s==null||s(e),d(!1)};return r.jsxs("div",{ref:o,className:a.cn("bear-relative bear-flex bear-flex-col bear-gap-1.5",y&&"bear-w-full"),children:[x&&r.jsx("label",{className:"bear-text-sm bear-font-medium bear-text-gray-700 dark:bear-text-gray-300",children:x}),r.jsxs("button",{type:"button",disabled:n,onClick:()=>!n&&d(!c),className:a.cn("bear-flex bear-items-center bear-justify-between bear-w-full","bear-rounded-lg bear-border bear-text-left bear-outline-none bear-transition-all bear-duration-200","bear-bg-white bear-text-gray-900 bear-border-gray-300","focus:bear-ring-2 focus:bear-ring-offset-2 focus:bear-ring-offset-white","dark:bear-bg-gray-800 dark:bear-text-white dark:bear-border-gray-600 dark:focus:bear-ring-offset-gray-900",k?"bear-border-red-500 focus:bear-ring-red-500":"focus:bear-border-bear-500 focus:bear-ring-bear-500 dark:focus:bear-border-bear-500 dark:focus:bear-ring-bear-500",n&&"bear-opacity-50 bear-cursor-not-allowed",j[m],h),children:[r.jsx("span",{className:b?"bear-text-gray-900 dark:bear-text-white":"bear-text-gray-500 dark:bear-text-gray-500",children:(b==null?void 0:b.label)||g}),r.jsx(f.ChevronDownIcon,{className:a.cn("bear-w-4 bear-h-4 bear-text-gray-500 dark:bear-text-gray-400 bear-transition-transform",c&&"bear-rotate-180")})]}),c&&r.jsx("div",{className:a.cn("bear-absolute bear-z-50 bear-w-full bear-mt-1","bear-rounded-lg bear-border bear-shadow-lg bear-overflow-hidden bear-top-full","bear-bg-white bear-border-gray-200 dark:bear-bg-gray-800 dark:bear-border-gray-600"),children:r.jsx("div",{className:"bear-max-h-60 bear-overflow-y-auto",children:u.map(e=>r.jsxs("button",{type:"button",disabled:e.disabled,onClick:()=>!e.disabled&&w(e.value),className:a.cn("bear-flex bear-items-center bear-justify-between bear-w-full bear-px-4 bear-py-2","bear-text-left bear-transition-colors",e.disabled?"bear-text-gray-500 bear-cursor-not-allowed":"bear-text-gray-700 dark:bear-text-gray-300 hover:bear-bg-gray-100 hover:bear-text-gray-900 dark:hover:bear-bg-gray-700 dark:hover:bear-text-white",e.value===t&&"bear-bg-bear-100 bear-text-bear-700 dark:bear-bg-bear-600/20 dark:bear-text-bear-300"),children:[e.label,e.value===t&&r.jsx(f.CheckIcon,{className:"bear-w-4 bear-h-4 bear-text-bear-600 dark:bear-text-bear-400"})]},e.value))})}),l&&r.jsx("p",{className:"bear-text-sm bear-text-red-500",children:l})]})};exports.Select=N;
|
|
@@ -1,94 +1,94 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useState as
|
|
1
|
+
import { jsxs as i, jsx as r } from "react/jsx-runtime";
|
|
2
|
+
import { useState as v, useRef as p, useEffect as N } from "react";
|
|
3
3
|
import { cn as a } from "../../utils/cn.js";
|
|
4
|
-
import { ChevronDownIcon as
|
|
4
|
+
import { ChevronDownIcon as j, CheckIcon as E } from "../Icon/index.js";
|
|
5
5
|
const S = {
|
|
6
6
|
sm: "bear-h-8 bear-text-sm bear-px-3",
|
|
7
7
|
md: "bear-h-10 bear-text-base bear-px-4",
|
|
8
8
|
lg: "bear-h-12 bear-text-lg bear-px-5"
|
|
9
9
|
}, O = ({
|
|
10
|
-
options:
|
|
10
|
+
options: f,
|
|
11
11
|
value: t,
|
|
12
12
|
onChange: s,
|
|
13
|
-
placeholder:
|
|
13
|
+
placeholder: g = "Select an option",
|
|
14
14
|
label: u,
|
|
15
15
|
error: l,
|
|
16
16
|
disabled: o = !1,
|
|
17
17
|
size: x = "md",
|
|
18
|
-
fullWidth:
|
|
19
|
-
className:
|
|
18
|
+
fullWidth: m = !1,
|
|
19
|
+
className: y
|
|
20
20
|
}) => {
|
|
21
|
-
const [
|
|
22
|
-
|
|
23
|
-
const e = (
|
|
24
|
-
|
|
21
|
+
const [d, n] = v(!1), c = p(null), h = !!l, b = f.find((e) => e.value === t);
|
|
22
|
+
N(() => {
|
|
23
|
+
const e = (w) => {
|
|
24
|
+
c.current && !c.current.contains(w.target) && n(!1);
|
|
25
25
|
};
|
|
26
26
|
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
27
27
|
}, []);
|
|
28
|
-
const
|
|
29
|
-
s == null || s(e),
|
|
28
|
+
const k = (e) => {
|
|
29
|
+
s == null || s(e), n(!1);
|
|
30
30
|
};
|
|
31
|
-
return /* @__PURE__ */
|
|
31
|
+
return /* @__PURE__ */ i(
|
|
32
32
|
"div",
|
|
33
33
|
{
|
|
34
|
-
ref:
|
|
35
|
-
className: a("bear-relative bear-flex bear-flex-col bear-gap-1.5",
|
|
34
|
+
ref: c,
|
|
35
|
+
className: a("bear-relative bear-flex bear-flex-col bear-gap-1.5", m && "bear-w-full"),
|
|
36
36
|
children: [
|
|
37
|
-
u && /* @__PURE__ */ r("label", { className: "bear-text-sm bear-font-medium bear-text-gray-300", children: u }),
|
|
38
|
-
/* @__PURE__ */
|
|
37
|
+
u && /* @__PURE__ */ r("label", { className: "bear-text-sm bear-font-medium bear-text-gray-700 dark:bear-text-gray-300", children: u }),
|
|
38
|
+
/* @__PURE__ */ i(
|
|
39
39
|
"button",
|
|
40
40
|
{
|
|
41
41
|
type: "button",
|
|
42
42
|
disabled: o,
|
|
43
|
-
onClick: () => !o &&
|
|
43
|
+
onClick: () => !o && n(!d),
|
|
44
44
|
className: a(
|
|
45
45
|
"bear-flex bear-items-center bear-justify-between bear-w-full",
|
|
46
|
-
"bear-rounded-lg bear-border bear-
|
|
47
|
-
"bear-
|
|
48
|
-
"focus:bear-ring-2 focus:bear-ring-offset-2 focus:bear-ring-offset-
|
|
49
|
-
|
|
46
|
+
"bear-rounded-lg bear-border bear-text-left bear-outline-none bear-transition-all bear-duration-200",
|
|
47
|
+
"bear-bg-white bear-text-gray-900 bear-border-gray-300",
|
|
48
|
+
"focus:bear-ring-2 focus:bear-ring-offset-2 focus:bear-ring-offset-white",
|
|
49
|
+
"dark:bear-bg-gray-800 dark:bear-text-white dark:bear-border-gray-600 dark:focus:bear-ring-offset-gray-900",
|
|
50
|
+
h ? "bear-border-red-500 focus:bear-ring-red-500" : "focus:bear-border-bear-500 focus:bear-ring-bear-500 dark:focus:bear-border-bear-500 dark:focus:bear-ring-bear-500",
|
|
50
51
|
o && "bear-opacity-50 bear-cursor-not-allowed",
|
|
51
52
|
S[x],
|
|
52
|
-
|
|
53
|
+
y
|
|
53
54
|
),
|
|
54
55
|
children: [
|
|
55
|
-
/* @__PURE__ */ r("span", { className: b ? "bear-text-white" : "bear-text-gray-500", children: (b == null ? void 0 : b.label) ||
|
|
56
|
+
/* @__PURE__ */ r("span", { className: b ? "bear-text-gray-900 dark:bear-text-white" : "bear-text-gray-500 dark:bear-text-gray-500", children: (b == null ? void 0 : b.label) || g }),
|
|
56
57
|
/* @__PURE__ */ r(
|
|
57
|
-
|
|
58
|
+
j,
|
|
58
59
|
{
|
|
59
60
|
className: a(
|
|
60
|
-
"bear-w-4 bear-h-4 bear-text-gray-400 bear-transition-transform",
|
|
61
|
-
|
|
61
|
+
"bear-w-4 bear-h-4 bear-text-gray-500 dark:bear-text-gray-400 bear-transition-transform",
|
|
62
|
+
d && "bear-rotate-180"
|
|
62
63
|
)
|
|
63
64
|
}
|
|
64
65
|
)
|
|
65
66
|
]
|
|
66
67
|
}
|
|
67
68
|
),
|
|
68
|
-
|
|
69
|
+
d && /* @__PURE__ */ r(
|
|
69
70
|
"div",
|
|
70
71
|
{
|
|
71
72
|
className: a(
|
|
72
73
|
"bear-absolute bear-z-50 bear-w-full bear-mt-1",
|
|
73
|
-
"bear-rounded-lg bear-border bear-
|
|
74
|
-
"bear-
|
|
75
|
-
"bear-top-full"
|
|
74
|
+
"bear-rounded-lg bear-border bear-shadow-lg bear-overflow-hidden bear-top-full",
|
|
75
|
+
"bear-bg-white bear-border-gray-200 dark:bear-bg-gray-800 dark:bear-border-gray-600"
|
|
76
76
|
),
|
|
77
|
-
children: /* @__PURE__ */ r("div", { className: "bear-max-h-60 bear-overflow-y-auto", children:
|
|
77
|
+
children: /* @__PURE__ */ r("div", { className: "bear-max-h-60 bear-overflow-y-auto", children: f.map((e) => /* @__PURE__ */ i(
|
|
78
78
|
"button",
|
|
79
79
|
{
|
|
80
80
|
type: "button",
|
|
81
81
|
disabled: e.disabled,
|
|
82
|
-
onClick: () => !e.disabled &&
|
|
82
|
+
onClick: () => !e.disabled && k(e.value),
|
|
83
83
|
className: a(
|
|
84
84
|
"bear-flex bear-items-center bear-justify-between bear-w-full bear-px-4 bear-py-2",
|
|
85
85
|
"bear-text-left bear-transition-colors",
|
|
86
|
-
e.disabled ? "bear-text-gray-500 bear-cursor-not-allowed" : "bear-text-gray-300 hover:bear-bg-gray-700 hover:bear-text-white",
|
|
87
|
-
e.value === t && "bear-bg-bear-600/20 bear-text-bear-
|
|
86
|
+
e.disabled ? "bear-text-gray-500 bear-cursor-not-allowed" : "bear-text-gray-700 dark:bear-text-gray-300 hover:bear-bg-gray-100 hover:bear-text-gray-900 dark:hover:bear-bg-gray-700 dark:hover:bear-text-white",
|
|
87
|
+
e.value === t && "bear-bg-bear-100 bear-text-bear-700 dark:bear-bg-bear-600/20 dark:bear-text-bear-300"
|
|
88
88
|
),
|
|
89
89
|
children: [
|
|
90
90
|
e.label,
|
|
91
|
-
e.value === t && /* @__PURE__ */ r(E, { className: "bear-w-4 bear-h-4 bear-text-bear-400" })
|
|
91
|
+
e.value === t && /* @__PURE__ */ r(E, { className: "bear-w-4 bear-h-4 bear-text-bear-600 dark:bear-text-bear-400" })
|
|
92
92
|
]
|
|
93
93
|
},
|
|
94
94
|
e.value
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),i=require("../../utils/cn.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),i=require("../../utils/cn.cjs"),t=require("../Icon/index.cjs"),p=require("./components/SidebarItem/SidebarItem.cjs"),a=require("./Sidebar.const.cjs"),L=S=>{const{items:b,collapsed:r=!1,onCollapsedChange:d,width:_=a.SIDEBAR_WIDTH,collapsedWidth:I=a.SIDEBAR_COLLAPSED_WIDTH,header:o,footer:c,showHeader:E=!0,activeItemId:h,onItemClick:u,activeVariant:f="fill",fullHeight:A=!1,variant:s="default",position:l="left",className:C,style:x,testId:B,id:R}=S,m=r?I:_,v=l==="left"?"bear-border-r":"bear-border-l",D=E&&o;return e.jsxs("aside",{id:R,"data-testid":B,className:i.cn("Bear-Sidebar",`Bear-Sidebar--${s}`,r&&"Bear-Sidebar--collapsed","bear-flex bear-flex-col bear-h-full bear-transition-all bear-duration-300",A&&"bear-min-h-full",s==="default"&&v,a.SIDEBAR_VARIANT_STYLES[s],C),style:{width:m,...x},children:[D&&e.jsxs("div",{className:i.cn("Bear-Sidebar__header",a.SIDEBAR_HEADER_CLASSES),children:[!r&&o,d&&e.jsx("button",{type:"button",onClick:()=>d(!r),className:i.cn("Bear-Sidebar__toggle",a.SIDEBAR_TOGGLE_CLASSES),"aria-label":r?"Expand sidebar":"Collapse sidebar",children:r?l==="left"?e.jsx(t.ChevronRightIcon,{size:a.SIDEBAR_TOGGLE_ICON_SIZE}):e.jsx(t.ChevronLeftIcon,{size:a.SIDEBAR_TOGGLE_ICON_SIZE}):l==="left"?e.jsx(t.ChevronLeftIcon,{size:a.SIDEBAR_TOGGLE_ICON_SIZE}):e.jsx(t.ChevronRightIcon,{size:a.SIDEBAR_TOGGLE_ICON_SIZE})})]}),e.jsx("nav",{className:"Bear-Sidebar__nav bear-flex-1 bear-overflow-y-auto bear-px-2 bear-py-3 bear-space-y-1 bear-min-h-0",children:b.map(n=>e.jsx(p.SidebarItem,{item:n,isActive:n.id===h,collapsed:r,onClick:u,activeVariant:f},n.id))}),c&&e.jsx("div",{className:i.cn("Bear-Sidebar__footer",a.SIDEBAR_FOOTER_CLASSES),children:r?null:c})]})};exports.Sidebar=L;
|