@vinyasa/tokens 1.0.23 → 1.0.25

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.
@@ -31,13 +31,17 @@ __webpack_require__.d(__webpack_exports__, {
31
31
  VinyasaProvider: ()=>VinyasaProvider,
32
32
  breakpoints: ()=>breakpoints,
33
33
  createTheme: ()=>createTheme,
34
+ darkHighContrastTheme: ()=>darkHighContrastTheme,
34
35
  darkTheme: ()=>darkTheme,
35
36
  defaultTheme: ()=>defaultTheme,
36
37
  focusRingStyle: ()=>focusRingStyle,
37
38
  grid: ()=>grid,
39
+ highContrastTheme: ()=>highContrastTheme,
38
40
  resolveBaseTheme: ()=>resolveBaseTheme,
39
41
  resolveDensitySpacing: ()=>resolveDensitySpacing,
40
42
  themeContract: ()=>themeContract,
43
+ useAssertVinyasaProvider: ()=>useAssertVinyasaProvider,
44
+ useThemedRef: ()=>useThemedRef,
41
45
  useVinyasaTheme: ()=>useVinyasaTheme
42
46
  });
43
47
  var themeContract = {
@@ -51,6 +55,7 @@ var themeContract = {
51
55
  error: 'var(--vinyasa-error)',
52
56
  onError: 'var(--vinyasa-on-error)',
53
57
  focus: 'var(--vinyasa-focus)',
58
+ textDefault: 'var(--vinyasa-text-default)',
54
59
  textMuted: 'var(--vinyasa-text-muted)',
55
60
  statusInfoBg: 'var(--vinyasa-status-info-bg)',
56
61
  statusInfoText: 'var(--vinyasa-status-info-text)',
@@ -163,7 +168,8 @@ const duskDark = {
163
168
  };
164
169
  const moss = {
165
170
  tint: '#E4EEE8',
166
- 700: '#3F6650'
171
+ 700: '#3F6650',
172
+ 800: '#3B604B'
167
173
  };
168
174
  const mossDark = {
169
175
  tint: '#22332A',
@@ -172,16 +178,19 @@ const mossDark = {
172
178
  const ember = {
173
179
  tint: '#F7E7E1',
174
180
  600: '#A64B2A',
181
+ 700: '#8E4024',
175
182
  onEmber: '#FFFFFF'
176
183
  };
177
184
  const emberDark = {
178
185
  tint: '#3A281F',
179
186
  600: '#E08D6D',
187
+ 700: '#E3977A',
180
188
  onEmber: '#2A1208'
181
189
  };
182
190
  const saffron = {
183
191
  tint: '#F5EBDD',
184
- 700: '#A15C1F'
192
+ 700: '#A15C1F',
193
+ 800: '#834B19'
185
194
  };
186
195
  const saffronDark = {
187
196
  tint: '#3A2F1B',
@@ -378,6 +387,7 @@ const defaultTheme = _object_spread_props(_object_spread({}, structural), {
378
387
  error: ember["600"],
379
388
  onError: ember.onEmber,
380
389
  focus: dusk["600"],
390
+ textDefault: stone["900"],
381
391
  textMuted: stone["700"],
382
392
  statusInfoBg: dusk.tint,
383
393
  statusInfoText: dusk["600"],
@@ -406,6 +416,7 @@ const darkTheme = _object_spread_props(_object_spread({}, structural), {
406
416
  error: emberDark["600"],
407
417
  onError: emberDark.onEmber,
408
418
  focus: duskDark["600"],
419
+ textDefault: stoneDark["900"],
409
420
  textMuted: stoneDark["600"],
410
421
  statusInfoBg: duskDark.tint,
411
422
  statusInfoText: duskDark["600"],
@@ -423,13 +434,33 @@ const darkTheme = _object_spread_props(_object_spread({}, structural), {
423
434
  elevationOverlay: shadowDark.md,
424
435
  elevationModal: shadowDark.lg
425
436
  });
437
+ const highContrastTheme = _object_spread_props(_object_spread({}, defaultTheme), {
438
+ primary: dusk["700"],
439
+ onTertiary: dusk["700"],
440
+ focus: dusk["700"],
441
+ error: ember["700"],
442
+ statusErrorText: ember["700"],
443
+ statusWarningText: saffron["800"],
444
+ statusSuccessText: moss["800"],
445
+ borderColorDefault: stone["600"]
446
+ });
447
+ const darkHighContrastTheme = _object_spread_props(_object_spread({}, darkTheme), {
448
+ primary: duskDark["700"],
449
+ onTertiary: duskDark["700"],
450
+ focus: duskDark["700"],
451
+ error: emberDark["700"],
452
+ statusErrorText: emberDark["700"],
453
+ borderColorDefault: stoneDark["600"]
454
+ });
426
455
  const createTheme = (overrides = {})=>_object_spread({}, defaultTheme, overrides);
427
456
  const themes = {
428
457
  light: {
429
- normal: defaultTheme
458
+ normal: defaultTheme,
459
+ high: highContrastTheme
430
460
  },
431
461
  dark: {
432
- normal: darkTheme
462
+ normal: darkTheme,
463
+ high: darkHighContrastTheme
433
464
  }
434
465
  };
435
466
  const resolveBaseTheme = (colorScheme, contrast)=>{
@@ -449,8 +480,26 @@ const comfortableSpacing = {
449
480
  space5: defaultTheme.space5,
450
481
  space6: defaultTheme.space6
451
482
  };
483
+ const compactSpacing = {
484
+ space1: '0.125rem',
485
+ space2: '0.375rem',
486
+ space3: '0.5rem',
487
+ space4: '0.75rem',
488
+ space5: '1rem',
489
+ space6: '1.125rem'
490
+ };
491
+ const spaciousSpacing = {
492
+ space1: '0.375rem',
493
+ space2: '0.75rem',
494
+ space3: '0.875rem',
495
+ space4: '1.5rem',
496
+ space5: '1.875rem',
497
+ space6: '2.25rem'
498
+ };
452
499
  const density_densitySpacing = {
453
- comfortable: comfortableSpacing
500
+ compact: compactSpacing,
501
+ comfortable: comfortableSpacing,
502
+ spacious: spaciousSpacing
454
503
  };
455
504
  const resolveDensitySpacing = (density)=>{
456
505
  const spacing = density_densitySpacing[density];
@@ -470,9 +519,34 @@ const grid = {
470
519
  columns: 12,
471
520
  containerMaxWidth: '1280px'
472
521
  };
522
+ const external_react_namespaceObject = require("react");
523
+ const PROBE_CUSTOM_PROPERTY = '--vinyasa-primary';
524
+ let warned = false;
525
+ const useAssertVinyasaProvider = (ref)=>{
526
+ (0, external_react_namespaceObject.useEffect)(()=>{
527
+ if (warned || 'production' === process.env.NODE_ENV) return;
528
+ const node = ref.current;
529
+ if (!node) return;
530
+ const value = getComputedStyle(node).getPropertyValue(PROBE_CUSTOM_PROPERTY).trim();
531
+ if (!value) {
532
+ warned = true;
533
+ console.warn('[vinyasa] rendered without a mounted VinyasaProvider (or outside its DOM subtree, e.g. via a portal) — theme tokens will not resolve. Wrap your app in <VinyasaProvider> from "@vinyasa/tokens".');
534
+ }
535
+ }, [
536
+ ref
537
+ ]);
538
+ };
539
+ const mergeRefs = (...refs)=>(node)=>{
540
+ for (const ref of refs)if ('function' == typeof ref) ref(node);
541
+ else if (ref) ref.current = node;
542
+ };
543
+ const useThemedRef = (ref)=>{
544
+ const innerRef = (0, external_react_namespaceObject.useRef)(null);
545
+ useAssertVinyasaProvider(innerRef);
546
+ return mergeRefs(ref, innerRef);
547
+ };
473
548
  const jsx_runtime_namespaceObject = require("react/jsx-runtime");
474
549
  const dynamic_namespaceObject = require("@vanilla-extract/dynamic");
475
- const external_react_namespaceObject = require("react");
476
550
  var resetScope = '_1k07u5u0';
477
551
  function VinyasaProvider_define_property(obj, key, value) {
478
552
  if (key in obj) Object.defineProperty(obj, key, {
@@ -533,25 +607,33 @@ const VinyasaProvider = ({ theme, colorScheme = 'light', contrast = 'normal', de
533
607
  exports.VinyasaProvider = __webpack_exports__.VinyasaProvider;
534
608
  exports.breakpoints = __webpack_exports__.breakpoints;
535
609
  exports.createTheme = __webpack_exports__.createTheme;
610
+ exports.darkHighContrastTheme = __webpack_exports__.darkHighContrastTheme;
536
611
  exports.darkTheme = __webpack_exports__.darkTheme;
537
612
  exports.defaultTheme = __webpack_exports__.defaultTheme;
538
613
  exports.focusRingStyle = __webpack_exports__.focusRingStyle;
539
614
  exports.grid = __webpack_exports__.grid;
615
+ exports.highContrastTheme = __webpack_exports__.highContrastTheme;
540
616
  exports.resolveBaseTheme = __webpack_exports__.resolveBaseTheme;
541
617
  exports.resolveDensitySpacing = __webpack_exports__.resolveDensitySpacing;
542
618
  exports.themeContract = __webpack_exports__.themeContract;
619
+ exports.useAssertVinyasaProvider = __webpack_exports__.useAssertVinyasaProvider;
620
+ exports.useThemedRef = __webpack_exports__.useThemedRef;
543
621
  exports.useVinyasaTheme = __webpack_exports__.useVinyasaTheme;
544
622
  for(var __rspack_i in __webpack_exports__)if (-1 === [
545
623
  "VinyasaProvider",
546
624
  "breakpoints",
547
625
  "createTheme",
626
+ "darkHighContrastTheme",
548
627
  "darkTheme",
549
628
  "defaultTheme",
550
629
  "focusRingStyle",
551
630
  "grid",
631
+ "highContrastTheme",
552
632
  "resolveBaseTheme",
553
633
  "resolveDensitySpacing",
554
634
  "themeContract",
635
+ "useAssertVinyasaProvider",
636
+ "useThemedRef",
555
637
  "useVinyasaTheme"
556
638
  ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
557
639
  Object.defineProperty(exports, '__esModule', {
@@ -9,6 +9,7 @@ export declare const themeContract: {
9
9
  error: `var(--${string})`;
10
10
  onError: `var(--${string})`;
11
11
  focus: `var(--${string})`;
12
+ textDefault: `var(--${string})`;
12
13
  textMuted: `var(--${string})`;
13
14
  statusInfoBg: `var(--${string})`;
14
15
  statusInfoText: `var(--${string})`;
@@ -1,7 +1,9 @@
1
1
  export { themeContract } from './contract.css';
2
2
  export { focusRingStyle } from './focusRing';
3
- export { createTheme, darkTheme, defaultTheme, type VinyasaTheme } from './theme';
3
+ export { createTheme, darkHighContrastTheme, darkTheme, defaultTheme, highContrastTheme, type VinyasaTheme, } from './theme';
4
4
  export { resolveBaseTheme, type ColorScheme, type Contrast } from './themes';
5
5
  export { resolveDensitySpacing, type Density } from './density';
6
6
  export { breakpoints, grid } from './layout';
7
+ export { useAssertVinyasaProvider } from './useAssertVinyasaProvider';
8
+ export { useThemedRef } from './useThemedRef';
7
9
  export { VinyasaProvider, useVinyasaTheme, type VinyasaProviderProps } from './VinyasaProvider';
package/dist/esm/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import "./index.css";
2
+ import { createContext, useContext, useEffect, useMemo, useRef } from "react";
2
3
  import { jsx } from "react/jsx-runtime";
3
4
  import { assignInlineVars } from "@vanilla-extract/dynamic";
4
- import { createContext, useContext, useMemo } from "react";
5
5
  var themeContract = {
6
6
  primary: 'var(--vinyasa-primary)',
7
7
  onPrimary: 'var(--vinyasa-on-primary)',
@@ -13,6 +13,7 @@ var themeContract = {
13
13
  error: 'var(--vinyasa-error)',
14
14
  onError: 'var(--vinyasa-on-error)',
15
15
  focus: 'var(--vinyasa-focus)',
16
+ textDefault: 'var(--vinyasa-text-default)',
16
17
  textMuted: 'var(--vinyasa-text-muted)',
17
18
  statusInfoBg: 'var(--vinyasa-status-info-bg)',
18
19
  statusInfoText: 'var(--vinyasa-status-info-text)',
@@ -125,7 +126,8 @@ const duskDark = {
125
126
  };
126
127
  const moss = {
127
128
  tint: '#E4EEE8',
128
- 700: '#3F6650'
129
+ 700: '#3F6650',
130
+ 800: '#3B604B'
129
131
  };
130
132
  const mossDark = {
131
133
  tint: '#22332A',
@@ -134,16 +136,19 @@ const mossDark = {
134
136
  const ember = {
135
137
  tint: '#F7E7E1',
136
138
  600: '#A64B2A',
139
+ 700: '#8E4024',
137
140
  onEmber: '#FFFFFF'
138
141
  };
139
142
  const emberDark = {
140
143
  tint: '#3A281F',
141
144
  600: '#E08D6D',
145
+ 700: '#E3977A',
142
146
  onEmber: '#2A1208'
143
147
  };
144
148
  const saffron = {
145
149
  tint: '#F5EBDD',
146
- 700: '#A15C1F'
150
+ 700: '#A15C1F',
151
+ 800: '#834B19'
147
152
  };
148
153
  const saffronDark = {
149
154
  tint: '#3A2F1B',
@@ -299,6 +304,7 @@ const defaultTheme = {
299
304
  error: ember["600"],
300
305
  onError: ember.onEmber,
301
306
  focus: dusk["600"],
307
+ textDefault: stone["900"],
302
308
  textMuted: stone["700"],
303
309
  statusInfoBg: dusk.tint,
304
310
  statusInfoText: dusk["600"],
@@ -328,6 +334,7 @@ const darkTheme = {
328
334
  error: emberDark["600"],
329
335
  onError: emberDark.onEmber,
330
336
  focus: duskDark["600"],
337
+ textDefault: stoneDark["900"],
331
338
  textMuted: stoneDark["600"],
332
339
  statusInfoBg: duskDark.tint,
333
340
  statusInfoText: duskDark["600"],
@@ -345,16 +352,38 @@ const darkTheme = {
345
352
  elevationOverlay: shadowDark.md,
346
353
  elevationModal: shadowDark.lg
347
354
  };
355
+ const highContrastTheme = {
356
+ ...defaultTheme,
357
+ primary: dusk["700"],
358
+ onTertiary: dusk["700"],
359
+ focus: dusk["700"],
360
+ error: ember["700"],
361
+ statusErrorText: ember["700"],
362
+ statusWarningText: saffron["800"],
363
+ statusSuccessText: moss["800"],
364
+ borderColorDefault: stone["600"]
365
+ };
366
+ const darkHighContrastTheme = {
367
+ ...darkTheme,
368
+ primary: duskDark["700"],
369
+ onTertiary: duskDark["700"],
370
+ focus: duskDark["700"],
371
+ error: emberDark["700"],
372
+ statusErrorText: emberDark["700"],
373
+ borderColorDefault: stoneDark["600"]
374
+ };
348
375
  const createTheme = (overrides = {})=>({
349
376
  ...defaultTheme,
350
377
  ...overrides
351
378
  });
352
379
  const themes = {
353
380
  light: {
354
- normal: defaultTheme
381
+ normal: defaultTheme,
382
+ high: highContrastTheme
355
383
  },
356
384
  dark: {
357
- normal: darkTheme
385
+ normal: darkTheme,
386
+ high: darkHighContrastTheme
358
387
  }
359
388
  };
360
389
  const resolveBaseTheme = (colorScheme, contrast)=>{
@@ -373,8 +402,26 @@ const comfortableSpacing = {
373
402
  space5: defaultTheme.space5,
374
403
  space6: defaultTheme.space6
375
404
  };
405
+ const compactSpacing = {
406
+ space1: '0.125rem',
407
+ space2: '0.375rem',
408
+ space3: '0.5rem',
409
+ space4: '0.75rem',
410
+ space5: '1rem',
411
+ space6: '1.125rem'
412
+ };
413
+ const spaciousSpacing = {
414
+ space1: '0.375rem',
415
+ space2: '0.75rem',
416
+ space3: '0.875rem',
417
+ space4: '1.5rem',
418
+ space5: '1.875rem',
419
+ space6: '2.25rem'
420
+ };
376
421
  const density_densitySpacing = {
377
- comfortable: comfortableSpacing
422
+ compact: compactSpacing,
423
+ comfortable: comfortableSpacing,
424
+ spacious: spaciousSpacing
378
425
  };
379
426
  const resolveDensitySpacing = (density)=>{
380
427
  const spacing = density_densitySpacing[density];
@@ -394,6 +441,31 @@ const grid = {
394
441
  columns: 12,
395
442
  containerMaxWidth: '1280px'
396
443
  };
444
+ const PROBE_CUSTOM_PROPERTY = '--vinyasa-primary';
445
+ let warned = false;
446
+ const useAssertVinyasaProvider = (ref)=>{
447
+ useEffect(()=>{
448
+ if (warned || 'production' === process.env.NODE_ENV) return;
449
+ const node = ref.current;
450
+ if (!node) return;
451
+ const value = getComputedStyle(node).getPropertyValue(PROBE_CUSTOM_PROPERTY).trim();
452
+ if (!value) {
453
+ warned = true;
454
+ console.warn('[vinyasa] rendered without a mounted VinyasaProvider (or outside its DOM subtree, e.g. via a portal) — theme tokens will not resolve. Wrap your app in <VinyasaProvider> from "@vinyasa/tokens".');
455
+ }
456
+ }, [
457
+ ref
458
+ ]);
459
+ };
460
+ const mergeRefs = (...refs)=>(node)=>{
461
+ for (const ref of refs)if ('function' == typeof ref) ref(node);
462
+ else if (ref) ref.current = node;
463
+ };
464
+ const useThemedRef = (ref)=>{
465
+ const innerRef = useRef(null);
466
+ useAssertVinyasaProvider(innerRef);
467
+ return mergeRefs(ref, innerRef);
468
+ };
397
469
  var resetScope = '_1k07u5u0';
398
470
  const ThemeContext = /*#__PURE__*/ createContext(defaultTheme);
399
471
  const useVinyasaTheme = ()=>useContext(ThemeContext);
@@ -433,4 +505,4 @@ const VinyasaProvider = ({ theme, colorScheme = 'light', contrast = 'normal', de
433
505
  })
434
506
  });
435
507
  };
436
- export { VinyasaProvider, breakpoints, createTheme, darkTheme, defaultTheme, focusRingStyle, grid, resolveBaseTheme, resolveDensitySpacing, themeContract, useVinyasaTheme };
508
+ export { VinyasaProvider, breakpoints, createTheme, darkHighContrastTheme, darkTheme, defaultTheme, focusRingStyle, grid, highContrastTheme, resolveBaseTheme, resolveDensitySpacing, themeContract, useAssertVinyasaProvider, useThemedRef, useVinyasaTheme };
@@ -51,6 +51,7 @@ export declare const sunriseDark: {
51
51
  export declare const moss: {
52
52
  readonly tint: "#E4EEE8";
53
53
  readonly 700: "#3F6650";
54
+ readonly 800: "#3B604B";
54
55
  };
55
56
  export declare const mossDark: {
56
57
  readonly tint: "#22332A";
@@ -59,16 +60,19 @@ export declare const mossDark: {
59
60
  export declare const ember: {
60
61
  readonly tint: "#F7E7E1";
61
62
  readonly 600: "#A64B2A";
63
+ readonly 700: "#8E4024";
62
64
  readonly onEmber: "#FFFFFF";
63
65
  };
64
66
  export declare const emberDark: {
65
67
  readonly tint: "#3A281F";
66
68
  readonly 600: "#E08D6D";
69
+ readonly 700: "#E3977A";
67
70
  readonly onEmber: "#2A1208";
68
71
  };
69
72
  export declare const saffron: {
70
73
  readonly tint: "#F5EBDD";
71
74
  readonly 700: "#A15C1F";
75
+ readonly 800: "#834B19";
72
76
  };
73
77
  export declare const saffronDark: {
74
78
  readonly tint: "#3A2F1B";
@@ -9,6 +9,7 @@ export interface VinyasaTheme {
9
9
  error: string;
10
10
  onError: string;
11
11
  focus: string;
12
+ textDefault: string;
12
13
  textMuted: string;
13
14
  statusInfoBg: string;
14
15
  statusInfoText: string;
@@ -78,4 +79,6 @@ export interface VinyasaTheme {
78
79
  }
79
80
  export declare const defaultTheme: VinyasaTheme;
80
81
  export declare const darkTheme: VinyasaTheme;
82
+ export declare const highContrastTheme: VinyasaTheme;
83
+ export declare const darkHighContrastTheme: VinyasaTheme;
81
84
  export declare const createTheme: (overrides?: Partial<VinyasaTheme>) => VinyasaTheme;
@@ -0,0 +1,13 @@
1
+ import { type RefObject } from 'react';
2
+ /**
3
+ * Dev-mode-only check that `ref`'s node actually sits inside a mounted
4
+ * `VinyasaProvider`'s DOM subtree. Reads the probe custom property via
5
+ * `getComputedStyle` on the real DOM node rather than checking a React
6
+ * context: the failure this guards against includes a component rendered
7
+ * *outside* the provider's DOM subtree entirely (e.g. via a portal to
8
+ * `document.body`, the exact scoping issue Toaster/Dialog/Select's own
9
+ * comments describe) — a React context would still see the provider as an
10
+ * ancestor in that case, even though the actual rendered element is nowhere
11
+ * near it and every `var(--vinyasa-*)` on it resolves to nothing.
12
+ */
13
+ export declare const useAssertVinyasaProvider: (ref: RefObject<Element | null>) => void;
@@ -0,0 +1,2 @@
1
+ import { type Ref } from 'react';
2
+ export declare const useThemedRef: <T extends Element>(ref?: Ref<T>) => Ref<T>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vinyasa/tokens",
3
- "version": "1.0.23",
3
+ "version": "1.0.25",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "sideEffects": [