@forgedevstack/bear 1.2.4 → 1.2.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/README.md +15 -0
- package/dist/components/AppBar/AppBar.cjs +1 -1
- package/dist/components/AppBar/AppBar.const.cjs +1 -0
- package/dist/components/AppBar/AppBar.const.d.ts +36 -1
- package/dist/components/AppBar/AppBar.const.js +39 -0
- package/dist/components/AppBar/AppBar.js +65 -42
- package/dist/components/AppBar/AppBar.types.d.ts +9 -3
- package/dist/components/Backdrop/Backdrop.cjs +1 -0
- package/dist/components/Backdrop/Backdrop.const.cjs +1 -0
- package/dist/components/Backdrop/Backdrop.const.d.ts +7 -0
- package/dist/components/Backdrop/Backdrop.const.js +10 -0
- package/dist/components/Backdrop/Backdrop.d.ts +3 -0
- package/dist/components/Backdrop/Backdrop.js +43 -0
- package/dist/components/Backdrop/Backdrop.types.d.ts +12 -0
- package/dist/components/Backdrop/index.d.ts +2 -0
- package/dist/components/BottomNavigation/BottomNavigation.cjs +1 -1
- package/dist/components/BottomNavigation/BottomNavigation.const.cjs +1 -0
- package/dist/components/BottomNavigation/BottomNavigation.const.d.ts +8 -1
- package/dist/components/BottomNavigation/BottomNavigation.const.js +11 -0
- package/dist/components/BottomNavigation/BottomNavigation.js +64 -46
- package/dist/components/Breadcrumbs/Breadcrumbs.cjs +1 -1
- package/dist/components/Breadcrumbs/Breadcrumbs.js +65 -64
- package/dist/components/Card/Card.types.d.ts +1 -2
- package/dist/components/Chat/Chat.const.cjs +1 -1
- package/dist/components/Chat/Chat.const.d.ts +1 -1
- package/dist/components/Chat/Chat.const.js +1 -1
- package/dist/components/Chip/Chip.cjs +1 -1
- package/dist/components/Chip/Chip.const.cjs +1 -0
- package/dist/components/Chip/Chip.const.d.ts +39 -0
- package/dist/components/Chip/Chip.const.js +43 -0
- package/dist/components/Chip/Chip.js +44 -65
- package/dist/components/ChipGroup/ChipGroup.cjs +1 -0
- package/dist/components/ChipGroup/ChipGroup.const.cjs +1 -0
- package/dist/components/ChipGroup/ChipGroup.const.d.ts +8 -0
- package/dist/components/ChipGroup/ChipGroup.const.js +11 -0
- package/dist/components/ChipGroup/ChipGroup.d.ts +3 -0
- package/dist/components/ChipGroup/ChipGroup.js +41 -0
- package/dist/components/ChipGroup/ChipGroup.types.d.ts +9 -0
- package/dist/components/ChipGroup/index.d.ts +2 -0
- package/dist/components/ColorSwatch/ColorSwatch.cjs +1 -1
- package/dist/components/ColorSwatch/ColorSwatch.js +8 -8
- package/dist/components/CommandPalette/CommandPalette.cjs +1 -1
- package/dist/components/CommandPalette/CommandPalette.js +71 -71
- package/dist/components/DiffSquares/DiffSquares.cjs +1 -1
- package/dist/components/DiffSquares/DiffSquares.js +11 -11
- package/dist/components/Drawer/Drawer.cjs +1 -1
- package/dist/components/Drawer/Drawer.js +57 -56
- package/dist/components/Input/Input.cjs +1 -1
- package/dist/components/Input/Input.js +63 -62
- package/dist/components/List/List.cjs +1 -1
- package/dist/components/List/List.js +133 -123
- package/dist/components/List/List.types.d.ts +2 -0
- package/dist/components/MentionsInput/MentionsInput.cjs +1 -1
- package/dist/components/MentionsInput/MentionsInput.js +114 -92
- package/dist/components/MentionsInput/MentionsInput.types.d.ts +4 -0
- package/dist/components/MessageList/MessageList.cjs +1 -0
- package/dist/components/MessageList/MessageList.const.cjs +1 -0
- package/dist/components/MessageList/MessageList.const.d.ts +29 -0
- package/dist/components/MessageList/MessageList.const.js +36 -0
- package/dist/components/MessageList/MessageList.d.ts +3 -0
- package/dist/components/MessageList/MessageList.js +194 -0
- package/dist/components/MessageList/MessageList.types.d.ts +74 -0
- package/dist/components/MessageList/MessageList.utils.cjs +1 -0
- package/dist/components/MessageList/MessageList.utils.d.ts +13 -0
- package/dist/components/MessageList/MessageList.utils.js +54 -0
- package/dist/components/MessageList/index.d.ts +2 -0
- package/dist/components/Progress/Progress.cjs +1 -1
- package/dist/components/Progress/Progress.const.cjs +1 -0
- package/dist/components/Progress/Progress.const.d.ts +16 -1
- package/dist/components/Progress/Progress.const.js +19 -0
- package/dist/components/Progress/Progress.d.ts +0 -10
- package/dist/components/Progress/Progress.js +81 -71
- package/dist/components/Progress/Progress.types.d.ts +2 -11
- package/dist/components/PropsPlayground/PropsPlayground.cjs +1 -1
- package/dist/components/PropsPlayground/PropsPlayground.js +40 -40
- package/dist/components/Select/Select.cjs +1 -1
- package/dist/components/Select/Select.const.cjs +1 -0
- package/dist/components/Select/Select.const.d.ts +9 -0
- package/dist/components/Select/Select.const.js +13 -0
- package/dist/components/Select/Select.js +144 -68
- package/dist/components/Stepper/Stepper.cjs +1 -1
- package/dist/components/Stepper/Stepper.js +89 -83
- package/dist/components/Toast/Toast.cjs +1 -1
- package/dist/components/Toast/Toast.const.cjs +1 -0
- package/dist/components/Toast/Toast.const.d.ts +4 -0
- package/dist/components/Toast/Toast.const.js +17 -0
- package/dist/components/Toast/Toast.d.ts +3 -7
- package/dist/components/Toast/Toast.js +101 -89
- package/dist/components/Toast/Toast.types.d.ts +9 -0
- package/dist/components/Toast/index.d.ts +1 -1
- package/dist/components/TreeSelect/TreeSelect.cjs +1 -1
- package/dist/components/TreeSelect/TreeSelect.js +22 -22
- package/dist/components/index.cjs +1 -1
- package/dist/components/index.d.ts +7 -1
- package/dist/components/index.js +284 -278
- package/dist/context/BearProvider.cjs +1 -1
- package/dist/context/BearProvider.d.ts +8 -0
- package/dist/context/BearProvider.js +149 -139
- package/dist/context/index.cjs +1 -1
- package/dist/context/index.d.ts +1 -1
- package/dist/context/index.js +12 -10
- package/dist/index.cjs +1 -1
- package/dist/index.js +392 -384
- package/dist/styles/_message-list.css +42 -0
- package/dist/styles/main.css +1 -0
- package/dist/styles.css +114 -19
- package/package.json +15 -2
|
@@ -1,75 +1,85 @@
|
|
|
1
|
-
import { jsxs as a, jsx as
|
|
2
|
-
import {
|
|
1
|
+
import { jsxs as a, jsx as n } from "react/jsx-runtime";
|
|
2
|
+
import { PROGRESS_DEFAULT_LABEL as E, PROGRESS_ROOT_CLASS as r, PROGRESS_BUFFER_CLASSES as L, PROGRESS_COLOR_CLASSES as O, PROGRESS_SIZE_CLASSES as P, PROGRESS_TRACK_CLASSES as y } from "./Progress.const.js";
|
|
3
|
+
import { cn as s } from "../../utils/cn.js";
|
|
3
4
|
import "react";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
5
|
+
import { resolveBearId as N } from "../../utils/generateBearId.utils.js";
|
|
6
|
+
import { useBearId as w } from "../../utils/useBearId.js";
|
|
7
|
+
const k = (S) => {
|
|
8
|
+
const {
|
|
9
|
+
id: g,
|
|
10
|
+
value: d,
|
|
11
|
+
max: i = 100,
|
|
12
|
+
bufferValue: b,
|
|
13
|
+
size: o = "md",
|
|
14
|
+
color: _ = "default",
|
|
15
|
+
showLabel: m = !1,
|
|
16
|
+
label: u = E,
|
|
17
|
+
labelPosition: c = "outside",
|
|
18
|
+
striped: l = !1,
|
|
19
|
+
animated: h = !1,
|
|
20
|
+
indeterminate: e = !1,
|
|
21
|
+
className: p,
|
|
22
|
+
testId: x
|
|
23
|
+
} = S, R = w("Progress"), v = N(g, R), t = Math.min(100, Math.max(0, d / i * 100)), f = b == null ? null : Math.min(100, Math.max(t, Math.max(0, b / i * 100)));
|
|
24
|
+
return /* @__PURE__ */ a(
|
|
25
|
+
"div",
|
|
26
|
+
{
|
|
27
|
+
id: v,
|
|
28
|
+
className: s(r, "bear-w-full", p),
|
|
29
|
+
"data-testid": x,
|
|
30
|
+
children: [
|
|
31
|
+
m && c === "outside" && /* @__PURE__ */ a("div", { className: `${r}__label-row bear-flex bear-justify-between bear-mb-1`, children: [
|
|
32
|
+
/* @__PURE__ */ n("span", { className: "bear-text-sm bear-font-medium bear-text-gray-700 dark:bear-text-gray-200", children: u }),
|
|
33
|
+
/* @__PURE__ */ a("span", { className: "bear-text-sm bear-font-medium bear-text-gray-700 dark:bear-text-gray-200", children: [
|
|
34
|
+
Math.round(t),
|
|
35
|
+
"%"
|
|
36
|
+
] })
|
|
37
|
+
] }),
|
|
38
|
+
/* @__PURE__ */ a("div", { className: s(`${r}__track`, y, P[o]), children: [
|
|
39
|
+
f != null && !e && /* @__PURE__ */ n(
|
|
40
|
+
"div",
|
|
41
|
+
{
|
|
42
|
+
className: s(
|
|
43
|
+
`${r}__buffer`,
|
|
44
|
+
"bear-absolute bear-inset-y-0 bear-left-0 bear-rounded-full",
|
|
45
|
+
L
|
|
46
|
+
),
|
|
47
|
+
style: { width: `${f}%` }
|
|
48
|
+
}
|
|
49
|
+
),
|
|
50
|
+
/* @__PURE__ */ n(
|
|
51
|
+
"div",
|
|
52
|
+
{
|
|
53
|
+
className: s(
|
|
54
|
+
`${r}__bar`,
|
|
55
|
+
"bear-relative bear-h-full bear-rounded-full bear-transition-all bear-duration-300 bear-ease-out",
|
|
56
|
+
"bear-flex bear-items-center bear-justify-center",
|
|
57
|
+
O[_],
|
|
58
|
+
l && "bear-bg-stripes",
|
|
59
|
+
h && "bear-animate-stripes",
|
|
60
|
+
e && "bear-animate-indeterminate"
|
|
61
|
+
),
|
|
62
|
+
style: {
|
|
63
|
+
width: e ? "50%" : `${t}%`,
|
|
64
|
+
backgroundSize: l ? "1rem 1rem" : void 0,
|
|
65
|
+
backgroundImage: l ? "linear-gradient(45deg, rgba(255,255,255,.15) 25%, transparent 25%, transparent 50%, rgba(255,255,255,.15) 50%, rgba(255,255,255,.15) 75%, transparent 75%, transparent)" : void 0
|
|
66
|
+
},
|
|
67
|
+
role: "progressbar",
|
|
68
|
+
"aria-valuenow": e ? void 0 : d,
|
|
69
|
+
"aria-valuemin": 0,
|
|
70
|
+
"aria-valuemax": i,
|
|
71
|
+
"aria-label": u,
|
|
72
|
+
children: m && c === "inside" && o === "lg" && !e && /* @__PURE__ */ a("span", { className: "bear-text-xs bear-font-medium bear-text-white", children: [
|
|
73
|
+
Math.round(t),
|
|
74
|
+
"%"
|
|
75
|
+
] })
|
|
76
|
+
}
|
|
77
|
+
)
|
|
78
|
+
] })
|
|
79
|
+
]
|
|
80
|
+
}
|
|
81
|
+
);
|
|
72
82
|
};
|
|
73
83
|
export {
|
|
74
|
-
|
|
84
|
+
k as Progress
|
|
75
85
|
};
|
|
@@ -1,25 +1,16 @@
|
|
|
1
1
|
export interface ProgressProps {
|
|
2
2
|
id?: string;
|
|
3
|
-
/** Progress value (0-100) */
|
|
4
3
|
value: number;
|
|
5
|
-
/** Maximum value */
|
|
6
4
|
max?: number;
|
|
7
|
-
|
|
5
|
+
bufferValue?: number;
|
|
8
6
|
size?: 'sm' | 'md' | 'lg';
|
|
9
|
-
/** Color variant */
|
|
10
7
|
color?: 'default' | 'success' | 'warning' | 'danger' | 'info';
|
|
11
|
-
/** Show percentage label */
|
|
12
8
|
showLabel?: boolean;
|
|
13
|
-
|
|
9
|
+
label?: string;
|
|
14
10
|
labelPosition?: 'inside' | 'outside';
|
|
15
|
-
/** Striped animation */
|
|
16
11
|
striped?: boolean;
|
|
17
|
-
/** Animated stripes */
|
|
18
12
|
animated?: boolean;
|
|
19
|
-
/** Indeterminate loading state */
|
|
20
13
|
indeterminate?: boolean;
|
|
21
|
-
/** Custom class name */
|
|
22
14
|
className?: string;
|
|
23
|
-
/** Test ID */
|
|
24
15
|
testId?: string;
|
|
25
16
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),c=require("react"),n=require("../../utils/cn.cjs"),j=require("../Icon/Icon.cjs"),l=require("./PropsPlayground.const.cjs"),$=require("./PropsPlayground.utils.cjs"),q=({size:b})=>e.jsx(j.Icon,{size:b,children:e.jsx("polyline",{points:"6 9 12 15 18 9"})}),I=({size:b})=>e.jsx(j.Icon,{size:b,children:e.jsx("polyline",{points:"9 18 15 12 9 6"})}),O=({size:b})=>e.jsxs(j.Icon,{size:b,children:[e.jsx("line",{x1:"4",y1:"21",x2:"4",y2:"14"}),e.jsx("line",{x1:"4",y1:"10",x2:"4",y2:"3"}),e.jsx("line",{x1:"12",y1:"21",x2:"12",y2:"12"}),e.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"3"}),e.jsx("line",{x1:"20",y1:"21",x2:"20",y2:"16"}),e.jsx("line",{x1:"20",y1:"12",x2:"20",y2:"3"}),e.jsx("line",{x1:"1",y1:"14",x2:"7",y2:"14"}),e.jsx("line",{x1:"9",y1:"8",x2:"15",y2:"8"}),e.jsx("line",{x1:"17",y1:"16",x2:"23",y2:"16"})]}),R=({config:b,render:v,title:z="Props",size:S="md",defaultCollapsed:C=!1,showReset:w=!0,columns:P=3,className:L,testId:E})=>{const u=c.useMemo(()=>$.getDefaults(b),[b]),[g,f]=c.useState(u),[m,A]=c.useState(C),o=c.useCallback((r,s)=>{f(i=>({...i,[r]:s}))},[]),_=c.useCallback(()=>{f(u)},[u]),t=l.SIZE_CLASSES[S],N=Object.keys(b).length,p=n.cn("bear-w-full bear-rounded-md bear-border bear-border-zinc-700","bear-bg-zinc-800 bear-text-zinc-100","placeholder:bear-text-zinc-500","focus:bear-outline-none focus:bear-ring-2 focus:bear-ring-primary-500/30 focus:bear-border-primary-500","bear-transition-colors",t.input);return e.jsxs("div",{"data-testid":E,className:n.cn(l.ROOT_CLASS,"bear-rounded-lg bear-border bear-border-zinc-700 bear-overflow-hidden",L),children:[e.jsxs("button",{type:"button",onClick:()=>A(r=>!r),className:n.cn("bear-w-full bear-flex bear-items-center bear-gap-2 bear-text-left bear-font-medium bear-transition-colors","bear-bg-zinc-800/60 hover:bear-bg-zinc-800","bear-text-zinc-200 bear-border-b bear-border-zinc-700","bear-px-4 bear-py-3",t.text),children:[e.jsx("span",{className:"bear-text-primary-500",children:m?e.jsx(I,{size:12}):e.jsx(q,{size:12})}),e.jsx("span",{className:"bear-text-primary-500",children:e.jsx(O,{size:14})}),e.jsx("span",{className:"bear-font-semibold",children:z}),e.jsxs("span",{className:"bear-ml-auto bear-flex bear-items-center bear-gap-2",children:[e.jsxs("span",{className:"bear-text-[10px] bear-font-medium bear-text-zinc-500",children:[N," ",N===1?"control":"controls"]}),w&&!m&&e.jsx("button",{type:"button",onClick:r=>{r.stopPropagation(),_()},className:"bear-text-[10px] bear-font-semibold bear-text-primary-500 hover:bear-text-primary-400 hover:bear-underline",children:"Reset"})]})]}),!m&&e.jsx("div",{className:n.cn("bear-bg-zinc-900/50",t.padding),children:e.jsx("div",{className:n.cn("bear-grid",t.gap,l.COLUMN_CLASSES[P]),children:Object.entries(b).map(([r,s])=>{const i=g[r],d=r.replace(/([A-Z])/g," $1").replace(/^./,a=>a.toUpperCase()).trim();if(s.type==="boolean"){const a=i===!0;return e.jsxs("div",{className:"bear-rounded-lg bear-border bear-border-zinc-700/60 bear-bg-zinc-800/30 bear-p-3",children:[e.jsx("span",{className:n.cn("bear-block bear-font-semibold bear-uppercase bear-tracking-wider bear-text-primary-500 bear-mb-2",t.label),children:l.TYPE_LABELS.boolean}),e.jsxs("label",{className:"bear-flex bear-items-center bear-gap-2.5 bear-cursor-pointer",children:[e.jsx("button",{type:"button",role:"switch","aria-checked":a,onClick:()=>o(r,!a),className:n.cn("bear-relative bear-inline-flex bear-h-5 bear-w-9 bear-flex-shrink-0 bear-rounded-full bear-border-2 bear-border-transparent bear-transition-colors",a?"bear-bg-primary-500":"bear-bg-zinc-600"),children:e.jsx("span",{className:n.cn("bear-pointer-events-none bear-inline-block bear-h-4 bear-w-4 bear-transform bear-rounded-full bear-bg-white bear-shadow bear-transition",a?"bear-translate-x-4":"bear-translate-x-0")})}),e.jsx("span",{className:n.cn("bear-font-medium bear-text-zinc-200 bear-truncate",t.text),children:d})]})]},r)}if(s.type==="select"&&s.options)return e.jsxs("div",{className:"bear-rounded-lg bear-border bear-border-zinc-700/60 bear-bg-zinc-800/30 bear-p-3",children:[e.jsxs("div",{className:"bear-flex bear-items-center bear-justify-between bear-mb-1.5",children:[e.jsx("label",{htmlFor:`pp-${r}`,className:n.cn("bear-font-medium bear-text-zinc-300 bear-truncate",t.label),children:d}),e.jsx("span",{className:n.cn("bear-font-semibold bear-uppercase bear-tracking-wider bear-text-primary-500",t.label),children:l.TYPE_LABELS.select})]}),e.jsx("select",{id:`pp-${r}`,value:String(i),onChange:a=>{const x=s.options.find(h=>String(h.value)===a.target.value);o(r,x?x.value:a.target.value)},className:n.cn(p,"bear-cursor-pointer bear-appearance-none"),children:s.options.map(a=>e.jsx("option",{value:String(a.value),children:a.label},String(a.value)))})]},r);if(s.type==="number"){const a=Number(i),x=Number.isNaN(a)?s.default:a;return e.jsxs("div",{className:"bear-rounded-lg bear-border bear-border-zinc-700/60 bear-bg-zinc-800/30 bear-p-3",children:[e.jsxs("div",{className:"bear-flex bear-items-center bear-justify-between bear-mb-1.5",children:[e.jsx("label",{htmlFor:`pp-${r}`,className:n.cn("bear-font-medium bear-text-zinc-300 bear-truncate",t.label),children:d}),e.jsx("span",{className:n.cn("bear-font-semibold bear-uppercase bear-tracking-wider bear-text-primary-500",t.label),children:l.TYPE_LABELS.number})]}),e.jsx("input",{id:`pp-${r}`,type:"number",value:x,min:s.min,max:s.max,step:s.step,onChange:h=>{const y=h.target.valueAsNumber;o(r,Number.isNaN(y)?s.default:y)},className:p})]},r)}return e.jsxs("div",{className:"bear-rounded-lg bear-border bear-border-zinc-700/60 bear-bg-zinc-800/30 bear-p-3",children:[e.jsxs("div",{className:"bear-flex bear-items-center bear-justify-between bear-mb-1.5",children:[e.jsx("label",{htmlFor:`pp-${r}`,className:n.cn("bear-font-medium bear-text-zinc-300 bear-truncate",t.label),children:d}),e.jsx("span",{className:n.cn("bear-font-semibold bear-uppercase bear-tracking-wider bear-text-primary-500",t.label),children:l.TYPE_LABELS.string})]}),e.jsx("input",{id:`pp-${r}`,type:"text",value:String(i??""),onChange:a=>o(r,a.target.value),placeholder:s.placeholder,className:p})]},r)})})}),e.jsx("div",{className:"bear-border-t bear-border-zinc-700 bear-p-6 bear-bg-zinc-900 bear-flex bear-items-center bear-justify-center bear-min-h-[180px]",children:e.jsx("div",{className:"bear-w-full",children:v(g)})})]})};exports.PropsPlayground=R;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),c=require("react"),n=require("../../utils/cn.cjs"),j=require("../Icon/Icon.cjs"),l=require("./PropsPlayground.const.cjs"),$=require("./PropsPlayground.utils.cjs"),q=({size:b})=>e.jsx(j.Icon,{size:b,children:e.jsx("polyline",{points:"6 9 12 15 18 9"})}),I=({size:b})=>e.jsx(j.Icon,{size:b,children:e.jsx("polyline",{points:"9 18 15 12 9 6"})}),O=({size:b})=>e.jsxs(j.Icon,{size:b,children:[e.jsx("line",{x1:"4",y1:"21",x2:"4",y2:"14"}),e.jsx("line",{x1:"4",y1:"10",x2:"4",y2:"3"}),e.jsx("line",{x1:"12",y1:"21",x2:"12",y2:"12"}),e.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"3"}),e.jsx("line",{x1:"20",y1:"21",x2:"20",y2:"16"}),e.jsx("line",{x1:"20",y1:"12",x2:"20",y2:"3"}),e.jsx("line",{x1:"1",y1:"14",x2:"7",y2:"14"}),e.jsx("line",{x1:"9",y1:"8",x2:"15",y2:"8"}),e.jsx("line",{x1:"17",y1:"16",x2:"23",y2:"16"})]}),R=({config:b,render:v,title:z="Props",size:S="md",defaultCollapsed:C=!1,showReset:w=!0,columns:P=3,className:L,testId:E})=>{const u=c.useMemo(()=>$.getDefaults(b),[b]),[g,f]=c.useState(u),[m,A]=c.useState(C),o=c.useCallback((r,s)=>{f(i=>({...i,[r]:s}))},[]),_=c.useCallback(()=>{f(u)},[u]),t=l.SIZE_CLASSES[S],N=Object.keys(b).length,p=n.cn("bear-w-full bear-rounded-md bear-border bear-border-zinc-700","bear-bg-zinc-800 bear-text-zinc-100","placeholder:bear-text-zinc-500","focus:bear-outline-none focus:bear-ring-2 focus:bear-ring-primary-500/30 focus:bear-border-primary-500","bear-transition-colors",t.input);return e.jsxs("div",{"data-testid":E,className:n.cn(l.ROOT_CLASS,"bear-rounded-lg bear-border bear-border-zinc-700 bear-overflow-hidden",L),children:[e.jsxs("button",{type:"button",onClick:()=>A(r=>!r),className:n.cn("bear-w-full bear-flex bear-items-center bear-gap-2 bear-text-left bear-font-medium bear-transition-colors","bear-bg-zinc-800/60 hover:bear-bg-zinc-800","bear-text-zinc-200 bear-border-b bear-border-zinc-700","bear-px-4 bear-py-3",t.text),children:[e.jsx("span",{className:"bear-text-primary-500",children:m?e.jsx(I,{size:12}):e.jsx(q,{size:12})}),e.jsx("span",{className:"bear-text-primary-500",children:e.jsx(O,{size:14})}),e.jsx("span",{className:"bear-font-semibold",children:z}),e.jsxs("span",{className:"bear-ml-auto bear-flex bear-items-center bear-gap-2",children:[e.jsxs("span",{className:"bear-text-[10px] bear-font-medium bear-text-zinc-500",children:[N," ",N===1?"control":"controls"]}),w&&!m&&e.jsx("button",{type:"button",onClick:r=>{r.stopPropagation(),_()},className:"bear-text-[10px] bear-font-semibold bear-text-primary-500 hover:bear-text-primary-400 hover:bear-underline",children:"Reset"})]})]}),!m&&e.jsx("div",{className:n.cn("bear-bg-gray-50 dark:bear-bg-zinc-900/50",t.padding),children:e.jsx("div",{className:n.cn("bear-grid",t.gap,l.COLUMN_CLASSES[P]),children:Object.entries(b).map(([r,s])=>{const i=g[r],d=r.replace(/([A-Z])/g," $1").replace(/^./,a=>a.toUpperCase()).trim();if(s.type==="boolean"){const a=i===!0;return e.jsxs("div",{className:"bear-rounded-lg bear-border bear-border-zinc-700/60 bear-bg-zinc-800/30 bear-p-3",children:[e.jsx("span",{className:n.cn("bear-block bear-font-semibold bear-uppercase bear-tracking-wider bear-text-primary-500 bear-mb-2",t.label),children:l.TYPE_LABELS.boolean}),e.jsxs("label",{className:"bear-flex bear-items-center bear-gap-2.5 bear-cursor-pointer",children:[e.jsx("button",{type:"button",role:"switch","aria-checked":a,onClick:()=>o(r,!a),className:n.cn("bear-relative bear-inline-flex bear-h-5 bear-w-9 bear-flex-shrink-0 bear-rounded-full bear-border-2 bear-border-transparent bear-transition-colors",a?"bear-bg-primary-500":"bear-bg-zinc-600"),children:e.jsx("span",{className:n.cn("bear-pointer-events-none bear-inline-block bear-h-4 bear-w-4 bear-transform bear-rounded-full bear-bg-white bear-shadow bear-transition",a?"bear-translate-x-4":"bear-translate-x-0")})}),e.jsx("span",{className:n.cn("bear-font-medium bear-text-zinc-200 bear-truncate",t.text),children:d})]})]},r)}if(s.type==="select"&&s.options)return e.jsxs("div",{className:"bear-rounded-lg bear-border bear-border-zinc-700/60 bear-bg-zinc-800/30 bear-p-3",children:[e.jsxs("div",{className:"bear-flex bear-items-center bear-justify-between bear-mb-1.5",children:[e.jsx("label",{htmlFor:`pp-${r}`,className:n.cn("bear-font-medium bear-text-zinc-300 bear-truncate",t.label),children:d}),e.jsx("span",{className:n.cn("bear-font-semibold bear-uppercase bear-tracking-wider bear-text-primary-500",t.label),children:l.TYPE_LABELS.select})]}),e.jsx("select",{id:`pp-${r}`,value:String(i),onChange:a=>{const x=s.options.find(h=>String(h.value)===a.target.value);o(r,x?x.value:a.target.value)},className:n.cn(p,"bear-cursor-pointer bear-appearance-none"),children:s.options.map(a=>e.jsx("option",{value:String(a.value),children:a.label},String(a.value)))})]},r);if(s.type==="number"){const a=Number(i),x=Number.isNaN(a)?s.default:a;return e.jsxs("div",{className:"bear-rounded-lg bear-border bear-border-zinc-700/60 bear-bg-zinc-800/30 bear-p-3",children:[e.jsxs("div",{className:"bear-flex bear-items-center bear-justify-between bear-mb-1.5",children:[e.jsx("label",{htmlFor:`pp-${r}`,className:n.cn("bear-font-medium bear-text-zinc-300 bear-truncate",t.label),children:d}),e.jsx("span",{className:n.cn("bear-font-semibold bear-uppercase bear-tracking-wider bear-text-primary-500",t.label),children:l.TYPE_LABELS.number})]}),e.jsx("input",{id:`pp-${r}`,type:"number",value:x,min:s.min,max:s.max,step:s.step,onChange:h=>{const y=h.target.valueAsNumber;o(r,Number.isNaN(y)?s.default:y)},className:p})]},r)}return e.jsxs("div",{className:"bear-rounded-lg bear-border bear-border-zinc-700/60 bear-bg-zinc-800/30 bear-p-3",children:[e.jsxs("div",{className:"bear-flex bear-items-center bear-justify-between bear-mb-1.5",children:[e.jsx("label",{htmlFor:`pp-${r}`,className:n.cn("bear-font-medium bear-text-zinc-300 bear-truncate",t.label),children:d}),e.jsx("span",{className:n.cn("bear-font-semibold bear-uppercase bear-tracking-wider bear-text-primary-500",t.label),children:l.TYPE_LABELS.string})]}),e.jsx("input",{id:`pp-${r}`,type:"text",value:String(i??""),onChange:a=>o(r,a.target.value),placeholder:s.placeholder,className:p})]},r)})})}),e.jsx("div",{className:"bear-border-t bear-border-gray-200 dark:bear-border-zinc-700 bear-p-6 bear-bg-white dark:bear-bg-zinc-900 bear-flex bear-items-center bear-justify-center bear-min-h-[180px]",children:e.jsx("div",{className:"bear-w-full",children:v(g)})})]})};exports.PropsPlayground=R;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useMemo as _, useState as z, useCallback as
|
|
1
|
+
import { jsxs as t, jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo as _, useState as z, useCallback as w } from "react";
|
|
3
3
|
import { cn as n } from "../../utils/cn.js";
|
|
4
|
-
import { Icon as
|
|
4
|
+
import { Icon as g } from "../Icon/Icon.js";
|
|
5
5
|
import { SIZE_CLASSES as F, TYPE_LABELS as m, COLUMN_CLASSES as I, ROOT_CLASS as V } from "./PropsPlayground.const.js";
|
|
6
|
-
import { getDefaults as
|
|
7
|
-
const
|
|
6
|
+
import { getDefaults as k } from "./PropsPlayground.utils.js";
|
|
7
|
+
const D = ({ size: i }) => /* @__PURE__ */ e(g, { size: i, children: /* @__PURE__ */ e("polyline", { points: "6 9 12 15 18 9" }) }), M = ({ size: i }) => /* @__PURE__ */ e(g, { size: i, children: /* @__PURE__ */ e("polyline", { points: "9 18 15 12 9 6" }) }), T = ({ size: i }) => /* @__PURE__ */ t(g, { size: i, children: [
|
|
8
8
|
/* @__PURE__ */ e("line", { x1: "4", y1: "21", x2: "4", y2: "14" }),
|
|
9
9
|
/* @__PURE__ */ e("line", { x1: "4", y1: "10", x2: "4", y2: "3" }),
|
|
10
10
|
/* @__PURE__ */ e("line", { x1: "12", y1: "21", x2: "12", y2: "12" }),
|
|
@@ -14,9 +14,9 @@ const M = ({ size: i }) => /* @__PURE__ */ e(f, { size: i, children: /* @__PURE_
|
|
|
14
14
|
/* @__PURE__ */ e("line", { x1: "1", y1: "14", x2: "7", y2: "14" }),
|
|
15
15
|
/* @__PURE__ */ e("line", { x1: "9", y1: "8", x2: "15", y2: "8" }),
|
|
16
16
|
/* @__PURE__ */ e("line", { x1: "17", y1: "16", x2: "23", y2: "16" })
|
|
17
|
-
] }),
|
|
17
|
+
] }), H = ({
|
|
18
18
|
config: i,
|
|
19
|
-
render:
|
|
19
|
+
render: C,
|
|
20
20
|
title: S = "Props",
|
|
21
21
|
size: j = "md",
|
|
22
22
|
defaultCollapsed: $ = !1,
|
|
@@ -25,12 +25,12 @@ const M = ({ size: i }) => /* @__PURE__ */ e(f, { size: i, children: /* @__PURE_
|
|
|
25
25
|
className: E,
|
|
26
26
|
testId: O
|
|
27
27
|
}) => {
|
|
28
|
-
const p = _(() =>
|
|
29
|
-
(r,
|
|
30
|
-
N((s) => ({ ...s, [r]:
|
|
28
|
+
const p = _(() => k(i), [i]), [f, N] = z(p), [u, P] = z($), o = w(
|
|
29
|
+
(r, b) => {
|
|
30
|
+
N((s) => ({ ...s, [r]: b }));
|
|
31
31
|
},
|
|
32
32
|
[]
|
|
33
|
-
), R =
|
|
33
|
+
), R = w(() => {
|
|
34
34
|
N(p);
|
|
35
35
|
}, [p]), l = F[j], v = Object.keys(i).length, h = n(
|
|
36
36
|
"bear-w-full bear-rounded-md bear-border bear-border-zinc-700",
|
|
@@ -40,7 +40,7 @@ const M = ({ size: i }) => /* @__PURE__ */ e(f, { size: i, children: /* @__PURE_
|
|
|
40
40
|
"bear-transition-colors",
|
|
41
41
|
l.input
|
|
42
42
|
);
|
|
43
|
-
return /* @__PURE__ */
|
|
43
|
+
return /* @__PURE__ */ t(
|
|
44
44
|
"div",
|
|
45
45
|
{
|
|
46
46
|
"data-testid": O,
|
|
@@ -50,7 +50,7 @@ const M = ({ size: i }) => /* @__PURE__ */ e(f, { size: i, children: /* @__PURE_
|
|
|
50
50
|
E
|
|
51
51
|
),
|
|
52
52
|
children: [
|
|
53
|
-
/* @__PURE__ */
|
|
53
|
+
/* @__PURE__ */ t(
|
|
54
54
|
"button",
|
|
55
55
|
{
|
|
56
56
|
type: "button",
|
|
@@ -63,11 +63,11 @@ const M = ({ size: i }) => /* @__PURE__ */ e(f, { size: i, children: /* @__PURE_
|
|
|
63
63
|
l.text
|
|
64
64
|
),
|
|
65
65
|
children: [
|
|
66
|
-
/* @__PURE__ */ e("span", { className: "bear-text-primary-500", children: u ? /* @__PURE__ */ e(
|
|
67
|
-
/* @__PURE__ */ e("span", { className: "bear-text-primary-500", children: /* @__PURE__ */ e(
|
|
66
|
+
/* @__PURE__ */ e("span", { className: "bear-text-primary-500", children: u ? /* @__PURE__ */ e(M, { size: 12 }) : /* @__PURE__ */ e(D, { size: 12 }) }),
|
|
67
|
+
/* @__PURE__ */ e("span", { className: "bear-text-primary-500", children: /* @__PURE__ */ e(T, { size: 14 }) }),
|
|
68
68
|
/* @__PURE__ */ e("span", { className: "bear-font-semibold", children: S }),
|
|
69
|
-
/* @__PURE__ */
|
|
70
|
-
/* @__PURE__ */
|
|
69
|
+
/* @__PURE__ */ t("span", { className: "bear-ml-auto bear-flex bear-items-center bear-gap-2", children: [
|
|
70
|
+
/* @__PURE__ */ t("span", { className: "bear-text-[10px] bear-font-medium bear-text-zinc-500", children: [
|
|
71
71
|
v,
|
|
72
72
|
" ",
|
|
73
73
|
v === 1 ? "control" : "controls"
|
|
@@ -87,17 +87,17 @@ const M = ({ size: i }) => /* @__PURE__ */ e(f, { size: i, children: /* @__PURE_
|
|
|
87
87
|
]
|
|
88
88
|
}
|
|
89
89
|
),
|
|
90
|
-
!u && /* @__PURE__ */ e("div", { className: n("bear-bg-zinc-900/50", l.padding), children: /* @__PURE__ */ e("div", { className: n("bear-grid", l.gap, I[L]), children: Object.entries(i).map(([r,
|
|
91
|
-
const s =
|
|
92
|
-
if (
|
|
90
|
+
!u && /* @__PURE__ */ e("div", { className: n("bear-bg-gray-50 dark:bear-bg-zinc-900/50", l.padding), children: /* @__PURE__ */ e("div", { className: n("bear-grid", l.gap, I[L]), children: Object.entries(i).map(([r, b]) => {
|
|
91
|
+
const s = f[r], c = r.replace(/([A-Z])/g, " $1").replace(/^./, (a) => a.toUpperCase()).trim();
|
|
92
|
+
if (b.type === "boolean") {
|
|
93
93
|
const a = s === !0;
|
|
94
|
-
return /* @__PURE__ */
|
|
94
|
+
return /* @__PURE__ */ t(
|
|
95
95
|
"div",
|
|
96
96
|
{
|
|
97
97
|
className: "bear-rounded-lg bear-border bear-border-zinc-700/60 bear-bg-zinc-800/30 bear-p-3",
|
|
98
98
|
children: [
|
|
99
99
|
/* @__PURE__ */ e("span", { className: n("bear-block bear-font-semibold bear-uppercase bear-tracking-wider bear-text-primary-500 bear-mb-2", l.label), children: m.boolean }),
|
|
100
|
-
/* @__PURE__ */
|
|
100
|
+
/* @__PURE__ */ t("label", { className: "bear-flex bear-items-center bear-gap-2.5 bear-cursor-pointer", children: [
|
|
101
101
|
/* @__PURE__ */ e(
|
|
102
102
|
"button",
|
|
103
103
|
{
|
|
@@ -127,13 +127,13 @@ const M = ({ size: i }) => /* @__PURE__ */ e(f, { size: i, children: /* @__PURE_
|
|
|
127
127
|
r
|
|
128
128
|
);
|
|
129
129
|
}
|
|
130
|
-
if (
|
|
131
|
-
return /* @__PURE__ */
|
|
130
|
+
if (b.type === "select" && b.options)
|
|
131
|
+
return /* @__PURE__ */ t(
|
|
132
132
|
"div",
|
|
133
133
|
{
|
|
134
134
|
className: "bear-rounded-lg bear-border bear-border-zinc-700/60 bear-bg-zinc-800/30 bear-p-3",
|
|
135
135
|
children: [
|
|
136
|
-
/* @__PURE__ */
|
|
136
|
+
/* @__PURE__ */ t("div", { className: "bear-flex bear-items-center bear-justify-between bear-mb-1.5", children: [
|
|
137
137
|
/* @__PURE__ */ e("label", { htmlFor: `pp-${r}`, className: n("bear-font-medium bear-text-zinc-300 bear-truncate", l.label), children: c }),
|
|
138
138
|
/* @__PURE__ */ e("span", { className: n("bear-font-semibold bear-uppercase bear-tracking-wider bear-text-primary-500", l.label), children: m.select })
|
|
139
139
|
] }),
|
|
@@ -143,25 +143,25 @@ const M = ({ size: i }) => /* @__PURE__ */ e(f, { size: i, children: /* @__PURE_
|
|
|
143
143
|
id: `pp-${r}`,
|
|
144
144
|
value: String(s),
|
|
145
145
|
onChange: (a) => {
|
|
146
|
-
const d =
|
|
146
|
+
const d = b.options.find((x) => String(x.value) === a.target.value);
|
|
147
147
|
o(r, d ? d.value : a.target.value);
|
|
148
148
|
},
|
|
149
149
|
className: n(h, "bear-cursor-pointer bear-appearance-none"),
|
|
150
|
-
children:
|
|
150
|
+
children: b.options.map((a) => /* @__PURE__ */ e("option", { value: String(a.value), children: a.label }, String(a.value)))
|
|
151
151
|
}
|
|
152
152
|
)
|
|
153
153
|
]
|
|
154
154
|
},
|
|
155
155
|
r
|
|
156
156
|
);
|
|
157
|
-
if (
|
|
158
|
-
const a = Number(s), d = Number.isNaN(a) ?
|
|
159
|
-
return /* @__PURE__ */
|
|
157
|
+
if (b.type === "number") {
|
|
158
|
+
const a = Number(s), d = Number.isNaN(a) ? b.default : a;
|
|
159
|
+
return /* @__PURE__ */ t(
|
|
160
160
|
"div",
|
|
161
161
|
{
|
|
162
162
|
className: "bear-rounded-lg bear-border bear-border-zinc-700/60 bear-bg-zinc-800/30 bear-p-3",
|
|
163
163
|
children: [
|
|
164
|
-
/* @__PURE__ */
|
|
164
|
+
/* @__PURE__ */ t("div", { className: "bear-flex bear-items-center bear-justify-between bear-mb-1.5", children: [
|
|
165
165
|
/* @__PURE__ */ e("label", { htmlFor: `pp-${r}`, className: n("bear-font-medium bear-text-zinc-300 bear-truncate", l.label), children: c }),
|
|
166
166
|
/* @__PURE__ */ e("span", { className: n("bear-font-semibold bear-uppercase bear-tracking-wider bear-text-primary-500", l.label), children: m.number })
|
|
167
167
|
] }),
|
|
@@ -171,12 +171,12 @@ const M = ({ size: i }) => /* @__PURE__ */ e(f, { size: i, children: /* @__PURE_
|
|
|
171
171
|
id: `pp-${r}`,
|
|
172
172
|
type: "number",
|
|
173
173
|
value: d,
|
|
174
|
-
min:
|
|
175
|
-
max:
|
|
176
|
-
step:
|
|
174
|
+
min: b.min,
|
|
175
|
+
max: b.max,
|
|
176
|
+
step: b.step,
|
|
177
177
|
onChange: (x) => {
|
|
178
178
|
const y = x.target.valueAsNumber;
|
|
179
|
-
o(r, Number.isNaN(y) ?
|
|
179
|
+
o(r, Number.isNaN(y) ? b.default : y);
|
|
180
180
|
},
|
|
181
181
|
className: h
|
|
182
182
|
}
|
|
@@ -186,12 +186,12 @@ const M = ({ size: i }) => /* @__PURE__ */ e(f, { size: i, children: /* @__PURE_
|
|
|
186
186
|
r
|
|
187
187
|
);
|
|
188
188
|
}
|
|
189
|
-
return /* @__PURE__ */
|
|
189
|
+
return /* @__PURE__ */ t(
|
|
190
190
|
"div",
|
|
191
191
|
{
|
|
192
192
|
className: "bear-rounded-lg bear-border bear-border-zinc-700/60 bear-bg-zinc-800/30 bear-p-3",
|
|
193
193
|
children: [
|
|
194
|
-
/* @__PURE__ */
|
|
194
|
+
/* @__PURE__ */ t("div", { className: "bear-flex bear-items-center bear-justify-between bear-mb-1.5", children: [
|
|
195
195
|
/* @__PURE__ */ e("label", { htmlFor: `pp-${r}`, className: n("bear-font-medium bear-text-zinc-300 bear-truncate", l.label), children: c }),
|
|
196
196
|
/* @__PURE__ */ e("span", { className: n("bear-font-semibold bear-uppercase bear-tracking-wider bear-text-primary-500", l.label), children: m.string })
|
|
197
197
|
] }),
|
|
@@ -202,7 +202,7 @@ const M = ({ size: i }) => /* @__PURE__ */ e(f, { size: i, children: /* @__PURE_
|
|
|
202
202
|
type: "text",
|
|
203
203
|
value: String(s ?? ""),
|
|
204
204
|
onChange: (a) => o(r, a.target.value),
|
|
205
|
-
placeholder:
|
|
205
|
+
placeholder: b.placeholder,
|
|
206
206
|
className: h
|
|
207
207
|
}
|
|
208
208
|
)
|
|
@@ -211,11 +211,11 @@ const M = ({ size: i }) => /* @__PURE__ */ e(f, { size: i, children: /* @__PURE_
|
|
|
211
211
|
r
|
|
212
212
|
);
|
|
213
213
|
}) }) }),
|
|
214
|
-
/* @__PURE__ */ e("div", { className: "bear-border-t bear-border-zinc-700 bear-p-6 bear-bg-zinc-900 bear-flex bear-items-center bear-justify-center bear-min-h-[180px]", children: /* @__PURE__ */ e("div", { className: "bear-w-full", children:
|
|
214
|
+
/* @__PURE__ */ e("div", { className: "bear-border-t bear-border-gray-200 dark:bear-border-zinc-700 bear-p-6 bear-bg-white dark:bear-bg-zinc-900 bear-flex bear-items-center bear-justify-center bear-min-h-[180px]", children: /* @__PURE__ */ e("div", { className: "bear-w-full", children: C(f) }) })
|
|
215
215
|
]
|
|
216
216
|
}
|
|
217
217
|
);
|
|
218
218
|
};
|
|
219
219
|
export {
|
|
220
|
-
|
|
220
|
+
H as PropsPlayground
|
|
221
221
|
};
|
|
@@ -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"),b=require("react"),a=require("./Select.const.cjs"),R=require("../Icon/index.cjs"),B=require("../Portal/Portal.cjs"),o=require("../../utils/cn.cjs"),U=require("../../utils/generateBearId.utils.cjs"),z=require("../../utils/useBearId.cjs"),F=require("../../hooks/useClickOutside.cjs");require("../../context/BearProvider.cjs");require("../../hooks/useBearComponent/useBearComponent.cjs");require("../FormControl/FormControl.context.cjs");const X=I=>{const{options:v,value:t,onChange:l,placeholder:E=a.SELECT_DEFAULT_PLACEHOLDER,label:c,error:n,disabled:i=!1,size:w="md",fullWidth:y=!1,displayEmpty:m=!1,renderValue:L,native:u=!1,className:p,id:A,testId:T}=I,P=z.useBearId("Select"),_=U.resolveBearId(A,P),[s,x]=b.useState(!1),[S,q]=b.useState({top:0,left:0,width:0}),h=b.useRef(null),O=b.useRef(null),f=!!n,C=v.find(e=>e.value===t),g=t===void 0||t==="",j=g||m&&g,D=b.useCallback(()=>x(!1),[]);F.useClickOutsideMultiple([h,O],D,{enabled:s&&!u});const M=e=>{l==null||l(e),x(!1)};b.useEffect(()=>{if(!s||u)return;const e=()=>{var k;const d=(k=h.current)==null?void 0:k.getBoundingClientRect();d&&q({top:d.bottom+a.SELECT_MENU_OFFSET_PX,left:Math.max(a.SELECT_MENU_EDGE_PAD_PX,Math.min(d.left,window.innerWidth-d.width-a.SELECT_MENU_EDGE_PAD_PX)),width:d.width})};return e(),window.addEventListener("resize",e),window.addEventListener("scroll",e,!0),()=>{window.removeEventListener("resize",e),window.removeEventListener("scroll",e,!0)}},[s,u]);const $=L&&!g?L(t):j||!C?E:C.label,N={backgroundColor:"var(--bear-bg-primary)",borderColor:f?void 0:"var(--bear-border-default)",color:C&&!j?"var(--bear-text-primary)":"var(--bear-text-muted)"};return u?r.jsxs("div",{id:_,"data-testid":T,className:o.cn(a.S_E_L_E_C_T_ROOT_CLASS,"bear-relative bear-flex bear-flex-col bear-gap-1.5",y&&"bear-w-full"),children:[c&&r.jsx("label",{htmlFor:`${_}-native`,className:"bear-text-sm bear-font-medium",style:{color:"var(--bear-text-secondary)"},children:c}),r.jsxs("select",{id:`${_}-native`,disabled:i,value:t??"",onChange:e=>l==null?void 0:l(e.target.value),className:o.cn(`${a.S_E_L_E_C_T_ROOT_CLASS}__native`,"bear-w-full bear-rounded-lg bear-border 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)]",f?"bear-border-red-500 focus:bear-ring-red-500":"focus:bear-border-bear-500 focus:bear-ring-bear-500",i&&"bear-opacity-50 bear-cursor-not-allowed",a.SELECT_SIZE_CLASSES[w],p),style:N,"aria-invalid":f||void 0,children:[(m||E)&&r.jsx("option",{value:"",disabled:!m,children:E}),v.map(e=>r.jsx("option",{value:e.value,disabled:e.disabled,children:e.label},e.value))]}),n&&r.jsx("p",{className:"bear-text-sm bear-text-red-500",children:n})]}):r.jsxs("div",{ref:h,id:_,"data-testid":T,className:o.cn(a.S_E_L_E_C_T_ROOT_CLASS,"bear-relative bear-flex bear-flex-col bear-gap-1.5",y&&"bear-w-full"),children:[c&&r.jsx("label",{className:"bear-text-sm bear-font-medium",style:{color:"var(--bear-text-secondary)"},children:c}),r.jsxs("button",{type:"button",disabled:i,onClick:()=>!i&&x(!s),className:o.cn(`${a.S_E_L_E_C_T_ROOT_CLASS}__trigger`,"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)]",f?"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",i&&"bear-opacity-50 bear-cursor-not-allowed",a.SELECT_SIZE_CLASSES[w],p),style:N,"aria-haspopup":"listbox","aria-expanded":s,children:[r.jsx("span",{className:`${a.S_E_L_E_C_T_ROOT_CLASS}__value`,children:$}),r.jsx(R.ChevronDownIcon,{className:o.cn("bear-w-4 bear-h-4 bear-shrink-0 bear-transition-transform",s&&"bear-rotate-180"),style:{color:"var(--bear-text-muted)"}})]}),s&&r.jsx(B.Portal,{children:r.jsx("div",{ref:O,className:`${a.S_E_L_E_C_T_ROOT_CLASS}__menu bear-fixed bear-rounded-lg bear-border bear-shadow-lg bear-overflow-hidden`,style:{backgroundColor:"var(--bear-bg-primary)",borderColor:"var(--bear-border-default)",top:S.top,left:S.left,width:S.width,zIndex:a.SELECT_MENU_Z_INDEX},role:"listbox",children:r.jsx("div",{className:"bear-max-h-60 bear-overflow-y-auto",children:v.map(e=>r.jsxs("button",{type:"button",disabled:e.disabled,onClick:()=>!e.disabled&&M(e.value),role:"option","aria-selected":e.value===t,className:o.cn(`${a.S_E_L_E_C_T_ROOT_CLASS}__option`,"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===t&&"bear-bg-bear-100 bear-text-bear-700 dark:bear-bg-bear-600/20 dark:bear-text-bear-300",!e.disabled&&e.value!==t&&"hover:bear-bg-[var(--bear-bg-tertiary)]"),style:e.disabled?{color:"var(--bear-text-muted)"}:e.value===t?void 0:{color:"var(--bear-text-secondary)"},children:[e.label,e.value===t&&r.jsx(R.CheckIcon,{className:"bear-w-4 bear-h-4 bear-shrink-0 bear-text-bear-600 dark:bear-text-bear-400"})]},e.value))})})}),n&&r.jsx("p",{className:"bear-text-sm bear-text-red-500",children:n})]})};exports.Select=X;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const E="Bear-Select",_="Select an option",S=4,e=8,L=1e4,t={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"};exports.SELECT_DEFAULT_PLACEHOLDER=_;exports.SELECT_MENU_EDGE_PAD_PX=e;exports.SELECT_MENU_OFFSET_PX=S;exports.SELECT_MENU_Z_INDEX=L;exports.SELECT_SIZE_CLASSES=t;exports.S_E_L_E_C_T_ROOT_CLASS=E;
|
|
@@ -1 +1,10 @@
|
|
|
1
1
|
export declare const S_E_L_E_C_T_ROOT_CLASS = "Bear-Select";
|
|
2
|
+
export declare const SELECT_DEFAULT_PLACEHOLDER = "Select an option";
|
|
3
|
+
export declare const SELECT_MENU_OFFSET_PX = 4;
|
|
4
|
+
export declare const SELECT_MENU_EDGE_PAD_PX = 8;
|
|
5
|
+
export declare const SELECT_MENU_Z_INDEX = 10000;
|
|
6
|
+
export declare const SELECT_SIZE_CLASSES: {
|
|
7
|
+
readonly sm: "bear-h-8 bear-text-sm bear-px-3";
|
|
8
|
+
readonly md: "bear-h-10 bear-text-base bear-px-4";
|
|
9
|
+
readonly lg: "bear-h-12 bear-text-lg bear-px-5";
|
|
10
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const E = "Bear-Select", _ = "Select an option", e = 4, t = 8, S = 1e4, a = {
|
|
2
|
+
sm: "bear-h-8 bear-text-sm bear-px-3",
|
|
3
|
+
md: "bear-h-10 bear-text-base bear-px-4",
|
|
4
|
+
lg: "bear-h-12 bear-text-lg bear-px-5"
|
|
5
|
+
};
|
|
6
|
+
export {
|
|
7
|
+
_ as SELECT_DEFAULT_PLACEHOLDER,
|
|
8
|
+
t as SELECT_MENU_EDGE_PAD_PX,
|
|
9
|
+
e as SELECT_MENU_OFFSET_PX,
|
|
10
|
+
S as SELECT_MENU_Z_INDEX,
|
|
11
|
+
a as SELECT_SIZE_CLASSES,
|
|
12
|
+
E as S_E_L_E_C_T_ROOT_CLASS
|
|
13
|
+
};
|