@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,127 +1,179 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { forwardRef as
|
|
3
|
-
import { cn as
|
|
4
|
-
import { BearContext as
|
|
5
|
-
import { ClearIcon as
|
|
6
|
-
import { applyAutoFormat as
|
|
7
|
-
import { validateFieldValue as
|
|
1
|
+
import { jsxs as u, jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as se, useContext as be, useState as le, useRef as ne, useCallback as w, useEffect as oe } from "react";
|
|
3
|
+
import { cn as l } from "../../utils/cn.js";
|
|
4
|
+
import { BearContext as ie } from "../../context/BearProvider.js";
|
|
5
|
+
import { ClearIcon as ce } from "./components/ClearIcon/ClearIcon.js";
|
|
6
|
+
import { applyAutoFormat as de } from "./Input.utils.js";
|
|
7
|
+
import { validateFieldValue as fe } from "../Form/Form.utils.js";
|
|
8
8
|
const ue = {
|
|
9
|
-
sm: "bear-h-8
|
|
10
|
-
md: "bear-h-10
|
|
11
|
-
lg: "bear-h-12
|
|
12
|
-
},
|
|
9
|
+
sm: "bear-h-8",
|
|
10
|
+
md: "bear-h-10",
|
|
11
|
+
lg: "bear-h-12"
|
|
12
|
+
}, pe = {
|
|
13
|
+
sm: "bear-text-sm bear-px-3",
|
|
14
|
+
md: "bear-text-base bear-px-4",
|
|
15
|
+
lg: "bear-text-lg bear-px-5"
|
|
16
|
+
}, xe = se(
|
|
13
17
|
({
|
|
14
|
-
label:
|
|
15
|
-
helperText:
|
|
16
|
-
error:
|
|
17
|
-
success:
|
|
18
|
-
size:
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
18
|
+
label: y,
|
|
19
|
+
helperText: V,
|
|
20
|
+
error: p,
|
|
21
|
+
success: B,
|
|
22
|
+
size: k = "md",
|
|
23
|
+
InputProps: s,
|
|
24
|
+
leftAddon: q,
|
|
25
|
+
rightAddon: D,
|
|
26
|
+
fullWidth: F = !1,
|
|
27
|
+
clearable: G = !1,
|
|
28
|
+
onClear: J,
|
|
29
|
+
showCharCount: I = !1,
|
|
25
30
|
charCountMax: K,
|
|
26
|
-
autoFormat:
|
|
31
|
+
autoFormat: x,
|
|
27
32
|
validation: a,
|
|
28
33
|
validateOnBlur: Q,
|
|
29
|
-
validateOnChange:
|
|
30
|
-
className:
|
|
31
|
-
disabled:
|
|
32
|
-
value:
|
|
33
|
-
defaultValue:
|
|
34
|
-
maxLength:
|
|
35
|
-
onChange:
|
|
36
|
-
onBlur:
|
|
37
|
-
...
|
|
38
|
-
},
|
|
39
|
-
var
|
|
40
|
-
const
|
|
34
|
+
validateOnChange: N = !1,
|
|
35
|
+
className: U,
|
|
36
|
+
disabled: m,
|
|
37
|
+
value: h,
|
|
38
|
+
defaultValue: g,
|
|
39
|
+
maxLength: C,
|
|
40
|
+
onChange: n,
|
|
41
|
+
onBlur: o,
|
|
42
|
+
...W
|
|
43
|
+
}, X) => {
|
|
44
|
+
var T;
|
|
45
|
+
const _ = be(ie), e = (T = _ == null ? void 0 : _.components) == null ? void 0 : T.Input, Y = e == null ? void 0 : e.root, Z = e == null ? void 0 : e.input, $ = e == null ? void 0 : e.label, z = e == null ? void 0 : e.helper, S = e == null ? void 0 : e.prefix, P = e == null ? void 0 : e.suffix, [ee, E] = le(null), j = ne(!1), A = a ? Q ?? !0 : !1, R = p || ee, b = !!R, i = !!B && !b, c = K ?? C, v = typeof h == "string" ? h.length : typeof g == "string" ? g.length : 0, L = c != null && v > c, re = G && !m && v > 0, M = (s == null ? void 0 : s.startAdornment) ?? q, H = (s == null ? void 0 : s.endAdornment) ?? D, O = R || B || V, d = w(async (r) => {
|
|
41
46
|
if (!a) return;
|
|
42
|
-
|
|
43
|
-
const
|
|
44
|
-
|
|
47
|
+
j.current = !0;
|
|
48
|
+
const f = await fe(r, a);
|
|
49
|
+
j.current = !1, E(f);
|
|
45
50
|
}, [a]);
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}, [
|
|
49
|
-
const
|
|
51
|
+
oe(() => {
|
|
52
|
+
p && E(null);
|
|
53
|
+
}, [p]);
|
|
54
|
+
const ae = w(
|
|
50
55
|
(r) => {
|
|
51
|
-
if (
|
|
52
|
-
const
|
|
53
|
-
|
|
56
|
+
if (x) {
|
|
57
|
+
const f = de(r.target.value, x);
|
|
58
|
+
f !== r.target.value && (r.target.value = f);
|
|
54
59
|
}
|
|
55
|
-
|
|
60
|
+
n == null || n(r), N && a && d(r.target.value);
|
|
56
61
|
},
|
|
57
|
-
[
|
|
58
|
-
),
|
|
62
|
+
[x, n, N, a, d]
|
|
63
|
+
), te = w(
|
|
59
64
|
(r) => {
|
|
60
|
-
|
|
65
|
+
o == null || o(r), A && a && d(r.target.value);
|
|
61
66
|
},
|
|
62
|
-
[
|
|
67
|
+
[o, A, a, d]
|
|
63
68
|
);
|
|
64
|
-
return /* @__PURE__ */
|
|
65
|
-
|
|
66
|
-
/* @__PURE__ */
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
"
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
69
|
+
return /* @__PURE__ */ u("div", { className: l("Bear-Input bear-flex bear-flex-col bear-gap-1.5", F && "bear-w-full"), style: Y, children: [
|
|
70
|
+
y && /* @__PURE__ */ t("label", { className: "Bear-Input__label bear-text-sm bear-font-medium", style: { color: "var(--bear-text-secondary)", ...$ }, children: y }),
|
|
71
|
+
/* @__PURE__ */ u(
|
|
72
|
+
"div",
|
|
73
|
+
{
|
|
74
|
+
className: l(
|
|
75
|
+
"Bear-Input__wrapper bear-flex bear-items-center bear-rounded-lg bear-border bear-overflow-hidden bear-transition-all bear-duration-200",
|
|
76
|
+
"focus-within:bear-ring-2 focus-within:bear-ring-offset-2",
|
|
77
|
+
"focus-within:bear-ring-offset-[var(--bear-bg-primary)]",
|
|
78
|
+
b ? "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",
|
|
79
|
+
m && "bear-opacity-50 bear-cursor-not-allowed",
|
|
80
|
+
ue[k]
|
|
81
|
+
),
|
|
82
|
+
style: {
|
|
83
|
+
backgroundColor: "var(--bear-bg-primary)",
|
|
84
|
+
borderColor: b || i ? void 0 : "var(--bear-border-default)"
|
|
85
|
+
},
|
|
86
|
+
children: [
|
|
87
|
+
M && /* @__PURE__ */ t(
|
|
88
|
+
"div",
|
|
89
|
+
{
|
|
90
|
+
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",
|
|
91
|
+
style: {
|
|
92
|
+
backgroundColor: "var(--bear-bg-tertiary)",
|
|
93
|
+
borderRight: "1px solid var(--bear-border-default)",
|
|
94
|
+
color: "var(--bear-text-secondary)",
|
|
95
|
+
...S
|
|
96
|
+
},
|
|
97
|
+
children: M
|
|
98
|
+
}
|
|
91
99
|
),
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
100
|
+
/* @__PURE__ */ t(
|
|
101
|
+
"input",
|
|
102
|
+
{
|
|
103
|
+
ref: X,
|
|
104
|
+
disabled: m,
|
|
105
|
+
value: h,
|
|
106
|
+
defaultValue: g,
|
|
107
|
+
maxLength: C,
|
|
108
|
+
"aria-invalid": b || void 0,
|
|
109
|
+
onChange: ae,
|
|
110
|
+
onBlur: te,
|
|
111
|
+
className: l(
|
|
112
|
+
"Bear-Input__field",
|
|
113
|
+
"bear-flex-1 bear-min-w-0 bear-h-full bear-border-0 bear-outline-none bear-bg-transparent",
|
|
114
|
+
"placeholder:opacity-100 placeholder:[color:var(--bear-text-muted)]",
|
|
115
|
+
pe[k],
|
|
116
|
+
U
|
|
117
|
+
),
|
|
118
|
+
style: {
|
|
119
|
+
color: "var(--bear-text-primary)",
|
|
120
|
+
...Z
|
|
121
|
+
},
|
|
122
|
+
...W
|
|
123
|
+
}
|
|
124
|
+
),
|
|
125
|
+
re && /* @__PURE__ */ t(
|
|
126
|
+
"div",
|
|
127
|
+
{
|
|
128
|
+
className: "Bear-Input__clear bear-flex bear-items-center bear-self-stretch bear-shrink-0 bear-px-2 bear-cursor-pointer",
|
|
129
|
+
style: { color: "var(--bear-text-muted)" },
|
|
130
|
+
children: /* @__PURE__ */ t(ce, { onClick: J })
|
|
131
|
+
}
|
|
132
|
+
),
|
|
133
|
+
H && /* @__PURE__ */ t(
|
|
134
|
+
"div",
|
|
135
|
+
{
|
|
136
|
+
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",
|
|
137
|
+
style: {
|
|
138
|
+
backgroundColor: "var(--bear-bg-tertiary)",
|
|
139
|
+
borderLeft: "1px solid var(--bear-border-default)",
|
|
140
|
+
color: "var(--bear-text-secondary)",
|
|
141
|
+
...P
|
|
142
|
+
},
|
|
143
|
+
children: H
|
|
144
|
+
}
|
|
145
|
+
)
|
|
146
|
+
]
|
|
147
|
+
}
|
|
148
|
+
),
|
|
149
|
+
/* @__PURE__ */ u("div", { className: "Bear-Input__footer bear-flex bear-items-center bear-justify-between bear-gap-2", children: [
|
|
150
|
+
O ? /* @__PURE__ */ t(
|
|
104
151
|
"p",
|
|
105
152
|
{
|
|
106
|
-
className:
|
|
153
|
+
className: l(
|
|
107
154
|
"Bear-Input__helper bear-text-sm bear-flex-1",
|
|
108
|
-
|
|
155
|
+
b && "Bear-Input__helper--error bear-text-red-500",
|
|
156
|
+
i && "Bear-Input__helper--success bear-text-green-500"
|
|
109
157
|
),
|
|
110
|
-
style:
|
|
111
|
-
|
|
158
|
+
style: {
|
|
159
|
+
...b || i ? {} : { color: "var(--bear-text-muted)" },
|
|
160
|
+
...z
|
|
161
|
+
},
|
|
162
|
+
children: O
|
|
112
163
|
}
|
|
113
|
-
) :
|
|
114
|
-
|
|
164
|
+
) : I ? /* @__PURE__ */ t("span", {}) : null,
|
|
165
|
+
I && c != null && /* @__PURE__ */ u(
|
|
115
166
|
"span",
|
|
116
167
|
{
|
|
117
|
-
className:
|
|
168
|
+
className: l(
|
|
118
169
|
"Bear-Input__char-count bear-text-xs bear-tabular-nums bear-shrink-0",
|
|
119
|
-
|
|
170
|
+
L && "bear-text-red-500"
|
|
120
171
|
),
|
|
172
|
+
style: L ? void 0 : { color: "var(--bear-text-muted)" },
|
|
121
173
|
children: [
|
|
122
|
-
|
|
174
|
+
v,
|
|
123
175
|
"/",
|
|
124
|
-
|
|
176
|
+
c
|
|
125
177
|
]
|
|
126
178
|
}
|
|
127
179
|
)
|
|
@@ -129,7 +181,7 @@ const ue = {
|
|
|
129
181
|
] });
|
|
130
182
|
}
|
|
131
183
|
);
|
|
132
|
-
|
|
184
|
+
xe.displayName = "Input";
|
|
133
185
|
export {
|
|
134
|
-
|
|
186
|
+
xe as Input
|
|
135
187
|
};
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { InputHTMLAttributes, ReactNode } from 'react';
|
|
2
2
|
import { ValidationRule } from '../Form/Form.types';
|
|
3
3
|
export type AutoFormatType = 'capitalize' | 'uppercase' | 'lowercase' | 'titleCase' | 'sentenceCase' | 'none';
|
|
4
|
+
export interface InputPropsInput {
|
|
5
|
+
startAdornment?: ReactNode;
|
|
6
|
+
endAdornment?: ReactNode;
|
|
7
|
+
}
|
|
4
8
|
export interface InputProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'size'> {
|
|
5
9
|
/** Input label */
|
|
6
10
|
label?: string;
|
|
@@ -12,9 +16,11 @@ export interface InputProps extends Omit<InputHTMLAttributes<HTMLInputElement>,
|
|
|
12
16
|
success?: string;
|
|
13
17
|
/** Input size */
|
|
14
18
|
size?: 'sm' | 'md' | 'lg';
|
|
15
|
-
/**
|
|
19
|
+
/** Start/end slots (takes precedence over leftAddon/rightAddon when set) */
|
|
20
|
+
InputProps?: InputPropsInput;
|
|
21
|
+
/** Left addon (legacy; use InputProps.startAdornment for start slot) */
|
|
16
22
|
leftAddon?: ReactNode;
|
|
17
|
-
/** Right addon */
|
|
23
|
+
/** Right addon (legacy; use InputProps.endAdornment for end slot) */
|
|
18
24
|
rightAddon?: ReactNode;
|
|
19
25
|
/** Whether input is full width */
|
|
20
26
|
fullWidth?: boolean;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { Input } from './Input';
|
|
2
|
-
export type { InputProps, AutoFormatType } from './Input.types';
|
|
2
|
+
export type { InputProps, InputPropsInput, AutoFormatType } from './Input.types';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("react/jsx-runtime"),l=require("react"),D=require("react-dom"),p=require("../../utils/cn.cjs"),H=1e4;function X(f,t,a){const e={position:"fixed",zIndex:H},s=f.split("-")[0],r=f.includes("start"),n=f.includes("end");return s==="bottom"?(e.top=t.bottom+a,r?e.left=t.left:n?e.left=t.right:e.left=t.left+t.width/2):s==="top"?(e.bottom=window.innerHeight-t.top+a,r?e.left=t.left:n?e.left=t.right:e.left=t.left+t.width/2):s==="left"?(e.right=window.innerWidth-t.left+a,r?e.top=t.top:n?e.bottom=window.innerHeight-t.bottom:e.top=t.top+t.height/2):(e.left=t.right+a,r?e.top=t.top:n?e.bottom=window.innerHeight-t.bottom:e.top=t.top+t.height/2),s==="bottom"||s==="top"?!r&&!n?e.transform="translateX(-50%)":n&&(e.transform="translateX(-100%)"):!r&&!n?e.transform="translateY(-50%)":n&&(e.transform="translateY(-100%)"),e}const T=({children:f,content:t,placement:a="bottom",trigger:e="click",open:s,onOpenChange:r,className:n,contentClassName:E,arrow:k=!0,closeOnClickOutside:m=!0,closeOnEscape:h=!0,offset:v=8})=>{const[z,R]=l.useState(!1),[S,j]=l.useState({}),d=l.useRef(null),w=l.useRef(null),i=s!==void 0?s:z,b=l.useCallback(o=>{R(o),r==null||r(o)},[r]);l.useEffect(()=>{if(i&&d.current){const o=d.current.getBoundingClientRect();j(X(a,o,v))}},[i,a,v]),l.useEffect(()=>{if(!m)return;const o=c=>{var g,x;const y=c.target;(g=d.current)!=null&&g.contains(y)||(x=w.current)!=null&&x.contains(y)||b(!1)};return i&&document.addEventListener("mousedown",o),()=>document.removeEventListener("mousedown",o)},[i,m,b]),l.useEffect(()=>{if(!h)return;const o=c=>{c.key==="Escape"&&b(!1)};return i&&document.addEventListener("keydown",o),()=>document.removeEventListener("keydown",o)},[i,h,b]);const L=()=>{e==="click"&&b(!i)},P=()=>{e==="hover"&&b(!0)},M=()=>{e==="hover"&&b(!1)},N={top:"bear-top-full bear-left-1/2 -bear-translate-x-1/2 bear-border-t-zinc-700 bear-border-x-transparent bear-border-b-transparent",bottom:"bear-bottom-full bear-left-1/2 -bear-translate-x-1/2 bear-border-b-zinc-700 bear-border-x-transparent bear-border-t-transparent",left:"bear-left-full bear-top-1/2 -bear-translate-y-1/2 bear-border-l-zinc-700 bear-border-y-transparent bear-border-r-transparent",right:"bear-right-full bear-top-1/2 -bear-translate-y-1/2 bear-border-r-zinc-700 bear-border-y-transparent bear-border-l-transparent"},q=a.split("-")[0],I=i&&typeof document<"u"&&D.createPortal(u.jsxs("div",{ref:w,"data-bear-popover":!0,className:p.cn("bear-bg-zinc-800 bear-border bear-border-zinc-700 bear-rounded-lg bear-shadow-xl bear-p-3",E),style:S,children:[t,k&&u.jsx("div",{className:p.cn("bear-absolute bear-w-0 bear-h-0 bear-border-8",N[q])})]}),document.body);return u.jsxs("div",{ref:d,className:p.cn("bear-relative bear-inline-block",n),onMouseEnter:P,onMouseLeave:M,children:[u.jsx("div",{onClick:L,className:"bear-cursor-pointer",children:f}),I]})};exports.Popover=T;
|
|
@@ -1,93 +1,93 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useState as
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { jsxs as x, jsx as E } from "react/jsx-runtime";
|
|
2
|
+
import { useState as k, useRef as z, useCallback as B, useEffect as u } from "react";
|
|
3
|
+
import { createPortal as T } from "react-dom";
|
|
4
|
+
import { cn as c } from "../../utils/cn.js";
|
|
5
|
+
const W = 1e4;
|
|
6
|
+
function Z(b, t, a) {
|
|
7
|
+
const e = { position: "fixed", zIndex: W }, s = b.split("-")[0], r = b.includes("start"), o = b.includes("end");
|
|
8
|
+
return s === "bottom" ? (e.top = t.bottom + a, r ? e.left = t.left : o ? e.left = t.right : e.left = t.left + t.width / 2) : s === "top" ? (e.bottom = window.innerHeight - t.top + a, r ? e.left = t.left : o ? e.left = t.right : e.left = t.left + t.width / 2) : s === "left" ? (e.right = window.innerWidth - t.left + a, r ? e.top = t.top : o ? e.bottom = window.innerHeight - t.bottom : e.top = t.top + t.height / 2) : (e.left = t.right + a, r ? e.top = t.top : o ? e.bottom = window.innerHeight - t.bottom : e.top = t.top + t.height / 2), s === "bottom" || s === "top" ? !r && !o ? e.transform = "translateX(-50%)" : o && (e.transform = "translateX(-100%)") : !r && !o ? e.transform = "translateY(-50%)" : o && (e.transform = "translateY(-100%)"), e;
|
|
9
|
+
}
|
|
10
|
+
const F = ({
|
|
11
|
+
children: b,
|
|
12
|
+
content: t,
|
|
7
13
|
placement: a = "bottom",
|
|
8
|
-
trigger:
|
|
9
|
-
open:
|
|
10
|
-
onOpenChange:
|
|
11
|
-
className:
|
|
12
|
-
contentClassName:
|
|
13
|
-
arrow:
|
|
14
|
-
closeOnClickOutside:
|
|
15
|
-
closeOnEscape:
|
|
16
|
-
offset:
|
|
14
|
+
trigger: e = "click",
|
|
15
|
+
open: s,
|
|
16
|
+
onOpenChange: r,
|
|
17
|
+
className: o,
|
|
18
|
+
contentClassName: L,
|
|
19
|
+
arrow: N = !0,
|
|
20
|
+
closeOnClickOutside: p = !0,
|
|
21
|
+
closeOnEscape: m = !0,
|
|
22
|
+
offset: h = 8
|
|
17
23
|
}) => {
|
|
18
|
-
const [
|
|
19
|
-
|
|
20
|
-
}, [
|
|
21
|
-
|
|
22
|
-
if (
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
const [I, M] = k(!1), [P, R] = k({}), f = z(null), v = z(null), i = s !== void 0 ? s : I, l = B((n) => {
|
|
25
|
+
M(n), r == null || r(n);
|
|
26
|
+
}, [r]);
|
|
27
|
+
u(() => {
|
|
28
|
+
if (i && f.current) {
|
|
29
|
+
const n = f.current.getBoundingClientRect();
|
|
30
|
+
R(Z(a, n, h));
|
|
31
|
+
}
|
|
32
|
+
}, [i, a, h]), u(() => {
|
|
33
|
+
if (!p) return;
|
|
34
|
+
const n = (d) => {
|
|
35
|
+
var y, g;
|
|
36
|
+
const w = d.target;
|
|
37
|
+
(y = f.current) != null && y.contains(w) || (g = v.current) != null && g.contains(w) || l(!1);
|
|
25
38
|
};
|
|
26
|
-
return
|
|
27
|
-
}, [
|
|
28
|
-
if (!
|
|
29
|
-
const
|
|
30
|
-
|
|
39
|
+
return i && document.addEventListener("mousedown", n), () => document.removeEventListener("mousedown", n);
|
|
40
|
+
}, [i, p, l]), u(() => {
|
|
41
|
+
if (!m) return;
|
|
42
|
+
const n = (d) => {
|
|
43
|
+
d.key === "Escape" && l(!1);
|
|
31
44
|
};
|
|
32
|
-
return
|
|
33
|
-
}, [
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
},
|
|
37
|
-
|
|
38
|
-
},
|
|
39
|
-
|
|
40
|
-
},
|
|
41
|
-
top: "bear-bottom-full bear-left-1/2 -bear-translate-x-1/2 bear-mb-2",
|
|
42
|
-
"top-start": "bear-bottom-full bear-left-0 bear-mb-2",
|
|
43
|
-
"top-end": "bear-bottom-full bear-right-0 bear-mb-2",
|
|
44
|
-
bottom: "bear-top-full bear-left-1/2 -bear-translate-x-1/2 bear-mt-2",
|
|
45
|
-
"bottom-start": "bear-top-full bear-left-0 bear-mt-2",
|
|
46
|
-
"bottom-end": "bear-top-full bear-right-0 bear-mt-2",
|
|
47
|
-
left: "bear-right-full bear-top-1/2 -bear-translate-y-1/2 bear-mr-2",
|
|
48
|
-
"left-start": "bear-right-full bear-top-0 bear-mr-2",
|
|
49
|
-
"left-end": "bear-right-full bear-bottom-0 bear-mr-2",
|
|
50
|
-
right: "bear-left-full bear-top-1/2 -bear-translate-y-1/2 bear-ml-2",
|
|
51
|
-
"right-start": "bear-left-full bear-top-0 bear-ml-2",
|
|
52
|
-
"right-end": "bear-left-full bear-bottom-0 bear-ml-2"
|
|
53
|
-
}, S = {
|
|
45
|
+
return i && document.addEventListener("keydown", n), () => document.removeEventListener("keydown", n);
|
|
46
|
+
}, [i, m, l]);
|
|
47
|
+
const S = () => {
|
|
48
|
+
e === "click" && l(!i);
|
|
49
|
+
}, H = () => {
|
|
50
|
+
e === "hover" && l(!0);
|
|
51
|
+
}, X = () => {
|
|
52
|
+
e === "hover" && l(!1);
|
|
53
|
+
}, j = {
|
|
54
54
|
top: "bear-top-full bear-left-1/2 -bear-translate-x-1/2 bear-border-t-zinc-700 bear-border-x-transparent bear-border-b-transparent",
|
|
55
55
|
bottom: "bear-bottom-full bear-left-1/2 -bear-translate-x-1/2 bear-border-b-zinc-700 bear-border-x-transparent bear-border-t-transparent",
|
|
56
56
|
left: "bear-left-full bear-top-1/2 -bear-translate-y-1/2 bear-border-l-zinc-700 bear-border-y-transparent bear-border-r-transparent",
|
|
57
57
|
right: "bear-right-full bear-top-1/2 -bear-translate-y-1/2 bear-border-r-zinc-700 bear-border-y-transparent bear-border-l-transparent"
|
|
58
|
-
},
|
|
59
|
-
|
|
58
|
+
}, D = a.split("-")[0], Y = i && typeof document < "u" && T(
|
|
59
|
+
/* @__PURE__ */ x(
|
|
60
|
+
"div",
|
|
61
|
+
{
|
|
62
|
+
ref: v,
|
|
63
|
+
"data-bear-popover": !0,
|
|
64
|
+
className: c(
|
|
65
|
+
"bear-bg-zinc-800 bear-border bear-border-zinc-700 bear-rounded-lg bear-shadow-xl bear-p-3",
|
|
66
|
+
L
|
|
67
|
+
),
|
|
68
|
+
style: P,
|
|
69
|
+
children: [
|
|
70
|
+
t,
|
|
71
|
+
N && /* @__PURE__ */ E("div", { className: c("bear-absolute bear-w-0 bear-h-0 bear-border-8", j[D]) })
|
|
72
|
+
]
|
|
73
|
+
}
|
|
74
|
+
),
|
|
75
|
+
document.body
|
|
76
|
+
);
|
|
77
|
+
return /* @__PURE__ */ x(
|
|
60
78
|
"div",
|
|
61
79
|
{
|
|
62
|
-
ref:
|
|
63
|
-
className:
|
|
64
|
-
onMouseEnter:
|
|
65
|
-
onMouseLeave:
|
|
80
|
+
ref: f,
|
|
81
|
+
className: c("bear-relative bear-inline-block", o),
|
|
82
|
+
onMouseEnter: H,
|
|
83
|
+
onMouseLeave: X,
|
|
66
84
|
children: [
|
|
67
|
-
/* @__PURE__ */
|
|
68
|
-
|
|
69
|
-
"div",
|
|
70
|
-
{
|
|
71
|
-
ref: z,
|
|
72
|
-
className: s(
|
|
73
|
-
"bear-absolute bear-z-50 bear-bg-zinc-800 bear-border bear-border-zinc-700 bear-rounded-lg bear-shadow-xl bear-p-3",
|
|
74
|
-
R[a],
|
|
75
|
-
k
|
|
76
|
-
),
|
|
77
|
-
style: { marginTop: a.startsWith("bottom") ? u : void 0, marginBottom: a.startsWith("top") ? u : void 0 },
|
|
78
|
-
children: [
|
|
79
|
-
y,
|
|
80
|
-
g && /* @__PURE__ */ m("div", { className: s(
|
|
81
|
-
"bear-absolute bear-w-0 bear-h-0 bear-border-8",
|
|
82
|
-
S[j]
|
|
83
|
-
) })
|
|
84
|
-
]
|
|
85
|
-
}
|
|
86
|
-
)
|
|
85
|
+
/* @__PURE__ */ E("div", { onClick: S, className: "bear-cursor-pointer", children: b }),
|
|
86
|
+
Y
|
|
87
87
|
]
|
|
88
88
|
}
|
|
89
89
|
);
|
|
90
90
|
};
|
|
91
91
|
export {
|
|
92
|
-
|
|
92
|
+
F as Popover
|
|
93
93
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),n=require("react"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),n=require("react"),s=require("../../utils/cn.cjs"),j=require("../../hooks/useClickOutside.cjs");require("../../context/BearProvider.cjs");require("../../hooks/useBearComponent/useBearComponent.cjs");const m=require("../Icon/index.cjs"),p={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:a,onChange:t,placeholder:v="Select an option",label:i,error:l,disabled:o=!1,size:y="md",fullWidth:g=!1,className:h})=>{const[c,d]=n.useState(!1),f=n.useRef(null),x=!!l,b=u.find(e=>e.value===a),k=n.useCallback(()=>d(!1),[]);j.useClickOutside(f,k);const w=e=>{t==null||t(e),d(!1)};return r.jsxs("div",{ref:f,className:s.cn("bear-relative bear-flex bear-flex-col bear-gap-1.5",g&&"bear-w-full"),children:[i&&r.jsx("label",{className:"bear-text-sm bear-font-medium",style:{color:"var(--bear-text-secondary)"},children:i}),r.jsxs("button",{type:"button",disabled:o,onClick:()=>!o&&d(!c),className:s.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","focus:bear-ring-2 focus:bear-ring-offset-2 focus:bear-ring-offset-[var(--bear-bg-primary)]",x?"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",o&&"bear-opacity-50 bear-cursor-not-allowed",p[y],h),style:{backgroundColor:"var(--bear-bg-primary)",borderColor:x?void 0:"var(--bear-border-default)",color:b?"var(--bear-text-primary)":"var(--bear-text-muted)"},children:[r.jsx("span",{children:(b==null?void 0:b.label)||v}),r.jsx(m.ChevronDownIcon,{className:s.cn("bear-w-4 bear-h-4 bear-shrink-0 bear-transition-transform",c&&"bear-rotate-180"),style:{color:"var(--bear-text-muted)"}})]}),c&&r.jsx("div",{className:"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",style:{backgroundColor:"var(--bear-bg-primary)",borderColor:"var(--bear-border-default)"},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:s.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-cursor-not-allowed",e.value===a&&"bear-bg-bear-100 bear-text-bear-700 dark:bear-bg-bear-600/20 dark:bear-text-bear-300",!e.disabled&&e.value!==a&&"hover:bear-bg-[var(--bear-bg-tertiary)]"),style:e.disabled?{color:"var(--bear-text-muted)"}:e.value===a?void 0:{color:"var(--bear-text-secondary)"},children:[e.label,e.value===a&&r.jsx(m.CheckIcon,{className:"bear-w-4 bear-h-4 bear-shrink-0 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;
|