@react-stately/checkbox 3.6.4-nightly.4555 → 3.6.4-nightly.4558

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/import.mjs CHANGED
@@ -1,18 +1,6 @@
1
- import {useFormValidationState as $b3nuO$useFormValidationState, mergeValidation as $b3nuO$mergeValidation} from "@react-stately/form";
2
- import {useControlledState as $b3nuO$useControlledState} from "@react-stately/utils";
3
- import {useRef as $b3nuO$useRef} from "react";
1
+ import {useCheckboxGroupState as $587d3ad58be6d31f$export$daff6da51032a415} from "./useCheckboxGroupState.mjs";
4
2
 
5
3
  /*
6
- * Copyright 2020 Adobe. All rights reserved.
7
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
8
- * you may not use this file except in compliance with the License. You may obtain a copy
9
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software distributed under
12
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
13
- * OF ANY KIND, either express or implied. See the License for the specific language
14
- * governing permissions and limitations under the License.
15
- */ /*
16
4
  * Copyright 2020 Adobe. All rights reserved.
17
5
  * This file is licensed to you under the Apache License, Version 2.0 (the "License");
18
6
  * you may not use this file except in compliance with the License. You may obtain a copy
@@ -25,57 +13,5 @@ import {useRef as $b3nuO$useRef} from "react";
25
13
  */
26
14
 
27
15
 
28
- function $587d3ad58be6d31f$export$daff6da51032a415(props = {}) {
29
- let [selectedValues, setValue] = (0, $b3nuO$useControlledState)(props.value, props.defaultValue || [], props.onChange);
30
- let isRequired = !!props.isRequired && selectedValues.length === 0;
31
- let invalidValues = (0, $b3nuO$useRef)(new Map());
32
- let validation = (0, $b3nuO$useFormValidationState)({
33
- ...props,
34
- value: selectedValues
35
- });
36
- let isInvalid = validation.displayValidation.isInvalid;
37
- var _props_validationState;
38
- const state = {
39
- ...validation,
40
- value: selectedValues,
41
- setValue (value) {
42
- if (props.isReadOnly || props.isDisabled) return;
43
- setValue(value);
44
- },
45
- isDisabled: props.isDisabled || false,
46
- isReadOnly: props.isReadOnly || false,
47
- isSelected (value) {
48
- return selectedValues.includes(value);
49
- },
50
- addValue (value) {
51
- if (props.isReadOnly || props.isDisabled) return;
52
- if (!selectedValues.includes(value)) setValue(selectedValues.concat(value));
53
- },
54
- removeValue (value) {
55
- if (props.isReadOnly || props.isDisabled) return;
56
- if (selectedValues.includes(value)) setValue(selectedValues.filter((existingValue)=>existingValue !== value));
57
- },
58
- toggleValue (value) {
59
- if (props.isReadOnly || props.isDisabled) return;
60
- if (selectedValues.includes(value)) setValue(selectedValues.filter((existingValue)=>existingValue !== value));
61
- else setValue(selectedValues.concat(value));
62
- },
63
- setInvalid (value, v) {
64
- let s = new Map(invalidValues.current);
65
- if (v.isInvalid) s.set(value, v);
66
- else s.delete(value);
67
- invalidValues.current = s;
68
- validation.updateValidation((0, $b3nuO$mergeValidation)(...s.values()));
69
- },
70
- validationState: (_props_validationState = props.validationState) !== null && _props_validationState !== void 0 ? _props_validationState : isInvalid ? "invalid" : null,
71
- isInvalid: isInvalid,
72
- isRequired: isRequired
73
- };
74
- return state;
75
- }
76
-
77
-
78
-
79
-
80
16
  export {$587d3ad58be6d31f$export$daff6da51032a415 as useCheckboxGroupState};
81
17
  //# sourceMappingURL=module.js.map
package/dist/main.js CHANGED
@@ -1,24 +1,12 @@
1
- var $jVLCf$reactstatelyform = require("@react-stately/form");
2
- var $jVLCf$reactstatelyutils = require("@react-stately/utils");
3
- var $jVLCf$react = require("react");
1
+ var $943f4c622056df75$exports = require("./useCheckboxGroupState.main.js");
4
2
 
5
3
 
6
4
  function $parcel$export(e, n, v, s) {
7
5
  Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
8
6
  }
9
7
 
10
- $parcel$export(module.exports, "useCheckboxGroupState", () => $943f4c622056df75$export$daff6da51032a415);
8
+ $parcel$export(module.exports, "useCheckboxGroupState", () => $943f4c622056df75$exports.useCheckboxGroupState);
11
9
  /*
12
- * Copyright 2020 Adobe. All rights reserved.
13
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
14
- * you may not use this file except in compliance with the License. You may obtain a copy
15
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
16
- *
17
- * Unless required by applicable law or agreed to in writing, software distributed under
18
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
19
- * OF ANY KIND, either express or implied. See the License for the specific language
20
- * governing permissions and limitations under the License.
21
- */ /*
22
10
  * Copyright 2020 Adobe. All rights reserved.
23
11
  * This file is licensed to you under the Apache License, Version 2.0 (the "License");
24
12
  * you may not use this file except in compliance with the License. You may obtain a copy
@@ -31,56 +19,4 @@ $parcel$export(module.exports, "useCheckboxGroupState", () => $943f4c622056df75$
31
19
  */
32
20
 
33
21
 
