@cladd-ui/react 0.0.1 → 0.0.2

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 (241) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1 -1
  3. package/components/Backdrop.d.ts +8 -0
  4. package/components/Backdrop.d.ts.map +1 -0
  5. package/components/Backdrop.js +7 -0
  6. package/components/Backdrop.js.map +1 -0
  7. package/components/BlockTitle.d.ts +10 -0
  8. package/components/BlockTitle.d.ts.map +1 -0
  9. package/components/BlockTitle.js +7 -0
  10. package/components/BlockTitle.js.map +1 -0
  11. package/components/Button.d.ts +61 -0
  12. package/components/Button.d.ts.map +1 -0
  13. package/components/Button.js +83 -0
  14. package/components/Button.js.map +1 -0
  15. package/components/Checkbox.d.ts +57 -0
  16. package/components/Checkbox.d.ts.map +1 -0
  17. package/components/Checkbox.js +48 -0
  18. package/components/Checkbox.js.map +1 -0
  19. package/components/Chip.d.ts +47 -0
  20. package/components/Chip.d.ts.map +1 -0
  21. package/components/Chip.js +55 -0
  22. package/components/Chip.js.map +1 -0
  23. package/components/Dialog.d.ts +118 -0
  24. package/components/Dialog.d.ts.map +1 -0
  25. package/components/Dialog.js +178 -0
  26. package/components/Dialog.js.map +1 -0
  27. package/components/DialogsPortal.d.ts +2 -0
  28. package/components/DialogsPortal.d.ts.map +1 -0
  29. package/components/DialogsPortal.js +17 -0
  30. package/components/DialogsPortal.js.map +1 -0
  31. package/components/DialogsPortalContext.d.ts +49 -0
  32. package/components/DialogsPortalContext.d.ts.map +1 -0
  33. package/components/DialogsPortalContext.js +17 -0
  34. package/components/DialogsPortalContext.js.map +1 -0
  35. package/components/FocusableLayer.d.ts +25 -0
  36. package/components/FocusableLayer.d.ts.map +1 -0
  37. package/components/FocusableLayer.js +18 -0
  38. package/components/FocusableLayer.js.map +1 -0
  39. package/components/Input.d.ts +87 -0
  40. package/components/Input.d.ts.map +1 -0
  41. package/components/Input.js +93 -0
  42. package/components/Input.js.map +1 -0
  43. package/components/Link.d.ts +28 -0
  44. package/components/Link.d.ts.map +1 -0
  45. package/components/Link.js +21 -0
  46. package/components/Link.js.map +1 -0
  47. package/components/List.d.ts +8 -0
  48. package/components/List.d.ts.map +1 -0
  49. package/components/List.js +7 -0
  50. package/components/List.js.map +1 -0
  51. package/components/ListButton.d.ts +61 -0
  52. package/components/ListButton.d.ts.map +1 -0
  53. package/components/ListButton.js +9 -0
  54. package/components/ListButton.js.map +1 -0
  55. package/components/ListItem.d.ts +8 -0
  56. package/components/ListItem.d.ts.map +1 -0
  57. package/components/ListItem.js +7 -0
  58. package/components/ListItem.js.map +1 -0
  59. package/components/ListSeparator.d.ts +8 -0
  60. package/components/ListSeparator.d.ts.map +1 -0
  61. package/components/ListSeparator.js +7 -0
  62. package/components/ListSeparator.js.map +1 -0
  63. package/components/ModalController.d.ts +26 -0
  64. package/components/ModalController.d.ts.map +1 -0
  65. package/components/ModalController.js +52 -0
  66. package/components/ModalController.js.map +1 -0
  67. package/components/NumberField.d.ts +49 -0
  68. package/components/NumberField.d.ts.map +1 -0
  69. package/components/NumberField.js +34 -0
  70. package/components/NumberField.js.map +1 -0
  71. package/components/Popover.d.ts +137 -0
  72. package/components/Popover.d.ts.map +1 -0
  73. package/components/Popover.js +366 -0
  74. package/components/Popover.js.map +1 -0
  75. package/components/Popup.d.ts +120 -0
  76. package/components/Popup.d.ts.map +1 -0
  77. package/components/Popup.js +235 -0
  78. package/components/Popup.js.map +1 -0
  79. package/components/PopupContent.d.ts +19 -0
  80. package/components/PopupContent.d.ts.map +1 -0
  81. package/components/PopupContent.js +8 -0
  82. package/components/PopupContent.js.map +1 -0
  83. package/components/Preloader.d.ts +12 -0
  84. package/components/Preloader.d.ts.map +1 -0
  85. package/components/Preloader.js +30 -0
  86. package/components/Preloader.js.map +1 -0
  87. package/components/Radio.d.ts +53 -0
  88. package/components/Radio.d.ts.map +1 -0
  89. package/components/Radio.js +46 -0
  90. package/components/Radio.js.map +1 -0
  91. package/components/Range.d.ts +35 -0
  92. package/components/Range.d.ts.map +1 -0
  93. package/components/Range.js +76 -0
  94. package/components/Range.js.map +1 -0
  95. package/components/Searchbar.d.ts +29 -0
  96. package/components/Searchbar.d.ts.map +1 -0
  97. package/components/Searchbar.js +10 -0
  98. package/components/Searchbar.js.map +1 -0
  99. package/components/Segmented.d.ts +39 -0
  100. package/components/Segmented.d.ts.map +1 -0
  101. package/components/Segmented.js +26 -0
  102. package/components/Segmented.js.map +1 -0
  103. package/components/SegmentedButton.d.ts +13 -0
  104. package/components/SegmentedButton.d.ts.map +1 -0
  105. package/components/SegmentedButton.js +10 -0
  106. package/components/SegmentedButton.js.map +1 -0
  107. package/components/SegmentedContext.d.ts +36 -0
  108. package/components/SegmentedContext.d.ts.map +1 -0
  109. package/components/SegmentedContext.js +10 -0
  110. package/components/SegmentedContext.js.map +1 -0
  111. package/components/Select.d.ts +145 -0
  112. package/components/Select.d.ts.map +1 -0
  113. package/components/Select.js +316 -0
  114. package/components/Select.js.map +1 -0
  115. package/components/Surface.d.ts +67 -0
  116. package/components/Surface.d.ts.map +1 -0
  117. package/components/Surface.js +36 -0
  118. package/components/Surface.js.map +1 -0
  119. package/components/SurfaceContent.d.ts +8 -0
  120. package/components/SurfaceContent.d.ts.map +1 -0
  121. package/components/SurfaceContent.js +7 -0
  122. package/components/SurfaceContent.js.map +1 -0
  123. package/components/SurfaceContext.d.ts +19 -0
  124. package/components/SurfaceContext.d.ts.map +1 -0
  125. package/components/SurfaceContext.js +9 -0
  126. package/components/SurfaceContext.js.map +1 -0
  127. package/components/SurfaceCut.d.ts +33 -0
  128. package/components/SurfaceCut.d.ts.map +1 -0
  129. package/components/SurfaceCut.js +17 -0
  130. package/components/SurfaceCut.js.map +1 -0
  131. package/components/SurfaceCutContent.d.ts +16 -0
  132. package/components/SurfaceCutContent.d.ts.map +1 -0
  133. package/components/SurfaceCutContent.js +8 -0
  134. package/components/SurfaceCutContent.js.map +1 -0
  135. package/components/TextArea.d.ts +61 -0
  136. package/components/TextArea.d.ts.map +1 -0
  137. package/components/TextArea.js +102 -0
  138. package/components/TextArea.js.map +1 -0
  139. package/components/ThemeContext.d.ts +23 -0
  140. package/components/ThemeContext.d.ts.map +1 -0
  141. package/components/ThemeContext.js +18 -0
  142. package/components/ThemeContext.js.map +1 -0
  143. package/components/Toast.d.ts +89 -0
  144. package/components/Toast.d.ts.map +1 -0
  145. package/components/Toast.js +129 -0
  146. package/components/Toast.js.map +1 -0
  147. package/components/ToastsPortal.d.ts +2 -0
  148. package/components/ToastsPortal.d.ts.map +1 -0
  149. package/components/ToastsPortal.js +17 -0
  150. package/components/ToastsPortal.js.map +1 -0
  151. package/components/ToastsPortalContext.d.ts +45 -0
  152. package/components/ToastsPortalContext.d.ts.map +1 -0
  153. package/components/ToastsPortalContext.js +17 -0
  154. package/components/ToastsPortalContext.js.map +1 -0
  155. package/components/Toggle.d.ts +69 -0
  156. package/components/Toggle.d.ts.map +1 -0
  157. package/components/Toggle.js +48 -0
  158. package/components/Toggle.js.map +1 -0
  159. package/components/Tooltip.d.ts +48 -0
  160. package/components/Tooltip.d.ts.map +1 -0
  161. package/components/Tooltip.js +90 -0
  162. package/components/Tooltip.js.map +1 -0
  163. package/components/UIProvider.d.ts +16 -0
  164. package/components/UIProvider.d.ts.map +1 -0
  165. package/components/UIProvider.js +11 -0
  166. package/components/UIProvider.js.map +1 -0
  167. package/components/WithTooltip.d.ts +36 -0
  168. package/components/WithTooltip.d.ts.map +1 -0
  169. package/components/WithTooltip.js +138 -0
  170. package/components/WithTooltip.js.map +1 -0
  171. package/components/icons/CheckIcon.d.ts +2 -0
  172. package/components/icons/CheckIcon.d.ts.map +1 -0
  173. package/components/icons/CheckIcon.js +5 -0
  174. package/components/icons/CheckIcon.js.map +1 -0
  175. package/components/icons/CloseIcon.d.ts +2 -0
  176. package/components/icons/CloseIcon.d.ts.map +1 -0
  177. package/components/icons/CloseIcon.js +3 -0
  178. package/components/icons/CloseIcon.js.map +1 -0
  179. package/components/icons/DropdownIcon.d.ts +2 -0
  180. package/components/icons/DropdownIcon.d.ts.map +1 -0
  181. package/components/icons/DropdownIcon.js +3 -0
  182. package/components/icons/DropdownIcon.js.map +1 -0
  183. package/components/icons/SearchIcon.d.ts +2 -0
  184. package/components/icons/SearchIcon.d.ts.map +1 -0
  185. package/components/icons/SearchIcon.js +5 -0
  186. package/components/icons/SearchIcon.js.map +1 -0
  187. package/hooks/use-accent-color.d.ts +2 -0
  188. package/hooks/use-accent-color.d.ts.map +1 -0
  189. package/hooks/use-accent-color.js +6 -0
  190. package/hooks/use-accent-color.js.map +1 -0
  191. package/hooks/use-device.d.ts +14 -0
  192. package/hooks/use-device.d.ts.map +1 -0
  193. package/hooks/use-device.js +68 -0
  194. package/hooks/use-device.js.map +1 -0
  195. package/hooks/use-dialog.d.ts +8 -0
  196. package/hooks/use-dialog.d.ts.map +1 -0
  197. package/hooks/use-dialog.js +38 -0
  198. package/hooks/use-dialog.js.map +1 -0
  199. package/hooks/use-focus-trap.d.ts +9 -0
  200. package/hooks/use-focus-trap.d.ts.map +1 -0
  201. package/hooks/use-focus-trap.js +106 -0
  202. package/hooks/use-focus-trap.js.map +1 -0
  203. package/hooks/use-modal-utils.d.ts +17 -0
  204. package/hooks/use-modal-utils.d.ts.map +1 -0
  205. package/hooks/use-modal-utils.js +110 -0
  206. package/hooks/use-modal-utils.js.map +1 -0
  207. package/hooks/use-surface.d.ts +2 -0
  208. package/hooks/use-surface.d.ts.map +1 -0
  209. package/hooks/use-surface.js +6 -0
  210. package/hooks/use-surface.js.map +1 -0
  211. package/hooks/use-theme.d.ts +2 -0
  212. package/hooks/use-theme.d.ts.map +1 -0
  213. package/hooks/use-theme.js +6 -0
  214. package/hooks/use-theme.js.map +1 -0
  215. package/hooks/use-toast.d.ts +3 -0
  216. package/hooks/use-toast.d.ts.map +1 -0
  217. package/hooks/use-toast.js +21 -0
  218. package/hooks/use-toast.js.map +1 -0
  219. package/index.d.ts +42 -0
  220. package/index.d.ts.map +1 -0
  221. package/index.js +42 -0
  222. package/index.js.map +1 -0
  223. package/package.json +27 -9
  224. package/shared/cn.d.ts +3 -0
  225. package/shared/cn.d.ts.map +1 -0
  226. package/shared/cn.js +6 -0
  227. package/shared/cn.js.map +1 -0
  228. package/shared/next-tick.d.ts +2 -0
  229. package/shared/next-tick.d.ts.map +1 -0
  230. package/shared/next-tick.js +6 -0
  231. package/shared/next-tick.js.map +1 -0
  232. package/styles/colors.css +403 -0
  233. package/styles/popup.css +14 -0
  234. package/styles/preloader.css +71 -0
  235. package/styles/range.css +17 -0
  236. package/styles/safe-areas.css +192 -0
  237. package/types.d.ts +2 -0
  238. package/types.d.ts.map +1 -0
  239. package/types.js +2 -0
  240. package/types.js.map +1 -0
  241. package/ui.css +10 -0
