@proyecto-viviana/solid-stately 0.1.0 → 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.
Files changed (74) hide show
  1. package/dist/autocomplete/createAutocompleteState.d.ts +45 -0
  2. package/dist/autocomplete/index.d.ts +1 -0
  3. package/dist/calendar/createCalendarState.d.ts +129 -0
  4. package/dist/calendar/createDateFieldState.d.ts +109 -0
  5. package/dist/calendar/createRangeCalendarState.d.ts +145 -0
  6. package/dist/calendar/createTimeFieldState.d.ts +94 -0
  7. package/dist/calendar/index.d.ts +6 -0
  8. package/dist/checkbox/createCheckboxGroupState.d.ts +70 -0
  9. package/dist/checkbox/index.d.ts +1 -0
  10. package/dist/collections/ListCollection.d.ts +36 -0
  11. package/dist/collections/createListState.d.ts +78 -0
  12. package/dist/collections/createMenuState.d.ts +49 -0
  13. package/dist/collections/createSelectionState.d.ts +75 -0
  14. package/dist/collections/index.d.ts +5 -0
  15. package/dist/collections/types.d.ts +146 -0
  16. package/dist/color/Color.d.ts +27 -0
  17. package/dist/color/createColorAreaState.d.ts +75 -0
  18. package/dist/color/createColorFieldState.d.ts +54 -0
  19. package/dist/color/createColorSliderState.d.ts +66 -0
  20. package/dist/color/createColorWheelState.d.ts +50 -0
  21. package/dist/color/index.d.ts +9 -0
  22. package/dist/color/types.d.ts +105 -0
  23. package/dist/combobox/createComboBoxState.d.ts +124 -0
  24. package/dist/combobox/index.d.ts +4 -0
  25. package/dist/disclosure/createDisclosureState.d.ts +63 -0
  26. package/dist/disclosure/index.d.ts +1 -0
  27. package/dist/dnd/createDragState.d.ts +58 -0
  28. package/dist/dnd/createDraggableCollectionState.d.ts +56 -0
  29. package/dist/dnd/createDropState.d.ts +60 -0
  30. package/dist/dnd/createDroppableCollectionState.d.ts +77 -0
  31. package/dist/dnd/index.d.ts +10 -0
  32. package/dist/dnd/types.d.ts +263 -0
  33. package/dist/form/createFormValidationState.d.ts +99 -0
  34. package/dist/form/index.d.ts +1 -0
  35. package/dist/grid/createGridState.d.ts +11 -0
  36. package/dist/grid/index.d.ts +6 -0
  37. package/dist/grid/types.d.ts +155 -0
  38. package/dist/index.d.ts +25 -3363
  39. package/dist/index.js +2 -2
  40. package/dist/index.js.map +7 -1
  41. package/dist/numberfield/createNumberFieldState.d.ts +64 -0
  42. package/dist/numberfield/index.d.ts +1 -0
  43. package/dist/overlays/createOverlayTriggerState.d.ts +31 -0
  44. package/dist/overlays/index.d.ts +1 -0
  45. package/dist/radio/createRadioGroupState.d.ts +76 -0
  46. package/dist/radio/index.d.ts +1 -0
  47. package/dist/searchfield/createSearchFieldState.d.ts +24 -0
  48. package/dist/searchfield/index.d.ts +2 -0
  49. package/dist/select/createSelectState.d.ts +72 -0
  50. package/dist/select/index.d.ts +1 -0
  51. package/dist/slider/createSliderState.d.ts +71 -0
  52. package/dist/slider/index.d.ts +2 -0
  53. package/dist/ssr/index.d.ts +27 -0
  54. package/dist/table/TableCollection.d.ts +51 -0
  55. package/dist/table/createTableState.d.ts +11 -0
  56. package/dist/table/index.d.ts +7 -0
  57. package/dist/table/types.d.ts +138 -0
  58. package/dist/tabs/createTabListState.d.ts +67 -0
  59. package/dist/tabs/index.d.ts +1 -0
  60. package/dist/textfield/createTextFieldState.d.ts +29 -0
  61. package/dist/textfield/index.d.ts +1 -0
  62. package/dist/toast/createToastState.d.ts +117 -0
  63. package/dist/toast/index.d.ts +1 -0
  64. package/dist/toggle/createToggleState.d.ts +33 -0
  65. package/dist/toggle/index.d.ts +1 -0
  66. package/dist/tooltip/createTooltipTriggerState.d.ts +38 -0
  67. package/dist/tooltip/index.d.ts +1 -0
  68. package/dist/tree/TreeCollection.d.ts +39 -0
  69. package/dist/tree/createTreeState.d.ts +13 -0
  70. package/dist/tree/index.d.ts +6 -0
  71. package/dist/tree/types.d.ts +156 -0
  72. package/dist/utils/index.d.ts +1 -0
  73. package/dist/utils/reactivity.d.ts +27 -0
  74. package/package.json +3 -4
