@proyecto-viviana/solid-stately 0.2.7 → 0.4.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/IncompleteDate.d.ts +61 -0
- package/dist/calendar/createCalendarState.d.ts +41 -16
- package/dist/calendar/createDateFieldState.d.ts +39 -9
- package/dist/calendar/createDatePickerState.d.ts +60 -0
- package/dist/calendar/createRangeCalendarState.d.ts +37 -10
- 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 +11 -8
- package/dist/collections/createMenuState.d.ts +7 -7
- package/dist/collections/createSelectionState.d.ts +22 -10
- package/dist/collections/getChildNodes.d.ts +11 -0
- package/dist/collections/index.d.ts +6 -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 +34 -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 +19 -17
- 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 +27 -11
- package/dist/index.d.ts +31 -30
- package/dist/index.js +9077 -7246
- 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 +14 -8
- package/dist/select/index.d.ts +1 -1
- package/dist/selection/Selection.d.ts +16 -0
- package/dist/selection/SelectionManager.d.ts +110 -0
- package/dist/selection/createMultipleSelectionState.d.ts +59 -0
- package/dist/selection/index.d.ts +6 -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 +33 -3
- package/dist/table/createTableColumnResizeState.d.ts +54 -0
- package/dist/table/createTableState.d.ts +2 -2
- package/dist/table/createTreeGridState.d.ts +15 -0
- package/dist/table/index.d.ts +6 -3
- package/dist/table/types.d.ts +68 -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 +24 -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 +27 -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/IncompleteDate.ts +430 -0
- package/src/calendar/createCalendarState.d.ts +139 -117
- package/src/calendar/createCalendarState.ts +308 -94
- package/src/calendar/createDateFieldState.d.ts +130 -95
- package/src/calendar/createDateFieldState.ts +447 -334
- package/src/calendar/createDatePickerState.ts +347 -0
- package/src/calendar/createRangeCalendarState.d.ts +154 -129
- package/src/calendar/createRangeCalendarState.ts +411 -85
- 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 +23 -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 +67 -35
- package/src/collections/createMenuState.d.ts +36 -31
- package/src/collections/createMenuState.ts +21 -12
- package/src/collections/createSelectionState.d.ts +78 -65
- package/src/collections/createSelectionState.ts +66 -52
- package/src/collections/getChildNodes.ts +98 -0
- package/src/collections/index.d.ts +38 -6
- package/src/collections/index.ts +14 -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 +184 -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 +55 -6
- package/src/dnd/index.ts +6 -18
- package/src/dnd/types.d.ts +170 -157
- package/src/dnd/types.ts +24 -22
- 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 +78 -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 +34 -18
- package/src/index.d.ts +311 -26
- package/src/index.ts +59 -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 +42 -29
- package/src/select/index.d.ts +2 -2
- package/src/select/index.ts +1 -5
- package/src/selection/Selection.ts +28 -0
- package/src/selection/SelectionManager.ts +526 -0
- package/src/selection/createMultipleSelectionState.ts +247 -0
- package/src/selection/index.ts +12 -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 +266 -99
- package/src/table/createTableColumnResizeState.ts +242 -0
- package/src/table/createTableState.d.ts +7 -4
- package/src/table/createTableState.ts +30 -7
- package/src/table/createTreeGridState.ts +146 -0
- package/src/table/index.d.ts +14 -4
- package/src/table/index.ts +13 -3
- package/src/table/types.d.ts +98 -92
- package/src/table/types.ts +83 -13
- package/src/tabs/createTabListState.d.ts +59 -57
- package/src/tabs/createTabListState.ts +34 -39
- 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 +90 -52
- package/src/toast/index.d.ts +12 -2
- package/src/toast/index.ts +2 -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 +70 -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 +30 -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
|
@@ -2,63 +2,67 @@
|
|
|
2
2
|
* Disclosure state management for SolidJS
|
|
3
3
|
* Based on @react-stately/disclosure useDisclosureState and useDisclosureGroupState
|
|
4
4
|
*/
|
|
5
|
-
import { type Accessor } from
|
|
6
|
-
import { type MaybeAccessor } from
|
|
5
|
+
import { type Accessor } from "solid-js";
|
|
6
|
+
import { type MaybeAccessor } from "../utils";
|
|
7
7
|
export interface DisclosureStateProps {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
/** Whether the disclosure is expanded (controlled). */
|
|
9
|
+
isExpanded?: boolean;
|
|
10
|
+
/** Whether the disclosure is expanded by default (uncontrolled). */
|
|
11
|
+
defaultExpanded?: boolean;
|
|
12
|
+
/** Handler that is called when the disclosure expanded state changes. */
|
|
13
|
+
onExpandedChange?: (isExpanded: boolean) => void;
|
|
14
14
|
}
|
|
15
15
|
export interface DisclosureState {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
16
|
+
/** Whether the disclosure is currently expanded. */
|
|
17
|
+
readonly isExpanded: Accessor<boolean>;
|
|
18
|
+
/** Sets whether the disclosure is expanded. */
|
|
19
|
+
setExpanded(isExpanded: boolean): void;
|
|
20
|
+
/** Expand the disclosure. */
|
|
21
|
+
expand(): void;
|
|
22
|
+
/** Collapse the disclosure. */
|
|
23
|
+
collapse(): void;
|
|
24
|
+
/** Toggles the disclosure's visibility. */
|
|
25
|
+
toggle(): void;
|
|
26
26
|
}
|
|
27
27
|
/**
|
|
28
28
|
* Manages state for a disclosure widget. Tracks whether the disclosure is expanded,
|
|
29
29
|
* and provides methods to toggle this state.
|
|
30
30
|
*/
|
|
31
|
-
export declare function createDisclosureState(
|
|
31
|
+
export declare function createDisclosureState(
|
|
32
|
+
props?: MaybeAccessor<DisclosureStateProps>,
|
|
33
|
+
): DisclosureState;
|
|
32
34
|
export type Key = string | number;
|
|
33
35
|
export interface DisclosureGroupStateProps {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
36
|
+
/** Whether multiple items can be expanded at the same time. */
|
|
37
|
+
allowsMultipleExpanded?: boolean;
|
|
38
|
+
/** Whether all items are disabled. */
|
|
39
|
+
isDisabled?: boolean;
|
|
40
|
+
/** The currently expanded keys in the group (controlled). */
|
|
41
|
+
expandedKeys?: Iterable<Key>;
|
|
42
|
+
/** The initial expanded keys in the group (uncontrolled). */
|
|
43
|
+
defaultExpandedKeys?: Iterable<Key>;
|
|
44
|
+
/** Handler that is called when items are expanded or collapsed. */
|
|
45
|
+
onExpandedChange?: (keys: Set<Key>) => void;
|
|
44
46
|
}
|
|
45
47
|
export interface DisclosureGroupState {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
48
|
+
/** Whether multiple items can be expanded at the same time. */
|
|
49
|
+
readonly allowsMultipleExpanded: boolean;
|
|
50
|
+
/** Whether all items are disabled. */
|
|
51
|
+
readonly isDisabled: boolean;
|
|
52
|
+
/** A set of keys for items that are expanded. */
|
|
53
|
+
readonly expandedKeys: Accessor<Set<Key>>;
|
|
54
|
+
/** Toggles the expanded state for an item by its key. */
|
|
55
|
+
toggleKey(key: Key): void;
|
|
56
|
+
/** Replaces the set of expanded keys. */
|
|
57
|
+
setExpandedKeys(keys: Set<Key>): void;
|
|
58
|
+
/** Check if a specific key is expanded. */
|
|
59
|
+
isExpanded(key: Key): boolean;
|
|
58
60
|
}
|
|
59
61
|
/**
|
|
60
62
|
* Manages state for a group of disclosures, e.g. an accordion.
|
|
61
63
|
* It supports both single and multiple expanded items.
|
|
62
64
|
*/
|
|
63
|
-
export declare function createDisclosureGroupState(
|
|
64
|
-
|
|
65
|
+
export declare function createDisclosureGroupState(
|
|
66
|
+
props?: MaybeAccessor<DisclosureGroupStateProps>,
|
|
67
|
+
): DisclosureGroupState;
|
|
68
|
+
//# sourceMappingURL=createDisclosureState.d.ts.map
|
|
@@ -3,12 +3,8 @@
|
|
|
3
3
|
* Based on @react-stately/disclosure useDisclosureState and useDisclosureGroupState
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { createSignal, createEffect, createMemo, type Accessor } from
|
|
7
|
-
import { access, type MaybeAccessor } from
|
|
8
|
-
|
|
9
|
-
// ============================================
|
|
10
|
-
// SINGLE DISCLOSURE STATE
|
|
11
|
-
// ============================================
|
|
6
|
+
import { createSignal, createEffect, createMemo, type Accessor } from "solid-js";
|
|
7
|
+
import { access, type MaybeAccessor } from "../utils";
|
|
12
8
|
|
|
13
9
|
export interface DisclosureStateProps {
|
|
14
10
|
/** Whether the disclosure is expanded (controlled). */
|
|
@@ -37,16 +33,14 @@ export interface DisclosureState {
|
|
|
37
33
|
* and provides methods to toggle this state.
|
|
38
34
|
*/
|
|
39
35
|
export function createDisclosureState(
|
|
40
|
-
props: MaybeAccessor<DisclosureStateProps> = {}
|
|
36
|
+
props: MaybeAccessor<DisclosureStateProps> = {},
|
|
41
37
|
): DisclosureState {
|
|
42
38
|
const propsAccessor = () => access(props);
|
|
43
39
|
|
|
44
|
-
// Internal state for uncontrolled mode
|
|
45
40
|
const [internalExpanded, setInternalExpanded] = createSignal(
|
|
46
|
-
propsAccessor().defaultExpanded ?? false
|
|
41
|
+
propsAccessor().defaultExpanded ?? false,
|
|
47
42
|
);
|
|
48
43
|
|
|
49
|
-
// Determine if expanded (controlled vs uncontrolled)
|
|
50
44
|
const isExpanded: Accessor<boolean> = () => {
|
|
51
45
|
const p = propsAccessor();
|
|
52
46
|
return p.isExpanded !== undefined ? p.isExpanded : internalExpanded();
|
|
@@ -73,10 +67,6 @@ export function createDisclosureState(
|
|
|
73
67
|
};
|
|
74
68
|
}
|
|
75
69
|
|
|
76
|
-
// ============================================
|
|
77
|
-
// DISCLOSURE GROUP STATE (Accordion)
|
|
78
|
-
// ============================================
|
|
79
|
-
|
|
80
70
|
export type Key = string | number;
|
|
81
71
|
|
|
82
72
|
export interface DisclosureGroupStateProps {
|
|
@@ -112,16 +102,14 @@ export interface DisclosureGroupState {
|
|
|
112
102
|
* It supports both single and multiple expanded items.
|
|
113
103
|
*/
|
|
114
104
|
export function createDisclosureGroupState(
|
|
115
|
-
props: MaybeAccessor<DisclosureGroupStateProps> = {}
|
|
105
|
+
props: MaybeAccessor<DisclosureGroupStateProps> = {},
|
|
116
106
|
): DisclosureGroupState {
|
|
117
107
|
const propsAccessor = () => access(props);
|
|
118
108
|
|
|
119
|
-
// Internal state for uncontrolled mode
|
|
120
109
|
const [internalKeys, setInternalKeys] = createSignal<Set<Key>>(
|
|
121
|
-
new Set(propsAccessor().defaultExpandedKeys ?? [])
|
|
110
|
+
new Set(propsAccessor().defaultExpandedKeys ?? []),
|
|
122
111
|
);
|
|
123
112
|
|
|
124
|
-
// Determine expanded keys (controlled vs uncontrolled, memoized)
|
|
125
113
|
const expandedKeys: Accessor<Set<Key>> = createMemo(() => {
|
|
126
114
|
const p = propsAccessor();
|
|
127
115
|
return p.expandedKeys !== undefined ? new Set(p.expandedKeys) : internalKeys();
|
|
@@ -135,8 +123,7 @@ export function createDisclosureGroupState(
|
|
|
135
123
|
p.onExpandedChange?.(keys);
|
|
136
124
|
};
|
|
137
125
|
|
|
138
|
-
// Ensure only one item is expanded if allowsMultipleExpanded is false
|
|
139
|
-
// Note: We use untrack to prevent infinite loops when calling setExpandedKeys
|
|
126
|
+
// Ensure only one item is expanded if allowsMultipleExpanded is false.
|
|
140
127
|
createEffect(() => {
|
|
141
128
|
const p = propsAccessor();
|
|
142
129
|
const allowsMultiple = p.allowsMultipleExpanded ?? false;
|
|
@@ -167,7 +154,6 @@ export function createDisclosureGroupState(
|
|
|
167
154
|
newKeys.add(key);
|
|
168
155
|
}
|
|
169
156
|
} else {
|
|
170
|
-
// Single selection: toggle off if already expanded, otherwise select only this one
|
|
171
157
|
newKeys = new Set(currentKeys.has(key) ? [] : [key]);
|
|
172
158
|
}
|
|
173
159
|
|
|
@@ -1,2 +1,10 @@
|
|
|
1
|
-
export {
|
|
2
|
-
|
|
1
|
+
export {
|
|
2
|
+
createDisclosureState,
|
|
3
|
+
createDisclosureGroupState,
|
|
4
|
+
type DisclosureStateProps,
|
|
5
|
+
type DisclosureState,
|
|
6
|
+
type DisclosureGroupStateProps,
|
|
7
|
+
type DisclosureGroupState,
|
|
8
|
+
type Key,
|
|
9
|
+
} from "./createDisclosureState";
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
package/src/disclosure/index.ts
CHANGED
|
@@ -3,51 +3,60 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Provides reactive state for drag operations.
|
|
5
5
|
*/
|
|
6
|
-
import { type Accessor } from
|
|
7
|
-
import type {
|
|
6
|
+
import { type Accessor } from "solid-js";
|
|
7
|
+
import type {
|
|
8
|
+
DragItem,
|
|
9
|
+
DragStartEvent,
|
|
10
|
+
DragMoveEvent,
|
|
11
|
+
DragEndEvent,
|
|
12
|
+
DropOperation,
|
|
13
|
+
DragPreviewRenderer,
|
|
14
|
+
} from "./types";
|
|
8
15
|
export interface DragStateOptions {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
16
|
+
/** A function that returns the items being dragged. */
|
|
17
|
+
getItems: () => DragItem[];
|
|
18
|
+
/** Function that returns the allowed drop operations. */
|
|
19
|
+
getAllowedDropOperations?: () => DropOperation[];
|
|
20
|
+
/** Handler that is called when a drag operation is started. */
|
|
21
|
+
onDragStart?: (e: DragStartEvent) => void;
|
|
22
|
+
/** Handler that is called when the drag is moved. */
|
|
23
|
+
onDragMove?: (e: DragMoveEvent) => void;
|
|
24
|
+
/** Handler that is called when the drag operation ends. */
|
|
25
|
+
onDragEnd?: (e: DragEndEvent) => void;
|
|
26
|
+
/** Whether the drag operation is disabled. */
|
|
27
|
+
isDisabled?: boolean;
|
|
28
|
+
/** Whether there is a separate drag button affordance. */
|
|
29
|
+
hasDragButton?: boolean;
|
|
30
|
+
/** Preview renderer function ref. */
|
|
31
|
+
preview?: {
|
|
32
|
+
current: DragPreviewRenderer | null;
|
|
33
|
+
};
|
|
27
34
|
}
|
|
28
35
|
export interface DragState {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
36
|
+
/** Whether an element is currently being dragged. */
|
|
37
|
+
readonly isDragging: boolean;
|
|
38
|
+
/** Whether drag is disabled. */
|
|
39
|
+
readonly isDisabled: boolean;
|
|
40
|
+
/** Start a drag operation. */
|
|
41
|
+
startDrag(x: number, y: number): void;
|
|
42
|
+
/** Update drag position. */
|
|
43
|
+
moveDrag(x: number, y: number): void;
|
|
44
|
+
/** End a drag operation. */
|
|
45
|
+
endDrag(x: number, y: number, dropOperation: DropOperation): void;
|
|
46
|
+
/** Cancel a drag operation. */
|
|
47
|
+
cancelDrag(): void;
|
|
48
|
+
/** Get the items being dragged. */
|
|
49
|
+
getItems(): DragItem[];
|
|
50
|
+
/** Get allowed drop operations. */
|
|
51
|
+
getAllowedDropOperations(): DropOperation[];
|
|
52
|
+
/** Whether there is a drag button. */
|
|
53
|
+
readonly hasDragButton: boolean;
|
|
54
|
+
/** Preview renderer. */
|
|
55
|
+
readonly preview:
|
|
56
|
+
| {
|
|
49
57
|
current: DragPreviewRenderer | null;
|
|
50
|
-
|
|
58
|
+
}
|
|
59
|
+
| undefined;
|
|
51
60
|
}
|
|
52
61
|
/**
|
|
53
62
|
* Creates drag state for managing drag operations.
|
|
@@ -56,4 +65,4 @@ export interface DragState {
|
|
|
56
65
|
* @returns Drag state object
|
|
57
66
|
*/
|
|
58
67
|
export declare function createDragState(props: Accessor<DragStateOptions>): DragState;
|
|
59
|
-
//# sourceMappingURL=createDragState.d.ts.map
|
|
68
|
+
//# sourceMappingURL=createDragState.d.ts.map
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Provides reactive state for drag operations.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import { createSignal, createMemo, type Accessor } from
|
|
7
|
+
import { createSignal, createMemo, type Accessor } from "solid-js";
|
|
8
8
|
import type {
|
|
9
9
|
DragItem,
|
|
10
10
|
DragStartEvent,
|
|
@@ -12,7 +12,7 @@ import type {
|
|
|
12
12
|
DragEndEvent,
|
|
13
13
|
DropOperation,
|
|
14
14
|
DragPreviewRenderer,
|
|
15
|
-
} from
|
|
15
|
+
} from "./types";
|
|
16
16
|
|
|
17
17
|
export interface DragStateOptions {
|
|
18
18
|
/** A function that returns the items being dragged. */
|
|
@@ -62,9 +62,7 @@ export interface DragState {
|
|
|
62
62
|
* @param props - Accessor returning drag state options
|
|
63
63
|
* @returns Drag state object
|
|
64
64
|
*/
|
|
65
|
-
export function createDragState(
|
|
66
|
-
props: Accessor<DragStateOptions>
|
|
67
|
-
): DragState {
|
|
65
|
+
export function createDragState(props: Accessor<DragStateOptions>): DragState {
|
|
68
66
|
const getProps = createMemo(() => props());
|
|
69
67
|
|
|
70
68
|
const [isDragging, setIsDragging] = createSignal(false);
|
|
@@ -75,9 +73,9 @@ export function createDragState(
|
|
|
75
73
|
|
|
76
74
|
setIsDragging(true);
|
|
77
75
|
|
|
78
|
-
if (typeof p.onDragStart ===
|
|
76
|
+
if (typeof p.onDragStart === "function") {
|
|
79
77
|
p.onDragStart({
|
|
80
|
-
type:
|
|
78
|
+
type: "dragstart",
|
|
81
79
|
x,
|
|
82
80
|
y,
|
|
83
81
|
});
|
|
@@ -88,9 +86,9 @@ export function createDragState(
|
|
|
88
86
|
const p = getProps();
|
|
89
87
|
if (!isDragging() || p.isDisabled) return;
|
|
90
88
|
|
|
91
|
-
if (typeof p.onDragMove ===
|
|
89
|
+
if (typeof p.onDragMove === "function") {
|
|
92
90
|
p.onDragMove({
|
|
93
|
-
type:
|
|
91
|
+
type: "dragmove",
|
|
94
92
|
x,
|
|
95
93
|
y,
|
|
96
94
|
});
|
|
@@ -103,9 +101,9 @@ export function createDragState(
|
|
|
103
101
|
|
|
104
102
|
setIsDragging(false);
|
|
105
103
|
|
|
106
|
-
if (typeof p.onDragEnd ===
|
|
104
|
+
if (typeof p.onDragEnd === "function") {
|
|
107
105
|
p.onDragEnd({
|
|
108
|
-
type:
|
|
106
|
+
type: "dragend",
|
|
109
107
|
x,
|
|
110
108
|
y,
|
|
111
109
|
dropOperation,
|
|
@@ -114,7 +112,7 @@ export function createDragState(
|
|
|
114
112
|
};
|
|
115
113
|
|
|
116
114
|
const cancelDrag = () => {
|
|
117
|
-
endDrag(0, 0,
|
|
115
|
+
endDrag(0, 0, "cancel");
|
|
118
116
|
};
|
|
119
117
|
|
|
120
118
|
const getItems = () => {
|
|
@@ -124,10 +122,10 @@ export function createDragState(
|
|
|
124
122
|
|
|
125
123
|
const getAllowedDropOperations = (): DropOperation[] => {
|
|
126
124
|
const p = getProps();
|
|
127
|
-
if (typeof p.getAllowedDropOperations ===
|
|
125
|
+
if (typeof p.getAllowedDropOperations === "function") {
|
|
128
126
|
return p.getAllowedDropOperations();
|
|
129
127
|
}
|
|
130
|
-
return [
|
|
128
|
+
return ["move", "copy", "link"];
|
|
131
129
|
};
|
|
132
130
|
|
|
133
131
|
return {
|
|
@@ -3,49 +3,58 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Provides reactive state for dragging items from a collection.
|
|
5
5
|
*/
|
|
6
|
-
import { type Accessor } from
|
|
7
|
-
import type {
|
|
6
|
+
import { type Accessor } from "solid-js";
|
|
7
|
+
import type {
|
|
8
|
+
DragItem,
|
|
9
|
+
DraggableCollectionStartEvent,
|
|
10
|
+
DraggableCollectionMoveEvent,
|
|
11
|
+
DraggableCollectionEndEvent,
|
|
12
|
+
DropOperation,
|
|
13
|
+
DragPreviewRenderer,
|
|
14
|
+
} from "./types";
|
|
8
15
|
export interface DraggableCollectionStateOptions<T = object> {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
16
|
+
/** A function that returns the items being dragged. */
|
|
17
|
+
getItems: (keys: Set<string | number>) => DragItem[];
|
|
18
|
+
/** Function that returns the allowed drop operations. */
|
|
19
|
+
getAllowedDropOperations?: () => DropOperation[];
|
|
20
|
+
/** Handler that is called when a drag operation is started. */
|
|
21
|
+
onDragStart?: (e: DraggableCollectionStartEvent) => void;
|
|
22
|
+
/** Handler that is called when the drag is moved. */
|
|
23
|
+
onDragMove?: (e: DraggableCollectionMoveEvent) => void;
|
|
24
|
+
/** Handler that is called when the drag operation ends. */
|
|
25
|
+
onDragEnd?: (e: DraggableCollectionEndEvent) => void;
|
|
26
|
+
/** Whether the drag operation is disabled. */
|
|
27
|
+
isDisabled?: boolean;
|
|
28
|
+
/** Preview renderer function ref. */
|
|
29
|
+
preview?: {
|
|
30
|
+
current: DragPreviewRenderer | null;
|
|
31
|
+
};
|
|
25
32
|
}
|
|
26
33
|
export interface DraggableCollectionState {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
34
|
+
/** Whether items are currently being dragged. */
|
|
35
|
+
readonly isDragging: boolean;
|
|
36
|
+
/** The keys of the items being dragged. */
|
|
37
|
+
readonly draggingKeys: Set<string | number>;
|
|
38
|
+
/** Whether dragging is disabled. */
|
|
39
|
+
readonly isDisabled: boolean;
|
|
40
|
+
/** Start a drag operation with the given keys. */
|
|
41
|
+
startDrag(keys: Set<string | number>, x: number, y: number): void;
|
|
42
|
+
/** Update drag position. */
|
|
43
|
+
moveDrag(x: number, y: number): void;
|
|
44
|
+
/** End a drag operation. */
|
|
45
|
+
endDrag(x: number, y: number, dropOperation: DropOperation, isInternal: boolean): void;
|
|
46
|
+
/** Cancel a drag operation. */
|
|
47
|
+
cancelDrag(): void;
|
|
48
|
+
/** Get the items being dragged for the given keys. */
|
|
49
|
+
getItems(keys: Set<string | number>): DragItem[];
|
|
50
|
+
/** Get allowed drop operations. */
|
|
51
|
+
getAllowedDropOperations(): DropOperation[];
|
|
52
|
+
/** Preview renderer. */
|
|
53
|
+
readonly preview:
|
|
54
|
+
| {
|
|
47
55
|
current: DragPreviewRenderer | null;
|
|
48
|
-
|
|
56
|
+
}
|
|
57
|
+
| undefined;
|
|
49
58
|
}
|
|
50
59
|
/**
|
|
51
60
|
* Creates state for dragging items from a collection.
|
|
@@ -53,5 +62,7 @@ export interface DraggableCollectionState {
|
|
|
53
62
|
* @param props - Accessor returning draggable collection options
|
|
54
63
|
* @returns Draggable collection state object
|
|
55
64
|
*/
|
|
56
|
-
export declare function createDraggableCollectionState<T = object>(
|
|
57
|
-
|
|
65
|
+
export declare function createDraggableCollectionState<T = object>(
|
|
66
|
+
props: Accessor<DraggableCollectionStateOptions<T>>,
|
|
67
|
+
): DraggableCollectionState;
|
|
68
|
+
//# sourceMappingURL=createDraggableCollectionState.d.ts.map
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Provides reactive state for dragging items from a collection.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import { createSignal, createMemo, type Accessor } from
|
|
7
|
+
import { createSignal, createMemo, type Accessor } from "solid-js";
|
|
8
8
|
import type {
|
|
9
9
|
DragItem,
|
|
10
10
|
DraggableCollectionStartEvent,
|
|
@@ -12,7 +12,7 @@ import type {
|
|
|
12
12
|
DraggableCollectionEndEvent,
|
|
13
13
|
DropOperation,
|
|
14
14
|
DragPreviewRenderer,
|
|
15
|
-
} from
|
|
15
|
+
} from "./types";
|
|
16
16
|
|
|
17
17
|
export interface DraggableCollectionStateOptions<T = object> {
|
|
18
18
|
/** A function that returns the items being dragged. */
|
|
@@ -61,14 +61,12 @@ export interface DraggableCollectionState {
|
|
|
61
61
|
* @returns Draggable collection state object
|
|
62
62
|
*/
|
|
63
63
|
export function createDraggableCollectionState<T = object>(
|
|
64
|
-
props: Accessor<DraggableCollectionStateOptions<T
|
|
64
|
+
props: Accessor<DraggableCollectionStateOptions<T>>,
|
|
65
65
|
): DraggableCollectionState {
|
|
66
66
|
const getProps = createMemo(() => props());
|
|
67
67
|
|
|
68
68
|
const [isDragging, setIsDragging] = createSignal(false);
|
|
69
|
-
const [draggingKeys, setDraggingKeys] = createSignal<Set<string | number>>(
|
|
70
|
-
new Set()
|
|
71
|
-
);
|
|
69
|
+
const [draggingKeys, setDraggingKeys] = createSignal<Set<string | number>>(new Set());
|
|
72
70
|
|
|
73
71
|
const startDrag = (keys: Set<string | number>, x: number, y: number) => {
|
|
74
72
|
const p = getProps();
|
|
@@ -77,9 +75,9 @@ export function createDraggableCollectionState<T = object>(
|
|
|
77
75
|
setIsDragging(true);
|
|
78
76
|
setDraggingKeys(keys);
|
|
79
77
|
|
|
80
|
-
if (typeof p.onDragStart ===
|
|
78
|
+
if (typeof p.onDragStart === "function") {
|
|
81
79
|
p.onDragStart({
|
|
82
|
-
type:
|
|
80
|
+
type: "dragstart",
|
|
83
81
|
x,
|
|
84
82
|
y,
|
|
85
83
|
keys,
|
|
@@ -91,9 +89,9 @@ export function createDraggableCollectionState<T = object>(
|
|
|
91
89
|
const p = getProps();
|
|
92
90
|
if (!isDragging() || p.isDisabled) return;
|
|
93
91
|
|
|
94
|
-
if (typeof p.onDragMove ===
|
|
92
|
+
if (typeof p.onDragMove === "function") {
|
|
95
93
|
p.onDragMove({
|
|
96
|
-
type:
|
|
94
|
+
type: "dragmove",
|
|
97
95
|
x,
|
|
98
96
|
y,
|
|
99
97
|
keys: draggingKeys(),
|
|
@@ -101,21 +99,16 @@ export function createDraggableCollectionState<T = object>(
|
|
|
101
99
|
}
|
|
102
100
|
};
|
|
103
101
|
|
|
104
|
-
const endDrag = (
|
|
105
|
-
x: number,
|
|
106
|
-
y: number,
|
|
107
|
-
dropOperation: DropOperation,
|
|
108
|
-
isInternal: boolean
|
|
109
|
-
) => {
|
|
102
|
+
const endDrag = (x: number, y: number, dropOperation: DropOperation, isInternal: boolean) => {
|
|
110
103
|
const p = getProps();
|
|
111
104
|
const keys = draggingKeys();
|
|
112
105
|
|
|
113
106
|
setIsDragging(false);
|
|
114
107
|
setDraggingKeys(new Set<string | number>());
|
|
115
108
|
|
|
116
|
-
if (typeof p.onDragEnd ===
|
|
109
|
+
if (typeof p.onDragEnd === "function") {
|
|
117
110
|
p.onDragEnd({
|
|
118
|
-
type:
|
|
111
|
+
type: "dragend",
|
|
119
112
|
x,
|
|
120
113
|
y,
|
|
121
114
|
dropOperation,
|
|
@@ -126,7 +119,7 @@ export function createDraggableCollectionState<T = object>(
|
|
|
126
119
|
};
|
|
127
120
|
|
|
128
121
|
const cancelDrag = () => {
|
|
129
|
-
endDrag(0, 0,
|
|
122
|
+
endDrag(0, 0, "cancel", false);
|
|
130
123
|
};
|
|
131
124
|
|
|
132
125
|
const getItems = (keys: Set<string | number>) => {
|
|
@@ -136,10 +129,10 @@ export function createDraggableCollectionState<T = object>(
|
|
|
136
129
|
|
|
137
130
|
const getAllowedDropOperations = (): DropOperation[] => {
|
|
138
131
|
const p = getProps();
|
|
139
|
-
if (typeof p.getAllowedDropOperations ===
|
|
132
|
+
if (typeof p.getAllowedDropOperations === "function") {
|
|
140
133
|
return p.getAllowedDropOperations();
|
|
141
134
|
}
|
|
142
|
-
return [
|
|
135
|
+
return ["move", "copy", "link"];
|
|
143
136
|
};
|
|
144
137
|
|
|
145
138
|
return {
|