34
- function $943f4c622056df75$export$daff6da51032a415(props = {}) {
35
- let [selectedValues, setValue] = (0, $jVLCf$reactstatelyutils.useControlledState)(props.value, props.defaultValue || [], props.onChange);
36
- let isRequired = !!props.isRequired && selectedValues.length === 0;
37
- let invalidValues = (0, $jVLCf$react.useRef)(new Map());
38
- let validation = (0, $jVLCf$reactstatelyform.useFormValidationState)({
39
- ...props,
40
- value: selectedValues
41
- });
42
- let isInvalid = validation.displayValidation.isInvalid;
43
- var _props_validationState;
44
- const state = {
45
- ...validation,
46
- value: selectedValues,
47
- setValue (value) {
48
- if (props.isReadOnly || props.isDisabled) return;
49
- setValue(value);
50
- },
51
- isDisabled: props.isDisabled || false,
52
- isReadOnly: props.isReadOnly || false,
53
- isSelected (value) {
54
- return selectedValues.includes(value);
55
- },
56
- addValue (value) {
57
- if (props.isReadOnly || props.isDisabled) return;
58
- if (!selectedValues.includes(value)) setValue(selectedValues.concat(value));
59
- },
60
- removeValue (value) {
61
- if (props.isReadOnly || props.isDisabled) return;
62
- if (selectedValues.includes(value)) setValue(selectedValues.filter((existingValue)=>existingValue !== value));
63
- },
64
- toggleValue (value) {
65
- if (props.isReadOnly || props.isDisabled) return;
66
- if (selectedValues.includes(value)) setValue(selectedValues.filter((existingValue)=>existingValue !== value));
67
- else setValue(selectedValues.concat(value));
68
- },
69
- setInvalid (value, v) {
70
- let s = new Map(invalidValues.current);
71
- if (v.isInvalid) s.set(value, v);
72
- else s.delete(value);
73
- invalidValues.current = s;
74
- validation.updateValidation((0, $jVLCf$reactstatelyform.mergeValidation)(...s.values()));
75
- },
76
- validationState: (_props_validationState = props.validationState) !== null && _props_validationState !== void 0 ? _props_validationState : isInvalid ? "invalid" : null,
77
- isInvalid: isInvalid,
78
- isRequired: isRequired
79
- };
80
- return state;
81
- }
82
-
83
-
84
-
85
-
86
22
  //# sourceMappingURL=main.js.map