@@ -0,0 +1,105 @@
1
+ /**
2
+ * Color types for color picker components.
3
+ * Based on @react-stately/color.
4
+ */
5
+ /**
6
+ * Supported color formats.
7
+ */
8
+ export type ColorFormat = 'hex' | 'hexa' | 'rgb' | 'rgba' | 'hsl' | 'hsla' | 'hsb' | 'hsba';
9
+ /**
10
+ * Color spaces.
11
+ */
12
+ export type ColorSpace = 'rgb' | 'hsl' | 'hsb';
13
+ /**
14
+ * Color channels.
15
+ */
16
+ export type ColorChannel = 'hue' | 'saturation' | 'brightness' | 'lightness' | 'red' | 'green' | 'blue' | 'alpha';
17
+ /**
18
+ * Range for a color channel.
19
+ */
20
+ export interface ColorChannelRange {
21
+ /** Minimum value. */
22
+ minValue: number;
23
+ /** Maximum value. */
24
+ maxValue: number;
25
+ /** Step for keyboard increment. */
26
+ step: number;
27
+ /** Page step for larger increments. */
28
+ pageSize: number;
29
+ }
30
+ /**
31
+ * Color axes for a color space.
32
+ */
33
+ export interface ColorAxes {
34
+ /** X-axis channel. */
35
+ xChannel: ColorChannel;
36
+ /** Y-axis channel. */
37
+ yChannel: ColorChannel;
38
+ /** Z-axis channel (the one not on x or y). */
39
+ zChannel: ColorChannel;
40
+ }
41
+ /**
42
+ * Color interface representing a color value.
43
+ */
44
+ export interface Color {
45
+ /** Convert to a different format. */
46
+ toFormat(format: ColorFormat): Color;
47
+ /** Convert to a CSS string. */
48
+ toString(format?: ColorFormat | 'css'): string;
49
+ /** Clone this color. */
50
+ clone(): Color;
51
+ /** Get the hex value as an integer. */
52
+ toHexInt(): number;
53
+ /** Get the value of a specific channel. */
54
+ getChannelValue(channel: ColorChannel): number;
55
+ /** Create a new color with a channel value changed. */
56
+ withChannelValue(channel: ColorChannel, value: number): Color;
57
+ /** Get the range for a channel. */
58
+ getChannelRange(channel: ColorChannel): ColorChannelRange;
59
+ /** Get the localized name of a channel. */
60
+ getChannelName(channel: ColorChannel, locale: string): string;
61
+ /** Get the format options for a channel. */
62
+ getChannelFormatOptions(channel: ColorChannel): Intl.NumberFormatOptions;
63
+ /** Format the value of a channel. */
64
+ formatChannelValue(channel: ColorChannel, locale: string): string;
65
+ /** Get the color space. */
66
+ getColorSpace(): ColorSpace;
67
+ /** Get the axes for a color space. */
68
+ getColorSpaceAxes(xyChannels?: {
69
+ xChannel?: ColorChannel;
70
+ yChannel?: ColorChannel;
71
+ }): ColorAxes;
72
+ /** Get all channels for this color space. */
73
+ getColorChannels(): [ColorChannel, ColorChannel, ColorChannel];
74
+ /** Get a human-readable color name. */
75
+ getColorName(locale: string): string;
76
+ /** Get the hue name (e.g., "red", "blue"). */
77
+ getHueName(locale: string): string;
78
+ }
79
+ /**
80
+ * RGB color value.
81
+ */
82
+ export interface RGBColor {
83
+ red: number;
84
+ green: number;
85
+ blue: number;
86
+ alpha: number;
87
+ }
88
+ /**
89
+ * HSL color value.
90
+ */
91
+ export interface HSLColor {
92
+ hue: number;
93
+ saturation: number;
94
+ lightness: number;
95
+ alpha: number;
96
+ }
97
+ /**
98
+ * HSB color value.
99
+ */
100
+ export interface HSBColor {
101
+ hue: number;
102
+ saturation: number;
103
+ brightness: number;
104
+ alpha: number;
105
+ }
@@ -0,0 +1,124 @@
1
+ /**
2
+ * State management for ComboBox components.
3
+ * Based on @react-stately/combobox useComboBoxState.
4
+ *
5
+ * ComboBox combines a text input with a dropdown list, allowing users to
6
+ * either type to filter options or select from a list.
7
+ */
8
+ import { type Accessor } from 'solid-js';
9
+ import { type MaybeAccessor } from '../utils';
10
+ import type { Key, CollectionNode, Collection, FocusStrategy } from '../collections/types';
11
+ export type MenuTriggerAction = 'focus' | 'input' | 'manual';
12
+ export type { FocusStrategy } from '../collections/types';
13
+ export type FilterFn = (textValue: string, inputValue: string) => boolean;
14
+ export interface ComboBoxStateProps<T = unknown> {
15
+ /** The items to display in the combobox dropdown. */
16
+ items: T[];
17
+ /** Default items when uncontrolled. */
18
+ defaultItems?: T[];
19
+ /** Function to get the key for an item. */
20
+ getKey?: (item: T) => Key;
21
+ /** Function to get the text value for an item. */
22
+ getTextValue?: (item: T) => string;
23
+ /** Function to check if an item is disabled. */
24
+ getDisabled?: (item: T) => boolean;
25
+ /** Keys of disabled items. */
26
+ disabledKeys?: Iterable<Key>;
27
+ /** The currently selected key (controlled). */
28
+ selectedKey?: Key | null;
29
+ /** The default selected key (uncontrolled). */
30
+ defaultSelectedKey?: Key | null;
31
+ /** Handler called when the selection changes. */
32
+ onSelectionChange?: (key: Key | null) => void;
33
+ /** The current input value (controlled). */
34
+ inputValue?: string;
35
+ /** The default input value (uncontrolled). */
36
+ defaultInputValue?: string;
37
+ /** Handler called when the input value changes. */
38
+ onInputChange?: (value: string) => void;
39
+ /** Whether the combobox is open (controlled). */
40
+ isOpen?: boolean;
41
+ /** Whether the combobox is open by default (uncontrolled). */
42
+ defaultOpen?: boolean;
43
+ /** Handler called when the open state changes. */
44
+ onOpenChange?: (isOpen: boolean, trigger?: MenuTriggerAction) => void;
45
+ /** Whether the combobox is disabled. */
46
+ isDisabled?: boolean;
47
+ /** Whether the combobox is read-only. */
48
+ isReadOnly?: boolean;
49
+ /** Whether the combobox is required. */
50
+ isRequired?: boolean;
51
+ /** The filter function to use when filtering items. */
52
+ defaultFilter?: FilterFn;
53
+ /** Whether to allow the menu to open when there are no items. */
54
+ allowsEmptyCollection?: boolean;
55
+ /** Whether to allow custom values that don't match any option. */
56
+ allowsCustomValue?: boolean;
57
+ /** What triggers the menu to open. */
58
+ menuTrigger?: MenuTriggerAction;
59
+ /** Whether to close the menu on blur. */
60
+ shouldCloseOnBlur?: boolean;
61
+ }
62
+ export interface ComboBoxState<T = unknown> {
63
+ /** The collection of items (may be filtered). */
64
+ readonly collection: Accessor<Collection<T>>;
65
+ /** Whether the combobox dropdown is open. */
66
+ readonly isOpen: Accessor<boolean>;
67
+ /** Open the combobox dropdown. */
68
+ open(focusStrategy?: FocusStrategy | null, trigger?: MenuTriggerAction): void;
69
+ /** Close the combobox dropdown. */
70
+ close(): void;
71
+ /** Toggle the combobox dropdown. */
72
+ toggle(focusStrategy?: FocusStrategy | null, trigger?: MenuTriggerAction): void;
73
+ /** The currently selected key. */
74
+ readonly selectedKey: Accessor<Key | null>;
75
+ /** The default selected key. */
76
+ readonly defaultSelectedKey: Key | null;
77
+ /** The currently selected item. */
78
+ readonly selectedItem: Accessor<CollectionNode<T> | null>;
79
+ /** Set the selected key. */
80
+ setSelectedKey(key: Key | null): void;
81
+ /** The current input value. */
82
+ readonly inputValue: Accessor<string>;
83
+ /** The default input value. */
84
+ readonly defaultInputValue: string;
85
+ /** Set the input value. */
86
+ setInputValue(value: string): void;
87
+ /** The currently focused key in the list. */
88
+ readonly focusedKey: Accessor<Key | null>;
89
+ /** Set the focused key. */
90
+ setFocusedKey(key: Key | null): void;
91
+ /** Whether the combobox input has focus. */
92
+ readonly isFocused: Accessor<boolean>;
93
+ /** Set whether the combobox has focus. */
94
+ setFocused(isFocused: boolean): void;
95
+ /** The focus strategy to use when opening. */
96
+ readonly focusStrategy: Accessor<FocusStrategy | null>;
97
+ /** Commit the current selection (select focused item or custom value). */
98
+ commit(): void;
99
+ /** Revert input to the selected item's text and close menu. */
100
+ revert(): void;
101
+ /** Whether a specific key is disabled. */
102
+ isKeyDisabled(key: Key): boolean;
103
+ /** Select a key and close the menu (for ListState compatibility). */
104
+ select(key: Key): void;
105
+ /** The selection mode (always 'single' for combobox). */
106
+ readonly selectionMode: Accessor<'single'>;
107
+ /** Check if a key is selected. */
108
+ isSelected(key: Key): boolean;
109
+ /** Whether the combobox is disabled. */
110
+ readonly isDisabled: boolean;
111
+ /** Whether the combobox is read-only. */
112
+ readonly isReadOnly: boolean;
113
+ /** Whether the combobox is required. */
114
+ readonly isRequired: boolean;
115
+ }
116
+ /**
117
+ * Default filter function that does case-insensitive "contains" matching.
118
+ */
119
+ export declare const defaultContainsFilter: FilterFn;
120
+ /**
121
+ * Creates state for a combobox component.
122
+ * Combines list state with input value management and filtering.
123
+ */
124
+ export declare function createComboBoxState<T = unknown>(props: MaybeAccessor<ComboBoxStateProps<T>>): ComboBoxState<T>;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * ComboBox state management for Solid Stately.
3
+ */
4
+ export { createComboBoxState, defaultContainsFilter, type ComboBoxState, type ComboBoxStateProps, type FilterFn, type MenuTriggerAction, type FocusStrategy, } from './createComboBoxState';
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Disclosure state management for SolidJS
3
+ * Based on @react-stately/disclosure useDisclosureState and useDisclosureGroupState
4
+ */
5
+ import { type Accessor } from 'solid-js';
6
+ import { type MaybeAccessor } from '../utils';
7
+ export interface DisclosureStateProps {
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
+ }
15
+ export interface DisclosureState {
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
+ }
27
+ /**
28
+ * Manages state for a disclosure widget. Tracks whether the disclosure is expanded,
29
+ * and provides methods to toggle this state.
30
+ */
31
+ export declare function createDisclosureState(props?: MaybeAccessor<DisclosureStateProps>): DisclosureState;
32
+ export type Key = string | number;
33
+ export interface DisclosureGroupStateProps {
34
+ /** Whether multiple items can be expanded at the same time. */
35
+ allowsMultipleExpanded?: boolean;
36
+ /** Whether all items are disabled. */
37
+ isDisabled?: boolean;
38
+ /** The currently expanded keys in the group (controlled). */
39
+ expandedKeys?: Iterable<Key>;
40
+ /** The initial expanded keys in the group (uncontrolled). */
41
+ defaultExpandedKeys?: Iterable<Key>;
42
+ /** Handler that is called when items are expanded or collapsed. */
43
+ onExpandedChange?: (keys: Set<Key>) => void;
44
+ }
45
+ export interface DisclosureGroupState {
46
+ /** Whether multiple items can be expanded at the same time. */
47
+ readonly allowsMultipleExpanded: boolean;
48
+ /** Whether all items are disabled. */
49
+ readonly isDisabled: boolean;
50
+ /** A set of keys for items that are expanded. */
51
+ readonly expandedKeys: Accessor<Set<Key>>;
52
+ /** Toggles the expanded state for an item by its key. */
53
+ toggleKey(key: Key): void;
54
+ /** Replaces the set of expanded keys. */
55
+ setExpandedKeys(keys: Set<Key>): void;
56
+ /** Check if a specific key is expanded. */
57
+ isExpanded(key: Key): boolean;
58
+ }
59
+ /**
60
+ * Manages state for a group of disclosures, e.g. an accordion.
61
+ * It supports both single and multiple expanded items.
62
+ */
63
+ export declare function createDisclosureGroupState(props?: MaybeAccessor<DisclosureGroupStateProps>): DisclosureGroupState;
@@ -0,0 +1 @@
1
+ export { createDisclosureState, createDisclosureGroupState, type DisclosureStateProps, type DisclosureState, type DisclosureGroupStateProps, type DisclosureGroupState, type Key, } from './createDisclosureState';
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Drag state management for solid-stately.
3
+ *
4
+ * Provides reactive state for drag operations.
5
+ */
6
+ import { type Accessor } from 'solid-js';
7
+ import type { DragItem, DragStartEvent, DragMoveEvent, DragEndEvent, DropOperation, DragPreviewRenderer } from './types';
8
+ export interface DragStateOptions {
9
+ /** A function that returns the items being dragged. */
10
+ getItems: () => DragItem[];
11
+ /** Function that returns the allowed drop operations. */
12
+ getAllowedDropOperations?: () => DropOperation[];
13
+ /** Handler that is called when a drag operation is started. */
14
+ onDragStart?: (e: DragStartEvent) => void;
15
+ /** Handler that is called when the drag is moved. */
16
+ onDragMove?: (e: DragMoveEvent) => void;
17
+ /** Handler that is called when the drag operation ends. */
18
+ onDragEnd?: (e: DragEndEvent) => void;
19
+ /** Whether the drag operation is disabled. */
20
+ isDisabled?: boolean;
21
+ /** Whether there is a separate drag button affordance. */
22
+ hasDragButton?: boolean;
23
+ /** Preview renderer function ref. */
24
+ preview?: {
25
+ current: DragPreviewRenderer | null;
26
+ };
27
+ }
28
+ export interface DragState {
29
+ /** Whether an element is currently being dragged. */
30
+ readonly isDragging: boolean;
31
+ /** Whether drag is disabled. */
32
+ readonly isDisabled: boolean;
33
+ /** Start a drag operation. */
34
+ startDrag(x: number, y: number): void;
35
+ /** Update drag position. */
36
+ moveDrag(x: number, y: number): void;
37
+ /** End a drag operation. */
38
+ endDrag(x: number, y: number, dropOperation: DropOperation): void;
39
+ /** Cancel a drag operation. */
40
+ cancelDrag(): void;
41
+ /** Get the items being dragged. */
42
+ getItems(): DragItem[];
43
+ /** Get allowed drop operations. */
44
+ getAllowedDropOperations(): DropOperation[];
45
+ /** Whether there is a drag button. */
46
+ readonly hasDragButton: boolean;
47
+ /** Preview renderer. */
48
+ readonly preview: {
49
+ current: DragPreviewRenderer | null;
50
+ } | undefined;
51
+ }
52
+ /**
53
+ * Creates drag state for managing drag operations.
54
+ *
55
+ * @param props - Accessor returning drag state options
56
+ * @returns Drag state object
57
+ */
58
+ export declare function createDragState(props: Accessor<DragStateOptions>): DragState;
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Draggable collection state management for solid-stately.
3
+ *
4
+ * Provides reactive state for dragging items from a collection.
5
+ */
6
+ import { type Accessor } from 'solid-js';
7
+ import type { DragItem, DraggableCollectionStartEvent, DraggableCollectionMoveEvent, DraggableCollectionEndEvent, DropOperation, DragPreviewRenderer } from './types';
8
+ export interface DraggableCollectionStateOptions<T = object> {
9
+ /** A function that returns the items being dragged. */
10
+ getItems: (keys: Set<string | number>) => DragItem[];
11
+ /** Function that returns the allowed drop operations. */
12
+ getAllowedDropOperations?: () => DropOperation[];
13
+ /** Handler that is called when a drag operation is started. */
14
+ onDragStart?: (e: DraggableCollectionStartEvent) => void;
15
+ /** Handler that is called when the drag is moved. */
16
+ onDragMove?: (e: DraggableCollectionMoveEvent) => void;
17
+ /** Handler that is called when the drag operation ends. */
18
+ onDragEnd?: (e: DraggableCollectionEndEvent) => void;
19
+ /** Whether the drag operation is disabled. */
20
+ isDisabled?: boolean;
21
+ /** Preview renderer function ref. */
22
+ preview?: {
23
+ current: DragPreviewRenderer | null;
24
+ };
25
+ }
26
+ export interface DraggableCollectionState {
27
+ /** Whether items are currently being dragged. */
28
+ readonly isDragging: boolean;
29
+ /** The keys of the items being dragged. */
30
+ readonly draggingKeys: Set<string | number>;
31
+ /** Whether dragging is disabled. */
32
+ readonly isDisabled: boolean;
33
+ /** Start a drag operation with the given keys. */
34
+ startDrag(keys: Set<string | number>, x: number, y: number): void;
35
+ /** Update drag position. */
36
+ moveDrag(x: number, y: number): void;
37
+ /** End a drag operation. */
38
+ endDrag(x: number, y: number, dropOperation: DropOperation, isInternal: boolean): void;
39
+ /** Cancel a drag operation. */
40
+ cancelDrag(): void;
41
+ /** Get the items being dragged for the given keys. */
42
+ getItems(keys: Set<string | number>): DragItem[];
43
+ /** Get allowed drop operations. */
44
+ getAllowedDropOperations(): DropOperation[];
45
+ /** Preview renderer. */
46
+ readonly preview: {
47
+ current: DragPreviewRenderer | null;
48
+ } | undefined;
49
+ }
50
+ /**
51
+ * Creates state for dragging items from a collection.
52
+ *
53
+ * @param props - Accessor returning draggable collection options
54
+ * @returns Draggable collection state object
55
+ */
56
+ export declare function createDraggableCollectionState<T = object>(props: Accessor<DraggableCollectionStateOptions<T>>): DraggableCollectionState;
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Drop state management for solid-stately.
3
+ *
4
+ * Provides reactive state for drop target operations.
5
+ */
6
+ import { type Accessor } from 'solid-js';
7
+ import type { DropItem, DropEnterEvent, DropMoveEvent, DropExitEvent, DropActivateEvent, DropEvent, DropOperation, DragTypes } from './types';
8
+ export interface DropStateOptions {
9
+ /**
10
+ * A function returning the drop operation to be performed.
11
+ */
12
+ getDropOperation?: (types: DragTypes, allowedOperations: DropOperation[]) => DropOperation;
13
+ /**
14
+ * A function returning the drop operation for a specific point.
15
+ */
16
+ getDropOperationForPoint?: (types: DragTypes, allowedOperations: DropOperation[], x: number, y: number) => DropOperation;
17
+ /** Handler that is called when a valid drag enters the drop target. */
18
+ onDropEnter?: (e: DropEnterEvent) => void;
19
+ /** Handler that is called when a valid drag is moved within the drop target. */
20
+ onDropMove?: (e: DropMoveEvent) => void;
21
+ /** Handler that is called after a valid drag is held over the drop target. */
22
+ onDropActivate?: (e: DropActivateEvent) => void;
23
+ /** Handler that is called when a valid drag exits the drop target. */
24
+ onDropExit?: (e: DropExitEvent) => void;
25
+ /** Handler that is called when a valid drag is dropped on the drop target. */
26
+ onDrop?: (e: DropEvent) => void;
27
+ /** Whether there is a separate drop button affordance. */
28
+ hasDropButton?: boolean;
29
+ /** Whether the drop target is disabled. */
30
+ isDisabled?: boolean;
31
+ }
32
+ export interface DropState {
33
+ /** Whether the drop target is currently being hovered or focused. */
34
+ readonly isDropTarget: boolean;
35
+ /** Whether the drop target is disabled. */
36
+ readonly isDisabled: boolean;
37
+ /** Whether there is a drop button. */
38
+ readonly hasDropButton: boolean;
39
+ /** Enter the drop target. */
40
+ enterTarget(x: number, y: number): void;
41
+ /** Move within the drop target. */
42
+ moveInTarget(x: number, y: number): void;
43
+ /** Exit the drop target. */
44
+ exitTarget(x: number, y: number): void;
45
+ /** Activate the drop target (after holding). */
46
+ activateTarget(x: number, y: number): void;
47
+ /** Perform a drop on the target. */
48
+ drop(x: number, y: number, items: DropItem[], dropOperation: DropOperation): void;
49
+ /** Get the drop operation for given types. */
50
+ getDropOperation(types: DragTypes, allowedOperations: DropOperation[]): DropOperation;
51
+ /** Get the drop operation for a specific point. */
52
+ getDropOperationForPoint(types: DragTypes, allowedOperations: DropOperation[], x: number, y: number): DropOperation;
53
+ }
54
+ /**
55
+ * Creates drop state for managing drop target operations.
56
+ *
57
+ * @param props - Accessor returning drop state options
58
+ * @returns Drop state object
59
+ */
60
+ export declare function createDropState(props: Accessor<DropStateOptions>): DropState;
@@ -0,0 +1,77 @@
1
+ /**
2
+ * Droppable collection state management for solid-stately.
3
+ *
4
+ * Provides reactive state for accepting drops onto a collection.
5
+ */
6
+ import { type Accessor } from 'solid-js';
7
+ import type { DropItem, DropTarget, DropOperation, DragTypes, DroppableCollectionEnterEvent, DroppableCollectionActivateEvent, DroppableCollectionExitEvent, DroppableCollectionDropEvent, DroppableCollectionInsertDropEvent, DroppableCollectionRootDropEvent, DroppableCollectionOnItemDropEvent, DroppableCollectionReorderEvent, ItemDropTarget } from './types';
8
+ export interface DroppableCollectionStateOptions {
9
+ /**
10
+ * The drag types that the droppable collection accepts.
11
+ * @default 'all'
12
+ */
13
+ acceptedDragTypes?: 'all' | Array<string | symbol>;
14
+ /**
15
+ * A function returning the drop operation to be performed.
16
+ */
17
+ getDropOperation?: (target: DropTarget, types: DragTypes, allowedOperations: DropOperation[]) => DropOperation;
18
+ /** Handler that is called when a valid drag enters a drop target. */
19
+ onDropEnter?: (e: DroppableCollectionEnterEvent) => void;
20
+ /** Handler that is called after a valid drag is held over a drop target. */
21
+ onDropActivate?: (e: DroppableCollectionActivateEvent) => void;
22
+ /** Handler that is called when a valid drag exits a drop target. */
23
+ onDropExit?: (e: DroppableCollectionExitEvent) => void;
24
+ /** Handler that is called when a valid drag is dropped. */
25
+ onDrop?: (e: DroppableCollectionDropEvent) => void;
26
+ /** Handler that is called when external items are dropped "between" items. */
27
+ onInsert?: (e: DroppableCollectionInsertDropEvent) => void;
28
+ /** Handler that is called when external items are dropped on the collection's root. */
29
+ onRootDrop?: (e: DroppableCollectionRootDropEvent) => void;
30
+ /** Handler that is called when items are dropped "on" an item. */
31
+ onItemDrop?: (e: DroppableCollectionOnItemDropEvent) => void;
32
+ /** Handler that is called when items are reordered within the collection. */
33
+ onReorder?: (e: DroppableCollectionReorderEvent) => void;
34
+ /** Handler that is called when items are moved within the source collection. */
35
+ onMove?: (e: DroppableCollectionReorderEvent) => void;
36
+ /** A function returning whether a given target is a valid "on" drop target. */
37
+ shouldAcceptItemDrop?: (target: ItemDropTarget, types: DragTypes) => boolean;
38
+ /** Whether the droppable collection is disabled. */
39
+ isDisabled?: boolean;
40
+ }
41
+ export interface DroppableCollectionState {
42
+ /** Whether a drag is currently over the collection. */
43
+ readonly isDropTarget: boolean;
44
+ /** The current drop target within the collection. */
45
+ readonly target: DropTarget | null;
46
+ /** Whether the collection is disabled for drops. */
47
+ readonly isDisabled: boolean;
48
+ /** Set the current drop target. */
49
+ setTarget(target: DropTarget | null): void;
50
+ /** Check if a drag type is accepted. */
51
+ isAccepted(types: DragTypes): boolean;
52
+ /** Enter the collection with a drop target. */
53
+ enterTarget(target: DropTarget, x: number, y: number): void;
54
+ /** Move to a new target within the collection. */
55
+ moveToTarget(target: DropTarget, x: number, y: number): void;
56
+ /** Exit the collection. */
57
+ exitTarget(x: number, y: number): void;
58
+ /** Activate the current target. */
59
+ activateTarget(x: number, y: number): void;
60
+ /** Perform a drop on the collection. */
61
+ drop(items: DropItem[], dropOperation: DropOperation, isInternal: boolean, draggingKeys?: Set<string | number>): void;
62
+ /** Get the drop operation for a target. */
63
+ getDropOperation(target: DropTarget, types: DragTypes, allowedOperations: DropOperation[]): DropOperation;
64
+ /** Check if an item drop should be accepted. */
65
+ shouldAcceptItemDrop(target: ItemDropTarget, types: DragTypes): boolean;
66
+ }
67
+ /**
68
+ * Symbol for directory drag type.
69
+ */
70
+ export declare const DIRECTORY_DRAG_TYPE: symbol;
71
+ /**
72
+ * Creates state for accepting drops onto a collection.
73
+ *
74
+ * @param props - Accessor returning droppable collection options
75
+ * @returns Droppable collection state object
76
+ */
77
+ export declare function createDroppableCollectionState(props: Accessor<DroppableCollectionStateOptions>): DroppableCollectionState;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Drag and Drop state management for solid-stately.
3
+ *
4
+ * Exports for DnD functionality.
5
+ */
6
+ export type { DropOperation, DragItem, DragDropEvent, DragStartEvent, DragMoveEvent, DragEndEvent, DropEnterEvent, DropMoveEvent, DropActivateEvent, DropExitEvent, TextDropItem, FileDropItem, DirectoryDropItem, DropItem, DropEvent, DropPosition, RootDropTarget, ItemDropTarget, DropTarget, DroppableCollectionEnterEvent, DroppableCollectionMoveEvent, DroppableCollectionActivateEvent, DroppableCollectionExitEvent, DroppableCollectionDropEvent, DroppableCollectionInsertDropEvent, DroppableCollectionRootDropEvent, DroppableCollectionOnItemDropEvent, DroppableCollectionReorderEvent, DragTypes, DropTargetDelegate, DraggableCollectionStartEvent, DraggableCollectionMoveEvent, DraggableCollectionEndEvent, DragPreviewRenderer, DroppableCollectionUtilityOptions, DroppableCollectionBaseProps, DroppableCollectionProps, DraggableCollectionProps, } from './types';
7
+ export { createDragState, type DragStateOptions, type DragState, } from './createDragState';
8
+ export { createDropState, type DropStateOptions, type DropState, } from './createDropState';
9
+ export { createDraggableCollectionState, type DraggableCollectionStateOptions, type DraggableCollectionState, } from './createDraggableCollectionState';
10
+ export { createDroppableCollectionState, DIRECTORY_DRAG_TYPE, type DroppableCollectionStateOptions, type DroppableCollectionState, } from './createDroppableCollectionState';