@vinyasa/tokens 1.0.22 → 1.0.24

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,35 @@ 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");
550
+ var resetScope = '_1k07u5u0';
476
551
  function VinyasaProvider_define_property(obj, key, value) {
477
552
  if (key in obj) Object.defineProperty(obj, key, {
478
553
  value: value,
@@ -520,6 +595,7 @@ const VinyasaProvider = ({ theme, colorScheme = 'light', contrast = 'normal', de
520
595
  return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(ThemeContext.Provider, {
521
596
  value: resolvedTheme,
522
597
  children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
598
+ className: resetScope,
523
599
  style: style,
524
600
  "data-vinyasa-color-scheme": colorScheme,
525
601
  "data-vinyasa-contrast": contrast,
@@ -531,25 +607,33 @@ const VinyasaProvider = ({ theme, colorScheme = 'light', contrast = 'normal', de
531
607
  exports.VinyasaProvider = __webpack_exports__.VinyasaProvider;
532
608
  exports.breakpoints = __webpack_exports__.breakpoints;
533
609
  exports.createTheme = __webpack_exports__.createTheme;
610
+ exports.darkHighContrastTheme = __webpack_exports__.darkHighContrastTheme;
534
611
  exports.darkTheme = __webpack_exports__.darkTheme;
535
612
  exports.defaultTheme = __webpack_exports__.defaultTheme;
536
613
  exports.focusRingStyle = __webpack_exports__.focusRingStyle;
537
614
  exports.grid = __webpack_exports__.grid;
615
+ exports.highContrastTheme = __webpack_exports__.highContrastTheme;
538
616
  exports.resolveBaseTheme = __webpack_exports__.resolveBaseTheme;
539
617
  exports.resolveDensitySpacing = __webpack_exports__.resolveDensitySpacing;
540
618
  exports.themeContract = __webpack_exports__.themeContract;
619
+ exports.useAssertVinyasaProvider = __webpack_exports__.useAssertVinyasaProvider;
620
+ exports.useThemedRef = __webpack_exports__.useThemedRef;
541
621
  exports.useVinyasaTheme = __webpack_exports__.useVinyasaTheme;
542
622
  for(var __rspack_i in __webpack_exports__)if (-1 === [
543
623
  "VinyasaProvider",
544
624
  "breakpoints",
545
625
  "createTheme",
626
+ "darkHighContrastTheme",
546
627
  "darkTheme",
547
628
  "defaultTheme",
548
629
  "focusRingStyle",
549
630
  "grid",
631
+ "highContrastTheme",
550
632
  "resolveBaseTheme",
551
633
  "resolveDensitySpacing",
552
634
  "themeContract",
635
+ "useAssertVinyasaProvider",
636
+ "useThemedRef",
553
637
  "useVinyasaTheme"
554
638
  ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
555
639
  Object.defineProperty(exports, '__esModule', {
@@ -0,0 +1,4 @@
1
+ ._1k07u5u0, ._1k07u5u0 * {
2
+ box-sizing: border-box;
3
+ }
4
+
@@ -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})`;
@@ -0,0 +1,4 @@
1
+ ._1k07u5u0, ._1k07u5u0 * {
2
+ box-sizing: border-box;
3
+ }
4
+
@@ -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,6 +1,7 @@
1
+ import "./index.css";
2
+ import { createContext, useContext, useEffect, useMemo, useRef } from "react";
1
3
  import { jsx } from "react/jsx-runtime";
2
4
  import { assignInlineVars } from "@vanilla-extract/dynamic";
3
- import { createContext, useContext, useMemo } from "react";
4
5
  var themeContract = {
5
6
  primary: 'var(--vinyasa-primary)',
6
7
  onPrimary: 'var(--vinyasa-on-primary)',
@@ -12,6 +13,7 @@ var themeContract = {
12
13
  error: 'var(--vinyasa-error)',
13
14
  onError: 'var(--vinyasa-on-error)',
14
15
  focus: 'var(--vinyasa-focus)',
16
+ textDefault: 'var(--vinyasa-text-default)',
15
17
  textMuted: 'var(--vinyasa-text-muted)',
16
18
  statusInfoBg: 'var(--vinyasa-status-info-bg)',
17
19
  statusInfoText: 'var(--vinyasa-status-info-text)',
@@ -124,7 +126,8 @@ const duskDark = {
124
126
  };
125
127
  const moss = {
126
128
  tint: '#E4EEE8',
127
- 700: '#3F6650'
129
+ 700: '#3F6650',
130
+ 800: '#3B604B'
128
131
  };
129
132
  const mossDark = {
130
133
  tint: '#22332A',
@@ -133,16 +136,19 @@ const mossDark = {
133
136
  const ember = {
134
137
  tint: '#F7E7E1',
135
138
  600: '#A64B2A',
139
+ 700: '#8E4024',
136
140
  onEmber: '#FFFFFF'
137
141
  };
138
142
  const emberDark = {
139
143
  tint: '#3A281F',
140
144
  600: '#E08D6D',
145
+ 700: '#E3977A',
141
146
  onEmber: '#2A1208'
142
147
  };
143
148
  const saffron = {
144
149
  tint: '#F5EBDD',
145
- 700: '#A15C1F'
150
+ 700: '#A15C1F',
151
+ 800: '#834B19'
146
152
  };
147
153
  const saffronDark = {
148
154
  tint: '#3A2F1B',
@@ -298,6 +304,7 @@ const defaultTheme = {
298
304
  error: ember["600"],
299
305
  onError: ember.onEmber,
300
306
  focus: dusk["600"],
307
+ textDefault: stone["900"],
301
308
  textMuted: stone["700"],
302
309
  statusInfoBg: dusk.tint,
303
310
  statusInfoText: dusk["600"],
@@ -327,6 +334,7 @@ const darkTheme = {
327
334
  error: emberDark["600"],
328
335
  onError: emberDark.onEmber,
329
336
  focus: duskDark["600"],
337
+ textDefault: stoneDark["900"],
330
338
  textMuted: stoneDark["600"],
331
339
  statusInfoBg: duskDark.tint,
332
340
  statusInfoText: duskDark["600"],
@@ -344,16 +352,38 @@ const darkTheme = {
344
352
  elevationOverlay: shadowDark.md,
345
353
  elevationModal: shadowDark.lg
346
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
+ };
347
375
  const createTheme = (overrides = {})=>({
348
376
  ...defaultTheme,
349
377
  ...overrides
350
378
  });
351
379
  const themes = {
352
380
  light: {
353
- normal: defaultTheme
381
+ normal: defaultTheme,
382
+ high: highContrastTheme
354
383
  },
355
384
  dark: {
356
- normal: darkTheme
385
+ normal: darkTheme,
386
+ high: darkHighContrastTheme
357
387
  }
358
388
  };
359
389
  const resolveBaseTheme = (colorScheme, contrast)=>{
@@ -372,8 +402,26 @@ const comfortableSpacing = {
372
402
  space5: defaultTheme.space5,
373
403
  space6: defaultTheme.space6
374
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
+ };
375
421
  const density_densitySpacing = {
376
- comfortable: comfortableSpacing
422
+ compact: compactSpacing,
423
+ comfortable: comfortableSpacing,
424
+ spacious: spaciousSpacing
377
425
  };
378
426
  const resolveDensitySpacing = (density)=>{
379
427
  const spacing = density_densitySpacing[density];
@@ -393,6 +441,32 @@ const grid = {
393
441
  columns: 12,
394
442
  containerMaxWidth: '1280px'
395
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
+ };
469
+ var resetScope = '_1k07u5u0';
396
470
  const ThemeContext = /*#__PURE__*/ createContext(defaultTheme);
397
471
  const useVinyasaTheme = ()=>useContext(ThemeContext);
398
472
  const VinyasaProvider = ({ theme, colorScheme = 'light', contrast = 'normal', density = 'comfortable', children })=>{
@@ -422,6 +496,7 @@ const VinyasaProvider = ({ theme, colorScheme = 'light', contrast = 'normal', de
422
496
  return /*#__PURE__*/ jsx(ThemeContext.Provider, {
423
497
  value: resolvedTheme,
424
498
  children: /*#__PURE__*/ jsx("div", {
499
+ className: resetScope,
425
500
  style: style,
426
501
  "data-vinyasa-color-scheme": colorScheme,
427
502
  "data-vinyasa-contrast": contrast,
@@ -430,4 +505,4 @@ const VinyasaProvider = ({ theme, colorScheme = 'light', contrast = 'normal', de
430
505
  })
431
506
  });
432
507
  };
433
- 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";
@@ -0,0 +1 @@
1
+ export declare const resetScope: string;
@@ -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.22",
3
+ "version": "1.0.24",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "sideEffects": [