@react-stately/checkbox 3.7.5 → 3.8.0

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,4 +1,4 @@
1
- import {useCheckboxGroupState as $587d3ad58be6d31f$export$daff6da51032a415} from "./useCheckboxGroupState.mjs";
1
+ import {useCheckboxGroupState as $3dc387672ff1cdaa$re_export$useCheckboxGroupState} from "react-stately/useCheckboxGroupState";
2
2
 
3
3
  /*
4
4
  * Copyright 2020 Adobe. All rights reserved.
@@ -13,5 +13,5 @@ import {useCheckboxGroupState as $587d3ad58be6d31f$export$daff6da51032a415} from
13
13
  */
14
14
 
15
15
 
16
- export {$587d3ad58be6d31f$export$daff6da51032a415 as useCheckboxGroupState};
16
+ export {$3dc387672ff1cdaa$re_export$useCheckboxGroupState as useCheckboxGroupState};
17
17
  //# sourceMappingURL=module.js.map
package/dist/main.js CHANGED
@@ -1,11 +1,11 @@
1
- var $943f4c622056df75$exports = require("./useCheckboxGroupState.main.js");
1
+ var $d6Ffh$reactstatelyuseCheckboxGroupState = require("react-stately/useCheckboxGroupState");
2
2
 
3
3
 
4
4
  function $parcel$export(e, n, v, s) {
5
5
  Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
6
6
  }
7
7
 
8
- $parcel$export(module.exports, "useCheckboxGroupState", () => $943f4c622056df75$exports.useCheckboxGroupState);
8
+ $parcel$export(module.exports, "useCheckboxGroupState", function () { return $d6Ffh$reactstatelyuseCheckboxGroupState.useCheckboxGroupState; });
9
9
  /*
10
10
  * Copyright 2020 Adobe. All rights reserved.
11
11
  * This file is licensed to you under the Apache License, Version 2.0 (the "License");
package/dist/main.js.map CHANGED
@@ -1 +1 @@
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"}
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 'react-stately/useCheckboxGroupState';\n\nexport type {CheckboxGroupProps, CheckboxGroupState} from 'react-stately/useCheckboxGroupState';\n"],"names":[],"version":3,"file":"main.js.map"}
package/dist/module.js CHANGED
@@ -1,4 +1,4 @@
1
- import {useCheckboxGroupState as $587d3ad58be6d31f$export$daff6da51032a415} from "./useCheckboxGroupState.module.js";
1
+ import {useCheckboxGroupState as $3dc387672ff1cdaa$re_export$useCheckboxGroupState} from "react-stately/useCheckboxGroupState";
2
2
 
3
3
  /*
4
4
  * Copyright 2020 Adobe. All rights reserved.
@@ -13,5 +13,5 @@ import {useCheckboxGroupState as $587d3ad58be6d31f$export$daff6da51032a415} from
13
13
  */
14
14
 
15
15
 
16
- export {$587d3ad58be6d31f$export$daff6da51032a415 as useCheckboxGroupState};
16
+ export {$3dc387672ff1cdaa$re_export$useCheckboxGroupState as useCheckboxGroupState};
17
17
  //# sourceMappingURL=module.js.map
