@proyecto-viviana/solid-stately 0.2.2 → 0.2.4
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/index.js +43 -43
- package/dist/index.js.map +1 -1
- package/package.json +7 -5
- package/src/autocomplete/createAutocompleteState.d.ts +46 -0
- package/src/autocomplete/createAutocompleteState.d.ts.map +1 -0
- package/src/autocomplete/createAutocompleteState.ts +90 -0
- package/src/autocomplete/index.d.ts +2 -0
- package/src/autocomplete/index.d.ts.map +1 -0
- package/src/autocomplete/index.ts +5 -0
- package/src/calendar/createCalendarState.d.ts +130 -0
- package/src/calendar/createCalendarState.d.ts.map +1 -0
- package/src/calendar/createCalendarState.ts +461 -0
- package/src/calendar/createDateFieldState.d.ts +110 -0
- package/src/calendar/createDateFieldState.d.ts.map +1 -0
- package/src/calendar/createDateFieldState.ts +562 -0
- package/src/calendar/createRangeCalendarState.d.ts +146 -0
- package/src/calendar/createRangeCalendarState.d.ts.map +1 -0
- package/src/calendar/createRangeCalendarState.ts +535 -0
- package/src/calendar/createTimeFieldState.d.ts +95 -0
- package/src/calendar/createTimeFieldState.d.ts.map +1 -0
- package/src/calendar/createTimeFieldState.ts +483 -0
- package/src/calendar/index.d.ts +7 -0
- package/src/calendar/index.d.ts.map +1 -0
- package/src/calendar/index.ts +81 -0
- package/src/checkbox/createCheckboxGroupState.d.ts +71 -0
- package/src/checkbox/createCheckboxGroupState.d.ts.map +1 -0
- package/src/checkbox/createCheckboxGroupState.ts +193 -0
- package/src/checkbox/index.d.ts +2 -0
- package/src/checkbox/index.d.ts.map +1 -0
- package/src/checkbox/index.ts +5 -0
- package/src/collections/ListCollection.d.ts +37 -0
- package/src/collections/ListCollection.d.ts.map +1 -0
- package/src/collections/ListCollection.ts +146 -0
- package/src/collections/createListState.d.ts +79 -0
- package/src/collections/createListState.d.ts.map +1 -0
- package/src/collections/createListState.ts +264 -0
- package/src/collections/createMenuState.d.ts +50 -0
- package/src/collections/createMenuState.d.ts.map +1 -0
- package/src/collections/createMenuState.ts +106 -0
- package/src/collections/createSelectionState.d.ts +76 -0
- package/src/collections/createSelectionState.d.ts.map +1 -0
- package/src/collections/createSelectionState.ts +336 -0
- package/src/collections/index.d.ts +6 -0
- package/src/collections/index.d.ts.map +1 -0
- package/src/collections/index.ts +46 -0
- package/src/collections/types.d.ts +147 -0
- package/src/collections/types.d.ts.map +1 -0
- package/src/collections/types.ts +169 -0
- package/src/color/Color.d.ts +28 -0
- package/src/color/Color.d.ts.map +1 -0
- package/src/color/Color.ts +951 -0
- package/src/color/createColorAreaState.d.ts +76 -0
- package/src/color/createColorAreaState.d.ts.map +1 -0
- package/src/color/createColorAreaState.ts +293 -0
- package/src/color/createColorFieldState.d.ts +55 -0
- package/src/color/createColorFieldState.d.ts.map +1 -0
- package/src/color/createColorFieldState.ts +292 -0
- package/src/color/createColorSliderState.d.ts +67 -0
- package/src/color/createColorSliderState.d.ts.map +1 -0
- package/src/color/createColorSliderState.ts +241 -0
- package/src/color/createColorWheelState.d.ts +51 -0
- package/src/color/createColorWheelState.d.ts.map +1 -0
- package/src/color/createColorWheelState.ts +211 -0
- package/src/color/index.d.ts +10 -0
- package/src/color/index.d.ts.map +1 -0
- package/src/color/index.ts +47 -0
- package/src/color/types.d.ts +106 -0
- package/src/color/types.d.ts.map +1 -0
- package/src/color/types.ts +127 -0
- package/src/combobox/createComboBoxState.d.ts +125 -0
- package/src/combobox/createComboBoxState.d.ts.map +1 -0
- package/src/combobox/createComboBoxState.ts +703 -0
- package/src/combobox/index.d.ts +5 -0
- package/src/combobox/index.d.ts.map +1 -0
- package/src/combobox/index.ts +13 -0
- package/src/disclosure/createDisclosureState.d.ts +64 -0
- package/src/disclosure/createDisclosureState.d.ts.map +1 -0
- package/src/disclosure/createDisclosureState.ts +193 -0
- package/src/disclosure/index.d.ts +2 -0
- package/src/disclosure/index.d.ts.map +1 -0
- package/src/disclosure/index.ts +9 -0
- package/src/dnd/createDragState.d.ts +59 -0
- package/src/dnd/createDragState.d.ts.map +1 -0
- package/src/dnd/createDragState.ts +153 -0
- package/src/dnd/createDraggableCollectionState.d.ts +57 -0
- package/src/dnd/createDraggableCollectionState.d.ts.map +1 -0
- package/src/dnd/createDraggableCollectionState.ts +165 -0
- package/src/dnd/createDropState.d.ts +61 -0
- package/src/dnd/createDropState.d.ts.map +1 -0
- package/src/dnd/createDropState.ts +212 -0
- package/src/dnd/createDroppableCollectionState.d.ts +78 -0
- package/src/dnd/createDroppableCollectionState.d.ts.map +1 -0
- package/src/dnd/createDroppableCollectionState.ts +357 -0
- package/src/dnd/index.d.ts +11 -0
- package/src/dnd/index.d.ts.map +1 -0
- package/src/dnd/index.ts +76 -0
- package/src/dnd/types.d.ts +264 -0
- package/src/dnd/types.d.ts.map +1 -0
- package/src/dnd/types.ts +317 -0
- package/src/form/createFormValidationState.d.ts +100 -0
- package/src/form/createFormValidationState.d.ts.map +1 -0
- package/src/form/createFormValidationState.ts +389 -0
- package/src/form/index.d.ts +2 -0
- package/src/form/index.d.ts.map +1 -0
- package/src/form/index.ts +15 -0
- package/src/grid/createGridState.d.ts +12 -0
- package/src/grid/createGridState.d.ts.map +1 -0
- package/src/grid/createGridState.ts +327 -0
- package/src/grid/index.d.ts +7 -0
- package/src/grid/index.d.ts.map +1 -0
- package/src/grid/index.ts +13 -0
- package/src/grid/types.d.ts +156 -0
- package/src/grid/types.d.ts.map +1 -0
- package/src/grid/types.ts +179 -0
- package/src/index.d.ts +26 -0
- package/src/index.d.ts.map +1 -0
- package/src/index.ts +383 -0
- package/src/numberfield/createNumberFieldState.d.ts +65 -0
- package/src/numberfield/createNumberFieldState.d.ts.map +1 -0
- package/src/numberfield/createNumberFieldState.ts +383 -0
- package/src/numberfield/index.d.ts +2 -0
- package/src/numberfield/index.d.ts.map +1 -0
- package/src/numberfield/index.ts +5 -0
- package/src/overlays/createOverlayTriggerState.d.ts +32 -0
- package/src/overlays/createOverlayTriggerState.d.ts.map +1 -0
- package/src/overlays/createOverlayTriggerState.ts +67 -0
- package/src/overlays/index.d.ts +2 -0
- package/src/overlays/index.d.ts.map +1 -0
- package/src/overlays/index.ts +5 -0
- package/src/radio/createRadioGroupState.d.ts +77 -0
- package/src/radio/createRadioGroupState.d.ts.map +1 -0
- package/src/radio/createRadioGroupState.ts +201 -0
- package/src/radio/index.d.ts +2 -0
- package/src/radio/index.d.ts.map +1 -0
- package/src/radio/index.ts +6 -0
- package/src/searchfield/createSearchFieldState.d.ts +25 -0
- package/src/searchfield/createSearchFieldState.d.ts.map +1 -0
- package/src/searchfield/createSearchFieldState.ts +62 -0
- package/src/searchfield/index.d.ts +3 -0
- package/src/searchfield/index.d.ts.map +1 -0
- package/src/searchfield/index.ts +5 -0
- package/src/select/createSelectState.d.ts +73 -0
- package/src/select/createSelectState.d.ts.map +1 -0
- package/src/select/createSelectState.ts +181 -0
- package/src/select/index.d.ts +2 -0
- package/src/select/index.d.ts.map +1 -0
- package/src/select/index.ts +5 -0
- package/src/slider/createSliderState.d.ts +72 -0
- package/src/slider/createSliderState.d.ts.map +1 -0
- package/src/slider/createSliderState.ts +211 -0
- package/src/slider/index.d.ts +3 -0
- package/src/slider/index.d.ts.map +1 -0
- package/src/slider/index.ts +6 -0
- package/src/ssr/index.d.ts +28 -0
- package/src/ssr/index.d.ts.map +1 -0
- package/src/ssr/index.ts +41 -0
- package/src/table/TableCollection.d.ts +52 -0
- package/src/table/TableCollection.d.ts.map +1 -0
- package/src/table/TableCollection.ts +388 -0
- package/src/table/createTableState.d.ts +12 -0
- package/src/table/createTableState.d.ts.map +1 -0
- package/src/table/createTableState.ts +127 -0
- package/src/table/index.d.ts +8 -0
- package/src/table/index.d.ts.map +1 -0
- package/src/table/index.ts +18 -0
- package/src/table/types.d.ts +139 -0
- package/src/table/types.d.ts.map +1 -0
- package/src/table/types.ts +150 -0
- package/src/tabs/createTabListState.d.ts +68 -0
- package/src/tabs/createTabListState.d.ts.map +1 -0
- package/src/tabs/createTabListState.ts +240 -0
- package/src/tabs/index.d.ts +2 -0
- package/src/tabs/index.d.ts.map +1 -0
- package/src/tabs/index.ts +7 -0
- package/src/textfield/createTextFieldState.d.ts +30 -0
- package/src/textfield/createTextFieldState.d.ts.map +1 -0
- package/src/textfield/createTextFieldState.ts +75 -0
- package/src/textfield/index.d.ts +2 -0
- package/src/textfield/index.d.ts.map +1 -0
- package/src/textfield/index.ts +5 -0
- package/src/toast/createToastState.d.ts +118 -0
- package/src/toast/createToastState.d.ts.map +1 -0
- package/src/toast/createToastState.ts +316 -0
- package/src/toast/index.d.ts +2 -0
- package/src/toast/index.d.ts.map +1 -0
- package/src/toast/index.ts +11 -0
- package/src/toggle/createToggleState.d.ts +34 -0
- package/src/toggle/createToggleState.d.ts.map +1 -0
- package/src/toggle/createToggleState.ts +94 -0
- package/src/toggle/index.d.ts +2 -0
- package/src/toggle/index.d.ts.map +1 -0
- package/src/toggle/index.ts +5 -0
- package/src/tooltip/createTooltipTriggerState.d.ts +39 -0
- package/src/tooltip/createTooltipTriggerState.d.ts.map +1 -0
- package/src/tooltip/createTooltipTriggerState.ts +183 -0
- package/src/tooltip/index.d.ts +2 -0
- package/src/tooltip/index.d.ts.map +1 -0
- package/src/tooltip/index.ts +6 -0
- package/src/tree/TreeCollection.d.ts +40 -0
- package/src/tree/TreeCollection.d.ts.map +1 -0
- package/src/tree/TreeCollection.ts +175 -0
- package/src/tree/createTreeState.d.ts +14 -0
- package/src/tree/createTreeState.d.ts.map +1 -0
- package/src/tree/createTreeState.ts +392 -0
- package/src/tree/index.d.ts +7 -0
- package/src/tree/index.d.ts.map +1 -0
- package/src/tree/index.ts +13 -0
- package/src/tree/types.d.ts +157 -0
- package/src/tree/types.d.ts.map +1 -0
- package/src/tree/types.ts +174 -0
- package/src/utils/index.d.ts +2 -0
- package/src/utils/index.d.ts.map +1 -0
- package/src/utils/index.ts +1 -0
- package/src/utils/reactivity.d.ts +28 -0
- package/src/utils/reactivity.d.ts.map +1 -0
- package/src/utils/reactivity.ts +36 -0
- package/dist/index.jsx +0 -6408
- package/dist/index.jsx.map +0 -7
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates state for a slider component.
|
|
3
|
+
* Based on @react-stately/slider useSliderState.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { type Accessor, createSignal, createMemo } from 'solid-js';
|
|
7
|
+
import { access, type MaybeAccessor } from '../utils';
|
|
8
|
+
|
|
9
|
+
export type SliderOrientation = 'horizontal' | 'vertical';
|
|
10
|
+
|
|
11
|
+
export interface SliderStateProps {
|
|
12
|
+
/** The current value (controlled). */
|
|
13
|
+
value?: number;
|
|
14
|
+
/** The default value (uncontrolled). */
|
|
15
|
+
defaultValue?: number;
|
|
16
|
+
/** Handler called when the value changes. */
|
|
17
|
+
onChange?: (value: number) => void;
|
|
18
|
+
/** Handler called when the user stops dragging. */
|
|
19
|
+
onChangeEnd?: (value: number) => void;
|
|
20
|
+
/** The minimum value. */
|
|
21
|
+
minValue?: number;
|
|
22
|
+
/** The maximum value. */
|
|
23
|
+
maxValue?: number;
|
|
24
|
+
/** The step value. */
|
|
25
|
+
step?: number;
|
|
26
|
+
/** The orientation of the slider. */
|
|
27
|
+
orientation?: SliderOrientation;
|
|
28
|
+
/** Whether the slider is disabled. */
|
|
29
|
+
isDisabled?: boolean;
|
|
30
|
+
/** The locale for number formatting. */
|
|
31
|
+
locale?: string;
|
|
32
|
+
/** Number format options. */
|
|
33
|
+
formatOptions?: Intl.NumberFormatOptions;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface SliderState {
|
|
37
|
+
/** The current value. */
|
|
38
|
+
value: Accessor<number>;
|
|
39
|
+
/** Sets the value. */
|
|
40
|
+
setValue: (value: number) => void;
|
|
41
|
+
/** Sets the value by percent (0-1). */
|
|
42
|
+
setValuePercent: (percent: number) => void;
|
|
43
|
+
/** Gets the value as a percent (0-1). */
|
|
44
|
+
getValuePercent: Accessor<number>;
|
|
45
|
+
/** Gets the formatted value string. */
|
|
46
|
+
getFormattedValue: Accessor<string>;
|
|
47
|
+
/** Whether the thumb is being dragged. */
|
|
48
|
+
isDragging: Accessor<boolean>;
|
|
49
|
+
/** Sets the dragging state. */
|
|
50
|
+
setDragging: (dragging: boolean) => void;
|
|
51
|
+
/** Whether the slider is focused. */
|
|
52
|
+
isFocused: Accessor<boolean>;
|
|
53
|
+
/** Sets the focused state. */
|
|
54
|
+
setFocused: (focused: boolean) => void;
|
|
55
|
+
/** Increments the value by step. */
|
|
56
|
+
increment: (stepMultiplier?: number) => void;
|
|
57
|
+
/** Decrements the value by step. */
|
|
58
|
+
decrement: (stepMultiplier?: number) => void;
|
|
59
|
+
/** The minimum value. */
|
|
60
|
+
minValue: number;
|
|
61
|
+
/** The maximum value. */
|
|
62
|
+
maxValue: number;
|
|
63
|
+
/** The step value. */
|
|
64
|
+
step: number;
|
|
65
|
+
/** The page step (larger step for Page Up/Down). */
|
|
66
|
+
pageStep: number;
|
|
67
|
+
/** The orientation. */
|
|
68
|
+
orientation: SliderOrientation;
|
|
69
|
+
/** Whether the slider is disabled. */
|
|
70
|
+
isDisabled: boolean;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const DEFAULT_MIN = 0;
|
|
74
|
+
const DEFAULT_MAX = 100;
|
|
75
|
+
const DEFAULT_STEP = 1;
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Clamps a value between min and max.
|
|
79
|
+
*/
|
|
80
|
+
function clamp(value: number, min: number, max: number): number {
|
|
81
|
+
return Math.min(Math.max(value, min), max);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Snaps a value to the nearest step.
|
|
86
|
+
*/
|
|
87
|
+
function snapToStep(value: number, min: number, max: number, step: number): number {
|
|
88
|
+
const snapped = Math.round((value - min) / step) * step + min;
|
|
89
|
+
// Handle floating point precision issues
|
|
90
|
+
const decimalPlaces = (step.toString().split('.')[1] || '').length;
|
|
91
|
+
const rounded = parseFloat(snapped.toFixed(decimalPlaces));
|
|
92
|
+
return clamp(rounded, min, max);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Provides state management for a slider component.
|
|
97
|
+
*/
|
|
98
|
+
export function createSliderState(
|
|
99
|
+
props: MaybeAccessor<SliderStateProps>
|
|
100
|
+
): SliderState {
|
|
101
|
+
const getProps = () => access(props);
|
|
102
|
+
|
|
103
|
+
// Get static values with defaults
|
|
104
|
+
const minValue = getProps().minValue ?? DEFAULT_MIN;
|
|
105
|
+
const maxValue = getProps().maxValue ?? DEFAULT_MAX;
|
|
106
|
+
const step = getProps().step ?? DEFAULT_STEP;
|
|
107
|
+
const orientation = getProps().orientation ?? 'horizontal';
|
|
108
|
+
const isDisabled = getProps().isDisabled ?? false;
|
|
109
|
+
|
|
110
|
+
// Calculate page step (10% of range, snapped to step)
|
|
111
|
+
const pageStep = Math.max(step, snapToStep((maxValue - minValue) / 10, 0, maxValue - minValue, step));
|
|
112
|
+
|
|
113
|
+
// Controlled vs uncontrolled
|
|
114
|
+
const isControlled = () => getProps().value !== undefined;
|
|
115
|
+
|
|
116
|
+
// Internal signal for uncontrolled mode
|
|
117
|
+
const [internalValue, setInternalValue] = createSignal(
|
|
118
|
+
snapToStep(getProps().defaultValue ?? minValue, minValue, maxValue, step)
|
|
119
|
+
);
|
|
120
|
+
|
|
121
|
+
// Dragging and focus state
|
|
122
|
+
const [isDragging, setIsDragging] = createSignal(false);
|
|
123
|
+
const [isFocused, setIsFocused] = createSignal(false);
|
|
124
|
+
|
|
125
|
+
// Current value accessor
|
|
126
|
+
const value = createMemo(() => {
|
|
127
|
+
const p = getProps();
|
|
128
|
+
const rawValue = isControlled() ? (p.value ?? minValue) : internalValue();
|
|
129
|
+
return snapToStep(rawValue, minValue, maxValue, step);
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
// Value as percent (0-1)
|
|
133
|
+
const getValuePercent = createMemo(() => {
|
|
134
|
+
return (value() - minValue) / (maxValue - minValue);
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
// Formatted value
|
|
138
|
+
const getFormattedValue = createMemo(() => {
|
|
139
|
+
const p = getProps();
|
|
140
|
+
const formatter = new Intl.NumberFormat(p.locale, p.formatOptions);
|
|
141
|
+
return formatter.format(value());
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
// Set value function
|
|
145
|
+
const setValue = (newValue: number) => {
|
|
146
|
+
if (isDisabled) return;
|
|
147
|
+
|
|
148
|
+
const p = getProps();
|
|
149
|
+
const snappedValue = snapToStep(newValue, minValue, maxValue, step);
|
|
150
|
+
|
|
151
|
+
if (!isControlled()) {
|
|
152
|
+
setInternalValue(snappedValue);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
p.onChange?.(snappedValue);
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
// Set value by percent
|
|
159
|
+
const setValuePercent = (percent: number) => {
|
|
160
|
+
const clampedPercent = clamp(percent, 0, 1);
|
|
161
|
+
const newValue = clampedPercent * (maxValue - minValue) + minValue;
|
|
162
|
+
setValue(newValue);
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
// Dragging state management
|
|
166
|
+
const setDragging = (dragging: boolean) => {
|
|
167
|
+
const wasDragging = isDragging();
|
|
168
|
+
setIsDragging(dragging);
|
|
169
|
+
|
|
170
|
+
// Call onChangeEnd when dragging stops
|
|
171
|
+
if (wasDragging && !dragging) {
|
|
172
|
+
getProps().onChangeEnd?.(value());
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
// Increment/decrement
|
|
177
|
+
const increment = (stepMultiplier = 1) => {
|
|
178
|
+
if (isDisabled) return;
|
|
179
|
+
setValue(value() + step * stepMultiplier);
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
const decrement = (stepMultiplier = 1) => {
|
|
183
|
+
if (isDisabled) return;
|
|
184
|
+
setValue(value() - step * stepMultiplier);
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
// Set focused state
|
|
188
|
+
const setFocused = (focused: boolean) => {
|
|
189
|
+
setIsFocused(focused);
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
return {
|
|
193
|
+
value,
|
|
194
|
+
setValue,
|
|
195
|
+
setValuePercent,
|
|
196
|
+
getValuePercent,
|
|
197
|
+
getFormattedValue,
|
|
198
|
+
isDragging,
|
|
199
|
+
setDragging,
|
|
200
|
+
isFocused,
|
|
201
|
+
setFocused,
|
|
202
|
+
increment,
|
|
203
|
+
decrement,
|
|
204
|
+
minValue,
|
|
205
|
+
maxValue,
|
|
206
|
+
step,
|
|
207
|
+
pageStep,
|
|
208
|
+
orientation,
|
|
209
|
+
isDisabled,
|
|
210
|
+
};
|
|
211
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,YAAY,EACV,WAAW,EACX,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SSR utilities for Solid Stately
|
|
3
|
+
*
|
|
4
|
+
* SolidJS has built-in SSR support with `isServer` and `createUniqueId()`.
|
|
5
|
+
* These utilities provide a consistent API matching React-Stately's patterns.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Re-export isServer from solid-js/web for convenience.
|
|
9
|
+
*/
|
|
10
|
+
export declare const isServer: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Returns whether the component is currently being server side rendered.
|
|
13
|
+
* Can be used to delay browser-specific rendering until after hydration.
|
|
14
|
+
*/
|
|
15
|
+
export declare function createIsSSR(): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Generate a unique ID that is stable across server and client.
|
|
18
|
+
* Uses SolidJS's built-in createUniqueId which handles SSR correctly.
|
|
19
|
+
*
|
|
20
|
+
* @param defaultId - Optional default ID to use instead of generating one.
|
|
21
|
+
*/
|
|
22
|
+
export declare function createId(defaultId?: string): string;
|
|
23
|
+
/**
|
|
24
|
+
* Check if we can use DOM APIs.
|
|
25
|
+
* This is useful for code that needs to run only in the browser.
|
|
26
|
+
*/
|
|
27
|
+
export declare const canUseDOM: boolean;
|
|
28
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH;;GAEG;AACH,eAAO,MAAM,QAAQ,SAAY,CAAC;AAElC;;;GAGG;AACH,wBAAgB,WAAW,IAAI,OAAO,CAErC;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAKnD;AAED;;;GAGG;AACH,eAAO,MAAM,SAAS,SAAY,CAAC"}
|
package/src/ssr/index.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SSR utilities for Solid Stately
|
|
3
|
+
*
|
|
4
|
+
* SolidJS has built-in SSR support with `isServer` and `createUniqueId()`.
|
|
5
|
+
* These utilities provide a consistent API matching React-Stately's patterns.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { createUniqueId } from 'solid-js';
|
|
9
|
+
import { isServer as _isServer } from 'solid-js/web';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Re-export isServer from solid-js/web for convenience.
|
|
13
|
+
*/
|
|
14
|
+
export const isServer = _isServer;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Returns whether the component is currently being server side rendered.
|
|
18
|
+
* Can be used to delay browser-specific rendering until after hydration.
|
|
19
|
+
*/
|
|
20
|
+
export function createIsSSR(): boolean {
|
|
21
|
+
return isServer;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Generate a unique ID that is stable across server and client.
|
|
26
|
+
* Uses SolidJS's built-in createUniqueId which handles SSR correctly.
|
|
27
|
+
*
|
|
28
|
+
* @param defaultId - Optional default ID to use instead of generating one.
|
|
29
|
+
*/
|
|
30
|
+
export function createId(defaultId?: string): string {
|
|
31
|
+
if (defaultId) {
|
|
32
|
+
return defaultId;
|
|
33
|
+
}
|
|
34
|
+
return `solid-stately-${createUniqueId()}`;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Check if we can use DOM APIs.
|
|
39
|
+
* This is useful for code that needs to run only in the browser.
|
|
40
|
+
*/
|
|
41
|
+
export const canUseDOM = !isServer;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TableCollection - A collection class for table data.
|
|
3
|
+
* Based on @react-stately/table/TableCollection.
|
|
4
|
+
*/
|
|
5
|
+
import type { Key } from '../collections/types';
|
|
6
|
+
import type { GridNode } from '../grid/types';
|
|
7
|
+
import type { TableCollection as ITableCollection, TableCollectionOptions } from './types';
|
|
8
|
+
/**
|
|
9
|
+
* Creates a table collection from column and row definitions.
|
|
10
|
+
*/
|
|
11
|
+
export declare class TableCollection<T = unknown> implements ITableCollection<T> {
|
|
12
|
+
private _columns;
|
|
13
|
+
private _rows;
|
|
14
|
+
private _headerRows;
|
|
15
|
+
private _body;
|
|
16
|
+
private _head;
|
|
17
|
+
private _keyMap;
|
|
18
|
+
private _rowHeaderColumnKeys;
|
|
19
|
+
private _size;
|
|
20
|
+
constructor(options: TableCollectionOptions<T>);
|
|
21
|
+
private buildColumns;
|
|
22
|
+
private buildColumnNode;
|
|
23
|
+
private getDefaultRowHeaderColumnKeys;
|
|
24
|
+
private buildHeaderRows;
|
|
25
|
+
private buildRows;
|
|
26
|
+
private isRowDefinition;
|
|
27
|
+
get size(): number;
|
|
28
|
+
get rows(): GridNode<T>[];
|
|
29
|
+
get columns(): GridNode<T>[];
|
|
30
|
+
get headerRows(): GridNode<T>[];
|
|
31
|
+
get head(): GridNode<T> | undefined;
|
|
32
|
+
get body(): GridNode<T>;
|
|
33
|
+
get rowCount(): number;
|
|
34
|
+
get columnCount(): number;
|
|
35
|
+
get rowHeaderColumnKeys(): Set<Key>;
|
|
36
|
+
getKeys(): Iterable<Key>;
|
|
37
|
+
getItem(key: Key): GridNode<T> | null;
|
|
38
|
+
at(index: number): GridNode<T> | null;
|
|
39
|
+
getChildren(key: Key): Iterable<GridNode<T>>;
|
|
40
|
+
getTextValue(key: Key): string;
|
|
41
|
+
getCell(rowKey: Key, columnKey: Key): GridNode<T> | null;
|
|
42
|
+
getFirstKey(): Key | null;
|
|
43
|
+
getLastKey(): Key | null;
|
|
44
|
+
getKeyBefore(key: Key): Key | null;
|
|
45
|
+
getKeyAfter(key: Key): Key | null;
|
|
46
|
+
[Symbol.iterator](): Iterator<GridNode<T>>;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Creates a table collection from options.
|
|
50
|
+
*/
|
|
51
|
+
export declare function createTableCollection<T>(options: TableCollectionOptions<T>): TableCollection<T>;
|
|
52
|
+
//# sourceMappingURL=TableCollection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TableCollection.d.ts","sourceRoot":"","sources":["TableCollection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,KAAK,EAAE,QAAQ,EAAgB,MAAM,eAAe,CAAC;AAC5D,OAAO,KAAK,EACV,eAAe,IAAI,gBAAgB,EACnC,sBAAsB,EAGvB,MAAM,SAAS,CAAC;AAEjB;;GAEG;AACH,qBAAa,eAAe,CAAC,CAAC,GAAG,OAAO,CAAE,YAAW,gBAAgB,CAAC,CAAC,CAAC;IACtE,OAAO,CAAC,QAAQ,CAAqB;IACrC,OAAO,CAAC,KAAK,CAAqB;IAClC,OAAO,CAAC,WAAW,CAAqB;IACxC,OAAO,CAAC,KAAK,CAAc;IAC3B,OAAO,CAAC,KAAK,CAA0B;IACvC,OAAO,CAAC,OAAO,CAAoC;IACnD,OAAO,CAAC,oBAAoB,CAAW;IACvC,OAAO,CAAC,KAAK,CAAa;gBAEd,OAAO,EAAE,sBAAsB,CAAC,CAAC,CAAC;IAuD9C,OAAO,CAAC,YAAY;IAmCpB,OAAO,CAAC,eAAe;IA6BvB,OAAO,CAAC,6BAA6B;IAUrC,OAAO,CAAC,eAAe;IAqCvB,OAAO,CAAC,SAAS;IAgEjB,OAAO,CAAC,eAAe;IAUvB,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,IAAI,IAAI,IAAI,QAAQ,CAAC,CAAC,CAAC,EAAE,CAExB;IAED,IAAI,OAAO,IAAI,QAAQ,CAAC,CAAC,CAAC,EAAE,CAE3B;IAED,IAAI,UAAU,IAAI,QAAQ,CAAC,CAAC,CAAC,EAAE,CAE9B;IAED,IAAI,IAAI,IAAI,QAAQ,CAAC,CAAC,CAAC,GAAG,SAAS,CAElC;IAED,IAAI,IAAI,IAAI,QAAQ,CAAC,CAAC,CAAC,CAEtB;IAED,IAAI,QAAQ,IAAI,MAAM,CAErB;IAED,IAAI,WAAW,IAAI,MAAM,CAExB;IAED,IAAI,mBAAmB,IAAI,GAAG,CAAC,GAAG,CAAC,CAElC;IAED,OAAO,IAAI,QAAQ,CAAC,GAAG,CAAC;IAIxB,OAAO,CAAC,GAAG,EAAE,GAAG,GAAG,QAAQ,CAAC,CAAC,CAAC,GAAG,IAAI;IAIrC,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,QAAQ,CAAC,CAAC,CAAC,GAAG,IAAI;IAQrC,WAAW,CAAC,GAAG,EAAE,GAAG,GAAG,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IAK5C,YAAY,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM;IAK9B,OAAO,CAAC,MAAM,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,GAAG,QAAQ,CAAC,CAAC,CAAC,GAAG,IAAI;IAKxD,WAAW,IAAI,GAAG,GAAG,IAAI;IAMzB,UAAU,IAAI,GAAG,GAAG,IAAI;IAMxB,YAAY,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,GAAG,IAAI;IAalC,WAAW,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,GAAG,IAAI;IAahC,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;CAM5C;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,CAAC,EACrC,OAAO,EAAE,sBAAsB,CAAC,CAAC,CAAC,GACjC,eAAe,CAAC,CAAC,CAAC,CAEpB"}
|