@gaulatti/bleecker 0.1.34 → 0.1.36

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.
Files changed (122) hide show
  1. package/README.md +75 -0
  2. package/dist/components/accordion.js +3 -2
  3. package/dist/components/activity-item.js +1 -1
  4. package/dist/components/alert-dialog.js +24 -11
  5. package/dist/components/alert.d.ts +2 -1
  6. package/dist/components/alert.js +11 -10
  7. package/dist/components/avatar.d.ts +2 -1
  8. package/dist/components/avatar.js +1 -0
  9. package/dist/components/bauhaus-background.js +1 -1
  10. package/dist/components/brand-lockup.js +1 -1
  11. package/dist/components/breadcrumb.js +3 -2
  12. package/dist/components/button.d.ts +3 -5
  13. package/dist/components/button.js +17 -12
  14. package/dist/components/card.d.ts +5 -1
  15. package/dist/components/card.js +3 -2
  16. package/dist/components/checkbox.js +1 -1
  17. package/dist/components/collection-filters.d.ts +2 -1
  18. package/dist/components/collection-filters.js +40 -7
  19. package/dist/components/command-spotlight.js +10 -5
  20. package/dist/components/context-menu.js +2 -2
  21. package/dist/components/dashboard-section.js +1 -1
  22. package/dist/components/data-list.js +1 -1
  23. package/dist/components/data-table-column-toggle.js +8 -20
  24. package/dist/components/data-table.js +2 -1
  25. package/dist/components/date-picker.d.ts +3 -1
  26. package/dist/components/date-picker.js +11 -29
  27. package/dist/components/date-range-picker.d.ts +3 -3
  28. package/dist/components/date-range-picker.js +24 -9
  29. package/dist/components/dialog-close-button.js +2 -2
  30. package/dist/components/donut-chart.js +1 -1
  31. package/dist/components/drawer.js +8 -22
  32. package/dist/components/dropdown-menu.js +7 -7
  33. package/dist/components/empty.js +1 -1
  34. package/dist/components/error-state.js +1 -1
  35. package/dist/components/feed-item.js +1 -1
  36. package/dist/components/field-help-tooltip.js +1 -1
  37. package/dist/components/field.d.ts +17 -0
  38. package/dist/components/field.js +16 -0
  39. package/dist/components/file-input.js +1 -1
  40. package/dist/components/filter-chip.js +2 -2
  41. package/dist/components/header-select.d.ts +13 -2
  42. package/dist/components/header-select.js +7 -3
  43. package/dist/components/hero-carousel.js +3 -2
  44. package/dist/components/hover-card.js +1 -1
  45. package/dist/components/icon-badge.d.ts +5 -2
  46. package/dist/components/icon-badge.js +2 -2
  47. package/dist/components/icon-button.d.ts +4 -0
  48. package/dist/components/icon-button.js +3 -2
  49. package/dist/components/input.d.ts +2 -3
  50. package/dist/components/input.js +5 -5
  51. package/dist/components/label.js +1 -1
  52. package/dist/components/loading-overlay.js +1 -1
  53. package/dist/components/loading-spinner.d.ts +3 -1
  54. package/dist/components/media-library.js +5 -3
  55. package/dist/components/menubar.js +17 -7
  56. package/dist/components/metric.d.ts +2 -2
  57. package/dist/components/metric.js +1 -0
  58. package/dist/components/modal.js +53 -13
  59. package/dist/components/navigation-menu.js +15 -5
  60. package/dist/components/notification-badge.js +1 -1
  61. package/dist/components/otp-input.js +2 -1
  62. package/dist/components/page-header.js +1 -1
  63. package/dist/components/pagination.js +3 -3
  64. package/dist/components/panel.js +1 -1
  65. package/dist/components/popover.d.ts +3 -2
  66. package/dist/components/popover.js +4 -91
  67. package/dist/components/progress.d.ts +4 -2
  68. package/dist/components/progress.js +3 -3
  69. package/dist/components/radio-group.d.ts +3 -1
  70. package/dist/components/radio-group.js +2 -2
  71. package/dist/components/sankey-chart.js +1 -0
  72. package/dist/components/scatter-chart.js +1 -1
  73. package/dist/components/search-input.js +1 -1
  74. package/dist/components/section-header.js +1 -1
  75. package/dist/components/select.d.ts +12 -1
  76. package/dist/components/select.js +13 -64
  77. package/dist/components/sheet.js +8 -24
  78. package/dist/components/sidebar.js +4 -3
  79. package/dist/components/slider.js +2 -2
  80. package/dist/components/sonner.js +3 -2
  81. package/dist/components/stat-card.js +1 -1
  82. package/dist/components/status-badge.d.ts +2 -1
  83. package/dist/components/status-badge.js +5 -6
  84. package/dist/components/stepper.js +2 -2
  85. package/dist/components/sunburst-chart.js +1 -0
  86. package/dist/components/switch.js +1 -1
  87. package/dist/components/table.js +10 -8
  88. package/dist/components/tabs.d.ts +6 -1
  89. package/dist/components/tabs.js +30 -7
  90. package/dist/components/textarea.d.ts +2 -3
  91. package/dist/components/textarea.js +2 -2
  92. package/dist/components/theme-toggle.js +1 -0
  93. package/dist/components/timeline.js +1 -1
  94. package/dist/components/toggle-group.js +2 -1
  95. package/dist/components/toggle.d.ts +4 -2
  96. package/dist/components/toggle.js +1 -1
  97. package/dist/components/tooltip.d.ts +2 -1
  98. package/dist/components/tooltip.js +3 -21
  99. package/dist/core/contracts.d.ts +48 -0
  100. package/dist/core/contracts.js +23 -0
  101. package/dist/core/index.d.ts +2 -0
  102. package/dist/core/index.js +2 -0
  103. package/dist/index.d.ts +3 -0
  104. package/dist/index.js +3 -0
  105. package/dist/layout/admin-shell.js +1 -1
  106. package/dist/layout/app-shell.js +1 -1
  107. package/dist/layout/footer.js +4 -4
  108. package/dist/layout/header.js +2 -1
  109. package/dist/styles.css +1 -1
  110. package/dist/theme/theme-provider.js +1 -0
  111. package/dist/theme/theme-script.d.ts +1 -2
  112. package/dist/theme/theme-script.js +1 -3
  113. package/dist/theme/types.d.ts +2 -1
  114. package/dist/tokens/index.d.ts +1 -0
  115. package/dist/tokens/index.js +1 -0
  116. package/dist/tokens/source.d.ts +221 -0
  117. package/dist/tokens/source.js +140 -0
  118. package/dist/utils/hooks.d.ts +14 -0
  119. package/dist/utils/hooks.js +101 -0
  120. package/package.json +41 -7
  121. package/src/styles/global.css +82 -175
  122. package/src/styles/tokens.generated.css +171 -0
