@proyecto-viviana/solid-stately 0.6.0-rc.1 → 0.6.0-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/form/createFormValidationState.d.ts.map +1 -1
- package/dist/index.js +32 -7
- package/dist/index.js.map +1 -1
- package/dist/textfield/createTextFieldState.d.ts.map +1 -1
- package/dist/toggle/createToggleGroupState.d.ts +0 -8
- package/dist/toggle/createToggleGroupState.d.ts.map +1 -1
- package/dist/toggle/createToggleState.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/form/createFormValidationState.ts +6 -2
- package/src/textfield/createTextFieldState.ts +6 -3
- package/src/toggle/createToggleGroupState.ts +4 -2
- package/src/toggle/createToggleState.ts +5 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createTextFieldState.d.ts","sourceRoot":"","sources":["../../src/textfield/createTextFieldState.ts"],"names":[],"mappings":"AAcA;;;;;;;GAOG;AAEH,OAAO,EAAE,QAAQ,
|
|
1
|
+
{"version":3,"file":"createTextFieldState.d.ts","sourceRoot":"","sources":["../../src/textfield/createTextFieldState.ts"],"names":[],"mappings":"AAcA;;;;;;;GAOG;AAEH,OAAO,EAAE,QAAQ,EAAW,MAAM,UAAU,CAAC;AAC7C,OAAO,EAAwB,KAAK,aAAa,EAAU,MAAM,UAAU,CAAC;AAE5E,MAAM,WAAW,qBAAqB;IACpC,sCAAsC;IACtC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,wCAAwC;IACxC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,qDAAqD;IACrD,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACpC;AAED,MAAM,WAAW,cAAc;IAC7B,2CAA2C;IAC3C,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;IACjC,wCAAwC;IACxC,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,KAAK,GAAE,aAAa,CAAC,qBAAqB,CAAM,GAC/C,cAAc,CAgChB"}
|
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Toggle group state for Solid Stately
|
|
3
|
-
*
|
|
4
|
-
* Provides state management for groups of toggle buttons with
|
|
5
|
-
* single or multiple selection.
|
|
6
|
-
*
|
|
7
|
-
* This is a port of @react-stately/toggle's useToggleGroupState.
|
|
8
|
-
*/
|
|
9
1
|
import type { Key } from "../collections";
|
|
10
2
|
import { type MaybeAccessor } from "../utils";
|
|
11
3
|
export interface ToggleGroupProps {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createToggleGroupState.d.ts","sourceRoot":"","sources":["../../src/toggle/createToggleGroupState.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"createToggleGroupState.d.ts","sourceRoot":"","sources":["../../src/toggle/createToggleGroupState.ts"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAyC,KAAK,aAAa,EAAE,MAAM,UAAU,CAAC;AAErF,MAAM,WAAW,gBAAgB;IAC/B;;;OAGG;IACH,aAAa,CAAC,EAAE,QAAQ,GAAG,UAAU,CAAC;IACtC,6CAA6C;IAC7C,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,gCAAgC;IAChC,YAAY,CAAC,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC;IAC7B,0CAA0C;IAC1C,mBAAmB,CAAC,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC;IACpC,wCAAwC;IACxC,iBAAiB,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,CAAC,GAAG,CAAC,KAAK,IAAI,CAAC;IAC7C,sCAAsC;IACtC,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,MAAM,WAAW,gBAAgB;IAC/B,uDAAuD;IACvD,QAAQ,CAAC,aAAa,EAAE,QAAQ,GAAG,UAAU,CAAC;IAC9C,sCAAsC;IACtC,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAC7B,6BAA6B;IAC7B,QAAQ,CAAC,YAAY,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC;IAChC,wCAAwC;IACxC,SAAS,CAAC,GAAG,EAAE,GAAG,GAAG,IAAI,CAAC;IAC1B,qCAAqC;IACrC,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE,UAAU,EAAE,OAAO,GAAG,IAAI,CAAC;IACjD,8BAA8B;IAC9B,eAAe,CAAC,IAAI,EAAE,GAAG,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;CACvC;AAMD;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,KAAK,GAAE,aAAa,CAAC,gBAAgB,CAAM,GAC1C,gBAAgB,CAgElB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createToggleState.d.ts","sourceRoot":"","sources":["../../src/toggle/createToggleState.ts"],"names":[],"mappings":"AAcA;;;;;;GAMG;AAEH,OAAO,EAAE,QAAQ,
|
|
1
|
+
{"version":3,"file":"createToggleState.d.ts","sourceRoot":"","sources":["../../src/toggle/createToggleState.ts"],"names":[],"mappings":"AAcA;;;;;;GAMG;AAEH,OAAO,EAAE,QAAQ,EAAW,MAAM,UAAU,CAAC;AAC7C,OAAO,EAAyC,KAAK,aAAa,EAAE,MAAM,UAAU,CAAC;AAErF,MAAM,WAAW,kBAAkB;IACjC,2DAA2D;IAC3D,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,wEAAwE;IACxE,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,yEAAyE;IACzE,QAAQ,CAAC,EAAE,CAAC,UAAU,EAAE,OAAO,KAAK,IAAI,CAAC;IACzC,wCAAwC;IACxC,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,MAAM,WAAW,WAAW;IAC1B,sCAAsC;IACtC,QAAQ,CAAC,UAAU,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC;IACvC,iDAAiD;IACjD,QAAQ,CAAC,eAAe,EAAE,OAAO,CAAC;IAClC,+BAA+B;IAC/B,WAAW,CAAC,UAAU,EAAE,OAAO,GAAG,IAAI,CAAC;IACvC,kCAAkC;IAClC,MAAM,IAAI,IAAI,CAAC;CAChB;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,GAAE,aAAa,CAAC,kBAAkB,CAAM,GAAG,WAAW,CA6C5F"}
|
package/package.json
CHANGED
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
* Port of react-stately's useFormValidationState.
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
|
-
import { createContext, createEffect, createMemo } from "solid-js";
|
|
24
|
+
import { createContext, createEffect, createMemo, untrack } from "solid-js";
|
|
25
25
|
import type { Accessor } from "solid-js";
|
|
26
26
|
import { createInternalSignal, useContextOptional } from "../utils";
|
|
27
27
|
|
|
@@ -324,7 +324,11 @@ export function createFormValidationState<T>(props: FormValidationProps<T>): For
|
|
|
324
324
|
displayValidation,
|
|
325
325
|
updateValidation(value: ValidationResult) {
|
|
326
326
|
// If validationBehavior is 'aria', update in realtime. Otherwise, store until commit.
|
|
327
|
-
|
|
327
|
+
// An imperative write: it reads the behavior and validity as they stand.
|
|
328
|
+
if (
|
|
329
|
+
untrack(validationBehavior) === "aria" &&
|
|
330
|
+
!isEqualValidation(untrack(currentValidity), value)
|
|
331
|
+
) {
|
|
328
332
|
setCurrentValidity(value);
|
|
329
333
|
} else {
|
|
330
334
|
nextValidation = value;
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
* as used by @react-aria/textfield.
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
|
-
import { Accessor } from "solid-js";
|
|
24
|
+
import { Accessor, untrack } from "solid-js";
|
|
25
25
|
import { createInternalSignal, type MaybeAccessor, access } from "../utils";
|
|
26
26
|
|
|
27
27
|
export interface TextFieldStateOptions {
|
|
@@ -49,8 +49,11 @@ export function createTextFieldState(
|
|
|
49
49
|
): TextFieldState {
|
|
50
50
|
const getProps = () => access(props);
|
|
51
51
|
|
|
52
|
-
|
|
53
|
-
const initialValue =
|
|
52
|
+
// Seeds the uncontrolled state once, by definition.
|
|
53
|
+
const initialValue = untrack(() => {
|
|
54
|
+
const initialProps = getProps();
|
|
55
|
+
return initialProps.value ?? initialProps.defaultValue ?? "";
|
|
56
|
+
});
|
|
54
57
|
|
|
55
58
|
const [internalValue, setInternalValue] = createInternalSignal(initialValue);
|
|
56
59
|
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
* This is a port of @react-stately/toggle's useToggleGroupState.
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
|
+
import { untrack } from "solid-js";
|
|
24
25
|
import type { Key } from "../collections";
|
|
25
26
|
import { access, createInternalSignal, readNow, type MaybeAccessor } from "../utils";
|
|
26
27
|
|
|
@@ -69,9 +70,10 @@ export function createToggleGroupState(
|
|
|
69
70
|
): ToggleGroupState {
|
|
70
71
|
const getProps = () => access(props);
|
|
71
72
|
|
|
72
|
-
|
|
73
|
+
// Seeds the uncontrolled state once, by definition.
|
|
74
|
+
const initialDefaultSelectedKeys = untrack(() => getProps().defaultSelectedKeys);
|
|
73
75
|
const [internalSelectedKeys, setInternalSelectedKeys] = createInternalSignal<Set<Key>>(
|
|
74
|
-
toKeySet(
|
|
76
|
+
toKeySet(initialDefaultSelectedKeys),
|
|
75
77
|
);
|
|
76
78
|
|
|
77
79
|
const isControlled = () => getProps().selectedKeys !== undefined;
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
* This is a 1:1 port of @react-stately/toggle's useToggleState.
|
|
21
21
|
*/
|
|
22
22
|
|
|
23
|
-
import { Accessor } from "solid-js";
|
|
23
|
+
import { Accessor, untrack } from "solid-js";
|
|
24
24
|
import { access, createInternalSignal, readNow, type MaybeAccessor } from "../utils";
|
|
25
25
|
|
|
26
26
|
export interface ToggleStateOptions {
|
|
@@ -51,8 +51,9 @@ export interface ToggleState {
|
|
|
51
51
|
export function createToggleState(props: MaybeAccessor<ToggleStateOptions> = {}): ToggleState {
|
|
52
52
|
const getProps = () => access(props);
|
|
53
53
|
|
|
54
|
-
|
|
55
|
-
const
|
|
54
|
+
// Seeds the uncontrolled state once, by definition.
|
|
55
|
+
const initialDefaultSelected = untrack(() => getProps().defaultSelected);
|
|
56
|
+
const initialSelected = untrack(() => getProps().isSelected) ?? initialDefaultSelected ?? false;
|
|
56
57
|
|
|
57
58
|
const [internalSelected, setInternalSelected] = createInternalSignal(initialSelected);
|
|
58
59
|
|
|
@@ -88,7 +89,7 @@ export function createToggleState(props: MaybeAccessor<ToggleStateOptions> = {})
|
|
|
88
89
|
|
|
89
90
|
return {
|
|
90
91
|
isSelected,
|
|
91
|
-
defaultSelected:
|
|
92
|
+
defaultSelected: initialDefaultSelected ?? initialSelected,
|
|
92
93
|
setSelected,
|
|
93
94
|
toggle,
|
|
94
95
|
};
|