@proyecto-viviana/solidaria-components 0.2.1 → 0.2.3
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.
- package/dist/Color.d.ts +2 -6
- package/dist/Color.d.ts.map +1 -1
- package/dist/ComboBox.d.ts +3 -3
- package/dist/ComboBox.d.ts.map +1 -1
- package/dist/GridList.d.ts +2 -2
- package/dist/GridList.d.ts.map +1 -1
- package/dist/ListBox.d.ts +5 -5
- package/dist/ListBox.d.ts.map +1 -1
- package/dist/Menu.d.ts +3 -3
- package/dist/Menu.d.ts.map +1 -1
- package/dist/Select.d.ts +3 -3
- package/dist/Select.d.ts.map +1 -1
- package/dist/Table.d.ts +2 -2
- package/dist/Table.d.ts.map +1 -1
- package/dist/Tabs.d.ts +1 -1
- package/dist/Tabs.d.ts.map +1 -1
- package/dist/index.js +56 -56
- package/dist/index.js.map +2 -2
- package/dist/index.ssr.js +56 -56
- package/dist/index.ssr.js.map +2 -2
- package/package.json +10 -8
- package/src/Autocomplete.tsx +174 -0
- package/src/Breadcrumbs.tsx +264 -0
- package/src/Button.tsx +238 -0
- package/src/Calendar.tsx +471 -0
- package/src/Checkbox.tsx +387 -0
- package/src/Color.tsx +1370 -0
- package/src/ComboBox.tsx +824 -0
- package/src/DateField.tsx +337 -0
- package/src/DatePicker.tsx +367 -0
- package/src/Dialog.tsx +262 -0
- package/src/Disclosure.tsx +439 -0
- package/src/GridList.tsx +511 -0
- package/src/Landmark.tsx +203 -0
- package/src/Link.tsx +201 -0
- package/src/ListBox.tsx +346 -0
- package/src/Menu.tsx +544 -0
- package/src/Meter.tsx +157 -0
- package/src/Modal.tsx +433 -0
- package/src/NumberField.tsx +542 -0
- package/src/Popover.tsx +540 -0
- package/src/ProgressBar.tsx +162 -0
- package/src/RadioGroup.tsx +356 -0
- package/src/RangeCalendar.tsx +462 -0
- package/src/SearchField.tsx +479 -0
- package/src/Select.tsx +734 -0
- package/src/Separator.tsx +130 -0
- package/src/Slider.tsx +500 -0
- package/src/Switch.tsx +213 -0
- package/src/Table.tsx +857 -0
- package/src/Tabs.tsx +552 -0
- package/src/TagGroup.tsx +421 -0
- package/src/TextField.tsx +271 -0
- package/src/TimeField.tsx +455 -0
- package/src/Toast.tsx +503 -0
- package/src/Toolbar.tsx +160 -0
- package/src/Tooltip.tsx +423 -0
- package/src/Tree.tsx +551 -0
- package/src/VisuallyHidden.tsx +60 -0
- package/src/contexts.ts +74 -0
- package/src/index.ts +620 -0
- package/src/utils.tsx +329 -0
package/package.json
CHANGED
|
@@ -1,30 +1,32 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@proyecto-viviana/solidaria-components",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"description": "Pre-wired headless components for SolidJS - port of react-aria-components",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"main": "./dist/index.
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
7
|
"module": "./dist/index.js",
|
|
8
8
|
"types": "./dist/index.d.ts",
|
|
9
9
|
"exports": {
|
|
10
10
|
".": {
|
|
11
11
|
"types": "./dist/index.d.ts",
|
|
12
|
-
"solid": "./
|
|
12
|
+
"solid": "./src/index.ts",
|
|
13
|
+
"import": "./dist/index.js",
|
|
13
14
|
"default": "./dist/index.js"
|
|
14
15
|
}
|
|
15
16
|
},
|
|
16
17
|
"files": [
|
|
17
|
-
"dist"
|
|
18
|
+
"dist",
|
|
19
|
+
"src"
|
|
18
20
|
],
|
|
19
21
|
"sideEffects": false,
|
|
20
22
|
"scripts": {
|
|
21
|
-
"build": "
|
|
23
|
+
"build": "tsup && rm -f tsconfig.build.tsbuildinfo && tsc -p tsconfig.build.json",
|
|
22
24
|
"dev": "tsup --watch",
|
|
23
|
-
"prepublishOnly": "deno task
|
|
25
|
+
"prepublishOnly": "echo 'Use deno task release from root'"
|
|
24
26
|
},
|
|
25
27
|
"dependencies": {
|
|
26
|
-
"@proyecto-viviana/
|
|
27
|
-
"@proyecto-viviana/
|
|
28
|
+
"@proyecto-viviana/solidaria": "workspace:*",
|
|
29
|
+
"@proyecto-viviana/solid-stately": "workspace:*"
|
|
28
30
|
},
|
|
29
31
|
"peerDependencies": {
|
|
30
32
|
"solid-js": "^1.9.0"
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Autocomplete component for solidaria-components
|
|
3
|
+
*
|
|
4
|
+
* Provides autocomplete functionality by wrapping a text input
|
|
5
|
+
* with a filterable collection (ListBox/Menu).
|
|
6
|
+
*
|
|
7
|
+
* Port of react-aria-components/src/Autocomplete.tsx
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import {
|
|
11
|
+
type JSX,
|
|
12
|
+
type ParentProps,
|
|
13
|
+
createContext,
|
|
14
|
+
useContext,
|
|
15
|
+
createMemo,
|
|
16
|
+
splitProps,
|
|
17
|
+
createSignal,
|
|
18
|
+
} from 'solid-js'
|
|
19
|
+
import {
|
|
20
|
+
createAutocomplete,
|
|
21
|
+
type AriaAutocompleteOptions,
|
|
22
|
+
type AutocompleteInputProps,
|
|
23
|
+
type CollectionOptions,
|
|
24
|
+
} from '@proyecto-viviana/solidaria'
|
|
25
|
+
import {
|
|
26
|
+
createAutocompleteState,
|
|
27
|
+
type AutocompleteState,
|
|
28
|
+
type AutocompleteStateOptions,
|
|
29
|
+
} from '@proyecto-viviana/solid-stately'
|
|
30
|
+
import { type SlotProps } from './utils'
|
|
31
|
+
|
|
32
|
+
// ============================================
|
|
33
|
+
// TYPES
|
|
34
|
+
// ============================================
|
|
35
|
+
|
|
36
|
+
export interface AutocompleteProps<T = unknown>
|
|
37
|
+
extends Omit<AutocompleteStateOptions, 'children'>,
|
|
38
|
+
Omit<AriaAutocompleteOptions<T>, 'inputRef' | 'collectionRef'>,
|
|
39
|
+
ParentProps,
|
|
40
|
+
SlotProps {}
|
|
41
|
+
|
|
42
|
+
// ============================================
|
|
43
|
+
// CONTEXTS
|
|
44
|
+
// ============================================
|
|
45
|
+
|
|
46
|
+
export interface AutocompleteContextValue {
|
|
47
|
+
inputProps: AutocompleteInputProps
|
|
48
|
+
inputRef: (el: HTMLInputElement) => void
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export interface AutocompleteCollectionContextValue {
|
|
52
|
+
collectionProps: CollectionOptions
|
|
53
|
+
collectionRef: (el: HTMLElement) => void
|
|
54
|
+
filter?: (textValue: string) => boolean
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export const AutocompleteContext = createContext<AutocompleteContextValue | null>(null)
|
|
58
|
+
export const AutocompleteStateContext = createContext<AutocompleteState | null>(null)
|
|
59
|
+
export const AutocompleteCollectionContext = createContext<AutocompleteCollectionContextValue | null>(null)
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Hook to consume autocomplete input context.
|
|
63
|
+
* Use this in your input component (TextField/SearchField) to get the autocomplete props.
|
|
64
|
+
*/
|
|
65
|
+
export function useAutocompleteInput() {
|
|
66
|
+
return useContext(AutocompleteContext)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Hook to consume autocomplete state context.
|
|
71
|
+
*/
|
|
72
|
+
export function useAutocompleteState() {
|
|
73
|
+
return useContext(AutocompleteStateContext)
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Hook to consume autocomplete collection context.
|
|
78
|
+
* Use this in your collection component (ListBox/Menu) to get the autocomplete props.
|
|
79
|
+
*/
|
|
80
|
+
export function useAutocompleteCollection() {
|
|
81
|
+
return useContext(AutocompleteCollectionContext)
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// ============================================
|
|
85
|
+
// AUTOCOMPLETE COMPONENT
|
|
86
|
+
// ============================================
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* An autocomplete allows users to search or filter a list of suggestions.
|
|
90
|
+
* It wraps a text input and a collection component (ListBox or Menu),
|
|
91
|
+
* providing keyboard navigation and filtering capabilities.
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* ```tsx
|
|
95
|
+
* // Basic usage with SearchField and ListBox
|
|
96
|
+
* <Autocomplete
|
|
97
|
+
* filter={(textValue, inputValue) =>
|
|
98
|
+
* textValue.toLowerCase().includes(inputValue.toLowerCase())
|
|
99
|
+
* }
|
|
100
|
+
* >
|
|
101
|
+
* <SearchField aria-label="Search">
|
|
102
|
+
* <Input />
|
|
103
|
+
* </SearchField>
|
|
104
|
+
* <ListBox aria-label="Suggestions">
|
|
105
|
+
* <ListBoxItem>Option 1</ListBoxItem>
|
|
106
|
+
* <ListBoxItem>Option 2</ListBoxItem>
|
|
107
|
+
* <ListBoxItem>Option 3</ListBoxItem>
|
|
108
|
+
* </ListBox>
|
|
109
|
+
* </Autocomplete>
|
|
110
|
+
*
|
|
111
|
+
* // Controlled input value
|
|
112
|
+
* const [value, setValue] = createSignal('');
|
|
113
|
+
* <Autocomplete
|
|
114
|
+
* inputValue={value()}
|
|
115
|
+
* onInputChange={setValue}
|
|
116
|
+
* filter={(textValue, inputValue) =>
|
|
117
|
+
* textValue.toLowerCase().includes(inputValue.toLowerCase())
|
|
118
|
+
* }
|
|
119
|
+
* >
|
|
120
|
+
* {/* ... *\/}
|
|
121
|
+
* </Autocomplete>
|
|
122
|
+
* ```
|
|
123
|
+
*/
|
|
124
|
+
export function Autocomplete<T = unknown>(props: AutocompleteProps<T>): JSX.Element {
|
|
125
|
+
const [stateProps, ariaProps, local] = splitProps(
|
|
126
|
+
props,
|
|
127
|
+
['inputValue', 'defaultInputValue', 'onInputChange'],
|
|
128
|
+
['filter', 'disableAutoFocusFirst', 'disableVirtualFocus']
|
|
129
|
+
)
|
|
130
|
+
|
|
131
|
+
// Create state
|
|
132
|
+
const state = createAutocompleteState(stateProps)
|
|
133
|
+
|
|
134
|
+
// Create refs
|
|
135
|
+
let inputRef: HTMLInputElement | undefined
|
|
136
|
+
let collectionRef: HTMLElement | undefined
|
|
137
|
+
|
|
138
|
+
// Create autocomplete aria
|
|
139
|
+
const autocomplete = createAutocomplete<T>(
|
|
140
|
+
{
|
|
141
|
+
...ariaProps,
|
|
142
|
+
inputRef: () => inputRef,
|
|
143
|
+
collectionRef: () => collectionRef,
|
|
144
|
+
},
|
|
145
|
+
state
|
|
146
|
+
)
|
|
147
|
+
|
|
148
|
+
// Input context value
|
|
149
|
+
const inputContextValue = createMemo<AutocompleteContextValue>(() => ({
|
|
150
|
+
inputProps: autocomplete.inputProps,
|
|
151
|
+
inputRef: (el: HTMLInputElement) => {
|
|
152
|
+
inputRef = el
|
|
153
|
+
},
|
|
154
|
+
}))
|
|
155
|
+
|
|
156
|
+
// Collection context value
|
|
157
|
+
const collectionContextValue = createMemo<AutocompleteCollectionContextValue>(() => ({
|
|
158
|
+
collectionProps: autocomplete.collectionProps,
|
|
159
|
+
collectionRef: (el: HTMLElement) => {
|
|
160
|
+
collectionRef = el
|
|
161
|
+
},
|
|
162
|
+
filter: autocomplete.filter,
|
|
163
|
+
}))
|
|
164
|
+
|
|
165
|
+
return (
|
|
166
|
+
<AutocompleteStateContext.Provider value={state}>
|
|
167
|
+
<AutocompleteContext.Provider value={inputContextValue()}>
|
|
168
|
+
<AutocompleteCollectionContext.Provider value={collectionContextValue()}>
|
|
169
|
+
{props.children}
|
|
170
|
+
</AutocompleteCollectionContext.Provider>
|
|
171
|
+
</AutocompleteContext.Provider>
|
|
172
|
+
</AutocompleteStateContext.Provider>
|
|
173
|
+
)
|
|
174
|
+
}
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Breadcrumbs component for solidaria-components
|
|
3
|
+
*
|
|
4
|
+
* A pre-wired headless breadcrumbs component that combines aria hooks.
|
|
5
|
+
* Port of react-aria-components Breadcrumbs.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import {
|
|
9
|
+
type JSX,
|
|
10
|
+
createContext,
|
|
11
|
+
createMemo,
|
|
12
|
+
splitProps,
|
|
13
|
+
useContext,
|
|
14
|
+
For,
|
|
15
|
+
} from 'solid-js';
|
|
16
|
+
import {
|
|
17
|
+
createBreadcrumbs,
|
|
18
|
+
createBreadcrumbItem,
|
|
19
|
+
type AriaBreadcrumbsProps,
|
|
20
|
+
type AriaBreadcrumbItemProps,
|
|
21
|
+
} from '@proyecto-viviana/solidaria';
|
|
22
|
+
import {
|
|
23
|
+
type RenderChildren,
|
|
24
|
+
type ClassNameOrFunction,
|
|
25
|
+
type StyleOrFunction,
|
|
26
|
+
type SlotProps,
|
|
27
|
+
useRenderProps,
|
|
28
|
+
filterDOMProps,
|
|
29
|
+
} from './utils';
|
|
30
|
+
|
|
31
|
+
// ============================================
|
|
32
|
+
// TYPES
|
|
33
|
+
// ============================================
|
|
34
|
+
|
|
35
|
+
export interface BreadcrumbsRenderProps {
|
|
36
|
+
/** Whether the breadcrumbs are disabled. */
|
|
37
|
+
isDisabled: boolean;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface BreadcrumbsProps<T> extends Omit<AriaBreadcrumbsProps, 'isDisabled'>, SlotProps {
|
|
41
|
+
/** The items to render in the breadcrumbs. */
|
|
42
|
+
items?: T[];
|
|
43
|
+
/** Function to get the key from an item. */
|
|
44
|
+
getKey?: (item: T) => string | number;
|
|
45
|
+
/** Whether the breadcrumbs are disabled. */
|
|
46
|
+
isDisabled?: boolean;
|
|
47
|
+
/** The children of the component - render function for each item. */
|
|
48
|
+
children: (item: T) => JSX.Element;
|
|
49
|
+
/** The CSS className for the element. */
|
|
50
|
+
class?: ClassNameOrFunction<BreadcrumbsRenderProps>;
|
|
51
|
+
/** The inline style for the element. */
|
|
52
|
+
style?: StyleOrFunction<BreadcrumbsRenderProps>;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export interface BreadcrumbItemRenderProps {
|
|
56
|
+
/** Whether this is the current/last item. */
|
|
57
|
+
isCurrent: boolean;
|
|
58
|
+
/** Whether the item is disabled. */
|
|
59
|
+
isDisabled: boolean;
|
|
60
|
+
/** Whether the item is pressed. */
|
|
61
|
+
isPressed: boolean;
|
|
62
|
+
/** Whether the item is focused. */
|
|
63
|
+
isFocused: boolean;
|
|
64
|
+
/** Whether the item has visible focus ring. */
|
|
65
|
+
isFocusVisible: boolean;
|
|
66
|
+
/** Whether the item is hovered. */
|
|
67
|
+
isHovered: boolean;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export interface BreadcrumbItemProps extends Omit<AriaBreadcrumbItemProps, 'isDisabled'>, SlotProps {
|
|
71
|
+
/** The children of the breadcrumb item. */
|
|
72
|
+
children?: RenderChildren<BreadcrumbItemRenderProps>;
|
|
73
|
+
/** The CSS className for the element. */
|
|
74
|
+
class?: ClassNameOrFunction<BreadcrumbItemRenderProps>;
|
|
75
|
+
/** The inline style for the element. */
|
|
76
|
+
style?: StyleOrFunction<BreadcrumbItemRenderProps>;
|
|
77
|
+
/** Whether this item is disabled. */
|
|
78
|
+
isDisabled?: boolean;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// ============================================
|
|
82
|
+
// CONTEXT
|
|
83
|
+
// ============================================
|
|
84
|
+
|
|
85
|
+
interface BreadcrumbsContextValue {
|
|
86
|
+
isDisabled: boolean;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export const BreadcrumbsContext = createContext<BreadcrumbsContextValue | null>(null);
|
|
90
|
+
|
|
91
|
+
// ============================================
|
|
92
|
+
// COMPONENTS
|
|
93
|
+
// ============================================
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Breadcrumbs show hierarchy and navigational context for a user's location within an application.
|
|
97
|
+
*/
|
|
98
|
+
export function Breadcrumbs<T>(props: BreadcrumbsProps<T>): JSX.Element {
|
|
99
|
+
const [local, ariaProps, rest] = splitProps(
|
|
100
|
+
props,
|
|
101
|
+
['children', 'class', 'style', 'slot', 'items', 'getKey', 'isDisabled'],
|
|
102
|
+
['aria-label', 'aria-labelledby', 'aria-describedby']
|
|
103
|
+
);
|
|
104
|
+
|
|
105
|
+
const isDisabled = () => local.isDisabled ?? false;
|
|
106
|
+
const items = () => local.items ?? [];
|
|
107
|
+
|
|
108
|
+
// Create breadcrumbs aria props
|
|
109
|
+
const { navProps } = createBreadcrumbs({
|
|
110
|
+
get 'aria-label'() {
|
|
111
|
+
return ariaProps['aria-label'];
|
|
112
|
+
},
|
|
113
|
+
get 'aria-labelledby'() {
|
|
114
|
+
return ariaProps['aria-labelledby'];
|
|
115
|
+
},
|
|
116
|
+
get 'aria-describedby'() {
|
|
117
|
+
return ariaProps['aria-describedby'];
|
|
118
|
+
},
|
|
119
|
+
get isDisabled() {
|
|
120
|
+
return isDisabled();
|
|
121
|
+
},
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
// Render props values
|
|
125
|
+
const renderValues = createMemo<BreadcrumbsRenderProps>(() => ({
|
|
126
|
+
isDisabled: isDisabled(),
|
|
127
|
+
}));
|
|
128
|
+
|
|
129
|
+
// Resolve render props
|
|
130
|
+
const renderProps = useRenderProps(
|
|
131
|
+
{
|
|
132
|
+
class: local.class,
|
|
133
|
+
style: local.style,
|
|
134
|
+
defaultClassName: 'solidaria-Breadcrumbs',
|
|
135
|
+
},
|
|
136
|
+
renderValues
|
|
137
|
+
);
|
|
138
|
+
|
|
139
|
+
// Filter DOM props
|
|
140
|
+
const domProps = createMemo(() => filterDOMProps(rest as Record<string, unknown>, { global: true }));
|
|
141
|
+
|
|
142
|
+
return (
|
|
143
|
+
<BreadcrumbsContext.Provider value={{ isDisabled: isDisabled() }}>
|
|
144
|
+
<nav
|
|
145
|
+
{...navProps}
|
|
146
|
+
{...domProps()}
|
|
147
|
+
class={renderProps.class()}
|
|
148
|
+
style={renderProps.style()}
|
|
149
|
+
data-disabled={isDisabled() || undefined}
|
|
150
|
+
>
|
|
151
|
+
<ol style={{ display: 'flex', 'align-items': 'center', 'list-style': 'none', margin: 0, padding: 0 }}>
|
|
152
|
+
<For each={items()}>
|
|
153
|
+
{(item) => (
|
|
154
|
+
<li style={{ display: 'flex', 'align-items': 'center' }}>
|
|
155
|
+
{props.children(item)}
|
|
156
|
+
</li>
|
|
157
|
+
)}
|
|
158
|
+
</For>
|
|
159
|
+
</ol>
|
|
160
|
+
</nav>
|
|
161
|
+
</BreadcrumbsContext.Provider>
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* A BreadcrumbItem represents an individual breadcrumb in the navigation trail.
|
|
167
|
+
*/
|
|
168
|
+
export function BreadcrumbItem(props: BreadcrumbItemProps): JSX.Element {
|
|
169
|
+
const [local, ariaProps] = splitProps(props, [
|
|
170
|
+
'class',
|
|
171
|
+
'style',
|
|
172
|
+
'slot',
|
|
173
|
+
'isDisabled',
|
|
174
|
+
]);
|
|
175
|
+
|
|
176
|
+
// Get context
|
|
177
|
+
const context = useContext(BreadcrumbsContext);
|
|
178
|
+
const isDisabled = () => local.isDisabled ?? context?.isDisabled ?? false;
|
|
179
|
+
const isCurrent = () => ariaProps.isCurrent ?? false;
|
|
180
|
+
|
|
181
|
+
// Create breadcrumb item aria props
|
|
182
|
+
const { itemProps, isPressed } = createBreadcrumbItem({
|
|
183
|
+
get isCurrent() {
|
|
184
|
+
return isCurrent();
|
|
185
|
+
},
|
|
186
|
+
get isDisabled() {
|
|
187
|
+
return isDisabled();
|
|
188
|
+
},
|
|
189
|
+
get href() {
|
|
190
|
+
return ariaProps.href;
|
|
191
|
+
},
|
|
192
|
+
get target() {
|
|
193
|
+
return ariaProps.target;
|
|
194
|
+
},
|
|
195
|
+
get rel() {
|
|
196
|
+
return ariaProps.rel;
|
|
197
|
+
},
|
|
198
|
+
get elementType() {
|
|
199
|
+
return ariaProps.elementType;
|
|
200
|
+
},
|
|
201
|
+
get onPress() {
|
|
202
|
+
return ariaProps.onPress;
|
|
203
|
+
},
|
|
204
|
+
get onPressStart() {
|
|
205
|
+
return ariaProps.onPressStart;
|
|
206
|
+
},
|
|
207
|
+
get onPressEnd() {
|
|
208
|
+
return ariaProps.onPressEnd;
|
|
209
|
+
},
|
|
210
|
+
get onClick() {
|
|
211
|
+
return ariaProps.onClick;
|
|
212
|
+
},
|
|
213
|
+
get 'aria-label'() {
|
|
214
|
+
return ariaProps['aria-label'];
|
|
215
|
+
},
|
|
216
|
+
get 'aria-current'() {
|
|
217
|
+
return ariaProps['aria-current'];
|
|
218
|
+
},
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
// Render props values
|
|
222
|
+
const renderValues = createMemo<BreadcrumbItemRenderProps>(() => ({
|
|
223
|
+
isCurrent: isCurrent(),
|
|
224
|
+
isDisabled: isDisabled(),
|
|
225
|
+
isPressed: isPressed(),
|
|
226
|
+
isFocused: false, // Would need focus tracking
|
|
227
|
+
isFocusVisible: false, // Would need focus visible tracking
|
|
228
|
+
isHovered: false, // Would need hover tracking
|
|
229
|
+
}));
|
|
230
|
+
|
|
231
|
+
// Resolve render props
|
|
232
|
+
const renderProps = useRenderProps(
|
|
233
|
+
{
|
|
234
|
+
children: props.children,
|
|
235
|
+
class: local.class,
|
|
236
|
+
style: local.style,
|
|
237
|
+
defaultClassName: 'solidaria-BreadcrumbItem',
|
|
238
|
+
},
|
|
239
|
+
renderValues
|
|
240
|
+
);
|
|
241
|
+
|
|
242
|
+
// Merge inline flex styles with user styles
|
|
243
|
+
const mergedStyle = () => {
|
|
244
|
+
const userStyle = renderProps.style();
|
|
245
|
+
const baseStyle = { display: 'inline-flex', 'align-items': 'center' };
|
|
246
|
+
return userStyle ? { ...baseStyle, ...userStyle } : baseStyle;
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
return (
|
|
250
|
+
<a
|
|
251
|
+
{...(itemProps as Record<string, unknown>)}
|
|
252
|
+
class={renderProps.class()}
|
|
253
|
+
style={mergedStyle()}
|
|
254
|
+
data-current={isCurrent() || undefined}
|
|
255
|
+
data-disabled={isDisabled() || undefined}
|
|
256
|
+
data-pressed={isPressed() || undefined}
|
|
257
|
+
>
|
|
258
|
+
{renderProps.renderChildren()}
|
|
259
|
+
</a>
|
|
260
|
+
);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
// Attach sub-components
|
|
264
|
+
Breadcrumbs.Item = BreadcrumbItem;
|