@proyecto-viviana/solid-stately 0.0.1 → 0.0.3
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.d.ts +263 -6
- package/dist/index.js +18 -25
- package/dist/index.jsx +247 -0
- package/package.json +9 -6
- package/src/checkbox/createCheckboxGroupState.ts +193 -0
- package/src/checkbox/index.ts +5 -0
- package/src/index.ts +34 -0
- package/src/radio/createRadioGroupState.ts +201 -0
- package/src/radio/index.ts +6 -0
- package/{dist/ssr/index.d.ts → src/ssr/index.ts} +16 -3
- package/src/textfield/createTextFieldState.ts +75 -0
- package/src/textfield/index.ts +5 -0
- package/src/toggle/createToggleState.ts +94 -0
- package/src/toggle/index.ts +5 -0
- package/{dist/utils/reactivity.d.ts → src/utils/reactivity.ts} +11 -2
- package/dist/checkbox/createCheckboxGroupState.d.ts +0 -70
- package/dist/checkbox/index.d.ts +0 -1
- package/dist/index.js.map +0 -1
- package/dist/radio/createRadioGroupState.d.ts +0 -76
- package/dist/radio/index.d.ts +0 -1
- package/dist/textfield/createTextFieldState.d.ts +0 -29
- package/dist/textfield/index.d.ts +0 -1
- package/dist/toggle/createToggleState.d.ts +0 -33
- package/dist/toggle/index.d.ts +0 -1
- /package/{dist/utils/index.d.ts → src/utils/index.ts} +0 -0
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Checkbox group state for Solid Stately
|
|
3
|
-
*
|
|
4
|
-
* Provides state management for a checkbox group component.
|
|
5
|
-
* Provides a name for the group, and manages selection and focus state.
|
|
6
|
-
*
|
|
7
|
-
* This is a 1:1 port of @react-stately/checkbox's useCheckboxGroupState.
|
|
8
|
-
*/
|
|
9
|
-
import { Accessor } from 'solid-js';
|
|
10
|
-
import { type MaybeAccessor } from '../utils';
|
|
11
|
-
export interface CheckboxGroupProps {
|
|
12
|
-
/** The current selected values (controlled). */
|
|
13
|
-
value?: string[];
|
|
14
|
-
/** The default selected values (uncontrolled). */
|
|
15
|
-
defaultValue?: string[];
|
|
16
|
-
/** Handler that is called when the value changes. */
|
|
17
|
-
onChange?: (value: string[]) => void;
|
|
18
|
-
/** Whether the checkbox group is disabled. */
|
|
19
|
-
isDisabled?: boolean;
|
|
20
|
-
/** Whether the checkbox group is read only. */
|
|
21
|
-
isReadOnly?: boolean;
|
|
22
|
-
/** Whether the checkbox group is required. */
|
|
23
|
-
isRequired?: boolean;
|
|
24
|
-
/** Whether the checkbox group is invalid. */
|
|
25
|
-
isInvalid?: boolean;
|
|
26
|
-
/** The name of the checkbox group, used when submitting an HTML form. */
|
|
27
|
-
name?: string;
|
|
28
|
-
/** The form to associate the checkbox group with. */
|
|
29
|
-
form?: string;
|
|
30
|
-
/** The label for the checkbox group. */
|
|
31
|
-
label?: string;
|
|
32
|
-
/** Handler that is called when the checkbox group receives focus. */
|
|
33
|
-
onFocus?: (e: FocusEvent) => void;
|
|
34
|
-
/** Handler that is called when the checkbox group loses focus. */
|
|
35
|
-
onBlur?: (e: FocusEvent) => void;
|
|
36
|
-
/** Handler that is called when the checkbox group's focus status changes. */
|
|
37
|
-
onFocusChange?: (isFocused: boolean) => void;
|
|
38
|
-
}
|
|
39
|
-
export interface CheckboxGroupState {
|
|
40
|
-
/** Current selected values. */
|
|
41
|
-
readonly value: Accessor<readonly string[]>;
|
|
42
|
-
/** Default selected values. */
|
|
43
|
-
readonly defaultValue: readonly string[];
|
|
44
|
-
/** Whether the checkbox group is disabled. */
|
|
45
|
-
readonly isDisabled: boolean;
|
|
46
|
-
/** Whether the checkbox group is read only. */
|
|
47
|
-
readonly isReadOnly: boolean;
|
|
48
|
-
/** Whether the checkbox group is invalid. */
|
|
49
|
-
readonly isInvalid: boolean;
|
|
50
|
-
/**
|
|
51
|
-
* Whether the checkboxes in the group are required.
|
|
52
|
-
* This changes to false once at least one item is selected.
|
|
53
|
-
*/
|
|
54
|
-
readonly isRequired: Accessor<boolean>;
|
|
55
|
-
/** Returns whether the given value is selected. */
|
|
56
|
-
isSelected(value: string): boolean;
|
|
57
|
-
/** Sets the selected values. */
|
|
58
|
-
setValue(value: string[]): void;
|
|
59
|
-
/** Adds a value to the set of selected values. */
|
|
60
|
-
addValue(value: string): void;
|
|
61
|
-
/** Removes a value from the set of selected values. */
|
|
62
|
-
removeValue(value: string): void;
|
|
63
|
-
/** Toggles a value in the set of selected values. */
|
|
64
|
-
toggleValue(value: string): void;
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Provides state management for a checkbox group component.
|
|
68
|
-
* Provides a name for the group, and manages selection and focus state.
|
|
69
|
-
*/
|
|
70
|
-
export declare function createCheckboxGroupState(props?: MaybeAccessor<CheckboxGroupProps>): CheckboxGroupState;
|
package/dist/checkbox/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { createCheckboxGroupState, type CheckboxGroupProps, type CheckboxGroupState, } from './createCheckboxGroupState';
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/utils/reactivity.ts","../src/toggle/createToggleState.ts","../src/textfield/createTextFieldState.ts","../src/checkbox/createCheckboxGroupState.ts","../src/ssr/index.ts","../src/radio/createRadioGroupState.ts"],"sourcesContent":["/**\n * Reactivity utilities for Solid Stately\n *\n * Provides type-safe utilities for working with SolidJS reactivity patterns.\n */\n\nimport { Accessor } from 'solid-js';\n\n/**\n * A value that may be either a raw value or an accessor function.\n * This is a common pattern in SolidJS for props that may be reactive.\n */\nexport type MaybeAccessor<T> = T | Accessor<T>;\n\n/**\n * Unwraps a MaybeAccessor to get the underlying value.\n * If the input is a function, it calls it to get the value.\n * Otherwise, it returns the value directly.\n *\n * @param value - The value or accessor to unwrap.\n */\nexport function access<T>(value: MaybeAccessor<T>): T {\n return typeof value === 'function' ? (value as Accessor<T>)() : value;\n}\n\n/**\n * A value that may be undefined or an accessor that returns the value or undefined.\n */\nexport type MaybeAccessorValue<T> = T | undefined | Accessor<T | undefined>;\n\n/**\n * Checks if a value is an accessor function.\n */\nexport function isAccessor<T>(value: MaybeAccessor<T>): value is Accessor<T> {\n return typeof value === 'function';\n}\n","/**\n * Toggle state for Solid Stately\n *\n * Provides state management for toggle components like checkboxes and switches.\n *\n * This is a 1:1 port of @react-stately/toggle's useToggleState.\n */\n\nimport { createSignal, Accessor } from 'solid-js';\nimport { type MaybeAccessor, access } from '../utils';\n\n// ============================================\n// TYPES\n// ============================================\n\nexport interface ToggleStateOptions {\n /** Whether the element should be selected (controlled). */\n isSelected?: boolean;\n /** Whether the element should be selected by default (uncontrolled). */\n defaultSelected?: boolean;\n /** Handler that is called when the element's selection state changes. */\n onChange?: (isSelected: boolean) => void;\n /** Whether the element is read only. */\n isReadOnly?: boolean;\n}\n\nexport interface ToggleState {\n /** Whether the toggle is selected. */\n readonly isSelected: Accessor<boolean>;\n /** Whether the toggle is selected by default. */\n readonly defaultSelected: boolean;\n /** Updates selection state. */\n setSelected(isSelected: boolean): void;\n /** Toggle the selection state. */\n toggle(): void;\n}\n\n// ============================================\n// IMPLEMENTATION\n// ============================================\n\n/**\n * Provides state management for toggle components like checkboxes and switches.\n */\nexport function createToggleState(props: MaybeAccessor<ToggleStateOptions> = {}): ToggleState {\n const getProps = () => access(props);\n\n // Get initial values\n const initialProps = getProps();\n const initialSelected = initialProps.isSelected ?? initialProps.defaultSelected ?? false;\n\n // Create internal signal for uncontrolled mode\n const [internalSelected, setInternalSelected] = createSignal(initialSelected);\n\n // Determine if controlled\n const isControlled = () => getProps().isSelected !== undefined;\n\n // Get current selection state\n const isSelected: Accessor<boolean> = () => {\n const p = getProps();\n return isControlled() ? (p.isSelected ?? false) : internalSelected();\n };\n\n // Update selection state\n function setSelected(value: boolean): void {\n const p = getProps();\n if (p.isReadOnly) {\n return;\n }\n\n if (!isControlled()) {\n setInternalSelected(value);\n }\n\n p.onChange?.(value);\n }\n\n // Toggle selection state\n function toggle(): void {\n const p = getProps();\n if (p.isReadOnly) {\n return;\n }\n\n setSelected(!isSelected());\n }\n\n return {\n isSelected,\n defaultSelected: initialProps.defaultSelected ?? initialSelected,\n setSelected,\n toggle,\n };\n}\n","/**\n * TextField state for Solid Stately\n *\n * Provides state management for text input components.\n *\n * This is a port of @react-stately/utils's useControlledState pattern\n * as used by @react-aria/textfield.\n */\n\nimport { createSignal, Accessor } from 'solid-js';\nimport { type MaybeAccessor, access } from '../utils';\n\n// ============================================\n// TYPES\n// ============================================\n\nexport interface TextFieldStateOptions {\n /** The current value (controlled). */\n value?: string;\n /** The default value (uncontrolled). */\n defaultValue?: string;\n /** Handler that is called when the value changes. */\n onChange?: (value: string) => void;\n}\n\nexport interface TextFieldState {\n /** The current value of the text field. */\n readonly value: Accessor<string>;\n /** Sets the value of the text field. */\n setValue(value: string): void;\n}\n\n// ============================================\n// IMPLEMENTATION\n// ============================================\n\n/**\n * Provides state management for text input components.\n * Supports both controlled and uncontrolled modes.\n */\nexport function createTextFieldState(props: MaybeAccessor<TextFieldStateOptions> = {}): TextFieldState {\n const getProps = () => access(props);\n\n // Get initial value\n const initialProps = getProps();\n const initialValue = initialProps.value ?? initialProps.defaultValue ?? '';\n\n // Create internal signal for uncontrolled mode\n const [internalValue, setInternalValue] = createSignal(initialValue);\n\n // Determine if controlled\n const isControlled = () => getProps().value !== undefined;\n\n // Get current value\n const value: Accessor<string> = () => {\n const p = getProps();\n return isControlled() ? (p.value ?? '') : internalValue();\n };\n\n // Update value\n function setValue(newValue: string): void {\n const p = getProps();\n\n if (!isControlled()) {\n setInternalValue(newValue);\n }\n\n p.onChange?.(newValue);\n }\n\n return {\n value,\n setValue,\n };\n}\n","/**\n * Checkbox group state for Solid Stately\n *\n * Provides state management for a checkbox group component.\n * Provides a name for the group, and manages selection and focus state.\n *\n * This is a 1:1 port of @react-stately/checkbox's useCheckboxGroupState.\n */\n\nimport { createSignal, Accessor } from 'solid-js';\nimport { type MaybeAccessor, access } from '../utils';\n\n// ============================================\n// TYPES\n// ============================================\n\nexport interface CheckboxGroupProps {\n /** The current selected values (controlled). */\n value?: string[];\n /** The default selected values (uncontrolled). */\n defaultValue?: string[];\n /** Handler that is called when the value changes. */\n onChange?: (value: string[]) => void;\n /** Whether the checkbox group is disabled. */\n isDisabled?: boolean;\n /** Whether the checkbox group is read only. */\n isReadOnly?: boolean;\n /** Whether the checkbox group is required. */\n isRequired?: boolean;\n /** Whether the checkbox group is invalid. */\n isInvalid?: boolean;\n /** The name of the checkbox group, used when submitting an HTML form. */\n name?: string;\n /** The form to associate the checkbox group with. */\n form?: string;\n /** The label for the checkbox group. */\n label?: string;\n /** Handler that is called when the checkbox group receives focus. */\n onFocus?: (e: FocusEvent) => void;\n /** Handler that is called when the checkbox group loses focus. */\n onBlur?: (e: FocusEvent) => void;\n /** Handler that is called when the checkbox group's focus status changes. */\n onFocusChange?: (isFocused: boolean) => void;\n}\n\nexport interface CheckboxGroupState {\n /** Current selected values. */\n readonly value: Accessor<readonly string[]>;\n /** Default selected values. */\n readonly defaultValue: readonly string[];\n /** Whether the checkbox group is disabled. */\n readonly isDisabled: boolean;\n /** Whether the checkbox group is read only. */\n readonly isReadOnly: boolean;\n /** Whether the checkbox group is invalid. */\n readonly isInvalid: boolean;\n /**\n * Whether the checkboxes in the group are required.\n * This changes to false once at least one item is selected.\n */\n readonly isRequired: Accessor<boolean>;\n /** Returns whether the given value is selected. */\n isSelected(value: string): boolean;\n /** Sets the selected values. */\n setValue(value: string[]): void;\n /** Adds a value to the set of selected values. */\n addValue(value: string): void;\n /** Removes a value from the set of selected values. */\n removeValue(value: string): void;\n /** Toggles a value in the set of selected values. */\n toggleValue(value: string): void;\n}\n\n// ============================================\n// IMPLEMENTATION\n// ============================================\n\n/**\n * Provides state management for a checkbox group component.\n * Provides a name for the group, and manages selection and focus state.\n */\nexport function createCheckboxGroupState(\n props: MaybeAccessor<CheckboxGroupProps> = {}\n): CheckboxGroupState {\n const getProps = () => access(props);\n\n // Get initial values\n const initialProps = getProps();\n const initialValue = initialProps.value ?? initialProps.defaultValue ?? [];\n\n // Create internal signal for uncontrolled mode\n const [internalValue, setInternalValue] = createSignal<readonly string[]>(initialValue);\n\n // Determine if controlled\n const isControlled = () => getProps().value !== undefined;\n\n // Get current value\n const value: Accessor<readonly string[]> = () => {\n const p = getProps();\n return isControlled() ? (p.value ?? []) : internalValue();\n };\n\n // Check if required (true if isRequired and no items selected)\n const isRequired: Accessor<boolean> = () => {\n const p = getProps();\n return !!p.isRequired && value().length === 0;\n };\n\n // Check if invalid\n const isInvalid = () => {\n return getProps().isInvalid ?? false;\n };\n\n // Set value\n function setValue(newValue: string[]): void {\n const p = getProps();\n if (p.isReadOnly || p.isDisabled) {\n return;\n }\n\n if (!isControlled()) {\n setInternalValue(newValue);\n }\n\n p.onChange?.(newValue);\n }\n\n // Check if value is selected\n function isSelected(checkValue: string): boolean {\n return value().includes(checkValue);\n }\n\n // Add value\n function addValue(addVal: string): void {\n const p = getProps();\n if (p.isReadOnly || p.isDisabled) {\n return;\n }\n\n const current = value();\n if (!current.includes(addVal)) {\n setValue([...current, addVal]);\n }\n }\n\n // Remove value\n function removeValue(removeVal: string): void {\n const p = getProps();\n if (p.isReadOnly || p.isDisabled) {\n return;\n }\n\n const current = value();\n if (current.includes(removeVal)) {\n setValue(current.filter((v) => v !== removeVal));\n }\n }\n\n // Toggle value\n function toggleValue(toggleVal: string): void {\n const p = getProps();\n if (p.isReadOnly || p.isDisabled) {\n return;\n }\n\n const current = value();\n if (current.includes(toggleVal)) {\n setValue(current.filter((v) => v !== toggleVal));\n } else {\n setValue([...current, toggleVal]);\n }\n }\n\n return {\n value,\n defaultValue: initialProps.defaultValue ?? initialValue,\n get isDisabled() {\n return getProps().isDisabled ?? false;\n },\n get isReadOnly() {\n return getProps().isReadOnly ?? false;\n },\n get isInvalid() {\n return isInvalid();\n },\n isRequired,\n isSelected,\n setValue,\n addValue,\n removeValue,\n toggleValue,\n };\n}\n","/**\n * SSR utilities for Solid Stately\n *\n * SolidJS has built-in SSR support with `isServer` and `createUniqueId()`.\n * These utilities provide a consistent API matching React-Stately's patterns.\n */\n\nimport { createUniqueId } from 'solid-js';\nimport { isServer } from 'solid-js/web';\n\n/**\n * Returns whether the component is currently being server side rendered.\n * Can be used to delay browser-specific rendering until after hydration.\n */\nexport function createIsSSR(): boolean {\n return isServer;\n}\n\n/**\n * Generate a unique ID that is stable across server and client.\n * Uses SolidJS's built-in createUniqueId which handles SSR correctly.\n *\n * @param defaultId - Optional default ID to use instead of generating one.\n */\nexport function createId(defaultId?: string): string {\n if (defaultId) {\n return defaultId;\n }\n return `solid-stately-${createUniqueId()}`;\n}\n\n/**\n * Check if we can use DOM APIs.\n * This is useful for code that needs to run only in the browser.\n */\nexport const canUseDOM = !isServer;\n","/**\n * Radio group state for Solid Stately\n *\n * Provides state management for a radio group component.\n * Provides a name for the group, and manages selection and focus state.\n *\n * This is a 1:1 port of @react-stately/radio's useRadioGroupState.\n */\n\nimport { createSignal, Accessor, untrack } from 'solid-js';\nimport { type MaybeAccessor, access } from '../utils';\nimport { createId } from '../ssr';\n\n// ============================================\n// TYPES\n// ============================================\n\nexport interface RadioGroupProps {\n /** The current selected value (controlled). */\n value?: string | null;\n /** The default selected value (uncontrolled). */\n defaultValue?: string | null;\n /** Handler that is called when the value changes. */\n onChange?: (value: string) => void;\n /** Whether the radio group is disabled. */\n isDisabled?: boolean;\n /** Whether the radio group is read only. */\n isReadOnly?: boolean;\n /** Whether the radio group is required. */\n isRequired?: boolean;\n /** Whether the radio group is invalid. */\n isInvalid?: boolean;\n /** The name of the radio group, used when submitting an HTML form. */\n name?: string;\n /** The form to associate the radio group with. */\n form?: string;\n /** The label for the radio group. */\n label?: string;\n /** Orientation of the radio group. */\n orientation?: 'horizontal' | 'vertical';\n /** Handler that is called when the radio group receives focus. */\n onFocus?: (e: FocusEvent) => void;\n /** Handler that is called when the radio group loses focus. */\n onBlur?: (e: FocusEvent) => void;\n /** Handler that is called when the radio group's focus status changes. */\n onFocusChange?: (isFocused: boolean) => void;\n}\n\nexport interface RadioGroupState {\n /** The name for the group, used for native form submission. */\n readonly name: string;\n\n /** Whether the radio group is disabled. */\n readonly isDisabled: boolean;\n\n /** Whether the radio group is read only. */\n readonly isReadOnly: boolean;\n\n /** Whether the radio group is required. */\n readonly isRequired: boolean;\n\n /** Whether the radio group is invalid. */\n readonly isInvalid: boolean;\n\n /** The currently selected value. */\n readonly selectedValue: Accessor<string | null>;\n\n /** The default selected value. */\n readonly defaultSelectedValue: string | null;\n\n /** Sets the selected value. */\n setSelectedValue(value: string | null): void;\n\n /** The value of the last focused radio. */\n readonly lastFocusedValue: Accessor<string | null>;\n\n /** Sets the last focused value. */\n setLastFocusedValue(value: string | null): void;\n}\n\n// ============================================\n// INTERNAL: SolidJS-specific sync mechanism\n// ============================================\n\n/**\n * Internal WeakMap to store sync version accessors for each radio group state.\n * This is used by createRadio to trigger DOM sync when native radio behavior\n * causes the DOM checked state to desync from our reactive state.\n *\n * This is kept separate from RadioGroupState to maintain API parity with React-Stately.\n * @internal\n */\nexport const radioGroupSyncVersion: WeakMap<RadioGroupState, Accessor<number>> = new WeakMap();\n\n// ============================================\n// IMPLEMENTATION\n// ============================================\n\n/**\n * Provides state management for a radio group component.\n * Provides a name for the group, and manages selection and focus state.\n */\nexport function createRadioGroupState(\n props: MaybeAccessor<RadioGroupProps> = {}\n): RadioGroupState {\n const getProps = () => access(props);\n\n // Get initial props using untrack to avoid setting up dependencies\n // This ensures we capture the initial defaultValue without reactivity issues\n const initialProps = untrack(() => getProps());\n\n // Generate name - preserved for backward compatibility\n // React Aria now generates the name instead of stately\n const name = initialProps.name || `radio-group-${createId()}`;\n\n // Create internal signal for uncontrolled mode\n // Initialize with defaultValue only (not value, which is for controlled mode)\n const [internalValue, setInternalValue] = createSignal<string | null>(\n initialProps.defaultValue ?? null\n );\n const [lastFocusedValue, setLastFocusedValueInternal] = createSignal<string | null>(null);\n\n // SolidJS-specific: Version counter for triggering DOM sync across all radios\n // This handles the case where native radio behavior causes DOM state to desync\n // from our reactive state (e.g., clicking a radio unchecks siblings in the DOM)\n const [syncVersion, setSyncVersion] = createSignal(0);\n\n // Determine if controlled - must be reactive to handle dynamic props\n const isControlled = () => getProps().value !== undefined;\n\n // Get current value - reactive for both controlled and uncontrolled modes\n const selectedValue: Accessor<string | null> = () => {\n const p = getProps();\n // In controlled mode, always read from props.value reactively\n // In uncontrolled mode, read from internal signal\n if (p.value !== undefined) {\n return p.value ?? null;\n }\n return internalValue();\n };\n\n // Check if invalid\n const isInvalid = () => {\n return getProps().isInvalid ?? false;\n };\n\n // Set value\n function setSelectedValue(value: string | null): void {\n const p = getProps();\n if (p.isReadOnly || p.isDisabled) {\n return;\n }\n\n // Always increment syncVersion to trigger DOM sync across all radios\n // This is crucial for SolidJS because:\n // 1. Native radio behavior unchecks siblings when one is checked\n // 2. In controlled mode, isSelected() may not change even though DOM changed\n // 3. We need ALL radios to re-sync their checked state after any click\n setSyncVersion((v) => v + 1);\n\n if (!isControlled()) {\n setInternalValue(value);\n }\n\n if (value != null) {\n p.onChange?.(value);\n }\n }\n\n // Set last focused value\n function setLastFocusedValue(value: string | null): void {\n setLastFocusedValueInternal(value);\n }\n\n const state: RadioGroupState = {\n name,\n selectedValue,\n defaultSelectedValue: initialProps.defaultValue ?? null,\n setSelectedValue,\n lastFocusedValue,\n setLastFocusedValue,\n get isDisabled() {\n return getProps().isDisabled ?? false;\n },\n get isReadOnly() {\n return getProps().isReadOnly ?? false;\n },\n get isRequired() {\n return getProps().isRequired ?? false;\n },\n get isInvalid() {\n return isInvalid();\n },\n };\n\n // Store syncVersion in internal WeakMap (not part of public API)\n // This maintains API parity with React-Stately while supporting SolidJS's reactivity needs\n radioGroupSyncVersion.set(state, syncVersion);\n\n return state;\n}\n"],"names":[],"mappings":";;AAqBO,SAAS,OAAU,OAA4B;AACpD,SAAO,OAAO,UAAU,aAAc,MAAA,IAA0B;AAClE;AAUO,SAAS,WAAc,OAA+C;AAC3E,SAAO,OAAO,UAAU;AAC1B;ACSO,SAAS,kBAAkB,QAA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a,cAAc,IAAI,aAAa,CAAC;AAGpD,QAAM,eAAe,MAAM,SAAA,EAAW,UAAU;AAGhD,QAAM,gBAAyC,MAAM;AACnD,UAAM,IAAI,SAAA;AAGV,QAAI,EAAE,UAAU,QAAW;AACzB,aAAO,EAAE,SAAS;AAAA,IACpB;AACA,WAAO,cAAA;AAAA,EACT;AAGA,QAAM,YAAY,MAAM;AACtB,WAAO,SAAA,EAAW,aAAa;AAAA,EACjC;AAGA,WAAS,iBAAiB,OAA4B;;AACpD,UAAM,IAAI,SAAA;AACV,QAAI,EAAE,cAAc,EAAE,YAAY;AAChC;AAAA,IACF;AAOA,mBAAe,CAAC,MAAM,IAAI,CAAC;AAE3B,QAAI,CAAC,gBAAgB;AACnB,uBAAiB,KAAK;AAAA,IACxB;AAEA,QAAI,SAAS,MAAM;AACjB,cAAE,aAAF,2BAAa;AAAA,IACf;AAAA,EACF;AAGA,WAAS,oBAAoB,OAA4B;AACvD,gCAA4B,KAAK;AAAA,EACnC;AAEA,QAAM,QAAyB;AAAA,IAC7B;AAAA,IACA;AAAA,IACA,sBAAsB,aAAa,gBAAgB;AAAA,IACnD;AAAA,IACA;AAAA,IACA;AAAA,IACA,IAAI,aAAa;AACf,aAAO,SAAA,EAAW,cAAc;AAAA,IAClC;AAAA,IACA,IAAI,aAAa;AACf,aAAO,SAAA,EAAW,cAAc;AAAA,IAClC;AAAA,IACA,IAAI,aAAa;AACf,aAAO,SAAA,EAAW,cAAc;AAAA,IAClC;AAAA,IACA,IAAI,YAAY;AACd,aAAO,UAAA;AAAA,IACT;AAAA,EAAA;AAKF,wBAAsB,IAAI,OAAO,WAAW;AAE5C,SAAO;AACT;"}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Radio group state for Solid Stately
|
|
3
|
-
*
|
|
4
|
-
* Provides state management for a radio group component.
|
|
5
|
-
* Provides a name for the group, and manages selection and focus state.
|
|
6
|
-
*
|
|
7
|
-
* This is a 1:1 port of @react-stately/radio's useRadioGroupState.
|
|
8
|
-
*/
|
|
9
|
-
import { Accessor } from 'solid-js';
|
|
10
|
-
import { type MaybeAccessor } from '../utils';
|
|
11
|
-
export interface RadioGroupProps {
|
|
12
|
-
/** The current selected value (controlled). */
|
|
13
|
-
value?: string | null;
|
|
14
|
-
/** The default selected value (uncontrolled). */
|
|
15
|
-
defaultValue?: string | null;
|
|
16
|
-
/** Handler that is called when the value changes. */
|
|
17
|
-
onChange?: (value: string) => void;
|
|
18
|
-
/** Whether the radio group is disabled. */
|
|
19
|
-
isDisabled?: boolean;
|
|
20
|
-
/** Whether the radio group is read only. */
|
|
21
|
-
isReadOnly?: boolean;
|
|
22
|
-
/** Whether the radio group is required. */
|
|
23
|
-
isRequired?: boolean;
|
|
24
|
-
/** Whether the radio group is invalid. */
|
|
25
|
-
isInvalid?: boolean;
|
|
26
|
-
/** The name of the radio group, used when submitting an HTML form. */
|
|
27
|
-
name?: string;
|
|
28
|
-
/** The form to associate the radio group with. */
|
|
29
|
-
form?: string;
|
|
30
|
-
/** The label for the radio group. */
|
|
31
|
-
label?: string;
|
|
32
|
-
/** Orientation of the radio group. */
|
|
33
|
-
orientation?: 'horizontal' | 'vertical';
|
|
34
|
-
/** Handler that is called when the radio group receives focus. */
|
|
35
|
-
onFocus?: (e: FocusEvent) => void;
|
|
36
|
-
/** Handler that is called when the radio group loses focus. */
|
|
37
|
-
onBlur?: (e: FocusEvent) => void;
|
|
38
|
-
/** Handler that is called when the radio group's focus status changes. */
|
|
39
|
-
onFocusChange?: (isFocused: boolean) => void;
|
|
40
|
-
}
|
|
41
|
-
export interface RadioGroupState {
|
|
42
|
-
/** The name for the group, used for native form submission. */
|
|
43
|
-
readonly name: string;
|
|
44
|
-
/** Whether the radio group is disabled. */
|
|
45
|
-
readonly isDisabled: boolean;
|
|
46
|
-
/** Whether the radio group is read only. */
|
|
47
|
-
readonly isReadOnly: boolean;
|
|
48
|
-
/** Whether the radio group is required. */
|
|
49
|
-
readonly isRequired: boolean;
|
|
50
|
-
/** Whether the radio group is invalid. */
|
|
51
|
-
readonly isInvalid: boolean;
|
|
52
|
-
/** The currently selected value. */
|
|
53
|
-
readonly selectedValue: Accessor<string | null>;
|
|
54
|
-
/** The default selected value. */
|
|
55
|
-
readonly defaultSelectedValue: string | null;
|
|
56
|
-
/** Sets the selected value. */
|
|
57
|
-
setSelectedValue(value: string | null): void;
|
|
58
|
-
/** The value of the last focused radio. */
|
|
59
|
-
readonly lastFocusedValue: Accessor<string | null>;
|
|
60
|
-
/** Sets the last focused value. */
|
|
61
|
-
setLastFocusedValue(value: string | null): void;
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Internal WeakMap to store sync version accessors for each radio group state.
|
|
65
|
-
* This is used by createRadio to trigger DOM sync when native radio behavior
|
|
66
|
-
* causes the DOM checked state to desync from our reactive state.
|
|
67
|
-
*
|
|
68
|
-
* This is kept separate from RadioGroupState to maintain API parity with React-Stately.
|
|
69
|
-
* @internal
|
|
70
|
-
*/
|
|
71
|
-
export declare const radioGroupSyncVersion: WeakMap<RadioGroupState, Accessor<number>>;
|
|
72
|
-
/**
|
|
73
|
-
* Provides state management for a radio group component.
|
|
74
|
-
* Provides a name for the group, and manages selection and focus state.
|
|
75
|
-
*/
|
|
76
|
-
export declare function createRadioGroupState(props?: MaybeAccessor<RadioGroupProps>): RadioGroupState;
|
package/dist/radio/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { createRadioGroupState, radioGroupSyncVersion, type RadioGroupProps, type RadioGroupState, } from './createRadioGroupState';
|
|
@@ -1,29 +0,0 @@
|
|
|
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;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { createTextFieldState, type TextFieldStateOptions, type TextFieldState, } from './createTextFieldState';
|
|
@@ -1,33 +0,0 @@
|
|
|
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;
|
package/dist/toggle/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { createToggleState, type ToggleStateOptions, type ToggleState, } from './createToggleState';
|
|
File without changes
|