@abhir9/pd-design-system 0.1.15 → 0.1.16
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 +53 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +36 -12
- package/dist/index.d.cts +7 -2
- package/dist/index.d.ts +7 -2
- package/dist/index.js +54 -14
- package/dist/index.js.map +1 -1
- package/dist/styles.css +32 -11
- package/package.json +1 -1
package/dist/index.css
CHANGED
|
@@ -691,6 +691,23 @@ video {
|
|
|
691
691
|
--z-sticky: 1020;
|
|
692
692
|
--z-tooltip: 1070;
|
|
693
693
|
|
|
694
|
+
/* Reset CSS Variables - can be overridden by consumers */
|
|
695
|
+
--pd-reset-html-font-size: 10px;
|
|
696
|
+
--pd-reset-html-height: 100vh;
|
|
697
|
+
--pd-reset-html-width: 100vw;
|
|
698
|
+
--pd-reset-html-min-height: 100vh;
|
|
699
|
+
--pd-reset-html-min-width: 100vw;
|
|
700
|
+
--pd-reset-body-margin: 0;
|
|
701
|
+
--pd-reset-body-padding: 0;
|
|
702
|
+
--pd-reset-body-height: 100vh;
|
|
703
|
+
--pd-reset-body-min-height: 100vh;
|
|
704
|
+
--pd-reset-body-width: 100vw;
|
|
705
|
+
--pd-reset-body-min-width: 100vw;
|
|
706
|
+
--pd-reset-box-sizing: border-box;
|
|
707
|
+
--pd-reset-border-width: 0;
|
|
708
|
+
--pd-reset-focus-outline: 0;
|
|
709
|
+
--pd-reset-focus-box-shadow: 0 0 0 0 rgba(0, 0, 0, 0);
|
|
710
|
+
|
|
694
711
|
font-family: var(--font-sans, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif);
|
|
695
712
|
color: var(--text-body);
|
|
696
713
|
background-color: var(--surface-base);
|
|
@@ -909,28 +926,34 @@ video {
|
|
|
909
926
|
color: var(--content-primary);
|
|
910
927
|
}
|
|
911
928
|
html {
|
|
912
|
-
font-size: 10px;
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
min-
|
|
917
|
-
width: 100vw;
|
|
918
|
-
min-width: 100vw;
|
|
929
|
+
font-size: var(--pd-reset-html-font-size, 10px);
|
|
930
|
+
height: var(--pd-reset-html-height, 100vh);
|
|
931
|
+
min-height: var(--pd-reset-html-min-height, 100vh);
|
|
932
|
+
width: var(--pd-reset-html-width, 100vw);
|
|
933
|
+
min-width: var(--pd-reset-html-min-width, 100vw);
|
|
919
934
|
margin: 0;
|
|
920
935
|
padding: 0;
|
|
921
936
|
}
|
|
937
|
+
html, body {
|
|
938
|
+
height: var(--pd-reset-html-height, 100vh);
|
|
939
|
+
min-height: var(--pd-reset-html-min-height, 100vh);
|
|
940
|
+
width: var(--pd-reset-html-width, 100vw);
|
|
941
|
+
min-width: var(--pd-reset-html-min-width, 100vw);
|
|
942
|
+
margin: var(--pd-reset-body-margin, 0);
|
|
943
|
+
padding: var(--pd-reset-body-padding, 0);
|
|
944
|
+
}
|
|
922
945
|
body {
|
|
923
946
|
font-family: var(--font-sans);
|
|
924
947
|
-webkit-font-smoothing: antialiased;
|
|
925
948
|
-moz-osx-font-smoothing: grayscale;
|
|
926
949
|
}
|
|
927
950
|
*, ::before, ::after {
|
|
928
|
-
box-sizing: border-box;
|
|
929
|
-
border-width: 0;
|
|
951
|
+
box-sizing: var(--pd-reset-box-sizing, border-box);
|
|
952
|
+
border-width: var(--pd-reset-border-width, 0);
|
|
930
953
|
}
|
|
931
954
|
:focus {
|
|
932
|
-
outline: 0
|
|
933
|
-
box-shadow: 0 0 0 0 rgba(0, 0, 0, 0)
|
|
955
|
+
outline: var(--pd-reset-focus-outline, 0);
|
|
956
|
+
box-shadow: var(--pd-reset-focus-box-shadow, 0 0 0 0 rgba(0, 0, 0, 0));
|
|
934
957
|
}
|
|
935
958
|
/* Autofill behavior */
|
|
936
959
|
input:-webkit-autofill,
|
|
@@ -1505,7 +1528,8 @@ button { font-family: inherit; font-size: inherit; }
|
|
|
1505
1528
|
.transition-colors { transition: color 0.15s ease-in-out, background-color 0.15s ease-in-out, border-color 0.15s ease-in-out; }
|
|
1506
1529
|
/* Opacity helpers */
|
|
1507
1530
|
|
|
1508
|
-
/* Non-color global defaults
|
|
1531
|
+
/* Non-color global defaults - now using CSS variables for easy override */
|
|
1532
|
+
|
|
1509
1533
|
|
|
1510
1534
|
/* Utilities */
|
|
1511
1535
|
|
package/dist/index.d.cts
CHANGED
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
3
|
import * as LucideIcons from 'lucide-react';
|
|
4
4
|
|
|
5
|
-
declare const THEME_MODES: readonly ["light", "dark"];
|
|
5
|
+
declare const THEME_MODES: readonly ["light", "dark", "system"];
|
|
6
6
|
declare const THEME_NAMES: readonly ["base", "brand"];
|
|
7
7
|
declare const ADAPTER_TYPES: readonly ["shadcn", "material"];
|
|
8
8
|
type ThemeMode = typeof THEME_MODES[number];
|
|
@@ -393,6 +393,11 @@ interface ButtonGroupProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'c
|
|
|
393
393
|
}
|
|
394
394
|
declare const ButtonGroup: React.ForwardRefExoticComponent<ButtonGroupProps & React.RefAttributes<HTMLDivElement>>;
|
|
395
395
|
|
|
396
|
+
/**
|
|
397
|
+
* Resolves 'system' mode to either 'light' or 'dark' based on OS preference
|
|
398
|
+
* Falls back to 'light' if matchMedia is not available (SSR)
|
|
399
|
+
*/
|
|
400
|
+
declare function resolveThemeMode(mode: ThemeMode): 'light' | 'dark';
|
|
396
401
|
declare function createTheme(name: ThemeName, mode: ThemeMode): Theme;
|
|
397
402
|
|
|
398
403
|
declare function setDesignSystemConfig(config: Partial<DesignSystemConfig>): void;
|
|
@@ -1477,4 +1482,4 @@ declare function validateAccessibilityProps(props: AccessibilityProps, component
|
|
|
1477
1482
|
iconOnly?: boolean;
|
|
1478
1483
|
}): void;
|
|
1479
1484
|
|
|
1480
|
-
export { ADAPTER_TYPES, type AccessibilityProps, type AdapterType, BUTTON_TYPES, type BackgroundToken, type BorderToken, Button, ButtonGroup, type ButtonGroupProps, type ButtonProps, type ButtonType, COLOR_SCALES, type ColorName, type ColorPrimitives, type ColorScale, type Colors, type ContentToken, DEFAULT_ADAPTER, DEFAULT_MODE, DEFAULT_THEME, type DesignSystemConfig, INPUT_TYPES, INTENTS, type InputType, type Intent, type LucideIconName, ORIENTATIONS, type Orientation, type Radius, SIZES, SURFACE_LEVELS, type SemanticToken, type SemanticTokens, type Shadows, type Size, type Spacing, type SurfaceLevel, THEME_MODES, THEME_NAMES, type Theme, type ThemeMode, type ThemeName, ThemeProvider, type ThemeProviderProps, type Tokens, type Typography, VARIANTS, type Variant, type ZIndex, backgroundTokens, blue, borderTokens, colorPrimitives, colors, contentTokens, createSemanticTokens, createTheme, getAdapter, getAvailableIconNames, getDesignSystemConfig, getIcon, getThemeMode, getThemeName, green, iconExists, neutral, orange, radius, red, renderIcon, semanticTokens, setDesignSystemConfig, shadows, spacing, tokens, typography, useTheme, validateAccessibilityProps, yellow, zIndex };
|
|
1485
|
+
export { ADAPTER_TYPES, type AccessibilityProps, type AdapterType, BUTTON_TYPES, type BackgroundToken, type BorderToken, Button, ButtonGroup, type ButtonGroupProps, type ButtonProps, type ButtonType, COLOR_SCALES, type ColorName, type ColorPrimitives, type ColorScale, type Colors, type ContentToken, DEFAULT_ADAPTER, DEFAULT_MODE, DEFAULT_THEME, type DesignSystemConfig, INPUT_TYPES, INTENTS, type InputType, type Intent, type LucideIconName, ORIENTATIONS, type Orientation, type Radius, SIZES, SURFACE_LEVELS, type SemanticToken, type SemanticTokens, type Shadows, type Size, type Spacing, type SurfaceLevel, THEME_MODES, THEME_NAMES, type Theme, type ThemeMode, type ThemeName, ThemeProvider, type ThemeProviderProps, type Tokens, type Typography, VARIANTS, type Variant, type ZIndex, backgroundTokens, blue, borderTokens, colorPrimitives, colors, contentTokens, createSemanticTokens, createTheme, getAdapter, getAvailableIconNames, getDesignSystemConfig, getIcon, getThemeMode, getThemeName, green, iconExists, neutral, orange, radius, red, renderIcon, resolveThemeMode, semanticTokens, setDesignSystemConfig, shadows, spacing, tokens, typography, useTheme, validateAccessibilityProps, yellow, zIndex };
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
3
|
import * as LucideIcons from 'lucide-react';
|
|
4
4
|
|
|
5
|
-
declare const THEME_MODES: readonly ["light", "dark"];
|
|
5
|
+
declare const THEME_MODES: readonly ["light", "dark", "system"];
|
|
6
6
|
declare const THEME_NAMES: readonly ["base", "brand"];
|
|
7
7
|
declare const ADAPTER_TYPES: readonly ["shadcn", "material"];
|
|
8
8
|
type ThemeMode = typeof THEME_MODES[number];
|
|
@@ -393,6 +393,11 @@ interface ButtonGroupProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'c
|
|
|
393
393
|
}
|
|
394
394
|
declare const ButtonGroup: React.ForwardRefExoticComponent<ButtonGroupProps & React.RefAttributes<HTMLDivElement>>;
|
|
395
395
|
|
|
396
|
+
/**
|
|
397
|
+
* Resolves 'system' mode to either 'light' or 'dark' based on OS preference
|
|
398
|
+
* Falls back to 'light' if matchMedia is not available (SSR)
|
|
399
|
+
*/
|
|
400
|
+
declare function resolveThemeMode(mode: ThemeMode): 'light' | 'dark';
|
|
396
401
|
declare function createTheme(name: ThemeName, mode: ThemeMode): Theme;
|
|
397
402
|
|
|
398
403
|
declare function setDesignSystemConfig(config: Partial<DesignSystemConfig>): void;
|
|
@@ -1477,4 +1482,4 @@ declare function validateAccessibilityProps(props: AccessibilityProps, component
|
|
|
1477
1482
|
iconOnly?: boolean;
|
|
1478
1483
|
}): void;
|
|
1479
1484
|
|
|
1480
|
-
export { ADAPTER_TYPES, type AccessibilityProps, type AdapterType, BUTTON_TYPES, type BackgroundToken, type BorderToken, Button, ButtonGroup, type ButtonGroupProps, type ButtonProps, type ButtonType, COLOR_SCALES, type ColorName, type ColorPrimitives, type ColorScale, type Colors, type ContentToken, DEFAULT_ADAPTER, DEFAULT_MODE, DEFAULT_THEME, type DesignSystemConfig, INPUT_TYPES, INTENTS, type InputType, type Intent, type LucideIconName, ORIENTATIONS, type Orientation, type Radius, SIZES, SURFACE_LEVELS, type SemanticToken, type SemanticTokens, type Shadows, type Size, type Spacing, type SurfaceLevel, THEME_MODES, THEME_NAMES, type Theme, type ThemeMode, type ThemeName, ThemeProvider, type ThemeProviderProps, type Tokens, type Typography, VARIANTS, type Variant, type ZIndex, backgroundTokens, blue, borderTokens, colorPrimitives, colors, contentTokens, createSemanticTokens, createTheme, getAdapter, getAvailableIconNames, getDesignSystemConfig, getIcon, getThemeMode, getThemeName, green, iconExists, neutral, orange, radius, red, renderIcon, semanticTokens, setDesignSystemConfig, shadows, spacing, tokens, typography, useTheme, validateAccessibilityProps, yellow, zIndex };
|
|
1485
|
+
export { ADAPTER_TYPES, type AccessibilityProps, type AdapterType, BUTTON_TYPES, type BackgroundToken, type BorderToken, Button, ButtonGroup, type ButtonGroupProps, type ButtonProps, type ButtonType, COLOR_SCALES, type ColorName, type ColorPrimitives, type ColorScale, type Colors, type ContentToken, DEFAULT_ADAPTER, DEFAULT_MODE, DEFAULT_THEME, type DesignSystemConfig, INPUT_TYPES, INTENTS, type InputType, type Intent, type LucideIconName, ORIENTATIONS, type Orientation, type Radius, SIZES, SURFACE_LEVELS, type SemanticToken, type SemanticTokens, type Shadows, type Size, type Spacing, type SurfaceLevel, THEME_MODES, THEME_NAMES, type Theme, type ThemeMode, type ThemeName, ThemeProvider, type ThemeProviderProps, type Tokens, type Typography, VARIANTS, type Variant, type ZIndex, backgroundTokens, blue, borderTokens, colorPrimitives, colors, contentTokens, createSemanticTokens, createTheme, getAdapter, getAvailableIconNames, getDesignSystemConfig, getIcon, getThemeMode, getThemeName, green, iconExists, neutral, orange, radius, red, renderIcon, resolveThemeMode, semanticTokens, setDesignSystemConfig, shadows, spacing, tokens, typography, useTheme, validateAccessibilityProps, yellow, zIndex };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { forwardRef, useMemo, createContext, useEffect, useContext } from 'react';
|
|
1
|
+
import React, { forwardRef, useMemo, createContext, useState, useEffect, useContext } from 'react';
|
|
2
2
|
import { cva } from 'class-variance-authority';
|
|
3
3
|
import * as LucideIcons from 'lucide-react';
|
|
4
4
|
import { Loader2 } from 'lucide-react';
|
|
@@ -7,10 +7,10 @@ import { twMerge } from 'tailwind-merge';
|
|
|
7
7
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
8
8
|
|
|
9
9
|
// src/theme/types.ts
|
|
10
|
-
var THEME_MODES = ["light", "dark"];
|
|
10
|
+
var THEME_MODES = ["light", "dark", "system"];
|
|
11
11
|
var THEME_NAMES = ["base", "brand"];
|
|
12
12
|
var ADAPTER_TYPES = ["shadcn", "material"];
|
|
13
|
-
var DEFAULT_MODE = "
|
|
13
|
+
var DEFAULT_MODE = "system";
|
|
14
14
|
var [DEFAULT_THEME] = THEME_NAMES;
|
|
15
15
|
var [DEFAULT_ADAPTER] = ADAPTER_TYPES;
|
|
16
16
|
|
|
@@ -272,11 +272,6 @@ var ShadcnButton = forwardRef(
|
|
|
272
272
|
children,
|
|
273
273
|
...props
|
|
274
274
|
}, ref) => {
|
|
275
|
-
if (process.env.NODE_ENV !== "production" && !children && (startIcon || endIcon) && !props["aria-label"]) {
|
|
276
|
-
console.warn(
|
|
277
|
-
"[pd-design] Icon-only buttons should have an aria-label for accessibility. Add aria-label prop to describe the button action."
|
|
278
|
-
);
|
|
279
|
-
}
|
|
280
275
|
const buttonClasses = cn(
|
|
281
276
|
buttonVariants({ variant, intent, size }),
|
|
282
277
|
fullWidth && "w-full"
|
|
@@ -999,9 +994,19 @@ function createSemanticTokens(mode) {
|
|
|
999
994
|
}
|
|
1000
995
|
|
|
1001
996
|
// src/theme/theme.ts
|
|
997
|
+
function resolveThemeMode(mode) {
|
|
998
|
+
if (mode !== "system") {
|
|
999
|
+
return mode;
|
|
1000
|
+
}
|
|
1001
|
+
if (typeof window !== "undefined" && window.matchMedia) {
|
|
1002
|
+
return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
1003
|
+
}
|
|
1004
|
+
return "light";
|
|
1005
|
+
}
|
|
1002
1006
|
function createTheme(name, mode) {
|
|
1003
|
-
const
|
|
1004
|
-
const
|
|
1007
|
+
const resolvedMode = resolveThemeMode(mode);
|
|
1008
|
+
const semantic = createSemanticTokens(resolvedMode);
|
|
1009
|
+
const isLight = resolvedMode === "light";
|
|
1005
1010
|
const border = isLight ? borderTokens.light : borderTokens.dark;
|
|
1006
1011
|
const content = isLight ? contentTokens.light : contentTokens.dark;
|
|
1007
1012
|
const background = isLight ? backgroundTokens.light : backgroundTokens.dark;
|
|
@@ -1169,7 +1174,8 @@ function createTheme(name, mode) {
|
|
|
1169
1174
|
};
|
|
1170
1175
|
return {
|
|
1171
1176
|
name,
|
|
1172
|
-
mode,
|
|
1177
|
+
mode: resolvedMode,
|
|
1178
|
+
// Store the resolved mode (light/dark) not 'system'
|
|
1173
1179
|
cssVariables
|
|
1174
1180
|
};
|
|
1175
1181
|
}
|
|
@@ -1180,12 +1186,46 @@ function ThemeProvider({
|
|
|
1180
1186
|
theme: themeName = DEFAULT_THEME,
|
|
1181
1187
|
mode = DEFAULT_MODE
|
|
1182
1188
|
}) {
|
|
1183
|
-
const
|
|
1189
|
+
const [resolvedMode, setResolvedMode] = useState(
|
|
1190
|
+
() => resolveThemeMode(mode)
|
|
1191
|
+
);
|
|
1192
|
+
useEffect(() => {
|
|
1193
|
+
if (mode !== "system" || typeof window === "undefined" || !window.matchMedia) {
|
|
1194
|
+
return;
|
|
1195
|
+
}
|
|
1196
|
+
const mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
|
|
1197
|
+
const handleChange = (e) => {
|
|
1198
|
+
setResolvedMode(e.matches ? "dark" : "light");
|
|
1199
|
+
};
|
|
1200
|
+
handleChange(mediaQuery);
|
|
1201
|
+
if (mediaQuery.addEventListener) {
|
|
1202
|
+
mediaQuery.addEventListener("change", handleChange);
|
|
1203
|
+
return () => mediaQuery.removeEventListener("change", handleChange);
|
|
1204
|
+
} else {
|
|
1205
|
+
mediaQuery.addListener(handleChange);
|
|
1206
|
+
return () => mediaQuery.removeListener(handleChange);
|
|
1207
|
+
}
|
|
1208
|
+
}, [mode]);
|
|
1209
|
+
useEffect(() => {
|
|
1210
|
+
if (mode !== "system") {
|
|
1211
|
+
setResolvedMode(mode === "dark" ? "dark" : "light");
|
|
1212
|
+
}
|
|
1213
|
+
}, [mode]);
|
|
1214
|
+
const theme = useMemo(() => {
|
|
1215
|
+
const effectiveMode = mode === "system" ? resolvedMode : mode;
|
|
1216
|
+
return createTheme(themeName, effectiveMode);
|
|
1217
|
+
}, [themeName, mode, resolvedMode]);
|
|
1184
1218
|
useEffect(() => {
|
|
1185
1219
|
setDesignSystemConfig({ adapter, theme: themeName, mode });
|
|
1186
1220
|
}, [adapter, themeName, mode]);
|
|
1187
1221
|
useEffect(() => {
|
|
1188
1222
|
const root = document.documentElement;
|
|
1223
|
+
const effectiveMode = mode === "system" ? resolvedMode : mode;
|
|
1224
|
+
if (effectiveMode === "dark") {
|
|
1225
|
+
root.classList.add("dark");
|
|
1226
|
+
} else {
|
|
1227
|
+
root.classList.remove("dark");
|
|
1228
|
+
}
|
|
1189
1229
|
Object.entries(theme.cssVariables).forEach(([key, value]) => {
|
|
1190
1230
|
root.style.setProperty(key, value);
|
|
1191
1231
|
});
|
|
@@ -1194,7 +1234,7 @@ function ThemeProvider({
|
|
|
1194
1234
|
root.style.removeProperty(key);
|
|
1195
1235
|
});
|
|
1196
1236
|
};
|
|
1197
|
-
}, [theme]);
|
|
1237
|
+
}, [theme, mode, resolvedMode]);
|
|
1198
1238
|
const contextValue = useMemo(() => ({
|
|
1199
1239
|
config: getDesignSystemConfig(),
|
|
1200
1240
|
setConfig: setDesignSystemConfig
|
|
@@ -1282,6 +1322,6 @@ function validateAccessibilityProps(props, componentType, options = {}) {
|
|
|
1282
1322
|
warnings.forEach((warning) => console.warn(warning));
|
|
1283
1323
|
}
|
|
1284
1324
|
|
|
1285
|
-
export { ADAPTER_TYPES, BUTTON_TYPES, Button, ButtonGroup, COLOR_SCALES, DEFAULT_ADAPTER, DEFAULT_MODE, DEFAULT_THEME, INPUT_TYPES, INTENTS, ORIENTATIONS, SIZES, SURFACE_LEVELS, THEME_MODES, THEME_NAMES, ThemeProvider, VARIANTS, backgroundTokens, blue, borderTokens, colorPrimitives, colors, contentTokens, createSemanticTokens, createTheme, getAdapter, getAvailableIconNames, getDesignSystemConfig, getIcon, getThemeMode, getThemeName, green, iconExists, neutral, orange, radius, red, renderIcon, semanticTokens, setDesignSystemConfig, shadows, spacing, tokens, typography, useTheme, validateAccessibilityProps, yellow, zIndex };
|
|
1325
|
+
export { ADAPTER_TYPES, BUTTON_TYPES, Button, ButtonGroup, COLOR_SCALES, DEFAULT_ADAPTER, DEFAULT_MODE, DEFAULT_THEME, INPUT_TYPES, INTENTS, ORIENTATIONS, SIZES, SURFACE_LEVELS, THEME_MODES, THEME_NAMES, ThemeProvider, VARIANTS, backgroundTokens, blue, borderTokens, colorPrimitives, colors, contentTokens, createSemanticTokens, createTheme, getAdapter, getAvailableIconNames, getDesignSystemConfig, getIcon, getThemeMode, getThemeName, green, iconExists, neutral, orange, radius, red, renderIcon, resolveThemeMode, semanticTokens, setDesignSystemConfig, shadows, spacing, tokens, typography, useTheme, validateAccessibilityProps, yellow, zIndex };
|
|
1286
1326
|
//# sourceMappingURL=index.js.map
|
|
1287
1327
|
//# sourceMappingURL=index.js.map
|