@@ -0,0 +1,316 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { Fragment, useEffect, useId, useRef, useState, } from 'react';
3
+ import { useDevice } from '../hooks/use-device';
4
+ import { useTheme } from '../hooks/use-theme';
5
+ import { cn } from '../shared/cn';
6
+ import { BlockTitle } from './BlockTitle';
7
+ import { Button, buttonIconSizes } from './Button';
8
+ import { Checkbox } from './Checkbox';
9
+ import { DropdownIcon } from './icons/DropdownIcon';
10
+ import { List } from './List';
11
+ import { ListButton } from './ListButton';
12
+ import { Popover } from './Popover';
13
+ import { Radio } from './Radio';
14
+ import { Searchbar } from './Searchbar';
15
+ export function Select(props) {
16
+ const theme = useTheme();
17
+ const { value = '', placeholder = '', title = '', options = [], multiple, disabled, readOnly,
18
+ // STYLING
19
+ color, rounded, size = 'md', className, contentClassName, valueClassName, surface, reverse, icon, dropdownIcon = true, multiline, placeholderClassName = '',
20
+ // CONTENT
21
+ children, beforeOptions, afterOptions,
22
+ // SEARCH RELATED PROPS
23
+ search, searchPlaceholder = 'Search', searchNotFound = 'Nothing found', searchFocus, onSearch,
24
+ // POPOVER RELATED PROPS
25
+ popoverColor, popoverPosition = 'bottom-end', popoverOffset = ['-50%', 4], popoverClassName = 'w-auto min-w-[160px]', popoverSurfaceLevel = theme === 'dark' ? '+1' : 1, anchorRef: elRefExternal, popoverState: popoverStateExternal, onPopoverState: setPopoverStateExternal,
26
+ // CALLBACKS
27
+ onChange = () => { }, onClick = () => { },
28
+ // OPTIONS
29
+ keyboardHints = true, togglesColor, optionToggleColor = () => undefined, isChecked, isOptionDisabled, getOptionValue = (option) => option, getOptionByValue, renderBeforeOption, renderAfterOption, renderOption = ({ value }) => String(value), renderOptionInfo,
30
+ /** Value of the "none/initial" option that should be mapped to the 0 key.
31
+ * If set, this option gets hint "0" and remaining options get 1-9 in order.
32
+ * If not set, straight ordering: 1, 2, 3, ..., 9, 0 (for 10th). */
33
+ noneOptionValue,
34
+ // FUNCTIONALITY
35
+ closeOnSelect = true, scrollToSelected, ref, ...rest } = props;
36
+ const elRef = useRef(null);
37
+ const listElRef = useRef(null);
38
+ const searchbarRef = useRef(null);
39
+ const device = useDevice();
40
+ const reactId = useId();
41
+ const listboxId = `select-listbox-${reactId}`;
42
+ const optionIdPrefix = `select-option-${reactId}`;
43
+ const [searchQuery, setSearchQuery] = useState('');
44
+ const [popoverState, setPopoverState] = useState(false);
45
+ const [selectedItemIndex, setSelectedItemIndex] = useState(-1);
46
+ const onChangeInternal = (optionValue, checked) => {
47
+ if (!multiple) {
48
+ onChange(getOptionValue(optionValue));
49
+ }
50
+ else {
51
+ const newValues = getOptionByValue
52
+ ? [...value].map((opt) => getOptionValue(opt))
53
+ : [...value];
54
+ if (checked)
55
+ newValues.push(getOptionValue(optionValue));
56
+ else if (newValues.includes(getOptionValue(optionValue))) {
57
+ newValues.splice(newValues.indexOf(getOptionValue(optionValue)), 1);
58
+ }
59
+ onChange(getOptionByValue
60
+ ? newValues.map((optValue) => getOptionByValue(options, optValue))
61
+ : newValues);
62
+ }
63
+ if (!multiple && closeOnSelect) {
64
+ if (setPopoverStateExternal)
65
+ setPopoverStateExternal(false);
66
+ else
67
+ setPopoverState(false);
68
+ }
69
+ };
70
+ const InputComponent = multiple ? Checkbox : Radio;
71
+ const displayOptions = search && onSearch ? onSearch(searchQuery) : options;
72
+ const getOptionIsChecked = (optionValue) => {
73
+ if (isChecked)
74
+ return isChecked(optionValue);
75
+ const optKey = getOptionValue(optionValue);
76
+ if (multiple) {
77
+ const arr = value ?? [];
78
+ if (getOptionByValue) {
79
+ return arr.some((v) => getOptionValue(v) === optKey);
80
+ }
81
+ return arr.includes(optKey);
82
+ }
83
+ if (getOptionByValue && value !== undefined && value !== '') {
84
+ return getOptionValue(value) === optKey;
85
+ }
86
+ return value === optKey;
87
+ };
88
+ const effectivePopoverState = popoverStateExternal ?? popoverState;
89
+ const scrollPopoverToElement = (scrollToEl, dir) => {
90
+ if (!scrollToEl && scrollToSelected && listElRef.current) {
91
+ const checkedEl = listElRef.current.querySelector('input[checked]');
92
+ if (!checkedEl)
93
+ return;
94
+ const labelEl = checkedEl.closest('label');
95
+ if (!labelEl)
96
+ return;
97
+ labelEl.scrollIntoView({ block: 'center' });
98
+ }
99
+ else if (scrollToEl && listElRef.current) {
100
+ const scrollEl = scrollToEl.closest('.overflow-auto');
101
+ if (!scrollEl)
102
+ return;
103
+ if (dir === 'up') {
104
+ if (scrollEl.scrollTop > scrollToEl.offsetTop) {
105
+ scrollToEl.scrollIntoView({
106
+ block: 'start',
107
+ behavior: 'smooth',
108
+ });
109
+ }
110
+ }
111
+ else {
112
+ if (scrollEl.scrollTop + scrollEl.offsetHeight < scrollToEl.offsetTop) {
113
+ scrollToEl.scrollIntoView({
114
+ block: 'end',
115
+ behavior: 'smooth',
116
+ });
117
+ }
118
+ }
119
+ }
120
+ };
121
+ const focusSearchOnOpened = () => {
122
+ if (searchFocus && searchbarRef.current) {
123
+ if (device.ios || device.android)
124
+ return;
125
+ const input = searchbarRef.current.querySelector('input');
126
+ if (input)
127
+ input.focus();
128
+ }
129
+ };
130
+ const onKeyDown = (e) => {
131
+ if (device.mobile)
132
+ return;
133
+ if (!effectivePopoverState)
134
+ return;
135
+ // Numeric quick-pick: 0-9 selects the corresponding option
136
+ // Skip when search input is focused so digits can be typed
137
+ if (keyboardHints &&
138
+ /^[0-9]$/.test(e.key) &&
139
+ !searchbarRef.current?.querySelector('input:focus')) {
140
+ e.preventDefault();
141
+ const digit = parseInt(e.key);
142
+ let targetIndex = -1;
143
+ if (noneOptionValue !== undefined) {
144
+ // Semantic mode: 0 = none/initial option, 1-9 = other options in order
145
+ if (digit === 0) {
146
+ targetIndex = displayOptions.findIndex((o) => getOptionValue(o) === noneOptionValue);
147
+ }
148
+ else {
149
+ let rank = 0;
150
+ for (let i = 0; i < displayOptions.length; i++) {
151
+ if (getOptionValue(displayOptions[i]) !== noneOptionValue) {
152
+ rank++;
153
+ if (rank === digit) {
154
+ targetIndex = i;
155
+ break;
156
+ }
157
+ }
158
+ }
159
+ }
160
+ }
161
+ else {
162
+ // Straight mode: 1=first, 2=second, ..., 9=ninth, 0=tenth
163
+ targetIndex = digit === 0 ? 9 : digit - 1;
164
+ }
165
+ if (targetIndex >= 0 && targetIndex < displayOptions.length) {
166
+ if (!multiple) {
167
+ onChangeInternal(displayOptions[targetIndex], true);
168
+ }
169
+ else {
170
+ onChangeInternal(displayOptions[targetIndex], !getOptionIsChecked(displayOptions[targetIndex]));
171
+ }
172
+ }
173
+ return;
174
+ }
175
+ if (e.key !== 'ArrowUp' &&
176
+ e.key !== 'Tab' &&
177
+ e.key !== 'ArrowDown' &&
178
+ e.key !== 'Enter' &&
179
+ e.key !== ' ') {
180
+ return;
181
+ }
182
+ const maxIndex = displayOptions.length - 1;
183
+ const minIndex = 0;
184
+ let newIndex = selectedItemIndex;
185
+ if (selectedItemIndex < 0) {
186
+ newIndex = displayOptions.findIndex(getOptionIsChecked);
187
+ }
188
+ let dir;
189
+ if (e.key === 'ArrowUp' || (e.key === 'Tab' && e.shiftKey)) {
190
+ dir = 'up';
191
+ newIndex -= 1;
192
+ e.preventDefault();
193
+ if (newIndex < minIndex) {
194
+ dir = 'down';
195
+ newIndex = maxIndex;
196
+ }
197
+ }
198
+ if (e.key === 'ArrowDown' || (e.key === 'Tab' && !e.shiftKey)) {
199
+ dir = 'down';
200
+ newIndex += 1;
201
+ e.preventDefault();
202
+ if (newIndex > maxIndex) {
203
+ dir = 'up';
204
+ newIndex = 0;
205
+ }
206
+ }
207
+ if (e.key === 'ArrowUp' || e.key === 'ArrowDown' || e.key === 'Tab') {
208
+ setSelectedItemIndex(newIndex);
209
+ if (listElRef.current) {
210
+ const el = listElRef.current.querySelectorAll('.list label')[newIndex];
211
+ if (el) {
212
+ el.focus();
213
+ scrollPopoverToElement(el, dir);
214
+ }
215
+ }
216
+ }
217
+ if ((e.key === 'Enter' || e.key === ' ') && selectedItemIndex >= 0) {
218
+ if (document.activeElement === searchbarRef.current?.querySelector('input')) {
219
+ return; // Don't select option when pressing Enter/Space in search input
220
+ }
221
+ e.preventDefault();
222
+ if (!multiple) {
223
+ onChangeInternal(displayOptions[selectedItemIndex], true);
224
+ }
225
+ else {
226
+ onChangeInternal(displayOptions[selectedItemIndex], !getOptionIsChecked(displayOptions[selectedItemIndex]));
227
+ }
228
+ }
229
+ };
230
+ const onPopoverOpen = () => {
231
+ scrollPopoverToElement();
232
+ };
233
+ const onPopoverOpened = () => {
234
+ focusSearchOnOpened();
235
+ };
236
+ const onPopoverClosed = () => {
237
+ setSelectedItemIndex(-1);
238
+ if (!device.mobile && elRef.current) {
239
+ elRef.current.focus();
240
+ }
241
+ };
242
+ useEffect(() => {
243
+ if (effectivePopoverState) {
244
+ setSearchQuery('');
245
+ }
246
+ }, [effectivePopoverState]);
247
+ useEffect(() => {
248
+ document.addEventListener('keydown', onKeyDown);
249
+ return () => {
250
+ document.removeEventListener('keydown', onKeyDown);
251
+ };
252
+ });
253
+ return (_jsxs(_Fragment, { children: [!elRefExternal && (_jsx(Button, { className: cn('select w-full', className), ref: (el) => {
254
+ elRef.current = el;
255
+ if (ref && typeof ref === 'function')
256
+ ref(el);
257
+ else if (ref && typeof ref === 'object')
258
+ ref.current = el;
259
+ }, size: size, rounded: rounded, color: color, disabled: disabled, multiline: multiline, surface: surface, readOnly: readOnly, role: "combobox", "aria-haspopup": "listbox", "aria-expanded": effectivePopoverState, "aria-controls": effectivePopoverState ? listboxId : undefined, "aria-activedescendant": effectivePopoverState && selectedItemIndex >= 0
260
+ ? `${optionIdPrefix}-${selectedItemIndex}`
261
+ : undefined, "aria-disabled": disabled || undefined, "aria-readonly": readOnly || undefined, onClick: (e) => {
262
+ onClick(e);
263
+ const currentState = popoverStateExternal ?? popoverState;
264
+ if (setPopoverStateExternal)
265
+ setPopoverStateExternal(!currentState);
266
+ else
267
+ setPopoverState(!currentState);
268
+ }, contentClassName: cn(dropdownIcon && 'pr-1.5'), ...rest, children: _jsxs("div", { className: cn('flex w-full min-w-0 shrink items-center justify-between gap-2', reverse && 'flex-row-reverse', contentClassName), children: [icon && _jsx("div", { className: buttonIconSizes[size], children: icon }), _jsx("div", { className: cn('w-full min-w-0 shrink', !children && !String(value) && 'text-on-surface-darker', placeholderClassName, valueClassName), children: children || String(value) || placeholder }), dropdownIcon && (_jsx(DropdownIcon, { className: cn('size-4', 'shrink-0 text-on-surface-darker') }))] }) })), !readOnly && !disabled && (_jsxs(Popover, { open: popoverStateExternal || popoverState, onOpenChange: setPopoverStateExternal || setPopoverState, anchorRef: elRefExternal || elRef, position: popoverPosition, offset: popoverOffset, color: popoverColor, surfaceLevel: popoverSurfaceLevel, className: popoverClassName, onOpen: onPopoverOpen, onOpened: onPopoverOpened, onClosed: onPopoverClosed, onClick: (e) => e.stopPropagation(), children: [title && _jsx(BlockTitle, { className: "px-4 pt-4", children: title }), search && (_jsx(Searchbar, { value: searchQuery, placeholder: searchPlaceholder, inset: !!title, ref: searchbarRef, className: cn(title && 'mt-2'), onChange: setSearchQuery })), beforeOptions, _jsxs(List, { ref: listElRef, id: listboxId, role: "listbox", "aria-multiselectable": multiple || undefined, children: [search && onSearch && searchQuery && !displayOptions.length && (_jsx("div", { className: cn('mb-2 flex h-8 w-full items-center pr-4 pl-4 text-xs font-medium text-on-surface-darker'), children: searchNotFound })), displayOptions.map((optionValue, optionIndex) => (_jsxs(Fragment, { children: [renderBeforeOption &&
269
+ renderBeforeOption(optionValue, optionIndex), _jsx(ListButton, { selected: optionIndex === selectedItemIndex, component: "label", contentClassName: "pl-1", disabled: isOptionDisabled && isOptionDisabled(optionValue), outline: false, rounded: true, id: `${optionIdPrefix}-${optionIndex}`, role: "option", "aria-selected": getOptionIsChecked(optionValue), "aria-disabled": (isOptionDisabled && isOptionDisabled(optionValue)) ||
270
+ undefined, children: _jsxs("div", { className: "flex w-full items-center gap-3", children: [_jsx(InputComponent, { component: "div", className: "shrink-0", focusable: false, hoverable: false, input: !isOptionDisabled || !isOptionDisabled(optionValue), color: optionToggleColor({
271
+ value: optionValue,
272
+ index: options.indexOf(optionValue),
273
+ selected: getOptionIsChecked(optionValue),
274
+ }) || togglesColor, disabled: isOptionDisabled && isOptionDisabled(optionValue), checked: getOptionIsChecked(optionValue), onChange: (checked) => onChangeInternal(optionValue, checked) }), _jsxs("div", { className: cn('w-full min-w-0 shrink'), children: [renderOption({
275
+ value: optionValue,
276
+ index: options.indexOf(optionValue),
277
+ selected: getOptionIsChecked(optionValue),
278
+ }), renderOptionInfo &&
279
+ renderOptionInfo({
280
+ value: optionValue,
281
+ index: options.indexOf(optionValue),
282
+ selected: getOptionIsChecked(optionValue),
283
+ }) && (_jsx("div", { className: "text-xs font-normal text-on-surface-dark", children: renderOptionInfo({
284
+ value: optionValue,
285
+ index: options.indexOf(optionValue),
286
+ selected: getOptionIsChecked(optionValue),
287
+ }) }))] }), keyboardHints &&
288
+ displayOptions.length > 1 &&
289
+ !device.mobile &&
290
+ (() => {
291
+ let hint = null;
292
+ if (noneOptionValue !== undefined) {
293
+ if (getOptionValue(optionValue) === noneOptionValue) {
294
+ hint = 0;
295
+ }
296
+ else {
297
+ let rank = 0;
298
+ for (let i = 0; i <= optionIndex; i++) {
299
+ if (getOptionValue(displayOptions[i]) !==
300
+ noneOptionValue)
301
+ rank++;
302
+ }
303
+ hint = rank <= 9 ? rank : null;
304
+ }
305
+ }
306
+ else {
307
+ if (optionIndex < 9)
308
+ hint = optionIndex + 1;
309
+ else if (optionIndex === 9)
310
+ hint = 0;
311
+ }
312
+ return hint !== null ? (_jsx("span", { className: "ml-auto shrink-0 font-mono text-[11px] font-normal text-on-surface-darker tabular-nums", children: hint })) : null;
313
+ })()] }) }), renderAfterOption &&
314
+ renderAfterOption(optionValue, optionIndex)] }, options.indexOf(optionValue))))] }), afterOptions] }))] }));
315
+ }
316
+ //# sourceMappingURL=Select.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Select.js","sourceRoot":"","sources":["../../../src/components/Select.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,QAAQ,EACR,SAAS,EACT,KAAK,EACL,MAAM,EACN,QAAQ,GAIT,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,EAAE,EAAE,MAAM,cAAc,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,eAAe,EAAc,MAAM,UAAU,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAkC,MAAM,WAAW,CAAC;AACpE,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAoKxC,MAAM,UAAU,MAAM,CAAa,KAAqB;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ACN,IAAI,IAAI,GAAG,CAAC,CAAC;gEACb,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,WAAW,EAAE,CAAC,EAAE,EAAE,CAAC;oEACtC,IACE,cAAc,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC;wEACjC,eAAe;wEAEf,IAAI,EAAE,CAAC;gEACX,CAAC;gEACD,IAAI,GAAG,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;4DACjC,CAAC;wDACH,CAAC;6DAAM,CAAC;4DACN,IAAI,WAAW,GAAG,CAAC;gEAAE,IAAI,GAAG,WAAW,GAAG,CAAC,CAAC;iEACvC,IAAI,WAAW,KAAK,CAAC;gEAAE,IAAI,GAAG,CAAC,CAAC;wDACvC,CAAC;wDACD,OAAO,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,CACrB,eAAM,SAAS,EAAC,wFAAwF,YACrG,IAAI,GACA,CACR,CAAC,CAAC,CAAC,IAAI,CAAC;oDACX,CAAC,CAAC,EAAE,IACF,GACK,EACZ,iBAAiB;wCAChB,iBAAiB,CAAC,WAAW,EAAE,WAAW,CAAC,KA/FhC,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,CAgGhC,CACZ,CAAC,IACG,EACN,YAAY,IACL,CACX,IACA,CACJ,CAAC;AACJ,CAAC"}
@@ -0,0 +1,67 @@
1
+ import { ReactNode, Ref, ElementType, ComponentPropsWithoutRef } from 'react';
2
+ import { Color } from '../types';
3
+ export type SurfaceVariant = 'transparent' | 'solid' | 'gradient' | 'solid-fill' | 'gradient-fill';
4
+ interface SurfaceOwnProps<C extends ElementType = 'div'> {
5
+ /**
6
+ * Surface depth level (1–5). Drives the background tone via `surface-level-N` classes
7
+ * and propagates to nested surfaces through `SurfaceContext`.
8
+ *
9
+ * Accepts:
10
+ * - An absolute number/string (e.g. `2`, `"3"`).
11
+ * - A relative offset against the parent context level (e.g. `"+1"`, `"-1"`).
12
+ * - `undefined` (default): one level deeper than the parent context.
13
+ *
14
+ * Result is clamped to `[1, 5]`. For `variant="transparent"`, children inherit
15
+ * `currentLevel - 1` so they appear at the same depth as this surface.
16
+ */
17
+ level?: number | string;
18
+ /** Surface content. */
19
+ children?: ReactNode;
20
+ /** Extra classes for the root element. */
21
+ className?: string;
22
+ /** Extra classes for the absolutely-positioned background layer (the tinted/outlined fill behind content). */
23
+ bgClassName?: string;
24
+ /** Extra classes for the inner `SurfaceContent` wrapper. Ignored when `wrapContent` is `false`. */
25
+ contentClassName?: string;
26
+ /** Render a 1px outline ring around the surface. Uses fill-aware token when `variant` ends in `-fill`. */
27
+ outline?: boolean;
28
+ /**
29
+ * Visual treatment of the surface background:
30
+ * - `transparent` - no background; children render at the parent level (used for nested groupings).
31
+ * - `solid` - flat surface fill (default).
32
+ * - `gradient` - diagonal highlight→surface gradient.
33
+ * - `solid-fill` - flat primary/accent fill (text inverts to `text-on-primary`).
34
+ * - `gradient-fill` - diagonal accent gradient (text inverts).
35
+ */
36
+ variant?: SurfaceVariant;
37
+ /**
38
+ * Polymorphic root element. Defaults to `'div'`. Use `'button'`, `'a'`, etc. when the
39
+ * surface is itself the interactive target (forwarding props of that element).
40
+ */
41
+ component?: C;
42
+ /** Enables active/pressed visual states (scale + pressed background). Combine with `hoverable`. */
43
+ clickable?: boolean;
44
+ /** Force the pressed visual state regardless of pointer activity (controlled press). */
45
+ pressed?: boolean;
46
+ /** Enables hover background overlay. For `variant="transparent"`, also reveals the surface fill on hover. */
47
+ hoverable?: boolean;
48
+ /** Accent color token. Sets the surface's `color-{name}` class - drives accent-aware borders, fills, and text colors. */
49
+ color?: Color;
50
+ /**
51
+ * Slot rendered between the background layer and the content wrapper, **outside** the
52
+ * `SurfaceContent` flex layout (e.g. `FocusableLayer`, decorative overlays).
53
+ */
54
+ beforeContent?: ReactNode;
55
+ /**
56
+ * When `true` (default), `children` are rendered inside a `SurfaceContent` flex wrapper
57
+ * styled by `contentClassName`. Set to `false` to render `children` directly - useful
58
+ * when the surface is the layout root and you want full control of the inner DOM.
59
+ */
60
+ wrapContent?: boolean;
61
+ /** Forwarded to the polymorphic root element. */
62
+ ref?: Ref<HTMLElement>;
63
+ }
64
+ export type SurfaceProps<C extends ElementType = 'div'> = SurfaceOwnProps<C> & Omit<ComponentPropsWithoutRef<C>, keyof SurfaceOwnProps<C>>;
65
+ export declare const Surface: <C extends ElementType = "div">(props: SurfaceProps<C>) => import("react/jsx-runtime").JSX.Element;
66
+ export {};
67
+ //# sourceMappingURL=Surface.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Surface.d.ts","sourceRoot":"","sources":["../../../src/components/Surface.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,WAAW,EAAE,wBAAwB,EAAE,MAAM,OAAO,CAAC;AAI9E,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAIjC,MAAM,MAAM,cAAc,GACtB,aAAa,GACb,OAAO,GACP,UAAU,GACV,YAAY,GACZ,eAAe,CAAC;AAEpB,UAAU,eAAe,CAAC,CAAC,SAAS,WAAW,GAAG,KAAK;IACrD;;;;;;;;;;;OAWG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB,uBAAuB;IACvB,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,0CAA0C;IAC1C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,8GAA8G;IAC9G,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,mGAAmG;IACnG,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,0GAA0G;IAC1G,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;;;;;OAOG;IACH,OAAO,CAAC,EAAE,cAAc,CAAC;IACzB;;;OAGG;IACH,SAAS,CAAC,EAAE,CAAC,CAAC;IACd,mGAAmG;IACnG,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,wFAAwF;IACxF,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,6GAA6G;IAC7G,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,yHAAyH;IACzH,KAAK,CAAC,EAAE,KAAK,CAAC;IACd;;;OAGG;IACH,aAAa,CAAC,EAAE,SAAS,CAAC;IAC1B;;;;OAIG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,iDAAiD;IACjD,GAAG,CAAC,EAAE,GAAG,CAAC,WAAW,CAAC,CAAC;CACxB;AAED,MAAM,MAAM,YAAY,CAAC,CAAC,SAAS,WAAW,GAAG,KAAK,IAAI,eAAe,CAAC,CAAC,CAAC,GAC1E,IAAI,CAAC,wBAAwB,CAAC,CAAC,CAAC,EAAE,MAAM,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;AAE9D,eAAO,MAAM,OAAO,GAAI,CAAC,SAAS,WAAW,GAAG,KAAK,EACnD,OAAO,YAAY,CAAC,CAAC,CAAC,4CA2HvB,CAAC"}
@@ -0,0 +1,36 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useSurface } from '../hooks/use-surface';
3
+ import { cn } from '../shared/cn';
4
+ import { SurfaceContent } from './SurfaceContent';
5
+ import { SurfaceContextProvider } from './SurfaceContext';
6
+ export const Surface = (props) => {
7
+ const MAX_LEVEL = 5;
8
+ const { level, children, className = '', contentClassName = '', bgClassName = '', outline = false, variant = 'solid', component = 'div', clickable = false, pressed, hoverable = false, color = '', wrapContent = true, beforeContent, ref, ...rest } = props;
9
+ const contextLevel = useSurface();
10
+ let levelProp = level;
11
+ if (typeof levelProp === 'string' &&
12
+ (levelProp.includes('+') || levelProp.includes('-'))) {
13
+ if (levelProp.includes('+'))
14
+ levelProp = contextLevel + parseInt(levelProp, 10);
15
+ else
16
+ levelProp = contextLevel + parseInt(levelProp, 10);
17
+ }
18
+ const currentLevel = Math.max(1, Math.min(typeof levelProp === 'undefined' ? contextLevel + 1 : Number(levelProp), MAX_LEVEL));
19
+ const Component = component;
20
+ const isFill = variant === 'solid-fill' || variant === 'gradient-fill';
21
+ return (_jsxs(Component, { className: cn('surface relative', isFill ? 'text-on-primary' : 'text-on-surface', (clickable || hoverable) && 'group/surface', `surface-level-${currentLevel}`, color && `color-${color}`, className), ref: ref, ...rest, children: [_jsx("div", { className: cn('pointer-events-none absolute inset-0 rounded-[inherit]', variant === 'solid' && 'bg-surface', variant === 'solid-fill' && 'bg-primary', variant === 'gradient' &&
22
+ 'bg-linear-to-br from-surface-highlight to-surface', variant === 'gradient-fill' &&
23
+ 'bg-linear-to-br from-primary to-primary/85 light:from-primary/80 light:to-primary', outline &&
24
+ cn(isFill ? 'shadow-surface-outline-fill' : 'shadow-surface-outline'), variant === 'transparent' &&
25
+ hoverable &&
26
+ 'duration-200 group-hover/surface:bg-surface', hoverable && clickable && 'group-active/surface:bg-surface', bgClassName), children: (hoverable || clickable) && (_jsx("div", { className: cn('absolute inset-0 rounded-[inherit] opacity-0 duration-200', hoverable &&
27
+ !pressed &&
28
+ cn('group-hover/surface:opacity-100', isFill
29
+ ? 'group-hover/surface:bg-surface-hover-fill'
30
+ : 'group-hover/surface:bg-surface-hover'), clickable &&
31
+ (pressed
32
+ ? 'bg-surface-pressed opacity-100'
33
+ : 'group-active/surface:bg-surface-pressed group-active/surface:opacity-100')) })) }), _jsxs(SurfaceContextProvider, { level: variant === 'transparent' ? currentLevel - 1 : currentLevel, children: [beforeContent, wrapContent ? (_jsx(SurfaceContent, { className: cn('duration-200', clickable &&
34
+ 'group-active/surface:scale-95 group-active/surface:opacity-75', contentClassName), children: children })) : (children)] })] }));
35
+ };
36
+ //# sourceMappingURL=Surface.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Surface.js","sourceRoot":"","sources":["../../../src/components/Surface.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,EAAE,EAAE,MAAM,cAAc,CAAC;AAElC,OAAO,EAAE,cAAc,EAAE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ACb,KAAC,cAAc,IACb,SAAS,EAAE,EAAE,CACX,cAAc,EACd,SAAS;4BACP,+DAA+D,EACjE,gBAAgB,CACjB,YAEA,QAAQ,GACM,CAClB,CAAC,CAAC,CAAC,CACF,QAAQ,CACT,IACsB,IACf,CACb,CAAC;AACJ,CAAC,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { ReactNode, Ref, HTMLAttributes } from 'react';
2
+ export interface SurfaceContentProps extends HTMLAttributes<HTMLDivElement> {
3
+ children?: ReactNode;
4
+ className?: string;
5
+ ref?: Ref<HTMLDivElement>;
6
+ }
7
+ export declare const SurfaceContent: (props: SurfaceContentProps) => import("react/jsx-runtime").JSX.Element;
8
+ //# sourceMappingURL=SurfaceContent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SurfaceContent.d.ts","sourceRoot":"","sources":["../../../src/components/SurfaceContent.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAIvD,MAAM,WAAW,mBAAoB,SAAQ,cAAc,CAAC,cAAc,CAAC;IACzE,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,GAAG,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;CAC3B;AAED,eAAO,MAAM,cAAc,GAAI,OAAO,mBAAmB,4CAOxD,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { cn } from '../shared/cn';
3
+ export const SurfaceContent = (props) => {
4
+ const { children, className = '', ref, ...rest } = props;
5
+ return (_jsx("div", { ref: ref, className: cn(`relative h-full`, className), ...rest, children: children }));
6
+ };
7
+ //# sourceMappingURL=SurfaceContent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SurfaceContent.js","sourceRoot":"","sources":["../../../src/components/SurfaceContent.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,EAAE,EAAE,MAAM,cAAc,CAAC;AAQlC,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,KAA0B,EAAE,EAAE;IAC3D,MAAM,EAAE,QAAQ,EAAE,SAAS,GAAG,EAAE,EAAE,GAAG,EAAE,GAAG,IAAI,EAAE,GAAG,KAAK,CAAC;IACzD,OAAO,CACL,cAAK,GAAG,EAAE,GAAG,EAAE,SAAS,EAAE,EAAE,CAAC,iBAAiB,EAAE,SAAS,CAAC,KAAM,IAAI,YACjE,QAAQ,GACL,CACP,CAAC;AACJ,CAAC,CAAC"}
@@ -0,0 +1,19 @@
1
+ import { ReactNode } from 'react';
2
+ /**
3
+ * Tracks the surface depth of the current React subtree. Each `Surface` publishes its own
4
+ * level (or `currentLevel - 1` for `variant="transparent"`) so nested surfaces can resolve
5
+ * relative levels (e.g. `"+1"`/`"-1"`) and pick appropriate background tones.
6
+ */
7
+ interface SurfaceContextValue {
8
+ /** Current surface depth (1–5). `0` outside any `Surface`. */
9
+ level: number;
10
+ }
11
+ interface SurfaceContextProviderProps {
12
+ /** Surface depth published to descendants. */
13
+ level: number;
14
+ children: ReactNode;
15
+ }
16
+ export declare const SurfaceContext: import("react").Context<SurfaceContextValue>;
17
+ export declare function SurfaceContextProvider(props: SurfaceContextProviderProps): import("react/jsx-runtime").JSX.Element;
18
+ export {};
19
+ //# sourceMappingURL=SurfaceContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SurfaceContext.d.ts","sourceRoot":"","sources":["../../../src/components/SurfaceContext.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAiB,SAAS,EAAE,MAAM,OAAO,CAAC;AAEjD;;;;GAIG;AACH,UAAU,mBAAmB;IAC3B,8DAA8D;IAC9D,KAAK,EAAE,MAAM,CAAC;CACf;AAED,UAAU,2BAA2B;IACnC,8CAA8C;IAC9C,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED,eAAO,MAAM,cAAc,8CAEzB,CAAC;AAEH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,2BAA2B,2CAMxE"}
@@ -0,0 +1,9 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { createContext } from 'react';
3
+ export const SurfaceContext = createContext({
4
+ level: 0,
5
+ });
6
+ export function SurfaceContextProvider(props) {
7
+ return (_jsx(SurfaceContext.Provider, { value: { level: props.level }, children: props.children }));
8
+ }
9
+ //# sourceMappingURL=SurfaceContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SurfaceContext.js","sourceRoot":"","sources":["../../../src/components/SurfaceContext.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAa,MAAM,OAAO,CAAC;AAkBjD,MAAM,CAAC,MAAM,cAAc,GAAG,aAAa,CAAsB;IAC/D,KAAK,EAAE,CAAC;CACT,CAAC,CAAC;AAEH,MAAM,UAAU,sBAAsB,CAAC,KAAkC;IACvE,OAAO,CACL,KAAC,cAAc,CAAC,QAAQ,IAAC,KAAK,EAAE,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,YACnD,KAAK,CAAC,QAAQ,GACS,CAC3B,CAAC;AACJ,CAAC"}
@@ -0,0 +1,33 @@
1
+ import { ReactNode, Ref, ElementType, ComponentPropsWithoutRef } from 'react';
2
+ import { Color } from '../types';
3
+ interface SurfaceCutOwnProps<C extends ElementType = 'div'> {
4
+ /** Surface-cut content. */
5
+ children?: ReactNode;
6
+ /** Extra classes for the root element. */
7
+ className?: string;
8
+ /** Render the inset outline ring. Default `true`. */
9
+ outline?: boolean;
10
+ /** Accent color token. Sets the surface's `color-{name}` class. */
11
+ color?: Color;
12
+ /** Show hover overlay on the cut surface. Default `false`. */
13
+ hoverable?: boolean;
14
+ /** Enable active/pressed visual states (scale + pressed background). Default `false`. */
15
+ clickable?: boolean;
16
+ /** Force the pressed visual state regardless of pointer activity. */
17
+ pressed?: boolean;
18
+ /** Polymorphic root element. Defaults to `'div'`. */
19
+ component?: C;
20
+ /**
21
+ * When `true` (default), `children` are wrapped in `SurfaceCutContent`. Set to `false`
22
+ * to render `children` directly when you need full layout control of the inner DOM.
23
+ */
24
+ wrapContent?: boolean;
25
+ /** Extra classes for the inner `SurfaceCutContent` wrapper. Ignored when `wrapContent` is `false`. */
26
+ contentClassName?: string;
27
+ /** Forwarded to the polymorphic root element. */
28
+ ref?: Ref<HTMLElement>;
29
+ }
30
+ export type SurfaceCutProps<C extends ElementType = 'div'> = SurfaceCutOwnProps<C> & Omit<ComponentPropsWithoutRef<C>, keyof SurfaceCutOwnProps<C>>;
31
+ export declare const SurfaceCut: <C extends ElementType = "div">(props: SurfaceCutProps<C>) => import("react/jsx-runtime").JSX.Element;
32
+ export {};
33
+ //# sourceMappingURL=SurfaceCut.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SurfaceCut.d.ts","sourceRoot":"","sources":["../../../src/components/SurfaceCut.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,WAAW,EAAE,wBAAwB,EAAE,MAAM,OAAO,CAAC;AAI9E,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAIjC,UAAU,kBAAkB,CAAC,CAAC,SAAS,WAAW,GAAG,KAAK;IACxD,2BAA2B;IAC3B,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,0CAA0C;IAC1C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,qDAAqD;IACrD,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,mEAAmE;IACnE,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,8DAA8D;IAC9D,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,yFAAyF;IACzF,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,qEAAqE;IACrE,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,qDAAqD;IACrD,SAAS,CAAC,EAAE,CAAC,CAAC;IACd;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,sGAAsG;IACtG,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,iDAAiD;IACjD,GAAG,CAAC,EAAE,GAAG,CAAC,WAAW,CAAC,CAAC;CACxB;AAED,MAAM,MAAM,eAAe,CAAC,CAAC,SAAS,WAAW,GAAG,KAAK,IACvD,kBAAkB,CAAC,CAAC,CAAC,GACnB,IAAI,CAAC,wBAAwB,CAAC,CAAC,CAAC,EAAE,MAAM,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC;AAEnE,eAAO,MAAM,UAAU,GAAI,CAAC,SAAS,WAAW,GAAG,KAAK,EACtD,OAAO,eAAe,CAAC,CAAC,CAAC,4CAuE1B,CAAC"}
@@ -0,0 +1,17 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useSurface } from '../hooks/use-surface';
3
+ import { cn } from '../shared/cn';
4
+ import { SurfaceContextProvider } from './SurfaceContext';
5
+ import { SurfaceCutContent } from './SurfaceCutContent';
6
+ export const SurfaceCut = (props) => {
7
+ const { children, className = '', outline = true, color, hoverable = false, clickable = false, pressed = false, component = 'div', wrapContent = true, contentClassName = '', ref, ...rest } = props;
8
+ const Component = component;
9
+ const contextLevel = useSurface();
10
+ return (_jsxs(Component, { className: cn('surface-cut group/surface-cut relative', hoverable && 'group/surface-cut-hoverable', color && `color-${color}`, className), ...rest, ref: ref, children: [_jsx("div", { className: cn(`pointer-events-none absolute inset-0 rounded-[inherit] bg-surface-cut`, outline && 'shadow-surface-cut-outline'), children: (hoverable || clickable) && (_jsx("div", { className: cn('absolute inset-0 rounded-[inherit] opacity-0 duration-200', hoverable &&
11
+ 'group-hover/surface-cut-hoverable:bg-surface-hover group-hover/surface-cut-hoverable:opacity-100', clickable &&
12
+ (pressed
13
+ ? 'bg-surface-pressed opacity-100'
14
+ : 'group-active/surface-cut:bg-surface-pressed group-active/surface-cut:opacity-100')) })) }), _jsx(SurfaceContextProvider, { level: contextLevel - 1, children: wrapContent ? (_jsx(SurfaceCutContent, { className: cn(clickable &&
15
+ 'duration-200 group-active/surface-cut:scale-95 group-active/surface-cut:opacity-75', contentClassName), children: children })) : (children) })] }));
16
+ };
17
+ //# sourceMappingURL=SurfaceCut.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SurfaceCut.js","sourceRoot":"","sources":["../../../src/components/SurfaceCut.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,EAAE,EAAE,MAAM,cAAc,CAAC;AAElC,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAkCxD,MAAM,CAAC,MAAM,UAAU,GAAG,CACxB,KAAyB,EACzB,EAAE;IACF,MAAM,EACJ,QAAQ,EACR,SAAS,GAAG,EAAE,EACd,OAAO,GAAG,IAAI,EACd,KAAK,EACL,SAAS,GAAG,KAAK,EACjB,SAAS,GAAG,KAAK,EACjB,OAAO,GAAG,KAAK,EACf,SAAS,GAAG,KAAK,EACjB,WAAW,GAAG,IAAI,EAClB,gBAAgB,GAAG,EAAE,EACrB,GAAG,EACH,GAAG,IAAI,EACR,GAAG,KAAK,CAAC;IAEV,MAAM,SAAS,GAAG,SAAwB,CAAC;IAE3C,MAAM,YAAY,GAAG,UAAU,EAAE,CAAC;IAElC,OAAO,CACL,MAAC,SAAS,IACR,SAAS,EAAE,EAAE,CACX,wCAAwC,EACxC,SAAS,IAAI,6BAA6B,EAC1C,KAAK,IAAI,SAAS,KAAK,EAAE,EACzB,SAAS,CACV,KACG,IAAI,EACR,GAAG,EAAE,GAAG,aAGR,cACE,SAAS,EAAE,EAAE,CACX,uEAAuE,EACvE,OAAO,IAAI,4BAA4B,CACxC,YAGA,CAAC,SAAS,IAAI,SAAS,CAAC,IAAI,CAC3B,cACE,SAAS,EAAE,EAAE,CACX,2DAA2D,EAC3D,SAAS;wBACP,kGAAkG,EACpG,SAAS;wBACP,CAAC,OAAO;4BACN,CAAC,CAAC,gCAAgC;4BAClC,CAAC,CAAC,kFAAkF,CAAC,CAC1F,GACD,CACH,GACG,EACN,KAAC,sBAAsB,IAAC,KAAK,EAAE,YAAY,GAAG,CAAC,YAC5C,WAAW,CAAC,CAAC,CAAC,CACb,KAAC,iBAAiB,IAChB,SAAS,EAAE,EAAE,CACX,SAAS;wBACP,oFAAoF,EACtF,gBAAgB,CACjB,YAEA,QAAQ,GACS,CACrB,CAAC,CAAC,CAAC,CACF,QAAQ,CACT,GACsB,IACf,CACb,CAAC;AACJ,CAAC,CAAC"}
@@ -0,0 +1,16 @@
1
+ import { ReactNode, Ref, ElementType, ComponentPropsWithoutRef } from 'react';
2
+ interface SurfaceCutContentOwnProps<C extends ElementType = 'div'> {
3
+ children?: ReactNode;
4
+ /** Stretch the content to `h-full`. Default `true`. Set `false` for content sized by intrinsic height. */
5
+ fullHeight?: boolean;
6
+ /** Polymorphic root element. Defaults to `'div'`. */
7
+ component?: C;
8
+ /** Extra classes for the wrapper. */
9
+ className?: string;
10
+ /** Forwarded to the polymorphic root element. */
11
+ ref?: Ref<HTMLElement>;
12
+ }
13
+ export type SurfaceCutContentProps<C extends ElementType = 'div'> = SurfaceCutContentOwnProps<C> & Omit<ComponentPropsWithoutRef<C>, keyof SurfaceCutContentOwnProps<C>>;
14
+ export declare const SurfaceCutContent: <C extends ElementType = "div">(props: SurfaceCutContentProps<C>) => import("react/jsx-runtime").JSX.Element;
15
+ export {};
16
+ //# sourceMappingURL=SurfaceCutContent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SurfaceCutContent.d.ts","sourceRoot":"","sources":["../../../src/components/SurfaceCutContent.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,WAAW,EAAE,wBAAwB,EAAE,MAAM,OAAO,CAAC;AAI9E,UAAU,yBAAyB,CAAC,CAAC,SAAS,WAAW,GAAG,KAAK;IAC/D,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,0GAA0G;IAC1G,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,qDAAqD;IACrD,SAAS,CAAC,EAAE,CAAC,CAAC;IACd,qCAAqC;IACrC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,iDAAiD;IACjD,GAAG,CAAC,EAAE,GAAG,CAAC,WAAW,CAAC,CAAC;CACxB;AAED,MAAM,MAAM,sBAAsB,CAAC,CAAC,SAAS,WAAW,GAAG,KAAK,IAC9D,yBAAyB,CAAC,CAAC,CAAC,GAC1B,IAAI,CAAC,wBAAwB,CAAC,CAAC,CAAC,EAAE,MAAM,yBAAyB,CAAC,CAAC,CAAC,CAAC,CAAC;AAE1E,eAAO,MAAM,iBAAiB,GAAI,CAAC,SAAS,WAAW,GAAG,KAAK,EAC7D,OAAO,sBAAsB,CAAC,CAAC,CAAC,4CAoBjC,CAAC"}