@datum-cloud/datum-ui 0.2.0-alpha.4 → 0.2.0-alpha.5
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 +33 -24
- package/dist/components/themes/index.d.ts +1 -1
- package/dist/components/themes/index.d.ts.map +1 -1
- package/dist/components/themes/types.d.ts +0 -2
- package/dist/components/themes/types.d.ts.map +1 -1
- package/dist/fonts/AllianceNo1-Medium.ttf +0 -0
- package/dist/fonts/AllianceNo1-Regular.ttf +0 -0
- package/dist/fonts/AllianceNo1-SemiBold.ttf +0 -0
- package/dist/hooks/index.mjs +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +4 -6
- package/dist/map/index.mjs +1 -1
- package/dist/{map-Df8QMcX0.mjs → map-WL6jhkSM.mjs} +1 -1
- package/dist/{style.css → styles.css} +317 -575
- package/dist/styles.mjs +1 -0
- package/dist/theme/index.mjs +1 -2
- package/dist/{theme.provider-DgGshapa.mjs → theme.provider-CzCxEFFh.mjs} +63 -1
- package/package.json +20 -21
- package/dist/datum.provider-B77goJgl.mjs +0 -37
- package/dist/provider/index.mjs +0 -4
- package/dist/providers/datum.provider.d.ts +0 -20
- package/dist/providers/datum.provider.d.ts.map +0 -1
- package/dist/providers/index.d.ts +0 -3
- package/dist/providers/index.d.ts.map +0 -1
- package/dist/theme-script-XBouzsNR.mjs +0 -66
- /package/dist/{map-leaflet-imports-CdzvEnzY.mjs → map-leaflet-imports-C4JYls8q.mjs} +0 -0
- /package/dist/{use-debounce-DQ1tmxOL.mjs → use-debounce-B6wPrZV8.mjs} +0 -0
package/dist/styles.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
package/dist/theme/index.mjs
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as useTheme, t as ThemeProvider } from "../theme.provider-DgGshapa.mjs";
|
|
1
|
+
import { i as ClientOnly, n as useTheme, r as ThemeScript, t as ThemeProvider } from "../theme.provider-CzCxEFFh.mjs";
|
|
3
2
|
|
|
4
3
|
export { ClientOnly, ThemeProvider, ThemeScript, useTheme };
|
|
@@ -1,6 +1,68 @@
|
|
|
1
1
|
import * as React$1 from "react";
|
|
2
2
|
import { Fragment as Fragment$1, jsx } from "react/jsx-runtime";
|
|
3
3
|
|
|
4
|
+
//#region src/components/themes/client-only.tsx
|
|
5
|
+
function ClientOnly({ children, fallback = null }) {
|
|
6
|
+
const [hasMounted, setHasMounted] = React$1.useState(false);
|
|
7
|
+
React$1.useEffect(() => {
|
|
8
|
+
setHasMounted(true);
|
|
9
|
+
}, []);
|
|
10
|
+
if (!hasMounted) return /* @__PURE__ */ jsx(Fragment$1, { children: fallback });
|
|
11
|
+
return /* @__PURE__ */ jsx(Fragment$1, { children });
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
//#endregion
|
|
15
|
+
//#region src/components/themes/script.ts
|
|
16
|
+
function script(attribute, storageKey, defaultTheme, forcedTheme, themes, value, enableSystem, enableColorScheme) {
|
|
17
|
+
if (typeof window === "undefined") return;
|
|
18
|
+
const el = document.documentElement;
|
|
19
|
+
const systemThemes = ["light", "dark"];
|
|
20
|
+
function updateDOM(theme) {
|
|
21
|
+
(Array.isArray(attribute) ? attribute : [attribute]).forEach((attr) => {
|
|
22
|
+
const isClass = attr === "class";
|
|
23
|
+
const classes = isClass && value ? themes.map((t) => value[t] || t) : themes;
|
|
24
|
+
if (isClass) {
|
|
25
|
+
el.classList.remove(...classes);
|
|
26
|
+
el.classList.add(value && value[theme] ? value[theme] : theme);
|
|
27
|
+
} else el.setAttribute(attr, theme);
|
|
28
|
+
});
|
|
29
|
+
setColorScheme(theme);
|
|
30
|
+
}
|
|
31
|
+
function setColorScheme(theme) {
|
|
32
|
+
if (enableColorScheme && systemThemes.includes(theme)) el.style.colorScheme = theme;
|
|
33
|
+
}
|
|
34
|
+
function getSystemTheme() {
|
|
35
|
+
return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
36
|
+
}
|
|
37
|
+
if (forcedTheme) updateDOM(forcedTheme);
|
|
38
|
+
else try {
|
|
39
|
+
const themeName = localStorage.getItem(storageKey) || defaultTheme;
|
|
40
|
+
updateDOM(enableSystem && themeName === "system" ? getSystemTheme() : themeName);
|
|
41
|
+
} catch {}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
//#endregion
|
|
45
|
+
//#region src/components/themes/theme-script.tsx
|
|
46
|
+
const ThemeScript = React$1.memo(({ forcedTheme, storageKey = "theme", attribute = "data-theme", enableSystem = true, enableColorScheme = true, defaultTheme = "system", value, themes = ["light", "dark"], nonce, scriptProps }) => {
|
|
47
|
+
const scriptArgs = JSON.stringify([
|
|
48
|
+
attribute,
|
|
49
|
+
storageKey,
|
|
50
|
+
defaultTheme,
|
|
51
|
+
forcedTheme,
|
|
52
|
+
themes,
|
|
53
|
+
value,
|
|
54
|
+
enableSystem,
|
|
55
|
+
enableColorScheme
|
|
56
|
+
]).slice(1, -1);
|
|
57
|
+
return /* @__PURE__ */ jsx("script", {
|
|
58
|
+
...scriptProps,
|
|
59
|
+
suppressHydrationWarning: true,
|
|
60
|
+
nonce,
|
|
61
|
+
dangerouslySetInnerHTML: { __html: `(${script.toString()})(${scriptArgs})` }
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
//#endregion
|
|
4
66
|
//#region src/components/themes/theme.provider.tsx
|
|
5
67
|
const colorSchemes = ["light", "dark"];
|
|
6
68
|
const MEDIA = "(prefers-color-scheme: dark)";
|
|
@@ -131,4 +193,4 @@ function getSystemTheme(e) {
|
|
|
131
193
|
}
|
|
132
194
|
|
|
133
195
|
//#endregion
|
|
134
|
-
export { useTheme as n, ThemeProvider as t };
|
|
196
|
+
export { ClientOnly as i, useTheme as n, ThemeScript as r, ThemeProvider as t };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@datum-cloud/datum-ui",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.2.0-alpha.
|
|
4
|
+
"version": "0.2.0-alpha.5",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"url": "https://github.com/datum-cloud/datum-ui"
|
|
@@ -14,10 +14,9 @@
|
|
|
14
14
|
"types": "./dist/index.d.ts",
|
|
15
15
|
"default": "./dist/index.mjs"
|
|
16
16
|
},
|
|
17
|
-
"./styles":
|
|
18
|
-
|
|
19
|
-
"
|
|
20
|
-
"default": "./dist/provider/index.mjs"
|
|
17
|
+
"./styles": {
|
|
18
|
+
"style": "./dist/styles.css",
|
|
19
|
+
"default": "./dist/styles.css"
|
|
21
20
|
},
|
|
22
21
|
"./theme": {
|
|
23
22
|
"types": "./dist/components/themes/index.d.ts",
|
|
@@ -244,6 +243,18 @@
|
|
|
244
243
|
"README.md",
|
|
245
244
|
"dist"
|
|
246
245
|
],
|
|
246
|
+
"scripts": {
|
|
247
|
+
"build": "tsdown --config-loader native && tsc -p tsconfig.build.json && node scripts/fix-dts-imports.mjs && cp -r src/styles/fonts dist/fonts",
|
|
248
|
+
"dev": "tsdown --config-loader native --watch",
|
|
249
|
+
"lint": "eslint .",
|
|
250
|
+
"typecheck": "tsc --noEmit",
|
|
251
|
+
"test": "vitest run",
|
|
252
|
+
"test:watch": "vitest",
|
|
253
|
+
"test:coverage": "vitest run --coverage",
|
|
254
|
+
"clean": "rm -rf dist .turbo node_modules coverage",
|
|
255
|
+
"prepack": "node scripts/strip-workspace-deps.mjs --strip",
|
|
256
|
+
"postpack": "node scripts/strip-workspace-deps.mjs --restore"
|
|
257
|
+
},
|
|
247
258
|
"peerDependencies": {
|
|
248
259
|
"@conform-to/react": ">=1",
|
|
249
260
|
"@conform-to/zod": ">=1",
|
|
@@ -402,9 +413,7 @@
|
|
|
402
413
|
"class-variance-authority": "^0.7",
|
|
403
414
|
"clsx": "^2.1.1",
|
|
404
415
|
"lucide-react": "^0.556",
|
|
405
|
-
"tailwind-merge": "^3.5.0"
|
|
406
|
-
"tailwind-scrollbar-hide": "^4.0.0",
|
|
407
|
-
"tw-animate-css": "^1.4.0"
|
|
416
|
+
"tailwind-merge": "^3.5.0"
|
|
408
417
|
},
|
|
409
418
|
"devDependencies": {
|
|
410
419
|
"@bosh-code/tsdown-plugin-tailwindcss": "^1.0.1",
|
|
@@ -415,6 +424,7 @@
|
|
|
415
424
|
"@radix-ui/react-slot": "^1.2.4",
|
|
416
425
|
"@radix-ui/react-tabs": "^1.1.13",
|
|
417
426
|
"@radix-ui/react-tooltip": "^1.2.8",
|
|
427
|
+
"@repo/config": "workspace:*",
|
|
418
428
|
"@stepperize/react": "^6.1.0",
|
|
419
429
|
"@tailwindcss/node": "^4.2.1",
|
|
420
430
|
"@tailwindcss/oxide": "^4.2.1",
|
|
@@ -451,20 +461,9 @@
|
|
|
451
461
|
"tsdown": "^0.20.3",
|
|
452
462
|
"typescript": "^5.9",
|
|
453
463
|
"vitest": "^3",
|
|
454
|
-
"zod": "^4.3.6"
|
|
455
|
-
"@repo/config": "0.0.0"
|
|
464
|
+
"zod": "^4.3.6"
|
|
456
465
|
},
|
|
457
466
|
"publishConfig": {
|
|
458
467
|
"access": "public"
|
|
459
|
-
},
|
|
460
|
-
"scripts": {
|
|
461
|
-
"build": "tsdown --config-loader native && tsc -p tsconfig.build.json && node scripts/fix-dts-imports.mjs && cp -r src/styles/fonts dist/fonts",
|
|
462
|
-
"dev": "tsdown --config-loader native --watch",
|
|
463
|
-
"lint": "eslint .",
|
|
464
|
-
"typecheck": "tsc --noEmit",
|
|
465
|
-
"test": "vitest run",
|
|
466
|
-
"test:watch": "vitest",
|
|
467
|
-
"test:coverage": "vitest run --coverage",
|
|
468
|
-
"clean": "rm -rf dist .turbo node_modules coverage"
|
|
469
468
|
}
|
|
470
|
-
}
|
|
469
|
+
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { t as ThemeProvider } from "./theme.provider-DgGshapa.mjs";
|
|
2
|
-
import { jsx } from "react/jsx-runtime";
|
|
3
|
-
|
|
4
|
-
//#region src/providers/datum.provider.tsx
|
|
5
|
-
const THEME_STYLE_MAP = {
|
|
6
|
-
alpha: {
|
|
7
|
-
light: "theme-alpha",
|
|
8
|
-
dark: "theme-alpha dark"
|
|
9
|
-
},
|
|
10
|
-
default: {
|
|
11
|
-
light: "theme-default",
|
|
12
|
-
dark: "theme-default dark"
|
|
13
|
-
},
|
|
14
|
-
experimental: {
|
|
15
|
-
light: "theme-experimental",
|
|
16
|
-
dark: "theme-experimental dark"
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
function DatumProvider({ children, defaultTheme = "system", themeStyle = "alpha", storageKey = "datum-theme", ...props }) {
|
|
20
|
-
const styleMap = THEME_STYLE_MAP[themeStyle];
|
|
21
|
-
return /* @__PURE__ */ jsx(ThemeProvider, {
|
|
22
|
-
attribute: "class",
|
|
23
|
-
defaultTheme,
|
|
24
|
-
storageKey,
|
|
25
|
-
enableSystem: true,
|
|
26
|
-
enableColorScheme: true,
|
|
27
|
-
value: {
|
|
28
|
-
light: styleMap.light,
|
|
29
|
-
dark: styleMap.dark
|
|
30
|
-
},
|
|
31
|
-
...props,
|
|
32
|
-
children
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
//#endregion
|
|
37
|
-
export { DatumProvider as t };
|
package/dist/provider/index.mjs
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { ReactNode } from 'react';
|
|
2
|
-
import type { Theme, ThemeStyle } from '../components/themes/types';
|
|
3
|
-
import '../styles/root.css';
|
|
4
|
-
export interface DatumProviderProps {
|
|
5
|
-
children: ReactNode;
|
|
6
|
-
/** Theme mode: light, dark, or follow system preference */
|
|
7
|
-
defaultTheme?: Theme;
|
|
8
|
-
/** Visual style variant applied to the design system */
|
|
9
|
-
themeStyle?: ThemeStyle;
|
|
10
|
-
/** Force a specific theme, overriding user preference */
|
|
11
|
-
forcedTheme?: Theme;
|
|
12
|
-
/** localStorage key for theme persistence */
|
|
13
|
-
storageKey?: string;
|
|
14
|
-
/** Disable CSS transitions during theme switches */
|
|
15
|
-
disableTransitionOnChange?: boolean;
|
|
16
|
-
/** CSP nonce for inline script */
|
|
17
|
-
nonce?: string;
|
|
18
|
-
}
|
|
19
|
-
export declare function DatumProvider({ children, defaultTheme, themeStyle, storageKey, ...props }: DatumProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
20
|
-
//# sourceMappingURL=datum.provider.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"datum.provider.d.ts","sourceRoot":"","sources":["../../src/providers/datum.provider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACtC,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAA;AAInE,OAAO,oBAAoB,CAAA;AAE3B,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,SAAS,CAAA;IACnB,2DAA2D;IAC3D,YAAY,CAAC,EAAE,KAAK,CAAA;IACpB,wDAAwD;IACxD,UAAU,CAAC,EAAE,UAAU,CAAA;IACvB,yDAAyD;IACzD,WAAW,CAAC,EAAE,KAAK,CAAA;IACnB,6CAA6C;IAC7C,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,oDAAoD;IACpD,yBAAyB,CAAC,EAAE,OAAO,CAAA;IACnC,kCAAkC;IAClC,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAQD,wBAAgB,aAAa,CAAC,EAC5B,QAAQ,EACR,YAAuB,EACvB,UAAoB,EACpB,UAA0B,EAC1B,GAAG,KAAK,EACT,EAAE,kBAAkB,2CAgBpB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/providers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAChD,YAAY,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA"}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import * as React$1 from "react";
|
|
2
|
-
import { Fragment as Fragment$1, jsx } from "react/jsx-runtime";
|
|
3
|
-
|
|
4
|
-
//#region src/components/themes/client-only.tsx
|
|
5
|
-
function ClientOnly({ children, fallback = null }) {
|
|
6
|
-
const [hasMounted, setHasMounted] = React$1.useState(false);
|
|
7
|
-
React$1.useEffect(() => {
|
|
8
|
-
setHasMounted(true);
|
|
9
|
-
}, []);
|
|
10
|
-
if (!hasMounted) return /* @__PURE__ */ jsx(Fragment$1, { children: fallback });
|
|
11
|
-
return /* @__PURE__ */ jsx(Fragment$1, { children });
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
//#endregion
|
|
15
|
-
//#region src/components/themes/script.ts
|
|
16
|
-
function script(attribute, storageKey, defaultTheme, forcedTheme, themes, value, enableSystem, enableColorScheme) {
|
|
17
|
-
if (typeof window === "undefined") return;
|
|
18
|
-
const el = document.documentElement;
|
|
19
|
-
const systemThemes = ["light", "dark"];
|
|
20
|
-
function updateDOM(theme) {
|
|
21
|
-
(Array.isArray(attribute) ? attribute : [attribute]).forEach((attr) => {
|
|
22
|
-
const isClass = attr === "class";
|
|
23
|
-
const classes = isClass && value ? themes.map((t) => value[t] || t) : themes;
|
|
24
|
-
if (isClass) {
|
|
25
|
-
el.classList.remove(...classes);
|
|
26
|
-
el.classList.add(value && value[theme] ? value[theme] : theme);
|
|
27
|
-
} else el.setAttribute(attr, theme);
|
|
28
|
-
});
|
|
29
|
-
setColorScheme(theme);
|
|
30
|
-
}
|
|
31
|
-
function setColorScheme(theme) {
|
|
32
|
-
if (enableColorScheme && systemThemes.includes(theme)) el.style.colorScheme = theme;
|
|
33
|
-
}
|
|
34
|
-
function getSystemTheme() {
|
|
35
|
-
return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
36
|
-
}
|
|
37
|
-
if (forcedTheme) updateDOM(forcedTheme);
|
|
38
|
-
else try {
|
|
39
|
-
const themeName = localStorage.getItem(storageKey) || defaultTheme;
|
|
40
|
-
updateDOM(enableSystem && themeName === "system" ? getSystemTheme() : themeName);
|
|
41
|
-
} catch {}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
//#endregion
|
|
45
|
-
//#region src/components/themes/theme-script.tsx
|
|
46
|
-
const ThemeScript = React$1.memo(({ forcedTheme, storageKey = "theme", attribute = "data-theme", enableSystem = true, enableColorScheme = true, defaultTheme = "system", value, themes = ["light", "dark"], nonce, scriptProps }) => {
|
|
47
|
-
const scriptArgs = JSON.stringify([
|
|
48
|
-
attribute,
|
|
49
|
-
storageKey,
|
|
50
|
-
defaultTheme,
|
|
51
|
-
forcedTheme,
|
|
52
|
-
themes,
|
|
53
|
-
value,
|
|
54
|
-
enableSystem,
|
|
55
|
-
enableColorScheme
|
|
56
|
-
]).slice(1, -1);
|
|
57
|
-
return /* @__PURE__ */ jsx("script", {
|
|
58
|
-
...scriptProps,
|
|
59
|
-
suppressHydrationWarning: true,
|
|
60
|
-
nonce,
|
|
61
|
-
dangerouslySetInnerHTML: { __html: `(${script.toString()})(${scriptArgs})` }
|
|
62
|
-
});
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
//#endregion
|
|
66
|
-
export { ClientOnly as n, ThemeScript as t };
|
|
File without changes
|
|
File without changes
|