@react-stately/checkbox 3.0.4-nightly.3047 → 3.0.4-nightly.3066

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/main.js CHANGED
@@ -39,26 +39,18 @@ function $ed6cc164b76540d4$export$daff6da51032a415(props = {
39
39
  },
40
40
  addValue (value) {
41
41
  if (props.isReadOnly || props.isDisabled) return;
42
- setValue((values)=>{
43
- if (!values.includes(value)) return values.concat(value);
44
- return values;
45
- });
42
+ if (!selectedValues.includes(value)) setValue(selectedValues.concat(value));
46
43
  },
47
44
  removeValue (value) {
48
45
  if (props.isReadOnly || props.isDisabled) return;
49
- setValue((values)=>{
50
- if (values.includes(value)) return values.filter((existingValue)=>existingValue !== value
51
- );
52
- return values;
53
- });
46
+ if (selectedValues.includes(value)) setValue(selectedValues.filter((existingValue)=>existingValue !== value
47
+ ));
54
48
  },
55
49
  toggleValue (value) {
56
50
  if (props.isReadOnly || props.isDisabled) return;
57
- setValue((values)=>{
58
- if (values.includes(value)) return values.filter((existingValue)=>existingValue !== value
59
- );
60
- return values.concat(value);
61
- });
51
+ if (selectedValues.includes(value)) setValue(selectedValues.filter((existingValue)=>existingValue !== value
52
+ ));
53
+ else setValue(selectedValues.concat(value));
62
54
  }
63
55
  };
64
56
  return state;
