@proyecto-viviana/solid-stately 0.1.1 → 0.1.2
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/autocomplete/createAutocompleteState.d.ts +45 -0
- package/dist/autocomplete/index.d.ts +1 -0
- package/dist/calendar/createCalendarState.d.ts +129 -0
- package/dist/calendar/createDateFieldState.d.ts +109 -0
- package/dist/calendar/createRangeCalendarState.d.ts +145 -0
- package/dist/calendar/createTimeFieldState.d.ts +94 -0
- package/dist/calendar/index.d.ts +6 -0
- package/dist/checkbox/createCheckboxGroupState.d.ts +70 -0
- package/dist/checkbox/index.d.ts +1 -0
- package/dist/collections/ListCollection.d.ts +36 -0
- package/dist/collections/createListState.d.ts +78 -0
- package/dist/collections/createMenuState.d.ts +49 -0
- package/dist/collections/createSelectionState.d.ts +75 -0
- package/dist/collections/index.d.ts +5 -0
- package/dist/collections/types.d.ts +146 -0
- package/dist/color/Color.d.ts +27 -0
- package/dist/color/createColorAreaState.d.ts +75 -0
- package/dist/color/createColorFieldState.d.ts +54 -0
- package/dist/color/createColorSliderState.d.ts +66 -0
- package/dist/color/createColorWheelState.d.ts +50 -0
- package/dist/color/index.d.ts +9 -0
- package/dist/color/types.d.ts +105 -0
- package/dist/combobox/createComboBoxState.d.ts +124 -0
- package/dist/combobox/index.d.ts +4 -0
- package/dist/disclosure/createDisclosureState.d.ts +63 -0
- package/dist/disclosure/index.d.ts +1 -0
- package/dist/dnd/createDragState.d.ts +58 -0
- package/dist/dnd/createDraggableCollectionState.d.ts +56 -0
- package/dist/dnd/createDropState.d.ts +60 -0
- package/dist/dnd/createDroppableCollectionState.d.ts +77 -0
- package/dist/dnd/index.d.ts +10 -0
- package/dist/dnd/types.d.ts +263 -0
- package/dist/form/createFormValidationState.d.ts +99 -0
- package/dist/form/index.d.ts +1 -0
- package/dist/grid/createGridState.d.ts +11 -0
- package/dist/grid/index.d.ts +6 -0
- package/dist/grid/types.d.ts +155 -0
- package/dist/index.d.ts +25 -3363
- package/dist/index.js +2 -2
- package/dist/index.js.map +7 -1
- package/dist/numberfield/createNumberFieldState.d.ts +64 -0
- package/dist/numberfield/index.d.ts +1 -0
- package/dist/overlays/createOverlayTriggerState.d.ts +31 -0
- package/dist/overlays/index.d.ts +1 -0
- package/dist/radio/createRadioGroupState.d.ts +76 -0
- package/dist/radio/index.d.ts +1 -0
- package/dist/searchfield/createSearchFieldState.d.ts +24 -0
- package/dist/searchfield/index.d.ts +2 -0
- package/dist/select/createSelectState.d.ts +72 -0
- package/dist/select/index.d.ts +1 -0
- package/dist/slider/createSliderState.d.ts +71 -0
- package/dist/slider/index.d.ts +2 -0
- package/dist/ssr/index.d.ts +27 -0
- package/dist/table/TableCollection.d.ts +51 -0
- package/dist/table/createTableState.d.ts +11 -0
- package/dist/table/index.d.ts +7 -0
- package/dist/table/types.d.ts +138 -0
- package/dist/tabs/createTabListState.d.ts +67 -0
- package/dist/tabs/index.d.ts +1 -0
- package/dist/textfield/createTextFieldState.d.ts +29 -0
- package/dist/textfield/index.d.ts +1 -0
- package/dist/toast/createToastState.d.ts +117 -0
- package/dist/toast/index.d.ts +1 -0
- package/dist/toggle/createToggleState.d.ts +33 -0
- package/dist/toggle/index.d.ts +1 -0
- package/dist/tooltip/createTooltipTriggerState.d.ts +38 -0
- package/dist/tooltip/index.d.ts +1 -0
- package/dist/tree/TreeCollection.d.ts +39 -0
- package/dist/tree/createTreeState.d.ts +13 -0
- package/dist/tree/index.d.ts +6 -0
- package/dist/tree/types.d.ts +156 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/reactivity.d.ts +27 -0
- package/package.json +3 -4
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TextField state for Solid Stately
|
|
3
|
+
*
|
|
4
|
+
* Provides state management for text input components.
|
|
5
|
+
*
|
|
6
|
+
* This is a port of @react-stately/utils's useControlledState pattern
|
|
7
|
+
* as used by @react-aria/textfield.
|
|
8
|
+
*/
|
|
9
|
+
import { Accessor } from 'solid-js';
|
|
10
|
+
import { type MaybeAccessor } from '../utils';
|
|
11
|
+
export interface TextFieldStateOptions {
|
|
12
|
+
/** The current value (controlled). */
|
|
13
|
+
value?: string;
|
|
14
|
+
/** The default value (uncontrolled). */
|
|
15
|
+
defaultValue?: string;
|
|
16
|
+
/** Handler that is called when the value changes. */
|
|
17
|
+
onChange?: (value: string) => void;
|
|
18
|
+
}
|
|
19
|
+
export interface TextFieldState {
|
|
20
|
+
/** The current value of the text field. */
|
|
21
|
+
readonly value: Accessor<string>;
|
|
22
|
+
/** Sets the value of the text field. */
|
|
23
|
+
setValue(value: string): void;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Provides state management for text input components.
|
|
27
|
+
* Supports both controlled and uncontrolled modes.
|
|
28
|
+
*/
|
|
29
|
+
export declare function createTextFieldState(props?: MaybeAccessor<TextFieldStateOptions>): TextFieldState;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createTextFieldState, type TextFieldStateOptions, type TextFieldState, } from './createTextFieldState';
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Toast state management for SolidJS
|
|
3
|
+
* Based on @react-stately/toast useToastState
|
|
4
|
+
*/
|
|
5
|
+
import { type Accessor } from 'solid-js';
|
|
6
|
+
export interface ToastOptions {
|
|
7
|
+
/** A timeout to automatically close the toast, in milliseconds. */
|
|
8
|
+
timeout?: number;
|
|
9
|
+
/** The priority of the toast relative to other toasts. */
|
|
10
|
+
priority?: number;
|
|
11
|
+
/** Handler called when the toast is closed. */
|
|
12
|
+
onClose?: () => void;
|
|
13
|
+
}
|
|
14
|
+
export interface QueuedToast<T> {
|
|
15
|
+
/** The content of the toast. */
|
|
16
|
+
content: T;
|
|
17
|
+
/** A unique key for the toast. */
|
|
18
|
+
key: string;
|
|
19
|
+
/** The timer for the toast. */
|
|
20
|
+
timer: Timer | null;
|
|
21
|
+
/** Whether the toast should be animated. */
|
|
22
|
+
animation?: 'entering' | 'exiting' | 'queued';
|
|
23
|
+
/** The priority of the toast. */
|
|
24
|
+
priority: number;
|
|
25
|
+
/** Handler called when the toast is closed. */
|
|
26
|
+
onClose?: () => void;
|
|
27
|
+
/** The timeout for the toast. */
|
|
28
|
+
timeout?: number;
|
|
29
|
+
}
|
|
30
|
+
export interface ToastQueueOptions {
|
|
31
|
+
/** The maximum number of toasts to display at once. */
|
|
32
|
+
maxVisibleToasts?: number;
|
|
33
|
+
/** Whether toasts should stack (true) or queue (false). */
|
|
34
|
+
hasExitAnimation?: boolean;
|
|
35
|
+
}
|
|
36
|
+
export interface ToastStateProps<T> {
|
|
37
|
+
/** The toast queue to use. */
|
|
38
|
+
queue: ToastQueue<T>;
|
|
39
|
+
}
|
|
40
|
+
export interface ToastState<T> {
|
|
41
|
+
/** The currently visible toasts. */
|
|
42
|
+
visibleToasts: Accessor<QueuedToast<T>[]>;
|
|
43
|
+
/** Adds a toast to the queue. */
|
|
44
|
+
add: (content: T, options?: ToastOptions) => string;
|
|
45
|
+
/** Closes a toast by key. */
|
|
46
|
+
close: (key: string) => void;
|
|
47
|
+
/** Pauses all toast timers. */
|
|
48
|
+
pauseAll: () => void;
|
|
49
|
+
/** Resumes all toast timers. */
|
|
50
|
+
resumeAll: () => void;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* A Timer that supports pause and resume.
|
|
54
|
+
*/
|
|
55
|
+
export declare class Timer {
|
|
56
|
+
private timerId;
|
|
57
|
+
private startTime;
|
|
58
|
+
private remaining;
|
|
59
|
+
private callback;
|
|
60
|
+
constructor(callback: () => void, delay: number);
|
|
61
|
+
pause(): void;
|
|
62
|
+
resume(): void;
|
|
63
|
+
reset(delay: number): void;
|
|
64
|
+
cancel(): void;
|
|
65
|
+
}
|
|
66
|
+
type SubscribeCallback<T> = (toasts: QueuedToast<T>[]) => void;
|
|
67
|
+
/**
|
|
68
|
+
* A queue that manages toast notifications.
|
|
69
|
+
* Can be created once and shared across the app (singleton pattern).
|
|
70
|
+
*/
|
|
71
|
+
export declare class ToastQueue<T> {
|
|
72
|
+
private queue;
|
|
73
|
+
private subscriptions;
|
|
74
|
+
private maxVisibleToasts;
|
|
75
|
+
private hasExitAnimation;
|
|
76
|
+
private keyCounter;
|
|
77
|
+
constructor(options?: ToastQueueOptions);
|
|
78
|
+
/**
|
|
79
|
+
* Subscribe to queue changes.
|
|
80
|
+
*/
|
|
81
|
+
subscribe(callback: SubscribeCallback<T>): () => void;
|
|
82
|
+
/**
|
|
83
|
+
* Add a toast to the queue.
|
|
84
|
+
*/
|
|
85
|
+
add(content: T, options?: ToastOptions): string;
|
|
86
|
+
/**
|
|
87
|
+
* Close a toast by key.
|
|
88
|
+
*/
|
|
89
|
+
close(key: string): void;
|
|
90
|
+
/**
|
|
91
|
+
* Remove a toast after exit animation completes.
|
|
92
|
+
*/
|
|
93
|
+
remove(key: string): void;
|
|
94
|
+
/**
|
|
95
|
+
* Pause all toast timers.
|
|
96
|
+
*/
|
|
97
|
+
pauseAll(): void;
|
|
98
|
+
/**
|
|
99
|
+
* Resume all toast timers.
|
|
100
|
+
*/
|
|
101
|
+
resumeAll(): void;
|
|
102
|
+
private updateVisibility;
|
|
103
|
+
private notify;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Creates reactive toast state from a ToastQueue.
|
|
107
|
+
* Use this hook to subscribe to toast changes in your component.
|
|
108
|
+
*/
|
|
109
|
+
export declare function createToastState<T>(props: ToastStateProps<T>): ToastState<T>;
|
|
110
|
+
/**
|
|
111
|
+
* Creates a new ToastQueue and returns reactive state.
|
|
112
|
+
* Use this if you don't need a global queue.
|
|
113
|
+
*/
|
|
114
|
+
export declare function createToastQueue<T>(options?: ToastQueueOptions): ToastState<T> & {
|
|
115
|
+
queue: ToastQueue<T>;
|
|
116
|
+
};
|
|
117
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createToastState, createToastQueue, ToastQueue, Timer, type ToastOptions, type QueuedToast, type ToastQueueOptions, type ToastStateProps, type ToastState, } from './createToastState';
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Toggle state for Solid Stately
|
|
3
|
+
*
|
|
4
|
+
* Provides state management for toggle components like checkboxes and switches.
|
|
5
|
+
*
|
|
6
|
+
* This is a 1:1 port of @react-stately/toggle's useToggleState.
|
|
7
|
+
*/
|
|
8
|
+
import { Accessor } from 'solid-js';
|
|
9
|
+
import { type MaybeAccessor } from '../utils';
|
|
10
|
+
export interface ToggleStateOptions {
|
|
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
|
+
}
|
|
20
|
+
export interface ToggleState {
|
|
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
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Provides state management for toggle components like checkboxes and switches.
|
|
32
|
+
*/
|
|
33
|
+
export declare function createToggleState(props?: MaybeAccessor<ToggleStateOptions>): ToggleState;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createToggleState, type ToggleStateOptions, type ToggleState, } from './createToggleState';
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Manages state for a tooltip trigger.
|
|
3
|
+
* Based on @react-stately/tooltip useTooltipTriggerState.
|
|
4
|
+
*
|
|
5
|
+
* Tracks whether the tooltip is open, and provides methods to toggle this state.
|
|
6
|
+
* Ensures only one tooltip is open at a time and controls the delay for showing a tooltip.
|
|
7
|
+
*/
|
|
8
|
+
import { type Accessor } from 'solid-js';
|
|
9
|
+
import { type OverlayTriggerProps } from '../overlays';
|
|
10
|
+
export interface TooltipTriggerProps extends OverlayTriggerProps {
|
|
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
|
+
}
|
|
16
|
+
export interface TooltipTriggerState {
|
|
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
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Resets the global tooltip state. Useful for testing.
|
|
30
|
+
* @internal
|
|
31
|
+
*/
|
|
32
|
+
export declare function resetTooltipState(): void;
|
|
33
|
+
/**
|
|
34
|
+
* Manages state for a tooltip trigger. Tracks whether the tooltip is open, and provides
|
|
35
|
+
* methods to toggle this state. Ensures only one tooltip is open at a time and controls
|
|
36
|
+
* the delay for showing a tooltip.
|
|
37
|
+
*/
|
|
38
|
+
export declare function createTooltipTriggerState(props?: TooltipTriggerProps): TooltipTriggerState;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createTooltipTriggerState, resetTooltipState, type TooltipTriggerProps, type TooltipTriggerState, } from './createTooltipTriggerState';
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TreeCollection implementation.
|
|
3
|
+
* Based on @react-stately/tree/TreeCollection.
|
|
4
|
+
*
|
|
5
|
+
* A flattened view of tree nodes that respects expanded state.
|
|
6
|
+
* Only visible nodes (root + expanded children) are included in iteration.
|
|
7
|
+
*/
|
|
8
|
+
import type { Key } from '../collections/types';
|
|
9
|
+
import type { TreeCollection as ITreeCollection, TreeNode, TreeItemData } from './types';
|
|
10
|
+
/**
|
|
11
|
+
* Creates a TreeCollection from hierarchical data.
|
|
12
|
+
* The collection is flattened based on expanded keys.
|
|
13
|
+
*/
|
|
14
|
+
export declare class TreeCollection<T> implements ITreeCollection<T> {
|
|
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
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Factory function to create a TreeCollection.
|
|
37
|
+
* Useful for the collectionFactory pattern in TreeStateOptions.
|
|
38
|
+
*/
|
|
39
|
+
export declare function createTreeCollection<T>(items: TreeItemData<T>[], expandedKeys: Set<Key>): TreeCollection<T>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tree state management for Tree components.
|
|
3
|
+
* Based on @react-stately/tree/useTreeState.
|
|
4
|
+
*
|
|
5
|
+
* Manages expansion state, selection, and focus for hierarchical tree data.
|
|
6
|
+
*/
|
|
7
|
+
import { type Accessor } from 'solid-js';
|
|
8
|
+
import type { TreeState, TreeStateOptions, TreeCollection } from './types';
|
|
9
|
+
/**
|
|
10
|
+
* Creates state management for a tree component.
|
|
11
|
+
* Handles expansion, selection, focus management, and keyboard navigation state.
|
|
12
|
+
*/
|
|
13
|
+
export declare function createTreeState<T extends object, C extends TreeCollection<T> = TreeCollection<T>>(options: Accessor<TreeStateOptions<T, C>>): TreeState<T, C>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tree state management exports.
|
|
3
|
+
*/
|
|
4
|
+
export { createTreeState } from './createTreeState';
|
|
5
|
+
export { TreeCollection, createTreeCollection } from './TreeCollection';
|
|
6
|
+
export type { TreeState, TreeStateOptions, TreeCollection as TreeCollectionInterface, TreeNode, TreeItemData, } from './types';
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tree collection types for Tree components.
|
|
3
|
+
* Based on @react-stately/tree.
|
|
4
|
+
*/
|
|
5
|
+
import type { Key, FocusStrategy } from '../collections/types';
|
|
6
|
+
import type { GridNode, GridCollection } from '../grid/types';
|
|
7
|
+
/**
|
|
8
|
+
* Represents a node in a tree collection.
|
|
9
|
+
* Extends GridNode with tree-specific properties.
|
|
10
|
+
*/
|
|
11
|
+
export interface TreeNode<T = unknown> extends GridNode<T> {
|
|
12
|
+
/** Whether this node has child nodes that can be expanded. */
|
|
13
|
+
hasChildNodes: boolean;
|
|
14
|
+
/** Child nodes of this tree item. */
|
|
15
|
+
childNodes: TreeNode<T>[];
|
|
16
|
+
/** The level of nesting (0 for root items). */
|
|
17
|
+
level: number;
|
|
18
|
+
/** The key of the parent node, if any. */
|
|
19
|
+
parentKey?: Key | null;
|
|
20
|
+
/** Whether this node is expandable. */
|
|
21
|
+
isExpandable?: boolean;
|
|
22
|
+
/** Whether this node is currently expanded (only meaningful if expandable). */
|
|
23
|
+
isExpanded?: boolean;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* A collection of tree nodes with tree-specific navigation.
|
|
27
|
+
* Only includes visible nodes (respects expanded state).
|
|
28
|
+
*/
|
|
29
|
+
export interface TreeCollection<T = unknown> extends Omit<GridCollection<T>, 'rows' | 'columns' | 'headerRows' | 'columnCount' | 'getCell'> {
|
|
30
|
+
/** All visible rows in the tree (respects expanded state). */
|
|
31
|
+
readonly rows: TreeNode<T>[];
|
|
32
|
+
/** Number of visible rows. */
|
|
33
|
+
readonly rowCount: number;
|
|
34
|
+
/** Get all keys in the collection (visible only). */
|
|
35
|
+
getKeys(): Iterable<Key>;
|
|
36
|
+
/** Get a node by its key (any node, visible or not). */
|
|
37
|
+
getItem(key: Key): TreeNode<T> | null;
|
|
38
|
+
/** Get a node by index (visible nodes only). */
|
|
39
|
+
at(index: number): TreeNode<T> | null;
|
|
40
|
+
/** Get the key before the given key (visible nodes only). */
|
|
41
|
+
getKeyBefore(key: Key): Key | null;
|
|
42
|
+
/** Get the key after the given key (visible nodes only). */
|
|
43
|
+
getKeyAfter(key: Key): Key | null;
|
|
44
|
+
/** Get the first key in the collection. */
|
|
45
|
+
getFirstKey(): Key | null;
|
|
46
|
+
/** Get the last key in the collection. */
|
|
47
|
+
getLastKey(): Key | null;
|
|
48
|
+
/** Get the children of a node. */
|
|
49
|
+
getChildren(key: Key): Iterable<TreeNode<T>>;
|
|
50
|
+
/** Get the text value for a key. */
|
|
51
|
+
getTextValue(key: Key): string;
|
|
52
|
+
/** Get the parent key for a node. */
|
|
53
|
+
getParentKey(key: Key): Key | null;
|
|
54
|
+
/** Iterator over visible nodes. */
|
|
55
|
+
[Symbol.iterator](): Iterator<TreeNode<T>>;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* State for a tree component.
|
|
59
|
+
* Extends grid state with expansion management.
|
|
60
|
+
*/
|
|
61
|
+
export interface TreeState<T, C extends TreeCollection<T> = TreeCollection<T>> {
|
|
62
|
+
/** The tree collection (only visible nodes). */
|
|
63
|
+
readonly collection: C;
|
|
64
|
+
/** Keys of disabled items. */
|
|
65
|
+
readonly disabledKeys: Set<Key>;
|
|
66
|
+
/** Keys of expanded items. */
|
|
67
|
+
readonly expandedKeys: Set<Key>;
|
|
68
|
+
/** Whether keyboard navigation is disabled. */
|
|
69
|
+
readonly isKeyboardNavigationDisabled: boolean;
|
|
70
|
+
/** Currently focused key. */
|
|
71
|
+
readonly focusedKey: Key | null;
|
|
72
|
+
/** Focus strategy for child focus. */
|
|
73
|
+
readonly childFocusStrategy: FocusStrategy | null;
|
|
74
|
+
/** Whether the tree is focused. */
|
|
75
|
+
readonly isFocused: boolean;
|
|
76
|
+
/** The selection mode. */
|
|
77
|
+
readonly selectionMode: 'none' | 'single' | 'multiple';
|
|
78
|
+
/** The currently selected keys. */
|
|
79
|
+
readonly selectedKeys: 'all' | Set<Key>;
|
|
80
|
+
/** Check if a key is selected. */
|
|
81
|
+
isSelected(key: Key): boolean;
|
|
82
|
+
/** Check if a key is disabled. */
|
|
83
|
+
isDisabled(key: Key): boolean;
|
|
84
|
+
/** Check if a key is expanded. */
|
|
85
|
+
isExpanded(key: Key): boolean;
|
|
86
|
+
/** Set the focused key. */
|
|
87
|
+
setFocusedKey(key: Key | null, childFocusStrategy?: FocusStrategy): void;
|
|
88
|
+
/** Set focused state. */
|
|
89
|
+
setFocused(isFocused: boolean): void;
|
|
90
|
+
/** Toggle selection for a key. */
|
|
91
|
+
toggleSelection(key: Key): void;
|
|
92
|
+
/** Replace selection with a key. */
|
|
93
|
+
replaceSelection(key: Key): void;
|
|
94
|
+
/** Extend selection to a key (shift-click). */
|
|
95
|
+
extendSelection(toKey: Key): void;
|
|
96
|
+
/** Select all visible items. */
|
|
97
|
+
selectAll(): void;
|
|
98
|
+
/** Clear selection. */
|
|
99
|
+
clearSelection(): void;
|
|
100
|
+
/** Toggle select all. */
|
|
101
|
+
toggleSelectAll(): void;
|
|
102
|
+
/** Toggle expansion for a key. */
|
|
103
|
+
toggleKey(key: Key): void;
|
|
104
|
+
/** Expand a key. */
|
|
105
|
+
expandKey(key: Key): void;
|
|
106
|
+
/** Collapse a key. */
|
|
107
|
+
collapseKey(key: Key): void;
|
|
108
|
+
/** Set the expanded keys. */
|
|
109
|
+
setExpandedKeys(keys: Set<Key>): void;
|
|
110
|
+
/** Set keyboard navigation disabled. */
|
|
111
|
+
setKeyboardNavigationDisabled(isDisabled: boolean): void;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Options for creating tree state.
|
|
115
|
+
*/
|
|
116
|
+
export interface TreeStateOptions<T, C extends TreeCollection<T> = TreeCollection<T>> {
|
|
117
|
+
/** The tree collection builder - receives expanded keys and returns collection. */
|
|
118
|
+
collectionFactory: (expandedKeys: Set<Key>) => C;
|
|
119
|
+
/** Keys of disabled items. */
|
|
120
|
+
disabledKeys?: Iterable<Key>;
|
|
121
|
+
/** Disabled behavior: 'selection' only or 'all' interactions. */
|
|
122
|
+
disabledBehavior?: 'selection' | 'all';
|
|
123
|
+
/** Selection mode. */
|
|
124
|
+
selectionMode?: 'none' | 'single' | 'multiple';
|
|
125
|
+
/** Selection behavior. */
|
|
126
|
+
selectionBehavior?: 'toggle' | 'replace';
|
|
127
|
+
/** Whether empty selection is disallowed. */
|
|
128
|
+
disallowEmptySelection?: boolean;
|
|
129
|
+
/** Currently selected keys (controlled). */
|
|
130
|
+
selectedKeys?: 'all' | Iterable<Key>;
|
|
131
|
+
/** Default selected keys (uncontrolled). */
|
|
132
|
+
defaultSelectedKeys?: 'all' | Iterable<Key>;
|
|
133
|
+
/** Handler for selection changes. */
|
|
134
|
+
onSelectionChange?: (keys: 'all' | Set<Key>) => void;
|
|
135
|
+
/** Currently expanded keys (controlled). */
|
|
136
|
+
expandedKeys?: Iterable<Key>;
|
|
137
|
+
/** Default expanded keys (uncontrolled). */
|
|
138
|
+
defaultExpandedKeys?: Iterable<Key>;
|
|
139
|
+
/** Handler for expansion changes. */
|
|
140
|
+
onExpandedChange?: (keys: Set<Key>) => void;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Item representation for building tree collections.
|
|
144
|
+
*/
|
|
145
|
+
export interface TreeItemData<T = unknown> {
|
|
146
|
+
/** Unique key for this item. */
|
|
147
|
+
key: Key;
|
|
148
|
+
/** The data value for this item. */
|
|
149
|
+
value: T;
|
|
150
|
+
/** Text content for accessibility and search. */
|
|
151
|
+
textValue?: string;
|
|
152
|
+
/** Child items (makes this item expandable). */
|
|
153
|
+
children?: TreeItemData<T>[];
|
|
154
|
+
/** Whether this item is disabled. */
|
|
155
|
+
isDisabled?: boolean;
|
|
156
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { access, isAccessor, type MaybeAccessor, type MaybeAccessorValue } from './reactivity';
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reactivity utilities for Solid Stately
|
|
3
|
+
*
|
|
4
|
+
* Provides type-safe utilities for working with SolidJS reactivity patterns.
|
|
5
|
+
*/
|
|
6
|
+
import { Accessor } from 'solid-js';
|
|
7
|
+
/**
|
|
8
|
+
* A value that may be either a raw value or an accessor function.
|
|
9
|
+
* This is a common pattern in SolidJS for props that may be reactive.
|
|
10
|
+
*/
|
|
11
|
+
export type MaybeAccessor<T> = T | Accessor<T>;
|
|
12
|
+
/**
|
|
13
|
+
* Unwraps a MaybeAccessor to get the underlying value.
|
|
14
|
+
* If the input is a function, it calls it to get the value.
|
|
15
|
+
* Otherwise, it returns the value directly.
|
|
16
|
+
*
|
|
17
|
+
* @param value - The value or accessor to unwrap.
|
|
18
|
+
*/
|
|
19
|
+
export declare function access<T>(value: MaybeAccessor<T>): T;
|
|
20
|
+
/**
|
|
21
|
+
* A value that may be undefined or an accessor that returns the value or undefined.
|
|
22
|
+
*/
|
|
23
|
+
export type MaybeAccessorValue<T> = T | undefined | Accessor<T | undefined>;
|
|
24
|
+
/**
|
|
25
|
+
* Checks if a value is an accessor function.
|
|
26
|
+
*/
|
|
27
|
+
export declare function isAccessor<T>(value: MaybeAccessor<T>): value is Accessor<T>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@proyecto-viviana/solid-stately",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
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",
|
|
@@ -20,9 +20,8 @@
|
|
|
20
20
|
],
|
|
21
21
|
"sideEffects": false,
|
|
22
22
|
"scripts": {
|
|
23
|
-
"build": "
|
|
24
|
-
"
|
|
25
|
-
"prepublishOnly": "bun run build"
|
|
23
|
+
"build": "deno run -A ../../scripts/build.ts solid-stately",
|
|
24
|
+
"prepublishOnly": "deno run -A ../../scripts/build.ts solid-stately"
|
|
26
25
|
},
|
|
27
26
|
"peerDependencies": {
|
|
28
27
|
"solid-js": "^1.9.0"
|