@bestow-ui/react 0.2.0 → 0.3.0
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 +244 -70
- 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 +138 -8
- package/dist/index.d.ts +138 -8
- package/dist/index.js +233 -63
- package/dist/index.js.map +1 -1
- package/package.json +3 -1
package/dist/index.js
CHANGED
|
@@ -1,11 +1,163 @@
|
|
|
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
|
+
return { light: { color: { [intent]: light } }, dark: { color: { [intent]: dark } } };
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// src/theme/createTheme.ts
|
|
119
|
+
import { assignInlineVars } from "@vanilla-extract/dynamic";
|
|
120
|
+
function deepMerge(target, source) {
|
|
121
|
+
if (!source) return target;
|
|
122
|
+
const out = { ...target };
|
|
123
|
+
for (const [key, value2] of Object.entries(source)) {
|
|
124
|
+
if (value2 === void 0) continue;
|
|
125
|
+
const prev = out[key];
|
|
126
|
+
out[key] = typeof value2 === "object" && typeof prev === "object" ? deepMerge(prev, value2) : value2;
|
|
127
|
+
}
|
|
128
|
+
return out;
|
|
129
|
+
}
|
|
130
|
+
function createTheme(...inputs) {
|
|
131
|
+
let light = {};
|
|
132
|
+
let dark = {};
|
|
133
|
+
for (const input3 of inputs) {
|
|
134
|
+
light = deepMerge(deepMerge(light, input3.common), input3.light);
|
|
135
|
+
dark = deepMerge(deepMerge(dark, input3.common), input3.dark);
|
|
136
|
+
}
|
|
137
|
+
return Object.freeze({ light, dark });
|
|
138
|
+
}
|
|
139
|
+
function mergeThemes(a, b) {
|
|
140
|
+
if (!a) return b;
|
|
141
|
+
if (!b) return a;
|
|
142
|
+
return createTheme(a, b);
|
|
143
|
+
}
|
|
144
|
+
function flatten(partial, contract, out) {
|
|
145
|
+
for (const [key, value2] of Object.entries(partial)) {
|
|
146
|
+
const target = contract[key];
|
|
147
|
+
if (target === void 0) continue;
|
|
148
|
+
if (typeof target === "string" && typeof value2 === "string") out[target] = value2;
|
|
149
|
+
else if (typeof target === "object" && typeof value2 === "object") flatten(value2, target, out);
|
|
150
|
+
}
|
|
151
|
+
return out;
|
|
152
|
+
}
|
|
153
|
+
function themeToStyle(theme, mode) {
|
|
154
|
+
if (!theme) return void 0;
|
|
155
|
+
const map = flatten(theme[mode], vars, {});
|
|
156
|
+
return Object.keys(map).length ? assignInlineVars(map) : void 0;
|
|
157
|
+
}
|
|
6
158
|
|
|
7
159
|
// src/theme/ThemeProvider.tsx
|
|
8
|
-
import { createContext, forwardRef, useContext } from "react";
|
|
160
|
+
import { createContext, forwardRef, useContext, useMemo } from "react";
|
|
9
161
|
|
|
10
162
|
// src/utils/cx.ts
|
|
11
163
|
function cx(...classNames) {
|
|
@@ -18,15 +170,36 @@ var root = "sfyhlv1 sfyhlv0";
|
|
|
18
170
|
|
|
19
171
|
// src/theme/ThemeProvider.tsx
|
|
20
172
|
import { jsx } from "react/jsx-runtime";
|
|
21
|
-
var ThemeContext = createContext("light");
|
|
22
|
-
var ThemeProvider = forwardRef(function ThemeProvider2({ theme
|
|
23
|
-
|
|
173
|
+
var ThemeContext = createContext({ theme: "light" });
|
|
174
|
+
var ThemeProvider = forwardRef(function ThemeProvider2({ theme: themeProp, overrides, className, style, children, ...rest }, ref) {
|
|
175
|
+
const parent = useContext(ThemeContext);
|
|
176
|
+
const theme = themeProp ?? parent.theme;
|
|
177
|
+
const merged = useMemo(() => mergeThemes(parent.overrides, overrides), [parent.overrides, overrides]);
|
|
178
|
+
const value2 = useMemo(
|
|
179
|
+
() => ({ theme, overrides: merged, style: themeToStyle(merged, theme) }),
|
|
180
|
+
[theme, merged]
|
|
181
|
+
);
|
|
182
|
+
return /* @__PURE__ */ jsx(ThemeContext.Provider, { value: value2, children: /* @__PURE__ */ jsx(
|
|
183
|
+
"div",
|
|
184
|
+
{
|
|
185
|
+
ref,
|
|
186
|
+
"data-theme": theme,
|
|
187
|
+
className: cx(themeClass[theme], root, className),
|
|
188
|
+
style: value2.style ? { ...value2.style, ...style } : style,
|
|
189
|
+
...rest,
|
|
190
|
+
children
|
|
191
|
+
}
|
|
192
|
+
) });
|
|
24
193
|
});
|
|
25
194
|
function useTheme() {
|
|
26
|
-
return useContext(ThemeContext);
|
|
195
|
+
return useContext(ThemeContext).theme;
|
|
196
|
+
}
|
|
197
|
+
function usePortalProps() {
|
|
198
|
+
const { theme, style } = useContext(ThemeContext);
|
|
199
|
+
return { className: cx(themeClass[theme], portal), style };
|
|
27
200
|
}
|
|
28
201
|
function usePortalClassName() {
|
|
29
|
-
return
|
|
202
|
+
return usePortalProps().className;
|
|
30
203
|
}
|
|
31
204
|
|
|
32
205
|
// src/components/Button/Button.tsx
|
|
@@ -175,19 +348,7 @@ var TextField = forwardRef5(function TextField2({ label: label2, helperText: hel
|
|
|
175
348
|
|
|
176
349
|
// src/components/Modal/Modal.tsx
|
|
177
350
|
import * as Dialog from "@radix-ui/react-dialog";
|
|
178
|
-
|
|
179
|
-
// src/icons/index.tsx
|
|
180
|
-
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
181
|
-
var base = { width: 16, height: 16, viewBox: "0 0 16 16", fill: "none", "aria-hidden": true };
|
|
182
|
-
function CloseIcon(props) {
|
|
183
|
-
return /* @__PURE__ */ jsx6("svg", { ...base, ...props, children: /* @__PURE__ */ jsx6("path", { d: "M4 4l8 8M12 4l-8 8", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round" }) });
|
|
184
|
-
}
|
|
185
|
-
function ChevronDownIcon(props) {
|
|
186
|
-
return /* @__PURE__ */ jsx6("svg", { ...base, ...props, children: /* @__PURE__ */ jsx6("path", { d: "M4 6l4 4 4-4", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }) });
|
|
187
|
-
}
|
|
188
|
-
function CheckIcon(props) {
|
|
189
|
-
return /* @__PURE__ */ jsx6("svg", { ...base, ...props, children: /* @__PURE__ */ jsx6("path", { d: "M3.5 8.5l3 3 6-7", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }) });
|
|
190
|
-
}
|
|
351
|
+
import { XIcon } from "@bestow-ui/icons";
|
|
191
352
|
|
|
192
353
|
// src/components/Modal/Modal.css.ts
|
|
193
354
|
import { createRuntimeFn as _7a4684 } from "@vanilla-extract/recipes/createRuntimeFn";
|
|
@@ -202,7 +363,7 @@ var overlay = "_1pdsmv00";
|
|
|
202
363
|
var title = "_1pdsmv07";
|
|
203
364
|
|
|
204
365
|
// src/components/Modal/Modal.tsx
|
|
205
|
-
import { jsx as
|
|
366
|
+
import { jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
206
367
|
function Modal({
|
|
207
368
|
open,
|
|
208
369
|
defaultOpen,
|
|
@@ -217,27 +378,28 @@ function Modal({
|
|
|
217
378
|
closeOnOverlayClick = true,
|
|
218
379
|
className
|
|
219
380
|
}) {
|
|
220
|
-
const
|
|
381
|
+
const portal2 = usePortalProps();
|
|
221
382
|
return /* @__PURE__ */ jsxs5(Dialog.Root, { open, defaultOpen, onOpenChange, children: [
|
|
222
|
-
trigger2 && /* @__PURE__ */
|
|
383
|
+
trigger2 && /* @__PURE__ */ jsx6(Dialog.Trigger, { asChild: true, children: trigger2 }),
|
|
223
384
|
/* @__PURE__ */ jsxs5(Dialog.Portal, { children: [
|
|
224
|
-
/* @__PURE__ */
|
|
385
|
+
/* @__PURE__ */ jsx6(Dialog.Overlay, { className: cx(portal2.className, overlay), style: portal2.style }),
|
|
225
386
|
/* @__PURE__ */ jsxs5(
|
|
226
387
|
Dialog.Content,
|
|
227
388
|
{
|
|
228
|
-
className: cx(
|
|
389
|
+
className: cx(portal2.className, content({ size }), className),
|
|
390
|
+
style: portal2.style,
|
|
229
391
|
onPointerDownOutside: closeOnOverlayClick ? void 0 : (event) => event.preventDefault(),
|
|
230
392
|
...description3 ? {} : { "aria-describedby": void 0 },
|
|
231
393
|
children: [
|
|
232
394
|
/* @__PURE__ */ jsxs5("div", { className: header, children: [
|
|
233
395
|
/* @__PURE__ */ jsxs5("div", { className: headings, children: [
|
|
234
|
-
/* @__PURE__ */
|
|
235
|
-
description3 && /* @__PURE__ */
|
|
396
|
+
/* @__PURE__ */ jsx6(Dialog.Title, { className: title, children: title3 }),
|
|
397
|
+
description3 && /* @__PURE__ */ jsx6(Dialog.Description, { className: description, children: description3 })
|
|
236
398
|
] }),
|
|
237
|
-
!hideCloseButton && /* @__PURE__ */
|
|
399
|
+
!hideCloseButton && /* @__PURE__ */ jsx6(Dialog.Close, { className: closeButton, "aria-label": "\uB2EB\uAE30", children: /* @__PURE__ */ jsx6(XIcon, { size: 16 }) })
|
|
238
400
|
] }),
|
|
239
|
-
children && /* @__PURE__ */
|
|
240
|
-
footer2 && /* @__PURE__ */
|
|
401
|
+
children && /* @__PURE__ */ jsx6("div", { className: body, children }),
|
|
402
|
+
footer2 && /* @__PURE__ */ jsx6("div", { className: footer, children: footer2 })
|
|
241
403
|
]
|
|
242
404
|
}
|
|
243
405
|
)
|
|
@@ -249,6 +411,7 @@ var ModalClose = Dialog.Close;
|
|
|
249
411
|
// src/components/Select/Select.tsx
|
|
250
412
|
import * as RadixSelect from "@radix-ui/react-select";
|
|
251
413
|
import { forwardRef as forwardRef6, useId as useId2 } from "react";
|
|
414
|
+
import { CheckIcon, ChevronDownIcon } from "@bestow-ui/icons";
|
|
252
415
|
|
|
253
416
|
// src/components/Select/Select.css.ts
|
|
254
417
|
var content2 = "_1kx81e83";
|
|
@@ -260,7 +423,7 @@ var value = "_1kx81e81";
|
|
|
260
423
|
var viewport = "_1kx81e84";
|
|
261
424
|
|
|
262
425
|
// src/components/Select/Select.tsx
|
|
263
|
-
import { jsx as
|
|
426
|
+
import { jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
264
427
|
var Select = forwardRef6(function Select2({
|
|
265
428
|
options,
|
|
266
429
|
value: value2,
|
|
@@ -282,11 +445,11 @@ var Select = forwardRef6(function Select2({
|
|
|
282
445
|
const generatedId = useId2();
|
|
283
446
|
const triggerId = id ?? generatedId;
|
|
284
447
|
const helperId = helperText2 ? `${triggerId}-helper` : void 0;
|
|
285
|
-
const
|
|
448
|
+
const portal2 = usePortalProps();
|
|
286
449
|
return /* @__PURE__ */ jsxs6("div", { className: cx(field, fullWidth && fieldFullWidth), children: [
|
|
287
450
|
label2 && /* @__PURE__ */ jsxs6("label", { htmlFor: triggerId, className: label, children: [
|
|
288
451
|
label2,
|
|
289
|
-
required && /* @__PURE__ */
|
|
452
|
+
required && /* @__PURE__ */ jsx7("span", { className: requiredMark, "aria-hidden": true, children: "*" })
|
|
290
453
|
] }),
|
|
291
454
|
/* @__PURE__ */ jsxs6(
|
|
292
455
|
RadixSelect.Root,
|
|
@@ -309,27 +472,28 @@ var Select = forwardRef6(function Select2({
|
|
|
309
472
|
"data-invalid": error || void 0,
|
|
310
473
|
className: cx(root3({ size, fullWidth }), trigger, className),
|
|
311
474
|
children: [
|
|
312
|
-
/* @__PURE__ */
|
|
313
|
-
/* @__PURE__ */
|
|
475
|
+
/* @__PURE__ */ jsx7("span", { className: value, children: /* @__PURE__ */ jsx7(RadixSelect.Value, { placeholder }) }),
|
|
476
|
+
/* @__PURE__ */ jsx7(RadixSelect.Icon, { className: icon2, children: /* @__PURE__ */ jsx7(ChevronDownIcon, { size: 16 }) })
|
|
314
477
|
]
|
|
315
478
|
}
|
|
316
479
|
),
|
|
317
|
-
/* @__PURE__ */
|
|
480
|
+
/* @__PURE__ */ jsx7(RadixSelect.Portal, { children: /* @__PURE__ */ jsx7(
|
|
318
481
|
RadixSelect.Content,
|
|
319
482
|
{
|
|
320
483
|
position: "popper",
|
|
321
484
|
sideOffset: 4,
|
|
322
485
|
collisionPadding: 8,
|
|
323
|
-
className: cx(
|
|
324
|
-
|
|
486
|
+
className: cx(portal2.className, content2),
|
|
487
|
+
style: portal2.style,
|
|
488
|
+
children: /* @__PURE__ */ jsx7(RadixSelect.Viewport, { className: viewport, children: options.map((option) => /* @__PURE__ */ jsxs6(
|
|
325
489
|
RadixSelect.Item,
|
|
326
490
|
{
|
|
327
491
|
value: option.value,
|
|
328
492
|
disabled: option.disabled,
|
|
329
493
|
className: item,
|
|
330
494
|
children: [
|
|
331
|
-
/* @__PURE__ */
|
|
332
|
-
/* @__PURE__ */
|
|
495
|
+
/* @__PURE__ */ jsx7(RadixSelect.ItemText, { children: option.label }),
|
|
496
|
+
/* @__PURE__ */ jsx7(RadixSelect.ItemIndicator, { className: itemIndicator, children: /* @__PURE__ */ jsx7(CheckIcon, { size: 16 }) })
|
|
333
497
|
]
|
|
334
498
|
},
|
|
335
499
|
option.value
|
|
@@ -339,7 +503,7 @@ var Select = forwardRef6(function Select2({
|
|
|
339
503
|
]
|
|
340
504
|
}
|
|
341
505
|
),
|
|
342
|
-
helperText2 && /* @__PURE__ */
|
|
506
|
+
helperText2 && /* @__PURE__ */ jsx7("p", { id: helperId, className: helperText({ error }), children: helperText2 })
|
|
343
507
|
] });
|
|
344
508
|
});
|
|
345
509
|
|
|
@@ -351,9 +515,9 @@ import { createRuntimeFn as _7a4685 } from "@vanilla-extract/recipes/createRunti
|
|
|
351
515
|
var stack = _7a4685({ defaultClassName: "_1jz9hj90", variantClassNames: { direction: { row: "_1jz9hj91", column: "_1jz9hj92", "row-reverse": "_1jz9hj93", "column-reverse": "_1jz9hj94" }, gap: { "0": "_1jz9hj95", "1": "_1jz9hj96", "2": "_1jz9hj97", "3": "_1jz9hj98", "4": "_1jz9hj99", "5": "_1jz9hj9a", "6": "_1jz9hj9b", "8": "_1jz9hj9c", "10": "_1jz9hj9d", "12": "_1jz9hj9e", "16": "_1jz9hj9f" }, align: { start: "_1jz9hj9g", center: "_1jz9hj9h", end: "_1jz9hj9i", stretch: "_1jz9hj9j", baseline: "_1jz9hj9k" }, justify: { start: "_1jz9hj9l", center: "_1jz9hj9m", end: "_1jz9hj9n", between: "_1jz9hj9o", around: "_1jz9hj9p", evenly: "_1jz9hj9q" }, wrap: { true: "_1jz9hj9r" } }, defaultVariants: { direction: "column" }, compoundVariants: [] });
|
|
352
516
|
|
|
353
517
|
// src/components/Stack/Stack.tsx
|
|
354
|
-
import { jsx as
|
|
518
|
+
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
355
519
|
var Stack = forwardRef7(function Stack2({ as: Component = "div", direction, gap, align, justify, wrap, className, ...rest }, ref) {
|
|
356
|
-
return /* @__PURE__ */
|
|
520
|
+
return /* @__PURE__ */ jsx8(
|
|
357
521
|
Component,
|
|
358
522
|
{
|
|
359
523
|
ref,
|
|
@@ -365,7 +529,8 @@ var Stack = forwardRef7(function Stack2({ as: Component = "div", direction, gap,
|
|
|
365
529
|
|
|
366
530
|
// src/components/Toast/Toast.tsx
|
|
367
531
|
import * as RadixToast from "@radix-ui/react-toast";
|
|
368
|
-
import { createContext as createContext2, useCallback, useContext as useContext2, useMemo, useRef as useRef2, useState } from "react";
|
|
532
|
+
import { createContext as createContext2, useCallback, useContext as useContext2, useMemo as useMemo2, useRef as useRef2, useState } from "react";
|
|
533
|
+
import { XIcon as XIcon2 } from "@bestow-ui/icons";
|
|
369
534
|
|
|
370
535
|
// src/components/Toast/Toast.css.ts
|
|
371
536
|
import { createRuntimeFn as _7a4686 } from "@vanilla-extract/recipes/createRuntimeFn";
|
|
@@ -377,13 +542,13 @@ var toast = _7a4686({ defaultClassName: "_1g11zvx1", variantClassNames: { varian
|
|
|
377
542
|
var viewport2 = "_1g11zvx0";
|
|
378
543
|
|
|
379
544
|
// src/components/Toast/Toast.tsx
|
|
380
|
-
import { jsx as
|
|
545
|
+
import { jsx as jsx9, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
381
546
|
var REMOVE_DELAY = 500;
|
|
382
547
|
var ToastContext = createContext2(null);
|
|
383
548
|
function ToastProvider({ children, duration = 5e3, label: label2 = "\uC54C\uB9BC" }) {
|
|
384
549
|
const [toasts, setToasts] = useState([]);
|
|
385
550
|
const nextId = useRef2(0);
|
|
386
|
-
const
|
|
551
|
+
const portal2 = usePortalProps();
|
|
387
552
|
const toast2 = useCallback((options) => {
|
|
388
553
|
const id = nextId.current++;
|
|
389
554
|
setToasts((prev) => [...prev, { ...options, id, open: true }]);
|
|
@@ -394,8 +559,8 @@ function ToastProvider({ children, duration = 5e3, label: label2 = "\uC54C\uB9BC
|
|
|
394
559
|
setToasts((prev) => prev.map((t) => isTarget(t) ? { ...t, open: false } : t));
|
|
395
560
|
setTimeout(() => setToasts((prev) => prev.filter((t) => t.open || !isTarget(t))), REMOVE_DELAY);
|
|
396
561
|
}, []);
|
|
397
|
-
const value2 =
|
|
398
|
-
return /* @__PURE__ */
|
|
562
|
+
const value2 = useMemo2(() => ({ toast: toast2, dismiss }), [toast2, dismiss]);
|
|
563
|
+
return /* @__PURE__ */ jsx9(ToastContext.Provider, { value: value2, children: /* @__PURE__ */ jsxs7(RadixToast.Provider, { duration, label: label2, swipeDirection: "right", children: [
|
|
399
564
|
children,
|
|
400
565
|
toasts.map(({ id, open, title: title3, description: description3, variant, duration: itemDuration, action: action2 }) => /* @__PURE__ */ jsxs7(
|
|
401
566
|
RadixToast.Root,
|
|
@@ -407,15 +572,15 @@ function ToastProvider({ children, duration = 5e3, label: label2 = "\uC54C\uB9BC
|
|
|
407
572
|
},
|
|
408
573
|
className: toast({ variant }),
|
|
409
574
|
children: [
|
|
410
|
-
/* @__PURE__ */
|
|
411
|
-
description3 && /* @__PURE__ */
|
|
412
|
-
action2 && /* @__PURE__ */
|
|
413
|
-
/* @__PURE__ */
|
|
575
|
+
/* @__PURE__ */ jsx9(RadixToast.Title, { className: title2, children: title3 }),
|
|
576
|
+
description3 && /* @__PURE__ */ jsx9(RadixToast.Description, { className: description2, children: description3 }),
|
|
577
|
+
action2 && /* @__PURE__ */ jsx9(RadixToast.Action, { asChild: true, altText: action2.altText ?? action2.label, className: action, children: /* @__PURE__ */ jsx9(Button, { size: "sm", variant: "soft", color: "neutral", onClick: action2.onClick, children: action2.label }) }),
|
|
578
|
+
/* @__PURE__ */ jsx9(RadixToast.Close, { className: close, "aria-label": "\uB2EB\uAE30", children: /* @__PURE__ */ jsx9(XIcon2, { size: 16 }) })
|
|
414
579
|
]
|
|
415
580
|
},
|
|
416
581
|
id
|
|
417
582
|
)),
|
|
418
|
-
/* @__PURE__ */
|
|
583
|
+
/* @__PURE__ */ jsx9(RadixToast.Viewport, { className: cx(portal2.className, viewport2), style: portal2.style })
|
|
419
584
|
] }) });
|
|
420
585
|
}
|
|
421
586
|
function useToast() {
|
|
@@ -432,7 +597,7 @@ var arrow = "z7rufs1";
|
|
|
432
597
|
var content3 = "z7rufs0";
|
|
433
598
|
|
|
434
599
|
// src/components/Tooltip/Tooltip.tsx
|
|
435
|
-
import { jsx as
|
|
600
|
+
import { jsx as jsx10, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
436
601
|
function Tooltip({
|
|
437
602
|
content: content4,
|
|
438
603
|
children,
|
|
@@ -445,21 +610,22 @@ function Tooltip({
|
|
|
445
610
|
disabled,
|
|
446
611
|
className
|
|
447
612
|
}) {
|
|
448
|
-
const
|
|
613
|
+
const portal2 = usePortalProps();
|
|
449
614
|
if (disabled || content4 == null || content4 === "") return children;
|
|
450
|
-
return /* @__PURE__ */
|
|
451
|
-
/* @__PURE__ */
|
|
452
|
-
/* @__PURE__ */
|
|
615
|
+
return /* @__PURE__ */ jsx10(RadixTooltip.Provider, { delayDuration: delay, children: /* @__PURE__ */ jsxs8(RadixTooltip.Root, { open, defaultOpen, onOpenChange, children: [
|
|
616
|
+
/* @__PURE__ */ jsx10(RadixTooltip.Trigger, { asChild: true, children }),
|
|
617
|
+
/* @__PURE__ */ jsx10(RadixTooltip.Portal, { children: /* @__PURE__ */ jsxs8(
|
|
453
618
|
RadixTooltip.Content,
|
|
454
619
|
{
|
|
455
620
|
side,
|
|
456
621
|
align,
|
|
457
622
|
sideOffset: 6,
|
|
458
623
|
collisionPadding: 8,
|
|
459
|
-
className: cx(
|
|
624
|
+
className: cx(portal2.className, content3, className),
|
|
625
|
+
style: portal2.style,
|
|
460
626
|
children: [
|
|
461
627
|
content4,
|
|
462
|
-
/* @__PURE__ */
|
|
628
|
+
/* @__PURE__ */ jsx10(RadixTooltip.Arrow, { className: arrow, width: 10, height: 5 })
|
|
463
629
|
]
|
|
464
630
|
}
|
|
465
631
|
) })
|
|
@@ -474,7 +640,7 @@ import { createRuntimeFn as _7a4687 } from "@vanilla-extract/recipes/createRunti
|
|
|
474
640
|
var typography = _7a4687({ defaultClassName: "kiolio0", variantClassNames: { variant: { display: "kiolio1", h1: "kiolio2", h2: "kiolio3", h3: "kiolio4", h4: "kiolio5", "body-lg": "kiolio6", body: "kiolio7", "body-sm": "kiolio8", caption: "kiolio9" }, color: { "default": "kiolioa", muted: "kioliob", subtle: "kiolioc", primary: "kioliod", danger: "kiolioe", success: "kioliof", inherit: "kioliog" }, weight: { regular: "kiolioh", medium: "kiolioi", semibold: "kiolioj", bold: "kioliok" }, align: { start: "kioliol", center: "kioliom", end: "kiolion" }, truncate: { true: "kiolioo" } }, defaultVariants: { variant: "body", color: "default" }, compoundVariants: [] });
|
|
475
641
|
|
|
476
642
|
// src/components/Typography/Typography.tsx
|
|
477
|
-
import { jsx as
|
|
643
|
+
import { jsx as jsx11 } from "react/jsx-runtime";
|
|
478
644
|
var defaultElement = {
|
|
479
645
|
display: "h1",
|
|
480
646
|
h1: "h1",
|
|
@@ -488,7 +654,7 @@ var defaultElement = {
|
|
|
488
654
|
};
|
|
489
655
|
var Typography = forwardRef8(function Typography2({ variant = "body", as, color, weight, align, truncate, className, ...rest }, ref) {
|
|
490
656
|
const Component = as ?? defaultElement[variant];
|
|
491
|
-
return /* @__PURE__ */
|
|
657
|
+
return /* @__PURE__ */ jsx11(
|
|
492
658
|
Component,
|
|
493
659
|
{
|
|
494
660
|
ref,
|
|
@@ -510,8 +676,12 @@ export {
|
|
|
510
676
|
ToastProvider,
|
|
511
677
|
Tooltip,
|
|
512
678
|
Typography,
|
|
679
|
+
contrastRatio,
|
|
680
|
+
createIntentColors,
|
|
681
|
+
createTheme,
|
|
513
682
|
themeClass,
|
|
514
683
|
usePortalClassName,
|
|
684
|
+
usePortalProps,
|
|
515
685
|
useTheme,
|
|
516
686
|
useToast,
|
|
517
687
|
vars
|