@gaulatti/bleecker 0.1.42 → 0.1.44
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 +98 -1
- package/dist/components/alert.js +0 -7
- package/dist/components/breadcrumb.js +1 -1
- package/dist/components/button.js +2 -2
- package/dist/components/chart-theme.d.ts +1 -1
- package/dist/components/command-spotlight.d.ts +2 -1
- package/dist/components/command-spotlight.js +11 -23
- package/dist/components/context-menu.d.ts +1 -1
- package/dist/components/context-menu.js +1 -1
- package/dist/components/dashboard-grid.d.ts +1 -1
- package/dist/components/dashboard-section.d.ts +1 -1
- package/dist/components/data-list.d.ts +1 -1
- package/dist/components/data-table-filters.d.ts +1 -1
- package/dist/components/data-table-toolbar.d.ts +1 -1
- package/dist/components/data-table.js +1 -1
- package/dist/components/dropdown-menu.d.ts +1 -1
- package/dist/components/dropdown-menu.js +1 -1
- package/dist/components/error-state.d.ts +1 -1
- package/dist/components/eyebrow.d.ts +1 -1
- package/dist/components/feed-item.js +4 -11
- package/dist/components/icon-badge.d.ts +1 -1
- package/dist/components/icon-button.js +1 -1
- package/dist/components/input.js +1 -1
- package/dist/components/label.d.ts +1 -1
- package/dist/components/label.js +1 -1
- package/dist/components/loading-overlay.d.ts +1 -1
- package/dist/components/media-library.js +2 -4
- package/dist/components/metric.d.ts +1 -1
- package/dist/components/metric.js +1 -1
- package/dist/components/page-header.d.ts +1 -1
- package/dist/components/progress.js +2 -1
- package/dist/components/sankey-chart.js +1 -1
- package/dist/components/search-input.d.ts +1 -1
- package/dist/components/search-input.js +1 -1
- package/dist/components/select.js +1 -1
- package/dist/components/sidebar.d.ts +1 -1
- package/dist/components/sidebar.js +1 -1
- package/dist/components/skeleton.d.ts +1 -1
- package/dist/components/stat-card.d.ts +1 -1
- package/dist/components/sunburst-chart.js +1 -1
- package/dist/components/table.js +3 -16
- package/dist/components/textarea.js +1 -1
- package/dist/components/timeline.d.ts +1 -1
- package/dist/layout/admin-shell.d.ts +1 -1
- package/dist/layout/auth-shell.d.ts +8 -1
- package/dist/layout/auth-shell.js +8 -1
- package/dist/layout/panel-layout.js +0 -4
- package/dist/styles.css +1 -1
- package/dist/theme/theme-provider.d.ts +2 -2
- package/dist/theme/theme-provider.js +16 -20
- package/dist/theme/types.d.ts +11 -0
- package/dist/utils/attention-color.js +4 -4
- package/dist/utils/avatar-initial.d.ts +1 -0
- package/dist/utils/avatar-initial.js +3 -0
- package/dist/utils/clamp-percent.d.ts +1 -0
- package/dist/utils/clamp-percent.js +3 -0
- package/dist/utils/format.js +17 -14
- package/dist/utils/hooks.d.ts +1 -1
- package/dist/utils/hooks.js +4 -8
- package/dist/utils/source-label.d.ts +1 -0
- package/dist/utils/source-label.js +9 -0
- package/package.json +8 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ThemeMode,
|
|
1
|
+
import type { ThemeMode, ThemeProviderOptions } from './types';
|
|
2
2
|
interface ThemeContextValue {
|
|
3
3
|
theme: ThemeMode;
|
|
4
4
|
resolvedTheme: 'light' | 'dark';
|
|
@@ -6,6 +6,6 @@ interface ThemeContextValue {
|
|
|
6
6
|
cycleTheme: () => void;
|
|
7
7
|
storageKey: string;
|
|
8
8
|
}
|
|
9
|
-
export declare function ThemeProvider(
|
|
9
|
+
export declare function ThemeProvider(props: ThemeProviderOptions): import("react/jsx-runtime").JSX.Element;
|
|
10
10
|
export declare function useTheme(): ThemeContextValue;
|
|
11
11
|
export {};
|
|
@@ -13,38 +13,32 @@ function nextTheme(theme) {
|
|
|
13
13
|
return 'light';
|
|
14
14
|
}
|
|
15
15
|
function getSystemPreference() {
|
|
16
|
-
if (typeof window === 'undefined') {
|
|
17
|
-
return false;
|
|
18
|
-
}
|
|
19
16
|
return window.matchMedia('(prefers-color-scheme: dark)').matches;
|
|
20
17
|
}
|
|
21
18
|
function readStoredTheme(storageKey, fallback) {
|
|
22
|
-
if (typeof window === 'undefined') {
|
|
23
|
-
return fallback;
|
|
24
|
-
}
|
|
25
19
|
const saved = window.localStorage.getItem(storageKey);
|
|
26
20
|
return saved === 'light' || saved === 'dark' || saved === 'system' ? saved : fallback;
|
|
27
21
|
}
|
|
28
22
|
function applyDocumentTheme(theme) {
|
|
29
|
-
if (typeof document === 'undefined') {
|
|
30
|
-
return resolveTheme(theme, false);
|
|
31
|
-
}
|
|
32
23
|
const resolved = resolveTheme(theme, getSystemPreference());
|
|
33
24
|
document.documentElement.classList.toggle('dark', resolved === 'dark');
|
|
34
25
|
return resolved;
|
|
35
26
|
}
|
|
36
|
-
export function ThemeProvider(
|
|
37
|
-
const
|
|
38
|
-
const
|
|
27
|
+
export function ThemeProvider(props) {
|
|
28
|
+
const { children, defaultTheme = 'system', storageKey = 'theme' } = props;
|
|
29
|
+
const isControlled = props.theme !== undefined;
|
|
30
|
+
const [storedTheme, setThemeState] = React.useState(defaultTheme);
|
|
31
|
+
const theme = props.theme ?? storedTheme;
|
|
32
|
+
const [resolvedTheme, setResolvedTheme] = React.useState(() => resolveTheme(theme, false));
|
|
39
33
|
React.useEffect(() => {
|
|
34
|
+
if (isControlled) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
40
37
|
const initialTheme = readStoredTheme(storageKey, defaultTheme);
|
|
41
38
|
setThemeState(initialTheme);
|
|
42
39
|
setResolvedTheme(applyDocumentTheme(initialTheme));
|
|
43
|
-
}, [defaultTheme, storageKey]);
|
|
40
|
+
}, [isControlled, defaultTheme, storageKey]);
|
|
44
41
|
React.useEffect(() => {
|
|
45
|
-
if (typeof window === 'undefined') {
|
|
46
|
-
return undefined;
|
|
47
|
-
}
|
|
48
42
|
const mediaQuery = window.matchMedia('(prefers-color-scheme: dark)');
|
|
49
43
|
const sync = () => setResolvedTheme(applyDocumentTheme(theme));
|
|
50
44
|
sync();
|
|
@@ -52,12 +46,14 @@ export function ThemeProvider({ children, defaultTheme = 'system', storageKey =
|
|
|
52
46
|
return () => mediaQuery.removeEventListener('change', sync);
|
|
53
47
|
}, [theme]);
|
|
54
48
|
const setTheme = React.useCallback((value) => {
|
|
49
|
+
if (props.theme !== undefined) {
|
|
50
|
+
props.onThemeChange(value);
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
55
53
|
setThemeState(value);
|
|
56
54
|
setResolvedTheme(applyDocumentTheme(value));
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
}, [storageKey]);
|
|
55
|
+
window.localStorage.setItem(storageKey, value);
|
|
56
|
+
}, [props.theme, props.onThemeChange, storageKey]);
|
|
61
57
|
const cycleTheme = React.useCallback(() => {
|
|
62
58
|
setTheme(nextTheme(theme));
|
|
63
59
|
}, [setTheme, theme]);
|
package/dist/theme/types.d.ts
CHANGED
|
@@ -6,3 +6,14 @@ export interface ThemeProviderProps {
|
|
|
6
6
|
defaultTheme?: ThemeMode;
|
|
7
7
|
storageKey?: string;
|
|
8
8
|
}
|
|
9
|
+
export interface ControlledThemeProviderProps {
|
|
10
|
+
children: ReactNode;
|
|
11
|
+
theme: ThemeMode;
|
|
12
|
+
onThemeChange: (theme: ThemeMode) => void;
|
|
13
|
+
defaultTheme?: never;
|
|
14
|
+
storageKey?: never;
|
|
15
|
+
}
|
|
16
|
+
export type ThemeProviderOptions = (ThemeProviderProps & {
|
|
17
|
+
theme?: never;
|
|
18
|
+
onThemeChange?: never;
|
|
19
|
+
}) | ControlledThemeProviderProps;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
function
|
|
1
|
+
function clampNumber(value, min, max) {
|
|
2
2
|
return Math.min(max, Math.max(min, value));
|
|
3
3
|
}
|
|
4
4
|
/**
|
|
@@ -8,12 +8,12 @@ function clamp(value, min, max) {
|
|
|
8
8
|
*/
|
|
9
9
|
export function createAttentionColor({ hue, intensity: rawIntensity }) {
|
|
10
10
|
const normalizedHue = ((Math.round(Number.isFinite(hue) ? hue : 210) % 360) + 360) % 360;
|
|
11
|
-
const intensity =
|
|
11
|
+
const intensity = clampNumber(Number.isFinite(rawIntensity) ? rawIntensity : 0, 0, 10);
|
|
12
12
|
const redMix = Math.round(intensity * 10);
|
|
13
|
-
const
|
|
13
|
+
const categoryShare = 100 - redMix;
|
|
14
14
|
const coverage = 24 + intensity * 7.2;
|
|
15
15
|
const colorStrength = Math.round(10 + intensity * 6.2);
|
|
16
|
-
const accent = `color-mix(in oklab, hsl(${normalizedHue} 66% 52%) ${
|
|
16
|
+
const accent = `color-mix(in oklab, hsl(${normalizedHue} 66% 52%) ${categoryShare}%, hsl(6 78% 56%) ${redMix}%)`;
|
|
17
17
|
return {
|
|
18
18
|
accent,
|
|
19
19
|
coverage,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function avatarInitial(author: string, init?: string): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function clampPercent(value: number, max: number): number;
|
package/dist/utils/format.js
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
export function formatNumber(value, options = {}) {
|
|
5
5
|
if (value === undefined || value === null || Number.isNaN(value))
|
|
6
6
|
return '';
|
|
7
|
-
const { locale, ...
|
|
8
|
-
return new Intl.NumberFormat(locale,
|
|
7
|
+
const { locale, ...numberOptions } = options;
|
|
8
|
+
return new Intl.NumberFormat(locale, numberOptions).format(value);
|
|
9
9
|
}
|
|
10
10
|
export function formatCurrency(value, currency = 'USD', options = {}) {
|
|
11
11
|
if (value === undefined || value === null || Number.isNaN(value))
|
|
@@ -22,10 +22,13 @@ export function formatPercent(value, options = {}) {
|
|
|
22
22
|
return '';
|
|
23
23
|
return new Intl.NumberFormat(options.locale, { style: 'percent', minimumFractionDigits: 1, maximumFractionDigits: 1, ...options }).format(value);
|
|
24
24
|
}
|
|
25
|
+
function toDate(value) {
|
|
26
|
+
return typeof value === 'string' || typeof value === 'number' ? new Date(value) : value;
|
|
27
|
+
}
|
|
25
28
|
export function formatDate(value, options = {}) {
|
|
26
29
|
if (value === undefined || value === null)
|
|
27
30
|
return '';
|
|
28
|
-
const date =
|
|
31
|
+
const date = toDate(value);
|
|
29
32
|
if (Number.isNaN(date.getTime()))
|
|
30
33
|
return '';
|
|
31
34
|
const { locale, dateStyle = 'medium', ...intlOptions } = options;
|
|
@@ -34,30 +37,30 @@ export function formatDate(value, options = {}) {
|
|
|
34
37
|
export function formatDateTime(value, options = {}) {
|
|
35
38
|
if (value === undefined || value === null)
|
|
36
39
|
return '';
|
|
37
|
-
const date =
|
|
40
|
+
const date = toDate(value);
|
|
38
41
|
if (Number.isNaN(date.getTime()))
|
|
39
42
|
return '';
|
|
40
|
-
const { locale, ...
|
|
41
|
-
return new Intl.DateTimeFormat(locale, { dateStyle: 'short', timeStyle: 'short', ...
|
|
43
|
+
const { locale, ...dateTimeOptions } = options;
|
|
44
|
+
return new Intl.DateTimeFormat(locale, { dateStyle: 'short', timeStyle: 'short', ...dateTimeOptions }).format(date);
|
|
42
45
|
}
|
|
43
46
|
export function formatRelativeTime(value, locale = 'en-US') {
|
|
44
47
|
if (value === undefined || value === null)
|
|
45
48
|
return '';
|
|
46
|
-
const date =
|
|
49
|
+
const date = toDate(value);
|
|
47
50
|
if (Number.isNaN(date.getTime()))
|
|
48
51
|
return '';
|
|
49
52
|
const now = Date.now();
|
|
50
|
-
const
|
|
51
|
-
const seconds = Math.round(
|
|
53
|
+
const delta = date.getTime() - now;
|
|
54
|
+
const seconds = Math.round(delta / 1000);
|
|
52
55
|
const minutes = Math.round(seconds / 60);
|
|
53
56
|
const hours = Math.round(minutes / 60);
|
|
54
57
|
const days = Math.round(hours / 24);
|
|
55
|
-
const
|
|
58
|
+
const relativeFormatter = new Intl.RelativeTimeFormat(locale, { numeric: 'auto' });
|
|
56
59
|
if (Math.abs(seconds) < 60)
|
|
57
|
-
return
|
|
60
|
+
return relativeFormatter.format(seconds, 'second');
|
|
58
61
|
if (Math.abs(minutes) < 60)
|
|
59
|
-
return
|
|
62
|
+
return relativeFormatter.format(minutes, 'minute');
|
|
60
63
|
if (Math.abs(hours) < 24)
|
|
61
|
-
return
|
|
62
|
-
return
|
|
64
|
+
return relativeFormatter.format(hours, 'hour');
|
|
65
|
+
return relativeFormatter.format(days, 'day');
|
|
63
66
|
}
|
package/dist/utils/hooks.d.ts
CHANGED
package/dist/utils/hooks.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import
|
|
2
|
+
import React from 'react';
|
|
3
3
|
/**
|
|
4
4
|
* Returns true once the component has mounted. Useful for avoiding SSR
|
|
5
5
|
* hydration mismatches in components that read from `window`/`document`.
|
|
@@ -15,8 +15,6 @@ export function useMounted() {
|
|
|
15
15
|
export function useMediaQuery(query) {
|
|
16
16
|
const [matches, setMatches] = React.useState(false);
|
|
17
17
|
React.useEffect(() => {
|
|
18
|
-
if (typeof window === 'undefined')
|
|
19
|
-
return undefined;
|
|
20
18
|
const media = window.matchMedia(query);
|
|
21
19
|
const update = () => setMatches(media.matches);
|
|
22
20
|
update();
|
|
@@ -70,11 +68,9 @@ export function usePresence(open, exitDuration = 150) {
|
|
|
70
68
|
React.useLayoutEffect(() => {
|
|
71
69
|
if (!open || !present)
|
|
72
70
|
return;
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
clearTimeout(enterTimerRef.current);
|
|
77
|
-
};
|
|
71
|
+
const timer = setTimeout(() => setVisible(true), 20);
|
|
72
|
+
enterTimerRef.current = timer;
|
|
73
|
+
return () => clearTimeout(timer);
|
|
78
74
|
}, [open, present]);
|
|
79
75
|
React.useEffect(() => {
|
|
80
76
|
return () => {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function describeSource(sourceUrl: string): string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gaulatti/bleecker",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.44",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -65,12 +65,16 @@
|
|
|
65
65
|
"build": "npm run clean && npm run check:exports-stories && npm run check:kolibri-toggle && npm run build:css && tsc && node scripts/fix-esm-imports.mjs && npm run check:runtime",
|
|
66
66
|
"storybook": "npm run build:css && storybook dev -p 6006",
|
|
67
67
|
"test": "vitest run",
|
|
68
|
+
"test:coverage": "vitest run --coverage.enabled --coverage.provider=v8 --coverage.reporter=json --coverage.reportsDirectory=coverage \"--coverage.include=src/**/*.{ts,tsx}\"",
|
|
68
69
|
"build-storybook": "npm run check:exports-stories && npm run check:kolibri-toggle && npm run build:css && storybook build",
|
|
69
70
|
"typecheck": "tsc --noEmit -p tsconfig.json",
|
|
70
71
|
"check:exports-stories": "node scripts/check-exports-and-stories.mjs",
|
|
71
|
-
"check": "npm run check:tokens && npm run typecheck && npm run check:exports-stories && npm run check:kolibri-toggle && npm test",
|
|
72
|
+
"check": "npm run check:tokens && npm run typecheck && npm run check:exports-stories && npm run check:kolibri-toggle && npm run test:select-reset && npm run typecheck:theme && npm run test:theme && npm test",
|
|
73
|
+
"test:select-reset": "node --test tests/select-controlled-reset.test.mjs",
|
|
72
74
|
"prepack": "npm run build",
|
|
73
|
-
"check:runtime": "node scripts/check-package-runtime.mjs"
|
|
75
|
+
"check:runtime": "node scripts/check-package-runtime.mjs",
|
|
76
|
+
"test:theme": "node --test tests/theme-provider.test.mjs",
|
|
77
|
+
"typecheck:theme": "tsc --noEmit -p tests/tsconfig.theme.json"
|
|
74
78
|
},
|
|
75
79
|
"peerDependencies": {
|
|
76
80
|
"react": "^18.2.0 || ^19.0.0",
|
|
@@ -105,6 +109,7 @@
|
|
|
105
109
|
"@types/react-dom": "^19.2.3",
|
|
106
110
|
"@vitest/browser-playwright": "^4.0.18",
|
|
107
111
|
"@vitest/coverage-v8": "^4.0.18",
|
|
112
|
+
"jsdom": "30.1.2",
|
|
108
113
|
"playwright": "^1.58.2",
|
|
109
114
|
"storybook": "^10.2.16",
|
|
110
115
|
"tailwindcss": "^4.2.1",
|