@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
|
@@ -5,30 +5,30 @@
|
|
|
5
5
|
*
|
|
6
6
|
* This is a 1:1 port of @react-stately/toggle's useToggleState.
|
|
7
7
|
*/
|
|
8
|
-
import { Accessor } from
|
|
9
|
-
import { type MaybeAccessor } from
|
|
8
|
+
import { Accessor } from "solid-js";
|
|
9
|
+
import { type MaybeAccessor } from "../utils";
|
|
10
10
|
export interface ToggleStateOptions {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
11
|
+
/** Whether the element should be selected (controlled). */
|
|
12
|
+
isSelected?: boolean;
|
|
13
|
+
/** Whether the element should be selected by default (uncontrolled). */
|
|
14
|
+
defaultSelected?: boolean;
|
|
15
|
+
/** Handler that is called when the element's selection state changes. */
|
|
16
|
+
onChange?: (isSelected: boolean) => void;
|
|
17
|
+
/** Whether the element is read only. */
|
|
18
|
+
isReadOnly?: boolean;
|
|
19
19
|
}
|
|
20
20
|
export interface ToggleState {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
21
|
+
/** Whether the toggle is selected. */
|
|
22
|
+
readonly isSelected: Accessor<boolean>;
|
|
23
|
+
/** Whether the toggle is selected by default. */
|
|
24
|
+
readonly defaultSelected: boolean;
|
|
25
|
+
/** Updates selection state. */
|
|
26
|
+
setSelected(isSelected: boolean): void;
|
|
27
|
+
/** Toggle the selection state. */
|
|
28
|
+
toggle(): void;
|
|
29
29
|
}
|
|
30
30
|
/**
|
|
31
31
|
* Provides state management for toggle components like checkboxes and switches.
|
|
32
32
|
*/
|
|
33
33
|
export declare function createToggleState(props?: MaybeAccessor<ToggleStateOptions>): ToggleState;
|
|
34
|
-
//# sourceMappingURL=createToggleState.d.ts.map
|
|
34
|
+
//# sourceMappingURL=createToggleState.d.ts.map
|
|
@@ -6,12 +6,8 @@
|
|
|
6
6
|
* This is a 1:1 port of @react-stately/toggle's useToggleState.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import { createSignal, Accessor } from
|
|
10
|
-
import { type MaybeAccessor, access } from
|
|
11
|
-
|
|
12
|
-
// ============================================
|
|
13
|
-
// TYPES
|
|
14
|
-
// ============================================
|
|
9
|
+
import { createSignal, Accessor } from "solid-js";
|
|
10
|
+
import { type MaybeAccessor, access } from "../utils";
|
|
15
11
|
|
|
16
12
|
export interface ToggleStateOptions {
|
|
17
13
|
/** Whether the element should be selected (controlled). */
|
|
@@ -35,33 +31,24 @@ export interface ToggleState {
|
|
|
35
31
|
toggle(): void;
|
|
36
32
|
}
|
|
37
33
|
|
|
38
|
-
// ============================================
|
|
39
|
-
// IMPLEMENTATION
|
|
40
|
-
// ============================================
|
|
41
|
-
|
|
42
34
|
/**
|
|
43
35
|
* Provides state management for toggle components like checkboxes and switches.
|
|
44
36
|
*/
|
|
45
37
|
export function createToggleState(props: MaybeAccessor<ToggleStateOptions> = {}): ToggleState {
|
|
46
38
|
const getProps = () => access(props);
|
|
47
39
|
|
|
48
|
-
// Get initial values
|
|
49
40
|
const initialProps = getProps();
|
|
50
41
|
const initialSelected = initialProps.isSelected ?? initialProps.defaultSelected ?? false;
|
|
51
42
|
|
|
52
|
-
// Create internal signal for uncontrolled mode
|
|
53
43
|
const [internalSelected, setInternalSelected] = createSignal(initialSelected);
|
|
54
44
|
|
|
55
|
-
// Determine if controlled
|
|
56
45
|
const isControlled = () => getProps().isSelected !== undefined;
|
|
57
46
|
|
|
58
|
-
// Get current selection state
|
|
59
47
|
const isSelected: Accessor<boolean> = () => {
|
|
60
48
|
const p = getProps();
|
|
61
49
|
return isControlled() ? (p.isSelected ?? false) : internalSelected();
|
|
62
50
|
};
|
|
63
51
|
|
|
64
|
-
// Update selection state
|
|
65
52
|
function setSelected(value: boolean): void {
|
|
66
53
|
const p = getProps();
|
|
67
54
|
if (p.isReadOnly) {
|
|
@@ -75,7 +62,6 @@ export function createToggleState(props: MaybeAccessor<ToggleStateOptions> = {})
|
|
|
75
62
|
p.onChange?.(value);
|
|
76
63
|
}
|
|
77
64
|
|
|
78
|
-
// Toggle selection state
|
|
79
65
|
function toggle(): void {
|
|
80
66
|
const p = getProps();
|
|
81
67
|
if (p.isReadOnly) {
|
package/src/toggle/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { createToggleState, type ToggleStateOptions, type ToggleState
|
|
2
|
-
//# sourceMappingURL=index.d.ts.map
|
|
1
|
+
export { createToggleState, type ToggleStateOptions, type ToggleState } from "./createToggleState";
|
|
2
|
+
//# sourceMappingURL=index.d.ts.map
|
package/src/toggle/index.ts
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
export {
|
|
2
|
-
createToggleState,
|
|
3
|
-
type ToggleStateOptions,
|
|
4
|
-
type ToggleState,
|
|
5
|
-
} from './createToggleState';
|
|
1
|
+
export { createToggleState, type ToggleStateOptions, type ToggleState } from "./createToggleState";
|
|
6
2
|
|
|
7
3
|
export {
|
|
8
4
|
createToggleGroupState,
|
|
9
5
|
type ToggleGroupProps,
|
|
10
6
|
type ToggleGroupState,
|
|
11
|
-
} from
|
|
7
|
+
} from "./createToggleGroupState";
|
|
@@ -5,25 +5,25 @@
|
|
|
5
5
|
* Tracks whether the tooltip is open, and provides methods to toggle this state.
|
|
6
6
|
* Ensures only one tooltip is open at a time and controls the delay for showing a tooltip.
|
|
7
7
|
*/
|
|
8
|
-
import { type Accessor } from
|
|
9
|
-
import { type OverlayTriggerProps } from
|
|
8
|
+
import { type Accessor } from "solid-js";
|
|
9
|
+
import { type OverlayTriggerProps } from "../overlays";
|
|
10
10
|
export interface TooltipTriggerProps extends OverlayTriggerProps {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
/** The delay time in milliseconds for the tooltip to show up. */
|
|
12
|
+
delay?: number;
|
|
13
|
+
/** The delay time in milliseconds for the tooltip to close. */
|
|
14
|
+
closeDelay?: number;
|
|
15
15
|
}
|
|
16
16
|
export interface TooltipTriggerState {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
17
|
+
/** Whether the tooltip is currently showing. */
|
|
18
|
+
readonly isOpen: Accessor<boolean>;
|
|
19
|
+
/**
|
|
20
|
+
* Shows the tooltip. By default, the tooltip becomes visible after a delay
|
|
21
|
+
* depending on a global warmup timer. The `immediate` option shows the
|
|
22
|
+
* tooltip immediately instead.
|
|
23
|
+
*/
|
|
24
|
+
open(immediate?: boolean): void;
|
|
25
|
+
/** Hides the tooltip. */
|
|
26
|
+
close(immediate?: boolean): void;
|
|
27
27
|
}
|
|
28
28
|
/**
|
|
29
29
|
* Resets the global tooltip state. Useful for testing.
|
|
@@ -36,4 +36,4 @@ export declare function resetTooltipState(): void;
|
|
|
36
36
|
* the delay for showing a tooltip.
|
|
37
37
|
*/
|
|
38
38
|
export declare function createTooltipTriggerState(props?: TooltipTriggerProps): TooltipTriggerState;
|
|
39
|
-
//# sourceMappingURL=createTooltipTriggerState.d.ts.map
|
|
39
|
+
//# sourceMappingURL=createTooltipTriggerState.d.ts.map
|
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
* Ensures only one tooltip is open at a time and controls the delay for showing a tooltip.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import { createSignal, onCleanup, type Accessor } from
|
|
10
|
-
import { createOverlayTriggerState, type OverlayTriggerProps } from
|
|
11
|
-
import { isServer } from
|
|
9
|
+
import { createSignal, onCleanup, type Accessor } from "solid-js";
|
|
10
|
+
import { createOverlayTriggerState, type OverlayTriggerProps } from "../overlays";
|
|
11
|
+
import { isServer } from "../ssr";
|
|
12
12
|
|
|
13
13
|
// Default delays (in ms)
|
|
14
14
|
const TOOLTIP_DELAY = 1500;
|
|
@@ -64,9 +64,7 @@ export function resetTooltipState(): void {
|
|
|
64
64
|
* methods to toggle this state. Ensures only one tooltip is open at a time and controls
|
|
65
65
|
* the delay for showing a tooltip.
|
|
66
66
|
*/
|
|
67
|
-
export function createTooltipTriggerState(
|
|
68
|
-
props: TooltipTriggerProps = {}
|
|
69
|
-
): TooltipTriggerState {
|
|
67
|
+
export function createTooltipTriggerState(props: TooltipTriggerProps = {}): TooltipTriggerState {
|
|
70
68
|
const delay = () => props.delay ?? TOOLTIP_DELAY;
|
|
71
69
|
const closeDelay = () => props.closeDelay ?? TOOLTIP_COOLDOWN;
|
|
72
70
|
|
|
@@ -132,11 +130,14 @@ export function createTooltipTriggerState(
|
|
|
132
130
|
if (globalCooldownTimeout) {
|
|
133
131
|
clearTimeout(globalCooldownTimeout);
|
|
134
132
|
}
|
|
135
|
-
globalCooldownTimeout = setTimeout(
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
133
|
+
globalCooldownTimeout = setTimeout(
|
|
134
|
+
() => {
|
|
135
|
+
delete tooltips[id];
|
|
136
|
+
globalCooldownTimeout = null;
|
|
137
|
+
globalWarmedUp = false;
|
|
138
|
+
},
|
|
139
|
+
Math.max(TOOLTIP_COOLDOWN, closeDelay()),
|
|
140
|
+
);
|
|
140
141
|
}
|
|
141
142
|
};
|
|
142
143
|
|
package/src/tooltip/index.d.ts
CHANGED
|
@@ -1,2 +1,7 @@
|
|
|
1
|
-
export {
|
|
2
|
-
|
|
1
|
+
export {
|
|
2
|
+
createTooltipTriggerState,
|
|
3
|
+
resetTooltipState,
|
|
4
|
+
type TooltipTriggerProps,
|
|
5
|
+
type TooltipTriggerState,
|
|
6
|
+
} from "./createTooltipTriggerState";
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
package/src/tooltip/index.ts
CHANGED
|
@@ -5,36 +5,39 @@
|
|
|
5
5
|
* A flattened view of tree nodes that respects expanded state.
|
|
6
6
|
* Only visible nodes (root + expanded children) are included in iteration.
|
|
7
7
|
*/
|
|
8
|
-
import type { Key } from
|
|
9
|
-
import type { TreeCollection as ITreeCollection, TreeNode, TreeItemData } from
|
|
8
|
+
import type { Key } from "../collections/types";
|
|
9
|
+
import type { TreeCollection as ITreeCollection, TreeNode, TreeItemData } from "./types";
|
|
10
10
|
/**
|
|
11
11
|
* Creates a TreeCollection from hierarchical data.
|
|
12
12
|
* The collection is flattened based on expanded keys.
|
|
13
13
|
*/
|
|
14
14
|
export declare class TreeCollection<T> implements ITreeCollection<T> {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
15
|
+
private keyMap;
|
|
16
|
+
private visibleKeys;
|
|
17
|
+
private _rows;
|
|
18
|
+
constructor(items: TreeItemData<T>[], expandedKeys: Set<Key>);
|
|
19
|
+
private buildCollection;
|
|
20
|
+
get size(): number;
|
|
21
|
+
get rows(): TreeNode<T>[];
|
|
22
|
+
get rowCount(): number;
|
|
23
|
+
getKeys(): Iterable<Key>;
|
|
24
|
+
getItem(key: Key): TreeNode<T> | null;
|
|
25
|
+
at(index: number): TreeNode<T> | null;
|
|
26
|
+
getKeyBefore(key: Key): Key | null;
|
|
27
|
+
getKeyAfter(key: Key): Key | null;
|
|
28
|
+
getFirstKey(): Key | null;
|
|
29
|
+
getLastKey(): Key | null;
|
|
30
|
+
getChildren(key: Key): Iterable<TreeNode<T>>;
|
|
31
|
+
getTextValue(key: Key): string;
|
|
32
|
+
getParentKey(key: Key): Key | null;
|
|
33
|
+
[Symbol.iterator](): Iterator<TreeNode<T>>;
|
|
34
34
|
}
|
|
35
35
|
/**
|
|
36
36
|
* Factory function to create a TreeCollection.
|
|
37
37
|
* Useful for the collectionFactory pattern in TreeStateOptions.
|
|
38
38
|
*/
|
|
39
|
-
export declare function createTreeCollection<T>(
|
|
40
|
-
|
|
39
|
+
export declare function createTreeCollection<T>(
|
|
40
|
+
items: TreeItemData<T>[],
|
|
41
|
+
expandedKeys: Set<Key>,
|
|
42
|
+
): TreeCollection<T>;
|
|
43
|
+
//# sourceMappingURL=TreeCollection.d.ts.map
|
|
@@ -6,8 +6,16 @@
|
|
|
6
6
|
* Only visible nodes (root + expanded children) are included in iteration.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import type { Key } from
|
|
10
|
-
import type { TreeCollection as ITreeCollection, TreeNode, TreeItemData } from
|
|
9
|
+
import type { Key } from "../collections/types";
|
|
10
|
+
import type { TreeCollection as ITreeCollection, TreeNode, TreeItemData } from "./types";
|
|
11
|
+
|
|
12
|
+
function getItemKey<T>(item: TreeItemData<T>): Key {
|
|
13
|
+
const key = item.key ?? item.id;
|
|
14
|
+
if (key == null) {
|
|
15
|
+
throw new Error("Tree items must define either a key or id.");
|
|
16
|
+
}
|
|
17
|
+
return key;
|
|
18
|
+
}
|
|
11
19
|
|
|
12
20
|
/**
|
|
13
21
|
* Creates a TreeCollection from hierarchical data.
|
|
@@ -19,10 +27,7 @@ export class TreeCollection<T> implements ITreeCollection<T> {
|
|
|
19
27
|
private firstKey: Key | null = null;
|
|
20
28
|
private lastKey: Key | null = null;
|
|
21
29
|
|
|
22
|
-
constructor(
|
|
23
|
-
items: TreeItemData<T>[],
|
|
24
|
-
expandedKeys: Set<Key>
|
|
25
|
-
) {
|
|
30
|
+
constructor(items: TreeItemData<T>[], expandedKeys: Set<Key>) {
|
|
26
31
|
this.buildCollection(items, expandedKeys);
|
|
27
32
|
}
|
|
28
33
|
|
|
@@ -34,25 +39,27 @@ export class TreeCollection<T> implements ITreeCollection<T> {
|
|
|
34
39
|
item: TreeItemData<T>,
|
|
35
40
|
level: number,
|
|
36
41
|
parentKey: Key | null,
|
|
37
|
-
indexInParent: number
|
|
42
|
+
indexInParent: number,
|
|
38
43
|
): TreeNode<T> => {
|
|
39
|
-
const
|
|
40
|
-
const
|
|
44
|
+
const key = getItemKey(item);
|
|
45
|
+
const hasLoadedChildren = Boolean(item.children && item.children.length > 0);
|
|
46
|
+
const hasChildren = hasLoadedChildren || !!item.hasChildItems;
|
|
47
|
+
const isExpanded = hasChildren && expandedKeys.has(key);
|
|
41
48
|
|
|
42
49
|
// Build child nodes first (even if not visible, for the map)
|
|
43
50
|
const childNodes: TreeNode<T>[] = [];
|
|
44
|
-
if (
|
|
51
|
+
if (hasLoadedChildren && item.children) {
|
|
45
52
|
for (let i = 0; i < item.children.length; i++) {
|
|
46
|
-
const childNode = visit(item.children[i], level + 1,
|
|
53
|
+
const childNode = visit(item.children[i], level + 1, key, i);
|
|
47
54
|
childNodes.push(childNode);
|
|
48
55
|
}
|
|
49
56
|
}
|
|
50
57
|
|
|
51
58
|
const node: TreeNode<T> = {
|
|
52
|
-
type:
|
|
53
|
-
key
|
|
54
|
-
value: item.value,
|
|
55
|
-
textValue: item.textValue || String(
|
|
59
|
+
type: "item",
|
|
60
|
+
key,
|
|
61
|
+
value: (item.value ?? item) as T,
|
|
62
|
+
textValue: item.textValue || String(key),
|
|
56
63
|
level,
|
|
57
64
|
index: indexInParent,
|
|
58
65
|
parentKey,
|
|
@@ -64,7 +71,7 @@ export class TreeCollection<T> implements ITreeCollection<T> {
|
|
|
64
71
|
};
|
|
65
72
|
|
|
66
73
|
// Always add to keyMap (for getItem lookups)
|
|
67
|
-
this.keyMap.set(
|
|
74
|
+
this.keyMap.set(key, node);
|
|
68
75
|
|
|
69
76
|
return node;
|
|
70
77
|
};
|
|
@@ -136,7 +143,7 @@ export class TreeCollection<T> implements ITreeCollection<T> {
|
|
|
136
143
|
while (previousKey != null) {
|
|
137
144
|
const candidate = this.keyMap.get(previousKey);
|
|
138
145
|
if (!candidate) break;
|
|
139
|
-
if (candidate.type !==
|
|
146
|
+
if (candidate.type !== "content") {
|
|
140
147
|
return candidate.key;
|
|
141
148
|
}
|
|
142
149
|
previousKey = candidate.prevKey ?? null;
|
|
@@ -150,7 +157,7 @@ export class TreeCollection<T> implements ITreeCollection<T> {
|
|
|
150
157
|
while (nextKey != null) {
|
|
151
158
|
const candidate = this.keyMap.get(nextKey);
|
|
152
159
|
if (!candidate) break;
|
|
153
|
-
if (candidate.type !==
|
|
160
|
+
if (candidate.type !== "content") {
|
|
154
161
|
return candidate.key;
|
|
155
162
|
}
|
|
156
163
|
nextKey = candidate.nextKey ?? null;
|
|
@@ -161,7 +168,7 @@ export class TreeCollection<T> implements ITreeCollection<T> {
|
|
|
161
168
|
getFirstKey(): Key | null {
|
|
162
169
|
if (this.firstKey == null) return null;
|
|
163
170
|
const candidate = this.keyMap.get(this.firstKey);
|
|
164
|
-
if (candidate?.type ===
|
|
171
|
+
if (candidate?.type === "content") {
|
|
165
172
|
return this.getKeyAfter(candidate.key);
|
|
166
173
|
}
|
|
167
174
|
return this.firstKey;
|
|
@@ -170,7 +177,7 @@ export class TreeCollection<T> implements ITreeCollection<T> {
|
|
|
170
177
|
getLastKey(): Key | null {
|
|
171
178
|
if (this.lastKey == null) return null;
|
|
172
179
|
const candidate = this.keyMap.get(this.lastKey);
|
|
173
|
-
if (candidate?.type ===
|
|
180
|
+
if (candidate?.type === "content") {
|
|
174
181
|
return this.getKeyBefore(candidate.key);
|
|
175
182
|
}
|
|
176
183
|
return this.lastKey;
|
|
@@ -183,7 +190,7 @@ export class TreeCollection<T> implements ITreeCollection<T> {
|
|
|
183
190
|
|
|
184
191
|
getTextValue(key: Key): string {
|
|
185
192
|
const node = this.keyMap.get(key);
|
|
186
|
-
return node?.textValue ??
|
|
193
|
+
return node?.textValue ?? "";
|
|
187
194
|
}
|
|
188
195
|
|
|
189
196
|
getParentKey(key: Key): Key | null {
|
|
@@ -202,7 +209,7 @@ export class TreeCollection<T> implements ITreeCollection<T> {
|
|
|
202
209
|
*/
|
|
203
210
|
export function createTreeCollection<T>(
|
|
204
211
|
items: TreeItemData<T>[],
|
|
205
|
-
expandedKeys: Set<Key
|
|
212
|
+
expandedKeys: Set<Key>,
|
|
206
213
|
): TreeCollection<T> {
|
|
207
214
|
return new TreeCollection(items, expandedKeys);
|
|
208
215
|
}
|
|
@@ -4,11 +4,14 @@
|
|
|
4
4
|
*
|
|
5
5
|
* Manages expansion state, selection, and focus for hierarchical tree data.
|
|
6
6
|
*/
|
|
7
|
-
import { type Accessor } from
|
|
8
|
-
import type { TreeState, TreeStateOptions, TreeCollection } from
|
|
7
|
+
import { type Accessor } from "solid-js";
|
|
8
|
+
import type { TreeState, TreeStateOptions, TreeCollection } from "./types";
|
|
9
9
|
/**
|
|
10
10
|
* Creates state management for a tree component.
|
|
11
11
|
* Handles expansion, selection, focus management, and keyboard navigation state.
|
|
12
12
|
*/
|
|
13
|
-
export declare function createTreeState<
|
|
14
|
-
|
|
13
|
+
export declare function createTreeState<
|
|
14
|
+
T extends object,
|
|
15
|
+
C extends TreeCollection<T> = TreeCollection<T>,
|
|
16
|
+
>(options: Accessor<TreeStateOptions<T, C>>): TreeState<T, C>;
|
|
17
|
+
//# sourceMappingURL=createTreeState.d.ts.map
|