@bestow-ui/react 0.2.1 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +225 -35
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +476 -476
- package/dist/index.css.map +1 -1
- package/dist/index.d.cts +140 -9
- package/dist/index.d.ts +140 -9
- package/dist/index.js +224 -38
- package/dist/index.js.map +1 -1
- package/package.json +2 -1
package/dist/index.js
CHANGED
|
@@ -1,11 +1,167 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
// src/theme/contract.css.ts
|
|
4
|
-
var themeClass = { light: "
|
|
5
|
-
var vars = { space: { "0": "var(--
|
|
4
|
+
var themeClass = { light: "tkagtb0", dark: "tkagtb1" };
|
|
5
|
+
var vars = { space: { "0": "var(--bestow-space-0)", "1": "var(--bestow-space-1)", "2": "var(--bestow-space-2)", "3": "var(--bestow-space-3)", "4": "var(--bestow-space-4)", "5": "var(--bestow-space-5)", "6": "var(--bestow-space-6)", "8": "var(--bestow-space-8)", "10": "var(--bestow-space-10)", "12": "var(--bestow-space-12)", "16": "var(--bestow-space-16)" }, radius: { none: "var(--bestow-radius-none)", sm: "var(--bestow-radius-sm)", md: "var(--bestow-radius-md)", lg: "var(--bestow-radius-lg)", xl: "var(--bestow-radius-xl)", full: "var(--bestow-radius-full)" }, font: { family: { sans: "var(--bestow-font-family-sans)", mono: "var(--bestow-font-family-mono)" }, size: { xs: "var(--bestow-font-size-xs)", sm: "var(--bestow-font-size-sm)", md: "var(--bestow-font-size-md)", lg: "var(--bestow-font-size-lg)", xl: "var(--bestow-font-size-xl)", "2xl": "var(--bestow-font-size-2xl)", "3xl": "var(--bestow-font-size-3xl)", "4xl": "var(--bestow-font-size-4xl)" }, weight: { regular: "var(--bestow-font-weight-regular)", medium: "var(--bestow-font-weight-medium)", semibold: "var(--bestow-font-weight-semibold)", bold: "var(--bestow-font-weight-bold)" }, lineHeight: { tight: "var(--bestow-font-line-height-tight)", normal: "var(--bestow-font-line-height-normal)", relaxed: "var(--bestow-font-line-height-relaxed)" } }, shadow: { sm: "var(--bestow-shadow-sm)", md: "var(--bestow-shadow-md)", lg: "var(--bestow-shadow-lg)" }, duration: { fast: "var(--bestow-duration-fast)", normal: "var(--bestow-duration-normal)", slow: "var(--bestow-duration-slow)" }, zIndex: { dropdown: "var(--bestow-z-index-dropdown)", overlay: "var(--bestow-z-index-overlay)", modal: "var(--bestow-z-index-modal)", toast: "var(--bestow-z-index-toast)", tooltip: "var(--bestow-z-index-tooltip)" }, color: { bg: { "default": "var(--bestow-color-bg-default)", subtle: "var(--bestow-color-bg-subtle)", muted: "var(--bestow-color-bg-muted)", inverse: "var(--bestow-color-bg-inverse)", overlay: "var(--bestow-color-bg-overlay)" }, fg: { "default": "var(--bestow-color-fg-default)", muted: "var(--bestow-color-fg-muted)", subtle: "var(--bestow-color-fg-subtle)", inverse: "var(--bestow-color-fg-inverse)" }, border: { "default": "var(--bestow-color-border-default)", strong: "var(--bestow-color-border-strong)", focus: "var(--bestow-color-border-focus)" }, primary: { solid: "var(--bestow-color-primary-solid)", solidHover: "var(--bestow-color-primary-solid-hover)", contrast: "var(--bestow-color-primary-contrast)", subtle: "var(--bestow-color-primary-subtle)", subtleHover: "var(--bestow-color-primary-subtle-hover)", text: "var(--bestow-color-primary-text)" }, neutral: { solid: "var(--bestow-color-neutral-solid)", solidHover: "var(--bestow-color-neutral-solid-hover)", contrast: "var(--bestow-color-neutral-contrast)", subtle: "var(--bestow-color-neutral-subtle)", subtleHover: "var(--bestow-color-neutral-subtle-hover)", text: "var(--bestow-color-neutral-text)" }, danger: { solid: "var(--bestow-color-danger-solid)", solidHover: "var(--bestow-color-danger-solid-hover)", contrast: "var(--bestow-color-danger-contrast)", subtle: "var(--bestow-color-danger-subtle)", subtleHover: "var(--bestow-color-danger-subtle-hover)", text: "var(--bestow-color-danger-text)" }, success: { solid: "var(--bestow-color-success-solid)", solidHover: "var(--bestow-color-success-solid-hover)", contrast: "var(--bestow-color-success-contrast)", subtle: "var(--bestow-color-success-subtle)", subtleHover: "var(--bestow-color-success-subtle-hover)", text: "var(--bestow-color-success-text)" } } };
|
|
6
|
+
|
|
7
|
+
// src/theme/color.ts
|
|
8
|
+
import { darkColors, lightColors, palette } from "@bestow-ui/tokens";
|
|
9
|
+
function parseHex(hex) {
|
|
10
|
+
const m = /^#?([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(hex.trim());
|
|
11
|
+
if (!m) throw new Error(`\uC62C\uBC14\uB978 hex \uC0C9\uC774 \uC544\uB2C8\uC5D0\uC694: "${hex}" (\uC608: "#7c3aed")`);
|
|
12
|
+
let h = m[1];
|
|
13
|
+
if (h.length === 3) h = h.replace(/./g, (c) => c + c);
|
|
14
|
+
return [0, 2, 4].map((i) => parseInt(h.slice(i, i + 2), 16) / 255);
|
|
15
|
+
}
|
|
16
|
+
function toHex(rgb) {
|
|
17
|
+
return `#${rgb.map((v) => Math.round(Math.min(1, Math.max(0, v)) * 255).toString(16).padStart(2, "0")).join("")}`;
|
|
18
|
+
}
|
|
19
|
+
var toLinear = (c) => c <= 0.04045 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4;
|
|
20
|
+
var fromLinear = (c) => c <= 31308e-7 ? 12.92 * c : 1.055 * c ** (1 / 2.4) - 0.055;
|
|
21
|
+
function rgbToOklch([r, g, b]) {
|
|
22
|
+
const [lr, lg, lb] = [toLinear(r), toLinear(g), toLinear(b)];
|
|
23
|
+
const l_ = Math.cbrt(0.4122214708 * lr + 0.5363325363 * lg + 0.0514459929 * lb);
|
|
24
|
+
const m_ = Math.cbrt(0.2119034982 * lr + 0.6806995451 * lg + 0.1073969566 * lb);
|
|
25
|
+
const s_ = Math.cbrt(0.0883024619 * lr + 0.2817188376 * lg + 0.6299787005 * lb);
|
|
26
|
+
const L = 0.2104542553 * l_ + 0.793617785 * m_ - 0.0040720468 * s_;
|
|
27
|
+
const a = 1.9779984951 * l_ - 2.428592205 * m_ + 0.4505937099 * s_;
|
|
28
|
+
const bb = 0.0259040371 * l_ + 0.7827717662 * m_ - 0.808675766 * s_;
|
|
29
|
+
return { l: L, c: Math.hypot(a, bb), h: Math.atan2(bb, a) };
|
|
30
|
+
}
|
|
31
|
+
function oklchToRgbUnclamped({ l, c, h }) {
|
|
32
|
+
const a = c * Math.cos(h);
|
|
33
|
+
const b = c * Math.sin(h);
|
|
34
|
+
const l_ = (l + 0.3963377774 * a + 0.2158037573 * b) ** 3;
|
|
35
|
+
const m_ = (l - 0.1055613458 * a - 0.0638541728 * b) ** 3;
|
|
36
|
+
const s_ = (l - 0.0894841775 * a - 1.291485548 * b) ** 3;
|
|
37
|
+
return [
|
|
38
|
+
fromLinear(4.0767416621 * l_ - 3.3077115913 * m_ + 0.2309699292 * s_),
|
|
39
|
+
fromLinear(-1.2684380046 * l_ + 2.6097574011 * m_ - 0.3413193965 * s_),
|
|
40
|
+
fromLinear(-0.0041960863 * l_ - 0.7034186147 * m_ + 1.707614701 * s_)
|
|
41
|
+
];
|
|
42
|
+
}
|
|
43
|
+
var inGamut = (rgb) => rgb.every((v) => v >= -1e-4 && v <= 1 + 1e-4);
|
|
44
|
+
function oklchToRgb(color) {
|
|
45
|
+
const l = Math.min(1, Math.max(0, color.l));
|
|
46
|
+
let rgb = oklchToRgbUnclamped({ ...color, l });
|
|
47
|
+
if (inGamut(rgb)) return rgb;
|
|
48
|
+
let lo = 0;
|
|
49
|
+
let hi = color.c;
|
|
50
|
+
for (let i = 0; i < 20; i++) {
|
|
51
|
+
const mid = (lo + hi) / 2;
|
|
52
|
+
if (inGamut(oklchToRgbUnclamped({ l, c: mid, h: color.h }))) lo = mid;
|
|
53
|
+
else hi = mid;
|
|
54
|
+
}
|
|
55
|
+
rgb = oklchToRgbUnclamped({ l, c: lo, h: color.h });
|
|
56
|
+
return rgb;
|
|
57
|
+
}
|
|
58
|
+
function luminance([r, g, b]) {
|
|
59
|
+
return 0.2126 * toLinear(r) + 0.7152 * toLinear(g) + 0.0722 * toLinear(b);
|
|
60
|
+
}
|
|
61
|
+
function contrastRatio(a, b) {
|
|
62
|
+
const [la, lb] = [luminance(parseHex(a)), luminance(parseHex(b))];
|
|
63
|
+
return (Math.max(la, lb) + 0.05) / (Math.min(la, lb) + 0.05);
|
|
64
|
+
}
|
|
65
|
+
function blend(fg, alpha, bg) {
|
|
66
|
+
const [f, b] = [parseHex(fg), parseHex(bg)];
|
|
67
|
+
return toHex(f.map((v, i) => v * alpha + b[i] * (1 - alpha)));
|
|
68
|
+
}
|
|
69
|
+
var withL = (base, l, c = base.c) => toHex(oklchToRgb({ l, c, h: base.h }));
|
|
70
|
+
function findReadable(base, startL, step, backgrounds) {
|
|
71
|
+
let l = startL;
|
|
72
|
+
for (let i = 0; i < 40; i++) {
|
|
73
|
+
const hex = withL(base, l);
|
|
74
|
+
if (backgrounds.every((bg) => contrastRatio(hex, bg) >= 4.5)) return hex;
|
|
75
|
+
l = Math.min(1, Math.max(0, l + step));
|
|
76
|
+
}
|
|
77
|
+
return step < 0 ? palette.black : palette.white;
|
|
78
|
+
}
|
|
79
|
+
function pickContrast(solid) {
|
|
80
|
+
const white = palette.white;
|
|
81
|
+
const dark = palette.gray[900];
|
|
82
|
+
if (contrastRatio(white, solid) >= 4.5) return white;
|
|
83
|
+
return contrastRatio(dark, solid) >= contrastRatio(white, solid) ? dark : white;
|
|
84
|
+
}
|
|
85
|
+
var rgba = (hex, alpha) => {
|
|
86
|
+
const [r, g, b] = parseHex(hex).map((v) => Math.round(v * 255));
|
|
87
|
+
return `rgba(${r}, ${g}, ${b}, ${alpha})`;
|
|
88
|
+
};
|
|
89
|
+
function createIntentColors(intent, color) {
|
|
90
|
+
const solid = toHex(parseHex(color));
|
|
91
|
+
const base = rgbToOklch(parseHex(solid));
|
|
92
|
+
const lightSubtle = withL(base, 0.97, Math.min(base.c, 0.12) * 0.3);
|
|
93
|
+
const lightSubtleHover = withL(base, 0.93, Math.min(base.c, 0.12) * 0.45);
|
|
94
|
+
const light = {
|
|
95
|
+
solid,
|
|
96
|
+
solidHover: withL(base, Math.max(0, base.l - 0.06)),
|
|
97
|
+
contrast: pickContrast(solid),
|
|
98
|
+
subtle: lightSubtle,
|
|
99
|
+
subtleHover: lightSubtleHover,
|
|
100
|
+
text: findReadable(base, Math.min(base.l, 0.55), -0.02, [lightColors.bg.default, lightSubtle, lightSubtleHover])
|
|
101
|
+
};
|
|
102
|
+
const darkBg = darkColors.bg.default;
|
|
103
|
+
const darkSolid = base.l < 0.5 ? withL(base, 0.55) : solid;
|
|
104
|
+
const darkBase = rgbToOklch(parseHex(darkSolid));
|
|
105
|
+
const darkSubtleOnBg = blend(darkSolid, 0.16, darkBg);
|
|
106
|
+
const darkSubtleHoverOnBg = blend(darkSolid, 0.26, darkBg);
|
|
107
|
+
const dark = {
|
|
108
|
+
solid: darkSolid,
|
|
109
|
+
solidHover: withL(darkBase, Math.min(1, darkBase.l + 0.06)),
|
|
110
|
+
contrast: pickContrast(darkSolid),
|
|
111
|
+
subtle: rgba(darkSolid, 0.16),
|
|
112
|
+
subtleHover: rgba(darkSolid, 0.26),
|
|
113
|
+
text: findReadable(darkBase, Math.max(darkBase.l, 0.75), 0.02, [darkBg, darkSubtleOnBg, darkSubtleHoverOnBg])
|
|
114
|
+
};
|
|
115
|
+
const focus = intent === "primary" ? { light: { border: { focus: light.solid } }, dark: { border: { focus: dark.solidHover } } } : void 0;
|
|
116
|
+
return {
|
|
117
|
+
light: { color: { [intent]: light, ...focus?.light } },
|
|
118
|
+
dark: { color: { [intent]: dark, ...focus?.dark } }
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// src/theme/createTheme.ts
|
|
123
|
+
import { assignInlineVars } from "@vanilla-extract/dynamic";
|
|
124
|
+
function deepMerge(target, source) {
|
|
125
|
+
if (!source) return target;
|
|
126
|
+
const out = { ...target };
|
|
127
|
+
for (const [key, value2] of Object.entries(source)) {
|
|
128
|
+
if (value2 === void 0) continue;
|
|
129
|
+
const prev = out[key];
|
|
130
|
+
out[key] = typeof value2 === "object" && typeof prev === "object" ? deepMerge(prev, value2) : value2;
|
|
131
|
+
}
|
|
132
|
+
return out;
|
|
133
|
+
}
|
|
134
|
+
function createTheme(...inputs) {
|
|
135
|
+
let light = {};
|
|
136
|
+
let dark = {};
|
|
137
|
+
for (const input3 of inputs) {
|
|
138
|
+
light = deepMerge(deepMerge(light, input3.common), input3.light);
|
|
139
|
+
dark = deepMerge(deepMerge(dark, input3.common), input3.dark);
|
|
140
|
+
}
|
|
141
|
+
return Object.freeze({ light, dark });
|
|
142
|
+
}
|
|
143
|
+
function mergeThemes(a, b) {
|
|
144
|
+
if (!a) return b;
|
|
145
|
+
if (!b) return a;
|
|
146
|
+
return createTheme(a, b);
|
|
147
|
+
}
|
|
148
|
+
function flatten(partial, contract, out) {
|
|
149
|
+
for (const [key, value2] of Object.entries(partial)) {
|
|
150
|
+
const target = contract[key];
|
|
151
|
+
if (target === void 0) continue;
|
|
152
|
+
if (typeof target === "string" && typeof value2 === "string") out[target] = value2;
|
|
153
|
+
else if (typeof target === "object" && typeof value2 === "object") flatten(value2, target, out);
|
|
154
|
+
}
|
|
155
|
+
return out;
|
|
156
|
+
}
|
|
157
|
+
function themeToStyle(theme, mode) {
|
|
158
|
+
if (!theme) return void 0;
|
|
159
|
+
const map = flatten(theme[mode], vars, {});
|
|
160
|
+
return Object.keys(map).length ? assignInlineVars(map) : void 0;
|
|
161
|
+
}
|
|
6
162
|
|
|
7
163
|
// src/theme/ThemeProvider.tsx
|
|
8
|
-
import { createContext, forwardRef, useContext } from "react";
|
|
164
|
+
import { createContext, forwardRef, useContext, useMemo } from "react";
|
|
9
165
|
|
|
10
166
|
// src/utils/cx.ts
|
|
11
167
|
function cx(...classNames) {
|
|
@@ -18,15 +174,36 @@ var root = "sfyhlv1 sfyhlv0";
|
|
|
18
174
|
|
|
19
175
|
// src/theme/ThemeProvider.tsx
|
|
20
176
|
import { jsx } from "react/jsx-runtime";
|
|
21
|
-
var ThemeContext = createContext("light");
|
|
22
|
-
var ThemeProvider = forwardRef(function ThemeProvider2({ theme
|
|
23
|
-
|
|
177
|
+
var ThemeContext = createContext({ theme: "light" });
|
|
178
|
+
var ThemeProvider = forwardRef(function ThemeProvider2({ theme: themeProp, overrides, className, style, children, ...rest }, ref) {
|
|
179
|
+
const parent = useContext(ThemeContext);
|
|
180
|
+
const theme = themeProp ?? parent.theme;
|
|
181
|
+
const merged = useMemo(() => mergeThemes(parent.overrides, overrides), [parent.overrides, overrides]);
|
|
182
|
+
const value2 = useMemo(
|
|
183
|
+
() => ({ theme, overrides: merged, style: themeToStyle(merged, theme) }),
|
|
184
|
+
[theme, merged]
|
|
185
|
+
);
|
|
186
|
+
return /* @__PURE__ */ jsx(ThemeContext.Provider, { value: value2, children: /* @__PURE__ */ jsx(
|
|
187
|
+
"div",
|
|
188
|
+
{
|
|
189
|
+
ref,
|
|
190
|
+
"data-theme": theme,
|
|
191
|
+
className: cx(themeClass[theme], root, className),
|
|
192
|
+
style: value2.style ? { ...value2.style, ...style } : style,
|
|
193
|
+
...rest,
|
|
194
|
+
children
|
|
195
|
+
}
|
|
196
|
+
) });
|
|
24
197
|
});
|
|
25
198
|
function useTheme() {
|
|
26
|
-
return useContext(ThemeContext);
|
|
199
|
+
return useContext(ThemeContext).theme;
|
|
200
|
+
}
|
|
201
|
+
function usePortalProps() {
|
|
202
|
+
const { theme, style } = useContext(ThemeContext);
|
|
203
|
+
return { className: cx(themeClass[theme], portal), style };
|
|
27
204
|
}
|
|
28
205
|
function usePortalClassName() {
|
|
29
|
-
return
|
|
206
|
+
return usePortalProps().className;
|
|
30
207
|
}
|
|
31
208
|
|
|
32
209
|
// src/components/Button/Button.tsx
|
|
@@ -205,15 +382,16 @@ function Modal({
|
|
|
205
382
|
closeOnOverlayClick = true,
|
|
206
383
|
className
|
|
207
384
|
}) {
|
|
208
|
-
const
|
|
385
|
+
const portal2 = usePortalProps();
|
|
209
386
|
return /* @__PURE__ */ jsxs5(Dialog.Root, { open, defaultOpen, onOpenChange, children: [
|
|
210
387
|
trigger2 && /* @__PURE__ */ jsx6(Dialog.Trigger, { asChild: true, children: trigger2 }),
|
|
211
388
|
/* @__PURE__ */ jsxs5(Dialog.Portal, { children: [
|
|
212
|
-
/* @__PURE__ */ jsx6(Dialog.Overlay, { className: cx(
|
|
389
|
+
/* @__PURE__ */ jsx6(Dialog.Overlay, { className: cx(portal2.className, overlay), style: portal2.style }),
|
|
213
390
|
/* @__PURE__ */ jsxs5(
|
|
214
391
|
Dialog.Content,
|
|
215
392
|
{
|
|
216
|
-
className: cx(
|
|
393
|
+
className: cx(portal2.className, content({ size }), className),
|
|
394
|
+
style: portal2.style,
|
|
217
395
|
onPointerDownOutside: closeOnOverlayClick ? void 0 : (event) => event.preventDefault(),
|
|
218
396
|
...description3 ? {} : { "aria-describedby": void 0 },
|
|
219
397
|
children: [
|
|
@@ -250,28 +428,30 @@ var viewport = "_1kx81e84";
|
|
|
250
428
|
|
|
251
429
|
// src/components/Select/Select.tsx
|
|
252
430
|
import { jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
253
|
-
var Select = forwardRef6(function Select2({
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
431
|
+
var Select = forwardRef6(function Select2(props, ref) {
|
|
432
|
+
const {
|
|
433
|
+
options,
|
|
434
|
+
value: value2,
|
|
435
|
+
defaultValue,
|
|
436
|
+
onValueChange,
|
|
437
|
+
placeholder,
|
|
438
|
+
label: label2,
|
|
439
|
+
helperText: helperText2,
|
|
440
|
+
error,
|
|
441
|
+
size,
|
|
442
|
+
fullWidth,
|
|
443
|
+
disabled,
|
|
444
|
+
required,
|
|
445
|
+
name,
|
|
446
|
+
id,
|
|
447
|
+
"aria-label": ariaLabel,
|
|
448
|
+
className
|
|
449
|
+
} = props;
|
|
450
|
+
const isControlled = "value" in props;
|
|
271
451
|
const generatedId = useId2();
|
|
272
452
|
const triggerId = id ?? generatedId;
|
|
273
453
|
const helperId = helperText2 ? `${triggerId}-helper` : void 0;
|
|
274
|
-
const
|
|
454
|
+
const portal2 = usePortalProps();
|
|
275
455
|
return /* @__PURE__ */ jsxs6("div", { className: cx(field, fullWidth && fieldFullWidth), children: [
|
|
276
456
|
label2 && /* @__PURE__ */ jsxs6("label", { htmlFor: triggerId, className: label, children: [
|
|
277
457
|
label2,
|
|
@@ -280,7 +460,7 @@ var Select = forwardRef6(function Select2({
|
|
|
280
460
|
/* @__PURE__ */ jsxs6(
|
|
281
461
|
RadixSelect.Root,
|
|
282
462
|
{
|
|
283
|
-
value: value2,
|
|
463
|
+
value: isControlled ? value2 ?? "" : void 0,
|
|
284
464
|
defaultValue,
|
|
285
465
|
onValueChange,
|
|
286
466
|
disabled,
|
|
@@ -309,7 +489,8 @@ var Select = forwardRef6(function Select2({
|
|
|
309
489
|
position: "popper",
|
|
310
490
|
sideOffset: 4,
|
|
311
491
|
collisionPadding: 8,
|
|
312
|
-
className: cx(
|
|
492
|
+
className: cx(portal2.className, content2),
|
|
493
|
+
style: portal2.style,
|
|
313
494
|
children: /* @__PURE__ */ jsx7(RadixSelect.Viewport, { className: viewport, children: options.map((option) => /* @__PURE__ */ jsxs6(
|
|
314
495
|
RadixSelect.Item,
|
|
315
496
|
{
|
|
@@ -354,7 +535,7 @@ var Stack = forwardRef7(function Stack2({ as: Component = "div", direction, gap,
|
|
|
354
535
|
|
|
355
536
|
// src/components/Toast/Toast.tsx
|
|
356
537
|
import * as RadixToast from "@radix-ui/react-toast";
|
|
357
|
-
import { createContext as createContext2, useCallback, useContext as useContext2, useMemo, useRef as useRef2, useState } from "react";
|
|
538
|
+
import { createContext as createContext2, useCallback, useContext as useContext2, useMemo as useMemo2, useRef as useRef2, useState } from "react";
|
|
358
539
|
import { XIcon as XIcon2 } from "@bestow-ui/icons";
|
|
359
540
|
|
|
360
541
|
// src/components/Toast/Toast.css.ts
|
|
@@ -373,7 +554,7 @@ var ToastContext = createContext2(null);
|
|
|
373
554
|
function ToastProvider({ children, duration = 5e3, label: label2 = "\uC54C\uB9BC" }) {
|
|
374
555
|
const [toasts, setToasts] = useState([]);
|
|
375
556
|
const nextId = useRef2(0);
|
|
376
|
-
const
|
|
557
|
+
const portal2 = usePortalProps();
|
|
377
558
|
const toast2 = useCallback((options) => {
|
|
378
559
|
const id = nextId.current++;
|
|
379
560
|
setToasts((prev) => [...prev, { ...options, id, open: true }]);
|
|
@@ -384,7 +565,7 @@ function ToastProvider({ children, duration = 5e3, label: label2 = "\uC54C\uB9BC
|
|
|
384
565
|
setToasts((prev) => prev.map((t) => isTarget(t) ? { ...t, open: false } : t));
|
|
385
566
|
setTimeout(() => setToasts((prev) => prev.filter((t) => t.open || !isTarget(t))), REMOVE_DELAY);
|
|
386
567
|
}, []);
|
|
387
|
-
const value2 =
|
|
568
|
+
const value2 = useMemo2(() => ({ toast: toast2, dismiss }), [toast2, dismiss]);
|
|
388
569
|
return /* @__PURE__ */ jsx9(ToastContext.Provider, { value: value2, children: /* @__PURE__ */ jsxs7(RadixToast.Provider, { duration, label: label2, swipeDirection: "right", children: [
|
|
389
570
|
children,
|
|
390
571
|
toasts.map(({ id, open, title: title3, description: description3, variant, duration: itemDuration, action: action2 }) => /* @__PURE__ */ jsxs7(
|
|
@@ -405,7 +586,7 @@ function ToastProvider({ children, duration = 5e3, label: label2 = "\uC54C\uB9BC
|
|
|
405
586
|
},
|
|
406
587
|
id
|
|
407
588
|
)),
|
|
408
|
-
/* @__PURE__ */ jsx9(RadixToast.Viewport, { className: cx(
|
|
589
|
+
/* @__PURE__ */ jsx9(RadixToast.Viewport, { className: cx(portal2.className, viewport2), style: portal2.style })
|
|
409
590
|
] }) });
|
|
410
591
|
}
|
|
411
592
|
function useToast() {
|
|
@@ -435,7 +616,7 @@ function Tooltip({
|
|
|
435
616
|
disabled,
|
|
436
617
|
className
|
|
437
618
|
}) {
|
|
438
|
-
const
|
|
619
|
+
const portal2 = usePortalProps();
|
|
439
620
|
if (disabled || content4 == null || content4 === "") return children;
|
|
440
621
|
return /* @__PURE__ */ jsx10(RadixTooltip.Provider, { delayDuration: delay, children: /* @__PURE__ */ jsxs8(RadixTooltip.Root, { open, defaultOpen, onOpenChange, children: [
|
|
441
622
|
/* @__PURE__ */ jsx10(RadixTooltip.Trigger, { asChild: true, children }),
|
|
@@ -446,7 +627,8 @@ function Tooltip({
|
|
|
446
627
|
align,
|
|
447
628
|
sideOffset: 6,
|
|
448
629
|
collisionPadding: 8,
|
|
449
|
-
className: cx(
|
|
630
|
+
className: cx(portal2.className, content3, className),
|
|
631
|
+
style: portal2.style,
|
|
450
632
|
children: [
|
|
451
633
|
content4,
|
|
452
634
|
/* @__PURE__ */ jsx10(RadixTooltip.Arrow, { className: arrow, width: 10, height: 5 })
|
|
@@ -500,8 +682,12 @@ export {
|
|
|
500
682
|
ToastProvider,
|
|
501
683
|
Tooltip,
|
|
502
684
|
Typography,
|
|
685
|
+
contrastRatio,
|
|
686
|
+
createIntentColors,
|
|
687
|
+
createTheme,
|
|
503
688
|
themeClass,
|
|
504
689
|
usePortalClassName,
|
|
690
|
+
usePortalProps,
|
|
505
691
|
useTheme,
|
|
506
692
|
useToast,
|
|
507
693
|
vars
|