@@ -1,3 +1,4 @@
1
+ 'use client';
1
2
  import { jsx as _jsx } from "react/jsx-runtime";
2
3
  import React from 'react';
3
4
  import { resolveTheme } from './theme-script.js';
@@ -1,5 +1,4 @@
1
- import type { ThemeMode } from './types';
2
- export declare function resolveTheme(theme: ThemeMode, prefersDark: boolean): "dark" | "light";
1
+ export { resolveTheme } from '../core';
3
2
  export declare function getThemeScript(storageKey?: string): string;
4
3
  export declare function BleeckerThemeScript({ storageKey }: {
5
4
  storageKey?: string;
@@ -1,7 +1,5 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- export function resolveTheme(theme, prefersDark) {
3
- return theme === 'system' ? (prefersDark ? 'dark' : 'light') : theme;
4
- }
2
+ export { resolveTheme } from '../core.js';
5
3
  export function getThemeScript(storageKey = 'theme') {
6
4
  return `(function(){try{var key=${JSON.stringify(storageKey)};var saved=localStorage.getItem(key);var theme=(saved==="light"||saved==="dark"||saved==="system")?saved:"system";var dark=theme==="dark"||(theme==="system"&&window.matchMedia("(prefers-color-scheme: dark)").matches);document.documentElement.classList.toggle("dark",dark);}catch(e){}})();`;
7
5
  }
@@ -1,5 +1,6 @@
1
1
  import type { ReactNode } from 'react';
2
- export type ThemeMode = 'light' | 'dark' | 'system';
2
+ import type { ThemeMode } from '../core';
3
+ export type { ThemeMode } from '../core';
3
4
  export interface ThemeProviderProps {
4
5
  children: ReactNode;
5
6
  defaultTheme?: ThemeMode;
@@ -0,0 +1 @@
1
+ export * from './source';
@@ -0,0 +1 @@
1
+ export * from './source.js';
@@ -0,0 +1,221 @@
1
+ /**
2
+ * Platform-neutral Bleecker design tokens.
3
+ *
4
+ * This module is the canonical source for both Bleecker's generated CSS and
5
+ * Thompson's React Native theme. Keep browser-only representations out of it.
6
+ */
7
+ export declare const fontFamilies: {
8
+ readonly primary: "Encode Sans";
9
+ readonly secondary: "Libre Franklin";
10
+ };
11
+ export declare const fontWeights: {
12
+ readonly regular: "400";
13
+ readonly medium: "500";
14
+ readonly semibold: "600";
15
+ readonly bold: "700";
16
+ };
17
+ export declare const spacing: {
18
+ readonly detail: 4;
19
+ readonly inline: 8;
20
+ readonly control: 12;
21
+ readonly component: 16;
22
+ readonly group: 24;
23
+ readonly container: 32;
24
+ readonly section: 48;
25
+ readonly page: 64;
26
+ };
27
+ export declare const radii: {
28
+ readonly button: 7;
29
+ readonly card: 12;
30
+ readonly ui: 7;
31
+ readonly dialog: 14;
32
+ readonly pill: 9999;
33
+ };
34
+ export declare const durations: {
35
+ readonly fast: 150;
36
+ readonly standard: 200;
37
+ readonly deliberate: 300;
38
+ readonly enter: 220;
39
+ readonly exit: 320;
40
+ readonly control: 190;
41
+ readonly surface: 220;
42
+ readonly overlay: 240;
43
+ readonly motionExit: 150;
44
+ };
45
+ export declare const letterSpacing: {
46
+ readonly refined: -0.02;
47
+ readonly ui: 0;
48
+ readonly elegant: 0.05;
49
+ };
50
+ export declare const easing: {
51
+ readonly spring: readonly [0.16, 1, 0.3, 1];
52
+ readonly bouncy: readonly [0.34, 1.56, 0.64, 1];
53
+ readonly outExpo: readonly [0.16, 1, 0.3, 1];
54
+ readonly premium: readonly [0.22, 1, 0.36, 1];
55
+ };
56
+ export declare const shadows: {
57
+ readonly surface: "0 1px 2px rgb(26 55 77 / 0.025), 0 10px 30px -18px rgb(26 55 77 / 0.18)";
58
+ readonly raised: "0 2px 5px rgb(26 55 77 / 0.045), 0 18px 42px -22px rgb(26 55 77 / 0.24)";
59
+ readonly overlay: "0 24px 64px -20px rgb(26 55 77 / 0.28), 0 4px 14px rgb(26 55 77 / 0.06)";
60
+ };
61
+ export declare const lightColors: {
62
+ readonly sand: "#e6d5b8";
63
+ readonly desert: "#c1814d";
64
+ readonly terracotta: "#a65d57";
65
+ readonly sea: "#2c5784";
66
+ readonly lightSand: "#f9f6f2";
67
+ readonly darkSand: "#d4c4a9";
68
+ readonly sunset: "#ff9677";
69
+ readonly accentGold: "#c6a760";
70
+ readonly accentBlue: "#2c5784";
71
+ readonly textPrimary: "#2d2d2d";
72
+ readonly textSecondary: "#595959";
73
+ readonly background: "#ffffff";
74
+ readonly foreground: "#2d2d2d";
75
+ readonly card: "#ffffff";
76
+ readonly cardForeground: "#2d2d2d";
77
+ readonly popover: "#ffffff";
78
+ readonly popoverForeground: "#2d2d2d";
79
+ readonly muted: "#f9f6f2";
80
+ readonly mutedForeground: "#595959";
81
+ readonly border: "rgba(0, 0, 0, 0.08)";
82
+ readonly input: "rgba(0, 0, 0, 0.08)";
83
+ readonly ring: "#2c5784";
84
+ readonly primary: "#2c5784";
85
+ readonly primaryForeground: "#ffffff";
86
+ readonly secondary: "#f9f6f2";
87
+ readonly secondaryForeground: "#2d2d2d";
88
+ readonly destructive: "#a65d57";
89
+ readonly destructiveForeground: "#ffffff";
90
+ readonly accent: "#f9f6f2";
91
+ readonly accentForeground: "#2d2d2d";
92
+ readonly dusk: "#694f5d";
93
+ readonly deepSea: "#1a374d";
94
+ readonly accentOxblood: "#76323f";
95
+ readonly accentBronze: "#cd7f32";
96
+ readonly accentRed: "#d94f4f";
97
+ readonly accentYellow: "#d4af37";
98
+ readonly persgray50: "#f9fafb";
99
+ };
100
+ export declare const darkColors: {
101
+ readonly sand: "#1a2332";
102
+ readonly desert: "#e0ac69";
103
+ readonly terracotta: "#d47b75";
104
+ readonly sea: "#5ba3f5";
105
+ readonly deepSea: "#182533";
106
+ readonly lightSand: "#0d1821";
107
+ readonly darkSand: "#243447";
108
+ readonly sunset: "#ff9677";
109
+ readonly accentGold: "#d4af37";
110
+ readonly accentBlue: "#5ba3f5";
111
+ readonly textPrimary: "#f0f4f8";
112
+ readonly textSecondary: "#b8c5d6";
113
+ readonly background: "#0d1821";
114
+ readonly foreground: "#f0f4f8";
115
+ readonly card: "#182533";
116
+ readonly cardForeground: "#f0f4f8";
117
+ readonly popover: "#182533";
118
+ readonly popoverForeground: "#f0f4f8";
119
+ readonly muted: "#1a2332";
120
+ readonly mutedForeground: "#b8c5d6";
121
+ readonly border: "rgba(255, 255, 255, 0.08)";
122
+ readonly input: "rgba(255, 255, 255, 0.08)";
123
+ readonly ring: "#5ba3f5";
124
+ readonly primary: "#5ba3f5";
125
+ readonly primaryForeground: "#0d1821";
126
+ readonly secondary: "#1a2332";
127
+ readonly secondaryForeground: "#f0f4f8";
128
+ readonly destructive: "#d47b75";
129
+ readonly destructiveForeground: "#0d1821";
130
+ readonly accent: "#1a2332";
131
+ readonly accentForeground: "#f0f4f8";
132
+ readonly dusk: "#694f5d";
133
+ readonly accentOxblood: "#76323f";
134
+ readonly accentBronze: "#cd7f32";
135
+ readonly accentRed: "#d94f4f";
136
+ readonly accentYellow: "#d4af37";
137
+ readonly persgray50: "#f9fafb";
138
+ };
139
+ export declare const themes: {
140
+ readonly light: {
141
+ readonly sand: "#e6d5b8";
142
+ readonly desert: "#c1814d";
143
+ readonly terracotta: "#a65d57";
144
+ readonly sea: "#2c5784";
145
+ readonly lightSand: "#f9f6f2";
146
+ readonly darkSand: "#d4c4a9";
147
+ readonly sunset: "#ff9677";
148
+ readonly accentGold: "#c6a760";
149
+ readonly accentBlue: "#2c5784";
150
+ readonly textPrimary: "#2d2d2d";
151
+ readonly textSecondary: "#595959";
152
+ readonly background: "#ffffff";
153
+ readonly foreground: "#2d2d2d";
154
+ readonly card: "#ffffff";
155
+ readonly cardForeground: "#2d2d2d";
156
+ readonly popover: "#ffffff";
157
+ readonly popoverForeground: "#2d2d2d";
158
+ readonly muted: "#f9f6f2";
159
+ readonly mutedForeground: "#595959";
160
+ readonly border: "rgba(0, 0, 0, 0.08)";
161
+ readonly input: "rgba(0, 0, 0, 0.08)";
162
+ readonly ring: "#2c5784";
163
+ readonly primary: "#2c5784";
164
+ readonly primaryForeground: "#ffffff";
165
+ readonly secondary: "#f9f6f2";
166
+ readonly secondaryForeground: "#2d2d2d";
167
+ readonly destructive: "#a65d57";
168
+ readonly destructiveForeground: "#ffffff";
169
+ readonly accent: "#f9f6f2";
170
+ readonly accentForeground: "#2d2d2d";
171
+ readonly dusk: "#694f5d";
172
+ readonly deepSea: "#1a374d";
173
+ readonly accentOxblood: "#76323f";
174
+ readonly accentBronze: "#cd7f32";
175
+ readonly accentRed: "#d94f4f";
176
+ readonly accentYellow: "#d4af37";
177
+ readonly persgray50: "#f9fafb";
178
+ };
179
+ readonly dark: {
180
+ readonly sand: "#1a2332";
181
+ readonly desert: "#e0ac69";
182
+ readonly terracotta: "#d47b75";
183
+ readonly sea: "#5ba3f5";
184
+ readonly deepSea: "#182533";
185
+ readonly lightSand: "#0d1821";
186
+ readonly darkSand: "#243447";
187
+ readonly sunset: "#ff9677";
188
+ readonly accentGold: "#d4af37";
189
+ readonly accentBlue: "#5ba3f5";
190
+ readonly textPrimary: "#f0f4f8";
191
+ readonly textSecondary: "#b8c5d6";
192
+ readonly background: "#0d1821";
193
+ readonly foreground: "#f0f4f8";
194
+ readonly card: "#182533";
195
+ readonly cardForeground: "#f0f4f8";
196
+ readonly popover: "#182533";
197
+ readonly popoverForeground: "#f0f4f8";
198
+ readonly muted: "#1a2332";
199
+ readonly mutedForeground: "#b8c5d6";
200
+ readonly border: "rgba(255, 255, 255, 0.08)";
201
+ readonly input: "rgba(255, 255, 255, 0.08)";
202
+ readonly ring: "#5ba3f5";
203
+ readonly primary: "#5ba3f5";
204
+ readonly primaryForeground: "#0d1821";
205
+ readonly secondary: "#1a2332";
206
+ readonly secondaryForeground: "#f0f4f8";
207
+ readonly destructive: "#d47b75";
208
+ readonly destructiveForeground: "#0d1821";
209
+ readonly accent: "#1a2332";
210
+ readonly accentForeground: "#f0f4f8";
211
+ readonly dusk: "#694f5d";
212
+ readonly accentOxblood: "#76323f";
213
+ readonly accentBronze: "#cd7f32";
214
+ readonly accentRed: "#d94f4f";
215
+ readonly accentYellow: "#d4af37";
216
+ readonly persgray50: "#f9fafb";
217
+ };
218
+ };
219
+ export type BleeckerColorScheme = keyof typeof themes;
220
+ export type BleeckerTheme = (typeof themes)[BleeckerColorScheme];
221
+ export type BleeckerColorToken = keyof BleeckerTheme;
@@ -0,0 +1,140 @@
1
+ /**
2
+ * Platform-neutral Bleecker design tokens.
3
+ *
4
+ * This module is the canonical source for both Bleecker's generated CSS and
5
+ * Thompson's React Native theme. Keep browser-only representations out of it.
6
+ */
7
+ export const fontFamilies = {
8
+ primary: 'Encode Sans',
9
+ secondary: 'Libre Franklin'
10
+ };
11
+ export const fontWeights = {
12
+ regular: '400',
13
+ medium: '500',
14
+ semibold: '600',
15
+ bold: '700'
16
+ };
17
+ export const spacing = {
18
+ detail: 4,
19
+ inline: 8,
20
+ control: 12,
21
+ component: 16,
22
+ group: 24,
23
+ container: 32,
24
+ section: 48,
25
+ page: 64
26
+ };
27
+ export const radii = {
28
+ button: 7,
29
+ card: 12,
30
+ ui: 7,
31
+ dialog: 14,
32
+ pill: 9999
33
+ };
34
+ export const durations = {
35
+ fast: 150,
36
+ standard: 200,
37
+ deliberate: 300,
38
+ enter: 220,
39
+ exit: 320,
40
+ control: 190,
41
+ surface: 220,
42
+ overlay: 240,
43
+ motionExit: 150
44
+ };
45
+ export const letterSpacing = {
46
+ refined: -0.02,
47
+ ui: 0,
48
+ elegant: 0.05
49
+ };
50
+ export const easing = {
51
+ spring: [0.16, 1, 0.3, 1],
52
+ bouncy: [0.34, 1.56, 0.64, 1],
53
+ outExpo: [0.16, 1, 0.3, 1],
54
+ premium: [0.22, 1, 0.36, 1]
55
+ };
56
+ export const shadows = {
57
+ surface: '0 1px 2px rgb(26 55 77 / 0.025), 0 10px 30px -18px rgb(26 55 77 / 0.18)',
58
+ raised: '0 2px 5px rgb(26 55 77 / 0.045), 0 18px 42px -22px rgb(26 55 77 / 0.24)',
59
+ overlay: '0 24px 64px -20px rgb(26 55 77 / 0.28), 0 4px 14px rgb(26 55 77 / 0.06)'
60
+ };
61
+ const sharedColors = {
62
+ dusk: '#694f5d',
63
+ deepSea: '#1a374d',
64
+ accentOxblood: '#76323f',
65
+ accentBronze: '#cd7f32',
66
+ accentRed: '#d94f4f',
67
+ accentYellow: '#d4af37',
68
+ persgray50: '#f9fafb'
69
+ };
70
+ export const lightColors = {
71
+ ...sharedColors,
72
+ sand: '#e6d5b8',
73
+ desert: '#c1814d',
74
+ terracotta: '#a65d57',
75
+ sea: '#2c5784',
76
+ lightSand: '#f9f6f2',
77
+ darkSand: '#d4c4a9',
78
+ sunset: '#ff9677',
79
+ accentGold: '#c6a760',
80
+ accentBlue: '#2c5784',
81
+ textPrimary: '#2d2d2d',
82
+ textSecondary: '#595959',
83
+ background: '#ffffff',
84
+ foreground: '#2d2d2d',
85
+ card: '#ffffff',
86
+ cardForeground: '#2d2d2d',
87
+ popover: '#ffffff',
88
+ popoverForeground: '#2d2d2d',
89
+ muted: '#f9f6f2',
90
+ mutedForeground: '#595959',
91
+ border: 'rgba(0, 0, 0, 0.08)',
92
+ input: 'rgba(0, 0, 0, 0.08)',
93
+ ring: '#2c5784',
94
+ primary: '#2c5784',
95
+ primaryForeground: '#ffffff',
96
+ secondary: '#f9f6f2',
97
+ secondaryForeground: '#2d2d2d',
98
+ destructive: '#a65d57',
99
+ destructiveForeground: '#ffffff',
100
+ accent: '#f9f6f2',
101
+ accentForeground: '#2d2d2d'
102
+ };
103
+ export const darkColors = {
104
+ ...sharedColors,
105
+ sand: '#1a2332',
106
+ desert: '#e0ac69',
107
+ terracotta: '#d47b75',
108
+ sea: '#5ba3f5',
109
+ deepSea: '#182533',
110
+ lightSand: '#0d1821',
111
+ darkSand: '#243447',
112
+ sunset: '#ff9677',
113
+ accentGold: '#d4af37',
114
+ accentBlue: '#5ba3f5',
115
+ textPrimary: '#f0f4f8',
116
+ textSecondary: '#b8c5d6',
117
+ background: '#0d1821',
118
+ foreground: '#f0f4f8',
119
+ card: '#182533',
120
+ cardForeground: '#f0f4f8',
121
+ popover: '#182533',
122
+ popoverForeground: '#f0f4f8',
123
+ muted: '#1a2332',
124
+ mutedForeground: '#b8c5d6',
125
+ border: 'rgba(255, 255, 255, 0.08)',
126
+ input: 'rgba(255, 255, 255, 0.08)',
127
+ ring: '#5ba3f5',
128
+ primary: '#5ba3f5',
129
+ primaryForeground: '#0d1821',
130
+ secondary: '#1a2332',
131
+ secondaryForeground: '#f0f4f8',
132
+ destructive: '#d47b75',
133
+ destructiveForeground: '#0d1821',
134
+ accent: '#1a2332',
135
+ accentForeground: '#f0f4f8'
136
+ };
137
+ export const themes = {
138
+ light: lightColors,
139
+ dark: darkColors
140
+ };
@@ -1,3 +1,4 @@
1
+ import * as React from 'react';
1
2
  /**
2
3
  * Returns true once the component has mounted. Useful for avoiding SSR
3
4
  * hydration mismatches in components that read from `window`/`document`.
@@ -15,8 +16,21 @@ export declare function useDebounce<T>(value: T, delay?: number): T;
15
16
  * Returns the previous value of a prop/state.
16
17
  */
17
18
  export declare function usePrevious<T>(value: T): T | undefined;
19
+ /**
20
+ * Keeps a conditional surface mounted long enough for its exit motion to
21
+ * complete, and separates DOM presence from visual visibility.
22
+ */
23
+ export declare function usePresence(open: boolean, exitDuration?: number): {
24
+ present: boolean;
25
+ visible: boolean;
26
+ };
18
27
  /**
19
28
  * Returns a stable callback that always calls the latest callback reference
20
29
  * without causing effect re-runs.
21
30
  */
22
31
  export declare function useEventCallback<T extends (...args: any[]) => any>(callback?: T): T;
32
+ /**
33
+ * Supplies the focus, Escape, and scroll-lock behavior expected of custom
34
+ * modal surfaces such as sheets and drawers.
35
+ */
36
+ export declare function useModalLayer<T extends HTMLElement>(open: boolean, onDismiss: () => void): React.RefObject<T | null>;
@@ -1,3 +1,4 @@
1
+ 'use client';
1
2
  import * as React from 'react';
2
3
  /**
3
4
  * Returns true once the component has mounted. Useful for avoiding SSR
@@ -45,6 +46,46 @@ export function usePrevious(value) {
45
46
  }, [value]);
46
47
  return ref.current;
47
48
  }
49
+ /**
50
+ * Keeps a conditional surface mounted long enough for its exit motion to
51
+ * complete, and separates DOM presence from visual visibility.
52
+ */
53
+ export function usePresence(open, exitDuration = 150) {
54
+ const [present, setPresent] = React.useState(open);
55
+ const [visible, setVisible] = React.useState(false);
56
+ const enterTimerRef = React.useRef(null);
57
+ const exitTimerRef = React.useRef(null);
58
+ React.useEffect(() => {
59
+ if (open) {
60
+ if (exitTimerRef.current)
61
+ clearTimeout(exitTimerRef.current);
62
+ setPresent(true);
63
+ return;
64
+ }
65
+ setVisible(false);
66
+ if (present) {
67
+ exitTimerRef.current = setTimeout(() => setPresent(false), exitDuration);
68
+ }
69
+ }, [exitDuration, open, present]);
70
+ React.useLayoutEffect(() => {
71
+ if (!open || !present)
72
+ return;
73
+ enterTimerRef.current = setTimeout(() => setVisible(true), 20);
74
+ return () => {
75
+ if (enterTimerRef.current)
76
+ clearTimeout(enterTimerRef.current);
77
+ };
78
+ }, [open, present]);
79
+ React.useEffect(() => {
80
+ return () => {
81
+ if (enterTimerRef.current)
82
+ clearTimeout(enterTimerRef.current);
83
+ if (exitTimerRef.current)
84
+ clearTimeout(exitTimerRef.current);
85
+ };
86
+ }, []);
87
+ return { present, visible };
88
+ }
48
89
  /**
49
90
  * Returns a stable callback that always calls the latest callback reference
50
91
  * without causing effect re-runs.
@@ -56,3 +97,63 @@ export function useEventCallback(callback) {
56
97
  }, [callback]);
57
98
  return React.useCallback((...args) => ref.current?.(...args), []);
58
99
  }
100
+ const focusableSelector = [
101
+ 'a[href]',
102
+ 'button:not([disabled])',
103
+ 'input:not([disabled])',
104
+ 'select:not([disabled])',
105
+ 'textarea:not([disabled])',
106
+ '[tabindex]:not([tabindex="-1"])'
107
+ ].join(',');
108
+ /**
109
+ * Supplies the focus, Escape, and scroll-lock behavior expected of custom
110
+ * modal surfaces such as sheets and drawers.
111
+ */
112
+ export function useModalLayer(open, onDismiss) {
113
+ const layerRef = React.useRef(null);
114
+ const dismiss = useEventCallback(onDismiss);
115
+ React.useEffect(() => {
116
+ if (!open || typeof document === 'undefined')
117
+ return undefined;
118
+ const layer = layerRef.current;
119
+ if (!layer)
120
+ return undefined;
121
+ const previouslyFocused = document.activeElement instanceof HTMLElement ? document.activeElement : null;
122
+ const previousOverflow = document.body.style.overflow;
123
+ document.body.style.overflow = 'hidden';
124
+ const focusable = Array.from(layer.querySelectorAll(focusableSelector));
125
+ (focusable[0] ?? layer).focus({ preventScroll: true });
126
+ const handleKeyDown = (event) => {
127
+ if (event.key === 'Escape') {
128
+ event.preventDefault();
129
+ dismiss();
130
+ return;
131
+ }
132
+ if (event.key !== 'Tab')
133
+ return;
134
+ const currentFocusable = Array.from(layer.querySelectorAll(focusableSelector));
135
+ if (currentFocusable.length === 0) {
136
+ event.preventDefault();
137
+ layer.focus();
138
+ return;
139
+ }
140
+ const first = currentFocusable[0];
141
+ const last = currentFocusable[currentFocusable.length - 1];
142
+ if (event.shiftKey && document.activeElement === first) {
143
+ event.preventDefault();
144
+ last.focus();
145
+ }
146
+ else if (!event.shiftKey && document.activeElement === last) {
147
+ event.preventDefault();
148
+ first.focus();
149
+ }
150
+ };
151
+ document.addEventListener('keydown', handleKeyDown);
152
+ return () => {
153
+ document.removeEventListener('keydown', handleKeyDown);
154
+ document.body.style.overflow = previousOverflow;
155
+ previouslyFocused?.focus({ preventScroll: true });
156
+ };
157
+ }, [dismiss, open]);
158
+ return layerRef;
159
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gaulatti/bleecker",
3
- "version": "0.1.34",
3
+ "version": "0.1.36",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/gaulatti/bleecker"
@@ -12,7 +12,8 @@
12
12
  "files": [
13
13
  "dist",
14
14
  "dist/styles.css",
15
- "src/styles/global.css"
15
+ "src/styles/global.css",
16
+ "src/styles/tokens.generated.css"
16
17
  ],
17
18
  "type": "module",
18
19
  "sideEffects": [
@@ -27,27 +28,60 @@
27
28
  "types": "./dist/index.d.ts",
28
29
  "import": "./dist/index.js"
29
30
  },
31
+ "./components/*": {
32
+ "types": "./dist/components/*.d.ts",
33
+ "import": "./dist/components/*.js"
34
+ },
35
+ "./layout/*": {
36
+ "types": "./dist/layout/*.d.ts",
37
+ "import": "./dist/layout/*.js"
38
+ },
39
+ "./theme/*": {
40
+ "types": "./dist/theme/*.d.ts",
41
+ "import": "./dist/theme/*.js"
42
+ },
43
+ "./utils/*": {
44
+ "types": "./dist/utils/*.d.ts",
45
+ "import": "./dist/utils/*.js"
46
+ },
47
+ "./core": {
48
+ "types": "./dist/core/index.d.ts",
49
+ "import": "./dist/core/index.js"
50
+ },
51
+ "./tokens": {
52
+ "types": "./dist/tokens/index.d.ts",
53
+ "import": "./dist/tokens/index.js"
54
+ },
30
55
  "./styles.css": "./dist/styles.css",
31
56
  "./styles.base.css": "./src/styles/global.css"
32
57
  },
33
58
  "scripts": {
34
- "build:css": "node -e \"require('node:fs').mkdirSync('dist',{recursive:true})\" && tailwindcss -i src/styles/global.css -o dist/styles.css --minify",
35
- "build": "npm run check:exports-stories && npm run build:css && tsc && node scripts/fix-esm-imports.mjs",
59
+ "clean": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\"",
60
+ "build:tokens": "node scripts/generate-token-css.mjs",
61
+ "check:tokens": "node scripts/generate-token-css.mjs --check",
62
+ "build:css": "npm run build:tokens && node -e \"require('node:fs').mkdirSync('dist',{recursive:true})\" && tailwindcss -i src/styles/global.css -o dist/styles.css --minify",
63
+ "build": "npm run clean && npm run check:exports-stories && npm run build:css && tsc && node scripts/fix-esm-imports.mjs",
36
64
  "storybook": "npm run build:css && storybook dev -p 6006",
65
+ "test": "vitest run",
37
66
  "build-storybook": "npm run check:exports-stories && npm run build:css && storybook build",
38
67
  "typecheck": "tsc --noEmit -p tsconfig.json",
39
- "check:exports-stories": "node scripts/check-exports-and-stories.mjs"
68
+ "check:exports-stories": "node scripts/check-exports-and-stories.mjs",
69
+ "check": "npm run check:tokens && npm run typecheck && npm run check:exports-stories && npm test",
70
+ "prepack": "npm run build"
40
71
  },
41
72
  "peerDependencies": {
42
- "react": "^19.0.0",
43
- "react-dom": "^19.0.0"
73
+ "react": "^18.2.0 || ^19.0.0",
74
+ "react-dom": "^18.2.0 || ^19.0.0"
44
75
  },
45
76
  "dependencies": {
46
77
  "@radix-ui/react-collapsible": "^1.1.14",
47
78
  "@radix-ui/react-context-menu": "^2.2.16",
48
79
  "@radix-ui/react-dropdown-menu": "^2.1.18",
49
80
  "@radix-ui/react-label": "^2.1.10",
81
+ "@radix-ui/react-popover": "^1.1.23",
82
+ "@radix-ui/react-select": "^2.3.7",
50
83
  "@radix-ui/react-separator": "^1.1.10",
84
+ "@radix-ui/react-tooltip": "^1.2.16",
51
85
  "@tanstack/react-table": "^8.21.3",
52
86
  "clsx": "^2.1.1",
53
87
  "lucide-react": "^0.563.0",