@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.
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,78 @@
1
+ /**
2
+ * State management for list-like components.
3
+ * Combines collection and selection state.
4
+ * Based on @react-stately/list.
5
+ */
6
+ import { type Accessor } from 'solid-js';
7
+ import { type MaybeAccessor } from '../utils';
8
+ import { type SelectionState } from './createSelectionState';
9
+ import type { Collection, CollectionNode, DisabledBehavior, FocusStrategy, Key, SelectionBehavior, SelectionMode } from './types';
10
+ export interface ListStateProps<T = unknown> {
11
+ /** The items in the list (for dynamic rendering). */
12
+ items?: T[];
13
+ /** Function to get a key from an item. */
14
+ getKey?: (item: T) => Key;
15
+ /** Function to get text value from an item. */
16
+ getTextValue?: (item: T) => string;
17
+ /** Function to check if an item is disabled. */
18
+ getDisabled?: (item: T) => boolean;
19
+ /** Keys of disabled items. */
20
+ disabledKeys?: Iterable<Key>;
21
+ /** How disabled keys behave. */
22
+ disabledBehavior?: DisabledBehavior;
23
+ /** The selection mode. */
24
+ selectionMode?: SelectionMode;
25
+ /** How selection behaves on interaction. */
26
+ selectionBehavior?: SelectionBehavior;
27
+ /** Whether empty selection is disallowed. */
28
+ disallowEmptySelection?: boolean;
29
+ /** Currently selected keys (controlled). */
30
+ selectedKeys?: 'all' | Iterable<Key>;
31
+ /** Default selected keys (uncontrolled). */
32
+ defaultSelectedKeys?: 'all' | Iterable<Key>;
33
+ /** Handler for selection changes. */
34
+ onSelectionChange?: (keys: 'all' | Set<Key>) => void;
35
+ /** Whether to allow duplicate selection events. */
36
+ allowDuplicateSelectionEvents?: boolean;
37
+ }
38
+ export interface ListState<T = unknown> extends SelectionState {
39
+ /** The collection of items. */
40
+ readonly collection: Accessor<Collection<T>>;
41
+ /** Whether the collection is focused. */
42
+ readonly isFocused: Accessor<boolean>;
43
+ /** Set the focused state. */
44
+ setFocused(isFocused: boolean): void;
45
+ /** The currently focused key. */
46
+ readonly focusedKey: Accessor<Key | null>;
47
+ /** Set the focused key. */
48
+ setFocusedKey(key: Key | null, childStrategy?: FocusStrategy): void;
49
+ /** The child focus strategy. */
50
+ readonly childFocusStrategy: Accessor<FocusStrategy | null>;
51
+ }
52
+ /**
53
+ * Creates state for a list component with selection.
54
+ */
55
+ export declare function createListState<T = unknown>(props: MaybeAccessor<ListStateProps<T>>): ListState<T>;
56
+ /**
57
+ * Props for single selection list state.
58
+ */
59
+ export interface SingleSelectListStateProps<T = unknown> extends Omit<ListStateProps<T>, 'selectionMode' | 'selectedKeys' | 'defaultSelectedKeys' | 'onSelectionChange'> {
60
+ /** The currently selected key (controlled). */
61
+ selectedKey?: Key | null;
62
+ /** The default selected key (uncontrolled). */
63
+ defaultSelectedKey?: Key;
64
+ /** Handler for selection changes. */
65
+ onSelectionChange?: (key: Key | null) => void;
66
+ }
67
+ export interface SingleSelectListState<T = unknown> extends ListState<T> {
68
+ /** The currently selected key. */
69
+ readonly selectedKey: Accessor<Key | null>;
70
+ /** Set the selected key. */
71
+ setSelectedKey(key: Key | null): void;
72
+ /** The currently selected item. */
73
+ readonly selectedItem: Accessor<CollectionNode<T> | null>;
74
+ }
75
+ /**
76
+ * Creates state for a single-select list component.
77
+ */
78
+ export declare function createSingleSelectListState<T = unknown>(props: MaybeAccessor<SingleSelectListStateProps<T>>): SingleSelectListState<T>;
@@ -0,0 +1,49 @@
1
+ /**
2
+ * State management for menu components.
3
+ * Based on @react-stately/menu.
4
+ */
5
+ import { type MaybeAccessor } from '../utils';
6
+ import { type ListState, type ListStateProps } from './createListState';
7
+ import type { Key } from './types';
8
+ export interface MenuStateProps<T = unknown> extends Omit<ListStateProps<T>, 'selectionMode' | 'disallowEmptySelection'> {
9
+ /** Handler called when an item is activated (pressed). */
10
+ onAction?: (key: Key) => void;
11
+ /** Handler called when the menu should close. */
12
+ onClose?: () => void;
13
+ }
14
+ export interface MenuState<T = unknown> extends ListState<T> {
15
+ /** Close the menu. */
16
+ close(): void;
17
+ }
18
+ /**
19
+ * Creates state for a menu component.
20
+ * Menus are single-select lists that support actions.
21
+ */
22
+ export declare function createMenuState<T = unknown>(props: MaybeAccessor<MenuStateProps<T>>): MenuState<T>;
23
+ export interface MenuTriggerStateProps {
24
+ /** Whether the menu is open (controlled). */
25
+ isOpen?: boolean;
26
+ /** Default open state (uncontrolled). */
27
+ defaultOpen?: boolean;
28
+ /** Handler called when the open state changes. */
29
+ onOpenChange?: (isOpen: boolean) => void;
30
+ }
31
+ export interface MenuTriggerState {
32
+ /** Whether the menu is open. */
33
+ readonly isOpen: () => boolean;
34
+ /** Open the menu. */
35
+ open(): void;
36
+ /** Close the menu. */
37
+ close(): void;
38
+ /** Toggle the menu. */
39
+ toggle(): void;
40
+ /** Focus strategy for when the menu opens. */
41
+ readonly focusStrategy: () => 'first' | 'last' | null;
42
+ /** Set the focus strategy. */
43
+ setFocusStrategy(strategy: 'first' | 'last' | null): void;
44
+ }
45
+ /**
46
+ * Creates state for a menu trigger (button that opens a menu).
47
+ * This is essentially the same as overlay trigger state but with focus strategy.
48
+ */
49
+ export { createOverlayTriggerState as createMenuTriggerState } from '../overlays';
@@ -0,0 +1,75 @@
1
+ /**
2
+ * Selection state management for collections.
3
+ * Based on @react-stately/selection.
4
+ */
5
+ import { type Accessor } from 'solid-js';
6
+ import { type MaybeAccessor } from '../utils';
7
+ import type { Collection, DisabledBehavior, Key, Selection, SelectionBehavior, SelectionMode } from './types';
8
+ export interface SelectionStateProps {
9
+ /** The selection mode. */
10
+ selectionMode?: SelectionMode;
11
+ /** How selection behaves on interaction. */
12
+ selectionBehavior?: SelectionBehavior;
13
+ /** Whether empty selection is disallowed. */
14
+ disallowEmptySelection?: boolean;
15
+ /** Currently selected keys (controlled). */
16
+ selectedKeys?: 'all' | Iterable<Key>;
17
+ /** Default selected keys (uncontrolled). */
18
+ defaultSelectedKeys?: 'all' | Iterable<Key>;
19
+ /** Handler for selection changes. */
20
+ onSelectionChange?: (keys: Selection) => void;
21
+ /** Keys of disabled items. */
22
+ disabledKeys?: Iterable<Key>;
23
+ /** How disabled keys behave. */
24
+ disabledBehavior?: DisabledBehavior;
25
+ /** Whether to allow duplicate selection events. */
26
+ allowDuplicateSelectionEvents?: boolean;
27
+ }
28
+ export interface SelectionState {
29
+ /** The selection mode. */
30
+ readonly selectionMode: Accessor<SelectionMode>;
31
+ /** The selection behavior. */
32
+ readonly selectionBehavior: Accessor<SelectionBehavior>;
33
+ /** Whether empty selection is disallowed. */
34
+ readonly disallowEmptySelection: Accessor<boolean>;
35
+ /** The currently selected keys. */
36
+ readonly selectedKeys: Accessor<Selection>;
37
+ /** Set of disabled keys. */
38
+ readonly disabledKeys: Accessor<Set<Key>>;
39
+ /** How disabled keys behave. */
40
+ readonly disabledBehavior: Accessor<DisabledBehavior>;
41
+ /** Whether the selection is empty. */
42
+ readonly isEmpty: Accessor<boolean>;
43
+ /** Whether all items are selected. */
44
+ readonly isSelectAll: Accessor<boolean>;
45
+ /** Check if a key is selected. */
46
+ isSelected(key: Key): boolean;
47
+ /** Check if a key is disabled. */
48
+ isDisabled(key: Key): boolean;
49
+ /** Set the selection behavior. */
50
+ setSelectionBehavior(behavior: SelectionBehavior): void;
51
+ /** Toggle selection for a key. */
52
+ toggleSelection(key: Key): void;
53
+ /** Replace selection with a single key. */
54
+ replaceSelection(key: Key): void;
55
+ /** Set multiple selected keys. */
56
+ setSelectedKeys(keys: Iterable<Key>): void;
57
+ /** Select all items. */
58
+ selectAll(): void;
59
+ /** Clear all selection. */
60
+ clearSelection(): void;
61
+ /** Toggle between select all and clear. */
62
+ toggleSelectAll(): void;
63
+ /** Extend selection to a key (for shift-click). */
64
+ extendSelection(toKey: Key, collection: Collection): void;
65
+ /** Select a key based on interaction. */
66
+ select(key: Key, e?: {
67
+ shiftKey?: boolean;
68
+ ctrlKey?: boolean;
69
+ metaKey?: boolean;
70
+ }, collection?: Collection): void;
71
+ }
72
+ /**
73
+ * Creates selection state for a collection.
74
+ */
75
+ export declare function createSelectionState(props?: MaybeAccessor<SelectionStateProps>): SelectionState;
@@ -0,0 +1,5 @@
1
+ export type { Key, SelectionMode, SelectionBehavior, Selection, FocusStrategy, DisabledBehavior, CollectionNode, Collection, ItemProps, SectionProps, CollectionBase, SingleSelection, MultipleSelection, } from './types';
2
+ export { ListCollection, createListCollection } from './ListCollection';
3
+ export { createSelectionState, type SelectionStateProps, type SelectionState, } from './createSelectionState';
4
+ export { createListState, createSingleSelectListState, type ListStateProps, type ListState, type SingleSelectListStateProps, type SingleSelectListState, } from './createListState';
5
+ export { createMenuState, createMenuTriggerState, type MenuStateProps, type MenuState, type MenuTriggerStateProps, type MenuTriggerState, } from './createMenuState';
@@ -0,0 +1,146 @@
1
+ /**
2
+ * Core types for collection state management.
3
+ * Simplified from @react-stately/collections for SolidJS.
4
+ */
5
+ import type { JSX } from 'solid-js';
6
+ /** A unique identifier for an item in a collection. */
7
+ export type Key = string | number;
8
+ /** The type of selection allowed in a collection. */
9
+ export type SelectionMode = 'none' | 'single' | 'multiple';
10
+ /** How selection behaves when clicking on items. */
11
+ export type SelectionBehavior = 'toggle' | 'replace';
12
+ /** Represents the current selection state. */
13
+ export type Selection = 'all' | Set<Key>;
14
+ /** Strategy for focusing first or last item. */
15
+ export type FocusStrategy = 'first' | 'last';
16
+ /** Whether disabled keys affect selection, actions, or both. */
17
+ export type DisabledBehavior = 'selection' | 'all';
18
+ /**
19
+ * Represents a node in a collection (item or section).
20
+ */
21
+ export interface CollectionNode<T = unknown> {
22
+ /** The type of node: 'item' or 'section'. */
23
+ type: 'item' | 'section';
24
+ /** A unique key for the node. */
25
+ key: Key;
26
+ /** The original value/data for this node. */
27
+ value: T | null;
28
+ /** The text content for accessibility and typeahead. */
29
+ textValue: string;
30
+ /** The rendered content (JSX). */
31
+ rendered: JSX.Element;
32
+ /** The level of nesting (0 for top-level). */
33
+ level: number;
34
+ /** The index within the parent. */
35
+ index: number;
36
+ /** The key of the parent node, if any. */
37
+ parentKey: Key | null;
38
+ /** Whether this node has child nodes. */
39
+ hasChildNodes: boolean;
40
+ /** Child nodes, if any. */
41
+ childNodes: CollectionNode<T>[];
42
+ /** Whether this item is disabled. */
43
+ isDisabled?: boolean;
44
+ /** ARIA label for this node. */
45
+ 'aria-label'?: string;
46
+ /** Additional props for the node. */
47
+ props?: Record<string, unknown>;
48
+ }
49
+ /**
50
+ * A collection of nodes with methods to traverse and query.
51
+ */
52
+ export interface Collection<T = unknown> extends Iterable<CollectionNode<T>> {
53
+ /** The number of items in the collection. */
54
+ readonly size: number;
55
+ /** Get all keys in the collection. */
56
+ getKeys(): Iterable<Key>;
57
+ /** Get a node by its key. */
58
+ getItem(key: Key): CollectionNode<T> | null;
59
+ /** Get a node by index. */
60
+ at(index: number): CollectionNode<T> | null;
61
+ /** Get the key before the given key. */
62
+ getKeyBefore(key: Key): Key | null;
63
+ /** Get the key after the given key. */
64
+ getKeyAfter(key: Key): Key | null;
65
+ /** Get the first key in the collection. */
66
+ getFirstKey(): Key | null;
67
+ /** Get the last key in the collection. */
68
+ getLastKey(): Key | null;
69
+ /** Get the children of a node. */
70
+ getChildren(key: Key): Iterable<CollectionNode<T>>;
71
+ /** Get the text value for a key. */
72
+ getTextValue(key: Key): string;
73
+ }
74
+ /**
75
+ * Props for items in a collection.
76
+ */
77
+ export interface ItemProps<T = unknown> {
78
+ /** Unique key for the item. Required if items is used for dynamic collections. */
79
+ key?: Key;
80
+ /** The text value for accessibility and typeahead. If not provided, derived from children. */
81
+ textValue?: string;
82
+ /** Whether the item is disabled. */
83
+ isDisabled?: boolean;
84
+ /** The rendered content of the item. */
85
+ children?: JSX.Element;
86
+ /** ARIA label for the item. */
87
+ 'aria-label'?: string;
88
+ /** The original value for dynamic collections. */
89
+ value?: T;
90
+ }
91
+ /**
92
+ * Props for sections in a collection.
93
+ */
94
+ export interface SectionProps<T = unknown> {
95
+ /** Unique key for the section. */
96
+ key?: Key;
97
+ /** The section header/title. */
98
+ title?: JSX.Element;
99
+ /** ARIA label for the section. */
100
+ 'aria-label'?: string;
101
+ /** The items in this section. */
102
+ children?: JSX.Element;
103
+ /** Items for dynamic rendering. */
104
+ items?: Iterable<T>;
105
+ }
106
+ /**
107
+ * Base props for components that use collections.
108
+ */
109
+ export interface CollectionBase<T = unknown> {
110
+ /** The items in the collection (for dynamic rendering). */
111
+ items?: Iterable<T>;
112
+ /** The children (static items or render function). */
113
+ children?: JSX.Element | ((item: T) => JSX.Element);
114
+ /** Keys of disabled items. */
115
+ disabledKeys?: Iterable<Key>;
116
+ }
117
+ /**
118
+ * Props for single selection.
119
+ */
120
+ export interface SingleSelection {
121
+ /** Whether empty selection is allowed. */
122
+ disallowEmptySelection?: boolean;
123
+ /** The currently selected key (controlled). */
124
+ selectedKey?: Key | null;
125
+ /** The default selected key (uncontrolled). */
126
+ defaultSelectedKey?: Key;
127
+ /** Handler called when selection changes. */
128
+ onSelectionChange?: (key: Key | null) => void;
129
+ }
130
+ /**
131
+ * Props for multiple selection.
132
+ */
133
+ export interface MultipleSelection {
134
+ /** The selection mode. */
135
+ selectionMode?: SelectionMode;
136
+ /** Whether empty selection is allowed. */
137
+ disallowEmptySelection?: boolean;
138
+ /** The currently selected keys (controlled). */
139
+ selectedKeys?: 'all' | Iterable<Key>;
140
+ /** The default selected keys (uncontrolled). */
141
+ defaultSelectedKeys?: 'all' | Iterable<Key>;
142
+ /** Handler called when selection changes. */
143
+ onSelectionChange?: (keys: Selection) => void;
144
+ /** Keys of disabled items. */
145
+ disabledKeys?: Iterable<Key>;
146
+ }
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Color class implementation.
3
+ * Based on @react-stately/color.
4
+ *
5
+ * Provides color manipulation, conversion, and formatting.
6
+ */
7
+ import type { Color } from './types';
8
+ /**
9
+ * Parse a color string into a Color object.
10
+ */
11
+ export declare function parseColor(value: string): Color;
12
+ /**
13
+ * Create an RGB color.
14
+ */
15
+ export declare function createRGBColor(red: number, green: number, blue: number, alpha?: number): Color;
16
+ /**
17
+ * Create an HSL color.
18
+ */
19
+ export declare function createHSLColor(hue: number, saturation: number, lightness: number, alpha?: number): Color;
20
+ /**
21
+ * Create an HSB color.
22
+ */
23
+ export declare function createHSBColor(hue: number, saturation: number, brightness: number, alpha?: number): Color;
24
+ /**
25
+ * Normalize a color value (string or Color) to a Color object.
26
+ */
27
+ export declare function normalizeColor(value: string | Color): Color;
@@ -0,0 +1,75 @@
1
+ /**
2
+ * ColorArea state management.
3
+ * Based on @react-stately/color useColorAreaState.
4
+ */
5
+ import { type Accessor } from 'solid-js';
6
+ import type { Color, ColorChannel } from './types';
7
+ export interface ColorAreaStateOptions {
8
+ /** The current color value (controlled). */
9
+ value?: Color | string;
10
+ /** The default color value (uncontrolled). */
11
+ defaultValue?: Color | string;
12
+ /** Handler called when the color changes. */
13
+ onChange?: (color: Color) => void;
14
+ /** Handler called when dragging ends. */
15
+ onChangeEnd?: (color: Color) => void;
16
+ /** The color channel for the X axis. */
17
+ xChannel?: ColorChannel;
18
+ /** The color channel for the Y axis. */
19
+ yChannel?: ColorChannel;
20
+ /** Whether the area is disabled. */
21
+ isDisabled?: boolean;
22
+ }
23
+ export interface ColorAreaState {
24
+ /** The current color value. */
25
+ readonly value: Color;
26
+ /** The X axis channel. */
27
+ readonly xChannel: ColorChannel;
28
+ /** The Y axis channel. */
29
+ readonly yChannel: ColorChannel;
30
+ /** The Z axis channel (the third channel). */
31
+ readonly zChannel: ColorChannel;
32
+ /** Whether the area is being dragged. */
33
+ readonly isDragging: boolean;
34
+ /** Whether the area is disabled. */
35
+ readonly isDisabled: boolean;
36
+ /** Step for X channel. */
37
+ readonly xChannelStep: number;
38
+ /** Step for Y channel. */
39
+ readonly yChannelStep: number;
40
+ /** Page step for X channel. */
41
+ readonly xChannelPageStep: number;
42
+ /** Page step for Y channel. */
43
+ readonly yChannelPageStep: number;
44
+ /** Get the X channel value. */
45
+ getXValue(): number;
46
+ /** Get the Y channel value. */
47
+ getYValue(): number;
48
+ /** Set the X channel value. */
49
+ setXValue(value: number): void;
50
+ /** Set the Y channel value. */
51
+ setYValue(value: number): void;
52
+ /** Set color from a point (0-1, 0-1). */
53
+ setColorFromPoint(x: number, y: number): void;
54
+ /** Get the thumb position as percentages. */
55
+ getThumbPosition(): {
56
+ x: number;
57
+ y: number;
58
+ };
59
+ /** Increment X value. */
60
+ incrementX(stepSize?: number): void;
61
+ /** Decrement X value. */
62
+ decrementX(stepSize?: number): void;
63
+ /** Increment Y value. */
64
+ incrementY(stepSize?: number): void;
65
+ /** Decrement Y value. */
66
+ decrementY(stepSize?: number): void;
67
+ /** Set the dragging state. */
68
+ setDragging(isDragging: boolean): void;
69
+ /** Get the display color (with alpha = 1). */
70
+ getDisplayColor(): Color;
71
+ }
72
+ /**
73
+ * Creates state for a color area (2D color picker).
74
+ */
75
+ export declare function createColorAreaState(options: Accessor<ColorAreaStateOptions>): ColorAreaState;
@@ -0,0 +1,54 @@
1
+ /**
2
+ * ColorField state management.
3
+ * Based on @react-stately/color useColorFieldState.
4
+ */
5
+ import { type Accessor } from 'solid-js';
6
+ import type { Color, ColorChannel, ColorFormat } from './types';
7
+ export interface ColorFieldStateOptions {
8
+ /** The current color value (controlled). */
9
+ value?: Color | string | null;
10
+ /** The default color value (uncontrolled). */
11
+ defaultValue?: Color | string;
12
+ /** Handler called when the color changes. */
13
+ onChange?: (color: Color | null) => void;
14
+ /** The color channel to edit (for single channel mode). */
15
+ channel?: ColorChannel;
16
+ /** The color format for parsing/displaying. */
17
+ colorFormat?: ColorFormat;
18
+ /** Whether the field is disabled. */
19
+ isDisabled?: boolean;
20
+ /** Whether the field is read-only. */
21
+ isReadOnly?: boolean;
22
+ }
23
+ export interface ColorFieldState {
24
+ /** The current color value (null if invalid). */
25
+ readonly value: Color | null;
26
+ /** The current input text. */
27
+ readonly inputValue: string;
28
+ /** Whether the input is invalid. */
29
+ readonly isInvalid: boolean;
30
+ /** Whether the field is disabled. */
31
+ readonly isDisabled: boolean;
32
+ /** Whether the field is read-only. */
33
+ readonly isReadOnly: boolean;
34
+ /** The color channel being edited (if single channel mode). */
35
+ readonly channel: ColorChannel | undefined;
36
+ /** Set the input text value. */
37
+ setInputValue(value: string): void;
38
+ /** Commit the current input value. */
39
+ commit(): void;
40
+ /** Increment the color channel value. */
41
+ increment(): void;
42
+ /** Decrement the color channel value. */
43
+ decrement(): void;
44
+ /** Increment by page size. */
45
+ incrementToMax(): void;
46
+ /** Decrement to minimum. */
47
+ decrementToMin(): void;
48
+ /** Validate the current input. */
49
+ validate(): boolean;
50
+ }
51
+ /**
52
+ * Creates state for a color field (text input for color values).
53
+ */
54
+ export declare function createColorFieldState(options: Accessor<ColorFieldStateOptions>): ColorFieldState;
@@ -0,0 +1,66 @@
1
+ /**
2
+ * ColorSlider state management.
3
+ * Based on @react-stately/color useColorSliderState.
4
+ */
5
+ import { type Accessor } from 'solid-js';
6
+ import type { Color, ColorChannel } from './types';
7
+ export interface ColorSliderStateOptions {
8
+ /** The current color value (controlled). */
9
+ value?: Color | string;
10
+ /** The default color value (uncontrolled). */
11
+ defaultValue?: Color | string;
12
+ /** Handler called when the color changes. */
13
+ onChange?: (color: Color) => void;
14
+ /** Handler called when dragging ends. */
15
+ onChangeEnd?: (color: Color) => void;
16
+ /** The color channel this slider controls. */
17
+ channel: ColorChannel;
18
+ /** Whether the slider is disabled. */
19
+ isDisabled?: boolean;
20
+ /** The locale for formatting. */
21
+ locale?: string;
22
+ }
23
+ export interface ColorSliderState {
24
+ /** The current color value. */
25
+ readonly value: Color;
26
+ /** Whether the slider is being dragged. */
27
+ readonly isDragging: boolean;
28
+ /** The color channel being controlled. */
29
+ readonly channel: ColorChannel;
30
+ /** The step value for the channel. */
31
+ readonly step: number;
32
+ /** The page step value for the channel. */
33
+ readonly pageSize: number;
34
+ /** The minimum value for the channel. */
35
+ readonly minValue: number;
36
+ /** The maximum value for the channel. */
37
+ readonly maxValue: number;
38
+ /** Whether the slider is disabled. */
39
+ readonly isDisabled: boolean;
40
+ /** Get the current channel value. */
41
+ getThumbValue(): number;
42
+ /** Get the minimum percent. */
43
+ getThumbMinValue(): number;
44
+ /** Get the maximum percent. */
45
+ getThumbMaxValue(): number;
46
+ /** Get the thumb value as a percentage. */
47
+ getThumbPercent(): number;
48
+ /** Set the channel value. */
49
+ setThumbValue(value: number): void;
50
+ /** Set the thumb value from a percentage (0-1). */
51
+ setThumbPercent(percent: number): void;
52
+ /** Increment the channel value. */
53
+ incrementThumb(stepSize?: number): void;
54
+ /** Decrement the channel value. */
55
+ decrementThumb(stepSize?: number): void;
56
+ /** Set the dragging state. */
57
+ setDragging(isDragging: boolean): void;
58
+ /** Get the display color (with alpha = 1). */
59
+ getDisplayColor(): Color;
60
+ /** Get the formatted value label. */
61
+ getThumbValueLabel(): string;
62
+ }
63
+ /**
64
+ * Creates state for a color slider.
65
+ */
66
+ export declare function createColorSliderState(options: Accessor<ColorSliderStateOptions>): ColorSliderState;
@@ -0,0 +1,50 @@
1
+ /**
2
+ * ColorWheel state management.
3
+ * Based on @react-stately/color useColorWheelState.
4
+ */
5
+ import { type Accessor } from 'solid-js';
6
+ import type { Color } from './types';
7
+ export interface ColorWheelStateOptions {
8
+ /** The current color value (controlled). */
9
+ value?: Color | string;
10
+ /** The default color value (uncontrolled). */
11
+ defaultValue?: Color | string;
12
+ /** Handler called when the color changes. */
13
+ onChange?: (color: Color) => void;
14
+ /** Handler called when dragging ends. */
15
+ onChangeEnd?: (color: Color) => void;
16
+ /** Whether the wheel is disabled. */
17
+ isDisabled?: boolean;
18
+ }
19
+ export interface ColorWheelState {
20
+ /** The current color value. */
21
+ readonly value: Color;
22
+ /** Whether the wheel is being dragged. */
23
+ readonly isDragging: boolean;
24
+ /** Whether the wheel is disabled. */
25
+ readonly isDisabled: boolean;
26
+ /** Step value for hue changes. */
27
+ readonly step: number;
28
+ /** Page step value for hue changes. */
29
+ readonly pageStep: number;
30
+ /** Get the current hue value (0-360). */
31
+ getHue(): number;
32
+ /** Set the hue value. */
33
+ setHue(value: number): void;
34
+ /** Set hue from an angle in radians. */
35
+ setHueFromAngle(angle: number): void;
36
+ /** Get the thumb angle in radians (0 = right, increases counterclockwise). */
37
+ getThumbAngle(): number;
38
+ /** Increment hue value. */
39
+ increment(stepSize?: number): void;
40
+ /** Decrement hue value. */
41
+ decrement(stepSize?: number): void;
42
+ /** Set the dragging state. */
43
+ setDragging(isDragging: boolean): void;
44
+ /** Get the display color (with full saturation/brightness for wheel). */
45
+ getDisplayColor(): Color;
46
+ }
47
+ /**
48
+ * Creates state for a color wheel (circular hue picker).
49
+ */
50
+ export declare function createColorWheelState(options: Accessor<ColorWheelStateOptions>): ColorWheelState;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Color state management exports.
3
+ */
4
+ export type { Color, ColorFormat, ColorSpace, ColorChannel, ColorChannelRange, ColorAxes, } from './types';
5
+ export { parseColor, normalizeColor, createRGBColor, createHSLColor, createHSBColor, } from './Color';
6
+ export { createColorSliderState, type ColorSliderStateOptions, type ColorSliderState, } from './createColorSliderState';
7
+ export { createColorAreaState, type ColorAreaStateOptions, type ColorAreaState, } from './createColorAreaState';
8
+ export { createColorWheelState, type ColorWheelStateOptions, type ColorWheelState, } from './createColorWheelState';
9
+ export { createColorFieldState, type ColorFieldStateOptions, type ColorFieldState, } from './createColorFieldState';