package/dist/main.js.map CHANGED
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;SC6CgB,yCAAqB,CAAC,KAAyB,GAAG,CAAC;AAAA,CAAC,EAAsB,CAAC;IACzF,GAAG,EAAE,cAAc,EAAE,QAAQ,IAAI,2CAAkB,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,YAAY,IAAI,CAAC,CAAC,EAAE,KAAK,CAAC,QAAQ;IAEzG,KAAK,CAAC,KAAK,GAAuB,CAAC;QACjC,KAAK,EAAE,cAAc;QACrB,QAAQ,EAAC,KAAK,EAAE,CAAC;YACf,EAAE,EAAE,KAAK,CAAC,UAA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AAM,CAAC,KAAK;AACd,CAAC","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 * 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 {useControlledState} from '@react-stately/utils';\n\nexport interface CheckboxGroupState {\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 /** 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\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\n const state: CheckboxGroupState = {\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 setValue(values => {\n if (!values.includes(value)) {\n return values.concat(value);\n }\n return values;\n });\n },\n removeValue(value) {\n if (props.isReadOnly || props.isDisabled) {\n return;\n }\n setValue(values => {\n if (values.includes(value)) {\n return values.filter(existingValue => existingValue !== value);\n }\n return values;\n });\n },\n toggleValue(value) {\n if (props.isReadOnly || props.isDisabled) {\n return;\n }\n setValue(values => {\n if (values.includes(value)) {\n return values.filter(existingValue => existingValue !== value);\n }\n return values.concat(value);\n });\n }\n };\n\n return state;\n}\n"],"names":[],"version":3,"file":"main.js.map"}
1
+ {"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;SC6CgB,yCAAqB,CAAC,KAAyB,GAAG,CAAC;AAAA,CAAC,EAAsB,CAAC;IACzF,GAAG,EAAE,cAAc,EAAE,QAAQ,IAAI,2CAAkB,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,YAAY,IAAI,CAAC,CAAC,EAAE,KAAK,CAAC,QAAQ;IAEzG,KAAK,CAAC,KAAK,GAAuB,CAAC;QACjC,KAAK,EAAE,cAAc;QACrB,QAAQ,EAAC,KAAK,EAAE,CAAC;YACf,EAAE,EAAE,KAAK,CAAC,UAAU,IAAI,KAAK,CAAC,UAAU,EACtC,MAAM;YAGR,QAAQ,CAAC,KAAK;QAChB,CAAC;QACD,UAAU,EAAE,KAAK,CAAC,UAAU,IAAI,KAAK;QACrC,UAAU,EAAE,KAAK,CAAC,UAAU,IAAI,KAAK;QACrC,UAAU,EAAC,KAAK,EAAE,CAAC;YACjB,MAAM,CAAC,cAAc,CAAC,QAAQ,CAAC,KAAK;QACtC,CAAC;QACD,QAAQ,EAAC,KAAK,EAAE,CAAC;YACf,EAAE,EAAE,KAAK,CAAC,UAAU,IAAI,KAAK,CAAC,UAAU,EACtC,MAAM;YAER,EAAE,GAAG,cAAc,CAAC,QAAQ,CAAC,KAAK,GAChC,QAAQ,CAAC,cAAc,CAAC,MAAM,CAAC,KAAK;QAExC,CAAC;QACD,WAAW,EAAC,KAAK,EAAE,CAAC;YAClB,EAAE,EAAE,KAAK,CAAC,UAAU,IAAI,KAAK,CAAC,UAAU,EACtC,MAAM;YAER,EAAE,EAAE,cAAc,CAAC,QAAQ,CAAC,KAAK,GAC/B,QAAQ,CAAC,cAAc,CAAC,MAAM,EAAC,aAAa,GAAI,aAAa,KAAK,KAAK;;QAE3E,CAAC;QACD,WAAW,EAAC,KAAK,EAAE,CAAC;YAClB,EAAE,EAAE,KAAK,CAAC,UAAU,IAAI,KAAK,CAAC,UAAU,EACtC,MAAM;YAER,EAAE,EAAE,cAAc,CAAC,QAAQ,CAAC,KAAK,GAC/B,QAAQ,CAAC,cAAc,CAAC,MAAM,EAAC,aAAa,GAAI,aAAa,KAAK,KAAK;;iBAEvE,QAAQ,CAAC,cAAc,CAAC,MAAM,CAAC,KAAK;QAExC,CAAC;IACH,CAAC;IAED,MAAM,CAAC,KAAK;AACd,CAAC","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 * 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 {useControlledState} from '@react-stately/utils';\n\nexport interface CheckboxGroupState {\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 /** 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\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\n const state: CheckboxGroupState = {\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 };\n\n return state;\n}\n"],"names":[],"version":3,"file":"main.js.map"}
package/dist/module.js CHANGED
@@ -23,26 +23,18 @@ function $22741eebe88b9d6f$export$daff6da51032a415(props = {
23
23
  },
24
24
  addValue (value) {
25
25
  if (props.isReadOnly || props.isDisabled) return;
26
- setValue((values)=>{
27
- if (!values.includes(value)) return values.concat(value);
28
- return values;
29
- });
26
+ if (!selectedValues.includes(value)) setValue(selectedValues.concat(value));
30
27
  },
31
28
  removeValue (value) {
32
29
  if (props.isReadOnly || props.isDisabled) return;
33
- setValue((values)=>{
34
- if (values.includes(value)) return values.filter((existingValue)=>existingValue !== value
35
- );
36
- return values;
37
- });
30
+ if (selectedValues.includes(value)) setValue(selectedValues.filter((existingValue)=>existingValue !== value
31
+ ));
38
32
  },
39
33
  toggleValue (value) {
40
34
  if (props.isReadOnly || props.isDisabled) return;
41
- setValue((values)=>{
42
- if (values.includes(value)) return values.filter((existingValue)=>existingValue !== value
43
- );
44
- return values.concat(value);
45
- });
35
+ if (selectedValues.includes(value)) setValue(selectedValues.filter((existingValue)=>existingValue !== value
36
+ ));
37
+ else setValue(selectedValues.concat(value));
46
38
  }
47
39
  };
48
40
  return state;
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;SC6CgB,yCAAqB,CAAC,KAAyB,GAAG,CAAC;AAAA,CAAC,EAAsB,CAAC;IACzF,GAAG,EAAE,cAAc,EAAE,QAAQ,IAAI,yBAAkB,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,YAAY,IAAI,CAAC,CAAC,EAAE,KAAK,CAAC,QAAQ;IAEzG,KAAK,CAAC,KAAK,GAAuB,CAAC;QACjC,KAAK,EAAE,cAAc;QACrB,QAAQ,EAAC,KAAK,EAAE,CAAC;YACf,EAAE,EAAE,KAAK,CAAC,UAAU,IAAI,KAAK,CAAC,UAAU,EACtC,MAAM;YA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ately/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 * 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 {useControlledState} from '@react-stately/utils';\n\nexport interface CheckboxGroupState {\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 /** 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\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\n const state: CheckboxGroupState = {\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 setValue(values => {\n if (!values.includes(value)) {\n return values.concat(value);\n }\n return values;\n });\n },\n removeValue(value) {\n if (props.isReadOnly || props.isDisabled) {\n return;\n }\n setValue(values => {\n if (values.includes(value)) {\n return values.filter(existingValue => existingValue !== value);\n }\n return values;\n });\n },\n toggleValue(value) {\n if (props.isReadOnly || props.isDisabled) {\n return;\n }\n setValue(values => {\n if (values.includes(value)) {\n return values.filter(existingValue => existingValue !== value);\n }\n return values.concat(value);\n });\n }\n };\n\n return state;\n}\n"],"names":[],"version":3,"file":"module.js.map"}
1
+ {"mappings":";;;;;;;;;SC6CgB,yCAAqB,CAAC,KAAyB,GAAG,CAAC;AAAA,CAAC,EAAsB,CAAC;IACzF,GAAG,EAAE,cAAc,EAAE,QAAQ,IAAI,yBAAkB,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,YAAY,IAAI,CAAC,CAAC,EAAE,KAAK,CAAC,QAAQ;IAEzG,KAAK,CAAC,KAAK,GAAuB,CAAC;QACjC,KAAK,EAAE,cAAc;QACrB,QAAQ,EAAC,KAAK,EAAE,CAAC;YACf,EAAE,EAAE,KAAK,CAAC,UAAU,IAAI,KAAK,CAAC,UAAU,EACtC,MAAM;YAGR,QAAQ,CAAC,KAAK;QAChB,CAAC;QACD,UAAU,EAAE,KAAK,CAAC,UAAU,IAAI,KAAK;QACrC,UAAU,EAAE,KAAK,CAAC,UAAU,IAAI,KAAK;QACrC,UAAU,EAAC,KAAK,EAAE,CAAC;YACjB,MAAM,CAAC,cAAc,CAAC,QAAQ,CAAC,KAAK;QACtC,CAAC;QACD,QAAQ,EAAC,KAAK,EAAE,CAAC;YACf,EAAE,EAAE,KAAK,CAAC,UAAU,IAAI,KAAK,CAAC,UAAU,EACtC,MAAM;YAER,EAAE,GAAG,cAAc,CAAC,QAAQ,CAAC,KAAK,GAChC,QAAQ,CAAC,cAAc,CAAC,MAAM,CAAC,KAAK;QAExC,CAAC;QACD,WAAW,EAAC,KAAK,EAAE,CAAC;YAClB,EAAE,EAAE,KAAK,CAAC,UAAU,IAAI,KAAK,CAAC,UAAU,EACtC,MAAM;YAER,EAAE,EAAE,cAAc,CAAC,QAAQ,CAAC,KAAK,GAC/B,QAAQ,CAAC,cAAc,CAAC,MAAM,EAAC,aAAa,GAAI,aAAa,KAAK,KAAK;;QAE3E,CAAC;QACD,WAAW,EAAC,KAAK,EAAE,CAAC;YAClB,EAAE,EAAE,KAAK,CAAC,UAAU,IAAI,KAAK,CAAC,UAAU,EACtC,MAAM;YAER,EAAE,EAAE,cAAc,CAAC,QAAQ,CAAC,KAAK,GAC/B,QAAQ,CAAC,cAAc,CAAC,MAAM,EAAC,aAAa,GAAI,aAAa,KAAK,KAAK;;iBAEvE,QAAQ,CAAC,cAAc,CAAC,MAAM,CAAC,KAAK;QAExC,CAAC;IACH,CAAC;IAED,MAAM,CAAC,KAAK;AACd,CAAC","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 * 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 {useControlledState} from '@react-stately/utils';\n\nexport interface CheckboxGroupState {\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 /** 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\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\n const state: CheckboxGroupState = {\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 };\n\n return state;\n}\n"],"names":[],"version":3,"file":"module.js.map"}
@@ -1 +1 @@
1
- {"mappings":";AAeA;IACE,+BAA+B;IAC/B,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IAElC,8CAA8C;IAC9C,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAE7B,+CAA+C;IAC/C,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAE7B,mDAAmD;IACnD,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;IAEnC,gCAAgC;IAChC,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IAEhC,kDAAkD;IAClD,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAE9B,uDAAuD;IACvD,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAEjC,qDAAqD;IACrD,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;CACjC;AAED;;;GAGG;AACH,sCAAsC,KAAK,GAAE,kBAAuB,GAAG,kBAAkB,CAqDxF","sources":["packages/@react-stately/checkbox/src/packages/@react-stately/checkbox/src/useCheckboxGroupState.ts","packages/@react-stately/checkbox/src/packages/@react-stately/checkbox/src/index.ts","packages/@react-stately/checkbox/src/index.ts"],"sourcesContent":[null,null,"/*\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 * from './useCheckboxGroupState';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
1
+ {"mappings":";AAeA;IACE,+BAA+B;IAC/B,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IAElC,8CAA8C;IAC9C,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAE7B,+CAA+C;IAC/C,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAE7B,mDAAmD;IACnD,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;IAEnC,gCAAgC;IAChC,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IAEhC,kDAAkD;IAClD,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAE9B,uDAAuD;IACvD,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAEjC,qDAAqD;IACrD,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;CACjC;AAED;;;GAGG;AACH,sCAAsC,KAAK,GAAE,kBAAuB,GAAG,kBAAkB,CA8CxF","sources":["packages/@react-stately/checkbox/src/packages/@react-stately/checkbox/src/useCheckboxGroupState.ts","packages/@react-stately/checkbox/src/packages/@react-stately/checkbox/src/index.ts","packages/@react-stately/checkbox/src/index.ts"],"sourcesContent":[null,null,"/*\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 * from './useCheckboxGroupState';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-stately/checkbox",
3
- "version": "3.0.4-nightly.3047+87960ad25",
3
+ "version": "3.0.4-nightly.3066+10e57d449",
4
4
  "description": "Spectrum UI components in React",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/main.js",
@@ -18,9 +18,9 @@
18
18
  },
19
19
  "dependencies": {
20
20
  "@babel/runtime": "^7.6.2",
21
- "@react-stately/toggle": "3.0.0-nightly.1356+87960ad25",
22
- "@react-stately/utils": "3.0.0-nightly.1356+87960ad25",
23
- "@react-types/checkbox": "3.0.0-nightly.1356+87960ad25"
21
+ "@react-stately/toggle": "3.0.0-nightly.1375+10e57d449",
22
+ "@react-stately/utils": "3.0.0-nightly.1375+10e57d449",
23
+ "@react-types/checkbox": "3.0.0-nightly.1375+10e57d449"
24
24
  },
25
25
  "peerDependencies": {
26
26
  "react": "^16.8.0 || ^17.0.0-rc.1"
@@ -28,5 +28,5 @@
28
28
  "publishConfig": {
29
29
  "access": "public"
30
30
  },
31
- "gitHead": "87960ad25c26bc4cd6af506bb5e7e0f06621556c"
31
+ "gitHead": "10e57d449dde2ae6bd095a63a8339e1d4c61cf59"
32
32
  }
@@ -64,34 +64,27 @@ export function useCheckboxGroupState(props: CheckboxGroupProps = {}): CheckboxG
64
64
  if (props.isReadOnly || props.isDisabled) {
65
65
  return;
66
66
  }
67
- setValue(values => {
68
- if (!values.includes(value)) {
69
- return values.concat(value);
70
- }
71
- return values;
72
- });
67
+ if (!selectedValues.includes(value)) {
68
+ setValue(selectedValues.concat(value));
69
+ }
73
70
  },
74
71
  removeValue(value) {
75
72
  if (props.isReadOnly || props.isDisabled) {
76
73
  return;
77
74
  }
78
- setValue(values => {
79
- if (values.includes(value)) {
80
- return values.filter(existingValue => existingValue !== value);
81
- }
82
- return values;
83
- });
75
+ if (selectedValues.includes(value)) {
76
+ setValue(selectedValues.filter(existingValue => existingValue !== value));
77
+ }
84
78
  },
85
79
  toggleValue(value) {
86
80
  if (props.isReadOnly || props.isDisabled) {
87
81
  return;
88
82
  }
89
- setValue(values => {
90
- if (values.includes(value)) {
91
- return values.filter(existingValue => existingValue !== value);
92
- }
93
- return values.concat(value);
94
- });
83
+ if (selectedValues.includes(value)) {
84
+ setValue(selectedValues.filter(existingValue => existingValue !== value));
85
+ } else {
86
+ setValue(selectedValues.concat(value));
87
+ }
95
88
  }
96
89
  };
97
90