package/dist/main.js.map CHANGED
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;AAAA;;;;;;;;;;ACAA;;;;;;;;;;CAUC;;;AAwDM,SAAS,0CAAsB,QAA4B,CAAC,CAAC;IAClE,IAAI,CAAC,gBAAgB,SAAS,GAAG,CAAA,GAAA,2CAAiB,EAAE,MAAM,KAAK,EAAE,MAAM,YAAY,IAAI,EAAE,EAAE,MAAM,QAAQ;IACzG,IAAI,aAAa,CAAC,CAAC,MAAM,UAAU,IAAI,eAAe,MAAM,KAAK;IAEjE,IAAI,gBAAgB,CAAA,GAAA,mBAAK,EAAE,IAAI;IAC/B,IAAI,aAAa,CAAA,GAAA,8CAAqB,EAAE;QACtC,GAAG,KAAK;QACR,OAAO;IACT;IAEA,IAAI,YAAY,WAAW,iBAAiB,CAAC,SAAS;QAqDnC;IApDnB,MAAM,QAA4B;QAChC,GAAG,UAAU;QACb,OAAO;QACP,UAAS,KAAK;YACZ,IAAI,MAAM,UAAU,IAAI,MAAM,UAAU,EACtC;YAGF,SAAS;QACX;QACA,YAAY,MAAM,UAAU,IAAI;QAChC,YAAY,MAAM,UAAU,IAAI;QAChC,YAAW,KAAK;YACd,OAAO,eAAe,QAAQ,CAAC;QACjC;QACA,UAAS,KAAK;YACZ,IAAI,MAAM,UAAU,IAAI,MAAM,UAAU,EACtC;YAEF,IAAI,CAAC,eAAe,QAAQ,CAAC,QAC3B,SAAS,eAAe,MAAM,CAAC;QAEnC;QACA,aAAY,KAAK;YACf,IAAI,MAAM,UAAU,IAAI,MAAM,UAAU,EACtC;YAEF,IAAI,eAAe,QAAQ,CAAC,QAC1B,SAAS,eAAe,MAAM,CAAC,CAAA,gBAAiB,kBAAkB;QAEtE;QACA,aAAY,KAAK;YACf,IAAI,MAAM,UAAU,IAAI,MAAM,UAAU,EACtC;YAEF,IAAI,eAAe,QAAQ,CAAC,QAC1B,SAAS,eAAe,MAAM,CAAC,CAAA,gBAAiB,kBAAkB;iBAElE,SAAS,eAAe,MAAM,CAAC;QAEnC;QACA,YAAW,KAAK,EAAE,CAAC;YACjB,IAAI,IAAI,IAAI,IAAI,cAAc,OAAO;YACrC,IAAI,EAAE,SAAS,EACb,EAAE,GAAG,CAAC,OAAO;iBAEb,EAAE,MAAM,CAAC;YAGX,cAAc,OAAO,GAAG;YACxB,WAAW,gBAAgB,CAAC,CAAA,GAAA,uCAAc,KAAK,EAAE,MAAM;QACzD;QACA,iBAAiB,CAAA,yBAAA,MAAM,eAAe,cAArB,oCAAA,yBAA0B,YAAY,YAAY;mBACnE;oBACA;IACF;IAEA,OAAO;AACT;;CD7HC","sources":["packages/@react-stately/checkbox/src/index.ts","packages/@react-stately/checkbox/src/useCheckboxGroupState.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport {useCheckboxGroupState} from './useCheckboxGroupState';\n\nexport type {CheckboxGroupProps} from '@react-types/checkbox';\nexport type {CheckboxGroupState} from './useCheckboxGroupState';\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {CheckboxGroupProps} from '@react-types/checkbox';\nimport {FormValidationState, mergeValidation, useFormValidationState} from '@react-stately/form';\nimport {useControlledState} from '@react-stately/utils';\nimport {useRef} from 'react';\nimport {ValidationResult, ValidationState} from '@react-types/shared';\n\nexport interface CheckboxGroupState extends FormValidationState {\n /** Current selected values. */\n readonly value: readonly string[],\n\n /** Whether the checkbox group is disabled. */\n readonly isDisabled: boolean,\n\n /** Whether the checkbox group is read only. */\n readonly isReadOnly: boolean,\n\n /**\n * The current validation state of the checkbox group.\n * @deprecated Use `isInvalid` instead.\n */\n readonly validationState: ValidationState | null,\n\n /** Whether the checkbox group is invalid. */\n readonly isInvalid: boolean,\n\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: boolean,\n\n /** Returns whether the given value is selected. */\n isSelected(value: string): boolean,\n\n /** Sets the selected values. */\n setValue(value: string[]): void,\n\n /** Adds a value to the set of selected values. */\n addValue(value: string): void,\n\n /** Removes a value from the set of selected values. */\n removeValue(value: string): void,\n\n /** Toggles a value in the set of selected values. */\n toggleValue(value: string): void,\n\n /** Sets whether one of the checkboxes is invalid. */\n setInvalid(value: string, validation: ValidationResult): void\n}\n\n/**\n * Provides state management for a checkbox group component. Provides a name for the group,\n * and manages selection and focus state.\n */\nexport function useCheckboxGroupState(props: CheckboxGroupProps = {}): CheckboxGroupState {\n let [selectedValues, setValue] = useControlledState(props.value, props.defaultValue || [], props.onChange);\n let isRequired = !!props.isRequired && selectedValues.length === 0;\n\n let invalidValues = useRef(new Map<string, ValidationResult>());\n let validation = useFormValidationState({\n ...props,\n value: selectedValues\n });\n\n let isInvalid = validation.displayValidation.isInvalid;\n const state: CheckboxGroupState = {\n ...validation,\n value: selectedValues,\n setValue(value) {\n if (props.isReadOnly || props.isDisabled) {\n return;\n }\n\n setValue(value);\n },\n isDisabled: props.isDisabled || false,\n isReadOnly: props.isReadOnly || false,\n isSelected(value) {\n return selectedValues.includes(value);\n },\n addValue(value) {\n if (props.isReadOnly || props.isDisabled) {\n return;\n }\n if (!selectedValues.includes(value)) {\n setValue(selectedValues.concat(value));\n }\n },\n removeValue(value) {\n if (props.isReadOnly || props.isDisabled) {\n return;\n }\n if (selectedValues.includes(value)) {\n setValue(selectedValues.filter(existingValue => existingValue !== value));\n }\n },\n toggleValue(value) {\n if (props.isReadOnly || props.isDisabled) {\n return;\n }\n if (selectedValues.includes(value)) {\n setValue(selectedValues.filter(existingValue => existingValue !== value));\n } else {\n setValue(selectedValues.concat(value));\n }\n },\n setInvalid(value, v) {\n let s = new Map(invalidValues.current);\n if (v.isInvalid) {\n s.set(value, v);\n } else {\n s.delete(value);\n }\n\n invalidValues.current = s;\n validation.updateValidation(mergeValidation(...s.values()));\n },\n validationState: props.validationState ?? (isInvalid ? 'invalid' : null),\n isInvalid,\n isRequired\n };\n\n return state;\n}\n"],"names":[],"version":3,"file":"main.js.map"}
1
+ {"mappings":";;;;;;;;AAAA;;;;;;;;;;CAUC","sources":["packages/@react-stately/checkbox/src/index.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport {useCheckboxGroupState} from './useCheckboxGroupState';\n\nexport type {CheckboxGroupProps} from '@react-types/checkbox';\nexport type {CheckboxGroupState} from './useCheckboxGroupState';\n"],"names":[],"version":3,"file":"main.js.map"}
package/dist/module.js CHANGED
@@ -1,18 +1,6 @@
1
- import {useFormValidationState as $b3nuO$useFormValidationState, mergeValidation as $b3nuO$mergeValidation} from "@react-stately/form";
2
- import {useControlledState as $b3nuO$useControlledState} from "@react-stately/utils";
3
- import {useRef as $b3nuO$useRef} from "react";
1
+ import {useCheckboxGroupState as $587d3ad58be6d31f$export$daff6da51032a415} from "./useCheckboxGroupState.module.js";
4
2
 
5
3
  /*
6
- * Copyright 2020 Adobe. All rights reserved.
7
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
8
- * you may not use this file except in compliance with the License. You may obtain a copy
9
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software distributed under
12
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
13
- * OF ANY KIND, either express or implied. See the License for the specific language
14
- * governing permissions and limitations under the License.
15
- */ /*
16
4
  * Copyright 2020 Adobe. All rights reserved.
17
5
  * This file is licensed to you under the Apache License, Version 2.0 (the "License");
18
6
  * you may not use this file except in compliance with the License. You may obtain a copy
@@ -25,57 +13,5 @@ import {useRef as $b3nuO$useRef} from "react";
25
13
  */
26
14
 
