@abhir9/pd-design-system 0.1.15 → 0.1.17

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.css CHANGED
@@ -691,9 +691,22 @@ video {
691
691
  --z-sticky: 1020;
692
692
  --z-tooltip: 1070;
693
693
 
694
- font-family: var(--font-sans, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif);
695
- color: var(--text-body);
696
- background-color: var(--surface-base);
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);
697
710
  }
698
711
 
699
712
  /**
@@ -890,10 +903,7 @@ video {
890
903
  --z-tooltip: 1070;
891
904
  }
892
905
 
893
- * {
894
- box-sizing: border-box;
895
- }
896
-
906
+ /* Focus styles for accessibility - only applied to interactive elements */
897
907
  button:focus-visible,
898
908
  input:focus-visible,
899
909
  select:focus-visible,
@@ -901,47 +911,6 @@ video {
901
911
  outline: 2px solid var(--intent-primary);
902
912
  outline-offset: 2px;
903
913
  }
904
- * {
905
- border-color: var(--border-primary);
906
- }
907
- body {
908
- background-color: var(--background-primary);
909
- color: var(--content-primary);
910
- }
911
- html {
912
- font-size: 10px;
913
- }
914
- html, body {
915
- height: 100vh;
916
- min-height: 100vh;
917
- width: 100vw;
918
- min-width: 100vw;
919
- margin: 0;
920
- padding: 0;
921
- }
922
- body {
923
- font-family: var(--font-sans);
924
- -webkit-font-smoothing: antialiased;
925
- -moz-osx-font-smoothing: grayscale;
926
- }
927
- *, ::before, ::after {
928
- box-sizing: border-box;
929
- border-width: 0;
930
- }
931
- :focus {
932
- outline: 0 !important;
933
- box-shadow: 0 0 0 0 rgba(0, 0, 0, 0) !important;
934
- }
935
- /* Autofill behavior */
936
- input:-webkit-autofill,
937
- input:-webkit-autofill:hover,
938
- input:-webkit-autofill:focus,
939
- input:-webkit-autofill:active {
940
- background-color: transparent;
941
- -webkit-transition: background-color 5000s ease-in-out 0s;
942
- transition: background-color 5000s ease-in-out 0s;
943
- -webkit-text-fill-color: var(--content-primary);
944
- }
945
914
  .container {
946
915
  width: 100%;
947
916
  }
@@ -1505,7 +1474,6 @@ button { font-family: inherit; font-size: inherit; }
1505
1474
  .transition-colors { transition: color 0.15s ease-in-out, background-color 0.15s ease-in-out, border-color 0.15s ease-in-out; }
1506
1475
  /* Opacity helpers */
1507
1476
 
1508
- /* Non-color global defaults derived from consumer app (safe subset) */
1509
1477
 
1510
1478
  /* Utilities */
1511
1479
 
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 = "light";
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 semantic = createSemanticTokens(mode);
1004
- const isLight = mode === "light";
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 theme = useMemo(() => createTheme(themeName, mode), [themeName, mode]);
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