@proyecto-viviana/ui 0.1.7 → 0.2.0

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 (130) hide show
  1. package/README.md +192 -0
  2. package/dist/autocomplete/index.d.ts +89 -0
  3. package/dist/autocomplete/index.d.ts.map +1 -0
  4. package/dist/breadcrumbs/index.d.ts +38 -0
  5. package/dist/breadcrumbs/index.d.ts.map +1 -0
  6. package/dist/button/Button.d.ts.map +1 -1
  7. package/dist/calendar/DateField.d.ts +47 -0
  8. package/dist/calendar/DateField.d.ts.map +1 -0
  9. package/dist/calendar/DatePicker.d.ts +48 -0
  10. package/dist/calendar/DatePicker.d.ts.map +1 -0
  11. package/dist/calendar/RangeCalendar.d.ts +42 -0
  12. package/dist/calendar/RangeCalendar.d.ts.map +1 -0
  13. package/dist/calendar/TimeField.d.ts +44 -0
  14. package/dist/calendar/TimeField.d.ts.map +1 -0
  15. package/dist/calendar/index.d.ts +50 -0
  16. package/dist/calendar/index.d.ts.map +1 -0
  17. package/dist/checkbox/index.d.ts.map +1 -1
  18. package/dist/color/index.d.ts +228 -0
  19. package/dist/color/index.d.ts.map +1 -0
  20. package/dist/combobox/index.d.ts +81 -0
  21. package/dist/combobox/index.d.ts.map +1 -0
  22. package/dist/components.css +116 -14
  23. package/dist/custom/chip/index.d.ts +7 -2
  24. package/dist/custom/chip/index.d.ts.map +1 -1
  25. package/dist/custom/event-card/index.d.ts +5 -1
  26. package/dist/custom/event-card/index.d.ts.map +1 -1
  27. package/dist/custom/header/index.d.ts +16 -0
  28. package/dist/custom/header/index.d.ts.map +1 -0
  29. package/dist/custom/logo/index.d.ts +2 -0
  30. package/dist/custom/logo/index.d.ts.map +1 -1
  31. package/dist/custom/page-layout/index.d.ts +2 -0
  32. package/dist/custom/page-layout/index.d.ts.map +1 -1
  33. package/dist/custom/profile-card/index.d.ts +5 -1
  34. package/dist/custom/profile-card/index.d.ts.map +1 -1
  35. package/dist/custom/timeline-item/index.d.ts +12 -2
  36. package/dist/custom/timeline-item/index.d.ts.map +1 -1
  37. package/dist/dialog/Dialog.d.ts +67 -0
  38. package/dist/dialog/Dialog.d.ts.map +1 -0
  39. package/dist/dialog/index.d.ts +2 -17
  40. package/dist/dialog/index.d.ts.map +1 -1
  41. package/dist/disclosure/index.d.ts +84 -0
  42. package/dist/disclosure/index.d.ts.map +1 -0
  43. package/dist/gridlist/index.d.ts +92 -0
  44. package/dist/gridlist/index.d.ts.map +1 -0
  45. package/dist/index.d.ts +58 -4
  46. package/dist/index.d.ts.map +1 -1
  47. package/dist/index.js +6984 -783
  48. package/dist/index.js.map +1 -1
  49. package/dist/index.ssr.js +5905 -571
  50. package/dist/index.ssr.js.map +1 -1
  51. package/dist/landmark/index.d.ts +83 -0
  52. package/dist/landmark/index.d.ts.map +1 -0
  53. package/dist/link/index.d.ts.map +1 -1
  54. package/dist/listbox/index.d.ts +47 -0
  55. package/dist/listbox/index.d.ts.map +1 -0
  56. package/dist/menu/index.d.ts +74 -0
  57. package/dist/menu/index.d.ts.map +1 -0
  58. package/dist/meter/index.d.ts +49 -0
  59. package/dist/meter/index.d.ts.map +1 -0
  60. package/dist/numberfield/index.d.ts +50 -0
  61. package/dist/numberfield/index.d.ts.map +1 -0
  62. package/dist/popover/index.d.ts +85 -0
  63. package/dist/popover/index.d.ts.map +1 -0
  64. package/dist/radio/index.d.ts +7 -4
  65. package/dist/radio/index.d.ts.map +1 -1
  66. package/dist/searchfield/index.d.ts +44 -0
  67. package/dist/searchfield/index.d.ts.map +1 -0
  68. package/dist/select/index.d.ts +72 -0
  69. package/dist/select/index.d.ts.map +1 -0
  70. package/dist/slider/index.d.ts +53 -0
  71. package/dist/slider/index.d.ts.map +1 -0
  72. package/dist/switch/ToggleSwitch.d.ts.map +1 -1
  73. package/dist/table/index.d.ts +140 -0
  74. package/dist/table/index.d.ts.map +1 -0
  75. package/dist/tabs/index.d.ts +56 -0
  76. package/dist/tabs/index.d.ts.map +1 -0
  77. package/dist/tag-group/index.d.ts +80 -0
  78. package/dist/tag-group/index.d.ts.map +1 -0
  79. package/dist/toast/index.d.ts +101 -0
  80. package/dist/toast/index.d.ts.map +1 -0
  81. package/dist/toolbar/index.d.ts +42 -0
  82. package/dist/toolbar/index.d.ts.map +1 -0
  83. package/dist/tooltip/index.d.ts +66 -5
  84. package/dist/tooltip/index.d.ts.map +1 -1
  85. package/dist/tree/index.d.ts +99 -0
  86. package/dist/tree/index.d.ts.map +1 -0
  87. package/package.json +66 -58
  88. package/src/autocomplete/index.tsx +313 -0
  89. package/src/breadcrumbs/index.tsx +207 -0
  90. package/src/button/Button.tsx +74 -75
  91. package/src/calendar/DateField.tsx +200 -0
  92. package/src/calendar/DatePicker.tsx +298 -0
  93. package/src/calendar/RangeCalendar.tsx +236 -0
  94. package/src/calendar/TimeField.tsx +196 -0
  95. package/src/calendar/index.tsx +223 -0
  96. package/src/checkbox/index.tsx +3 -4
  97. package/src/color/index.tsx +687 -0
  98. package/src/combobox/index.tsx +383 -0
  99. package/src/components.css +116 -14
  100. package/src/custom/chip/index.tsx +17 -3
  101. package/src/custom/event-card/index.tsx +8 -2
  102. package/src/custom/header/index.tsx +33 -0
  103. package/src/custom/logo/index.tsx +7 -3
  104. package/src/custom/page-layout/index.tsx +12 -3
  105. package/src/custom/profile-card/index.tsx +8 -2
  106. package/src/custom/timeline-item/index.tsx +28 -4
  107. package/src/dialog/Dialog.tsx +260 -0
  108. package/src/dialog/index.tsx +3 -69
  109. package/src/disclosure/index.tsx +307 -0
  110. package/src/gridlist/index.tsx +403 -0
  111. package/src/index.ts +219 -4
  112. package/src/landmark/index.tsx +231 -0
  113. package/src/link/index.tsx +1 -2
  114. package/src/listbox/index.tsx +231 -0
  115. package/src/menu/index.tsx +297 -0
  116. package/src/meter/index.tsx +163 -0
  117. package/src/numberfield/index.tsx +482 -0
  118. package/src/popover/index.tsx +260 -0
  119. package/src/radio/index.tsx +36 -82
  120. package/src/searchfield/index.tsx +453 -0
  121. package/src/select/index.tsx +349 -0
  122. package/src/slider/index.tsx +382 -0
  123. package/src/switch/ToggleSwitch.tsx +1 -2
  124. package/src/table/index.tsx +531 -0
  125. package/src/tabs/index.tsx +273 -0
  126. package/src/tag-group/index.tsx +240 -0
  127. package/src/toast/index.tsx +324 -0
  128. package/src/toolbar/index.tsx +108 -0
  129. package/src/tooltip/index.tsx +171 -5
  130. package/src/tree/index.tsx +494 -0