27
15
 
28
- function $587d3ad58be6d31f$export$daff6da51032a415(props = {}) {
29
- let [selectedValues, setValue] = (0, $b3nuO$useControlledState)(props.value, props.defaultValue || [], props.onChange);
30
- let isRequired = !!props.isRequired && selectedValues.length === 0;
31
- let invalidValues = (0, $b3nuO$useRef)(new Map());
32
- let validation = (0, $b3nuO$useFormValidationState)({
33
- ...props,
34
- value: selectedValues
35
- });
36
- let isInvalid = validation.displayValidation.isInvalid;
37
- var _props_validationState;
38
- const state = {
39
- ...validation,
40
- value: selectedValues,
41
- setValue (value) {
42
- if (props.isReadOnly || props.isDisabled) return;
43
- setValue(value);
44
- },
45
- isDisabled: props.isDisabled || false,
46
- isReadOnly: props.isReadOnly || false,
47
- isSelected (value) {
48
- return selectedValues.includes(value);
49
- },
50
- addValue (value) {
51
- if (props.isReadOnly || props.isDisabled) return;
52
- if (!selectedValues.includes(value)) setValue(selectedValues.concat(value));
53
- },
54
- removeValue (value) {
55
- if (props.isReadOnly || props.isDisabled) return;
56
- if (selectedValues.includes(value)) setValue(selectedValues.filter((existingValue)=>existingValue !== value));
57
- },
58
- toggleValue (value) {
59
- if (props.isReadOnly || props.isDisabled) return;
60
- if (selectedValues.includes(value)) setValue(selectedValues.filter((existingValue)=>existingValue !== value));
61
- else setValue(selectedValues.concat(value));
62
- },
63
- setInvalid (value, v) {
64
- let s = new Map(invalidValues.current);
65
- if (v.isInvalid) s.set(value, v);
66
- else s.delete(value);
67
- invalidValues.current = s;
68
- validation.updateValidation((0, $b3nuO$mergeValidation)(...s.values()));
69
- },
70
- validationState: (_props_validationState = props.validationState) !== null && _props_validationState !== void 0 ? _props_validationState : isInvalid ? "invalid" : null,
71
- isInvalid: isInvalid,
72
- isRequired: isRequired
73
- };
74
- return state;
75
- }
76
-
77
-
78
-
79
-
80
16
  export {$587d3ad58be6d31f$export$daff6da51032a415 as useCheckboxGroupState};
81
17
  //# sourceMappingURL=module.js.map
