@react-aria/checkbox 3.16.4 → 3.17.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 +3 -5
- package/dist/main.js +5 -7
- package/dist/main.js.map +1 -1
- package/dist/module.js +3 -5
- package/dist/module.js.map +1 -1
- package/dist/types/src/index.d.ts +4 -0
- package/package.json +15 -21
- package/src/index.ts +5 -6
- package/dist/types.d.ts +0 -56
- package/dist/types.d.ts.map +0 -1
- package/dist/useCheckbox.main.js +0 -81
- package/dist/useCheckbox.main.js.map +0 -1
- package/dist/useCheckbox.mjs +0 -76
- package/dist/useCheckbox.module.js +0 -76
- package/dist/useCheckbox.module.js.map +0 -1
- package/dist/useCheckboxGroup.main.js +0 -69
- package/dist/useCheckboxGroup.main.js.map +0 -1
- package/dist/useCheckboxGroup.mjs +0 -64
- package/dist/useCheckboxGroup.module.js +0 -64
- package/dist/useCheckboxGroup.module.js.map +0 -1
- package/dist/useCheckboxGroupItem.main.js +0 -93
- package/dist/useCheckboxGroupItem.main.js.map +0 -1
- package/dist/useCheckboxGroupItem.mjs +0 -88
- package/dist/useCheckboxGroupItem.module.js +0 -88
- package/dist/useCheckboxGroupItem.module.js.map +0 -1
- package/dist/utils.main.js +0 -20
- package/dist/utils.main.js.map +0 -1
- package/dist/utils.mjs +0 -15
- package/dist/utils.module.js +0 -15
- package/dist/utils.module.js.map +0 -1
- package/src/useCheckbox.ts +0 -104
- package/src/useCheckboxGroup.ts +0 -81
- package/src/useCheckboxGroupItem.ts +0 -102
- package/src/utils.ts +0 -23
package/dist/import.mjs
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {useCheckbox as $
|
|
2
|
-
import {useCheckboxGroup as $
|
|
3
|
-
import {useCheckboxGroupItem as $fba3e38d5ca8983f$export$353b32fc6898d37d} from "./useCheckboxGroupItem.mjs";
|
|
1
|
+
import {useCheckbox as $e13c36517ae74384$re_export$useCheckbox} from "react-aria/useCheckbox";
|
|
2
|
+
import {useCheckboxGroup as $e13c36517ae74384$re_export$useCheckboxGroup, useCheckboxGroupItem as $e13c36517ae74384$re_export$useCheckboxGroupItem} from "react-aria/useCheckboxGroup";
|
|
4
3
|
|
|
5
4
|
/*
|
|
6
5
|
* Copyright 2020 Adobe. All rights reserved.
|
|
@@ -16,6 +15,5 @@ import {useCheckboxGroupItem as $fba3e38d5ca8983f$export$353b32fc6898d37d} from
|
|
|
16
15
|
|
|
17
16
|
|
|
18
17
|
|
|
19
|
-
|
|
20
|
-
export {$406796ff087fe49b$export$e375f10ce42261c5 as useCheckbox, $1e9fce0cfacc738b$export$49ff6f28c54f1cbe as useCheckboxGroup, $fba3e38d5ca8983f$export$353b32fc6898d37d as useCheckboxGroupItem};
|
|
18
|
+
export {$e13c36517ae74384$re_export$useCheckbox as useCheckbox, $e13c36517ae74384$re_export$useCheckboxGroup as useCheckboxGroup, $e13c36517ae74384$re_export$useCheckboxGroupItem as useCheckboxGroupItem};
|
|
21
19
|
//# sourceMappingURL=module.js.map
|
package/dist/main.js
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
var $
|
|
2
|
-
var $
|
|
3
|
-
var $07e03121d6ac83c8$exports = require("./useCheckboxGroupItem.main.js");
|
|
1
|
+
var $kpGGk$reactariauseCheckbox = require("react-aria/useCheckbox");
|
|
2
|
+
var $kpGGk$reactariauseCheckboxGroup = require("react-aria/useCheckboxGroup");
|
|
4
3
|
|
|
5
4
|
|
|
6
5
|
function $parcel$export(e, n, v, s) {
|
|
7
6
|
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
8
7
|
}
|
|
9
8
|
|
|
10
|
-
$parcel$export(module.exports, "useCheckbox", ()
|
|
11
|
-
$parcel$export(module.exports, "useCheckboxGroup", ()
|
|
12
|
-
$parcel$export(module.exports, "useCheckboxGroupItem", ()
|
|
9
|
+
$parcel$export(module.exports, "useCheckbox", function () { return $kpGGk$reactariauseCheckbox.useCheckbox; });
|
|
10
|
+
$parcel$export(module.exports, "useCheckboxGroup", function () { return $kpGGk$reactariauseCheckboxGroup.useCheckboxGroup; });
|
|
11
|
+
$parcel$export(module.exports, "useCheckboxGroupItem", function () { return $kpGGk$reactariauseCheckboxGroup.useCheckboxGroupItem; });
|
|
13
12
|
/*
|
|
14
13
|
* Copyright 2020 Adobe. All rights reserved.
|
|
15
14
|
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
@@ -24,5 +23,4 @@ $parcel$export(module.exports, "useCheckboxGroupItem", () => $07e03121d6ac83c8$e
|
|
|
24
23
|
|
|
25
24
|
|
|
26
25
|
|
|
27
|
-
|
|
28
26
|
//# sourceMappingURL=main.js.map
|
package/dist/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"
|
|
1
|
+
{"mappings":";;;;;;;;;;;AAAA;;;;;;;;;;CAUC","sources":["packages/@react-aria/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 */\nexport {useCheckbox} from 'react-aria/useCheckbox';\n\nexport {useCheckboxGroup, useCheckboxGroupItem} from 'react-aria/useCheckboxGroup';\nexport type {CheckboxAria, CheckboxProps, AriaCheckboxProps} from 'react-aria/useCheckbox';\nexport type {AriaCheckboxGroupProps, CheckboxGroupAria, AriaCheckboxGroupItemProps} from 'react-aria/useCheckboxGroup';\n"],"names":[],"version":3,"file":"main.js.map"}
|
package/dist/module.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {useCheckbox as $
|
|
2
|
-
import {useCheckboxGroup as $
|
|
3
|
-
import {useCheckboxGroupItem as $fba3e38d5ca8983f$export$353b32fc6898d37d} from "./useCheckboxGroupItem.module.js";
|
|
1
|
+
import {useCheckbox as $e13c36517ae74384$re_export$useCheckbox} from "react-aria/useCheckbox";
|
|
2
|
+
import {useCheckboxGroup as $e13c36517ae74384$re_export$useCheckboxGroup, useCheckboxGroupItem as $e13c36517ae74384$re_export$useCheckboxGroupItem} from "react-aria/useCheckboxGroup";
|
|
4
3
|
|
|
5
4
|
/*
|
|
6
5
|
* Copyright 2020 Adobe. All rights reserved.
|
|
@@ -16,6 +15,5 @@ import {useCheckboxGroupItem as $fba3e38d5ca8983f$export$353b32fc6898d37d} from
|
|
|
16
15
|
|
|
17
16
|
|
|
18
17
|
|
|
19
|
-
|
|
20
|
-
export {$406796ff087fe49b$export$e375f10ce42261c5 as useCheckbox, $1e9fce0cfacc738b$export$49ff6f28c54f1cbe as useCheckboxGroup, $fba3e38d5ca8983f$export$353b32fc6898d37d as useCheckboxGroupItem};
|
|
18
|
+
export {$e13c36517ae74384$re_export$useCheckbox as useCheckbox, $e13c36517ae74384$re_export$useCheckboxGroup as useCheckboxGroup, $e13c36517ae74384$re_export$useCheckboxGroupItem as useCheckboxGroupItem};
|
|
21
19
|
//# sourceMappingURL=module.js.map
|
package/dist/module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"
|
|
1
|
+
{"mappings":";;;AAAA;;;;;;;;;;CAUC","sources":["packages/@react-aria/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 */\nexport {useCheckbox} from 'react-aria/useCheckbox';\n\nexport {useCheckboxGroup, useCheckboxGroupItem} from 'react-aria/useCheckboxGroup';\nexport type {CheckboxAria, CheckboxProps, AriaCheckboxProps} from 'react-aria/useCheckbox';\nexport type {AriaCheckboxGroupProps, CheckboxGroupAria, AriaCheckboxGroupItemProps} from 'react-aria/useCheckboxGroup';\n"],"names":[],"version":3,"file":"module.js.map"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { useCheckbox } from 'react-aria/useCheckbox';
|
|
2
|
+
export { useCheckboxGroup, useCheckboxGroupItem } from 'react-aria/useCheckboxGroup';
|
|
3
|
+
export type { CheckboxAria, CheckboxProps, AriaCheckboxProps } from 'react-aria/useCheckbox';
|
|
4
|
+
export type { AriaCheckboxGroupProps, CheckboxGroupAria, AriaCheckboxGroupItemProps } from 'react-aria/useCheckboxGroup';
|
package/package.json
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-aria/checkbox",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.17.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
|
-
"
|
|
10
|
-
|
|
11
|
-
"./dist/types.d.ts",
|
|
12
|
-
"./
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
"
|
|
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,8 @@
|
|
|
26
26
|
"url": "https://github.com/adobe/react-spectrum"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@
|
|
30
|
-
"
|
|
31
|
-
"@react-aria/label": "^3.7.24",
|
|
32
|
-
"@react-aria/toggle": "^3.12.4",
|
|
33
|
-
"@react-aria/utils": "^3.33.0",
|
|
34
|
-
"@react-stately/checkbox": "^3.7.4",
|
|
35
|
-
"@react-stately/form": "^3.2.3",
|
|
36
|
-
"@react-stately/toggle": "^3.9.4",
|
|
37
|
-
"@react-types/checkbox": "^3.10.3",
|
|
38
|
-
"@react-types/shared": "^3.33.0",
|
|
39
|
-
"@swc/helpers": "^0.5.0"
|
|
29
|
+
"@swc/helpers": "^0.5.0",
|
|
30
|
+
"react-aria": "3.48.0"
|
|
40
31
|
},
|
|
41
32
|
"peerDependencies": {
|
|
42
33
|
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1",
|
|
@@ -45,5 +36,8 @@
|
|
|
45
36
|
"publishConfig": {
|
|
46
37
|
"access": "public"
|
|
47
38
|
},
|
|
48
|
-
"
|
|
39
|
+
"targets": {
|
|
40
|
+
"types": false
|
|
41
|
+
},
|
|
42
|
+
"gitHead": "a6999bdf494a2e9c0381a5881908328bdd22ddae"
|
|
49
43
|
}
|
package/src/index.ts
CHANGED
|
@@ -9,9 +9,8 @@
|
|
|
9
9
|
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
|
-
export
|
|
13
|
-
|
|
14
|
-
export {useCheckboxGroup} from '
|
|
15
|
-
export {
|
|
16
|
-
export type {
|
|
17
|
-
export type {CheckboxGroupAria} from './useCheckboxGroup';
|
|
12
|
+
export {useCheckbox} from 'react-aria/useCheckbox';
|
|
13
|
+
|
|
14
|
+
export {useCheckboxGroup, useCheckboxGroupItem} from 'react-aria/useCheckboxGroup';
|
|
15
|
+
export type {CheckboxAria, CheckboxProps, AriaCheckboxProps} from 'react-aria/useCheckbox';
|
|
16
|
+
export type {AriaCheckboxGroupProps, CheckboxGroupAria, AriaCheckboxGroupItemProps} from 'react-aria/useCheckboxGroup';
|
package/dist/types.d.ts
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { AriaCheckboxProps, AriaCheckboxGroupProps, AriaCheckboxGroupItemProps } from "@react-types/checkbox";
|
|
2
|
-
import { InputHTMLAttributes, LabelHTMLAttributes } from "react";
|
|
3
|
-
import { RefObject, ValidationResult, DOMAttributes } from "@react-types/shared";
|
|
4
|
-
import { ToggleState } from "@react-stately/toggle";
|
|
5
|
-
import { CheckboxGroupState } from "@react-stately/checkbox";
|
|
6
|
-
export interface CheckboxAria extends ValidationResult {
|
|
7
|
-
/** Props for the label wrapper element. */
|
|
8
|
-
labelProps: LabelHTMLAttributes<HTMLLabelElement>;
|
|
9
|
-
/** Props for the input element. */
|
|
10
|
-
inputProps: InputHTMLAttributes<HTMLInputElement>;
|
|
11
|
-
/** Whether the checkbox is selected. */
|
|
12
|
-
isSelected: boolean;
|
|
13
|
-
/** Whether the checkbox is in a pressed state. */
|
|
14
|
-
isPressed: boolean;
|
|
15
|
-
/** Whether the checkbox is disabled. */
|
|
16
|
-
isDisabled: boolean;
|
|
17
|
-
/** Whether the checkbox is read only. */
|
|
18
|
-
isReadOnly: boolean;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Provides the behavior and accessibility implementation for a checkbox component.
|
|
22
|
-
* Checkboxes allow users to select multiple items from a list of individual items, or
|
|
23
|
-
* to mark one individual item as selected.
|
|
24
|
-
* @param props - Props for the checkbox.
|
|
25
|
-
* @param state - State for the checkbox, as returned by `useToggleState`.
|
|
26
|
-
* @param inputRef - A ref for the HTML input element.
|
|
27
|
-
*/
|
|
28
|
-
export function useCheckbox(props: AriaCheckboxProps, state: ToggleState, inputRef: RefObject<HTMLInputElement | null>): CheckboxAria;
|
|
29
|
-
export interface CheckboxGroupAria extends ValidationResult {
|
|
30
|
-
/** Props for the checkbox group wrapper element. */
|
|
31
|
-
groupProps: DOMAttributes;
|
|
32
|
-
/** Props for the checkbox group's visible label (if any). */
|
|
33
|
-
labelProps: DOMAttributes;
|
|
34
|
-
/** Props for the checkbox group description element, if any. */
|
|
35
|
-
descriptionProps: DOMAttributes;
|
|
36
|
-
/** Props for the checkbox group error message element, if any. */
|
|
37
|
-
errorMessageProps: DOMAttributes;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Provides the behavior and accessibility implementation for a checkbox group component.
|
|
41
|
-
* Checkbox groups allow users to select multiple items from a list of options.
|
|
42
|
-
* @param props - Props for the checkbox group.
|
|
43
|
-
* @param state - State for the checkbox group, as returned by `useCheckboxGroupState`.
|
|
44
|
-
*/
|
|
45
|
-
export function useCheckboxGroup(props: AriaCheckboxGroupProps, state: CheckboxGroupState): CheckboxGroupAria;
|
|
46
|
-
/**
|
|
47
|
-
* Provides the behavior and accessibility implementation for a checkbox component contained within a checkbox group.
|
|
48
|
-
* Checkbox groups allow users to select multiple items from a list of options.
|
|
49
|
-
* @param props - Props for the checkbox.
|
|
50
|
-
* @param state - State for the checkbox, as returned by `useCheckboxGroupState`.
|
|
51
|
-
* @param inputRef - A ref for the HTML input element.
|
|
52
|
-
*/
|
|
53
|
-
export function useCheckboxGroupItem(props: AriaCheckboxGroupItemProps, state: CheckboxGroupState, inputRef: RefObject<HTMLInputElement | null>): CheckboxAria;
|
|
54
|
-
export type { AriaCheckboxGroupItemProps, AriaCheckboxGroupProps, AriaCheckboxProps } from '@react-types/checkbox';
|
|
55
|
-
|
|
56
|
-
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":";;;;;AAsBA,6BAA8B,SAAQ,gBAAgB;IACpD,2CAA2C;IAC3C,UAAU,EAAE,oBAAoB,gBAAgB,CAAC,CAAC;IAClD,mCAAmC;IACnC,UAAU,EAAE,oBAAoB,gBAAgB,CAAC,CAAC;IAClD,wCAAwC;IACxC,UAAU,EAAE,OAAO,CAAC;IACpB,kDAAkD;IAClD,SAAS,EAAE,OAAO,CAAC;IACnB,wCAAwC;IACxC,UAAU,EAAE,OAAO,CAAC;IACpB,yCAAyC;IACzC,UAAU,EAAE,OAAO,CAAA;CACpB;AAED;;;;;;;GAOG;AACH,4BAA4B,KAAK,EAAE,iBAAiB,EAAE,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,UAAU,gBAAgB,GAAG,IAAI,CAAC,GAAG,YAAY,CA0DpI;AEnFD,kCAAmC,SAAQ,gBAAgB;IACzD,oDAAoD;IACpD,UAAU,EAAE,aAAa,CAAC;IAC1B,6DAA6D;IAC7D,UAAU,EAAE,aAAa,CAAC;IAC1B,gEAAgE;IAChE,gBAAgB,EAAE,aAAa,CAAC;IAChC,kEAAkE;IAClE,iBAAiB,EAAE,aAAa,CAAA;CACjC;AAED;;;;;GAKG;AACH,iCAAiC,KAAK,EAAE,sBAAsB,EAAE,KAAK,EAAE,kBAAkB,GAAG,iBAAiB,CA2C5G;AC3DD;;;;;;GAMG;AACH,qCAAqC,KAAK,EAAE,0BAA0B,EAAE,KAAK,EAAE,kBAAkB,EAAE,QAAQ,EAAE,UAAU,gBAAgB,GAAG,IAAI,CAAC,GAAG,YAAY,CAyE7J;ACtFD,YAAY,EAAC,0BAA0B,EAAE,sBAAsB,EAAE,iBAAiB,EAAC,MAAM,uBAAuB,CAAC","sources":["packages/@react-aria/checkbox/src/packages/@react-aria/checkbox/src/useCheckbox.ts","packages/@react-aria/checkbox/src/packages/@react-aria/checkbox/src/utils.ts","packages/@react-aria/checkbox/src/packages/@react-aria/checkbox/src/useCheckboxGroup.ts","packages/@react-aria/checkbox/src/packages/@react-aria/checkbox/src/useCheckboxGroupItem.ts","packages/@react-aria/checkbox/src/packages/@react-aria/checkbox/src/index.ts","packages/@react-aria/checkbox/src/index.ts"],"sourcesContent":[null,null,null,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 */\nexport type {CheckboxAria} from './useCheckbox';\nexport {useCheckbox} from './useCheckbox';\nexport {useCheckboxGroup} from './useCheckboxGroup';\nexport {useCheckboxGroupItem} from './useCheckboxGroupItem';\nexport type {AriaCheckboxGroupItemProps, AriaCheckboxGroupProps, AriaCheckboxProps} from '@react-types/checkbox';\nexport type {CheckboxGroupAria} from './useCheckboxGroup';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
|
package/dist/useCheckbox.main.js
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
var $ar5WQ$react = require("react");
|
|
2
|
-
var $ar5WQ$reactariautils = require("@react-aria/utils");
|
|
3
|
-
var $ar5WQ$reactstatelyform = require("@react-stately/form");
|
|
4
|
-
var $ar5WQ$reactariaform = require("@react-aria/form");
|
|
5
|
-
var $ar5WQ$reactariainteractions = require("@react-aria/interactions");
|
|
6
|
-
var $ar5WQ$reactariatoggle = require("@react-aria/toggle");
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
function $parcel$export(e, n, v, s) {
|
|
10
|
-
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
$parcel$export(module.exports, "useCheckbox", () => $468c774d7db917b7$export$e375f10ce42261c5);
|
|
14
|
-
/*
|
|
15
|
-
* Copyright 2020 Adobe. All rights reserved.
|
|
16
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
17
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
18
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
19
|
-
*
|
|
20
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
21
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
22
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
23
|
-
* governing permissions and limitations under the License.
|
|
24
|
-
*/
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
function $468c774d7db917b7$export$e375f10ce42261c5(props, state, inputRef) {
|
|
31
|
-
// Create validation state here because it doesn't make sense to add to general useToggleState.
|
|
32
|
-
let validationState = (0, $ar5WQ$reactstatelyform.useFormValidationState)({
|
|
33
|
-
...props,
|
|
34
|
-
value: state.isSelected
|
|
35
|
-
});
|
|
36
|
-
let { isInvalid: isInvalid, validationErrors: validationErrors, validationDetails: validationDetails } = validationState.displayValidation;
|
|
37
|
-
let { labelProps: labelProps, inputProps: inputProps, isSelected: isSelected, isPressed: isPressed, isDisabled: isDisabled, isReadOnly: isReadOnly } = (0, $ar5WQ$reactariatoggle.useToggle)({
|
|
38
|
-
...props,
|
|
39
|
-
isInvalid: isInvalid
|
|
40
|
-
}, state, inputRef);
|
|
41
|
-
(0, $ar5WQ$reactariaform.useFormValidation)(props, validationState, inputRef);
|
|
42
|
-
let { isIndeterminate: isIndeterminate, isRequired: isRequired, validationBehavior: validationBehavior = 'aria' } = props;
|
|
43
|
-
(0, $ar5WQ$react.useEffect)(()=>{
|
|
44
|
-
// indeterminate is a property, but it can only be set via javascript
|
|
45
|
-
// https://css-tricks.com/indeterminate-checkboxes/
|
|
46
|
-
if (inputRef.current) inputRef.current.indeterminate = !!isIndeterminate;
|
|
47
|
-
});
|
|
48
|
-
// Reset validation state on label press for checkbox with a hidden input.
|
|
49
|
-
let { pressProps: pressProps } = (0, $ar5WQ$reactariainteractions.usePress)({
|
|
50
|
-
isDisabled: isDisabled || isReadOnly,
|
|
51
|
-
onPress () {
|
|
52
|
-
// @ts-expect-error
|
|
53
|
-
let { [(0, $ar5WQ$reactstatelyform.privateValidationStateProp)]: groupValidationState } = props;
|
|
54
|
-
let { commitValidation: commitValidation } = groupValidationState ? groupValidationState : validationState;
|
|
55
|
-
commitValidation();
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
return {
|
|
59
|
-
labelProps: (0, $ar5WQ$reactariautils.mergeProps)(labelProps, pressProps, (0, $ar5WQ$react.useMemo)(()=>({
|
|
60
|
-
// Prevent label from being focused when mouse down on it.
|
|
61
|
-
// Note, this does not prevent the input from being focused in the `click` event.
|
|
62
|
-
onMouseDown: (e)=>e.preventDefault()
|
|
63
|
-
}), [])),
|
|
64
|
-
inputProps: {
|
|
65
|
-
...inputProps,
|
|
66
|
-
checked: isSelected,
|
|
67
|
-
'aria-required': isRequired && validationBehavior === 'aria' || undefined,
|
|
68
|
-
required: isRequired && validationBehavior === 'native'
|
|
69
|
-
},
|
|
70
|
-
isSelected: isSelected,
|
|
71
|
-
isPressed: isPressed,
|
|
72
|
-
isDisabled: isDisabled,
|
|
73
|
-
isReadOnly: isReadOnly,
|
|
74
|
-
isInvalid: isInvalid,
|
|
75
|
-
validationErrors: validationErrors,
|
|
76
|
-
validationDetails: validationDetails
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
//# sourceMappingURL=useCheckbox.main.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;AAmCM,SAAS,0CAAY,KAAwB,EAAE,KAAkB,EAAE,QAA4C;IACpH,+FAA+F;IAC/F,IAAI,kBAAkB,CAAA,GAAA,8CAAqB,EAAE;QAAC,GAAG,KAAK;QAAE,OAAO,MAAM,UAAU;IAAA;IAC/E,IAAI,aAAC,SAAS,oBAAE,gBAAgB,qBAAE,iBAAiB,EAAC,GAAG,gBAAgB,iBAAiB;IACxF,IAAI,cAAC,UAAU,cAAE,UAAU,cAAE,UAAU,aAAE,SAAS,cAAE,UAAU,cAAE,UAAU,EAAC,GAAG,CAAA,GAAA,gCAAQ,EAAE;QACtF,GAAG,KAAK;mBACR;IACF,GAAG,OAAO;IAEV,CAAA,GAAA,sCAAgB,EAAE,OAAO,iBAAiB;IAE1C,IAAI,mBAAC,eAAe,cAAE,UAAU,sBAAE,qBAAqB,QAAO,GAAG;IACjE,CAAA,GAAA,sBAAQ,EAAE;QACR,qEAAqE;QACrE,mDAAmD;QACnD,IAAI,SAAS,OAAO,EAClB,SAAS,OAAO,CAAC,aAAa,GAAG,CAAC,CAAC;IAEvC;IAEA,0EAA0E;IAC1E,IAAI,cAAC,UAAU,EAAC,GAAG,CAAA,GAAA,qCAAO,EAAE;QAC1B,YAAY,cAAc;QAC1B;YACE,mBAAmB;YACnB,IAAI,EAAC,CAAC,CAAA,GAAA,kDAAyB,EAAE,EAAE,oBAAoB,EAAC,GAAG;YAE3D,IAAI,oBAAC,gBAAgB,EAAC,GAAG,uBACvB,uBACA;YAEF;QACF;IACF;IAEA,OAAO;QACL,YAAY,CAAA,GAAA,gCAAS,EACnB,YACA,YACA,CAAA,GAAA,oBAAM,EAAE,IAAO,CAAA;gBACb,0DAA0D;gBAC1D,iFAAiF;gBACjF,aAAa,CAAA,IAAK,EAAE,cAAc;YACpC,CAAA,GAAI,EAAE;QACR,YAAY;YACV,GAAG,UAAU;YACb,SAAS;YACT,iBAAiB,AAAC,cAAc,uBAAuB,UAAW;YAClE,UAAU,cAAc,uBAAuB;QACjD;oBACA;mBACA;oBACA;oBACA;mBACA;0BACA;2BACA;IACF;AACF","sources":["packages/@react-aria/checkbox/src/useCheckbox.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 {AriaCheckboxProps} from '@react-types/checkbox';\nimport {InputHTMLAttributes, LabelHTMLAttributes, useEffect, useMemo} from 'react';\nimport {mergeProps} from '@react-aria/utils';\nimport {privateValidationStateProp, useFormValidationState} from '@react-stately/form';\nimport {RefObject, ValidationResult} from '@react-types/shared';\nimport {ToggleState} from '@react-stately/toggle';\nimport {useFormValidation} from '@react-aria/form';\nimport {usePress} from '@react-aria/interactions';\nimport {useToggle} from '@react-aria/toggle';\n\nexport interface CheckboxAria extends ValidationResult {\n /** Props for the label wrapper element. */\n labelProps: LabelHTMLAttributes<HTMLLabelElement>,\n /** Props for the input element. */\n inputProps: InputHTMLAttributes<HTMLInputElement>,\n /** Whether the checkbox is selected. */\n isSelected: boolean,\n /** Whether the checkbox is in a pressed state. */\n isPressed: boolean,\n /** Whether the checkbox is disabled. */\n isDisabled: boolean,\n /** Whether the checkbox is read only. */\n isReadOnly: boolean\n}\n\n/**\n * Provides the behavior and accessibility implementation for a checkbox component.\n * Checkboxes allow users to select multiple items from a list of individual items, or\n * to mark one individual item as selected.\n * @param props - Props for the checkbox.\n * @param state - State for the checkbox, as returned by `useToggleState`.\n * @param inputRef - A ref for the HTML input element.\n */\nexport function useCheckbox(props: AriaCheckboxProps, state: ToggleState, inputRef: RefObject<HTMLInputElement | null>): CheckboxAria {\n // Create validation state here because it doesn't make sense to add to general useToggleState.\n let validationState = useFormValidationState({...props, value: state.isSelected});\n let {isInvalid, validationErrors, validationDetails} = validationState.displayValidation;\n let {labelProps, inputProps, isSelected, isPressed, isDisabled, isReadOnly} = useToggle({\n ...props,\n isInvalid\n }, state, inputRef);\n\n useFormValidation(props, validationState, inputRef);\n\n let {isIndeterminate, isRequired, validationBehavior = 'aria'} = props;\n useEffect(() => {\n // indeterminate is a property, but it can only be set via javascript\n // https://css-tricks.com/indeterminate-checkboxes/\n if (inputRef.current) {\n inputRef.current.indeterminate = !!isIndeterminate;\n }\n });\n\n // Reset validation state on label press for checkbox with a hidden input.\n let {pressProps} = usePress({\n isDisabled: isDisabled || isReadOnly,\n onPress() {\n // @ts-expect-error\n let {[privateValidationStateProp]: groupValidationState} = props;\n\n let {commitValidation} = groupValidationState\n ? groupValidationState\n : validationState;\n\n commitValidation();\n }\n });\n\n return {\n labelProps: mergeProps(\n labelProps,\n pressProps,\n useMemo(() => ({\n // Prevent label from being focused when mouse down on it.\n // Note, this does not prevent the input from being focused in the `click` event.\n onMouseDown: e => e.preventDefault()\n }), [])),\n inputProps: {\n ...inputProps,\n checked: isSelected,\n 'aria-required': (isRequired && validationBehavior === 'aria') || undefined,\n required: isRequired && validationBehavior === 'native'\n },\n isSelected,\n isPressed,\n isDisabled,\n isReadOnly,\n isInvalid,\n validationErrors,\n validationDetails\n };\n}\n"],"names":[],"version":3,"file":"useCheckbox.main.js.map"}
|
package/dist/useCheckbox.mjs
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import {useEffect as $jNP0e$useEffect, useMemo as $jNP0e$useMemo} from "react";
|
|
2
|
-
import {mergeProps as $jNP0e$mergeProps} from "@react-aria/utils";
|
|
3
|
-
import {useFormValidationState as $jNP0e$useFormValidationState, privateValidationStateProp as $jNP0e$privateValidationStateProp} from "@react-stately/form";
|
|
4
|
-
import {useFormValidation as $jNP0e$useFormValidation} from "@react-aria/form";
|
|
5
|
-
import {usePress as $jNP0e$usePress} from "@react-aria/interactions";
|
|
6
|
-
import {useToggle as $jNP0e$useToggle} from "@react-aria/toggle";
|
|
7
|
-
|
|
8
|
-
/*
|
|
9
|
-
* Copyright 2020 Adobe. All rights reserved.
|
|
10
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
11
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
12
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
13
|
-
*
|
|
14
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
15
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
16
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
17
|
-
* governing permissions and limitations under the License.
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
function $406796ff087fe49b$export$e375f10ce42261c5(props, state, inputRef) {
|
|
25
|
-
// Create validation state here because it doesn't make sense to add to general useToggleState.
|
|
26
|
-
let validationState = (0, $jNP0e$useFormValidationState)({
|
|
27
|
-
...props,
|
|
28
|
-
value: state.isSelected
|
|
29
|
-
});
|
|
30
|
-
let { isInvalid: isInvalid, validationErrors: validationErrors, validationDetails: validationDetails } = validationState.displayValidation;
|
|
31
|
-
let { labelProps: labelProps, inputProps: inputProps, isSelected: isSelected, isPressed: isPressed, isDisabled: isDisabled, isReadOnly: isReadOnly } = (0, $jNP0e$useToggle)({
|
|
32
|
-
...props,
|
|
33
|
-
isInvalid: isInvalid
|
|
34
|
-
}, state, inputRef);
|
|
35
|
-
(0, $jNP0e$useFormValidation)(props, validationState, inputRef);
|
|
36
|
-
let { isIndeterminate: isIndeterminate, isRequired: isRequired, validationBehavior: validationBehavior = 'aria' } = props;
|
|
37
|
-
(0, $jNP0e$useEffect)(()=>{
|
|
38
|
-
// indeterminate is a property, but it can only be set via javascript
|
|
39
|
-
// https://css-tricks.com/indeterminate-checkboxes/
|
|
40
|
-
if (inputRef.current) inputRef.current.indeterminate = !!isIndeterminate;
|
|
41
|
-
});
|
|
42
|
-
// Reset validation state on label press for checkbox with a hidden input.
|
|
43
|
-
let { pressProps: pressProps } = (0, $jNP0e$usePress)({
|
|
44
|
-
isDisabled: isDisabled || isReadOnly,
|
|
45
|
-
onPress () {
|
|
46
|
-
// @ts-expect-error
|
|
47
|
-
let { [(0, $jNP0e$privateValidationStateProp)]: groupValidationState } = props;
|
|
48
|
-
let { commitValidation: commitValidation } = groupValidationState ? groupValidationState : validationState;
|
|
49
|
-
commitValidation();
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
return {
|
|
53
|
-
labelProps: (0, $jNP0e$mergeProps)(labelProps, pressProps, (0, $jNP0e$useMemo)(()=>({
|
|
54
|
-
// Prevent label from being focused when mouse down on it.
|
|
55
|
-
// Note, this does not prevent the input from being focused in the `click` event.
|
|
56
|
-
onMouseDown: (e)=>e.preventDefault()
|
|
57
|
-
}), [])),
|
|
58
|
-
inputProps: {
|
|
59
|
-
...inputProps,
|
|
60
|
-
checked: isSelected,
|
|
61
|
-
'aria-required': isRequired && validationBehavior === 'aria' || undefined,
|
|
62
|
-
required: isRequired && validationBehavior === 'native'
|
|
63
|
-
},
|
|
64
|
-
isSelected: isSelected,
|
|
65
|
-
isPressed: isPressed,
|
|
66
|
-
isDisabled: isDisabled,
|
|
67
|
-
isReadOnly: isReadOnly,
|
|
68
|
-
isInvalid: isInvalid,
|
|
69
|
-
validationErrors: validationErrors,
|
|
70
|
-
validationDetails: validationDetails
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
export {$406796ff087fe49b$export$e375f10ce42261c5 as useCheckbox};
|
|
76
|
-
//# sourceMappingURL=useCheckbox.module.js.map
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import {useEffect as $jNP0e$useEffect, useMemo as $jNP0e$useMemo} from "react";
|
|
2
|
-
import {mergeProps as $jNP0e$mergeProps} from "@react-aria/utils";
|
|
3
|
-
import {useFormValidationState as $jNP0e$useFormValidationState, privateValidationStateProp as $jNP0e$privateValidationStateProp} from "@react-stately/form";
|
|
4
|
-
import {useFormValidation as $jNP0e$useFormValidation} from "@react-aria/form";
|
|
5
|
-
import {usePress as $jNP0e$usePress} from "@react-aria/interactions";
|
|
6
|
-
import {useToggle as $jNP0e$useToggle} from "@react-aria/toggle";
|
|
7
|
-
|
|
8
|
-
/*
|
|
9
|
-
* Copyright 2020 Adobe. All rights reserved.
|
|
10
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
11
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
12
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
13
|
-
*
|
|
14
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
15
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
16
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
17
|
-
* governing permissions and limitations under the License.
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
function $406796ff087fe49b$export$e375f10ce42261c5(props, state, inputRef) {
|
|
25
|
-
// Create validation state here because it doesn't make sense to add to general useToggleState.
|
|
26
|
-
let validationState = (0, $jNP0e$useFormValidationState)({
|
|
27
|
-
...props,
|
|
28
|
-
value: state.isSelected
|
|
29
|
-
});
|
|
30
|
-
let { isInvalid: isInvalid, validationErrors: validationErrors, validationDetails: validationDetails } = validationState.displayValidation;
|
|
31
|
-
let { labelProps: labelProps, inputProps: inputProps, isSelected: isSelected, isPressed: isPressed, isDisabled: isDisabled, isReadOnly: isReadOnly } = (0, $jNP0e$useToggle)({
|
|
32
|
-
...props,
|
|
33
|
-
isInvalid: isInvalid
|
|
34
|
-
}, state, inputRef);
|
|
35
|
-
(0, $jNP0e$useFormValidation)(props, validationState, inputRef);
|
|
36
|
-
let { isIndeterminate: isIndeterminate, isRequired: isRequired, validationBehavior: validationBehavior = 'aria' } = props;
|
|
37
|
-
(0, $jNP0e$useEffect)(()=>{
|
|
38
|
-
// indeterminate is a property, but it can only be set via javascript
|
|
39
|
-
// https://css-tricks.com/indeterminate-checkboxes/
|
|
40
|
-
if (inputRef.current) inputRef.current.indeterminate = !!isIndeterminate;
|
|
41
|
-
});
|
|
42
|
-
// Reset validation state on label press for checkbox with a hidden input.
|
|
43
|
-
let { pressProps: pressProps } = (0, $jNP0e$usePress)({
|
|
44
|
-
isDisabled: isDisabled || isReadOnly,
|
|
45
|
-
onPress () {
|
|
46
|
-
// @ts-expect-error
|
|
47
|
-
let { [(0, $jNP0e$privateValidationStateProp)]: groupValidationState } = props;
|
|
48
|
-
let { commitValidation: commitValidation } = groupValidationState ? groupValidationState : validationState;
|
|
49
|
-
commitValidation();
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
return {
|
|
53
|
-
labelProps: (0, $jNP0e$mergeProps)(labelProps, pressProps, (0, $jNP0e$useMemo)(()=>({
|
|
54
|
-
// Prevent label from being focused when mouse down on it.
|
|
55
|
-
// Note, this does not prevent the input from being focused in the `click` event.
|
|
56
|
-
onMouseDown: (e)=>e.preventDefault()
|
|
57
|
-
}), [])),
|
|
58
|
-
inputProps: {
|
|
59
|
-
...inputProps,
|
|
60
|
-
checked: isSelected,
|
|
61
|
-
'aria-required': isRequired && validationBehavior === 'aria' || undefined,
|
|
62
|
-
required: isRequired && validationBehavior === 'native'
|
|
63
|
-
},
|
|
64
|
-
isSelected: isSelected,
|
|
65
|
-
isPressed: isPressed,
|
|
66
|
-
isDisabled: isDisabled,
|
|
67
|
-
isReadOnly: isReadOnly,
|
|
68
|
-
isInvalid: isInvalid,
|
|
69
|
-
validationErrors: validationErrors,
|
|
70
|
-
validationDetails: validationDetails
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
export {$406796ff087fe49b$export$e375f10ce42261c5 as useCheckbox};
|
|
76
|
-
//# sourceMappingURL=useCheckbox.module.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":";;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;AAmCM,SAAS,0CAAY,KAAwB,EAAE,KAAkB,EAAE,QAA4C;IACpH,+FAA+F;IAC/F,IAAI,kBAAkB,CAAA,GAAA,6BAAqB,EAAE;QAAC,GAAG,KAAK;QAAE,OAAO,MAAM,UAAU;IAAA;IAC/E,IAAI,aAAC,SAAS,oBAAE,gBAAgB,qBAAE,iBAAiB,EAAC,GAAG,gBAAgB,iBAAiB;IACxF,IAAI,cAAC,UAAU,cAAE,UAAU,cAAE,UAAU,aAAE,SAAS,cAAE,UAAU,cAAE,UAAU,EAAC,GAAG,CAAA,GAAA,gBAAQ,EAAE;QACtF,GAAG,KAAK;mBACR;IACF,GAAG,OAAO;IAEV,CAAA,GAAA,wBAAgB,EAAE,OAAO,iBAAiB;IAE1C,IAAI,mBAAC,eAAe,cAAE,UAAU,sBAAE,qBAAqB,QAAO,GAAG;IACjE,CAAA,GAAA,gBAAQ,EAAE;QACR,qEAAqE;QACrE,mDAAmD;QACnD,IAAI,SAAS,OAAO,EAClB,SAAS,OAAO,CAAC,aAAa,GAAG,CAAC,CAAC;IAEvC;IAEA,0EAA0E;IAC1E,IAAI,cAAC,UAAU,EAAC,GAAG,CAAA,GAAA,eAAO,EAAE;QAC1B,YAAY,cAAc;QAC1B;YACE,mBAAmB;YACnB,IAAI,EAAC,CAAC,CAAA,GAAA,iCAAyB,EAAE,EAAE,oBAAoB,EAAC,GAAG;YAE3D,IAAI,oBAAC,gBAAgB,EAAC,GAAG,uBACvB,uBACA;YAEF;QACF;IACF;IAEA,OAAO;QACL,YAAY,CAAA,GAAA,iBAAS,EACnB,YACA,YACA,CAAA,GAAA,cAAM,EAAE,IAAO,CAAA;gBACb,0DAA0D;gBAC1D,iFAAiF;gBACjF,aAAa,CAAA,IAAK,EAAE,cAAc;YACpC,CAAA,GAAI,EAAE;QACR,YAAY;YACV,GAAG,UAAU;YACb,SAAS;YACT,iBAAiB,AAAC,cAAc,uBAAuB,UAAW;YAClE,UAAU,cAAc,uBAAuB;QACjD;oBACA;mBACA;oBACA;oBACA;mBACA;0BACA;2BACA;IACF;AACF","sources":["packages/@react-aria/checkbox/src/useCheckbox.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 {AriaCheckboxProps} from '@react-types/checkbox';\nimport {InputHTMLAttributes, LabelHTMLAttributes, useEffect, useMemo} from 'react';\nimport {mergeProps} from '@react-aria/utils';\nimport {privateValidationStateProp, useFormValidationState} from '@react-stately/form';\nimport {RefObject, ValidationResult} from '@react-types/shared';\nimport {ToggleState} from '@react-stately/toggle';\nimport {useFormValidation} from '@react-aria/form';\nimport {usePress} from '@react-aria/interactions';\nimport {useToggle} from '@react-aria/toggle';\n\nexport interface CheckboxAria extends ValidationResult {\n /** Props for the label wrapper element. */\n labelProps: LabelHTMLAttributes<HTMLLabelElement>,\n /** Props for the input element. */\n inputProps: InputHTMLAttributes<HTMLInputElement>,\n /** Whether the checkbox is selected. */\n isSelected: boolean,\n /** Whether the checkbox is in a pressed state. */\n isPressed: boolean,\n /** Whether the checkbox is disabled. */\n isDisabled: boolean,\n /** Whether the checkbox is read only. */\n isReadOnly: boolean\n}\n\n/**\n * Provides the behavior and accessibility implementation for a checkbox component.\n * Checkboxes allow users to select multiple items from a list of individual items, or\n * to mark one individual item as selected.\n * @param props - Props for the checkbox.\n * @param state - State for the checkbox, as returned by `useToggleState`.\n * @param inputRef - A ref for the HTML input element.\n */\nexport function useCheckbox(props: AriaCheckboxProps, state: ToggleState, inputRef: RefObject<HTMLInputElement | null>): CheckboxAria {\n // Create validation state here because it doesn't make sense to add to general useToggleState.\n let validationState = useFormValidationState({...props, value: state.isSelected});\n let {isInvalid, validationErrors, validationDetails} = validationState.displayValidation;\n let {labelProps, inputProps, isSelected, isPressed, isDisabled, isReadOnly} = useToggle({\n ...props,\n isInvalid\n }, state, inputRef);\n\n useFormValidation(props, validationState, inputRef);\n\n let {isIndeterminate, isRequired, validationBehavior = 'aria'} = props;\n useEffect(() => {\n // indeterminate is a property, but it can only be set via javascript\n // https://css-tricks.com/indeterminate-checkboxes/\n if (inputRef.current) {\n inputRef.current.indeterminate = !!isIndeterminate;\n }\n });\n\n // Reset validation state on label press for checkbox with a hidden input.\n let {pressProps} = usePress({\n isDisabled: isDisabled || isReadOnly,\n onPress() {\n // @ts-expect-error\n let {[privateValidationStateProp]: groupValidationState} = props;\n\n let {commitValidation} = groupValidationState\n ? groupValidationState\n : validationState;\n\n commitValidation();\n }\n });\n\n return {\n labelProps: mergeProps(\n labelProps,\n pressProps,\n useMemo(() => ({\n // Prevent label from being focused when mouse down on it.\n // Note, this does not prevent the input from being focused in the `click` event.\n onMouseDown: e => e.preventDefault()\n }), [])),\n inputProps: {\n ...inputProps,\n checked: isSelected,\n 'aria-required': (isRequired && validationBehavior === 'aria') || undefined,\n required: isRequired && validationBehavior === 'native'\n },\n isSelected,\n isPressed,\n isDisabled,\n isReadOnly,\n isInvalid,\n validationErrors,\n validationDetails\n };\n}\n"],"names":[],"version":3,"file":"useCheckbox.module.js.map"}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
var $64fc3370e682155f$exports = require("./utils.main.js");
|
|
2
|
-
var $6d1SX$reactariautils = require("@react-aria/utils");
|
|
3
|
-
var $6d1SX$reactarialabel = require("@react-aria/label");
|
|
4
|
-
var $6d1SX$reactariainteractions = require("@react-aria/interactions");
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
function $parcel$export(e, n, v, s) {
|
|
8
|
-
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
$parcel$export(module.exports, "useCheckboxGroup", () => $253685172d17db7d$export$49ff6f28c54f1cbe);
|
|
12
|
-
/*
|
|
13
|
-
* Copyright 2020 Adobe. All rights reserved.
|
|
14
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
15
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
16
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
17
|
-
*
|
|
18
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
19
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
20
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
21
|
-
* governing permissions and limitations under the License.
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
function $253685172d17db7d$export$49ff6f28c54f1cbe(props, state) {
|
|
27
|
-
let { isDisabled: isDisabled, name: name, form: form, validationBehavior: validationBehavior = 'aria' } = props;
|
|
28
|
-
let { isInvalid: isInvalid, validationErrors: validationErrors, validationDetails: validationDetails } = state.displayValidation;
|
|
29
|
-
let { labelProps: labelProps, fieldProps: fieldProps, descriptionProps: descriptionProps, errorMessageProps: errorMessageProps } = (0, $6d1SX$reactarialabel.useField)({
|
|
30
|
-
...props,
|
|
31
|
-
// Checkbox group is not an HTML input element so it
|
|
32
|
-
// shouldn't be labeled by a <label> element.
|
|
33
|
-
labelElementType: 'span',
|
|
34
|
-
isInvalid: isInvalid,
|
|
35
|
-
errorMessage: props.errorMessage || validationErrors
|
|
36
|
-
});
|
|
37
|
-
(0, $64fc3370e682155f$exports.checkboxGroupData).set(state, {
|
|
38
|
-
name: name,
|
|
39
|
-
form: form,
|
|
40
|
-
descriptionId: descriptionProps.id,
|
|
41
|
-
errorMessageId: errorMessageProps.id,
|
|
42
|
-
validationBehavior: validationBehavior
|
|
43
|
-
});
|
|
44
|
-
let domProps = (0, $6d1SX$reactariautils.filterDOMProps)(props, {
|
|
45
|
-
labelable: true
|
|
46
|
-
});
|
|
47
|
-
let { focusWithinProps: focusWithinProps } = (0, $6d1SX$reactariainteractions.useFocusWithin)({
|
|
48
|
-
onBlurWithin: props.onBlur,
|
|
49
|
-
onFocusWithin: props.onFocus,
|
|
50
|
-
onFocusWithinChange: props.onFocusChange
|
|
51
|
-
});
|
|
52
|
-
return {
|
|
53
|
-
groupProps: (0, $6d1SX$reactariautils.mergeProps)(domProps, {
|
|
54
|
-
role: 'group',
|
|
55
|
-
'aria-disabled': isDisabled || undefined,
|
|
56
|
-
...fieldProps,
|
|
57
|
-
...focusWithinProps
|
|
58
|
-
}),
|
|
59
|
-
labelProps: labelProps,
|
|
60
|
-
descriptionProps: descriptionProps,
|
|
61
|
-
errorMessageProps: errorMessageProps,
|
|
62
|
-
isInvalid: isInvalid,
|
|
63
|
-
validationErrors: validationErrors,
|
|
64
|
-
validationDetails: validationDetails
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
//# sourceMappingURL=useCheckboxGroup.main.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;AA2BM,SAAS,0CAAiB,KAA6B,EAAE,KAAyB;IACvF,IAAI,cAAC,UAAU,QAAE,IAAI,QAAE,IAAI,sBAAE,qBAAqB,QAAO,GAAG;IAC5D,IAAI,aAAC,SAAS,oBAAE,gBAAgB,qBAAE,iBAAiB,EAAC,GAAG,MAAM,iBAAiB;IAE9E,IAAI,cAAC,UAAU,cAAE,UAAU,oBAAE,gBAAgB,qBAAE,iBAAiB,EAAC,GAAG,CAAA,GAAA,8BAAO,EAAE;QAC3E,GAAG,KAAK;QACR,oDAAoD;QACpD,6CAA6C;QAC7C,kBAAkB;mBAClB;QACA,cAAc,MAAM,YAAY,IAAI;IACtC;IAEA,CAAA,GAAA,2CAAgB,EAAE,GAAG,CAAC,OAAO;cAC3B;cACA;QACA,eAAe,iBAAiB,EAAE;QAClC,gBAAgB,kBAAkB,EAAE;4BACpC;IACF;IAEA,IAAI,WAAW,CAAA,GAAA,oCAAa,EAAE,OAAO;QAAC,WAAW;IAAI;IAErD,IAAI,oBAAC,gBAAgB,EAAC,GAAG,CAAA,GAAA,2CAAa,EAAE;QACtC,cAAc,MAAM,MAAM;QAC1B,eAAe,MAAM,OAAO;QAC5B,qBAAqB,MAAM,aAAa;IAC1C;IAEA,OAAO;QACL,YAAY,CAAA,GAAA,gCAAS,EAAE,UAAU;YAC/B,MAAM;YACN,iBAAiB,cAAc;YAC/B,GAAG,UAAU;YACb,GAAG,gBAAgB;QACrB;oBACA;0BACA;2BACA;mBACA;0BACA;2BACA;IACF;AACF","sources":["packages/@react-aria/checkbox/src/useCheckboxGroup.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 {AriaCheckboxGroupProps} from '@react-types/checkbox';\nimport {checkboxGroupData} from './utils';\nimport {CheckboxGroupState} from '@react-stately/checkbox';\nimport {DOMAttributes, ValidationResult} from '@react-types/shared';\nimport {filterDOMProps, mergeProps} from '@react-aria/utils';\nimport {useField} from '@react-aria/label';\nimport {useFocusWithin} from '@react-aria/interactions';\n\nexport interface CheckboxGroupAria extends ValidationResult {\n /** Props for the checkbox group wrapper element. */\n groupProps: DOMAttributes,\n /** Props for the checkbox group's visible label (if any). */\n labelProps: DOMAttributes,\n /** Props for the checkbox group description element, if any. */\n descriptionProps: DOMAttributes,\n /** Props for the checkbox group error message element, if any. */\n errorMessageProps: DOMAttributes\n}\n\n/**\n * Provides the behavior and accessibility implementation for a checkbox group component.\n * Checkbox groups allow users to select multiple items from a list of options.\n * @param props - Props for the checkbox group.\n * @param state - State for the checkbox group, as returned by `useCheckboxGroupState`.\n */\nexport function useCheckboxGroup(props: AriaCheckboxGroupProps, state: CheckboxGroupState): CheckboxGroupAria {\n let {isDisabled, name, form, validationBehavior = 'aria'} = props;\n let {isInvalid, validationErrors, validationDetails} = state.displayValidation;\n\n let {labelProps, fieldProps, descriptionProps, errorMessageProps} = useField({\n ...props,\n // Checkbox group is not an HTML input element so it\n // shouldn't be labeled by a <label> element.\n labelElementType: 'span',\n isInvalid,\n errorMessage: props.errorMessage || validationErrors\n });\n\n checkboxGroupData.set(state, {\n name,\n form,\n descriptionId: descriptionProps.id,\n errorMessageId: errorMessageProps.id,\n validationBehavior\n });\n\n let domProps = filterDOMProps(props, {labelable: true});\n\n let {focusWithinProps} = useFocusWithin({\n onBlurWithin: props.onBlur,\n onFocusWithin: props.onFocus,\n onFocusWithinChange: props.onFocusChange\n });\n\n return {\n groupProps: mergeProps(domProps, {\n role: 'group',\n 'aria-disabled': isDisabled || undefined,\n ...fieldProps,\n ...focusWithinProps\n }),\n labelProps,\n descriptionProps,\n errorMessageProps,\n isInvalid,\n validationErrors,\n validationDetails\n };\n}\n"],"names":[],"version":3,"file":"useCheckboxGroup.main.js.map"}
|