@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 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const yt=require("react/jsx-runtime"),o=require("react"),$=require("./bearProvider.const.cjs"),B=require("./defaultTheme.cjs"),k=o.createContext(null),ht="bear-theme-mode",gt=["primary","secondary","success","warning","danger","info","ghost","outline","error"],rt=t=>{const u=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);return u?{r:parseInt(u[1],16),g:parseInt(u[2],16),b:parseInt(u[3],16)}:null},st=(t,u,n)=>"#"+[t,u,n].map(i=>{const s=Math.max(0,Math.min(255,Math.round(i))).toString(16);return s.length===1?"0"+s:s}).join(""),E=(t,u)=>{const n=rt(t);if(!n)return t;const i=u/100;return st(n.r+(255-n.r)*i,n.g+(255-n.g)*i,n.b+(255-n.b)*i)},O=(t,u)=>{const n=rt(t);if(!n)return t;const i=1-u/100;return st(n.r*i,n.g*i,n.b*i)},mt=t=>({50:E(t,95),100:E(t,85),200:E(t,70),300:E(t,50),400:E(t,25),500:t,600:O(t,10),700:O(t,25),800:O(t,40),900:O(t,55),950:O(t,70)}),$t=t=>typeof t!="string"?!1:t.startsWith("#")||t.startsWith("rgb")||/^[a-z]+$/i.test(t),tt={red:"#ef4444",blue:"#3b82f6",green:"#22c55e",yellow:"#eab308",orange:"#f97316",purple:"#a855f7",pink:"#ec4899",cyan:"#06b6d4",teal:"#14b8a6",indigo:"#6366f1",violet:"#8b5cf6",rose:"#f43f5e",amber:"#f59e0b",lime:"#84cc16",emerald:"#10b981",sky:"#0ea5e9",slate:"#64748b",gray:"#6b7280",zinc:"#71717a",neutral:"#737373",stone:"#78716c",white:"#ffffff",black:"#000000"},kt=t=>{const u=t.toLowerCase();return tt[u]?tt[u]:(t.startsWith("#"),t)};function j(t,u){if(!u)return t;const n={...t},i=t,s=u,b=n;for(const p in s)if(Object.prototype.hasOwnProperty.call(s,p)){const a=s[p],r=i[p];a&&typeof a=="object"&&!Array.isArray(a)&&r&&typeof r=="object"&&!Array.isArray(r)?b[p]=j(r,a):a!==void 0&&(b[p]=a)}return n}const et=(t,u,n,i)=>{const s=[],b=(a,r)=>{Object.entries(r).forEach(([w,I])=>{s.push(`--bear-${a}-${w}:${I}`)})};b("primary",t.colors.primary),b("secondary",t.colors.secondary),b("success",t.colors.success),b("warning",t.colors.warning),b("danger",t.colors.danger),b("info",t.colors.info),b("neutral",t.colors.neutral),s.push(`--bear-bg-primary:${t.colors.background.primary}`),s.push(`--bear-bg-secondary:${t.colors.background.secondary}`),s.push(`--bear-bg-tertiary:${t.colors.background.tertiary}`),s.push(`--bear-text-primary:${t.colors.text.primary}`),s.push(`--bear-text-secondary:${t.colors.text.secondary}`),s.push(`--bear-text-muted:${t.colors.text.muted}`),s.push(`--bear-text-inverted:${t.colors.text.inverted}`),s.push(`--bear-border-default:${t.colors.border.default}`),s.push(`--bear-border-subtle:${t.colors.border.subtle}`),s.push(`--bear-border-strong:${t.colors.border.strong}`),u!=null&&u.Button&&Object.entries(u.Button).forEach(([a,r])=>{r&&(r.bg&&s.push(`--bear-btn-${a}-bg:${r.bg}`),r.bgHover&&s.push(`--bear-btn-${a}-bg-hover:${r.bgHover}`),r.bgActive&&s.push(`--bear-btn-${a}-bg-active:${r.bgActive}`),r.bgDisabled&&s.push(`--bear-btn-${a}-bg-disabled:${r.bgDisabled}`),r.text&&s.push(`--bear-btn-${a}-text:${r.text}`),r.textDisabled&&s.push(`--bear-btn-${a}-text-disabled:${r.textDisabled}`),r.border&&s.push(`--bear-btn-${a}-border:${r.border}`),r.borderHover&&s.push(`--bear-btn-${a}-border-hover:${r.borderHover}`),r.ring&&s.push(`--bear-btn-${a}-ring:${r.ring}`))}),Object.entries(n).forEach(([a,r])=>{s.push(`--bear-${a}-bg:${r.bg}`),r.bgHover&&s.push(`--bear-${a}-bg-hover:${r.bgHover}`),r.bgActive&&s.push(`--bear-${a}-bg-active:${r.bgActive}`),r.text&&s.push(`--bear-${a}-text:${r.text}`),r.border&&s.push(`--bear-${a}-border:${r.border}`),r.ring&&s.push(`--bear-${a}-ring:${r.ring}`)}),s.push(`--bear-font-sans:${t.typography.fontFamily.sans}`),s.push(`--bear-font-mono:${t.typography.fontFamily.mono}`),Object.entries(t.shadows).forEach(([a,r])=>{s.push(`--bear-shadow-${a}:${r}`)}),Object.entries(t.borderRadius).forEach(([a,r])=>{s.push(`--bear-radius-${a}:${r}`)}),Object.entries(t.spacing).forEach(([a,r])=>{s.push(`--bear-spacing-${a}:${r}`)});const p=i==="compact"?$.DENSITY_SCALE_COMPACT:$.DENSITY_SCALE_COMFORTABLE;return s.push(`${$.DENSITY_CSS_VAR}:${p}`),s.join(";")},Dt=({children:t,defaultMode:u="light",mode:n,onModeChange:i,direction:s=$.DEFAULT_DIRECTION,density:b=$.DEFAULT_DENSITY,theme:p,components:a={},defaultProps:r={},variants:w={},customVariants:I={},customTypography:ot={},persistPreference:D=!0,storageKey:x=ht})=>{const[nt,L]=o.useState(()=>{if(n!==void 0)return n;if(typeof window<"u"&&D){const e=localStorage.getItem(x);if(e==="light"||e==="dark")return e;if(window.matchMedia("(prefers-color-scheme: dark)").matches)return"dark"}return u}),y=n??nt,[S,at]=o.useState(s),[f,ut]=o.useState(b),[T,it]=o.useState(p||{}),[R,ct]=o.useState(a),[V]=o.useState(r),[h,bt]=o.useState(w),[l,dt]=o.useState(I),[g,lt]=o.useState(ot),m=o.useMemo(()=>{if(!T||Object.keys(T).length===0)return{};const e={...T};if(e.colors){const c=["primary","secondary","success","warning","danger","info","neutral"];for(const d of c){const M=e.colors[d];if($t(M)){const ft=kt(M);e.colors[d]=mt(ft)}}}return e},[T]),C=o.useMemo(()=>Object.keys(m).length===0?B.defaultLightTheme:j(B.defaultLightTheme,m),[m]),_=o.useMemo(()=>Object.keys(m).length===0?B.defaultDarkTheme:j(B.defaultDarkTheme,m),[m]),v=y==="dark"?_:C,N=o.useMemo(()=>et(C,h,l,f),[C,h,l,f]),F=o.useMemo(()=>et(_,h,l,f),[_,h,l,f]),H=o.useCallback(e=>{n===void 0&&L(e),i==null||i(e),typeof window<"u"&&D&&localStorage.setItem(x,e)},[n,i,D,x]),Y=o.useCallback(e=>{at(e)},[]),P=o.useCallback(e=>{ut(e)},[]),U=o.useCallback(()=>{if(n!==void 0){const e=n==="light"?"dark":"light";i==null||i(e);return}o.startTransition(()=>{L(e=>{const c=e==="light"?"dark":"light";return i==null||i(c),typeof window<"u"&&D&&localStorage.setItem(x,c),c})})},[n,i,D,x]),q=o.useCallback(e=>{it(c=>j(c,e))},[]),z=o.useCallback((e,c)=>{ct(d=>({...d,[e]:{...d[e]||{},...c}}))},[]),W=o.useCallback((e,c)=>{bt(d=>({...d,[e]:{...d[e]||{},...c}}))},[]),G=o.useCallback(e=>gt.includes(e)||e in l,[l]),J=o.useCallback(e=>l[e],[l]),Q=o.useCallback((e,c)=>{dt(d=>({...d,[e]:c}))},[]),X=o.useCallback(e=>e in g,[g]),Z=o.useCallback(e=>g[e],[g]),K=o.useCallback((e,c)=>{lt(d=>({...d,[e]:c}))},[]);o.useEffect(()=>{n!==void 0&&L(n)},[n]),o.useEffect(()=>{if(typeof document>"u")return;const e="bear-theme-vars";let c=document.getElementById(e);c||(c=document.createElement("style"),c.id=e,document.head.appendChild(c)),c.textContent=`:root.bear-light,:root:not(.dark){${N}}:root.bear-dark,:root.dark,.dark{${F}}`},[N,F]),o.useEffect(()=>{if(typeof document>"u")return;const e=document.documentElement;e.classList.toggle("dark",y==="dark"),e.classList.remove("bear-light","bear-dark"),e.classList.add(y==="dark"?"bear-dark":"bear-light"),e.setAttribute("dir",S),e.classList.toggle("bear-rtl",S==="rtl"),e.classList.toggle("bear-density-compact",f==="compact")},[y,S,f]);const pt=o.useMemo(()=>({theme:v,mode:y,setMode:H,toggleMode:U,updateTheme:q,direction:S,setDirection:Y,density:f,setDensity:P,defaultProps:V,components:R,variants:h,customVariants:l,hasVariant:G,getVariant:J,addVariant:Q,customTypography:g,hasTypography:X,getTypography:Z,addTypography:K,registerComponent:z,registerVariant:W}),[v,y,H,U,q,S,Y,f,P,V,R,h,l,G,J,Q,g,X,Z,K,z,W]);return yt.jsx(k.Provider,{value:pt,children:t})},A=()=>{const t=o.useContext(k);if(!t)throw new Error("useBear must be used within a BearProvider");return t},xt=()=>{const{theme:t}=A();return t},St=()=>{const t=o.useContext(k);return t?t.theme:B.defaultDarkTheme},Et=()=>{const{mode:t,setMode:u,toggleMode:n}=A();return{mode:t,setMode:u,toggleMode:n}},Ot=()=>{const{direction:t,setDirection:u}=A();return{direction:t,setDirection:u}},Bt=()=>{const t=o.useContext(k);return t?{direction:t.direction,setDirection:t.setDirection}:{direction:"ltr",setDirection:u=>{}}},At=()=>{const{density:t,setDensity:u}=A();return{density:t,setDensity:u}},Tt=()=>{const t=o.useContext(k);return t?{density:t.density,setDensity:t.setDensity}:{density:$.DEFAULT_DENSITY,setDensity:u=>{}}};exports.BearContext=k;exports.BearProvider=Dt;exports.useBear=A;exports.useBearDensity=At;exports.useBearDensityOptional=Tt;exports.useBearDirection=Ot;exports.useBearDirectionOptional=Bt;exports.useBearMode=Et;exports.useBearTheme=xt;exports.useBearThemeOptional=St;
|
|
@@ -118,10 +118,18 @@ export declare const useBearDirection: () => {
|
|
|
118
118
|
direction: BearDirection;
|
|
119
119
|
setDirection: (direction: BearDirection) => void;
|
|
120
120
|
};
|
|
121
|
+
export declare const useBearDirectionOptional: () => {
|
|
122
|
+
direction: BearDirection;
|
|
123
|
+
setDirection: (direction: BearDirection) => void;
|
|
124
|
+
};
|
|
121
125
|
export declare const useBearDensity: () => {
|
|
122
126
|
density: BearDensity;
|
|
123
127
|
setDensity: (density: BearDensity) => void;
|
|
124
128
|
};
|
|
129
|
+
export declare const useBearDensityOptional: () => {
|
|
130
|
+
density: BearDensity;
|
|
131
|
+
setDensity: (density: BearDensity) => void;
|
|
132
|
+
};
|
|
125
133
|
/**
|
|
126
134
|
* Hook to work with custom variants
|
|
127
135
|
*
|
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { createContext as kt, useContext as
|
|
3
|
-
import { DEFAULT_DIRECTION as Et, DEFAULT_DENSITY as
|
|
4
|
-
import { defaultDarkTheme as
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
return
|
|
8
|
-
r: parseInt(
|
|
9
|
-
g: parseInt(
|
|
10
|
-
b: parseInt(
|
|
1
|
+
import { jsx as xt } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as kt, useContext as I, useState as f, useMemo as x, useCallback as u, startTransition as Dt, useEffect as N } from "react";
|
|
3
|
+
import { DEFAULT_DIRECTION as Et, DEFAULT_DENSITY as it, DENSITY_CSS_VAR as Ot, DENSITY_SCALE_COMPACT as St, DENSITY_SCALE_COMFORTABLE as wt } from "./bearProvider.const.js";
|
|
4
|
+
import { defaultDarkTheme as R, defaultLightTheme as st } from "./defaultTheme.js";
|
|
5
|
+
const w = kt(null), At = "bear-theme-mode", jt = ["primary", "secondary", "success", "warning", "danger", "info", "ghost", "outline", "error"], at = (t) => {
|
|
6
|
+
const i = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);
|
|
7
|
+
return i ? {
|
|
8
|
+
r: parseInt(i[1], 16),
|
|
9
|
+
g: parseInt(i[2], 16),
|
|
10
|
+
b: parseInt(i[3], 16)
|
|
11
11
|
} : null;
|
|
12
|
-
}, ct = (t,
|
|
13
|
-
const s = Math.max(0, Math.min(255, Math.round(
|
|
12
|
+
}, ct = (t, i, o) => "#" + [t, i, o].map((a) => {
|
|
13
|
+
const s = Math.max(0, Math.min(255, Math.round(a))).toString(16);
|
|
14
14
|
return s.length === 1 ? "0" + s : s;
|
|
15
|
-
}).join(""),
|
|
15
|
+
}).join(""), O = (t, i) => {
|
|
16
16
|
const o = at(t);
|
|
17
17
|
if (!o) return t;
|
|
18
|
-
const
|
|
18
|
+
const a = i / 100;
|
|
19
19
|
return ct(
|
|
20
|
-
o.r + (255 - o.r) *
|
|
21
|
-
o.g + (255 - o.g) *
|
|
22
|
-
o.b + (255 - o.b) *
|
|
20
|
+
o.r + (255 - o.r) * a,
|
|
21
|
+
o.g + (255 - o.g) * a,
|
|
22
|
+
o.b + (255 - o.b) * a
|
|
23
23
|
);
|
|
24
|
-
},
|
|
24
|
+
}, S = (t, i) => {
|
|
25
25
|
const o = at(t);
|
|
26
26
|
if (!o) return t;
|
|
27
|
-
const
|
|
28
|
-
return ct(o.r *
|
|
27
|
+
const a = 1 - i / 100;
|
|
28
|
+
return ct(o.r * a, o.g * a, o.b * a);
|
|
29
29
|
}, It = (t) => ({
|
|
30
|
-
50:
|
|
31
|
-
100:
|
|
32
|
-
200:
|
|
33
|
-
300:
|
|
34
|
-
400:
|
|
30
|
+
50: O(t, 95),
|
|
31
|
+
100: O(t, 85),
|
|
32
|
+
200: O(t, 70),
|
|
33
|
+
300: O(t, 50),
|
|
34
|
+
400: O(t, 25),
|
|
35
35
|
500: t,
|
|
36
|
-
600:
|
|
37
|
-
700:
|
|
38
|
-
800:
|
|
39
|
-
900:
|
|
40
|
-
950:
|
|
41
|
-
}),
|
|
36
|
+
600: S(t, 10),
|
|
37
|
+
700: S(t, 25),
|
|
38
|
+
800: S(t, 40),
|
|
39
|
+
900: S(t, 55),
|
|
40
|
+
950: S(t, 70)
|
|
41
|
+
}), Bt = (t) => typeof t != "string" ? !1 : t.startsWith("#") || t.startsWith("rgb") || /^[a-z]+$/i.test(t), ot = {
|
|
42
42
|
red: "#ef4444",
|
|
43
43
|
blue: "#3b82f6",
|
|
44
44
|
green: "#22c55e",
|
|
@@ -62,30 +62,30 @@ const N = kt(null), At = "bear-theme-mode", jt = ["primary", "secondary", "succe
|
|
|
62
62
|
stone: "#78716c",
|
|
63
63
|
white: "#ffffff",
|
|
64
64
|
black: "#000000"
|
|
65
|
-
},
|
|
66
|
-
const
|
|
67
|
-
return
|
|
65
|
+
}, Lt = (t) => {
|
|
66
|
+
const i = t.toLowerCase();
|
|
67
|
+
return ot[i] ? ot[i] : (t.startsWith("#"), t);
|
|
68
68
|
};
|
|
69
|
-
function
|
|
70
|
-
if (!
|
|
71
|
-
const o = { ...t },
|
|
69
|
+
function j(t, i) {
|
|
70
|
+
if (!i) return t;
|
|
71
|
+
const o = { ...t }, a = t, s = i, b = o;
|
|
72
72
|
for (const l in s)
|
|
73
73
|
if (Object.prototype.hasOwnProperty.call(s, l)) {
|
|
74
|
-
const n = s[l], e =
|
|
75
|
-
n && typeof n == "object" && !Array.isArray(n) && e && typeof e == "object" && !Array.isArray(e) ? b[l] =
|
|
74
|
+
const n = s[l], e = a[l];
|
|
75
|
+
n && typeof n == "object" && !Array.isArray(n) && e && typeof e == "object" && !Array.isArray(e) ? b[l] = j(
|
|
76
76
|
e,
|
|
77
77
|
n
|
|
78
78
|
) : n !== void 0 && (b[l] = n);
|
|
79
79
|
}
|
|
80
80
|
return o;
|
|
81
81
|
}
|
|
82
|
-
const
|
|
82
|
+
const nt = (t, i, o, a) => {
|
|
83
83
|
const s = [], b = (n, e) => {
|
|
84
|
-
Object.entries(e).forEach(([
|
|
85
|
-
s.push(`--bear-${n}-${
|
|
84
|
+
Object.entries(e).forEach(([L, _]) => {
|
|
85
|
+
s.push(`--bear-${n}-${L}:${_}`);
|
|
86
86
|
});
|
|
87
87
|
};
|
|
88
|
-
b("primary", t.colors.primary), b("secondary", t.colors.secondary), b("success", t.colors.success), b("warning", t.colors.warning), b("danger", t.colors.danger), b("info", t.colors.info), b("neutral", t.colors.neutral), s.push(`--bear-bg-primary:${t.colors.background.primary}`), s.push(`--bear-bg-secondary:${t.colors.background.secondary}`), s.push(`--bear-bg-tertiary:${t.colors.background.tertiary}`), s.push(`--bear-text-primary:${t.colors.text.primary}`), s.push(`--bear-text-secondary:${t.colors.text.secondary}`), s.push(`--bear-text-muted:${t.colors.text.muted}`), s.push(`--bear-text-inverted:${t.colors.text.inverted}`), s.push(`--bear-border-default:${t.colors.border.default}`), s.push(`--bear-border-subtle:${t.colors.border.subtle}`), s.push(`--bear-border-strong:${t.colors.border.strong}`),
|
|
88
|
+
b("primary", t.colors.primary), b("secondary", t.colors.secondary), b("success", t.colors.success), b("warning", t.colors.warning), b("danger", t.colors.danger), b("info", t.colors.info), b("neutral", t.colors.neutral), s.push(`--bear-bg-primary:${t.colors.background.primary}`), s.push(`--bear-bg-secondary:${t.colors.background.secondary}`), s.push(`--bear-bg-tertiary:${t.colors.background.tertiary}`), s.push(`--bear-text-primary:${t.colors.text.primary}`), s.push(`--bear-text-secondary:${t.colors.text.secondary}`), s.push(`--bear-text-muted:${t.colors.text.muted}`), s.push(`--bear-text-inverted:${t.colors.text.inverted}`), s.push(`--bear-border-default:${t.colors.border.default}`), s.push(`--bear-border-subtle:${t.colors.border.subtle}`), s.push(`--bear-border-strong:${t.colors.border.strong}`), i != null && i.Button && Object.entries(i.Button).forEach(([n, e]) => {
|
|
89
89
|
e && (e.bg && s.push(`--bear-btn-${n}-bg:${e.bg}`), e.bgHover && s.push(`--bear-btn-${n}-bg-hover:${e.bgHover}`), e.bgActive && s.push(`--bear-btn-${n}-bg-active:${e.bgActive}`), e.bgDisabled && s.push(`--bear-btn-${n}-bg-disabled:${e.bgDisabled}`), e.text && s.push(`--bear-btn-${n}-text:${e.text}`), e.textDisabled && s.push(`--bear-btn-${n}-text-disabled:${e.textDisabled}`), e.border && s.push(`--bear-btn-${n}-border:${e.border}`), e.borderHover && s.push(`--bear-btn-${n}-border-hover:${e.borderHover}`), e.ring && s.push(`--bear-btn-${n}-ring:${e.ring}`));
|
|
90
90
|
}), Object.entries(o).forEach(([n, e]) => {
|
|
91
91
|
s.push(`--bear-${n}-bg:${e.bg}`), e.bgHover && s.push(`--bear-${n}-bg-hover:${e.bgHover}`), e.bgActive && s.push(`--bear-${n}-bg-active:${e.bgActive}`), e.text && s.push(`--bear-${n}-text:${e.text}`), e.border && s.push(`--bear-${n}-border:${e.border}`), e.ring && s.push(`--bear-${n}-ring:${e.ring}`);
|
|
@@ -96,167 +96,177 @@ const ot = (t, a, o, c) => {
|
|
|
96
96
|
}), Object.entries(t.spacing).forEach(([n, e]) => {
|
|
97
97
|
s.push(`--bear-spacing-${n}:${e}`);
|
|
98
98
|
});
|
|
99
|
-
const l =
|
|
100
|
-
return s.push(`${
|
|
99
|
+
const l = a === "compact" ? St : wt;
|
|
100
|
+
return s.push(`${Ot}:${l}`), s.join(";");
|
|
101
101
|
}, Nt = ({
|
|
102
102
|
children: t,
|
|
103
|
-
defaultMode:
|
|
103
|
+
defaultMode: i = "light",
|
|
104
104
|
mode: o,
|
|
105
|
-
onModeChange:
|
|
105
|
+
onModeChange: a,
|
|
106
106
|
direction: s = Et,
|
|
107
|
-
density: b =
|
|
107
|
+
density: b = it,
|
|
108
108
|
theme: l,
|
|
109
109
|
components: n = {},
|
|
110
110
|
defaultProps: e = {},
|
|
111
|
-
variants:
|
|
112
|
-
customVariants:
|
|
111
|
+
variants: L = {},
|
|
112
|
+
customVariants: _ = {},
|
|
113
113
|
customTypography: ut = {},
|
|
114
|
-
persistPreference:
|
|
115
|
-
storageKey:
|
|
114
|
+
persistPreference: k = !0,
|
|
115
|
+
storageKey: D = At
|
|
116
116
|
}) => {
|
|
117
|
-
const [
|
|
117
|
+
const [bt, T] = f(() => {
|
|
118
118
|
if (o !== void 0)
|
|
119
119
|
return o;
|
|
120
|
-
if (typeof window < "u" &&
|
|
121
|
-
const r = localStorage.getItem(
|
|
120
|
+
if (typeof window < "u" && k) {
|
|
121
|
+
const r = localStorage.getItem(D);
|
|
122
122
|
if (r === "light" || r === "dark")
|
|
123
123
|
return r;
|
|
124
124
|
if (window.matchMedia("(prefers-color-scheme: dark)").matches)
|
|
125
125
|
return "dark";
|
|
126
126
|
}
|
|
127
|
-
return
|
|
128
|
-
}),
|
|
129
|
-
if (!
|
|
127
|
+
return i;
|
|
128
|
+
}), h = o ?? bt, [E, dt] = f(s), [y, pt] = f(b), [A, lt] = f(l || {}), [F, ft] = f(n), [Y] = f(e), [g, yt] = f(L), [p, ht] = f(_), [$, gt] = f(ut), m = x(() => {
|
|
129
|
+
if (!A || Object.keys(A).length === 0)
|
|
130
130
|
return {};
|
|
131
|
-
const r = { ...
|
|
131
|
+
const r = { ...A };
|
|
132
132
|
if (r.colors) {
|
|
133
|
-
const
|
|
134
|
-
for (const d of
|
|
135
|
-
const
|
|
136
|
-
if (
|
|
137
|
-
const
|
|
138
|
-
r.colors[d] = It(
|
|
133
|
+
const c = ["primary", "secondary", "success", "warning", "danger", "info", "neutral"];
|
|
134
|
+
for (const d of c) {
|
|
135
|
+
const et = r.colors[d];
|
|
136
|
+
if (Bt(et)) {
|
|
137
|
+
const mt = Lt(et);
|
|
138
|
+
r.colors[d] = It(mt);
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
141
|
}
|
|
142
142
|
return r;
|
|
143
|
-
}, [
|
|
144
|
-
() =>
|
|
145
|
-
[
|
|
146
|
-
), U =
|
|
147
|
-
() =>
|
|
148
|
-
[
|
|
149
|
-
),
|
|
150
|
-
o === void 0 &&
|
|
151
|
-
}, [o,
|
|
152
|
-
bt(r);
|
|
153
|
-
}, []), W = i((r) => {
|
|
143
|
+
}, [A]), V = x(() => Object.keys(m).length === 0 ? st : j(st, m), [m]), H = x(() => Object.keys(m).length === 0 ? R : j(R, m), [m]), v = h === "dark" ? H : V, z = x(
|
|
144
|
+
() => nt(V, g, p, y),
|
|
145
|
+
[V, g, p, y]
|
|
146
|
+
), U = x(
|
|
147
|
+
() => nt(H, g, p, y),
|
|
148
|
+
[H, g, p, y]
|
|
149
|
+
), P = u((r) => {
|
|
150
|
+
o === void 0 && T(r), a == null || a(r), typeof window < "u" && k && localStorage.setItem(D, r);
|
|
151
|
+
}, [o, a, k, D]), W = u((r) => {
|
|
154
152
|
dt(r);
|
|
155
|
-
}, []), C =
|
|
153
|
+
}, []), C = u((r) => {
|
|
154
|
+
pt(r);
|
|
155
|
+
}, []), G = u(() => {
|
|
156
156
|
if (o !== void 0) {
|
|
157
157
|
const r = o === "light" ? "dark" : "light";
|
|
158
|
-
|
|
158
|
+
a == null || a(r);
|
|
159
159
|
return;
|
|
160
160
|
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
const
|
|
164
|
-
return
|
|
161
|
+
Dt(() => {
|
|
162
|
+
T((r) => {
|
|
163
|
+
const c = r === "light" ? "dark" : "light";
|
|
164
|
+
return a == null || a(c), typeof window < "u" && k && localStorage.setItem(D, c), c;
|
|
165
165
|
});
|
|
166
166
|
});
|
|
167
|
-
}, [o,
|
|
168
|
-
|
|
169
|
-
}, []),
|
|
170
|
-
|
|
167
|
+
}, [o, a, k, D]), q = u((r) => {
|
|
168
|
+
lt((c) => j(c, r));
|
|
169
|
+
}, []), J = u((r, c) => {
|
|
170
|
+
ft((d) => ({
|
|
171
171
|
...d,
|
|
172
172
|
[r]: {
|
|
173
173
|
...d[r] || {},
|
|
174
|
-
...
|
|
174
|
+
...c
|
|
175
175
|
}
|
|
176
176
|
}));
|
|
177
|
-
}, []),
|
|
178
|
-
|
|
177
|
+
}, []), Q = u((r, c) => {
|
|
178
|
+
yt((d) => ({
|
|
179
179
|
...d,
|
|
180
180
|
[r]: {
|
|
181
181
|
...d[r] || {},
|
|
182
|
-
...
|
|
182
|
+
...c
|
|
183
183
|
}
|
|
184
184
|
}));
|
|
185
|
-
}, []),
|
|
185
|
+
}, []), X = u((r) => jt.includes(r) || r in p, [p]), Z = u((r) => p[r], [p]), K = u((r, c) => {
|
|
186
186
|
ht((d) => ({
|
|
187
187
|
...d,
|
|
188
|
-
[r]:
|
|
188
|
+
[r]: c
|
|
189
189
|
}));
|
|
190
|
-
}, []),
|
|
191
|
-
|
|
190
|
+
}, []), M = u((r) => r in $, [$]), tt = u((r) => $[r], [$]), rt = u((r, c) => {
|
|
191
|
+
gt((d) => ({
|
|
192
192
|
...d,
|
|
193
|
-
[r]:
|
|
193
|
+
[r]: c
|
|
194
194
|
}));
|
|
195
195
|
}, []);
|
|
196
|
-
|
|
197
|
-
o !== void 0 &&
|
|
198
|
-
}, [o]),
|
|
196
|
+
N(() => {
|
|
197
|
+
o !== void 0 && T(o);
|
|
198
|
+
}, [o]), N(() => {
|
|
199
199
|
if (typeof document > "u") return;
|
|
200
200
|
const r = "bear-theme-vars";
|
|
201
|
-
let
|
|
202
|
-
|
|
203
|
-
}, [z, U]),
|
|
201
|
+
let c = document.getElementById(r);
|
|
202
|
+
c || (c = document.createElement("style"), c.id = r, document.head.appendChild(c)), c.textContent = `:root.bear-light,:root:not(.dark){${z}}:root.bear-dark,:root.dark,.dark{${U}}`;
|
|
203
|
+
}, [z, U]), N(() => {
|
|
204
204
|
if (typeof document > "u") return;
|
|
205
205
|
const r = document.documentElement;
|
|
206
|
-
r.classList.toggle("dark",
|
|
207
|
-
}, [
|
|
208
|
-
const
|
|
209
|
-
theme:
|
|
210
|
-
mode:
|
|
211
|
-
setMode:
|
|
212
|
-
toggleMode:
|
|
213
|
-
updateTheme:
|
|
214
|
-
direction:
|
|
215
|
-
setDirection:
|
|
216
|
-
density:
|
|
217
|
-
setDensity:
|
|
218
|
-
defaultProps:
|
|
219
|
-
components:
|
|
206
|
+
r.classList.toggle("dark", h === "dark"), r.classList.remove("bear-light", "bear-dark"), r.classList.add(h === "dark" ? "bear-dark" : "bear-light"), r.setAttribute("dir", E), r.classList.toggle("bear-rtl", E === "rtl"), r.classList.toggle("bear-density-compact", y === "compact");
|
|
207
|
+
}, [h, E, y]);
|
|
208
|
+
const $t = x(() => ({
|
|
209
|
+
theme: v,
|
|
210
|
+
mode: h,
|
|
211
|
+
setMode: P,
|
|
212
|
+
toggleMode: G,
|
|
213
|
+
updateTheme: q,
|
|
214
|
+
direction: E,
|
|
215
|
+
setDirection: W,
|
|
216
|
+
density: y,
|
|
217
|
+
setDensity: C,
|
|
218
|
+
defaultProps: Y,
|
|
219
|
+
components: F,
|
|
220
220
|
variants: g,
|
|
221
221
|
customVariants: p,
|
|
222
|
-
hasVariant:
|
|
223
|
-
getVariant:
|
|
224
|
-
addVariant:
|
|
222
|
+
hasVariant: X,
|
|
223
|
+
getVariant: Z,
|
|
224
|
+
addVariant: K,
|
|
225
225
|
customTypography: $,
|
|
226
|
-
hasTypography:
|
|
227
|
-
getTypography:
|
|
228
|
-
addTypography:
|
|
229
|
-
registerComponent:
|
|
230
|
-
registerVariant:
|
|
231
|
-
}), [
|
|
232
|
-
return /* @__PURE__ */
|
|
233
|
-
},
|
|
234
|
-
const t =
|
|
226
|
+
hasTypography: M,
|
|
227
|
+
getTypography: tt,
|
|
228
|
+
addTypography: rt,
|
|
229
|
+
registerComponent: J,
|
|
230
|
+
registerVariant: Q
|
|
231
|
+
}), [v, h, P, G, q, E, W, y, C, Y, F, g, p, X, Z, K, $, M, tt, rt, J, Q]);
|
|
232
|
+
return /* @__PURE__ */ xt(w.Provider, { value: $t, children: t });
|
|
233
|
+
}, B = () => {
|
|
234
|
+
const t = I(w);
|
|
235
235
|
if (!t)
|
|
236
236
|
throw new Error("useBear must be used within a BearProvider");
|
|
237
237
|
return t;
|
|
238
238
|
}, Rt = () => {
|
|
239
|
-
const { theme: t } =
|
|
239
|
+
const { theme: t } = B();
|
|
240
240
|
return t;
|
|
241
241
|
}, Ft = () => {
|
|
242
|
-
const t =
|
|
243
|
-
return t ? t.theme :
|
|
242
|
+
const t = I(w);
|
|
243
|
+
return t ? t.theme : R;
|
|
244
244
|
}, Yt = () => {
|
|
245
|
-
const { mode: t, setMode:
|
|
246
|
-
return { mode: t, setMode:
|
|
245
|
+
const { mode: t, setMode: i, toggleMode: o } = B();
|
|
246
|
+
return { mode: t, setMode: i, toggleMode: o };
|
|
247
|
+
}, vt = () => {
|
|
248
|
+
const { direction: t, setDirection: i } = B();
|
|
249
|
+
return { direction: t, setDirection: i };
|
|
247
250
|
}, zt = () => {
|
|
248
|
-
const
|
|
249
|
-
return { direction: t, setDirection:
|
|
251
|
+
const t = I(w);
|
|
252
|
+
return t ? { direction: t.direction, setDirection: t.setDirection } : { direction: "ltr", setDirection: (i) => {
|
|
253
|
+
} };
|
|
250
254
|
}, Ut = () => {
|
|
251
|
-
const { density: t, setDensity:
|
|
252
|
-
return { density: t, setDensity:
|
|
255
|
+
const { density: t, setDensity: i } = B();
|
|
256
|
+
return { density: t, setDensity: i };
|
|
257
|
+
}, Pt = () => {
|
|
258
|
+
const t = I(w);
|
|
259
|
+
return t ? { density: t.density, setDensity: t.setDensity } : { density: it, setDensity: (i) => {
|
|
260
|
+
} };
|
|
253
261
|
};
|
|
254
262
|
export {
|
|
255
|
-
|
|
263
|
+
w as BearContext,
|
|
256
264
|
Nt as BearProvider,
|
|
257
|
-
|
|
265
|
+
B as useBear,
|
|
258
266
|
Ut as useBearDensity,
|
|
259
|
-
|
|
267
|
+
Pt as useBearDensityOptional,
|
|
268
|
+
vt as useBearDirection,
|
|
269
|
+
zt as useBearDirectionOptional,
|
|
260
270
|
Yt as useBearMode,
|
|
261
271
|
Rt as useBearTheme,
|
|
262
272
|
Ft as useBearThemeOptional
|
package/dist/context/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./BearProvider.cjs"),r=require("./defaultTheme.cjs");exports.BearProvider=e.BearProvider;exports.useBear=e.useBear;exports.useBearDensity=e.useBearDensity;exports.useBearDirection=e.useBearDirection;exports.useBearMode=e.useBearMode;exports.useBearTheme=e.useBearTheme;exports.useBearThemeOptional=e.useBearThemeOptional;exports.defaultDarkTheme=r.defaultDarkTheme;exports.defaultLightTheme=r.defaultLightTheme;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./BearProvider.cjs"),r=require("./defaultTheme.cjs");exports.BearProvider=e.BearProvider;exports.useBear=e.useBear;exports.useBearDensity=e.useBearDensity;exports.useBearDensityOptional=e.useBearDensityOptional;exports.useBearDirection=e.useBearDirection;exports.useBearDirectionOptional=e.useBearDirectionOptional;exports.useBearMode=e.useBearMode;exports.useBearTheme=e.useBearTheme;exports.useBearThemeOptional=e.useBearThemeOptional;exports.defaultDarkTheme=r.defaultDarkTheme;exports.defaultLightTheme=r.defaultLightTheme;
|
package/dist/context/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { BearProvider, useBear, useBearTheme, useBearThemeOptional, useBearMode, useBearDirection, useBearDensity } from './BearProvider';
|
|
1
|
+
export { BearProvider, useBear, useBearTheme, useBearThemeOptional, useBearMode, useBearDirection, useBearDirectionOptional, useBearDensity, useBearDensityOptional } from './BearProvider';
|
|
2
2
|
export { defaultLightTheme, defaultDarkTheme } from './defaultTheme';
|
|
3
3
|
export type { BearDirection, BearDensity } from './bearProvider.types';
|
package/dist/context/index.js
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import { BearProvider as a, useBear as
|
|
2
|
-
import { defaultDarkTheme as
|
|
1
|
+
import { BearProvider as a, useBear as t, useBearDensity as i, useBearDensityOptional as o, useBearDirection as s, useBearDirectionOptional as u, useBearMode as B, useBearTheme as n, useBearThemeOptional as m } from "./BearProvider.js";
|
|
2
|
+
import { defaultDarkTheme as l, defaultLightTheme as p } from "./defaultTheme.js";
|
|
3
3
|
export {
|
|
4
4
|
a as BearProvider,
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
s as
|
|
11
|
-
|
|
12
|
-
|
|
5
|
+
l as defaultDarkTheme,
|
|
6
|
+
p as defaultLightTheme,
|
|
7
|
+
t as useBear,
|
|
8
|
+
i as useBearDensity,
|
|
9
|
+
o as useBearDensityOptional,
|
|
10
|
+
s as useBearDirection,
|
|
11
|
+
u as useBearDirectionOptional,
|
|
12
|
+
B as useBearMode,
|
|
13
|
+
n as useBearTheme,
|
|
14
|
+
m as useBearThemeOptional
|
|
13
15
|
};
|