@proyecto-viviana/solid-stately 0.2.7 → 0.3.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.
- package/README.md +30 -283
- package/dist/autocomplete/createAutocompleteState.d.ts +2 -2
- package/dist/autocomplete/index.d.ts +1 -1
- package/dist/calendar/createCalendarState.d.ts +22 -7
- package/dist/calendar/createDateFieldState.d.ts +30 -7
- package/dist/calendar/createDatePickerState.d.ts +60 -0
- package/dist/calendar/createRangeCalendarState.d.ts +27 -8
- package/dist/calendar/createTimeFieldState.d.ts +34 -7
- package/dist/calendar/index.d.ts +7 -6
- package/dist/checkbox/createCheckboxGroupState.d.ts +6 -6
- package/dist/checkbox/index.d.ts +1 -1
- package/dist/collections/ListCollection.d.ts +1 -1
- package/dist/collections/createListState.d.ts +8 -8
- package/dist/collections/createMenuState.d.ts +7 -7
- package/dist/collections/createSelectionState.d.ts +5 -5
- package/dist/collections/index.d.ts +5 -5
- package/dist/collections/types.d.ts +12 -12
- package/dist/color/Color.d.ts +1 -1
- package/dist/color/createColorAreaState.d.ts +4 -2
- package/dist/color/createColorFieldState.d.ts +38 -12
- package/dist/color/createColorSliderState.d.ts +9 -2
- package/dist/color/createColorWheelState.d.ts +13 -2
- package/dist/color/getColorChannels.d.ts +1 -1
- package/dist/color/index.d.ts +6 -6
- package/dist/color/types.d.ts +4 -4
- package/dist/combobox/createComboBoxState.d.ts +27 -13
- package/dist/combobox/index.d.ts +1 -1
- package/dist/data/createAsyncList.d.ts +4 -4
- package/dist/data/createListData.d.ts +2 -2
- package/dist/data/createTreeData.d.ts +6 -2
- package/dist/data/index.d.ts +3 -3
- package/dist/datepicker/index.d.ts +2 -4
- package/dist/disclosure/createDisclosureState.d.ts +2 -2
- package/dist/disclosure/index.d.ts +1 -1
- package/dist/dnd/createDragState.d.ts +2 -2
- package/dist/dnd/createDraggableCollectionState.d.ts +2 -2
- package/dist/dnd/createDropState.d.ts +2 -2
- package/dist/dnd/createDroppableCollectionState.d.ts +3 -3
- package/dist/dnd/index.d.ts +5 -5
- package/dist/dnd/types.d.ts +16 -16
- package/dist/form/createFormValidationState.d.ts +3 -3
- package/dist/form/index.d.ts +1 -1
- package/dist/grid/createGridState.d.ts +2 -2
- package/dist/grid/index.d.ts +2 -2
- package/dist/grid/types.d.ts +13 -11
- package/dist/index.d.ts +31 -30
- package/dist/index.js +7924 -7238
- package/dist/index.js.map +1 -1
- package/dist/menu/index.d.ts +2 -2
- package/dist/numberfield/createNumberFieldState.d.ts +2 -2
- package/dist/numberfield/index.d.ts +1 -1
- package/dist/overlays/createOverlayTriggerState.d.ts +2 -2
- package/dist/overlays/index.d.ts +1 -1
- package/dist/radio/createRadioGroupState.d.ts +7 -7
- package/dist/radio/index.d.ts +1 -1
- package/dist/searchfield/createSearchFieldState.d.ts +2 -2
- package/dist/searchfield/index.d.ts +2 -2
- package/dist/select/createSelectState.d.ts +8 -8
- package/dist/select/index.d.ts +1 -1
- package/dist/selection/index.d.ts +5 -5
- package/dist/slider/createSliderState.d.ts +3 -3
- package/dist/slider/index.d.ts +2 -2
- package/dist/steplist/createStepListState.d.ts +48 -0
- package/dist/steplist/index.d.ts +1 -0
- package/dist/table/TableCollection.d.ts +3 -3
- package/dist/table/createTableColumnResizeState.d.ts +54 -0
- package/dist/table/createTableState.d.ts +2 -2
- package/dist/table/index.d.ts +5 -3
- package/dist/table/types.d.ts +10 -10
- package/dist/tabs/createTabListState.d.ts +5 -5
- package/dist/tabs/index.d.ts +1 -1
- package/dist/textfield/createTextFieldState.d.ts +2 -2
- package/dist/textfield/index.d.ts +1 -1
- package/dist/toast/createToastState.d.ts +8 -2
- package/dist/toast/index.d.ts +1 -1
- package/dist/toggle/createToggleGroupState.d.ts +4 -4
- package/dist/toggle/createToggleState.d.ts +2 -2
- package/dist/toggle/index.d.ts +2 -2
- package/dist/tooltip/createTooltipTriggerState.d.ts +2 -2
- package/dist/tooltip/index.d.ts +1 -1
- package/dist/tree/TreeCollection.d.ts +2 -2
- package/dist/tree/createTreeState.d.ts +2 -2
- package/dist/tree/index.d.ts +3 -3
- package/dist/tree/types.d.ts +19 -13
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/reactivity.d.ts +1 -1
- package/package.json +29 -30
- package/src/autocomplete/createAutocompleteState.d.ts +19 -17
- package/src/autocomplete/createAutocompleteState.ts +24 -30
- package/src/autocomplete/index.d.ts +6 -2
- package/src/autocomplete/index.ts +1 -1
- package/src/calendar/createCalendarState.d.ts +139 -117
- package/src/calendar/createCalendarState.ts +221 -74
- package/src/calendar/createDateFieldState.d.ts +130 -95
- package/src/calendar/createDateFieldState.ts +263 -151
- package/src/calendar/createDatePickerState.ts +347 -0
- package/src/calendar/createRangeCalendarState.d.ts +154 -129
- package/src/calendar/createRangeCalendarState.ts +293 -79
- package/src/calendar/createTimeFieldState.d.ts +81 -79
- package/src/calendar/createTimeFieldState.ts +187 -108
- package/src/calendar/index.d.ts +80 -7
- package/src/calendar/index.ts +21 -12
- package/src/checkbox/createCheckboxGroupState.d.ts +57 -55
- package/src/checkbox/createCheckboxGroupState.ts +20 -29
- package/src/checkbox/index.d.ts +6 -2
- package/src/checkbox/index.ts +1 -1
- package/src/collections/ListCollection.d.ts +25 -22
- package/src/collections/ListCollection.ts +6 -6
- package/src/collections/createListState.d.ts +73 -58
- package/src/collections/createListState.ts +19 -18
- package/src/collections/createMenuState.d.ts +36 -31
- package/src/collections/createMenuState.ts +18 -12
- package/src/collections/createSelectionState.d.ts +78 -65
- package/src/collections/createSelectionState.ts +36 -32
- package/src/collections/index.d.ts +38 -6
- package/src/collections/index.ts +5 -10
- package/src/collections/types.d.ts +101 -101
- package/src/collections/types.ts +12 -12
- package/src/color/Color.d.ts +20 -5
- package/src/color/Color.ts +357 -254
- package/src/color/createColorAreaState.d.ts +67 -65
- package/src/color/createColorAreaState.ts +21 -13
- package/src/color/createColorFieldState.d.ts +46 -44
- package/src/color/createColorFieldState.ts +285 -149
- package/src/color/createColorSliderState.d.ts +58 -56
- package/src/color/createColorSliderState.ts +45 -14
- package/src/color/createColorWheelState.d.ts +42 -40
- package/src/color/createColorWheelState.ts +101 -64
- package/src/color/getColorChannels.ts +7 -5
- package/src/color/index.d.ts +36 -7
- package/src/color/index.ts +6 -9
- package/src/color/types.d.ts +68 -63
- package/src/color/types.ts +11 -19
- package/src/combobox/createComboBoxState.d.ts +107 -105
- package/src/combobox/createComboBoxState.ts +176 -89
- package/src/combobox/index.d.ts +10 -2
- package/src/combobox/index.ts +1 -1
- package/src/data/createAsyncList.ts +89 -63
- package/src/data/createListData.ts +67 -67
- package/src/data/createTreeData.ts +304 -91
- package/src/data/index.ts +3 -3
- package/src/datepicker/index.ts +6 -10
- package/src/disclosure/createDisclosureState.d.ts +47 -43
- package/src/disclosure/createDisclosureState.ts +7 -21
- package/src/disclosure/index.d.ts +10 -2
- package/src/disclosure/index.ts +1 -1
- package/src/dnd/createDragState.d.ts +51 -42
- package/src/dnd/createDragState.ts +12 -14
- package/src/dnd/createDraggableCollectionState.d.ts +52 -41
- package/src/dnd/createDraggableCollectionState.ts +14 -21
- package/src/dnd/createDropState.d.ts +64 -45
- package/src/dnd/createDropState.ts +22 -32
- package/src/dnd/createDroppableCollectionState.d.ts +88 -59
- package/src/dnd/createDroppableCollectionState.ts +40 -43
- package/src/dnd/index.d.ts +54 -6
- package/src/dnd/index.ts +5 -18
- package/src/dnd/types.d.ts +167 -156
- package/src/dnd/types.ts +20 -21
- package/src/form/createFormValidationState.d.ts +47 -45
- package/src/form/createFormValidationState.ts +30 -63
- package/src/form/index.d.ts +16 -2
- package/src/form/index.ts +1 -1
- package/src/grid/createGridState.d.ts +7 -4
- package/src/grid/createGridState.ts +44 -51
- package/src/grid/index.d.ts +3 -3
- package/src/grid/index.ts +2 -8
- package/src/grid/types.d.ts +136 -129
- package/src/grid/types.ts +20 -18
- package/src/index.d.ts +310 -26
- package/src/index.ts +48 -89
- package/src/menu/index.ts +2 -4
- package/src/numberfield/createNumberFieldState.d.ts +56 -54
- package/src/numberfield/createNumberFieldState.ts +26 -31
- package/src/numberfield/index.d.ts +6 -2
- package/src/numberfield/index.ts +1 -1
- package/src/overlays/createOverlayTriggerState.d.ts +22 -20
- package/src/overlays/createOverlayTriggerState.ts +3 -4
- package/src/overlays/index.d.ts +6 -2
- package/src/overlays/index.ts +1 -1
- package/src/radio/createRadioGroupState.d.ts +54 -52
- package/src/radio/createRadioGroupState.ts +27 -29
- package/src/radio/index.d.ts +7 -2
- package/src/radio/index.ts +1 -1
- package/src/searchfield/createSearchFieldState.d.ts +16 -14
- package/src/searchfield/createSearchFieldState.ts +5 -11
- package/src/searchfield/index.d.ts +3 -3
- package/src/searchfield/index.ts +2 -5
- package/src/select/createSelectState.d.ts +63 -61
- package/src/select/createSelectState.ts +27 -27
- package/src/select/index.d.ts +2 -2
- package/src/select/index.ts +1 -5
- package/src/selection/index.ts +6 -7
- package/src/slider/createSliderState.d.ts +60 -60
- package/src/slider/createSliderState.ts +55 -33
- package/src/slider/index.d.ts +3 -3
- package/src/slider/index.ts +2 -6
- package/src/ssr/index.d.ts +1 -1
- package/src/ssr/index.ts +2 -2
- package/src/steplist/createStepListState.ts +191 -0
- package/src/steplist/index.ts +5 -0
- package/src/table/TableCollection.d.ts +42 -40
- package/src/table/TableCollection.ts +61 -64
- package/src/table/createTableColumnResizeState.ts +242 -0
- package/src/table/createTableState.d.ts +7 -4
- package/src/table/createTableState.ts +10 -7
- package/src/table/index.d.ts +14 -4
- package/src/table/index.ts +10 -3
- package/src/table/types.d.ts +98 -92
- package/src/table/types.ts +17 -13
- package/src/tabs/createTabListState.d.ts +59 -57
- package/src/tabs/createTabListState.ts +24 -31
- package/src/tabs/index.d.ts +8 -2
- package/src/tabs/index.ts +1 -1
- package/src/textfield/createTextFieldState.d.ts +16 -14
- package/src/textfield/createTextFieldState.ts +7 -18
- package/src/textfield/index.d.ts +6 -2
- package/src/textfield/index.ts +1 -1
- package/src/toast/createToastState.d.ts +92 -86
- package/src/toast/createToastState.ts +48 -43
- package/src/toast/index.d.ts +12 -2
- package/src/toast/index.ts +1 -1
- package/src/toggle/createToggleGroupState.ts +11 -21
- package/src/toggle/createToggleState.d.ts +19 -19
- package/src/toggle/createToggleState.ts +2 -16
- package/src/toggle/index.d.ts +2 -2
- package/src/toggle/index.ts +2 -6
- package/src/tooltip/createTooltipTriggerState.d.ts +17 -17
- package/src/tooltip/createTooltipTriggerState.ts +12 -11
- package/src/tooltip/index.d.ts +7 -2
- package/src/tooltip/index.ts +1 -1
- package/src/tree/TreeCollection.d.ts +26 -23
- package/src/tree/TreeCollection.ts +29 -22
- package/src/tree/createTreeState.d.ts +7 -4
- package/src/tree/createTreeState.ts +39 -41
- package/src/tree/index.d.ts +10 -4
- package/src/tree/index.ts +3 -3
- package/src/tree/types.d.ts +131 -126
- package/src/tree/types.ts +22 -13
- package/src/utils/index.d.ts +2 -2
- package/src/utils/index.ts +1 -1
- package/src/utils/reactivity.d.ts +2 -2
- package/src/utils/reactivity.ts +3 -3
package/dist/tree/types.d.ts
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* Tree collection types for Tree components.
|
|
3
3
|
* Based on @react-stately/tree.
|
|
4
4
|
*/
|
|
5
|
-
import type { Key, FocusStrategy } from
|
|
6
|
-
import type { GridNode, GridCollection } from
|
|
5
|
+
import type { Key, FocusStrategy } from "../collections/types";
|
|
6
|
+
import type { GridNode, GridCollection } from "../grid/types";
|
|
7
7
|
/**
|
|
8
8
|
* Represents a node in a tree collection.
|
|
9
9
|
* Extends GridNode with tree-specific properties.
|
|
@@ -26,7 +26,7 @@ export interface TreeNode<T = unknown> extends GridNode<T> {
|
|
|
26
26
|
* A collection of tree nodes with tree-specific navigation.
|
|
27
27
|
* Only includes visible nodes (respects expanded state).
|
|
28
28
|
*/
|
|
29
|
-
export interface TreeCollection<T = unknown> extends Omit<GridCollection<T>,
|
|
29
|
+
export interface TreeCollection<T = unknown> extends Omit<GridCollection<T>, "rows" | "columns" | "headerRows" | "columnCount" | "getCell"> {
|
|
30
30
|
/** All visible rows in the tree (respects expanded state). */
|
|
31
31
|
readonly rows: TreeNode<T>[];
|
|
32
32
|
/** Number of visible rows. */
|
|
@@ -74,9 +74,11 @@ export interface TreeState<T, C extends TreeCollection<T> = TreeCollection<T>> {
|
|
|
74
74
|
/** Whether the tree is focused. */
|
|
75
75
|
readonly isFocused: boolean;
|
|
76
76
|
/** The selection mode. */
|
|
77
|
-
readonly selectionMode:
|
|
77
|
+
readonly selectionMode: "none" | "single" | "multiple";
|
|
78
|
+
/** How selection behaves when pressing an item. */
|
|
79
|
+
readonly selectionBehavior: "toggle" | "replace";
|
|
78
80
|
/** The currently selected keys. */
|
|
79
|
-
readonly selectedKeys:
|
|
81
|
+
readonly selectedKeys: "all" | Set<Key>;
|
|
80
82
|
/** Check if a key is selected. */
|
|
81
83
|
isSelected(key: Key): boolean;
|
|
82
84
|
/** Check if a key is disabled. */
|
|
@@ -119,19 +121,19 @@ export interface TreeStateOptions<T, C extends TreeCollection<T> = TreeCollectio
|
|
|
119
121
|
/** Keys of disabled items. */
|
|
120
122
|
disabledKeys?: Iterable<Key>;
|
|
121
123
|
/** Disabled behavior: 'selection' only or 'all' interactions. */
|
|
122
|
-
disabledBehavior?:
|
|
124
|
+
disabledBehavior?: "selection" | "all";
|
|
123
125
|
/** Selection mode. */
|
|
124
|
-
selectionMode?:
|
|
126
|
+
selectionMode?: "none" | "single" | "multiple";
|
|
125
127
|
/** Selection behavior. */
|
|
126
|
-
selectionBehavior?:
|
|
128
|
+
selectionBehavior?: "toggle" | "replace";
|
|
127
129
|
/** Whether empty selection is disallowed. */
|
|
128
130
|
disallowEmptySelection?: boolean;
|
|
129
131
|
/** Currently selected keys (controlled). */
|
|
130
|
-
selectedKeys?:
|
|
132
|
+
selectedKeys?: "all" | Iterable<Key>;
|
|
131
133
|
/** Default selected keys (uncontrolled). */
|
|
132
|
-
defaultSelectedKeys?:
|
|
134
|
+
defaultSelectedKeys?: "all" | Iterable<Key>;
|
|
133
135
|
/** Handler for selection changes. */
|
|
134
|
-
onSelectionChange?: (keys:
|
|
136
|
+
onSelectionChange?: (keys: "all" | Set<Key>) => void;
|
|
135
137
|
/** Currently expanded keys (controlled). */
|
|
136
138
|
expandedKeys?: Iterable<Key>;
|
|
137
139
|
/** Default expanded keys (uncontrolled). */
|
|
@@ -144,13 +146,17 @@ export interface TreeStateOptions<T, C extends TreeCollection<T> = TreeCollectio
|
|
|
144
146
|
*/
|
|
145
147
|
export interface TreeItemData<T = unknown> {
|
|
146
148
|
/** Unique key for this item. */
|
|
147
|
-
key
|
|
149
|
+
key?: Key;
|
|
150
|
+
/** S2/React Aria-compatible unique id alias. */
|
|
151
|
+
id?: Key;
|
|
148
152
|
/** The data value for this item. */
|
|
149
|
-
value
|
|
153
|
+
value?: T;
|
|
150
154
|
/** Text content for accessibility and search. */
|
|
151
155
|
textValue?: string;
|
|
152
156
|
/** Child items (makes this item expandable). */
|
|
153
157
|
children?: TreeItemData<T>[];
|
|
158
|
+
/** Whether this item has children that may not be loaded yet. */
|
|
159
|
+
hasChildItems?: boolean;
|
|
154
160
|
/** Whether this item is disabled. */
|
|
155
161
|
isDisabled?: boolean;
|
|
156
162
|
}
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { access, isAccessor, type MaybeAccessor, type MaybeAccessorValue } from
|
|
1
|
+
export { access, isAccessor, type MaybeAccessor, type MaybeAccessorValue } from "./reactivity";
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Provides type-safe utilities for working with SolidJS reactivity patterns.
|
|
5
5
|
*/
|
|
6
|
-
import { Accessor } from
|
|
6
|
+
import { Accessor } from "solid-js";
|
|
7
7
|
/**
|
|
8
8
|
* A value that may be either a raw value or an accessor function.
|
|
9
9
|
* This is a common pattern in SolidJS for props that may be reactive.
|
package/package.json
CHANGED
|
@@ -1,31 +1,40 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@proyecto-viviana/solid-stately",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "A 1-1 SolidJS port of React Stately - headless state management for UI components",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"headless",
|
|
7
|
+
"react-stately",
|
|
8
|
+
"solid",
|
|
9
|
+
"solidjs",
|
|
10
|
+
"state",
|
|
11
|
+
"stately"
|
|
12
|
+
],
|
|
13
|
+
"license": "MIT",
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "git+https://github.com/proyecto-viviana/ui.git",
|
|
17
|
+
"directory": "packages/solid-stately"
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"dist",
|
|
21
|
+
"src"
|
|
22
|
+
],
|
|
5
23
|
"type": "module",
|
|
24
|
+
"sideEffects": false,
|
|
6
25
|
"main": "./dist/index.js",
|
|
7
26
|
"module": "./dist/index.js",
|
|
8
27
|
"types": "./dist/index.d.ts",
|
|
9
28
|
"exports": {
|
|
10
29
|
".": {
|
|
11
30
|
"types": "./dist/index.d.ts",
|
|
12
|
-
"solid": "./
|
|
31
|
+
"solid": "./dist/index.js",
|
|
13
32
|
"import": "./dist/index.js",
|
|
14
33
|
"default": "./dist/index.js"
|
|
15
34
|
}
|
|
16
35
|
},
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"src"
|
|
20
|
-
],
|
|
21
|
-
"sideEffects": false,
|
|
22
|
-
"scripts": {
|
|
23
|
-
"build": "tsup && rm -f tsconfig.build.tsbuildinfo && tsc -p tsconfig.build.json",
|
|
24
|
-
"dev": "tsup --watch",
|
|
25
|
-
"prepublishOnly": "echo 'Use the root Changesets npm release workflow'"
|
|
26
|
-
},
|
|
27
|
-
"peerDependencies": {
|
|
28
|
-
"solid-js": "^1.9.0"
|
|
36
|
+
"publishConfig": {
|
|
37
|
+
"access": "public"
|
|
29
38
|
},
|
|
30
39
|
"dependencies": {
|
|
31
40
|
"@internationalized/date": "^3.8.0"
|
|
@@ -33,21 +42,11 @@
|
|
|
33
42
|
"devDependencies": {
|
|
34
43
|
"solid-js": "^1.9.11"
|
|
35
44
|
},
|
|
36
|
-
"
|
|
37
|
-
"solid"
|
|
38
|
-
"solidjs",
|
|
39
|
-
"stately",
|
|
40
|
-
"state",
|
|
41
|
-
"headless",
|
|
42
|
-
"react-stately"
|
|
43
|
-
],
|
|
44
|
-
"license": "MIT",
|
|
45
|
-
"repository": {
|
|
46
|
-
"type": "git",
|
|
47
|
-
"url": "git+https://github.com/proyecto-viviana/proyecto-viviana.git",
|
|
48
|
-
"directory": "packages/solid-stately"
|
|
45
|
+
"peerDependencies": {
|
|
46
|
+
"solid-js": "^1.9.0"
|
|
49
47
|
},
|
|
50
|
-
"
|
|
51
|
-
"
|
|
48
|
+
"scripts": {
|
|
49
|
+
"build": "rm -rf dist && tsdown && rm -f tsconfig.build.tsbuildinfo && tsc -p tsconfig.build.json",
|
|
50
|
+
"dev": "tsup --watch"
|
|
52
51
|
}
|
|
53
|
-
}
|
|
52
|
+
}
|
|
@@ -3,24 +3,24 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Based on @react-stately/autocomplete useAutocompleteState.
|
|
5
5
|
*/
|
|
6
|
-
import { type Accessor } from
|
|
6
|
+
import { type Accessor } from "solid-js";
|
|
7
7
|
export interface AutocompleteState {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
8
|
+
/** The current value of the autocomplete input. */
|
|
9
|
+
inputValue: Accessor<string>;
|
|
10
|
+
/** Sets the value of the autocomplete input. */
|
|
11
|
+
setInputValue(value: string): void;
|
|
12
|
+
/** The id of the current aria-activedescendant of the autocomplete input. */
|
|
13
|
+
focusedNodeId: Accessor<string | null>;
|
|
14
|
+
/** Sets the id of the current aria-activedescendant of the autocomplete input. */
|
|
15
|
+
setFocusedNodeId(value: string | null): void;
|
|
16
16
|
}
|
|
17
17
|
export interface AutocompleteStateOptions {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
/** The value of the autocomplete input (controlled). */
|
|
19
|
+
inputValue?: string;
|
|
20
|
+
/** The default value of the autocomplete input (uncontrolled). */
|
|
21
|
+
defaultInputValue?: string;
|
|
22
|
+
/** Handler that is called when the autocomplete input value changes. */
|
|
23
|
+
onInputChange?: (value: string) => void;
|
|
24
24
|
}
|
|
25
25
|
/**
|
|
26
26
|
* Provides state management for an autocomplete component.
|
|
@@ -42,5 +42,7 @@ export interface AutocompleteStateOptions {
|
|
|
42
42
|
* state.setFocusedNodeId('item-1');
|
|
43
43
|
* ```
|
|
44
44
|
*/
|
|
45
|
-
export declare function createAutocompleteState(
|
|
46
|
-
|
|
45
|
+
export declare function createAutocompleteState(
|
|
46
|
+
props?: AutocompleteStateOptions,
|
|
47
|
+
): AutocompleteState;
|
|
48
|
+
//# sourceMappingURL=createAutocompleteState.d.ts.map
|
|
@@ -4,37 +4,29 @@
|
|
|
4
4
|
* Based on @react-stately/autocomplete useAutocompleteState.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import { createSignal, type Accessor } from
|
|
8
|
-
import { access, type MaybeAccessor } from
|
|
9
|
-
|
|
10
|
-
// ============================================
|
|
11
|
-
// TYPES
|
|
12
|
-
// ============================================
|
|
7
|
+
import { createSignal, type Accessor } from "solid-js";
|
|
8
|
+
import { access, type MaybeAccessor } from "../utils";
|
|
13
9
|
|
|
14
10
|
export interface AutocompleteState {
|
|
15
11
|
/** The current value of the autocomplete input. */
|
|
16
|
-
inputValue: Accessor<string
|
|
12
|
+
inputValue: Accessor<string>;
|
|
17
13
|
/** Sets the value of the autocomplete input. */
|
|
18
|
-
setInputValue(value: string): void
|
|
14
|
+
setInputValue(value: string): void;
|
|
19
15
|
/** The id of the current aria-activedescendant of the autocomplete input. */
|
|
20
|
-
focusedNodeId: Accessor<string | null
|
|
16
|
+
focusedNodeId: Accessor<string | null>;
|
|
21
17
|
/** Sets the id of the current aria-activedescendant of the autocomplete input. */
|
|
22
|
-
setFocusedNodeId(value: string | null): void
|
|
18
|
+
setFocusedNodeId(value: string | null): void;
|
|
23
19
|
}
|
|
24
20
|
|
|
25
21
|
export interface AutocompleteStateOptions {
|
|
26
22
|
/** The value of the autocomplete input (controlled). */
|
|
27
|
-
inputValue?: string
|
|
23
|
+
inputValue?: string;
|
|
28
24
|
/** The default value of the autocomplete input (uncontrolled). */
|
|
29
|
-
defaultInputValue?: string
|
|
25
|
+
defaultInputValue?: string;
|
|
30
26
|
/** Handler that is called when the autocomplete input value changes. */
|
|
31
|
-
onInputChange?: (value: string) => void
|
|
27
|
+
onInputChange?: (value: string) => void;
|
|
32
28
|
}
|
|
33
29
|
|
|
34
|
-
// ============================================
|
|
35
|
-
// CREATE AUTOCOMPLETE STATE
|
|
36
|
-
// ============================================
|
|
37
|
-
|
|
38
30
|
/**
|
|
39
31
|
* Provides state management for an autocomplete component.
|
|
40
32
|
*
|
|
@@ -56,34 +48,36 @@ export interface AutocompleteStateOptions {
|
|
|
56
48
|
* ```
|
|
57
49
|
*/
|
|
58
50
|
export function createAutocompleteState(
|
|
59
|
-
props: MaybeAccessor<AutocompleteStateOptions> = {}
|
|
51
|
+
props: MaybeAccessor<AutocompleteStateOptions> = {},
|
|
60
52
|
): AutocompleteState {
|
|
61
|
-
const getProps = () => access(props)
|
|
53
|
+
const getProps = () => access(props);
|
|
62
54
|
|
|
63
55
|
// Track focused node ID for aria-activedescendant
|
|
64
|
-
const [focusedNodeId, setFocusedNodeId] = createSignal<string | null>(null)
|
|
56
|
+
const [focusedNodeId, setFocusedNodeId] = createSignal<string | null>(null);
|
|
65
57
|
|
|
66
58
|
// Handle controlled vs uncontrolled input value
|
|
67
|
-
const isControlled = () => getProps().inputValue !== undefined
|
|
68
|
-
const [uncontrolledValue, setUncontrolledValue] = createSignal(
|
|
59
|
+
const isControlled = () => getProps().inputValue !== undefined;
|
|
60
|
+
const [uncontrolledValue, setUncontrolledValue] = createSignal(
|
|
61
|
+
getProps().defaultInputValue ?? "",
|
|
62
|
+
);
|
|
69
63
|
|
|
70
64
|
const inputValue: Accessor<string> = () => {
|
|
71
|
-
const p = getProps()
|
|
72
|
-
return isControlled() ? (p.inputValue ??
|
|
73
|
-
}
|
|
65
|
+
const p = getProps();
|
|
66
|
+
return isControlled() ? (p.inputValue ?? "") : uncontrolledValue();
|
|
67
|
+
};
|
|
74
68
|
|
|
75
69
|
const setInputValue = (value: string) => {
|
|
76
|
-
const p = getProps()
|
|
70
|
+
const p = getProps();
|
|
77
71
|
if (!isControlled()) {
|
|
78
|
-
setUncontrolledValue(value)
|
|
72
|
+
setUncontrolledValue(value);
|
|
79
73
|
}
|
|
80
|
-
p.onInputChange?.(value)
|
|
81
|
-
}
|
|
74
|
+
p.onInputChange?.(value);
|
|
75
|
+
};
|
|
82
76
|
|
|
83
77
|
return {
|
|
84
78
|
inputValue,
|
|
85
79
|
setInputValue,
|
|
86
80
|
focusedNodeId,
|
|
87
81
|
setFocusedNodeId,
|
|
88
|
-
}
|
|
82
|
+
};
|
|
89
83
|
}
|
|
@@ -1,2 +1,6 @@
|
|
|
1
|
-
export {
|
|
2
|
-
|
|
1
|
+
export {
|
|
2
|
+
createAutocompleteState,
|
|
3
|
+
type AutocompleteState,
|
|
4
|
+
type AutocompleteStateOptions,
|
|
5
|
+
} from "./createAutocompleteState";
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -4,127 +4,149 @@
|
|
|
4
4
|
* Provides state management for calendar components.
|
|
5
5
|
* Based on @react-stately/calendar useCalendarState
|
|
6
6
|
*/
|
|
7
|
-
import { type Accessor } from
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
import { type Accessor } from "solid-js";
|
|
8
|
+
import {
|
|
9
|
+
type Calendar as InternationalizedCalendar,
|
|
10
|
+
type CalendarDate,
|
|
11
|
+
type CalendarIdentifier,
|
|
12
|
+
type DateValue,
|
|
13
|
+
} from "@internationalized/date";
|
|
14
|
+
import { type MaybeAccessor } from "../utils";
|
|
15
|
+
export type ValidationState = "valid" | "invalid";
|
|
16
|
+
export type CalendarPageBehavior = "single" | "visible";
|
|
17
|
+
export type CalendarSelectionAlignment = "start" | "center" | "end";
|
|
18
|
+
export type CalendarDayOfWeek = "sun" | "mon" | "tue" | "wed" | "thu" | "fri" | "sat";
|
|
11
19
|
export interface CalendarStateProps<T extends DateValue = DateValue> {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
20
|
+
/** The current value (controlled). */
|
|
21
|
+
value?: MaybeAccessor<T | null>;
|
|
22
|
+
/** The default value (uncontrolled). */
|
|
23
|
+
defaultValue?: T | null;
|
|
24
|
+
/** Handler called when the value changes. */
|
|
25
|
+
onChange?: (value: T | null) => void;
|
|
26
|
+
/** The minimum allowed date. */
|
|
27
|
+
minValue?: MaybeAccessor<DateValue | undefined>;
|
|
28
|
+
/** The maximum allowed date. */
|
|
29
|
+
maxValue?: MaybeAccessor<DateValue | undefined>;
|
|
30
|
+
/** Whether the calendar is disabled. */
|
|
31
|
+
isDisabled?: MaybeAccessor<boolean>;
|
|
32
|
+
/** Whether the calendar is read-only. */
|
|
33
|
+
isReadOnly?: MaybeAccessor<boolean>;
|
|
34
|
+
/** Whether dates outside the visible range are automatically focused. */
|
|
35
|
+
autoFocus?: boolean;
|
|
36
|
+
/** The date that is focused when the calendar first mounts. */
|
|
37
|
+
focusedValue?: MaybeAccessor<DateValue | null | undefined>;
|
|
38
|
+
/** The default focused date (uncontrolled). */
|
|
39
|
+
defaultFocusedValue?: DateValue;
|
|
40
|
+
/** Handler called when the focused date changes. */
|
|
41
|
+
onFocusChange?: (date: CalendarDate) => void;
|
|
42
|
+
/** The locale to use for formatting. */
|
|
43
|
+
locale?: MaybeAccessor<string | undefined>;
|
|
44
|
+
/** Creates a calendar object for a locale calendar identifier. */
|
|
45
|
+
createCalendar?: (identifier: CalendarIdentifier) => InternationalizedCalendar;
|
|
46
|
+
/** Callback that is called for each date in the calendar to determine if it is unavailable. */
|
|
47
|
+
isDateUnavailable?: (date: DateValue) => boolean;
|
|
48
|
+
/** The number of months to display at once. */
|
|
49
|
+
visibleMonths?: number;
|
|
50
|
+
/** Controls whether paging advances by one month or by the visible month range. */
|
|
51
|
+
pageBehavior?: CalendarPageBehavior;
|
|
52
|
+
/** Determines how the visible months align around the initial focused date. */
|
|
53
|
+
selectionAlignment?: CalendarSelectionAlignment;
|
|
54
|
+
/** Whether to automatically focus the calendar when it is mounted. */
|
|
55
|
+
autoFocusOnMount?: boolean;
|
|
56
|
+
/** Controls which days are disabled. */
|
|
57
|
+
isDateDisabled?: (date: DateValue) => boolean;
|
|
58
|
+
/** Validation state. */
|
|
59
|
+
validationState?: MaybeAccessor<ValidationState | undefined>;
|
|
60
|
+
/** Error message. */
|
|
61
|
+
errorMessage?: string;
|
|
62
|
+
/** The first day of the week (0 = Sunday, 1 = Monday, etc.). */
|
|
63
|
+
firstDayOfWeek?: 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
50
64
|
}
|
|
51
65
|
export interface CalendarState<T extends DateValue = DateValue> {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
66
|
+
/** The currently selected date. */
|
|
67
|
+
value: Accessor<T | null>;
|
|
68
|
+
/** Sets the selected date. */
|
|
69
|
+
setValue: (value: T | null) => void;
|
|
70
|
+
/** The currently focused date. */
|
|
71
|
+
focusedDate: Accessor<CalendarDate>;
|
|
72
|
+
/** Sets the focused date. */
|
|
73
|
+
setFocusedDate: (date: CalendarDate) => void;
|
|
74
|
+
/** Whether the calendar is disabled. */
|
|
75
|
+
isDisabled: Accessor<boolean>;
|
|
76
|
+
/** Whether the calendar is read-only. */
|
|
77
|
+
isReadOnly: Accessor<boolean>;
|
|
78
|
+
/** The visible date range (first and last day of visible month(s)). */
|
|
79
|
+
visibleRange: Accessor<{
|
|
80
|
+
start: CalendarDate;
|
|
81
|
+
end: CalendarDate;
|
|
82
|
+
}>;
|
|
83
|
+
/** The timezone used for date calculations. */
|
|
84
|
+
timeZone: string;
|
|
85
|
+
/** The locale used for formatting and locale-specific week starts. */
|
|
86
|
+
locale: Accessor<string>;
|
|
87
|
+
/** The explicitly requested first weekday, or undefined for the locale default. */
|
|
88
|
+
firstDayOfWeek: Accessor<CalendarDayOfWeek | undefined>;
|
|
89
|
+
/** The validation state. */
|
|
90
|
+
validationState: Accessor<ValidationState | undefined>;
|
|
91
|
+
/** Whether the current value is invalid according to validation state. */
|
|
92
|
+
isValueInvalid: Accessor<boolean>;
|
|
93
|
+
/** Whether a date is selected. */
|
|
94
|
+
isSelected: (date: DateValue) => boolean;
|
|
95
|
+
/** Whether a date is focused. */
|
|
96
|
+
isCellFocused: (date: DateValue) => boolean;
|
|
97
|
+
/** Whether a date is unavailable. */
|
|
98
|
+
isCellUnavailable: (date: DateValue) => boolean;
|
|
99
|
+
/** Whether a date is disabled. */
|
|
100
|
+
isCellDisabled: (date: DateValue) => boolean;
|
|
101
|
+
/** Whether a date is outside the visible range. */
|
|
102
|
+
isOutsideVisibleRange: (date: DateValue) => boolean;
|
|
103
|
+
/** Whether a date is invalid. */
|
|
104
|
+
isInvalid: (date: DateValue) => boolean;
|
|
105
|
+
/** Moves focus to the previous page (month). */
|
|
106
|
+
focusPreviousPage: () => void;
|
|
107
|
+
/** Moves focus to the next page (month). */
|
|
108
|
+
focusNextPage: () => void;
|
|
109
|
+
/** Moves focus to the previous section (year). */
|
|
110
|
+
focusPreviousSection: () => void;
|
|
111
|
+
/** Moves focus to the next section (year). */
|
|
112
|
+
focusNextSection: () => void;
|
|
113
|
+
/** Moves focus to the previous day. */
|
|
114
|
+
focusPreviousDay: () => void;
|
|
115
|
+
/** Moves focus to the next day. */
|
|
116
|
+
focusNextDay: () => void;
|
|
117
|
+
/** Moves focus to the previous week. */
|
|
118
|
+
focusPreviousWeek: () => void;
|
|
119
|
+
/** Moves focus to the next week. */
|
|
120
|
+
focusNextWeek: () => void;
|
|
121
|
+
/** Moves focus to the start of the month. */
|
|
122
|
+
focusPageStart: () => void;
|
|
123
|
+
/** Moves focus to the end of the month. */
|
|
124
|
+
focusPageEnd: () => void;
|
|
125
|
+
/** Selects the focused date. */
|
|
126
|
+
selectFocusedDate: () => void;
|
|
127
|
+
/** Selects a specific date. */
|
|
128
|
+
selectDate: (date: CalendarDate) => void;
|
|
129
|
+
/** Whether focus is currently within the calendar. */
|
|
130
|
+
isFocused: Accessor<boolean>;
|
|
131
|
+
/** Sets whether focus is within the calendar. */
|
|
132
|
+
setFocused: (focused: boolean) => void;
|
|
133
|
+
/** Gets the dates for a week in the visible range. */
|
|
134
|
+
getDatesInWeek: (weekIndex: number, monthStartDate?: CalendarDate) => (CalendarDate | null)[];
|
|
135
|
+
/** Gets the number of weeks in a month. */
|
|
136
|
+
getWeeksInMonth: (date?: CalendarDate) => number;
|
|
137
|
+
/** The week day headers. */
|
|
138
|
+
weekDays: Accessor<string[]>;
|
|
139
|
+
/** The title for the calendar (formatted month and year). */
|
|
140
|
+
title: Accessor<string>;
|
|
141
|
+
/** The number of visible months. */
|
|
142
|
+
visibleMonths: number;
|
|
143
|
+
/** Whether the calendar is paginating (for animations). */
|
|
144
|
+
isPaginating: Accessor<boolean>;
|
|
125
145
|
}
|
|
126
146
|
/**
|
|
127
147
|
* Provides state management for a calendar component.
|
|
128
148
|
*/
|
|
129
|
-
export declare function createCalendarState<T extends DateValue = CalendarDate>(
|
|
130
|
-
|
|
149
|
+
export declare function createCalendarState<T extends DateValue = CalendarDate>(
|
|
150
|
+
props?: CalendarStateProps<T>,
|
|
151
|
+
): CalendarState<T>;
|
|
152
|
+
//# sourceMappingURL=createCalendarState.d.ts.map
|