@@ -1 +1 @@
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"}
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 'react-stately/useCheckboxGroupState';\n\nexport type {CheckboxGroupProps, CheckboxGroupState} from 'react-stately/useCheckboxGroupState';\n"],"names":[],"version":3,"file":"module.js.map"}
@@ -0,0 +1,2 @@
1
+ export { useCheckboxGroupState } from 'react-stately/useCheckboxGroupState';
2
+ export type { CheckboxGroupProps, CheckboxGroupState } from 'react-stately/useCheckboxGroupState';
package/package.json CHANGED
@@ -1,20 +1,20 @@
1
1
  {
2
2
  "name": "@react-stately/checkbox",
3
- "version": "3.7.5",
3
+ "version": "3.8.0",
4
4
  "description": "Spectrum UI components in React",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/main.js",
7
7
  "module": "dist/module.js",
8
8
  "exports": {
9
- "source": "./src/index.ts",
10
- "types": [
11
- "./dist/types.d.ts",
12
- "./src/index.ts"
13
- ],
14
- "import": "./dist/import.mjs",
15
- "require": "./dist/main.js"
9
+ ".": {
10
+ "source": "./src/index.ts",
11
+ "types": "./dist/types/src/index.d.ts",
12
+ "import": "./dist/import.mjs",
13
+ "require": "./dist/main.js"
14
+ },
15
+ "./package.json": "./package.json"
16
16
  },
17
- "types": "dist/types.d.ts",
17
+ "types": "dist/types/src/index.d.ts",
18
18
  "source": "src/index.ts",
19
19
  "files": [
20
20
  "dist",
@@ -26,17 +26,18 @@
26
26
  "url": "https://github.com/adobe/react-spectrum"
27
27
  },
28
28
  "dependencies": {
29
- "@react-stately/form": "^3.2.4",
30
- "@react-stately/utils": "^3.11.0",
31
- "@react-types/checkbox": "^3.10.4",
32
- "@react-types/shared": "^3.33.1",
33
- "@swc/helpers": "^0.5.0"
29
+ "@swc/helpers": "^0.5.0",
30
+ "react-stately": "3.46.0"
34
31
  },
35
32
  "peerDependencies": {
36
- "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1"
33
+ "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1",
34
+ "react-dom": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1"
37
35
  },
38
36
  "publishConfig": {
39
37
  "access": "public"
40
38
  },
41
- "gitHead": "8df187370053aa35f553cb388ad670f65e1ab371"
39
+ "targets": {
40
+ "types": false
41
+ },
42
+ "gitHead": "a6999bdf494a2e9c0381a5881908328bdd22ddae"
42
43
  }
package/src/index.ts CHANGED
@@ -10,7 +10,6 @@
10
10
  * governing permissions and limitations under the License.
11
11
  */
12
12
 
13
- export {useCheckboxGroupState} from './useCheckboxGroupState';
13
+ export {useCheckboxGroupState} from 'react-stately/useCheckboxGroupState';
14
14
 