@@ -1 +1 @@
1
- {"mappings":";;;;AAAA;;;;;;;;;;ACAA;;;;;;;;;;CAUC;;;AAwDM,SAAS,0CAAsB,QAA4B,CAAC,CAAC;IAClE,IAAI,CAAC,gBAAgB,SAAS,GAAG,CAAA,GAAA,yBAAiB,EAAE,MAAM,KAAK,EAAE,MAAM,YAAY,IAAI,EAAE,EAAE,MAAM,QAAQ;IACzG,IAAI,aAAa,CAAC,CAAC,MAAM,UAAU,IAAI,eAAe,MAAM,KAAK;IAEjE,IAAI,gBAAgB,CAAA,GAAA,aAAK,EAAE,IAA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react-stately/checkbox/src/index.ts","packages/@react-stately/checkbox/src/useCheckboxGroupState.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport {useCheckboxGroupState} from './useCheckboxGroupState';\n\nexport type {CheckboxGroupProps} from '@react-types/checkbox';\nexport type {CheckboxGroupState} from './useCheckboxGroupState';\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {CheckboxGroupProps} from '@react-types/checkbox';\nimport {FormValidationState, mergeValidation, useFormValidationState} from '@react-stately/form';\nimport {useControlledState} from '@react-stately/utils';\nimport {useRef} from 'react';\nimport {ValidationResult, ValidationState} from '@react-types/shared';\n\nexport interface CheckboxGroupState extends FormValidationState {\n /** Current selected values. */\n readonly value: readonly string[],\n\n /** Whether the checkbox group is disabled. */\n readonly isDisabled: boolean,\n\n /** Whether the checkbox group is read only. */\n readonly isReadOnly: boolean,\n\n /**\n * The current validation state of the checkbox group.\n * @deprecated Use `isInvalid` instead.\n */\n readonly validationState: ValidationState | null,\n\n /** Whether the checkbox group is invalid. */\n readonly isInvalid: boolean,\n\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: boolean,\n\n /** Returns whether the given value is selected. */\n isSelected(value: string): boolean,\n\n /** Sets the selected values. */\n setValue(value: string[]): void,\n\n /** Adds a value to the set of selected values. */\n addValue(value: string): void,\n\n /** Removes a value from the set of selected values. */\n removeValue(value: string): void,\n\n /** Toggles a value in the set of selected values. */\n toggleValue(value: string): void,\n\n /** Sets whether one of the checkboxes is invalid. */\n setInvalid(value: string, validation: ValidationResult): void\n}\n\n/**\n * Provides state management for a checkbox group component. Provides a name for the group,\n * and manages selection and focus state.\n */\nexport function useCheckboxGroupState(props: CheckboxGroupProps = {}): CheckboxGroupState {\n let [selectedValues, setValue] = useControlledState(props.value, props.defaultValue || [], props.onChange);\n let isRequired = !!props.isRequired && selectedValues.length === 0;\n\n let invalidValues = useRef(new Map<string, ValidationResult>());\n let validation = useFormValidationState({\n ...props,\n value: selectedValues\n });\n\n let isInvalid = validation.displayValidation.isInvalid;\n const state: CheckboxGroupState = {\n ...validation,\n value: selectedValues,\n setValue(value) {\n if (props.isReadOnly || props.isDisabled) {\n return;\n }\n\n setValue(value);\n },\n isDisabled: props.isDisabled || false,\n isReadOnly: props.isReadOnly || false,\n isSelected(value) {\n return selectedValues.includes(value);\n },\n addValue(value) {\n if (props.isReadOnly || props.isDisabled) {\n return;\n }\n if (!selectedValues.includes(value)) {\n setValue(selectedValues.concat(value));\n }\n },\n removeValue(value) {\n if (props.isReadOnly || props.isDisabled) {\n return;\n }\n if (selectedValues.includes(value)) {\n setValue(selectedValues.filter(existingValue => existingValue !== value));\n }\n },\n toggleValue(value) {\n if (props.isReadOnly || props.isDisabled) {\n return;\n }\n if (selectedValues.includes(value)) {\n setValue(selectedValues.filter(existingValue => existingValue !== value));\n } else {\n setValue(selectedValues.concat(value));\n }\n },\n setInvalid(value, v) {\n let s = new Map(invalidValues.current);\n if (v.isInvalid) {\n s.set(value, v);\n } else {\n s.delete(value);\n }\n\n invalidValues.current = s;\n validation.updateValidation(mergeValidation(...s.values()));\n },\n validationState: props.validationState ?? (isInvalid ? 'invalid' : null),\n isInvalid,\n isRequired\n };\n\n return state;\n}\n"],"names":[],"version":3,"file":"module.js.map"}
1
+ {"mappings":";;AAAA;;;;;;;;;;CAUC","sources":["packages/@react-stately/checkbox/src/index.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport {useCheckboxGroupState} from './useCheckboxGroupState';\n\nexport type {CheckboxGroupProps} from '@react-types/checkbox';\nexport type {CheckboxGroupState} from './useCheckboxGroupState';\n"],"names":[],"version":3,"file":"module.js.map"}
@@ -0,0 +1,74 @@
1
+ var $6SsBH$reactstatelyform = require("@react-stately/form");
2
+ var $6SsBH$reactstatelyutils = require("@react-stately/utils");
3
+ var $6SsBH$react = require("react");
4
+
5
+
6
+ function $parcel$export(e, n, v, s) {
7
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
8
+ }
9
+
10
+ $parcel$export(module.exports, "useCheckboxGroupState", () => $943f4c622056df75$export$daff6da51032a415);
11
+ /*
12
+ * Copyright 2020 Adobe. All rights reserved.
13
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
14
+ * you may not use this file except in compliance with the License. You may obtain a copy
15
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
16
+ *
17
+ * Unless required by applicable law or agreed to in writing, software distributed under
18
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
19
+ * OF ANY KIND, either express or implied. See the License for the specific language
20
+ * governing permissions and limitations under the License.
21
+ */
22
+
23
+
24
+ function $943f4c622056df75$export$daff6da51032a415(props = {}) {
25
+ let [selectedValues, setValue] = (0, $6SsBH$reactstatelyutils.useControlledState)(props.value, props.defaultValue || [], props.onChange);
26
+ let isRequired = !!props.isRequired && selectedValues.length === 0;
27
+ let invalidValues = (0, $6SsBH$react.useRef)(new Map());
28
+ let validation = (0, $6SsBH$reactstatelyform.useFormValidationState)({
29
+ ...props,
30
+ value: selectedValues
31
+ });
32
+ let isInvalid = validation.displayValidation.isInvalid;
33
+ var _props_validationState;
34
+ const state = {
35
+ ...validation,
36
+ value: selectedValues,
37
+ setValue (value) {
38
+ if (props.isReadOnly || props.isDisabled) return;
39
+ setValue(value);
40
+ },
41
+ isDisabled: props.isDisabled || false,
42
+ isReadOnly: props.isReadOnly || false,
43
+ isSelected (value) {
44
+ return selectedValues.includes(value);
45
+ },
46
+ addValue (value) {
47
+ if (props.isReadOnly || props.isDisabled) return;
48
+ if (!selectedValues.includes(value)) setValue(selectedValues.concat(value));
49
+ },
50
+ removeValue (value) {
51
+ if (props.isReadOnly || props.isDisabled) return;
52
+ if (selectedValues.includes(value)) setValue(selectedValues.filter((existingValue)=>existingValue !== value));
53
+ },
54
+ toggleValue (value) {
55
+ if (props.isReadOnly || props.isDisabled) return;
56
+ if (selectedValues.includes(value)) setValue(selectedValues.filter((existingValue)=>existingValue !== value));
57
+ else setValue(selectedValues.concat(value));
58
+ },
59
+ setInvalid (value, v) {
60
+ let s = new Map(invalidValues.current);
61
+ if (v.isInvalid) s.set(value, v);
62
+ else s.delete(value);
63
+ invalidValues.current = s;
64
+ validation.updateValidation((0, $6SsBH$reactstatelyform.mergeValidation)(...s.values()));
65
+ },
66
+ validationState: (_props_validationState = props.validationState) !== null && _props_validationState !== void 0 ? _props_validationState : isInvalid ? "invalid" : null,
67
+ isInvalid: isInvalid,
68
+ isRequired: isRequired
69
+ };
70
+ return state;
71
+ }
72
+
73
+
74
+ //# sourceMappingURL=useCheckboxGroupState.main.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;;;;AAAA;;;;;;;;;;C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IAAI,EAAE,SAAS,EACb,EAAE,GAAG,CAAC,OAAO;iBAEb,EAAE,MAAM,CAAC;YAGX,cAAc,OAAO,GAAG;YACxB,WAAW,gBAAgB,CAAC,CAAA,GAAA,uCAAc,KAAK,EAAE,MAAM;QACzD;QACA,iBAAiB,CAAA,yBAAA,MAAM,eAAe,cAArB,oCAAA,yBAA0B,YAAY,YAAY;mBACnE;oBACA;IACF;IAEA,OAAO;AACT","sources":["packages/@react-stately/checkbox/src/useCheckboxGroupState.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {CheckboxGroupProps} from '@react-types/checkbox';\nimport {FormValidationState, mergeValidation, useFormValidationState} from '@react-stately/form';\nimport {useControlledState} from '@react-stately/utils';\nimport {useRef} from 'react';\nimport {ValidationResult, ValidationState} from '@react-types/shared';\n\nexport interface CheckboxGroupState extends FormValidationState {\n /** Current selected values. */\n readonly value: readonly string[],\n\n /** Whether the checkbox group is disabled. */\n readonly isDisabled: boolean,\n\n /** Whether the checkbox group is read only. */\n readonly isReadOnly: boolean,\n\n /**\n * The current validation state of the checkbox group.\n * @deprecated Use `isInvalid` instead.\n */\n readonly validationState: ValidationState | null,\n\n /** Whether the checkbox group is invalid. */\n readonly isInvalid: boolean,\n\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: boolean,\n\n /** Returns whether the given value is selected. */\n isSelected(value: string): boolean,\n\n /** Sets the selected values. */\n setValue(value: string[]): void,\n\n /** Adds a value to the set of selected values. */\n addValue(value: string): void,\n\n /** Removes a value from the set of selected values. */\n removeValue(value: string): void,\n\n /** Toggles a value in the set of selected values. */\n toggleValue(value: string): void,\n\n /** Sets whether one of the checkboxes is invalid. */\n setInvalid(value: string, validation: ValidationResult): void\n}\n\n/**\n * Provides state management for a checkbox group component. Provides a name for the group,\n * and manages selection and focus state.\n */\nexport function useCheckboxGroupState(props: CheckboxGroupProps = {}): CheckboxGroupState {\n let [selectedValues, setValue] = useControlledState(props.value, props.defaultValue || [], props.onChange);\n let isRequired = !!props.isRequired && selectedValues.length === 0;\n\n let invalidValues = useRef(new Map<string, ValidationResult>());\n let validation = useFormValidationState({\n ...props,\n value: selectedValues\n });\n\n let isInvalid = validation.displayValidation.isInvalid;\n const state: CheckboxGroupState = {\n ...validation,\n value: selectedValues,\n setValue(value) {\n if (props.isReadOnly || props.isDisabled) {\n return;\n }\n\n setValue(value);\n },\n isDisabled: props.isDisabled || false,\n isReadOnly: props.isReadOnly || false,\n isSelected(value) {\n return selectedValues.includes(value);\n },\n addValue(value) {\n if (props.isReadOnly || props.isDisabled) {\n return;\n }\n if (!selectedValues.includes(value)) {\n setValue(selectedValues.concat(value));\n }\n },\n removeValue(value) {\n if (props.isReadOnly || props.isDisabled) {\n return;\n }\n if (selectedValues.includes(value)) {\n setValue(selectedValues.filter(existingValue => existingValue !== value));\n }\n },\n toggleValue(value) {\n if (props.isReadOnly || props.isDisabled) {\n return;\n }\n if (selectedValues.includes(value)) {\n setValue(selectedValues.filter(existingValue => existingValue !== value));\n } else {\n setValue(selectedValues.concat(value));\n }\n },\n setInvalid(value, v) {\n let s = new Map(invalidValues.current);\n if (v.isInvalid) {\n s.set(value, v);\n } else {\n s.delete(value);\n }\n\n invalidValues.current = s;\n validation.updateValidation(mergeValidation(...s.values()));\n },\n validationState: props.validationState ?? (isInvalid ? 'invalid' : null),\n isInvalid,\n isRequired\n };\n\n return state;\n}\n"],"names":[],"version":3,"file":"useCheckboxGroupState.main.js.map"}
@@ -0,0 +1,69 @@
1
+ import {useFormValidationState as $3Of4A$useFormValidationState, mergeValidation as $3Of4A$mergeValidation} from "@react-stately/form";
2
+ import {useControlledState as $3Of4A$useControlledState} from "@react-stately/utils";
3
+ import {useRef as $3Of4A$useRef} from "react";
4
+
5
+ /*
6
+ * Copyright 2020 Adobe. All rights reserved.
7
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
8
+ * you may not use this file except in compliance with the License. You may obtain a copy
9
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software distributed under
12
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
13
+ * OF ANY KIND, either express or implied. See the License for the specific language
14
+ * governing permissions and limitations under the License.
15
+ */
16
+
17
+
18
+ function $587d3ad58be6d31f$export$daff6da51032a415(props = {}) {
19
+ let [selectedValues, setValue] = (0, $3Of4A$useControlledState)(props.value, props.defaultValue || [], props.onChange);
20
+ let isRequired = !!props.isRequired && selectedValues.length === 0;
21
+ let invalidValues = (0, $3Of4A$useRef)(new Map());
22
+ let validation = (0, $3Of4A$useFormValidationState)({
23
+ ...props,
24
+ value: selectedValues
25
+ });
26
+ let isInvalid = validation.displayValidation.isInvalid;
27
+ var _props_validationState;
28
+ const state = {
29
+ ...validation,
30
+ value: selectedValues,
31
+ setValue (value) {
32
+ if (props.isReadOnly || props.isDisabled) return;
33
+ setValue(value);
34
+ },
35
+ isDisabled: props.isDisabled || false,
36
+ isReadOnly: props.isReadOnly || false,
37
+ isSelected (value) {
38
+ return selectedValues.includes(value);
39
+ },
40
+ addValue (value) {
41
+ if (props.isReadOnly || props.isDisabled) return;
42
+ if (!selectedValues.includes(value)) setValue(selectedValues.concat(value));
43
+ },
44
+ removeValue (value) {
45
+ if (props.isReadOnly || props.isDisabled) return;
46
+ if (selectedValues.includes(value)) setValue(selectedValues.filter((existingValue)=>existingValue !== value));
47
+ },
48
+ toggleValue (value) {
49
+ if (props.isReadOnly || props.isDisabled) return;
50
+ if (selectedValues.includes(value)) setValue(selectedValues.filter((existingValue)=>existingValue !== value));
51
+ else setValue(selectedValues.concat(value));
52
+ },
53
+ setInvalid (value, v) {
54
+ let s = new Map(invalidValues.current);
55
+ if (v.isInvalid) s.set(value, v);
56
+ else s.delete(value);
57
+ invalidValues.current = s;
58
+ validation.updateValidation((0, $3Of4A$mergeValidation)(...s.values()));
59
+ },
60
+ validationState: (_props_validationState = props.validationState) !== null && _props_validationState !== void 0 ? _props_validationState : isInvalid ? "invalid" : null,
61
+ isInvalid: isInvalid,
62
+ isRequired: isRequired
63
+ };
64
+ return state;
65
+ }
66
+
67
+
68
+ export {$587d3ad58be6d31f$export$daff6da51032a415 as useCheckboxGroupState};
69
+ //# sourceMappingURL=useCheckboxGroupState.mjs.map
@@ -0,0 +1,69 @@
1
+ import {useFormValidationState as $3Of4A$useFormValidationState, mergeValidation as $3Of4A$mergeValidation} from "@react-stately/form";
2
+ import {useControlledState as $3Of4A$useControlledState} from "@react-stately/utils";
3
+ import {useRef as $3Of4A$useRef} from "react";
4
+
5
+ /*
6
+ * Copyright 2020 Adobe. All rights reserved.
7
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
8
+ * you may not use this file except in compliance with the License. You may obtain a copy
9
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software distributed under
12
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
13
+ * OF ANY KIND, either express or implied. See the License for the specific language
14
+ * governing permissions and limitations under the License.
15
+ */
16
+
17
+
18
+ function $587d3ad58be6d31f$export$daff6da51032a415(props = {}) {
19
+ let [selectedValues, setValue] = (0, $3Of4A$useControlledState)(props.value, props.defaultValue || [], props.onChange);
20
+ let isRequired = !!props.isRequired && selectedValues.length === 0;
21
+ let invalidValues = (0, $3Of4A$useRef)(new Map());
22
+ let validation = (0, $3Of4A$useFormValidationState)({
23
+ ...props,
24
+ value: selectedValues
25
+ });
26
+ let isInvalid = validation.displayValidation.isInvalid;
27
+ var _props_validationState;
28
+ const state = {
29
+ ...validation,
30
+ value: selectedValues,
31
+ setValue (value) {
32
+ if (props.isReadOnly || props.isDisabled) return;
33
+ setValue(value);
34
+ },
35
+ isDisabled: props.isDisabled || false,
36
+ isReadOnly: props.isReadOnly || false,
37
+ isSelected (value) {
38
+ return selectedValues.includes(value);
39
+ },
40
+ addValue (value) {
41
+ if (props.isReadOnly || props.isDisabled) return;
42
+ if (!selectedValues.includes(value)) setValue(selectedValues.concat(value));
43
+ },
44
+ removeValue (value) {
45
+ if (props.isReadOnly || props.isDisabled) return;
46
+ if (selectedValues.includes(value)) setValue(selectedValues.filter((existingValue)=>existingValue !== value));
47
+ },
48
+ toggleValue (value) {
49
+ if (props.isReadOnly || props.isDisabled) return;
50
+ if (selectedValues.includes(value)) setValue(selectedValues.filter((existingValue)=>existingValue !== value));
51
+ else setValue(selectedValues.concat(value));
52
+ },
53
+ setInvalid (value, v) {
54
+ let s = new Map(invalidValues.current);
55
+ if (v.isInvalid) s.set(value, v);
56
+ else s.delete(value);
57
+ invalidValues.current = s;
58
+ validation.updateValidation((0, $3Of4A$mergeValidation)(...s.values()));
59
+ },
60
+ validationState: (_props_validationState = props.validationState) !== null && _props_validationState !== void 0 ? _props_validationState : isInvalid ? "invalid" : null,
61
+ isInvalid: isInvalid,
62
+ isRequired: isRequired
63
+ };
64
+ return state;
65
+ }
66
+
67
+
68
+ export {$587d3ad58be6d31f$export$daff6da51032a415 as useCheckboxGroupState};
69
+ //# sourceMappingURL=useCheckboxGroupState.module.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;AAAA;;;;;;;;;;CAUC;;;AAwDM,SAAS,0CAAsB,QAA4B,CAAC,CAAC;IAClE,IAAI,CAAC,gBAAgB,SAAS,GAAG,CAAA,GAAA,yBAAiB,EAAE,MAAM,KAAK,EAAE,MAAM,YAAY,IAAI,EAAE,EAAE,MAAM,QAAQ;IACzG,IAAI,aAAa,CAAC,CAAC,MAAM,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CAAA,yBAA0B,YAAY,YAAY;mBACnE;oBACA;IACF;IAEA,OAAO;AACT","sources":["packages/@react-stately/checkbox/src/useCheckboxGroupState.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {CheckboxGroupProps} from '@react-types/checkbox';\nimport {FormValidationState, mergeValidation, useFormValidationState} from '@react-stately/form';\nimport {useControlledState} from '@react-stately/utils';\nimport {useRef} from 'react';\nimport {ValidationResult, ValidationState} from '@react-types/shared';\n\nexport interface CheckboxGroupState extends FormValidationState {\n /** Current selected values. */\n readonly value: readonly string[],\n\n /** Whether the checkbox group is disabled. */\n readonly isDisabled: boolean,\n\n /** Whether the checkbox group is read only. */\n readonly isReadOnly: boolean,\n\n /**\n * The current validation state of the checkbox group.\n * @deprecated Use `isInvalid` instead.\n */\n readonly validationState: ValidationState | null,\n\n /** Whether the checkbox group is invalid. */\n readonly isInvalid: boolean,\n\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: boolean,\n\n /** Returns whether the given value is selected. */\n isSelected(value: string): boolean,\n\n /** Sets the selected values. */\n setValue(value: string[]): void,\n\n /** Adds a value to the set of selected values. */\n addValue(value: string): void,\n\n /** Removes a value from the set of selected values. */\n removeValue(value: string): void,\n\n /** Toggles a value in the set of selected values. */\n toggleValue(value: string): void,\n\n /** Sets whether one of the checkboxes is invalid. */\n setInvalid(value: string, validation: ValidationResult): void\n}\n\n/**\n * Provides state management for a checkbox group component. Provides a name for the group,\n * and manages selection and focus state.\n */\nexport function useCheckboxGroupState(props: CheckboxGroupProps = {}): CheckboxGroupState {\n let [selectedValues, setValue] = useControlledState(props.value, props.defaultValue || [], props.onChange);\n let isRequired = !!props.isRequired && selectedValues.length === 0;\n\n let invalidValues = useRef(new Map<string, ValidationResult>());\n let validation = useFormValidationState({\n ...props,\n value: selectedValues\n });\n\n let isInvalid = validation.displayValidation.isInvalid;\n const state: CheckboxGroupState = {\n ...validation,\n value: selectedValues,\n setValue(value) {\n if (props.isReadOnly || props.isDisabled) {\n return;\n }\n\n setValue(value);\n },\n isDisabled: props.isDisabled || false,\n isReadOnly: props.isReadOnly || false,\n isSelected(value) {\n return selectedValues.includes(value);\n },\n addValue(value) {\n if (props.isReadOnly || props.isDisabled) {\n return;\n }\n if (!selectedValues.includes(value)) {\n setValue(selectedValues.concat(value));\n }\n },\n removeValue(value) {\n if (props.isReadOnly || props.isDisabled) {\n return;\n }\n if (selectedValues.includes(value)) {\n setValue(selectedValues.filter(existingValue => existingValue !== value));\n }\n },\n toggleValue(value) {\n if (props.isReadOnly || props.isDisabled) {\n return;\n }\n if (selectedValues.includes(value)) {\n setValue(selectedValues.filter(existingValue => existingValue !== value));\n } else {\n setValue(selectedValues.concat(value));\n }\n },\n setInvalid(value, v) {\n let s = new Map(invalidValues.current);\n if (v.isInvalid) {\n s.set(value, v);\n } else {\n s.delete(value);\n }\n\n invalidValues.current = s;\n validation.updateValidation(mergeValidation(...s.values()));\n },\n validationState: props.validationState ?? (isInvalid ? 'invalid' : null),\n isInvalid,\n isRequired\n };\n\n return state;\n}\n"],"names":[],"version":3,"file":"useCheckboxGroupState.module.js.map"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-stately/checkbox",
3
- "version": "3.6.4-nightly.4555+81162ea39",
3
+ "version": "3.6.4-nightly.4558+c5e4b3701",
4
4
  "description": "Spectrum UI components in React",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/main.js",
