@forgedevstack/bear 1.1.8 → 1.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/dist/components/BearLogo/BearLogo.d.ts +2 -7
- package/dist/components/BearLogo/BearLogo.types.d.ts +15 -0
- package/dist/components/BearLogo/EmberLogo.d.ts +1 -8
- package/dist/components/BearLogo/index.d.ts +1 -2
- package/dist/components/Biometric/Biometric.cjs +1 -0
- package/dist/components/Biometric/Biometric.d.ts +3 -0
- package/dist/components/Biometric/Biometric.js +123 -0
- package/dist/components/Biometric/Biometric.types.d.ts +35 -0
- package/dist/components/Biometric/BiometricIcon.cjs +1 -0
- package/dist/components/Biometric/BiometricIcon.d.ts +3 -0
- package/dist/components/Biometric/BiometricIcon.js +45 -0
- package/dist/components/Biometric/index.d.ts +3 -0
- package/dist/components/Biometric/useBiometric.cjs +1 -0
- package/dist/components/Biometric/useBiometric.d.ts +2 -0
- package/dist/components/Biometric/useBiometric.js +21 -0
- package/dist/components/DateRangePicker/DateRangePicker.cjs +1 -1
- package/dist/components/DateRangePicker/DateRangePicker.const.cjs +1 -1
- package/dist/components/DateRangePicker/DateRangePicker.const.js +12 -13
- package/dist/components/DateRangePicker/DateRangePicker.js +107 -81
- package/dist/components/Dropdown/Dropdown.cjs +1 -1
- package/dist/components/Dropdown/Dropdown.js +48 -44
- package/dist/components/Input/Input.cjs +1 -1
- package/dist/components/Input/Input.js +153 -101
- package/dist/components/Input/Input.types.d.ts +8 -2
- package/dist/components/Input/index.d.ts +1 -1
- package/dist/components/Popover/Popover.cjs +1 -1
- package/dist/components/Popover/Popover.js +76 -76
- package/dist/components/Select/Select.cjs +1 -1
- package/dist/components/Select/Select.js +41 -38
- package/dist/components/Tabs/TabList.cjs +1 -0
- package/dist/components/Tabs/TabList.d.ts +3 -0
- package/dist/components/Tabs/TabList.js +69 -0
- package/dist/components/Tabs/TabPanel.cjs +1 -0
- package/dist/components/Tabs/TabPanel.d.ts +3 -0
- package/dist/components/Tabs/TabPanel.js +13 -0
- package/dist/components/Tabs/Tabs.cjs +1 -1
- package/dist/components/Tabs/Tabs.d.ts +2 -27
- package/dist/components/Tabs/Tabs.js +42 -61
- package/dist/components/Tabs/Tabs.types.d.ts +4 -0
- package/dist/components/Tabs/index.d.ts +3 -1
- package/dist/components/index.cjs +1 -1
- package/dist/components/index.d.ts +5 -2
- package/dist/components/index.js +316 -309
- package/dist/index.cjs +1 -1
- package/dist/index.js +391 -384
- package/dist/styles.css +1 -1
- package/package.json +1 -1
|
@@ -1,37 +1,38 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useState as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
/* @__PURE__ */
|
|
12
|
-
|
|
1
|
+
import { jsxs as i, jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import { useState as u, useRef as P, useEffect as T, useCallback as v } from "react";
|
|
3
|
+
import { createPortal as se } from "react-dom";
|
|
4
|
+
import { cn as p } from "../../utils/cn.js";
|
|
5
|
+
import { getDefaultPresets as oe, LABEL_CLASSES as le, SIZE_CLASSES as ce, TRIGGER_CLASSES as ie, PRESET_BTN_CLASSES as $, ERROR_CLASSES as de, HELPER_CLASSES as be, ROOT_CLASSES as me, CALENDAR_HEADER_CLASSES as ue, NAV_BTN_CLASSES as G, MONTH_LABELS as pe, DAY_LABELS as he, DAY_TODAY_CLASSES as Se, DAY_IN_RANGE_CLASSES as fe, DAY_SELECTED_CLASSES as ge, DAY_DISABLED_CLASSES as Ee, DAY_HOVER_CLASSES as Le, DAY_BASE_CLASSES as ke } from "./DateRangePicker.const.js";
|
|
6
|
+
import { formatDate as W, getCalendarDays as Ae, isSameDay as Y, isInRange as Ne } from "./DateRangePicker.utils.js";
|
|
7
|
+
const F = ({ year: E, month: c, range: r, onDayClick: L, onNav: k, minDate: d, maxDate: A }) => {
|
|
8
|
+
const N = Ae(E, c), h = /* @__PURE__ */ new Date();
|
|
9
|
+
return h.setHours(0, 0, 0, 0), /* @__PURE__ */ i("div", { className: "bear-w-64", children: [
|
|
10
|
+
/* @__PURE__ */ i("div", { className: ue, children: [
|
|
11
|
+
/* @__PURE__ */ t("button", { type: "button", onClick: () => k(-1), className: G, "aria-label": "Previous month", children: /* @__PURE__ */ t("svg", { className: "bear-w-4 bear-h-4", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ t("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M15 19l-7-7 7-7" }) }) }),
|
|
12
|
+
/* @__PURE__ */ i("span", { className: "bear-text-sm bear-font-semibold bear-text-gray-900 dark:bear-text-white", children: [
|
|
13
|
+
pe[c],
|
|
13
14
|
" ",
|
|
14
|
-
|
|
15
|
+
E
|
|
15
16
|
] }),
|
|
16
|
-
/* @__PURE__ */
|
|
17
|
+
/* @__PURE__ */ t("button", { type: "button", onClick: () => k(1), className: G, "aria-label": "Next month", children: /* @__PURE__ */ t("svg", { className: "bear-w-4 bear-h-4", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ t("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M9 5l7 7-7 7" }) }) })
|
|
17
18
|
] }),
|
|
18
|
-
/* @__PURE__ */
|
|
19
|
-
/* @__PURE__ */
|
|
20
|
-
if (!a) return /* @__PURE__ */
|
|
21
|
-
const S =
|
|
22
|
-
return /* @__PURE__ */
|
|
19
|
+
/* @__PURE__ */ t("div", { className: "bear-grid bear-grid-cols-7 bear-gap-0.5 bear-mb-1", children: he.map((a) => /* @__PURE__ */ t("div", { className: "bear-text-xs bear-text-center bear-font-medium bear-text-gray-400 dark:bear-text-zinc-500 bear-py-1", children: a }, a)) }),
|
|
20
|
+
/* @__PURE__ */ t("div", { className: "bear-grid bear-grid-cols-7 bear-gap-0.5", children: N.map((a, x) => {
|
|
21
|
+
if (!a) return /* @__PURE__ */ t("div", {}, `e-${x}`);
|
|
22
|
+
const S = d && a < d || A && a > A, l = Y(a, r.start) || Y(a, r.end), b = Ne(a, r.start, r.end), _ = Y(a, h);
|
|
23
|
+
return /* @__PURE__ */ t(
|
|
23
24
|
"button",
|
|
24
25
|
{
|
|
25
26
|
type: "button",
|
|
26
27
|
disabled: !!S,
|
|
27
|
-
onClick: () =>
|
|
28
|
-
className:
|
|
29
|
-
|
|
30
|
-
S ?
|
|
31
|
-
l &&
|
|
32
|
-
!l &&
|
|
33
|
-
!l && !
|
|
34
|
-
!l && !
|
|
28
|
+
onClick: () => L(a),
|
|
29
|
+
className: p(
|
|
30
|
+
ke,
|
|
31
|
+
S ? Ee : Le,
|
|
32
|
+
l && ge,
|
|
33
|
+
!l && b && fe,
|
|
34
|
+
!l && !b && _ && Se,
|
|
35
|
+
!l && !b && !S && "bear-text-gray-700 dark:bear-text-zinc-300"
|
|
35
36
|
),
|
|
36
37
|
children: a.getDate()
|
|
37
38
|
},
|
|
@@ -39,77 +40,102 @@ const H = ({ year: L, month: o, range: r, onDayClick: A, onNav: N, minDate: i, m
|
|
|
39
40
|
);
|
|
40
41
|
}) })
|
|
41
42
|
] });
|
|
42
|
-
},
|
|
43
|
+
}, Re = (E) => {
|
|
43
44
|
const {
|
|
44
|
-
value:
|
|
45
|
+
value: c,
|
|
45
46
|
onChange: r,
|
|
46
|
-
label:
|
|
47
|
-
placeholder:
|
|
48
|
-
disabled:
|
|
49
|
-
clearable:
|
|
50
|
-
minDate:
|
|
51
|
-
maxDate:
|
|
47
|
+
label: L,
|
|
48
|
+
placeholder: k = "Select date range",
|
|
49
|
+
disabled: d = !1,
|
|
50
|
+
clearable: A = !0,
|
|
51
|
+
minDate: N,
|
|
52
|
+
maxDate: h,
|
|
52
53
|
presets: a,
|
|
53
|
-
showPresets:
|
|
54
|
+
showPresets: x = !0,
|
|
54
55
|
size: S = "md",
|
|
55
56
|
error: l,
|
|
56
|
-
helperText:
|
|
57
|
-
className:
|
|
58
|
-
testId:
|
|
59
|
-
...
|
|
60
|
-
} =
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}, [
|
|
64
|
-
|
|
65
|
-
|
|
57
|
+
helperText: b,
|
|
58
|
+
className: _,
|
|
59
|
+
testId: Z,
|
|
60
|
+
...q
|
|
61
|
+
} = E, [w, D] = u(!1), [H, J] = u({ top: 0, left: 0 }), [s, f] = u(c ?? { start: null, end: null }), [M, C] = u("start"), z = P(null), R = P(null), O = P(null), I = /* @__PURE__ */ new Date(), [m, K] = u(I.getMonth()), [g, Q] = u(I.getFullYear()), U = m === 11 ? 0 : m + 1, X = m === 11 ? g + 1 : g;
|
|
62
|
+
T(() => {
|
|
63
|
+
c && f(c);
|
|
64
|
+
}, [c]), T(() => {
|
|
65
|
+
if (w && R.current) {
|
|
66
|
+
const e = R.current.getBoundingClientRect(), n = 8, o = 400, ne = window.innerHeight - e.bottom < o && e.top > o;
|
|
67
|
+
J({
|
|
68
|
+
top: ne ? e.top - o - n : e.bottom + n,
|
|
69
|
+
left: e.left
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
}, [w]), T(() => {
|
|
73
|
+
const e = (n) => {
|
|
74
|
+
var y, B;
|
|
75
|
+
const o = n.target;
|
|
76
|
+
(y = z.current) != null && y.contains(o) || (B = O.current) != null && B.contains(o) || D(!1);
|
|
66
77
|
};
|
|
67
|
-
return document.addEventListener("mousedown",
|
|
78
|
+
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
68
79
|
}, []);
|
|
69
|
-
const
|
|
70
|
-
if (
|
|
71
|
-
|
|
80
|
+
const j = v((e) => {
|
|
81
|
+
if (M === "start")
|
|
82
|
+
f({ start: e, end: null }), C("end");
|
|
72
83
|
else {
|
|
73
|
-
const n =
|
|
74
|
-
|
|
84
|
+
const n = e >= (s.start ?? e) ? { start: s.start, end: e } : { start: e, end: s.start };
|
|
85
|
+
f(n), C("start"), r == null || r(n);
|
|
75
86
|
}
|
|
76
|
-
}, [
|
|
77
|
-
|
|
78
|
-
}, [r]),
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
}, [r]),
|
|
82
|
-
let n =
|
|
83
|
-
n < 0 && (n = 11,
|
|
84
|
-
}, [
|
|
85
|
-
return /* @__PURE__ */
|
|
86
|
-
|
|
87
|
-
/* @__PURE__ */
|
|
87
|
+
}, [M, s.start, r]), ee = v((e) => {
|
|
88
|
+
f(e), r == null || r(e), D(!1), C("start");
|
|
89
|
+
}, [r]), te = v(() => {
|
|
90
|
+
const e = { start: null, end: null };
|
|
91
|
+
f(e), r == null || r(e), C("start");
|
|
92
|
+
}, [r]), re = v((e) => {
|
|
93
|
+
let n = m + e, o = g;
|
|
94
|
+
n < 0 && (n = 11, o--), n > 11 && (n = 0, o++), K(n), Q(o);
|
|
95
|
+
}, [m, g]), V = a ?? (x ? oe() : []), ae = s.start ? `${W(s.start)}${s.end ? ` – ${W(s.end)}` : ""}` : k;
|
|
96
|
+
return /* @__PURE__ */ i("div", { ref: z, className: p(me, _), "data-testid": Z, ...q, children: [
|
|
97
|
+
L && /* @__PURE__ */ t("label", { className: le, children: L }),
|
|
98
|
+
/* @__PURE__ */ i(
|
|
88
99
|
"button",
|
|
89
100
|
{
|
|
101
|
+
ref: R,
|
|
90
102
|
type: "button",
|
|
91
|
-
disabled:
|
|
92
|
-
onClick: () => !
|
|
93
|
-
className:
|
|
103
|
+
disabled: d,
|
|
104
|
+
onClick: () => !d && D(!w),
|
|
105
|
+
className: p(ie, ce[S], d && "bear-opacity-50 bear-cursor-not-allowed"),
|
|
94
106
|
children: [
|
|
95
|
-
/* @__PURE__ */
|
|
96
|
-
/* @__PURE__ */
|
|
107
|
+
/* @__PURE__ */ t("span", { className: p(!s.start && "bear-text-gray-400 dark:bear-text-zinc-500"), children: ae }),
|
|
108
|
+
/* @__PURE__ */ t("svg", { className: "bear-w-4 bear-h-4 bear-ml-2 bear-text-gray-400", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ t("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z" }) })
|
|
97
109
|
]
|
|
98
110
|
}
|
|
99
111
|
),
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
112
|
+
w && typeof document < "u" && se(
|
|
113
|
+
/* @__PURE__ */ t(
|
|
114
|
+
"div",
|
|
115
|
+
{
|
|
116
|
+
ref: O,
|
|
117
|
+
"data-bear-daterangepicker-dropdown": !0,
|
|
118
|
+
className: p(
|
|
119
|
+
"bear-fixed bear-z-[9999] bear-bg-white dark:bear-bg-zinc-800 bear-border bear-border-gray-200 dark:bear-border-zinc-700 bear-rounded-xl bear-shadow-xl bear-p-4"
|
|
120
|
+
),
|
|
121
|
+
style: { top: H.top, left: H.left },
|
|
122
|
+
children: /* @__PURE__ */ i("div", { className: "bear-flex bear-gap-4", children: [
|
|
123
|
+
V.length > 0 && /* @__PURE__ */ i("div", { className: "bear-border-r bear-border-gray-200 dark:bear-border-zinc-700 bear-pr-3 bear-space-y-1 bear-min-w-[120px]", children: [
|
|
124
|
+
V.map((e) => /* @__PURE__ */ t("button", { type: "button", onClick: () => ee(e.range()), className: $, children: e.label }, e.label)),
|
|
125
|
+
A && s.start && /* @__PURE__ */ t("button", { type: "button", onClick: te, className: p($, "bear-text-red-500"), children: "Clear" })
|
|
126
|
+
] }),
|
|
127
|
+
/* @__PURE__ */ t(F, { year: g, month: m, range: s, onDayClick: j, onNav: re, minDate: N, maxDate: h }),
|
|
128
|
+
/* @__PURE__ */ t(F, { year: X, month: U, range: s, onDayClick: j, onNav: () => {
|
|
129
|
+
}, minDate: N, maxDate: h })
|
|
130
|
+
] })
|
|
131
|
+
}
|
|
132
|
+
),
|
|
133
|
+
document.body
|
|
134
|
+
),
|
|
135
|
+
l && /* @__PURE__ */ t("p", { className: de, children: l }),
|
|
136
|
+
!l && b && /* @__PURE__ */ t("p", { className: be, children: b })
|
|
111
137
|
] });
|
|
112
138
|
};
|
|
113
139
|
export {
|
|
114
|
-
|
|
140
|
+
Re as DateRangePicker
|
|
115
141
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),r=require("react"),h=require("../../utils/cn.cjs"),B=require("../../hooks/useClickOutside.cjs");require("../../context/BearProvider.cjs");require("../../hooks/useBearComponent/useBearComponent.cjs");const K={xs:"bear-text-xs bear-py-1 bear-px-2",sm:"bear-text-sm bear-py-1.5 bear-px-3",md:"bear-text-sm bear-py-2 bear-px-3",lg:"bear-text-base bear-py-2.5 bear-px-4",xl:"bear-text-lg bear-py-3 bear-px-5"},U={"bottom-start":"bear-top-full bear-left-0 bear-mt-1","bottom-end":"bear-top-full bear-right-0 bear-mt-1",bottom:"bear-top-full bear-left-1/2 -bear-translate-x-1/2 bear-mt-1","top-start":"bear-bottom-full bear-left-0 bear-mb-1","top-end":"bear-bottom-full bear-right-0 bear-mb-1",top:"bear-bottom-full bear-left-1/2 -bear-translate-x-1/2 bear-mb-1",left:"bear-right-full bear-top-0 bear-mr-1",right:"bear-left-full bear-top-0 bear-ml-1"},V=({trigger:x,items:i,open:k,defaultOpen:j=!1,placement:N="bottom-start",offset:Z=4,matchWidth:S=!1,minWidth:D=150,maxHeight:I=300,size:R="md",closeOnSelect:y=!0,closeOnClickOutside:g=!0,disabled:m=!1,onOpenChange:u,className:q,testId:A,...L})=>{var C;const[M,W]=r.useState(j),[o,d]=r.useState(-1),w=r.useRef(null),z=r.useRef(null),E=r.useRef(null),p=k!==void 0,t=p?k:M,f=r.useCallback(e=>{p||W(e),u==null||u(e)},[p,u]),F=r.useCallback(()=>{m||f(!t)},[m,t,f]),n=r.useCallback(()=>{f(!1),d(-1)},[f]),v=r.useCallback(e=>{var b;e.disabled||e.divider||e.header||((b=e.onClick)==null||b.call(e),y&&!e.items&&n())},[y,n]),P=r.useCallback(()=>{t&&g&&n()},[t,g,n]);B.useClickOutside(w,P),r.useEffect(()=>{if(!t)return;const e=i.filter(a=>!a.disabled&&!a.divider&&!a.header),b=a=>{switch(a.key){case"Escape":a.preventDefault(),n();break;case"ArrowDown":a.preventDefault(),d(c=>{const l=c+1;return l>=e.length?0:l});break;case"ArrowUp":a.preventDefault(),d(c=>{const l=c-1;return l<0?e.length-1:l});break;case"Enter":case" ":a.preventDefault(),o>=0&&o<e.length&&v(e[o]);break}};return document.addEventListener("keydown",b),()=>document.removeEventListener("keydown",b)},[t,i,o,n,v]),r.useEffect(()=>{t||d(-1)},[t]);const T=(e,b)=>{if(e.divider)return s.jsx("div",{className:"bear-my-1 bear-mx-2 bear-h-px",style:{backgroundColor:"var(--bear-border-default)"},role:"separator"},e.key);if(e.header)return s.jsx("div",{className:"bear-px-3 bear-py-1.5 bear-text-xs bear-font-semibold bear-uppercase bear-tracking-wider",style:{color:"var(--bear-text-muted)"},children:e.label},e.key);const a=i.slice(0,b).filter(l=>!l.disabled&&!l.divider&&!l.header).length,c=o===a;return s.jsxs("button",{type:"button",role:"menuitem",disabled:e.disabled,onClick:()=>v(e),onMouseEnter:()=>d(a),className:h.cn("bear-w-full bear-flex bear-items-center bear-gap-2 bear-text-left bear-border-none bear-bg-transparent",K[R],"bear-transition-colors bear-cursor-pointer",c&&!e.danger&&"bear-bg-[var(--bear-bg-tertiary)]",e.danger&&"bear-text-red-600 dark:bear-text-red-400 hover:bear-bg-red-50 dark:hover:bear-bg-red-900/20",!e.danger&&!e.disabled&&"hover:bear-bg-[var(--bear-bg-tertiary)]",e.disabled&&"bear-opacity-50 bear-cursor-not-allowed bear-pointer-events-none"),style:e.disabled?{color:"var(--bear-text-muted)"}:e.danger?void 0:{color:"var(--bear-text-secondary)"},children:[e.icon&&s.jsx("span",{className:"bear-flex-shrink-0 bear-w-5 bear-h-5 bear-flex bear-items-center bear-justify-center",children:e.icon}),s.jsx("span",{className:"bear-flex-1",children:e.label}),e.trailing&&s.jsx("span",{className:"bear-flex-shrink-0",style:{color:"var(--bear-text-muted)"},children:e.trailing}),e.items&&s.jsx("svg",{className:"bear-w-4 bear-h-4 bear-flex-shrink-0",style:{color:"var(--bear-text-muted)"},viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:s.jsx("polyline",{points:"9 18 15 12 9 6"})})]},e.key)},_=r.isValidElement(x)?r.cloneElement(x,{onClick:F,ref:E,"aria-expanded":t,"aria-haspopup":!0}):x;return s.jsxs("div",{ref:w,className:h.cn("bear-relative bear-inline-block",q),"data-testid":A,...L,children:[_,t&&s.jsx("div",{ref:z,role:"menu",className:h.cn("bear-absolute bear-z-50","bear-border bear-rounded-lg bear-shadow-lg","bear-py-1 bear-overflow-y-auto","bear-animate-in bear-fade-in-0 bear-zoom-in-95 bear-duration-100",U[N]),style:{backgroundColor:"var(--bear-bg-primary)",borderColor:"var(--bear-border-default)",minWidth:S?(C=E.current)==null?void 0:C.offsetWidth:D,maxHeight:I},children:i.map((e,b)=>T(e,b))})]})};exports.Dropdown=V;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useState as
|
|
3
|
-
import { cn as
|
|
1
|
+
import { jsxs as I, jsx as o } from "react/jsx-runtime";
|
|
2
|
+
import { useState as D, useRef as v, useCallback as c, useEffect as S, isValidElement as q, cloneElement as G } from "react";
|
|
3
|
+
import { cn as h } from "../../utils/cn.js";
|
|
4
4
|
import { useClickOutside as H } from "../../hooks/useClickOutside.js";
|
|
5
5
|
import "../../context/BearProvider.js";
|
|
6
6
|
import "../../hooks/useBearComponent/useBearComponent.js";
|
|
@@ -21,8 +21,8 @@ const J = {
|
|
|
21
21
|
right: "bear-left-full bear-top-0 bear-ml-1"
|
|
22
22
|
}, te = ({
|
|
23
23
|
trigger: p,
|
|
24
|
-
items:
|
|
25
|
-
open:
|
|
24
|
+
items: i,
|
|
25
|
+
open: y,
|
|
26
26
|
defaultOpen: A = !1,
|
|
27
27
|
placement: L = "bottom-start",
|
|
28
28
|
offset: X = 4,
|
|
@@ -30,33 +30,33 @@ const J = {
|
|
|
30
30
|
minWidth: j = 150,
|
|
31
31
|
maxHeight: W = 300,
|
|
32
32
|
size: z = "md",
|
|
33
|
-
closeOnSelect:
|
|
34
|
-
closeOnClickOutside:
|
|
33
|
+
closeOnSelect: g = !0,
|
|
34
|
+
closeOnClickOutside: k = !0,
|
|
35
35
|
disabled: w = !1,
|
|
36
36
|
onOpenChange: f,
|
|
37
37
|
className: F,
|
|
38
38
|
testId: M,
|
|
39
39
|
..._
|
|
40
40
|
}) => {
|
|
41
|
-
var
|
|
42
|
-
const [B, K] =
|
|
41
|
+
var C;
|
|
42
|
+
const [B, K] = D(A), [n, s] = D(-1), E = v(null), P = v(null), N = v(null), x = y !== void 0, a = x ? y : B, u = c((e) => {
|
|
43
43
|
x || K(e), f == null || f(e);
|
|
44
|
-
}, [x, f]), T =
|
|
44
|
+
}, [x, f]), T = c(() => {
|
|
45
45
|
w || u(!a);
|
|
46
|
-
}, [w, a, u]),
|
|
46
|
+
}, [w, a, u]), l = c(() => {
|
|
47
47
|
u(!1), s(-1);
|
|
48
|
-
}, [u]),
|
|
48
|
+
}, [u]), m = c((e) => {
|
|
49
49
|
var t;
|
|
50
|
-
e.disabled || e.divider || e.header || ((t = e.onClick) == null || t.call(e),
|
|
51
|
-
}, [
|
|
52
|
-
a &&
|
|
53
|
-
}, [a,
|
|
54
|
-
H(E, U),
|
|
50
|
+
e.disabled || e.divider || e.header || ((t = e.onClick) == null || t.call(e), g && !e.items && l());
|
|
51
|
+
}, [g, l]), U = c(() => {
|
|
52
|
+
a && k && l();
|
|
53
|
+
}, [a, k, l]);
|
|
54
|
+
H(E, U), S(() => {
|
|
55
55
|
if (!a) return;
|
|
56
|
-
const e =
|
|
56
|
+
const e = i.filter((r) => !r.disabled && !r.divider && !r.header), t = (r) => {
|
|
57
57
|
switch (r.key) {
|
|
58
58
|
case "Escape":
|
|
59
|
-
r.preventDefault(),
|
|
59
|
+
r.preventDefault(), l();
|
|
60
60
|
break;
|
|
61
61
|
case "ArrowDown":
|
|
62
62
|
r.preventDefault(), s((d) => {
|
|
@@ -72,55 +72,59 @@ const J = {
|
|
|
72
72
|
break;
|
|
73
73
|
case "Enter":
|
|
74
74
|
case " ":
|
|
75
|
-
r.preventDefault(),
|
|
75
|
+
r.preventDefault(), n >= 0 && n < e.length && m(e[n]);
|
|
76
76
|
break;
|
|
77
77
|
}
|
|
78
78
|
};
|
|
79
79
|
return document.addEventListener("keydown", t), () => document.removeEventListener("keydown", t);
|
|
80
|
-
}, [a,
|
|
80
|
+
}, [a, i, n, l, m]), S(() => {
|
|
81
81
|
a || s(-1);
|
|
82
82
|
}, [a]);
|
|
83
83
|
const V = (e, t) => {
|
|
84
84
|
if (e.divider)
|
|
85
|
-
return /* @__PURE__ */
|
|
85
|
+
return /* @__PURE__ */ o(
|
|
86
86
|
"div",
|
|
87
87
|
{
|
|
88
|
-
className: "bear-my-1 bear-mx-2 bear-h-px
|
|
88
|
+
className: "bear-my-1 bear-mx-2 bear-h-px",
|
|
89
|
+
style: { backgroundColor: "var(--bear-border-default)" },
|
|
89
90
|
role: "separator"
|
|
90
91
|
},
|
|
91
92
|
e.key
|
|
92
93
|
);
|
|
93
94
|
if (e.header)
|
|
94
|
-
return /* @__PURE__ */
|
|
95
|
+
return /* @__PURE__ */ o(
|
|
95
96
|
"div",
|
|
96
97
|
{
|
|
97
|
-
className: "bear-px-3 bear-py-1.5 bear-text-xs bear-font-semibold bear-uppercase bear-tracking-wider
|
|
98
|
+
className: "bear-px-3 bear-py-1.5 bear-text-xs bear-font-semibold bear-uppercase bear-tracking-wider",
|
|
99
|
+
style: { color: "var(--bear-text-muted)" },
|
|
98
100
|
children: e.label
|
|
99
101
|
},
|
|
100
102
|
e.key
|
|
101
103
|
);
|
|
102
|
-
const r =
|
|
103
|
-
return /* @__PURE__ */
|
|
104
|
+
const r = i.slice(0, t).filter((b) => !b.disabled && !b.divider && !b.header).length, d = n === r;
|
|
105
|
+
return /* @__PURE__ */ I(
|
|
104
106
|
"button",
|
|
105
107
|
{
|
|
106
108
|
type: "button",
|
|
107
109
|
role: "menuitem",
|
|
108
110
|
disabled: e.disabled,
|
|
109
|
-
onClick: () =>
|
|
111
|
+
onClick: () => m(e),
|
|
110
112
|
onMouseEnter: () => s(r),
|
|
111
|
-
className:
|
|
113
|
+
className: h(
|
|
112
114
|
"bear-w-full bear-flex bear-items-center bear-gap-2 bear-text-left bear-border-none bear-bg-transparent",
|
|
113
115
|
J[z],
|
|
114
116
|
"bear-transition-colors bear-cursor-pointer",
|
|
115
|
-
d && "bear-bg-
|
|
116
|
-
e.danger
|
|
117
|
+
d && !e.danger && "bear-bg-[var(--bear-bg-tertiary)]",
|
|
118
|
+
e.danger && "bear-text-red-600 dark:bear-text-red-400 hover:bear-bg-red-50 dark:hover:bear-bg-red-900/20",
|
|
119
|
+
!e.danger && !e.disabled && "hover:bear-bg-[var(--bear-bg-tertiary)]",
|
|
117
120
|
e.disabled && "bear-opacity-50 bear-cursor-not-allowed bear-pointer-events-none"
|
|
118
121
|
),
|
|
122
|
+
style: e.disabled ? { color: "var(--bear-text-muted)" } : e.danger ? void 0 : { color: "var(--bear-text-secondary)" },
|
|
119
123
|
children: [
|
|
120
|
-
e.icon && /* @__PURE__ */
|
|
121
|
-
/* @__PURE__ */
|
|
122
|
-
e.trailing && /* @__PURE__ */
|
|
123
|
-
e.items && /* @__PURE__ */
|
|
124
|
+
e.icon && /* @__PURE__ */ o("span", { className: "bear-flex-shrink-0 bear-w-5 bear-h-5 bear-flex bear-items-center bear-justify-center", children: e.icon }),
|
|
125
|
+
/* @__PURE__ */ o("span", { className: "bear-flex-1", children: e.label }),
|
|
126
|
+
e.trailing && /* @__PURE__ */ o("span", { className: "bear-flex-shrink-0", style: { color: "var(--bear-text-muted)" }, children: e.trailing }),
|
|
127
|
+
e.items && /* @__PURE__ */ o("svg", { className: "bear-w-4 bear-h-4 bear-flex-shrink-0", style: { color: "var(--bear-text-muted)" }, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: /* @__PURE__ */ o("polyline", { points: "9 18 15 12 9 6" }) })
|
|
124
128
|
]
|
|
125
129
|
},
|
|
126
130
|
e.key
|
|
@@ -131,34 +135,34 @@ const J = {
|
|
|
131
135
|
"aria-expanded": a,
|
|
132
136
|
"aria-haspopup": !0
|
|
133
137
|
}) : p;
|
|
134
|
-
return /* @__PURE__ */
|
|
138
|
+
return /* @__PURE__ */ I(
|
|
135
139
|
"div",
|
|
136
140
|
{
|
|
137
141
|
ref: E,
|
|
138
|
-
className:
|
|
142
|
+
className: h("bear-relative bear-inline-block", F),
|
|
139
143
|
"data-testid": M,
|
|
140
144
|
..._,
|
|
141
145
|
children: [
|
|
142
146
|
Z,
|
|
143
|
-
a && /* @__PURE__ */
|
|
147
|
+
a && /* @__PURE__ */ o(
|
|
144
148
|
"div",
|
|
145
149
|
{
|
|
146
150
|
ref: P,
|
|
147
151
|
role: "menu",
|
|
148
|
-
className:
|
|
152
|
+
className: h(
|
|
149
153
|
"bear-absolute bear-z-50",
|
|
150
|
-
"bear-
|
|
151
|
-
"bear-border bear-border-gray-200 dark:bear-border-gray-700",
|
|
152
|
-
"bear-rounded-lg bear-shadow-lg",
|
|
154
|
+
"bear-border bear-rounded-lg bear-shadow-lg",
|
|
153
155
|
"bear-py-1 bear-overflow-y-auto",
|
|
154
156
|
"bear-animate-in bear-fade-in-0 bear-zoom-in-95 bear-duration-100",
|
|
155
157
|
Q[L]
|
|
156
158
|
),
|
|
157
159
|
style: {
|
|
158
|
-
|
|
160
|
+
backgroundColor: "var(--bear-bg-primary)",
|
|
161
|
+
borderColor: "var(--bear-border-default)",
|
|
162
|
+
minWidth: R ? (C = N.current) == null ? void 0 : C.offsetWidth : j,
|
|
159
163
|
maxHeight: W
|
|
160
164
|
},
|
|
161
|
-
children:
|
|
165
|
+
children: i.map((e, t) => V(e, t))
|
|
162
166
|
}
|
|
163
167
|
)
|
|
164
168
|
]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),s=require("react"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),s=require("react"),b=require("../../utils/cn.cjs"),se=require("../../context/BearProvider.cjs"),ne=require("./components/ClearIcon/ClearIcon.cjs"),le=require("./Input.utils.cjs"),be=require("../Form/Form.utils.cjs"),ce={sm:"bear-h-8",md:"bear-h-10",lg:"bear-h-12"},oe={sm:"bear-text-sm bear-px-3",md:"bear-text-base bear-px-4",lg:"bear-text-lg bear-px-5"},T=s.forwardRef(({label:y,helperText:F,error:x,success:w,size:B="md",InputProps:n,leftAddon:H,rightAddon:S,fullWidth:V=!1,clearable:D=!1,onClear:G,showCharCount:j=!1,charCountMax:J,autoFormat:h,validation:t,validateOnBlur:K,validateOnChange:I=!1,className:Q,disabled:p,value:g,defaultValue:m,maxLength:k,onChange:c,onBlur:o,...U},W)=>{var O;const _=s.useContext(se.BearContext),e=(O=_==null?void 0:_.components)==null?void 0:O.Input,X=e==null?void 0:e.root,Y=e==null?void 0:e.input,Z=e==null?void 0:e.label,$=e==null?void 0:e.helper,z=e==null?void 0:e.prefix,P=e==null?void 0:e.suffix,[ee,N]=s.useState(null),C=s.useRef(!1),q=t?K??!0:!1,R=x||ee,l=!!R,i=!!w&&!l,u=J??k,v=typeof g=="string"?g.length:typeof m=="string"?m.length:0,E=u!=null&&v>u,re=D&&!p&&v>0,A=(n==null?void 0:n.startAdornment)??H,M=(n==null?void 0:n.endAdornment)??S,L=R||w||F,d=s.useCallback(async a=>{if(!t)return;C.current=!0;const f=await be.validateFieldValue(a,t);C.current=!1,N(f)},[t]);s.useEffect(()=>{x&&N(null)},[x]);const ae=s.useCallback(a=>{if(h){const f=le.applyAutoFormat(a.target.value,h);f!==a.target.value&&(a.target.value=f)}c==null||c(a),I&&t&&d(a.target.value)},[h,c,I,t,d]),te=s.useCallback(a=>{o==null||o(a),q&&t&&d(a.target.value)},[o,q,t,d]);return r.jsxs("div",{className:b.cn("Bear-Input bear-flex bear-flex-col bear-gap-1.5",V&&"bear-w-full"),style:X,children:[y&&r.jsx("label",{className:"Bear-Input__label bear-text-sm bear-font-medium",style:{color:"var(--bear-text-secondary)",...Z},children:y}),r.jsxs("div",{className:b.cn("Bear-Input__wrapper bear-flex bear-items-center bear-rounded-lg bear-border bear-overflow-hidden bear-transition-all bear-duration-200","focus-within:bear-ring-2 focus-within:bear-ring-offset-2","focus-within:bear-ring-offset-[var(--bear-bg-primary)]",l?"Bear-Input__wrapper--error bear-border-red-500 focus-within:bear-ring-red-500":i?"Bear-Input__wrapper--success bear-border-green-500 focus-within:bear-ring-green-500":"focus-within:bear-border-bear-500 focus-within:bear-ring-bear-500 dark:focus-within:bear-border-bear-500 dark:focus-within:bear-ring-bear-500",p&&"bear-opacity-50 bear-cursor-not-allowed",ce[B]),style:{backgroundColor:"var(--bear-bg-primary)",borderColor:l||i?void 0:"var(--bear-border-default)"},children:[A&&r.jsx("div",{className:"Bear-Input__addon Bear-Input__addon--left bear-flex bear-items-center bear-self-stretch bear-shrink-0 bear-px-3 bear-text-sm bear-font-medium bear-select-none bear-pointer-events-none",style:{backgroundColor:"var(--bear-bg-tertiary)",borderRight:"1px solid var(--bear-border-default)",color:"var(--bear-text-secondary)",...z},children:A}),r.jsx("input",{ref:W,disabled:p,value:g,defaultValue:m,maxLength:k,"aria-invalid":l||void 0,onChange:ae,onBlur:te,className:b.cn("Bear-Input__field","bear-flex-1 bear-min-w-0 bear-h-full bear-border-0 bear-outline-none bear-bg-transparent","placeholder:opacity-100 placeholder:[color:var(--bear-text-muted)]",oe[B],Q),style:{color:"var(--bear-text-primary)",...Y},...U}),re&&r.jsx("div",{className:"Bear-Input__clear bear-flex bear-items-center bear-self-stretch bear-shrink-0 bear-px-2 bear-cursor-pointer",style:{color:"var(--bear-text-muted)"},children:r.jsx(ne.ClearIcon,{onClick:G})}),M&&r.jsx("div",{className:"Bear-Input__addon Bear-Input__addon--right bear-flex bear-items-center bear-self-stretch bear-shrink-0 bear-px-3 bear-gap-1.5",style:{backgroundColor:"var(--bear-bg-tertiary)",borderLeft:"1px solid var(--bear-border-default)",color:"var(--bear-text-secondary)",...P},children:M})]}),r.jsxs("div",{className:"Bear-Input__footer bear-flex bear-items-center bear-justify-between bear-gap-2",children:[L?r.jsx("p",{className:b.cn("Bear-Input__helper bear-text-sm bear-flex-1",l&&"Bear-Input__helper--error bear-text-red-500",i&&"Bear-Input__helper--success bear-text-green-500"),style:{...l||i?{}:{color:"var(--bear-text-muted)"},...$},children:L}):j?r.jsx("span",{}):null,j&&u!=null&&r.jsxs("span",{className:b.cn("Bear-Input__char-count bear-text-xs bear-tabular-nums bear-shrink-0",E&&"bear-text-red-500"),style:E?void 0:{color:"var(--bear-text-muted)"},children:[v,"/",u]})]})]})});T.displayName="Input";exports.Input=T;
|