15
- export type {CheckboxGroupProps} from '@react-types/checkbox';
16
- export type {CheckboxGroupState} from './useCheckboxGroupState';
15
+ export type {CheckboxGroupProps, CheckboxGroupState} from 'react-stately/useCheckboxGroupState';
package/dist/types.d.ts DELETED
@@ -1,45 +0,0 @@
1
- import { CheckboxGroupProps } from "@react-types/checkbox";
2
- import { FormValidationState } from "@react-stately/form";
3
- import { ValidationResult, ValidationState } from "@react-types/shared";
4
- export interface CheckboxGroupState extends FormValidationState {
5
- /** Current selected values. */
6
- readonly value: readonly string[];
7
- /** Default selected values. */
8
- readonly defaultValue: readonly string[];
9
- /** Whether the checkbox group is disabled. */
10
- readonly isDisabled: boolean;
11
- /** Whether the checkbox group is read only. */
12
- readonly isReadOnly: boolean;
13
- /**
14
- * The current validation state of the checkbox group.
15
- * @deprecated Use `isInvalid` instead.
16
- */
17
- readonly validationState: ValidationState | null;
18
- /** Whether the checkbox group is invalid. */
19
- readonly isInvalid: boolean;
20
- /**
21
- * Whether the checkboxes in the group are required.
22
- * This changes to false once at least one item is selected.
23
- */
24
- readonly isRequired: boolean;
25
- /** Returns whether the given value is selected. */
26
- isSelected(value: string): boolean;
27
- /** Sets the selected values. */
28
- setValue(value: string[]): void;
29
- /** Adds a value to the set of selected values. */
30
- addValue(value: string): void;
31
- /** Removes a value from the set of selected values. */
32
- removeValue(value: string): void;
33
- /** Toggles a value in the set of selected values. */
34
- toggleValue(value: string): void;
35
- /** Sets whether one of the checkboxes is invalid. */
36
- setInvalid(value: string, validation: ValidationResult): void;
37
- }
38
- /**
39
- * Provides state management for a checkbox group component. Provides a name for the group,
40
- * and manages selection and focus state.
41
- */
42
- export function useCheckboxGroupState(props?: CheckboxGroupProps): CheckboxGroupState;
43
- export type { CheckboxGroupProps } from '@react-types/checkbox';
44
-
45
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"mappings":";;;AAkBA,mCAAoC,SAAQ,mBAAmB;IAC7D,+BAA+B;IAC/B,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,+BAA+B;IAC/B,QAAQ,CAAC,YAAY,EAAE,SAAS,MAAM,EAAE,CAAC;IAEzC,8CAA8C;IAC9C,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAE7B,+CAA+C;IAC/C,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAE7B;;;OAGG;IACH,QAAQ,CAAC,eAAe,EAAE,eAAe,GAAG,IAAI,CAAC;IAEjD,6CAA6C;IAC7C,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAE5B;;;OAGG;IACH,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,qDAAqD;IACrD,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,gBAAgB,GAAG,IAAI,CAAA;CAC9D;AAED;;;GAGG;AACH,sCAAsC,KAAK,GAAE,kBAAuB,GAAG,kBAAkB,CA0ExF;AChID,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,79 +0,0 @@
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 [initialValues] = (0, $6SsBH$react.useState)(selectedValues);
27
- let isRequired = !!props.isRequired && selectedValues.length === 0;
28
- let invalidValues = (0, $6SsBH$react.useRef)(new Map());
29
- let validation = (0, $6SsBH$reactstatelyform.useFormValidationState)({
30
- ...props,
31
- value: selectedValues
32
- });
33
- let isInvalid = validation.displayValidation.isInvalid;
34
- var _props_defaultValue, _props_validationState;
35
- const state = {
36
- ...validation,
37
- value: selectedValues,
38
- defaultValue: (_props_defaultValue = props.defaultValue) !== null && _props_defaultValue !== void 0 ? _props_defaultValue : initialValues,
39
- setValue (value) {
40
- if (props.isReadOnly || props.isDisabled) return;
41
- setValue(value);
42
- },
43
- isDisabled: props.isDisabled || false,
44
- isReadOnly: props.isReadOnly || false,
45
- isSelected (value) {
46
- return selectedValues.includes(value);
47
- },
48
- addValue (value) {
49
- if (props.isReadOnly || props.isDisabled) return;
50
- setValue((selectedValues)=>{
51
- if (!selectedValues.includes(value)) return selectedValues.concat(value);
52
- return selectedValues;
53
- });
54
- },
55
- removeValue (value) {
56
- if (props.isReadOnly || props.isDisabled) return;
57
- if (selectedValues.includes(value)) setValue(selectedValues.filter((existingValue)=>existingValue !== value));
58
- },
59
- toggleValue (value) {
60
- if (props.isReadOnly || props.isDisabled) return;
61
- if (selectedValues.includes(value)) setValue(selectedValues.filter((existingValue)=>existingValue !== value));
62
- else setValue(selectedValues.concat(value));
63
- },
64
- setInvalid (value, v) {
65
- let s = new Map(invalidValues.current);
66
- if (v.isInvalid) s.set(value, v);
67
- else s.delete(value);
68
- invalidValues.current = s;
69
- validation.updateValidation((0, $6SsBH$reactstatelyform.mergeValidation)(...s.values()));
70
- },
71
- validationState: (_props_validationState = props.validationState) !== null && _props_validationState !== void 0 ? _props_validationState : isInvalid ? 'invalid' : null,
72
- isInvalid: isInvalid,
73
- isRequired: isRequired
74
- };
75
- return state;
76
- }
77
-
78
-
79
- //# sourceMappingURL=useCheckboxGroupState.main.js.map
@@ -1 +0,0 @@
1
- {"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;AA0DM,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,CAAC,cAAc,GAAG,CAAA,GAAA,qBAAO,EAAE;IAC/B,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;QAItC,qBAqDG;IAxDnB,MAAM,QAA4B;QAChC,GAAG,UAAU;QACb,OAAO;QACP,cAAc,CAAA,sBAAA,MAAM,YAAY,cAAlB,iCAAA,sBAAsB;QACpC,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,SAAS,CAAA;gBACP,IAAI,CAAC,eAAe,QAAQ,CAAC,QAC3B,OAAO,eAAe,MAAM,CAAC;gBAE/B,OAAO;YACT;QACF;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","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, useState} 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 /** Default selected values. */\n readonly defaultValue: 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 [initialValues] = useState(selectedValues);\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 defaultValue: props.defaultValue ?? initialValues,\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(selectedValues => {\n if (!selectedValues.includes(value)) {\n return selectedValues.concat(value);\n }\n return selectedValues;\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"}
@@ -1,74 +0,0 @@
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 {useState as $3Of4A$useState, 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 [initialValues] = (0, $3Of4A$useState)(selectedValues);
21
- let isRequired = !!props.isRequired && selectedValues.length === 0;
22
- let invalidValues = (0, $3Of4A$useRef)(new Map());
23
- let validation = (0, $3Of4A$useFormValidationState)({
24
- ...props,
25
- value: selectedValues
26
- });
27
- let isInvalid = validation.displayValidation.isInvalid;
28
- var _props_defaultValue, _props_validationState;
29
- const state = {
30
- ...validation,
31
- value: selectedValues,
32
- defaultValue: (_props_defaultValue = props.defaultValue) !== null && _props_defaultValue !== void 0 ? _props_defaultValue : initialValues,
33
- setValue (value) {
34
- if (props.isReadOnly || props.isDisabled) return;
35
- setValue(value);
36
- },
37
- isDisabled: props.isDisabled || false,
38
- isReadOnly: props.isReadOnly || false,
39
- isSelected (value) {
40
- return selectedValues.includes(value);
41
- },
42
- addValue (value) {
43
- if (props.isReadOnly || props.isDisabled) return;
44
- setValue((selectedValues)=>{
45
- if (!selectedValues.includes(value)) return selectedValues.concat(value);
46
- return selectedValues;
47
- });
48
- },
49
- removeValue (value) {
50
- if (props.isReadOnly || props.isDisabled) return;
51
- if (selectedValues.includes(value)) setValue(selectedValues.filter((existingValue)=>existingValue !== value));
52
- },
53
- toggleValue (value) {
54
- if (props.isReadOnly || props.isDisabled) return;
55
- if (selectedValues.includes(value)) setValue(selectedValues.filter((existingValue)=>existingValue !== value));
56
- else setValue(selectedValues.concat(value));
57
- },
58
- setInvalid (value, v) {
59
- let s = new Map(invalidValues.current);
60
- if (v.isInvalid) s.set(value, v);
61
- else s.delete(value);
62
- invalidValues.current = s;
63
- validation.updateValidation((0, $3Of4A$mergeValidation)(...s.values()));
64
- },
65
- validationState: (_props_validationState = props.validationState) !== null && _props_validationState !== void 0 ? _props_validationState : isInvalid ? 'invalid' : null,
66
- isInvalid: isInvalid,
67
- isRequired: isRequired
68
- };
69
- return state;
70
- }
71
-
72
-
73
- export {$587d3ad58be6d31f$export$daff6da51032a415 as useCheckboxGroupState};
74
- //# sourceMappingURL=useCheckboxGroupState.module.js.map
@@ -1,74 +0,0 @@
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 {useState as $3Of4A$useState, 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 [initialValues] = (0, $3Of4A$useState)(selectedValues);
21
- let isRequired = !!props.isRequired && selectedValues.length === 0;
22
- let invalidValues = (0, $3Of4A$useRef)(new Map());
23
- let validation = (0, $3Of4A$useFormValidationState)({
24
- ...props,
25
- value: selectedValues
26
- });
27
- let isInvalid = validation.displayValidation.isInvalid;
28
- var _props_defaultValue, _props_validationState;
29
- const state = {
30
- ...validation,
31
- value: selectedValues,
32
- defaultValue: (_props_defaultValue = props.defaultValue) !== null && _props_defaultValue !== void 0 ? _props_defaultValue : initialValues,
33
- setValue (value) {
34
- if (props.isReadOnly || props.isDisabled) return;
35
- setValue(value);
36
- },
37
- isDisabled: props.isDisabled || false,
38
- isReadOnly: props.isReadOnly || false,
39
- isSelected (value) {
40
- return selectedValues.includes(value);
41
- },
42
- addValue (value) {
43
- if (props.isReadOnly || props.isDisabled) return;
44
- setValue((selectedValues)=>{
45
- if (!selectedValues.includes(value)) return selectedValues.concat(value);
46
- return selectedValues;
47
- });
48
- },
49
- removeValue (value) {
50
- if (props.isReadOnly || props.isDisabled) return;
51
- if (selectedValues.includes(value)) setValue(selectedValues.filter((existingValue)=>existingValue !== value));
52
- },
53
- toggleValue (value) {
54
- if (props.isReadOnly || props.isDisabled) return;
55
- if (selectedValues.includes(value)) setValue(selectedValues.filter((existingValue)=>existingValue !== value));
56
- else setValue(selectedValues.concat(value));
57
- },
58
- setInvalid (value, v) {
59
- let s = new Map(invalidValues.current);
60
- if (v.isInvalid) s.set(value, v);
61
- else s.delete(value);
62
- invalidValues.current = s;
63
- validation.updateValidation((0, $3Of4A$mergeValidation)(...s.values()));
64
- },
65
- validationState: (_props_validationState = props.validationState) !== null && _props_validationState !== void 0 ? _props_validationState : isInvalid ? 'invalid' : null,
66
- isInvalid: isInvalid,
67
- isRequired: isRequired
68
- };
69
- return state;
70
- }
71
-
72
-
73
- export {$587d3ad58be6d31f$export$daff6da51032a415 as useCheckboxGroupState};
74
- //# sourceMappingURL=useCheckboxGroupState.module.js.map
@@ -1 +0,0 @@
1
- {"mappings":";;;;AAAA;;;;;;;;;;CAUC;;;AA0DM,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,CAAC,cAAc,GAAG,CAAA,GAAA,eAAO,EAAE;IAC/B,IAAI,aAAa,CAAC,CAAC,MAAM,UAAU,IAAI,eAAe,MAAM,KAAK;IAEjE,IAAI,gBAAgB,CAAA,GAAA,aAAK,EAAE,IAAI;IAC/B,IAAI,aAAa,CAAA,GAAA,6BAAqB,EAAE;QACtC,GAAG,KAAK;QACR,OAAO;IACT;IAEA,IAAI,YAAY,WAAW,iBAAiB,CAAC,SAAS;QAItC,qBAqDG;IAxDnB,MAAM,QAA4B;QAChC,GAAG,UAAU;QACb,OAAO;QACP,cAAc,CAAA,sBAAA,MAAM,YAAY,cAAlB,iCAAA,sBAAsB;QACpC,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,SAAS,CAAA;gBACP,IAAI,CAAC,eAAe,QAAQ,CAAC,QAC3B,OAAO,eAAe,MAAM,CAAC;gBAE/B,OAAO;YACT;QACF;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,sBAAc,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, useState} 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 /** Default selected values. */\n readonly defaultValue: 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 [initialValues] = useState(selectedValues);\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 defaultValue: props.defaultValue ?? initialValues,\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(selectedValues => {\n if (!selectedValues.includes(value)) {\n return selectedValues.concat(value);\n }\n return selectedValues;\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"}
@@ -1,143 +0,0 @@
1
- /*
2
- * Copyright 2020 Adobe. All rights reserved.
3
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
- * you may not use this file except in compliance with the License. You may obtain a copy
5
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
- *
7
- * Unless required by applicable law or agreed to in writing, software distributed under
8
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
- * OF ANY KIND, either express or implied. See the License for the specific language
10
- * governing permissions and limitations under the License.
11
- */
12
-
13
- import {CheckboxGroupProps} from '@react-types/checkbox';
14
- import {FormValidationState, mergeValidation, useFormValidationState} from '@react-stately/form';
15
- import {useControlledState} from '@react-stately/utils';
16
- import {useRef, useState} from 'react';
17
- import {ValidationResult, ValidationState} from '@react-types/shared';
18
-
19
- export interface CheckboxGroupState extends FormValidationState {
20
- /** Current selected values. */
21
- readonly value: readonly string[],
22
- /** Default selected values. */
23
- readonly defaultValue: readonly string[],
24
-
25
- /** Whether the checkbox group is disabled. */
26
- readonly isDisabled: boolean,
27
-
28
- /** Whether the checkbox group is read only. */
29
- readonly isReadOnly: boolean,
30
-
31
- /**
32
- * The current validation state of the checkbox group.
33
- * @deprecated Use `isInvalid` instead.
34
- */
35
- readonly validationState: ValidationState | null,
36
-
37
- /** Whether the checkbox group is invalid. */
38
- readonly isInvalid: boolean,
39
-
40
- /**
41
- * Whether the checkboxes in the group are required.
42
- * This changes to false once at least one item is selected.
43
- */
44
- readonly isRequired: boolean,
45
-
46
- /** Returns whether the given value is selected. */
47
- isSelected(value: string): boolean,
48
-
49
- /** Sets the selected values. */
50
- setValue(value: string[]): void,
51
-
52
- /** Adds a value to the set of selected values. */
53
- addValue(value: string): void,
54
-
55
- /** Removes a value from the set of selected values. */
56
- removeValue(value: string): void,
57
-
58
- /** Toggles a value in the set of selected values. */
59
- toggleValue(value: string): void,
60
-
61
- /** Sets whether one of the checkboxes is invalid. */
62
- setInvalid(value: string, validation: ValidationResult): void
63
- }
64
-
65
- /**
66
- * Provides state management for a checkbox group component. Provides a name for the group,
67
- * and manages selection and focus state.
68
- */
69
- export function useCheckboxGroupState(props: CheckboxGroupProps = {}): CheckboxGroupState {
70
- let [selectedValues, setValue] = useControlledState(props.value, props.defaultValue || [], props.onChange);
71
- let [initialValues] = useState(selectedValues);
72
- let isRequired = !!props.isRequired && selectedValues.length === 0;
73
-
74
- let invalidValues = useRef(new Map<string, ValidationResult>());
75
- let validation = useFormValidationState({
76
- ...props,
77
- value: selectedValues
78
- });
79
-
80
- let isInvalid = validation.displayValidation.isInvalid;
81
- const state: CheckboxGroupState = {
82
- ...validation,
83
- value: selectedValues,
84
- defaultValue: props.defaultValue ?? initialValues,
85
- setValue(value) {
86
- if (props.isReadOnly || props.isDisabled) {
87
- return;
88
- }
89
-
90
- setValue(value);
91
- },
92
- isDisabled: props.isDisabled || false,
93
- isReadOnly: props.isReadOnly || false,
94
- isSelected(value) {
95
- return selectedValues.includes(value);
96
- },
97
- addValue(value) {
98
- if (props.isReadOnly || props.isDisabled) {
99
- return;
100
- }
101
- setValue(selectedValues => {
102
- if (!selectedValues.includes(value)) {
103
- return selectedValues.concat(value);
104
- }
105
- return selectedValues;
106
- });
107
- },
108
- removeValue(value) {
109
- if (props.isReadOnly || props.isDisabled) {
110
- return;
111
- }
112
- if (selectedValues.includes(value)) {
113
- setValue(selectedValues.filter(existingValue => existingValue !== value));
114
- }
115
- },
116
- toggleValue(value) {
117
- if (props.isReadOnly || props.isDisabled) {
118
- return;
119
- }
120
- if (selectedValues.includes(value)) {
121
- setValue(selectedValues.filter(existingValue => existingValue !== value));
122
- } else {
123
- setValue(selectedValues.concat(value));
124
- }
125
- },
126
- setInvalid(value, v) {
127
- let s = new Map(invalidValues.current);
128
- if (v.isInvalid) {
129
- s.set(value, v);
130
- } else {
131
- s.delete(value);
132
- }
133
-
134
- invalidValues.current = s;
135
- validation.updateValidation(mergeValidation(...s.values()));
136
- },
137
- validationState: props.validationState ?? (isInvalid ? 'invalid' : null),
138
- isInvalid,
139
- isRequired
140
- };
141
-
142
- return state;
143
- }