@alea-design/ui 0.1.1 → 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/README.md +7 -1
- package/dist/components/accordion/Accordion.js +29 -0
- package/dist/components/ai/AI.d.ts +5 -1
- package/dist/components/ai/AI.js +187 -0
- package/dist/components/app/AppParts.d.ts +16 -4
- package/dist/components/app/AppParts.js +134 -0
- package/dist/components/button/Button.d.ts +1 -1
- package/dist/components/button/Button.js +137 -0
- package/dist/components/button/Groups.d.ts +1 -1
- package/dist/components/button/Groups.js +112 -0
- package/dist/components/card/Card.d.ts +3 -2
- package/dist/components/card/Card.js +47 -0
- package/dist/components/chat/Chat.d.ts +4 -2
- package/dist/components/chat/Chat.js +275 -0
- package/dist/components/choice/Choice.js +69 -0
- package/dist/components/color/Color.d.ts +3 -3
- package/dist/components/color/Color.js +98 -0
- package/dist/components/combobox/Autocomplete.d.ts +5 -5
- package/dist/components/combobox/Autocomplete.js +126 -0
- package/dist/components/combobox/ComboBox.d.ts +4 -4
- package/dist/components/combobox/ComboBox.js +112 -0
- package/dist/components/combobox/Highlight.js +50 -0
- package/dist/components/command/CommandPalette.d.ts +10 -3
- package/dist/components/command/CommandPalette.js +56 -0
- package/dist/components/content/Content.d.ts +1 -1
- package/dist/components/content/Content.js +125 -0
- package/dist/components/data/Data.js +79 -0
- package/dist/components/date/Date.js +109 -0
- package/dist/components/display/Display.d.ts +5 -3
- package/dist/components/display/Display.js +89 -0
- package/dist/components/display/Display2.d.ts +3 -1
- package/dist/components/display/Display2.js +75 -0
- package/dist/components/emoji/EmojiPicker.js +52 -0
- package/dist/components/emoji/emoji-data.js +27 -0
- package/dist/components/extras/CodeSteps.d.ts +3 -0
- package/dist/components/extras/CodeSteps.js +19 -0
- package/dist/components/extras/Extras.d.ts +1 -1
- package/dist/components/extras/Extras.js +116 -0
- package/dist/components/feedback/Feedback.d.ts +11 -8
- package/dist/components/feedback/Feedback.js +185 -0
- package/dist/components/feedback/Spinner.js +18 -0
- package/dist/components/feedback/Status.d.ts +6 -2
- package/dist/components/feedback/Status.js +48 -0
- package/dist/components/field/Field.d.ts +1 -1
- package/dist/components/field/Field.js +187 -0
- package/dist/components/field/FieldLoading.d.ts +1 -1
- package/dist/components/field/FieldLoading.js +18 -0
- package/dist/components/filter/FilterBar.js +96 -0
- package/dist/components/form/Form.d.ts +5 -5
- package/dist/components/form/Form.js +53 -0
- package/dist/components/icon/Icon.d.ts +2 -2
- package/dist/components/icon/Icon.js +66 -0
- package/dist/components/icon/icon-cells.js +39 -0
- package/dist/components/icon/icon-contexts.d.ts +1 -1
- package/dist/components/icon/icon-contexts.js +38 -0
- package/dist/components/icon/icon-names.d.ts +1 -1
- package/dist/components/icon/icon-names.js +376 -0
- package/dist/components/layout/Bento.d.ts +1 -1
- package/dist/components/layout/Bento.js +38 -0
- package/dist/components/layout/Layout.d.ts +1 -1
- package/dist/components/layout/Layout.js +54 -0
- package/dist/components/layout/Layout2.d.ts +36 -6
- package/dist/components/layout/Layout2.js +105 -0
- package/dist/components/layout/Layout3.js +35 -0
- package/dist/components/layout/Responsive.d.ts +1 -1
- package/dist/components/layout/Responsive.js +32 -0
- package/dist/components/list/List.d.ts +3 -2
- package/dist/components/list/List.js +82 -0
- package/dist/components/list/Lists2.d.ts +6 -4
- package/dist/components/list/Lists2.js +60 -0
- package/dist/components/media/Media.d.ts +8 -4
- package/dist/components/media/Media.js +188 -0
- package/dist/components/menu/Menu.d.ts +23 -12
- package/dist/components/menu/Menu.js +68 -0
- package/dist/components/more/More.d.ts +7 -7
- package/dist/components/more/More.js +182 -0
- package/dist/components/navigation/Navbar.d.ts +1 -1
- package/dist/components/navigation/Navbar.js +27 -0
- package/dist/components/navigation/Navigation.js +121 -0
- package/dist/components/navigation/Navigation2.d.ts +6 -2
- package/dist/components/navigation/Navigation2.js +355 -0
- package/dist/components/overlay/Drawer.d.ts +11 -6
- package/dist/components/overlay/Drawer.js +39 -0
- package/dist/components/overlay/Modal.d.ts +6 -3
- package/dist/components/overlay/Modal.js +27 -0
- package/dist/components/overlay/Overlay.d.ts +14 -9
- package/dist/components/overlay/Overlay.js +76 -0
- package/dist/components/overlay/Sheet.d.ts +11 -5
- package/dist/components/overlay/Sheet.js +52 -0
- package/dist/components/page/Page.d.ts +5 -5
- package/dist/components/page/Page.js +132 -0
- package/dist/components/page/PageParts.d.ts +5 -5
- package/dist/components/page/PageParts.js +109 -0
- package/dist/components/picker/Picker.d.ts +11 -11
- package/dist/components/picker/Picker.js +294 -0
- package/dist/components/picker/Wheel.js +132 -0
- package/dist/components/rating/Rating.d.ts +2 -1
- package/dist/components/rating/Rating.js +66 -0
- package/dist/components/select/Select.d.ts +8 -6
- package/dist/components/select/Select.js +146 -0
- package/dist/components/shell/AppShell.d.ts +3 -3
- package/dist/components/shell/AppShell.js +56 -0
- package/dist/components/shell/AppSidebar.d.ts +5 -5
- package/dist/components/shell/AppSidebar.js +62 -0
- package/dist/components/slider/Slider.d.ts +2 -1
- package/dist/components/slider/Slider.js +36 -0
- package/dist/components/surface/Surface.d.ts +16 -0
- package/dist/components/surface/Surface.js +7 -0
- package/dist/components/table/Table.d.ts +4 -3
- package/dist/components/table/Table.js +58 -0
- package/dist/components/tabs/Tabs.d.ts +1 -0
- package/dist/components/tabs/Tabs.js +120 -0
- package/dist/components/theme/Theme.d.ts +11 -6
- package/dist/components/theme/Theme.js +186 -0
- package/dist/components/theme/lens.js +104 -0
- package/dist/components/tree/Tree.js +303 -0
- package/dist/components/typography/Typography.js +43 -0
- package/dist/components/upload/Upload.js +71 -0
- package/dist/components/work/Ops.js +24 -0
- package/dist/components/work/Work.d.ts +4 -2
- package/dist/components/work/Work.js +241 -0
- package/dist/css/accordion.css +1 -0
- package/dist/css/ai.css +1 -0
- package/dist/css/app.css +1 -0
- package/dist/css/base.css +1 -0
- package/dist/css/button.css +1 -0
- package/dist/css/card.css +1 -0
- package/dist/css/chat.css +1 -0
- package/dist/css/choice.css +1 -0
- package/dist/css/color.css +1 -0
- package/dist/css/combobox.css +1 -0
- package/dist/css/command.css +1 -0
- package/dist/css/content.css +1 -0
- package/dist/css/data.css +1 -0
- package/dist/css/date.css +1 -0
- package/dist/css/display.css +1 -0
- package/dist/css/emoji.css +1 -0
- package/dist/css/extras.css +1 -0
- package/dist/css/feedback.css +1 -0
- package/dist/css/field.css +1 -0
- package/dist/css/filter.css +1 -0
- package/dist/css/form.css +1 -0
- package/dist/css/groups.json +346 -0
- package/dist/css/icon.css +1 -0
- package/dist/css/layout.css +1 -0
- package/dist/css/list.css +1 -0
- package/dist/css/media.css +1 -0
- package/dist/css/menu.css +1 -0
- package/dist/css/more.css +1 -0
- package/dist/css/navigation.css +1 -0
- package/dist/css/overlay.css +1 -0
- package/dist/css/page.css +1 -0
- package/dist/css/picker.css +1 -0
- package/dist/css/rating.css +1 -0
- package/dist/css/select.css +1 -0
- package/dist/css/shell.css +1 -0
- package/dist/css/slider.css +1 -0
- package/dist/css/surface.css +1 -0
- package/dist/css/table.css +1 -0
- package/dist/css/tabs.css +1 -0
- package/dist/css/tree.css +1 -0
- package/dist/css/typography.css +1 -0
- package/dist/css/upload.css +1 -0
- package/dist/css/work.css +1 -0
- package/dist/i18n/strings.js +842 -0
- package/dist/index.d.ts +71 -70
- package/dist/index.js +398 -7436
- package/dist/styles.css +1 -1
- package/dist/utils/Blueprint.js +131 -0
- package/dist/utils/DotField.js +32 -0
- package/dist/utils/attr.d.ts +1 -1
- package/dist/utils/attr.js +18 -0
- package/dist/utils/blueprintScene.js +161 -0
- package/dist/utils/controlled.js +11 -0
- package/dist/utils/cx.js +11 -0
- package/dist/utils/inert.js +9 -0
- package/dist/utils/refs.d.ts +3 -0
- package/dist/utils/refs.js +11 -0
- package/dist/utils/responsive.js +12 -0
- package/dist/utils/scrollEdges.js +31 -0
- package/dist/utils/space.js +10 -0
- package/dist/utils/vocabulary.d.ts +6 -0
- package/dist/utils/vocabulary.js +17 -0
- package/package.json +12 -8
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type ReactNode } from 'react';
|
|
2
2
|
import { type MotionConfig } from '@alea-design/motion';
|
|
3
|
-
import { type AleaStrings } from '../../i18n/strings';
|
|
4
|
-
import { type GlassRefraction } from './lens';
|
|
3
|
+
import { type AleaStrings } from '../../i18n/strings.js';
|
|
4
|
+
import { type GlassRefraction } from './lens.js';
|
|
5
5
|
/** Brand changes on top of the Alea tokens. Everything not set keeps the default. */
|
|
6
6
|
export interface BrandTheme {
|
|
7
7
|
/** Your accent color (any CSS color). Strong (for text and links), subtle and focus are mixed from it per theme; check text on it with ContrastBadge. */
|
|
@@ -11,7 +11,7 @@ export interface BrandTheme {
|
|
|
11
11
|
/** Multiplies every radius: 0 square, 0.5 tight, 1 the Alea default, 1.4 rounder. */
|
|
12
12
|
radius?: number;
|
|
13
13
|
/** compact (controls 8 px shorter and the Compact space scale: base 2 px) or comfy (default). To change the space scale only, use the density prop of ThemeProvider. 'comfortable' is a deprecated alias of 'comfy'. */
|
|
14
|
-
density?: 'comfy' | 'compact' | 'comfortable';
|
|
14
|
+
density?: 'comfy' | 'compact' | /** @deprecated Use comfy. */ 'comfortable';
|
|
15
15
|
/** Font stacks: body (UI and text), display (big titles), mono (code). Load the fonts yourself. */
|
|
16
16
|
fonts?: {
|
|
17
17
|
body?: string;
|
|
@@ -49,13 +49,16 @@ export interface ThemeProviderProps {
|
|
|
49
49
|
/** Brand changes: accent color, radius, density, fonts. */
|
|
50
50
|
brand?: BrandTheme;
|
|
51
51
|
/** Space density: "comfy" (default, base 4 px; "comfortable" is a deprecated alias) or "compact" (base 2 px: every space token halves, odd results rounded up to even). Sets data-density on the root or the wrapper; controls keep their size (use brand.density for shorter controls too). */
|
|
52
|
-
density?: 'comfy' | 'compact' | 'comfortable';
|
|
52
|
+
density?: 'comfy' | 'compact' | /** @deprecated Use comfy. */ 'comfortable';
|
|
53
53
|
/** Your router's navigate function (React Router's useNavigate(), Next's router.push): links in the kit then navigate without a reload. */
|
|
54
54
|
navigate?: (path: string, options?: any) => void;
|
|
55
55
|
/** Your router's useHref, for routers with a base path. */
|
|
56
56
|
useHref?: (href: string) => string;
|
|
57
57
|
/** A BCP 47 locale ("es-ES", "pt-BR"): dates, numbers, calendars and the built-in labels follow it. Default the browser's. */
|
|
58
58
|
locale?: string;
|
|
59
|
+
/** Reading direction. Default: from the locale (Arabic, Hebrew, Persian, Urdu... are right to left), else left to right. Sets `dir` on the document (or on the scope element), and every component mirrors through logical CSS properties.
|
|
60
|
+
* The keyboard keys and slider geometry follow the locale, so pair `dir="rtl"` with an RTL `locale` (a console warning says so when they disagree). */
|
|
61
|
+
dir?: 'ltr' | 'rtl';
|
|
59
62
|
/** A look on top of the tokens, each with dark and light: "graphite" is monochrome (near-black and white, gray surfaces, sans titles); "midnight" is serious and precise (navy, hairline borders, a clear blue accent and button, sans titles); "glass" is light and airy (frosted glass on every surface, Inter, a blue accent); "ember", "solar" and "moss" keep one hue each: warm red, amber and green, in dark and light. */
|
|
60
63
|
preset?: 'default' | 'graphite' | 'midnight' | 'glass' | 'ember' | 'solar' | 'moss';
|
|
61
64
|
/** "glass" turns floating surfaces (navbar, popovers, menus, dialogs, toasts, drawers) into frosted glass. */
|
|
@@ -77,18 +80,20 @@ export interface ThemeProviderProps {
|
|
|
77
80
|
/** Motion for everything below: mode (expressive, productive, reduced, off), reduced (system, always, never), speed, intensity, and per-component defaults. */
|
|
78
81
|
motion?: MotionConfig;
|
|
79
82
|
}
|
|
83
|
+
/** The reading direction of a BCP 47 locale ("ar-EG" and "he" are right to left; "es-ES" is left to right). */
|
|
84
|
+
export declare function directionOf(locale?: string): 'ltr' | 'rtl';
|
|
80
85
|
/** An inline script for server-rendered pages: sets data-theme on <html> from the stored choice (or the OS) before
|
|
81
86
|
* the first paint, so the page never flashes the other theme. Put it in <head> with suppressHydrationWarning on <html>. */
|
|
82
87
|
export declare function themeScript(storageKey?: string, defaultTheme?: ThemeName): string;
|
|
83
88
|
/** The same script as an element, for React frameworks with server components (a server layout can render it; it cannot
|
|
84
89
|
* call themeScript() directly): <head><ThemeScript /></head>, with suppressHydrationWarning on <html>. */
|
|
85
90
|
export declare function ThemeScript({ storageKey, defaultTheme }: {
|
|
86
|
-
storageKey?: string;
|
|
91
|
+
storageKey?: string; /** The theme used when nothing is saved yet: dark (default) or light. */
|
|
87
92
|
defaultTheme?: ThemeName;
|
|
88
93
|
}): import("react").JSX.Element;
|
|
89
94
|
/** A router's useHref that leaves absolute URLs, protocol-relative URLs and #anchors alone (routers would turn https://… into /current/https:/…). */
|
|
90
95
|
export declare function keepAbsolute(useHref: (href: string) => string): (href: string) => string;
|
|
91
|
-
export declare function ThemeProvider({ children, defaultTheme, theme: controlled, onThemeChange, storageKey, scope, className, brand, density, navigate, useHref, locale, motion, preset, surface, contrast, background, strings, glass }: ThemeProviderProps): import("react").JSX.Element;
|
|
96
|
+
export declare function ThemeProvider({ children, dir: dirProp, defaultTheme, theme: controlled, onThemeChange, storageKey, scope, className, brand, density, navigate, useHref, locale, motion, preset, surface, contrast, background, strings, glass }: ThemeProviderProps): import("react").JSX.Element;
|
|
92
97
|
/** The current theme and a setter. Works without a provider (reads the document). */
|
|
93
98
|
export declare function useTheme(): ThemeContextValue;
|
|
94
99
|
export {};
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsxs as V, Fragment as H, jsx as p } from "react/jsx-runtime";
|
|
3
|
+
import { useState as q, useSyncExternalStore as W, useEffect as u, useMemo as k, useId as K, useCallback as ee, useContext as te, createContext as ne } from "react";
|
|
4
|
+
import { warnDeprecated as ae } from "../../utils/vocabulary.js";
|
|
5
|
+
import { RouterProvider as re, I18nProvider as oe } from "react-aria-components";
|
|
6
|
+
import { motionVariables as ce, motionAttributes as ie, motionComponentCss as se } from "@alea-design/motion";
|
|
7
|
+
import { cx as le } from "../../utils/cx.js";
|
|
8
|
+
import { StringsContext as de } from "../../i18n/strings.js";
|
|
9
|
+
import { refractionLevel as me, startGlassLens as ue } from "./lens.js";
|
|
10
|
+
const fe = {
|
|
11
|
+
"--alea-spacing-base": "0.125rem",
|
|
12
|
+
"--alea-space-0": "0rem",
|
|
13
|
+
"--alea-space-0-25": "0.0625rem",
|
|
14
|
+
"--alea-space-0-5": "0.0625rem",
|
|
15
|
+
"--alea-space-1-5": "0.1875rem",
|
|
16
|
+
"--alea-space-2-5": "0.3125rem",
|
|
17
|
+
"--alea-space-3-5": "0.4375rem",
|
|
18
|
+
"--alea-space-1": "0.125rem",
|
|
19
|
+
"--alea-space-2": "0.25rem",
|
|
20
|
+
"--alea-space-3": "0.375rem",
|
|
21
|
+
"--alea-space-4": "0.5rem",
|
|
22
|
+
"--alea-space-5": "0.625rem",
|
|
23
|
+
"--alea-space-6": "0.75rem",
|
|
24
|
+
"--alea-space-7": "0.875rem",
|
|
25
|
+
"--alea-space-8": "1rem",
|
|
26
|
+
"--alea-space-10": "1.25rem",
|
|
27
|
+
"--alea-space-12": "1.5rem",
|
|
28
|
+
"--alea-space-16": "2rem",
|
|
29
|
+
"--alea-space-20": "2.5rem",
|
|
30
|
+
"--alea-space-22": "2.75rem",
|
|
31
|
+
"--alea-space-24": "3rem"
|
|
32
|
+
}, B = [["3xs", 1], ["2xs", 2], ["xs", 4], ["sm", 6], ["field", 8], ["md", 10], ["lg", 12], ["xl", 16], ["2xl", 20], ["3xl", 24], ["4xl", 32]], pe = B.map(([e, n]) => [e, e === "3xs" || e === "2xs" ? n : n * 2]);
|
|
33
|
+
function he(e = {}, n = "default") {
|
|
34
|
+
var r, s, i;
|
|
35
|
+
const t = {};
|
|
36
|
+
if (e.accent) {
|
|
37
|
+
t["--alea-accent"] = e.accent, t["--alea-accent-strong"] = `color-mix(in oklch, ${e.accent} 62%, var(--alea-text))`, t["--alea-accent-subtle"] = `color-mix(in oklch, ${e.accent} 16%, transparent)`, t["--alea-focus"] = e.accent, t["--alea-focus-halo"] = `color-mix(in oklch, ${e.accent} 30%, transparent)`, t["--alea-accent-solid"] = e.accent;
|
|
38
|
+
const o = `color-mix(in oklch, ${e.accent} 55%, white)`;
|
|
39
|
+
t["--alea-gradient-accent"] = `radial-gradient(100% 100% at 25% 100%, ${e.accent} 0%, ${o} 100%)`, t["--alea-gradient-accent-linear"] = `linear-gradient(120deg, ${e.accent} 0%, ${o} 100%)`, t["--alea-gradient-text"] = t["--alea-gradient-accent"], t["--alea-gradient-text-linear"] = t["--alea-gradient-accent-linear"], t["--alea-shadow-glow"] = `0 10px 30px -10px color-mix(in srgb, ${e.accent} 55%, transparent)`;
|
|
40
|
+
}
|
|
41
|
+
if (e.accentOn && (t["--alea-accent-on"] = e.accentOn), e.radius != null) {
|
|
42
|
+
for (const [o, A] of n === "glass" ? pe : B) t[`--alea-radius-${o}`] = `${Math.round(A * e.radius)}px`;
|
|
43
|
+
t["--alea-radius-full"] = e.radius >= 1 ? "9999px" : `${Math.round(18 * e.radius)}px`;
|
|
44
|
+
}
|
|
45
|
+
return e.density === "compact" && Object.assign(t, fe, {
|
|
46
|
+
"--alea-size-control-sm": "24px",
|
|
47
|
+
"--alea-size-control-md": "32px",
|
|
48
|
+
"--alea-size-control-lg": "40px",
|
|
49
|
+
"--alea-size-field": "36px"
|
|
50
|
+
}), (r = e.fonts) != null && r.body && (t["--alea-font-family-body"] = e.fonts.body), (s = e.fonts) != null && s.display && (t["--alea-font-family-display"] = e.fonts.display), (i = e.fonts) != null && i.mono && (t["--alea-font-family-mono"] = e.fonts.mono), t;
|
|
51
|
+
}
|
|
52
|
+
const F = ne(null), ye = /* @__PURE__ */ new Set(["ar", "arc", "ckb", "dv", "fa", "he", "ks", "ku", "ps", "sd", "ug", "ur", "yi"]);
|
|
53
|
+
function P(e) {
|
|
54
|
+
var t, r;
|
|
55
|
+
if (!e) return "ltr";
|
|
56
|
+
try {
|
|
57
|
+
const s = new Intl.Locale(e), i = ((t = s.getTextInfo) == null ? void 0 : t.call(s).direction) ?? ((r = s.textInfo) == null ? void 0 : r.direction);
|
|
58
|
+
if (i === "rtl" || i === "ltr") return i;
|
|
59
|
+
} catch {
|
|
60
|
+
}
|
|
61
|
+
const n = e.toLowerCase().split(/[-_]/)[0];
|
|
62
|
+
return ye.has(n) ? "rtl" : "ltr";
|
|
63
|
+
}
|
|
64
|
+
function T() {
|
|
65
|
+
return typeof window < "u" && window.matchMedia && window.matchMedia("(prefers-color-scheme: light)").matches ? "light" : "dark";
|
|
66
|
+
}
|
|
67
|
+
function xe(e) {
|
|
68
|
+
var t;
|
|
69
|
+
if (typeof window > "u" || !window.matchMedia) return () => {
|
|
70
|
+
};
|
|
71
|
+
const n = window.matchMedia("(prefers-color-scheme: light)");
|
|
72
|
+
return (t = n.addEventListener) == null || t.call(n, "change", e), () => {
|
|
73
|
+
var r;
|
|
74
|
+
return (r = n.removeEventListener) == null ? void 0 : r.call(n, "change", e);
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
const we = () => () => {
|
|
78
|
+
};
|
|
79
|
+
function ve(e = "alea-theme", n = "dark") {
|
|
80
|
+
const t = (r) => JSON.stringify(r).replace(/</g, "\\u003c").replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
|
|
81
|
+
return `(function(){try{var k=${t(e)},t=k&&localStorage.getItem(k);if(t!=='dark'&&t!=='light'&&t!=='system')t=${t(n)};if(t==='system')t=matchMedia('(prefers-color-scheme: light)').matches?'light':'dark';document.documentElement.setAttribute('data-theme',t)}catch(e){}})()`;
|
|
82
|
+
}
|
|
83
|
+
function Pe({ storageKey: e = "alea-theme", defaultTheme: n = "dark" }) {
|
|
84
|
+
return /* @__PURE__ */ p("script", { dangerouslySetInnerHTML: { __html: ve(e, n) } });
|
|
85
|
+
}
|
|
86
|
+
function J(e) {
|
|
87
|
+
if (!e || typeof window > "u") return null;
|
|
88
|
+
try {
|
|
89
|
+
const n = window.localStorage.getItem(e);
|
|
90
|
+
return n === "dark" || n === "light" || n === "system" ? n : null;
|
|
91
|
+
} catch {
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
const ge = /^([a-z][a-z0-9+.-]*:|\/\/|#)/i, U = /* @__PURE__ */ new WeakMap();
|
|
96
|
+
function ke(e) {
|
|
97
|
+
let n = U.get(e);
|
|
98
|
+
return n || (n = (t) => {
|
|
99
|
+
const r = e(t);
|
|
100
|
+
return ge.test(t) ? t : r;
|
|
101
|
+
}, U.set(e, n)), n;
|
|
102
|
+
}
|
|
103
|
+
function Ae(e, n, t = !0) {
|
|
104
|
+
u(() => {
|
|
105
|
+
typeof document > "u" || (document.documentElement.setAttribute("data-alea-refraction", String(e)), t ? document.documentElement.removeAttribute("data-alea-lens-pause") : document.documentElement.setAttribute("data-alea-lens-pause", "off"), ue(n).refresh());
|
|
106
|
+
}, [e, n, t]);
|
|
107
|
+
}
|
|
108
|
+
function Te({ children: e, dir: n, defaultTheme: t = "dark", theme: r, onThemeChange: s, storageKey: i = "alea-theme", scope: o = "document", className: A, brand: l, density: E, navigate: j, useHref: _, locale: d, motion: f, preset: h = "default", surface: S = "solid", contrast: $ = "system", background: C = "decorated", strings: b, glass: m }) {
|
|
109
|
+
Ae(me(m == null ? void 0 : m.refraction), m == null ? void 0 : m.lensSelector, (m == null ? void 0 : m.pauseOnScroll) !== !1);
|
|
110
|
+
const [L, Z] = q(null), Q = W(we, () => J(i), () => null), y = r ?? L ?? Q ?? t, X = W(xe, T, () => "dark"), x = y === "system" ? X : y;
|
|
111
|
+
u(() => {
|
|
112
|
+
if (o !== "document" || typeof document > "u") return;
|
|
113
|
+
const a = r ?? L ?? J(i) ?? t;
|
|
114
|
+
document.documentElement.setAttribute("data-theme", a === "system" ? T() : a), document.documentElement.classList.add("alea-root");
|
|
115
|
+
}, [x, o, r, L, i, t]), u(() => {
|
|
116
|
+
if (o !== "document" || typeof window > "u") return;
|
|
117
|
+
const a = document.documentElement, c = () => a.style.setProperty("--alea-scrollbar", `${Math.max(0, window.innerWidth - a.clientWidth)}px`);
|
|
118
|
+
return c(), window.addEventListener("resize", c), () => {
|
|
119
|
+
window.removeEventListener("resize", c), a.style.removeProperty("--alea-scrollbar");
|
|
120
|
+
};
|
|
121
|
+
}, [o]);
|
|
122
|
+
const w = n ?? (d ? P(d) : void 0);
|
|
123
|
+
u(() => {
|
|
124
|
+
if (o !== "document" || typeof document > "u" || !w) return;
|
|
125
|
+
const a = document.documentElement, c = a.getAttribute("dir");
|
|
126
|
+
return a.setAttribute("dir", w), () => {
|
|
127
|
+
c == null ? a.removeAttribute("dir") : a.setAttribute("dir", c);
|
|
128
|
+
};
|
|
129
|
+
}, [w, o]), u(() => {
|
|
130
|
+
!n || !d || P(d) === n || console.warn(`[alea] dir="${n}" does not match locale "${d}" (${P(d)}): the styles mirror, but the arrow keys, sliders and calendars follow the locale. Pass a ${n === "rtl" ? "right to left" : "left to right"} locale as well.`);
|
|
131
|
+
}, [n, d]);
|
|
132
|
+
const I = JSON.stringify(f || {}), v = k(() => ({ ...he(l, h), ...ce(f) }), [l, I, h]);
|
|
133
|
+
u(() => {
|
|
134
|
+
(E === "comfortable" || (l == null ? void 0 : l.density) === "comfortable") && ae("ThemeProvider", 'density="comfortable"', 'density="comfy"');
|
|
135
|
+
}, [E, l == null ? void 0 : l.density]);
|
|
136
|
+
const G = (E ?? ((l == null ? void 0 : l.density) === "compact" ? "compact" : "comfy")) === "compact", g = k(() => ({ ...ie(f), ...G ? { "data-density": "compact" } : {}, ...h !== "default" ? { "data-preset": h } : {}, ...S !== "solid" ? { "data-surface": S } : {}, ...$ !== "system" ? { "data-contrast": $ } : {}, ...C === "plain" ? { "data-background": "plain" } : {} }), [I, h, S, $, C, G]), O = K().replace(/[^a-zA-Z0-9_-]/g, ""), M = k(() => se(f == null ? void 0 : f.components, o === "document" ? ":root" : `[data-alea-scope="${O}"]`), [I, o, O]);
|
|
137
|
+
u(() => {
|
|
138
|
+
if (o !== "document" || typeof document > "u") return;
|
|
139
|
+
const a = document.documentElement;
|
|
140
|
+
return Object.entries(g).forEach(([c, z]) => a.setAttribute(c, z)), () => {
|
|
141
|
+
Object.keys(g).forEach((c) => a.removeAttribute(c));
|
|
142
|
+
};
|
|
143
|
+
}, [g, o]), u(() => {
|
|
144
|
+
if (o !== "document" || typeof document > "u") return;
|
|
145
|
+
const a = document.documentElement;
|
|
146
|
+
return Object.entries(v).forEach(([c, z]) => a.style.setProperty(c, z)), () => {
|
|
147
|
+
Object.keys(v).forEach((c) => a.style.removeProperty(c));
|
|
148
|
+
};
|
|
149
|
+
}, [v, o]);
|
|
150
|
+
const N = ee((a) => {
|
|
151
|
+
if (r === void 0 && Z(a), s == null || s(a), i)
|
|
152
|
+
try {
|
|
153
|
+
window.localStorage.setItem(i, a);
|
|
154
|
+
} catch {
|
|
155
|
+
}
|
|
156
|
+
}, [r, s, i]), Y = k(() => ({ theme: y, resolvedTheme: x, setTheme: N }), [y, x, N]), R = M ? /* @__PURE__ */ p("style", { children: M }) : null, D = o === "element" ? /* @__PURE__ */ V("div", { className: le("alea-root", A), dir: w, "data-theme": x, "data-alea-scope": M ? O : void 0, ...g, style: v, children: [
|
|
157
|
+
R,
|
|
158
|
+
e
|
|
159
|
+
] }) : /* @__PURE__ */ V(H, { children: [
|
|
160
|
+
R,
|
|
161
|
+
e
|
|
162
|
+
] });
|
|
163
|
+
return /* @__PURE__ */ p(F.Provider, { value: Y, children: (() => {
|
|
164
|
+
const a = b ? /* @__PURE__ */ p(de.Provider, { value: b, children: D }) : D, c = j ? /* @__PURE__ */ p(re, { navigate: j, useHref: _ ? ke(_) : void 0, children: a }) : a;
|
|
165
|
+
return d ? /* @__PURE__ */ p(oe, { locale: d, children: c }) : c;
|
|
166
|
+
})() });
|
|
167
|
+
}
|
|
168
|
+
function je() {
|
|
169
|
+
const e = te(F);
|
|
170
|
+
if (e) return e;
|
|
171
|
+
const n = typeof document < "u" && document.documentElement.getAttribute("data-theme") === "light" ? "light" : "dark";
|
|
172
|
+
return { theme: n, resolvedTheme: n, setTheme: (t) => {
|
|
173
|
+
typeof document < "u" && document.documentElement.setAttribute("data-theme", t === "system" ? T() : t);
|
|
174
|
+
} };
|
|
175
|
+
}
|
|
176
|
+
export {
|
|
177
|
+
fe as COMPACT_SPACE,
|
|
178
|
+
pe as GLASS_RADII,
|
|
179
|
+
Te as ThemeProvider,
|
|
180
|
+
Pe as ThemeScript,
|
|
181
|
+
he as brandVariables,
|
|
182
|
+
P as directionOf,
|
|
183
|
+
ke as keepAbsolute,
|
|
184
|
+
ve as themeScript,
|
|
185
|
+
je as useTheme
|
|
186
|
+
};
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
const S = '.alea-popover, .alea-modal, .alea-toast, .alea-command, .alea-hovercard, .alea-menu, .alea-button[data-variant="secondary"], .alea-button[data-variant="primary"], .alea-input-wrap, .alea-select-trigger, .alea-segmented, .alea-tag, .alea-switch-track, [data-alea-lens]', I = { off: 0, subtle: 0.5, medium: 1, strong: 1.8 };
|
|
3
|
+
function W(t) {
|
|
4
|
+
return t == null ? 1 : typeof t == "number" ? Math.max(0, t) : I[t] ?? 1;
|
|
5
|
+
}
|
|
6
|
+
const R = '[data-preset="glass"], [data-surface="glass"]', F = "http://www.w3.org/2000/svg", q = 400 * 300, H = 150, T = 8e-3, _ = 44, C = (t) => "data:image/svg+xml," + encodeURIComponent(t);
|
|
7
|
+
function L(t, a) {
|
|
8
|
+
const r = Math.max(0.02, Math.min(0.45, a)).toFixed(4), o = (1 - Number(r)).toFixed(4), [n, d] = t === "x" ? ["#ff0000", "#000000"] : ["#00ff00", "#000000"], f = t === "x" ? "#800000" : "#008000";
|
|
9
|
+
return C(`<svg xmlns='http://www.w3.org/2000/svg' width='256' height='256' preserveAspectRatio='none'><linearGradient id='g' ${t === "x" ? "x2='1' y2='0'" : "x2='0' y2='1'"}><stop offset='0' stop-color='${n}'/><stop offset='${r}' stop-color='${f}'/><stop offset='${o}' stop-color='${f}'/><stop offset='1' stop-color='${d}'/></linearGradient><rect width='256' height='256' fill='url(%23g)'/></svg>`);
|
|
10
|
+
}
|
|
11
|
+
function B(t, a) {
|
|
12
|
+
return C(`<svg xmlns='http://www.w3.org/2000/svg' width='${t}' height='${a}'><filter id='n' x='0' y='0' width='1' height='1' color-interpolation-filters='sRGB'><feTurbulence type='fractalNoise' baseFrequency='${T}' numOctaves='1' seed='5'/><feGaussianBlur stdDeviation='6'/><feColorMatrix values='1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1'/></filter><rect width='${t}' height='${a}' filter='url(#n)'/></svg>`);
|
|
13
|
+
}
|
|
14
|
+
function P() {
|
|
15
|
+
var a;
|
|
16
|
+
return typeof navigator > "u" ? !1 : (((a = navigator.userAgentData) == null ? void 0 : a.brands) || []).some((r) => /Chromium/.test(r.brand));
|
|
17
|
+
}
|
|
18
|
+
function U(t = document.documentElement, a = H) {
|
|
19
|
+
let r = !1, o = 0, n = 0;
|
|
20
|
+
const d = () => {
|
|
21
|
+
o = 0, r && (r = !1, t.removeAttribute("data-alea-scrolling"));
|
|
22
|
+
}, f = () => {
|
|
23
|
+
n = 0, o && clearTimeout(o), o = window.setTimeout(d, a);
|
|
24
|
+
}, i = () => {
|
|
25
|
+
t.getAttribute("data-alea-lens-pause") !== "off" && (r || (r = !0, t.setAttribute("data-alea-scrolling", "")), n || (n = requestAnimationFrame(f)));
|
|
26
|
+
};
|
|
27
|
+
return window.addEventListener("scroll", i, { capture: !0, passive: !0 }), () => {
|
|
28
|
+
window.removeEventListener("scroll", i, { capture: !0 }), n && cancelAnimationFrame(n), o && clearTimeout(o), r = !1, t.removeAttribute("data-alea-scrolling");
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
let g = null;
|
|
32
|
+
function O(t = "") {
|
|
33
|
+
if (g) return g;
|
|
34
|
+
if (typeof document > "u" || !P()) return { stop: () => {
|
|
35
|
+
}, refresh: () => {
|
|
36
|
+
} };
|
|
37
|
+
const a = t ? `${S}, ${t}` : S, r = document.createElementNS(F, "svg");
|
|
38
|
+
r.setAttribute("aria-hidden", "true"), r.setAttribute("width", "0"), r.setAttribute("height", "0"), r.setAttribute("style", "position:absolute;width:0;height:0;overflow:hidden;pointer-events:none"), document.body.appendChild(r);
|
|
39
|
+
const o = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set(), d = () => {
|
|
40
|
+
const e = document.documentElement.getAttribute("data-alea-refraction");
|
|
41
|
+
return e == null ? 1 : Number(e) || 0;
|
|
42
|
+
}, f = (e, h, m, u) => {
|
|
43
|
+
const s = Math.max(8, Math.round(e / 4) * 4), c = Math.max(8, Math.round(h / 4) * 4), k = Math.round(Math.min(m, s / 2, c / 2)), A = Math.round(Math.min(36, Math.min(s, c) * 0.45)), y = Math.round(Math.min(120, Math.max(20, A * 3)) * u), v = `alea-lens-${s}x${c}r${k}s${y}`;
|
|
44
|
+
if (!o.has(v)) {
|
|
45
|
+
const l = document.createElementNS(F, "filter");
|
|
46
|
+
l.setAttribute("id", v), l.setAttribute("x", "0"), l.setAttribute("y", "0"), l.setAttribute("width", "1"), l.setAttribute("height", "1"), l.setAttribute("primitiveUnits", "objectBoundingBox"), l.setAttribute("color-interpolation-filters", "sRGB");
|
|
47
|
+
const E = Math.min(3, _ * u / Math.max(1, y)).toFixed(3), G = (-Number(E) / 2).toFixed(3);
|
|
48
|
+
l.innerHTML = `<feImage href="${L("x", A / s)}" x="0" y="0" width="1" height="1" preserveAspectRatio="none" result="rx"/><feImage href="${L("y", A / c)}" x="0" y="0" width="1" height="1" preserveAspectRatio="none" result="gy"/><feComposite in="rx" in2="gy" operator="arithmetic" k1="0" k2="1" k3="1" k4="0" result="edge"/><feImage href="${B(s, c)}" x="0" y="0" width="1" height="1" preserveAspectRatio="none" result="noise"/><feComposite in="edge" in2="noise" operator="arithmetic" k1="0" k2="1" k3="${E}" k4="${G}" result="map"/><feDisplacementMap in="SourceGraphic" in2="map" scale="${(y / Math.max(s, c)).toFixed(4)}" xChannelSelector="R" yChannelSelector="G" result="bent"/><feComposite in="bent" in2="SourceGraphic" operator="over"/>`, r.appendChild(l), o.add(v);
|
|
49
|
+
}
|
|
50
|
+
return v;
|
|
51
|
+
}, i = (e) => {
|
|
52
|
+
e.style.removeProperty("--alea-lens-def"), e.style.removeProperty("--alea-lens-blur-def"), e.removeAttribute("data-alea-lensed");
|
|
53
|
+
}, w = (e) => {
|
|
54
|
+
var c;
|
|
55
|
+
const h = d(), m = e.offsetWidth, u = e.offsetHeight;
|
|
56
|
+
if (!h || m < 16 || u < 16 || m * u > q || !e.closest(R)) {
|
|
57
|
+
i(e);
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
if ((m > 240 || u > 120) && ((c = e.parentElement) != null && c.closest(a))) {
|
|
61
|
+
i(e);
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
const s = getComputedStyle(e);
|
|
65
|
+
if (/(auto|scroll)/.test(s.overflowY + s.overflowX) && (e.scrollHeight > e.clientHeight + 1 || e.scrollWidth > e.clientWidth + 1)) {
|
|
66
|
+
i(e);
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
e.style.setProperty("--alea-lens-def", `url(#${f(m, u, parseFloat(s.borderTopLeftRadius) || 0, h)})`), e.setAttribute("data-alea-lensed", ""), e.style.setProperty("--alea-lens-blur-def", "4px");
|
|
70
|
+
}, b = new ResizeObserver((e) => {
|
|
71
|
+
for (const h of e) w(h.target);
|
|
72
|
+
});
|
|
73
|
+
let p = 0;
|
|
74
|
+
const x = () => {
|
|
75
|
+
if (p = 0, !document.querySelector(R) || !d()) {
|
|
76
|
+
n.forEach((e) => {
|
|
77
|
+
i(e), b.unobserve(e);
|
|
78
|
+
}), n.clear();
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
document.querySelectorAll(a).forEach((e) => {
|
|
82
|
+
n.has(e) || (n.add(e), b.observe(e), w(e));
|
|
83
|
+
}), n.forEach((e) => {
|
|
84
|
+
e.isConnected || (n.delete(e), b.unobserve(e));
|
|
85
|
+
});
|
|
86
|
+
}, M = () => {
|
|
87
|
+
p || (p = requestAnimationFrame(x));
|
|
88
|
+
}, $ = new MutationObserver(M);
|
|
89
|
+
$.observe(document.documentElement, { childList: !0, subtree: !0, attributes: !0, attributeFilter: ["data-preset", "data-surface", "data-alea-refraction"] }), x();
|
|
90
|
+
const N = U();
|
|
91
|
+
return g = { stop: () => {
|
|
92
|
+
N(), $.disconnect(), b.disconnect(), p && cancelAnimationFrame(p), n.forEach(i), r.remove(), g = null;
|
|
93
|
+
}, refresh: () => {
|
|
94
|
+
n.forEach(w), M();
|
|
95
|
+
} }, g;
|
|
96
|
+
}
|
|
97
|
+
export {
|
|
98
|
+
H as LENS_IDLE_MS,
|
|
99
|
+
S as LENS_SURFACES,
|
|
100
|
+
W as refractionLevel,
|
|
101
|
+
O as startGlassLens,
|
|
102
|
+
P as supportsLens,
|
|
103
|
+
U as watchScrolling
|
|
104
|
+
};
|