@react-stately/checkbox 3.2.2-nightly.3475 → 3.2.2-nightly.3479

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
@@ -34,7 +34,8 @@ function $943f4c622056df75$export$daff6da51032a415(props = {
34
34
  if (selectedValues.includes(value)) setValue(selectedValues.filter((existingValue)=>existingValue !== value
35
35
  ));
36
36
  else setValue(selectedValues.concat(value));
37
- }
37
+ },
38
+ validationState: props.validationState
38
39
  };
39
40
  return state;
40
41
  }
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,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 {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 {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"}
1
+ {"mappings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KAAK,GAC/B,QAAQ,CAAC,cAAc,CAAC,MAAM,EAAC,aAAa,GAAI,aAAa,KAAK,KAAK;;iBAEvE,QAAQ,CAAC,cAAc,CAAC,MAAM,CAAC,KAAK;QAExC,CAAC;QACD,eAAe,EAAE,KAAK,CAAC,eAAe;IACxC,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 {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 {useControlledState} from '@react-stately/utils';\nimport {ValidationState} from '@react-types/shared';\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 /** The current validation state of the checkbox group. */\n validationState: ValidationState\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 validationState: props.validationState\n };\n\n return state;\n}\n"],"names":[],"version":3,"file":"main.js.map"}
package/dist/module.js CHANGED
@@ -29,7 +29,8 @@ function $587d3ad58be6d31f$export$daff6da51032a415(props = {
29
29
  if (selectedValues.includes(value)) setValue(selectedValues.filter((existingValue)=>existingValue !== value
30
30
  ));
31
31
  else setValue(selectedValues.concat(value));
32
- }
32
+ },
33
+ validationState: props.validationState
33
34
  };
34
35
  return state;
35
36
  }
@@ -1 +1 @@
1
- {"mappings":";;;SC6CgB,yCAAqB,CAAC,KAAyB,GAAG,CA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,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 {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 {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
+ {"mappings":";;;SCiDgB,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;QACD,eAAe,EAAE,KAAK,CAAC,eAAe;IACxC,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 {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 {useControlledState} from '@react-stately/utils';\nimport {ValidationState} from '@react-types/shared';\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 /** The current validation state of the checkbox group. */\n validationState: ValidationState\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 validationState: props.validationState\n };\n\n return state;\n}\n"],"names":[],"version":3,"file":"module.js.map"}
package/dist/types.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { CheckboxGroupProps } from "@react-types/checkbox";
2
+ import { ValidationState } from "@react-types/shared";
2
3
  export interface CheckboxGroupState {
3
4
  /** Current selected values. */
4
5
  readonly value: readonly string[];
@@ -16,6 +17,8 @@ export interface CheckboxGroupState {
16
17
  removeValue(value: string): void;
17
18
  /** Toggles a value in the set of selected values. */
18
19
  toggleValue(value: string): void;
20
+ /** The current validation state of the checkbox group. */
21
+ validationState: ValidationState;
19
22
  }
20
23
  /**
21
24
  * Provides state management for a checkbox group component. Provides a name for the group,
@@ -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,CA8CxF;AC7ED,YAAY,EAAC,kBAAkB,EAAC,MAAM,uBAAuB,CAAC","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 {useCheckboxGroupState} from './useCheckboxGroupState';\n\nexport type {CheckboxGroupProps} from '@react-types/checkbox';\nexport type {CheckboxGroupState} from './useCheckboxGroupState';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
1
+ {"mappings":";;AAgBA;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,CAAC;IAEjC,0DAA0D;IAC1D,eAAe,EAAE,eAAe,CAAA;CACjC;AAED;;;GAGG;AACH,sCAAsC,KAAK,GAAE,kBAAuB,GAAG,kBAAkB,CA+CxF;AClFD,YAAY,EAAC,kBAAkB,EAAC,MAAM,uBAAuB,CAAC","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 {useCheckboxGroupState} from './useCheckboxGroupState';\n\nexport type {CheckboxGroupProps} from '@react-types/checkbox';\nexport type {CheckboxGroupState} 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.2.2-nightly.3475+00c313323",
3
+ "version": "3.2.2-nightly.3479+afb946c4a",
4
4
  "description": "Spectrum UI components in React",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/main.js",
@@ -18,9 +18,10 @@
18
18
  },
19
19
  "dependencies": {
20
20
  "@babel/runtime": "^7.6.2",
21
- "@react-stately/toggle": "3.0.0-nightly.1775+00c313323",
22
- "@react-stately/utils": "3.0.0-nightly.1775+00c313323",
23
- "@react-types/checkbox": "3.0.0-nightly.1775+00c313323"
21
+ "@react-stately/toggle": "3.0.0-nightly.1779+afb946c4a",
22
+ "@react-stately/utils": "3.0.0-nightly.1779+afb946c4a",
23
+ "@react-types/checkbox": "3.0.0-nightly.1779+afb946c4a",
24
+ "@react-types/shared": "3.0.0-nightly.1779+afb946c4a"
24
25
  },
25
26
  "peerDependencies": {
26
27
  "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0"
@@ -28,5 +29,5 @@
28
29
  "publishConfig": {
29
30
  "access": "public"
30
31
  },
31
- "gitHead": "00c313323581ca010123f94e464f48d71cd47d8d"
32
+ "gitHead": "afb946c4ab759b0dd19e024f8c0768d382134a7b"
32
33
  }
@@ -12,6 +12,7 @@
12
12
 
13
13
  import {CheckboxGroupProps} from '@react-types/checkbox';
14
14
  import {useControlledState} from '@react-stately/utils';
15
+ import {ValidationState} from '@react-types/shared';
15
16
 
16
17
  export interface CheckboxGroupState {
17
18
  /** Current selected values. */
@@ -36,7 +37,10 @@ export interface CheckboxGroupState {
36
37
  removeValue(value: string): void,
37
38
 
38
39
  /** Toggles a value in the set of selected values. */
39
- toggleValue(value: string): void
40
+ toggleValue(value: string): void,
41
+
42
+ /** The current validation state of the checkbox group. */
43
+ validationState: ValidationState
40
44
  }
41
45
 
42
46
  /**
@@ -85,7 +89,8 @@ export function useCheckboxGroupState(props: CheckboxGroupProps = {}): CheckboxG
85
89
  } else {
86
90
  setValue(selectedValues.concat(value));
87
91
  }
88
- }
92
+ },
93
+ validationState: props.validationState
89
94
  };
90
95
 
91
96
  return state;