@proyecto-viviana/solid-stately 0.2.2 → 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/index.js +43 -43
- package/dist/index.js.map +1 -1
- package/package.json +7 -5
- package/src/autocomplete/createAutocompleteState.d.ts +46 -0
- package/src/autocomplete/createAutocompleteState.d.ts.map +1 -0
- package/src/autocomplete/createAutocompleteState.ts +90 -0
- package/src/autocomplete/index.d.ts +2 -0
- package/src/autocomplete/index.d.ts.map +1 -0
- package/src/autocomplete/index.ts +5 -0
- package/src/calendar/createCalendarState.d.ts +130 -0
- package/src/calendar/createCalendarState.d.ts.map +1 -0
- package/src/calendar/createCalendarState.ts +461 -0
- package/src/calendar/createDateFieldState.d.ts +110 -0
- package/src/calendar/createDateFieldState.d.ts.map +1 -0
- package/src/calendar/createDateFieldState.ts +562 -0
- package/src/calendar/createRangeCalendarState.d.ts +146 -0
- package/src/calendar/createRangeCalendarState.d.ts.map +1 -0
- package/src/calendar/createRangeCalendarState.ts +535 -0
- package/src/calendar/createTimeFieldState.d.ts +95 -0
- package/src/calendar/createTimeFieldState.d.ts.map +1 -0
- package/src/calendar/createTimeFieldState.ts +483 -0
- package/src/calendar/index.d.ts +7 -0
- package/src/calendar/index.d.ts.map +1 -0
- package/src/calendar/index.ts +81 -0
- package/src/checkbox/createCheckboxGroupState.d.ts +71 -0
- package/src/checkbox/createCheckboxGroupState.d.ts.map +1 -0
- package/src/checkbox/createCheckboxGroupState.ts +193 -0
- package/src/checkbox/index.d.ts +2 -0
- package/src/checkbox/index.d.ts.map +1 -0
- package/src/checkbox/index.ts +5 -0
- package/src/collections/ListCollection.d.ts +37 -0
- package/src/collections/ListCollection.d.ts.map +1 -0
- package/src/collections/ListCollection.ts +146 -0
- package/src/collections/createListState.d.ts +79 -0
- package/src/collections/createListState.d.ts.map +1 -0
- package/src/collections/createListState.ts +264 -0
- package/src/collections/createMenuState.d.ts +50 -0
- package/src/collections/createMenuState.d.ts.map +1 -0
- package/src/collections/createMenuState.ts +106 -0
- package/src/collections/createSelectionState.d.ts +76 -0
- package/src/collections/createSelectionState.d.ts.map +1 -0
- package/src/collections/createSelectionState.ts +336 -0
- package/src/collections/index.d.ts +6 -0
- package/src/collections/index.d.ts.map +1 -0
- package/src/collections/index.ts +46 -0
- package/src/collections/types.d.ts +147 -0
- package/src/collections/types.d.ts.map +1 -0
- package/src/collections/types.ts +169 -0
- package/src/color/Color.d.ts +28 -0
- package/src/color/Color.d.ts.map +1 -0
- package/src/color/Color.ts +951 -0
- package/src/color/createColorAreaState.d.ts +76 -0
- package/src/color/createColorAreaState.d.ts.map +1 -0
- package/src/color/createColorAreaState.ts +293 -0
- package/src/color/createColorFieldState.d.ts +55 -0
- package/src/color/createColorFieldState.d.ts.map +1 -0
- package/src/color/createColorFieldState.ts +292 -0
- package/src/color/createColorSliderState.d.ts +67 -0
- package/src/color/createColorSliderState.d.ts.map +1 -0
- package/src/color/createColorSliderState.ts +241 -0
- package/src/color/createColorWheelState.d.ts +51 -0
- package/src/color/createColorWheelState.d.ts.map +1 -0
- package/src/color/createColorWheelState.ts +211 -0
- package/src/color/index.d.ts +10 -0
- package/src/color/index.d.ts.map +1 -0
- package/src/color/index.ts +47 -0
- package/src/color/types.d.ts +106 -0
- package/src/color/types.d.ts.map +1 -0
- package/src/color/types.ts +127 -0
- package/src/combobox/createComboBoxState.d.ts +125 -0
- package/src/combobox/createComboBoxState.d.ts.map +1 -0
- package/src/combobox/createComboBoxState.ts +703 -0
- package/src/combobox/index.d.ts +5 -0
- package/src/combobox/index.d.ts.map +1 -0
- package/src/combobox/index.ts +13 -0
- package/src/disclosure/createDisclosureState.d.ts +64 -0
- package/src/disclosure/createDisclosureState.d.ts.map +1 -0
- package/src/disclosure/createDisclosureState.ts +193 -0
- package/src/disclosure/index.d.ts +2 -0
- package/src/disclosure/index.d.ts.map +1 -0
- package/src/disclosure/index.ts +9 -0
- package/src/dnd/createDragState.d.ts +59 -0
- package/src/dnd/createDragState.d.ts.map +1 -0
- package/src/dnd/createDragState.ts +153 -0
- package/src/dnd/createDraggableCollectionState.d.ts +57 -0
- package/src/dnd/createDraggableCollectionState.d.ts.map +1 -0
- package/src/dnd/createDraggableCollectionState.ts +165 -0
- package/src/dnd/createDropState.d.ts +61 -0
- package/src/dnd/createDropState.d.ts.map +1 -0
- package/src/dnd/createDropState.ts +212 -0
- package/src/dnd/createDroppableCollectionState.d.ts +78 -0
- package/src/dnd/createDroppableCollectionState.d.ts.map +1 -0
- package/src/dnd/createDroppableCollectionState.ts +357 -0
- package/src/dnd/index.d.ts +11 -0
- package/src/dnd/index.d.ts.map +1 -0
- package/src/dnd/index.ts +76 -0
- package/src/dnd/types.d.ts +264 -0
- package/src/dnd/types.d.ts.map +1 -0
- package/src/dnd/types.ts +317 -0
- package/src/form/createFormValidationState.d.ts +100 -0
- package/src/form/createFormValidationState.d.ts.map +1 -0
- package/src/form/createFormValidationState.ts +389 -0
- package/src/form/index.d.ts +2 -0
- package/src/form/index.d.ts.map +1 -0
- package/src/form/index.ts +15 -0
- package/src/grid/createGridState.d.ts +12 -0
- package/src/grid/createGridState.d.ts.map +1 -0
- package/src/grid/createGridState.ts +327 -0
- package/src/grid/index.d.ts +7 -0
- package/src/grid/index.d.ts.map +1 -0
- package/src/grid/index.ts +13 -0
- package/src/grid/types.d.ts +156 -0
- package/src/grid/types.d.ts.map +1 -0
- package/src/grid/types.ts +179 -0
- package/src/index.d.ts +26 -0
- package/src/index.d.ts.map +1 -0
- package/src/index.ts +383 -0
- package/src/numberfield/createNumberFieldState.d.ts +65 -0
- package/src/numberfield/createNumberFieldState.d.ts.map +1 -0
- package/src/numberfield/createNumberFieldState.ts +383 -0
- package/src/numberfield/index.d.ts +2 -0
- package/src/numberfield/index.d.ts.map +1 -0
- package/src/numberfield/index.ts +5 -0
- package/src/overlays/createOverlayTriggerState.d.ts +32 -0
- package/src/overlays/createOverlayTriggerState.d.ts.map +1 -0
- package/src/overlays/createOverlayTriggerState.ts +67 -0
- package/src/overlays/index.d.ts +2 -0
- package/src/overlays/index.d.ts.map +1 -0
- package/src/overlays/index.ts +5 -0
- package/src/radio/createRadioGroupState.d.ts +77 -0
- package/src/radio/createRadioGroupState.d.ts.map +1 -0
- package/src/radio/createRadioGroupState.ts +201 -0
- package/src/radio/index.d.ts +2 -0
- package/src/radio/index.d.ts.map +1 -0
- package/src/radio/index.ts +6 -0
- package/src/searchfield/createSearchFieldState.d.ts +25 -0
- package/src/searchfield/createSearchFieldState.d.ts.map +1 -0
- package/src/searchfield/createSearchFieldState.ts +62 -0
- package/src/searchfield/index.d.ts +3 -0
- package/src/searchfield/index.d.ts.map +1 -0
- package/src/searchfield/index.ts +5 -0
- package/src/select/createSelectState.d.ts +73 -0
- package/src/select/createSelectState.d.ts.map +1 -0
- package/src/select/createSelectState.ts +181 -0
- package/src/select/index.d.ts +2 -0
- package/src/select/index.d.ts.map +1 -0
- package/src/select/index.ts +5 -0
- package/src/slider/createSliderState.d.ts +72 -0
- package/src/slider/createSliderState.d.ts.map +1 -0
- package/src/slider/createSliderState.ts +211 -0
- package/src/slider/index.d.ts +3 -0
- package/src/slider/index.d.ts.map +1 -0
- package/src/slider/index.ts +6 -0
- package/src/ssr/index.d.ts +28 -0
- package/src/ssr/index.d.ts.map +1 -0
- package/src/ssr/index.ts +41 -0
- package/src/table/TableCollection.d.ts +52 -0
- package/src/table/TableCollection.d.ts.map +1 -0
- package/src/table/TableCollection.ts +388 -0
- package/src/table/createTableState.d.ts +12 -0
- package/src/table/createTableState.d.ts.map +1 -0
- package/src/table/createTableState.ts +127 -0
- package/src/table/index.d.ts +8 -0
- package/src/table/index.d.ts.map +1 -0
- package/src/table/index.ts +18 -0
- package/src/table/types.d.ts +139 -0
- package/src/table/types.d.ts.map +1 -0
- package/src/table/types.ts +150 -0
- package/src/tabs/createTabListState.d.ts +68 -0
- package/src/tabs/createTabListState.d.ts.map +1 -0
- package/src/tabs/createTabListState.ts +240 -0
- package/src/tabs/index.d.ts +2 -0
- package/src/tabs/index.d.ts.map +1 -0
- package/src/tabs/index.ts +7 -0
- package/src/textfield/createTextFieldState.d.ts +30 -0
- package/src/textfield/createTextFieldState.d.ts.map +1 -0
- package/src/textfield/createTextFieldState.ts +75 -0
- package/src/textfield/index.d.ts +2 -0
- package/src/textfield/index.d.ts.map +1 -0
- package/src/textfield/index.ts +5 -0
- package/src/toast/createToastState.d.ts +118 -0
- package/src/toast/createToastState.d.ts.map +1 -0
- package/src/toast/createToastState.ts +316 -0
- package/src/toast/index.d.ts +2 -0
- package/src/toast/index.d.ts.map +1 -0
- package/src/toast/index.ts +11 -0
- package/src/toggle/createToggleState.d.ts +34 -0
- package/src/toggle/createToggleState.d.ts.map +1 -0
- package/src/toggle/createToggleState.ts +94 -0
- package/src/toggle/index.d.ts +2 -0
- package/src/toggle/index.d.ts.map +1 -0
- package/src/toggle/index.ts +5 -0
- package/src/tooltip/createTooltipTriggerState.d.ts +39 -0
- package/src/tooltip/createTooltipTriggerState.d.ts.map +1 -0
- package/src/tooltip/createTooltipTriggerState.ts +183 -0
- package/src/tooltip/index.d.ts +2 -0
- package/src/tooltip/index.d.ts.map +1 -0
- package/src/tooltip/index.ts +6 -0
- package/src/tree/TreeCollection.d.ts +40 -0
- package/src/tree/TreeCollection.d.ts.map +1 -0
- package/src/tree/TreeCollection.ts +175 -0
- package/src/tree/createTreeState.d.ts +14 -0
- package/src/tree/createTreeState.d.ts.map +1 -0
- package/src/tree/createTreeState.ts +392 -0
- package/src/tree/index.d.ts +7 -0
- package/src/tree/index.d.ts.map +1 -0
- package/src/tree/index.ts +13 -0
- package/src/tree/types.d.ts +157 -0
- package/src/tree/types.d.ts.map +1 -0
- package/src/tree/types.ts +174 -0
- package/src/utils/index.d.ts +2 -0
- package/src/utils/index.d.ts.map +1 -0
- package/src/utils/index.ts +1 -0
- package/src/utils/reactivity.d.ts +28 -0
- package/src/utils/reactivity.d.ts.map +1 -0
- package/src/utils/reactivity.ts +36 -0
- package/dist/index.jsx +0 -6408
- package/dist/index.jsx.map +0 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@proyecto-viviana/solid-stately",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"description": "A 1-1 SolidJS port of React Stately - headless state management for UI components",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -9,18 +9,20 @@
|
|
|
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",
|
|
22
24
|
"dev": "tsup --watch",
|
|
23
|
-
"prepublishOnly": "deno task
|
|
25
|
+
"prepublishOnly": "echo 'Use deno task release from root'"
|
|
24
26
|
},
|
|
25
27
|
"peerDependencies": {
|
|
26
28
|
"solid-js": "^1.9.0"
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* createAutocompleteState - State management for autocomplete components
|
|
3
|
+
*
|
|
4
|
+
* Based on @react-stately/autocomplete useAutocompleteState.
|
|
5
|
+
*/
|
|
6
|
+
import { type Accessor } from 'solid-js';
|
|
7
|
+
export interface AutocompleteState {
|
|
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
|
+
}
|
|
17
|
+
export interface AutocompleteStateOptions {
|
|
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
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Provides state management for an autocomplete component.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```tsx
|
|
30
|
+
* const state = createAutocompleteState({
|
|
31
|
+
* defaultInputValue: '',
|
|
32
|
+
* onInputChange: (value) => console.log('Input changed:', value),
|
|
33
|
+
* });
|
|
34
|
+
*
|
|
35
|
+
* // Access current input value
|
|
36
|
+
* console.log(state.inputValue());
|
|
37
|
+
*
|
|
38
|
+
* // Update input value
|
|
39
|
+
* state.setInputValue('new value');
|
|
40
|
+
*
|
|
41
|
+
* // Track focused node for aria-activedescendant
|
|
42
|
+
* state.setFocusedNodeId('item-1');
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
export declare function createAutocompleteState(props?: AutocompleteStateOptions): AutocompleteState;
|
|
46
|
+
//# sourceMappingURL=createAutocompleteState.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createAutocompleteState.d.ts","sourceRoot":"","sources":["createAutocompleteState.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAgB,KAAK,QAAQ,EAAE,MAAM,UAAU,CAAA;AAMtD,MAAM,WAAW,iBAAiB;IAChC,mDAAmD;IACnD,UAAU,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAA;IAC5B,gDAAgD;IAChD,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IAClC,6EAA6E;IAC7E,aAAa,EAAE,QAAQ,CAAC,MAAM,GAAG,IAAI,CAAC,CAAA;IACtC,kFAAkF;IAClF,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAAA;CAC7C;AAED,MAAM,WAAW,wBAAwB;IACvC,wDAAwD;IACxD,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,kEAAkE;IAClE,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,wEAAwE;IACxE,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;CACxC;AAMD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,uBAAuB,CACrC,KAAK,GAAE,wBAA6B,GACnC,iBAAiB,CA+BnB"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* createAutocompleteState - State management for autocomplete components
|
|
3
|
+
*
|
|
4
|
+
* Based on @react-stately/autocomplete useAutocompleteState.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { createSignal, type Accessor } from 'solid-js'
|
|
8
|
+
|
|
9
|
+
// ============================================
|
|
10
|
+
// TYPES
|
|
11
|
+
// ============================================
|
|
12
|
+
|
|
13
|
+
export interface AutocompleteState {
|
|
14
|
+
/** The current value of the autocomplete input. */
|
|
15
|
+
inputValue: Accessor<string>
|
|
16
|
+
/** Sets the value of the autocomplete input. */
|
|
17
|
+
setInputValue(value: string): void
|
|
18
|
+
/** The id of the current aria-activedescendant of the autocomplete input. */
|
|
19
|
+
focusedNodeId: Accessor<string | null>
|
|
20
|
+
/** Sets the id of the current aria-activedescendant of the autocomplete input. */
|
|
21
|
+
setFocusedNodeId(value: string | null): void
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface AutocompleteStateOptions {
|
|
25
|
+
/** The value of the autocomplete input (controlled). */
|
|
26
|
+
inputValue?: string
|
|
27
|
+
/** The default value of the autocomplete input (uncontrolled). */
|
|
28
|
+
defaultInputValue?: string
|
|
29
|
+
/** Handler that is called when the autocomplete input value changes. */
|
|
30
|
+
onInputChange?: (value: string) => void
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// ============================================
|
|
34
|
+
// CREATE AUTOCOMPLETE STATE
|
|
35
|
+
// ============================================
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Provides state management for an autocomplete component.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```tsx
|
|
42
|
+
* const state = createAutocompleteState({
|
|
43
|
+
* defaultInputValue: '',
|
|
44
|
+
* onInputChange: (value) => console.log('Input changed:', value),
|
|
45
|
+
* });
|
|
46
|
+
*
|
|
47
|
+
* // Access current input value
|
|
48
|
+
* console.log(state.inputValue());
|
|
49
|
+
*
|
|
50
|
+
* // Update input value
|
|
51
|
+
* state.setInputValue('new value');
|
|
52
|
+
*
|
|
53
|
+
* // Track focused node for aria-activedescendant
|
|
54
|
+
* state.setFocusedNodeId('item-1');
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
export function createAutocompleteState(
|
|
58
|
+
props: AutocompleteStateOptions = {}
|
|
59
|
+
): AutocompleteState {
|
|
60
|
+
const {
|
|
61
|
+
inputValue: controlledInputValue,
|
|
62
|
+
defaultInputValue = '',
|
|
63
|
+
onInputChange,
|
|
64
|
+
} = props
|
|
65
|
+
|
|
66
|
+
// Track focused node ID for aria-activedescendant
|
|
67
|
+
const [focusedNodeId, setFocusedNodeId] = createSignal<string | null>(null)
|
|
68
|
+
|
|
69
|
+
// Handle controlled vs uncontrolled input value
|
|
70
|
+
const isControlled = controlledInputValue !== undefined
|
|
71
|
+
const [uncontrolledValue, setUncontrolledValue] = createSignal(defaultInputValue)
|
|
72
|
+
|
|
73
|
+
const inputValue: Accessor<string> = () => {
|
|
74
|
+
return isControlled ? controlledInputValue : uncontrolledValue()
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const setInputValue = (value: string) => {
|
|
78
|
+
if (!isControlled) {
|
|
79
|
+
setUncontrolledValue(value)
|
|
80
|
+
}
|
|
81
|
+
onInputChange?.(value)
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return {
|
|
85
|
+
inputValue,
|
|
86
|
+
setInputValue,
|
|
87
|
+
focusedNodeId,
|
|
88
|
+
setFocusedNodeId,
|
|
89
|
+
}
|
|
90
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EACvB,KAAK,iBAAiB,EACtB,KAAK,wBAAwB,GAC9B,MAAM,2BAA2B,CAAA"}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CalendarState for Solid-Stately
|
|
3
|
+
*
|
|
4
|
+
* Provides state management for calendar components.
|
|
5
|
+
* Based on @react-stately/calendar useCalendarState
|
|
6
|
+
*/
|
|
7
|
+
import { type Accessor } from 'solid-js';
|
|
8
|
+
import { type CalendarDate, type DateValue } from '@internationalized/date';
|
|
9
|
+
import { type MaybeAccessor } from '../utils';
|
|
10
|
+
export type ValidationState = 'valid' | 'invalid';
|
|
11
|
+
export interface CalendarStateProps<T extends DateValue = DateValue> {
|
|
12
|
+
/** The current value (controlled). */
|
|
13
|
+
value?: MaybeAccessor<T | null>;
|
|
14
|
+
/** The default value (uncontrolled). */
|
|
15
|
+
defaultValue?: T | null;
|
|
16
|
+
/** Handler called when the value changes. */
|
|
17
|
+
onChange?: (value: T) => void;
|
|
18
|
+
/** The minimum allowed date. */
|
|
19
|
+
minValue?: MaybeAccessor<DateValue | undefined>;
|
|
20
|
+
/** The maximum allowed date. */
|
|
21
|
+
maxValue?: MaybeAccessor<DateValue | undefined>;
|
|
22
|
+
/** Whether the calendar is disabled. */
|
|
23
|
+
isDisabled?: MaybeAccessor<boolean>;
|
|
24
|
+
/** Whether the calendar is read-only. */
|
|
25
|
+
isReadOnly?: MaybeAccessor<boolean>;
|
|
26
|
+
/** Whether dates outside the visible range are automatically focused. */
|
|
27
|
+
autoFocus?: boolean;
|
|
28
|
+
/** The date that is focused when the calendar first mounts. */
|
|
29
|
+
focusedValue?: MaybeAccessor<DateValue | undefined>;
|
|
30
|
+
/** The default focused date (uncontrolled). */
|
|
31
|
+
defaultFocusedValue?: DateValue;
|
|
32
|
+
/** Handler called when the focused date changes. */
|
|
33
|
+
onFocusChange?: (date: CalendarDate) => void;
|
|
34
|
+
/** The locale to use for formatting. */
|
|
35
|
+
locale?: string;
|
|
36
|
+
/** Callback that is called for each date in the calendar to determine if it is unavailable. */
|
|
37
|
+
isDateUnavailable?: (date: DateValue) => boolean;
|
|
38
|
+
/** The number of months to display at once. */
|
|
39
|
+
visibleMonths?: number;
|
|
40
|
+
/** Whether to automatically focus the calendar when it is mounted. */
|
|
41
|
+
autoFocusOnMount?: boolean;
|
|
42
|
+
/** Controls which days are disabled. */
|
|
43
|
+
isDateDisabled?: (date: DateValue) => boolean;
|
|
44
|
+
/** Validation state. */
|
|
45
|
+
validationState?: MaybeAccessor<ValidationState | undefined>;
|
|
46
|
+
/** Error message. */
|
|
47
|
+
errorMessage?: string;
|
|
48
|
+
/** The first day of the week (0 = Sunday, 1 = Monday, etc.). */
|
|
49
|
+
firstDayOfWeek?: 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
50
|
+
}
|
|
51
|
+
export interface CalendarState<T extends DateValue = DateValue> {
|
|
52
|
+
/** The currently selected date. */
|
|
53
|
+
value: Accessor<T | null>;
|
|
54
|
+
/** Sets the selected date. */
|
|
55
|
+
setValue: (value: T | null) => void;
|
|
56
|
+
/** The currently focused date. */
|
|
57
|
+
focusedDate: Accessor<CalendarDate>;
|
|
58
|
+
/** Sets the focused date. */
|
|
59
|
+
setFocusedDate: (date: CalendarDate) => void;
|
|
60
|
+
/** Whether the calendar is disabled. */
|
|
61
|
+
isDisabled: Accessor<boolean>;
|
|
62
|
+
/** Whether the calendar is read-only. */
|
|
63
|
+
isReadOnly: Accessor<boolean>;
|
|
64
|
+
/** The visible date range (first and last day of visible month(s)). */
|
|
65
|
+
visibleRange: Accessor<{
|
|
66
|
+
start: CalendarDate;
|
|
67
|
+
end: CalendarDate;
|
|
68
|
+
}>;
|
|
69
|
+
/** The timezone used for date calculations. */
|
|
70
|
+
timeZone: string;
|
|
71
|
+
/** The validation state. */
|
|
72
|
+
validationState: Accessor<ValidationState | undefined>;
|
|
73
|
+
/** Whether a date is selected. */
|
|
74
|
+
isSelected: (date: DateValue) => boolean;
|
|
75
|
+
/** Whether a date is focused. */
|
|
76
|
+
isCellFocused: (date: DateValue) => boolean;
|
|
77
|
+
/** Whether a date is unavailable. */
|
|
78
|
+
isCellUnavailable: (date: DateValue) => boolean;
|
|
79
|
+
/** Whether a date is disabled. */
|
|
80
|
+
isCellDisabled: (date: DateValue) => boolean;
|
|
81
|
+
/** Whether a date is outside the visible range. */
|
|
82
|
+
isOutsideVisibleRange: (date: DateValue) => boolean;
|
|
83
|
+
/** Whether a date is invalid. */
|
|
84
|
+
isInvalid: (date: DateValue) => boolean;
|
|
85
|
+
/** Moves focus to the previous page (month). */
|
|
86
|
+
focusPreviousPage: () => void;
|
|
87
|
+
/** Moves focus to the next page (month). */
|
|
88
|
+
focusNextPage: () => void;
|
|
89
|
+
/** Moves focus to the previous section (year). */
|
|
90
|
+
focusPreviousSection: () => void;
|
|
91
|
+
/** Moves focus to the next section (year). */
|
|
92
|
+
focusNextSection: () => void;
|
|
93
|
+
/** Moves focus to the previous day. */
|
|
94
|
+
focusPreviousDay: () => void;
|
|
95
|
+
/** Moves focus to the next day. */
|
|
96
|
+
focusNextDay: () => void;
|
|
97
|
+
/** Moves focus to the previous week. */
|
|
98
|
+
focusPreviousWeek: () => void;
|
|
99
|
+
/** Moves focus to the next week. */
|
|
100
|
+
focusNextWeek: () => void;
|
|
101
|
+
/** Moves focus to the start of the month. */
|
|
102
|
+
focusPageStart: () => void;
|
|
103
|
+
/** Moves focus to the end of the month. */
|
|
104
|
+
focusPageEnd: () => void;
|
|
105
|
+
/** Selects the focused date. */
|
|
106
|
+
selectFocusedDate: () => void;
|
|
107
|
+
/** Selects a specific date. */
|
|
108
|
+
selectDate: (date: CalendarDate) => void;
|
|
109
|
+
/** Whether focus is currently within the calendar. */
|
|
110
|
+
isFocused: Accessor<boolean>;
|
|
111
|
+
/** Sets whether focus is within the calendar. */
|
|
112
|
+
setFocused: (focused: boolean) => void;
|
|
113
|
+
/** Gets the dates for a week in the visible range. */
|
|
114
|
+
getDatesInWeek: (weekIndex: number, monthStartDate?: CalendarDate) => (CalendarDate | null)[];
|
|
115
|
+
/** Gets the number of weeks in a month. */
|
|
116
|
+
getWeeksInMonth: (date?: CalendarDate) => number;
|
|
117
|
+
/** The week day headers. */
|
|
118
|
+
weekDays: Accessor<string[]>;
|
|
119
|
+
/** The title for the calendar (formatted month and year). */
|
|
120
|
+
title: Accessor<string>;
|
|
121
|
+
/** The number of visible months. */
|
|
122
|
+
visibleMonths: number;
|
|
123
|
+
/** Whether the calendar is paginating (for animations). */
|
|
124
|
+
isPaginating: Accessor<boolean>;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Provides state management for a calendar component.
|
|
128
|
+
*/
|
|
129
|
+
export declare function createCalendarState<T extends DateValue = CalendarDate>(props?: CalendarStateProps<T>): CalendarState<T>;
|
|
130
|
+
//# sourceMappingURL=createCalendarState.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createCalendarState.d.ts","sourceRoot":"","sources":["createCalendarState.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAA4B,KAAK,QAAQ,EAAE,MAAM,UAAU,CAAC;AACnE,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,SAAS,EAYf,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAU,KAAK,aAAa,EAAE,MAAM,UAAU,CAAC;AAMtD,MAAM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