package/package.json CHANGED
@@ -1,58 +1,66 @@
1
- {
2
- "name": "@proyecto-viviana/ui",
3
- "version": "0.1.7",
4
- "description": "Styled UI components for SolidJS - inspired by React Spectrum",
5
- "type": "module",
6
- "main": "./dist/index.ssr.js",
7
- "module": "./dist/index.js",
8
- "types": "./dist/index.d.ts",
9
- "exports": {
10
- ".": {
11
- "types": "./dist/index.d.ts",
12
- "solid": "./src/index.ts",
13
- "browser": "./dist/index.js",
14
- "import": "./dist/index.js",
15
- "default": "./dist/index.js"
16
- },
17
- "./theme.css": "./dist/theme.css",
18
- "./styles.css": "./dist/styles.css",
19
- "./components.css": "./dist/components.css"
20
- },
21
- "files": [
22
- "dist",
23
- "src"
24
- ],
25
- "sideEffects": [
26
- "*.css"
27
- ],
28
- "scripts": {
29
- "build": "tsup && tsc -p tsconfig.build.json",
30
- "dev": "tsup --watch",
31
- "prepublishOnly": "bun run build"
32
- },
33
- "dependencies": {
34
- "@proyecto-viviana/solidaria": "^0.0.2",
35
- "@proyecto-viviana/solidaria-components": "^0.0.2"
36
- },
37
- "peerDependencies": {
38
- "solid-js": "^1.9.0"
39
- },
40
- "devDependencies": {
41
- "solid-js": "^1.9.10"
42
- },
43
- "keywords": [
44
- "solid",
45
- "solidjs",
46
- "ui",
47
- "components",
48
- "design-system"
49
- ],
50
- "license": "MIT",
51
- "repository": {
52
- "type": "git",
53
- "url": "https://github.com/proyecto-viviana/proyecto-viviana"
54
- },
55
- "publishConfig": {
56
- "access": "public"
57
- }
58
- }
1
+ {
2
+ "name": "@proyecto-viviana/ui",
3
+ "version": "0.2.0",
4
+ "description": "Styled UI components for SolidJS - inspired by React Spectrum",
5
+ "type": "module",
6
+ "main": "./dist/index.ssr.js",
7
+ "module": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "solid": "./src/index.ts",
13
+ "import": "./dist/index.js",
14
+ "default": "./dist/index.js"
15
+ },
16
+ "./theme.css": {
17
+ "import": "./dist/theme.css",
18
+ "default": "./src/theme.css"
19
+ },
20
+ "./styles.css": {
21
+ "import": "./dist/styles.css",
22
+ "default": "./src/styles.css"
23
+ },
24
+ "./components.css": {
25
+ "import": "./dist/components.css",
26
+ "default": "./src/components.css"
27
+ }
28
+ },
29
+ "files": [
30
+ "dist",
31
+ "src"
32
+ ],
33
+ "sideEffects": [
34
+ "*.css"
35
+ ],
36
+ "scripts": {
37
+ "build": "tsup && rm -f tsconfig.build.tsbuildinfo && tsc -p tsconfig.build.json",
38
+ "dev": "tsup --watch",
39
+ "prepublishOnly": "bun run build"
40
+ },
41
+ "dependencies": {
42
+ "@proyecto-viviana/solidaria": "workspace:*",
43
+ "@proyecto-viviana/solidaria-components": "workspace:*"
44
+ },
45
+ "peerDependencies": {
46
+ "solid-js": "^1.9.0"
47
+ },
48
+ "devDependencies": {
49
+ "solid-js": "^1.9.10"
50
+ },
51
+ "keywords": [
52
+ "solid",
53
+ "solidjs",
54
+ "ui",
55
+ "components",
56
+ "design-system"
57
+ ],
58
+ "license": "MIT",
59
+ "repository": {
60
+ "type": "git",
61
+ "url": "https://github.com/proyecto-viviana/proyecto-viviana"
62
+ },
63
+ "publishConfig": {
64
+ "access": "public"
65
+ }
66
+ }
@@ -0,0 +1,313 @@
1
+ /**
2
+ * SearchAutocomplete component for proyecto-viviana-ui
3
+ *
4
+ * A styled autocomplete component combining a search input with a
5
+ * filterable dropdown list of options.
6
+ */
7
+
8
+ import { type JSX, splitProps, createMemo, Show, For, createSignal } from 'solid-js'
9
+ import {
10
+ Autocomplete,
11
+ useAutocompleteInput,
12
+ useAutocompleteCollection,
13
+ useAutocompleteState,
14
+ } from '@proyecto-viviana/solidaria-components'
15
+
16
+ // ============================================
17
+ // TYPES
18
+ // ============================================
19
+
20
+ export type SearchAutocompleteSize = 'sm' | 'md' | 'lg'
21
+
22
+ export interface SearchAutocompleteItem {
23
+ id: string
24
+ name: string
25
+ [key: string]: unknown
26
+ }
27
+
28
+ export interface SearchAutocompleteProps<T extends SearchAutocompleteItem = SearchAutocompleteItem> {
29
+ /** The items to display in the dropdown. */
30
+ items: T[]
31
+ /** The size of the autocomplete. @default 'md' */
32
+ size?: SearchAutocompleteSize
33
+ /** Placeholder text for the input. */
34
+ placeholder?: string
35
+ /** Accessible label for the input. */
36
+ 'aria-label'?: string
37
+ /** Label text shown above the input. */
38
+ label?: string
39
+ /** Description text shown below the input. */
40
+ description?: string
41
+ /** The current input value (controlled). */
42
+ inputValue?: string
43
+ /** The default input value (uncontrolled). */
44
+ defaultInputValue?: string
45
+ /** Handler called when the input value changes. */
46
+ onInputChange?: (value: string) => void
47
+ /** Handler called when an item is selected. */
48
+ onSelect?: (item: T) => void
49
+ /** Additional CSS class name. */
50
+ class?: string
51
+ /** Whether the input is disabled. */
52
+ isDisabled?: boolean
53
+ /**
54
+ * Custom filter function. By default, filters by case-insensitive name match.
55
+ */
56
+ filter?: (textValue: string, inputValue: string) => boolean
57
+ /**
58
+ * Custom render function for items.
59
+ */
60
+ renderItem?: (item: T) => JSX.Element
61
+ /**
62
+ * Key to use for the display text. @default 'name'
63
+ */
64
+ textKey?: keyof T
65
+ }
66
+
67
+ // ============================================
68
+ // STYLES
69
+ // ============================================
70
+
71
+ const sizeStyles = {
72
+ sm: {
73
+ container: 'text-sm',
74
+ input: 'h-8 px-3 text-sm',
75
+ label: 'text-xs mb-1',
76
+ list: 'max-h-48',
77
+ item: 'px-3 py-1.5 text-sm',
78
+ },
79
+ md: {
80
+ container: 'text-base',
81
+ input: 'h-10 px-4 text-base',
82
+ label: 'text-sm mb-1.5',
83
+ list: 'max-h-64',
84
+ item: 'px-4 py-2 text-base',
85
+ },
86
+ lg: {
87
+ container: 'text-lg',
88
+ input: 'h-12 px-5 text-lg',
89
+ label: 'text-base mb-2',
90
+ list: 'max-h-80',
91
+ item: 'px-5 py-2.5 text-lg',
92
+ },
93
+ }
94
+
95
+ // ============================================
96
+ // INNER COMPONENTS
97
+ // ============================================
98
+
99
+ function AutocompleteInput(props: {
100
+ placeholder?: string
101
+ 'aria-label'?: string
102
+ isDisabled?: boolean
103
+ size: SearchAutocompleteSize
104
+ }) {
105
+ const ctx = useAutocompleteInput()
106
+ if (!ctx) return null
107
+
108
+ const styles = () => sizeStyles[props.size]
109
+
110
+ return (
111
+ <input
112
+ ref={ctx.inputRef}
113
+ type="text"
114
+ placeholder={props.placeholder}
115
+ aria-label={props['aria-label']}
116
+ disabled={props.isDisabled}
117
+ value={ctx.inputProps.value()}
118
+ onInput={(e) => ctx.inputProps.onChange(e.currentTarget.value)}
119
+ onKeyDown={ctx.inputProps.onKeyDown}
120
+ onFocus={ctx.inputProps.onFocus}
121
+ onBlur={ctx.inputProps.onBlur}
122
+ aria-activedescendant={ctx.inputProps['aria-activedescendant']()}
123
+ aria-controls={ctx.inputProps['aria-controls']}
124
+ aria-autocomplete={ctx.inputProps['aria-autocomplete']}
125
+ autocomplete={ctx.inputProps.autoComplete}
126
+ autocorrect={ctx.inputProps.autoCorrect}
127
+ spellcheck={ctx.inputProps.spellCheck !== 'false'}
128
+ class={[
129
+ 'w-full rounded-md border border-bg-200 bg-bg-50',
130
+ 'focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-primary-500',
131
+ 'placeholder:text-text-400',
132
+ 'disabled:opacity-50 disabled:cursor-not-allowed',
133
+ styles().input,
134
+ ].join(' ')}
135
+ />
136
+ )
137
+ }
138
+
139
+ function AutocompleteList<T extends SearchAutocompleteItem>(props: {
140
+ items: T[]
141
+ size: SearchAutocompleteSize
142
+ onSelect?: (item: T) => void
143
+ renderItem?: (item: T) => JSX.Element
144
+ textKey: keyof T
145
+ }) {
146
+ const ctx = useAutocompleteCollection()
147
+ const state = useAutocompleteState()
148
+ if (!ctx) return null
149
+
150
+ const styles = () => sizeStyles[props.size]
151
+
152
+ // Filter items based on input
153
+ const filteredItems = createMemo(() => {
154
+ if (!ctx.filter) return props.items
155
+ return props.items.filter((item) => {
156
+ const textValue = String(item[props.textKey] ?? item.name ?? '')
157
+ return ctx.filter!(textValue)
158
+ })
159
+ })
160
+
161
+ const handleSelect = (item: T) => {
162
+ props.onSelect?.(item)
163
+ state?.setInputValue(String(item[props.textKey] ?? item.name ?? ''))
164
+ }
165
+
166
+ return (
167
+ <Show when={filteredItems().length > 0}>
168
+ <ul
169
+ ref={ctx.collectionRef}
170
+ id={ctx.collectionProps.id}
171
+ role="listbox"
172
+ aria-label={ctx.collectionProps['aria-label']}
173
+ class={[
174
+ 'mt-1 w-full rounded-md border border-bg-200 bg-bg-50 shadow-lg',
175
+ 'overflow-auto',
176
+ styles().list,
177
+ ].join(' ')}
178
+ >
179
+ <For each={filteredItems()}>
180
+ {(item) => {
181
+ const itemId = `autocomplete-item-${item.id}`
182
+ const isFocused = () => state?.focusedNodeId() === itemId
183
+
184
+ return (
185
+ <li
186
+ id={itemId}
187
+ role="option"
188
+ aria-selected={isFocused()}
189
+ onClick={() => handleSelect(item)}
190
+ onMouseEnter={() => state?.setFocusedNodeId(itemId)}
191
+ onMouseLeave={() => {
192
+ if (state?.focusedNodeId() === itemId) {
193
+ state?.setFocusedNodeId(null)
194
+ }
195
+ }}
196
+ class={[
197
+ 'cursor-pointer transition-colors',
198
+ isFocused()
199
+ ? 'bg-primary-100 text-primary-900'
200
+ : 'hover:bg-bg-100',
201
+ styles().item,
202
+ ].join(' ')}
203
+ >
204
+ {props.renderItem ? props.renderItem(item) : String(item[props.textKey] ?? item.name)}
205
+ </li>
206
+ )
207
+ }}
208
+ </For>
209
+ </ul>
210
+ </Show>
211
+ )
212
+ }
213
+
214
+ // ============================================
215
+ // SEARCH AUTOCOMPLETE COMPONENT
216
+ // ============================================
217
+
218
+ /**
219
+ * A styled autocomplete component for searching and selecting from a list.
220
+ *
221
+ * @example
222
+ * ```tsx
223
+ * const items = [
224
+ * { id: '1', name: 'Apple' },
225
+ * { id: '2', name: 'Banana' },
226
+ * { id: '3', name: 'Cherry' },
227
+ * ];
228
+ *
229
+ * <SearchAutocomplete
230
+ * items={items}
231
+ * placeholder="Search fruits..."
232
+ * aria-label="Fruit search"
233
+ * onSelect={(item) => console.log('Selected:', item)}
234
+ * />
235
+ *
236
+ * // With custom filter
237
+ * <SearchAutocomplete
238
+ * items={items}
239
+ * filter={(textValue, inputValue) =>
240
+ * textValue.toLowerCase().startsWith(inputValue.toLowerCase())
241
+ * }
242
+ * onSelect={(item) => console.log('Selected:', item)}
243
+ * />
244
+ *
245
+ * // With label and description
246
+ * <SearchAutocomplete
247
+ * items={items}
248
+ * label="Search"
249
+ * description="Type to filter the list"
250
+ * placeholder="Start typing..."
251
+ * />
252
+ * ```
253
+ */
254
+ export function SearchAutocomplete<T extends SearchAutocompleteItem = SearchAutocompleteItem>(
255
+ props: SearchAutocompleteProps<T>
256
+ ): JSX.Element {
257
+ const [local, autocompleteProps] = splitProps(props, [
258
+ 'items',
259
+ 'size',
260
+ 'placeholder',
261
+ 'aria-label',
262
+ 'label',
263
+ 'description',
264
+ 'onSelect',
265
+ 'class',
266
+ 'isDisabled',
267
+ 'renderItem',
268
+ 'textKey',
269
+ ])
270
+
271
+ const size = () => local.size ?? 'md'
272
+ const textKey = () => local.textKey ?? 'name'
273
+ const styles = () => sizeStyles[size()]
274
+
275
+ // Default filter: case-insensitive contains
276
+ const defaultFilter = (textValue: string, inputValue: string) => {
277
+ if (!inputValue) return true
278
+ return textValue.toLowerCase().includes(inputValue.toLowerCase())
279
+ }
280
+
281
+ return (
282
+ <div class={['vui-search-autocomplete relative', styles().container, local.class].filter(Boolean).join(' ')}>
283
+ <Show when={local.label}>
284
+ <label class={['block font-medium text-text-700', styles().label].join(' ')}>
285
+ {local.label}
286
+ </label>
287
+ </Show>
288
+
289
+ <Autocomplete
290
+ {...autocompleteProps}
291
+ filter={autocompleteProps.filter ?? defaultFilter}
292
+ >
293
+ <AutocompleteInput
294
+ placeholder={local.placeholder}
295
+ aria-label={local['aria-label']}
296
+ isDisabled={local.isDisabled}
297
+ size={size()}
298
+ />
299
+ <AutocompleteList
300
+ items={local.items}
301
+ size={size()}
302
+ onSelect={local.onSelect}
303
+ renderItem={local.renderItem}
304
+ textKey={textKey() as keyof T}
305
+ />
306
+ </Autocomplete>
307
+
308
+ <Show when={local.description}>
309
+ <p class="mt-1 text-sm text-text-500">{local.description}</p>
310
+ </Show>
311
+ </div>
312
+ )
313
+ }
@@ -0,0 +1,207 @@
1
+ /**
2
+ * Breadcrumbs component for proyecto-viviana-ui
3
+ *
4
+ * Styled breadcrumbs component built on top of solidaria-components.
5
+ * Inspired by Spectrum 2's Breadcrumbs component patterns.
6
+ */
7
+
8
+ import { type JSX, splitProps, createContext, useContext } from 'solid-js'
9
+ import {
10
+ Breadcrumbs as HeadlessBreadcrumbs,
11
+ BreadcrumbItem as HeadlessBreadcrumbItem,
12
+ type BreadcrumbsProps as HeadlessBreadcrumbsProps,
13
+ type BreadcrumbItemProps as HeadlessBreadcrumbItemProps,
14
+ type BreadcrumbsRenderProps,
15
+ type BreadcrumbItemRenderProps,
16
+ } from '@proyecto-viviana/solidaria-components'
17
+
18
+ // ============================================
19
+ // SIZE CONTEXT
20
+ // ============================================
21
+
22
+ export type BreadcrumbsSize = 'sm' | 'md' | 'lg'
23
+ export type BreadcrumbsVariant = 'default' | 'subtle'
24
+
25
+ interface BreadcrumbsContextValue {
26
+ size: BreadcrumbsSize
27
+ variant: BreadcrumbsVariant
28
+ showSeparator: boolean
29
+ }
30
+
31
+ const BreadcrumbsSizeContext = createContext<BreadcrumbsContextValue>({
32
+ size: 'md',
33
+ variant: 'default',
34
+ showSeparator: true,
35
+ })
36
+
37
+ // ============================================
38
+ // TYPES
39
+ // ============================================
40
+
41
+ export interface BreadcrumbsProps<T> extends Omit<HeadlessBreadcrumbsProps<T>, 'class' | 'style'> {
42
+ /** The size of the breadcrumbs. */
43
+ size?: BreadcrumbsSize
44
+ /** The visual variant. */
45
+ variant?: BreadcrumbsVariant
46
+ /** Whether to show separators between items. */
47
+ showSeparator?: boolean
48
+ /** Additional CSS class name. */
49
+ class?: string
50
+ }
51
+
52
+ export interface BreadcrumbItemProps extends Omit<HeadlessBreadcrumbItemProps, 'class' | 'style'> {
53
+ /** Additional CSS class name. */
54
+ class?: string
55
+ }
56
+
57
+ // ============================================
58
+ // STYLES
59
+ // ============================================
60
+
61
+ const sizeStyles = {
62
+ sm: {
63
+ text: 'text-sm',
64
+ icon: 'h-3 w-3',
65
+ gap: 'gap-1',
66
+ },
67
+ md: {
68
+ text: 'text-base',
69
+ icon: 'h-4 w-4',
70
+ gap: 'gap-1.5',
71
+ },
72
+ lg: {
73
+ text: 'text-lg',
74
+ icon: 'h-5 w-5',
75
+ gap: 'gap-2',
76
+ },
77
+ }
78
+
79
+ const variantStyles = {
80
+ default: {
81
+ item: 'text-primary-400 hover:text-primary-200',
82
+ current: 'text-primary-100 font-medium',
83
+ separator: 'text-primary-500',
84
+ },
85
+ subtle: {
86
+ item: 'text-primary-500 hover:text-primary-300',
87
+ current: 'text-primary-200',
88
+ separator: 'text-primary-600',
89
+ },
90
+ }
91
+
92
+ // ============================================
93
+ // BREADCRUMBS COMPONENT
94
+ // ============================================
95
+
96
+ /**
97
+ * Breadcrumbs show hierarchy and navigational context for a user's location within an application.
98
+ *
99
+ * Built on solidaria-components Breadcrumbs for full accessibility support.
100
+ */
101
+ export function Breadcrumbs<T>(props: BreadcrumbsProps<T>): JSX.Element {
102
+ const [local, headlessProps] = splitProps(props, [
103
+ 'size',
104
+ 'variant',
105
+ 'showSeparator',
106
+ 'class',
107
+ ])
108
+
109
+ const size = local.size ?? 'md'
110
+ const variant = local.variant ?? 'default'
111
+ const showSeparator = local.showSeparator ?? true
112
+ const customClass = local.class ?? ''
113
+
114
+ const getClassName = (renderProps: BreadcrumbsRenderProps): string => {
115
+ const base = 'flex items-center'
116
+ const sizeClass = sizeStyles[size].gap
117
+ const disabledClass = renderProps.isDisabled ? 'opacity-50' : ''
118
+ return [base, sizeClass, disabledClass, customClass].filter(Boolean).join(' ')
119
+ }
120
+
121
+ return (
122
+ <BreadcrumbsSizeContext.Provider value={{ size, variant, showSeparator }}>
123
+ <HeadlessBreadcrumbs
124
+ {...headlessProps}
125
+ class={getClassName}
126
+ children={props.children}
127
+ />
128
+ </BreadcrumbsSizeContext.Provider>
129
+ )
130
+ }
131
+
132
+ // ============================================
133
+ // BREADCRUMB ITEM COMPONENT
134
+ // ============================================
135
+
136
+ /**
137
+ * A BreadcrumbItem represents an individual breadcrumb in the navigation trail.
138
+ */
139
+ export function BreadcrumbItem(props: BreadcrumbItemProps): JSX.Element {
140
+ const [local, headlessProps] = splitProps(props, ['class'])
141
+ const ctx = useContext(BreadcrumbsSizeContext)
142
+ const customClass = local.class ?? ''
143
+
144
+ const getClassName = (renderProps: BreadcrumbItemRenderProps): string => {
145
+ const sizeClass = sizeStyles[ctx.size].text
146
+ const vStyles = variantStyles[ctx.variant]
147
+
148
+ let stateClass: string
149
+ if (renderProps.isCurrent) {
150
+ stateClass = vStyles.current
151
+ } else if (renderProps.isDisabled) {
152
+ stateClass = 'text-primary-600 cursor-not-allowed'
153
+ } else {
154
+ stateClass = vStyles.item
155
+ }
156
+
157
+ const cursorClass = renderProps.isCurrent || renderProps.isDisabled ? '' : 'cursor-pointer'
158
+ const transitionClass = 'transition-colors duration-150'
159
+ const focusClass = renderProps.isFocusVisible
160
+ ? 'ring-2 ring-accent-300 ring-offset-1 ring-offset-bg-400 outline-none rounded'
161
+ : ''
162
+
163
+ return [sizeClass, stateClass, cursorClass, transitionClass, focusClass, customClass].filter(Boolean).join(' ')
164
+ }
165
+
166
+ const vStyles = variantStyles[ctx.variant]
167
+ // Hide separator on first item, and on current (last) item
168
+ const separatorClass = `${sizeStyles[ctx.size].icon} ${vStyles.separator} mx-1 shrink-0 hidden data-current:hidden [&:not([data-current])]:block [li:first-child_&]:!hidden`
169
+
170
+ // Wrap children with separator icon
171
+ const renderChildren = () => (
172
+ <>
173
+ {/* Separator shows before items except first and current */}
174
+ {ctx.showSeparator && <ChevronIcon class={separatorClass} />}
175
+ {props.children as JSX.Element}
176
+ </>
177
+ )
178
+
179
+ return (
180
+ <HeadlessBreadcrumbItem
181
+ {...headlessProps}
182
+ class={getClassName}
183
+ children={renderChildren()}
184
+ />
185
+ )
186
+ }
187
+
188
+ // ============================================
189
+ // ICONS
190
+ // ============================================
191
+
192
+ function ChevronIcon(props: { class?: string }): JSX.Element {
193
+ return (
194
+ <svg
195
+ class={props.class}
196
+ fill="none"
197
+ viewBox="0 0 24 24"
198
+ stroke="currentColor"
199
+ stroke-width="2"
200
+ >
201
+ <path stroke-linecap="round" stroke-linejoin="round" d="M9 5l7 7-7 7" />
202
+ </svg>
203
+ )
204
+ }
205
+
206
+ // Attach sub-components for convenience
207
+ Breadcrumbs.Item = BreadcrumbItem