@@ -22,10 +22,10 @@
22
22
  "url": "https://github.com/adobe/react-spectrum"
23
23
  },
24
24
  "dependencies": {
25
- "@react-stately/form": "3.0.2-nightly.4555+81162ea39",
26
- "@react-stately/utils": "3.0.0-nightly.2843+81162ea39",
27
- "@react-types/checkbox": "3.0.0-nightly.2843+81162ea39",
28
- "@react-types/shared": "3.0.0-nightly.2843+81162ea39",
25
+ "@react-stately/form": "3.0.2-nightly.4558+c5e4b3701",
26
+ "@react-stately/utils": "3.0.0-nightly.2846+c5e4b3701",
27
+ "@react-types/checkbox": "3.0.0-nightly.2846+c5e4b3701",
28
+ "@react-types/shared": "3.0.0-nightly.2846+c5e4b3701",
29
29
  "@swc/helpers": "^0.5.0"
30
30
  },
31
31
  "peerDependencies": {
@@ -34,5 +34,5 @@
34
34
  "publishConfig": {
35
35
  "access": "public"
36
36
  },
37
- "gitHead": "81162ea392926d06ec3d25c228e6f9b6b5479d59"
37
+ "gitHead": "c5e4b3701fdb89eb551f1b3697ac253f06ef68fa"
38
38
  }