@react-aria/label 3.0.0-nightly-641446f65-240905

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/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # @react-aria/label
2
+
3
+ This package is part of [react-spectrum](https://github.com/adobe/react-spectrum). See the repo for more details.
@@ -0,0 +1,19 @@
1
+ import {useField as $2baaea4c71418dea$export$294aa081a6c6f55d} from "./useField.mjs";
2
+ import {useLabel as $d191a55c9702f145$export$8467354a121f1b9f} from "./useLabel.mjs";
3
+
4
+ /*
5
+ * Copyright 2020 Adobe. All rights reserved.
6
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License. You may obtain a copy
8
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software distributed under
11
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
12
+ * OF ANY KIND, either express or implied. See the License for the specific language
13
+ * governing permissions and limitations under the License.
14
+ */
15
+
16
+
17
+
18
+ export {$2baaea4c71418dea$export$294aa081a6c6f55d as useField, $d191a55c9702f145$export$8467354a121f1b9f as useLabel};
19
+ //# sourceMappingURL=module.js.map
package/dist/main.js ADDED
@@ -0,0 +1,25 @@
1
+ var $50e2f39368b9c636$exports = require("./useField.main.js");
2
+ var $ce7359c25a7dec1c$exports = require("./useLabel.main.js");
3
+
4
+
5
+ function $parcel$export(e, n, v, s) {
6
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
7
+ }
8
+
9
+ $parcel$export(module.exports, "useField", () => $50e2f39368b9c636$exports.useField);
10
+ $parcel$export(module.exports, "useLabel", () => $ce7359c25a7dec1c$exports.useLabel);
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
+
25
+ //# sourceMappingURL=main.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC","sources":["packages/@react-aria/label/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 type {AriaFieldProps, FieldAria} from './useField';\nexport type {LabelAriaProps, LabelAria} from './useLabel';\n\nexport {useField} from './useField';\nexport {useLabel} from './useLabel';\n"],"names":[],"version":3,"file":"main.js.map"}
package/dist/module.js ADDED
@@ -0,0 +1,19 @@
1
+ import {useField as $2baaea4c71418dea$export$294aa081a6c6f55d} from "./useField.module.js";
2
+ import {useLabel as $d191a55c9702f145$export$8467354a121f1b9f} from "./useLabel.module.js";
3
+
4
+ /*
5
+ * Copyright 2020 Adobe. All rights reserved.
6
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License. You may obtain a copy
8
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software distributed under
11
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
12
+ * OF ANY KIND, either express or implied. See the License for the specific language
13
+ * governing permissions and limitations under the License.
14
+ */
15
+
16
+
17
+
18
+ export {$2baaea4c71418dea$export$294aa081a6c6f55d as useField, $d191a55c9702f145$export$8467354a121f1b9f as useLabel};
19
+ //# sourceMappingURL=module.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;AAAA;;;;;;;;;;CAUC","sources":["packages/@react-aria/label/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 type {AriaFieldProps, FieldAria} from './useField';\nexport type {LabelAriaProps, LabelAria} from './useLabel';\n\nexport {useField} from './useField';\nexport {useLabel} from './useLabel';\n"],"names":[],"version":3,"file":"module.js.map"}
@@ -0,0 +1,37 @@
1
+ import { AriaLabelingProps, DOMAttributes, DOMProps, LabelableProps, HelpTextProps, Validation } from "@react-types/shared";
2
+ import { ElementType, LabelHTMLAttributes } from "react";
3
+ export interface LabelAriaProps extends LabelableProps, DOMProps, AriaLabelingProps {
4
+ /**
5
+ * The HTML element used to render the label, e.g. 'label', or 'span'.
6
+ * @default 'label'
7
+ */
8
+ labelElementType?: ElementType;
9
+ }
10
+ export interface LabelAria {
11
+ /** Props to apply to the label container element. */
12
+ labelProps: DOMAttributes | LabelHTMLAttributes<HTMLLabelElement>;
13
+ /** Props to apply to the field container element being labeled. */
14
+ fieldProps: AriaLabelingProps & DOMProps;
15
+ }
16
+ /**
17
+ * Provides the accessibility implementation for labels and their associated elements.
18
+ * Labels provide context for user inputs.
19
+ * @param props - The props for labels and fields.
20
+ */
21
+ export function useLabel(props: LabelAriaProps): LabelAria;
22
+ export interface AriaFieldProps extends LabelAriaProps, HelpTextProps, Omit<Validation<any>, 'isRequired'> {
23
+ }
24
+ export interface FieldAria extends LabelAria {
25
+ /** Props for the description element, if any. */
26
+ descriptionProps: DOMAttributes;
27
+ /** Props for the error message element, if any. */
28
+ errorMessageProps: DOMAttributes;
29
+ }
30
+ /**
31
+ * Provides the accessibility implementation for input fields.
32
+ * Fields accept user input, gain context from their label, and may display a description or error message.
33
+ * @param props - Props for the Field.
34
+ */
35
+ export function useField(props: AriaFieldProps): FieldAria;
36
+
37
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"mappings":";;AAgBA,+BAAgC,SAAQ,cAAc,EAAE,QAAQ,EAAE,iBAAiB;IACjF;;;OAGG;IACH,gBAAgB,CAAC,EAAE,WAAW,CAAA;CAC/B;AAED;IACE,qDAAqD;IACrD,UAAU,EAAE,aAAa,GAAG,oBAAoB,gBAAgB,CAAC,CAAC;IAClE,mEAAmE;IACnE,UAAU,EAAE,iBAAiB,GAAG,QAAQ,CAAA;CACzC;AAED;;;;GAIG;AACH,yBAAyB,KAAK,EAAE,cAAc,GAAG,SAAS,CAgCzD;ACpDD,+BAAgC,SAAQ,cAAc,EAAE,aAAa,EAAE,IAAI,CAAC,WAAW,GAAG,CAAC,EAAE,YAAY,CAAC;CAAG;AAE7G,0BAA2B,SAAQ,SAAS;IAC1C,iDAAiD;IACjD,gBAAgB,EAAE,aAAa,CAAC;IAChC,mDAAmD;IACnD,iBAAiB,EAAE,aAAa,CAAA;CACjC;AAED;;;;GAIG;AACH,yBAAyB,KAAK,EAAE,cAAc,GAAG,SAAS,CA0BzD","sources":["packages/@react-aria/label/src/packages/@react-aria/label/src/useLabel.ts","packages/@react-aria/label/src/packages/@react-aria/label/src/useField.ts","packages/@react-aria/label/src/packages/@react-aria/label/src/index.ts","packages/@react-aria/label/src/index.ts"],"sourcesContent":[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 */\n\nexport type {AriaFieldProps, FieldAria} from './useField';\nexport type {LabelAriaProps, LabelAria} from './useLabel';\n\nexport {useField} from './useField';\nexport {useLabel} from './useLabel';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
@@ -0,0 +1,58 @@
1
+ var $ce7359c25a7dec1c$exports = require("./useLabel.main.js");
2
+ var $iujgQ$reactariautils = require("@react-aria/utils");
3
+
4
+
5
+ function $parcel$export(e, n, v, s) {
6
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
7
+ }
8
+
9
+ $parcel$export(module.exports, "useField", () => $50e2f39368b9c636$export$294aa081a6c6f55d);
10
+ /*
11
+ * Copyright 2021 Adobe. All rights reserved.
12
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
13
+ * you may not use this file except in compliance with the License. You may obtain a copy
14
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
15
+ *
16
+ * Unless required by applicable law or agreed to in writing, software distributed under
17
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
18
+ * OF ANY KIND, either express or implied. See the License for the specific language
19
+ * governing permissions and limitations under the License.
20
+ */
21
+
22
+ function $50e2f39368b9c636$export$294aa081a6c6f55d(props) {
23
+ let { description: description, errorMessage: errorMessage, isInvalid: isInvalid, validationState: validationState } = props;
24
+ let { labelProps: labelProps, fieldProps: fieldProps } = (0, $ce7359c25a7dec1c$exports.useLabel)(props);
25
+ let descriptionId = (0, $iujgQ$reactariautils.useSlotId)([
26
+ Boolean(description),
27
+ Boolean(errorMessage),
28
+ isInvalid,
29
+ validationState
30
+ ]);
31
+ let errorMessageId = (0, $iujgQ$reactariautils.useSlotId)([
32
+ Boolean(description),
33
+ Boolean(errorMessage),
34
+ isInvalid,
35
+ validationState
36
+ ]);
37
+ fieldProps = (0, $iujgQ$reactariautils.mergeProps)(fieldProps, {
38
+ 'aria-describedby': [
39
+ descriptionId,
40
+ // Use aria-describedby for error message because aria-errormessage is unsupported using VoiceOver or NVDA. See https://github.com/adobe/react-spectrum/issues/1346#issuecomment-740136268
41
+ errorMessageId,
42
+ props['aria-describedby']
43
+ ].filter(Boolean).join(' ') || undefined
44
+ });
45
+ return {
46
+ labelProps: labelProps,
47
+ fieldProps: fieldProps,
48
+ descriptionProps: {
49
+ id: descriptionId
50
+ },
51
+ errorMessageProps: {
52
+ id: errorMessageId
53
+ }
54
+ };
55
+ }
56
+
57
+
58
+ //# sourceMappingURL=useField.main.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC;;AAoBM,SAAS,0CAAS,KAAqB;IAC5C,IAAI,eAAC,WAAW,gBAAE,YAAY,aAAE,SAAS,mBAAE,eAAe,EAAC,GAAG;IAC9D,IAAI,cAAC,UAAU,cAAE,UAAU,EAAC,GAAG,CAAA,GAAA,kCAAO,EAAE;IAExC,IAAI,gBAAgB,CAAA,GAAA,+BAAQ,EAAE;QAAC,QAAQ;QAAc,QAAQ;QAAe;QAAW;KAAgB;IACvG,IAAI,iBAAiB,CAAA,GAAA,+BAAQ,EAAE;QAAC,QAAQ;QAAc,QAAQ;QAAe;QAAW;KAAgB;IAExG,aAAa,CAAA,GAAA,gCAAS,EAAE,YAAY;QAClC,oBAAoB;YAClB;YACA,0LAA0L;YAC1L;YACA,KAAK,CAAC,mBAAmB;SAC1B,CAAC,MAAM,CAAC,SAAS,IAAI,CAAC,QAAQ;IACjC;IAEA,OAAO;oBACL;oBACA;QACA,kBAAkB;YAChB,IAAI;QACN;QACA,mBAAmB;YACjB,IAAI;QACN;IACF;AACF","sources":["packages/@react-aria/label/src/useField.ts"],"sourcesContent":["/*\n * Copyright 2021 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 {DOMAttributes, HelpTextProps, Validation} from '@react-types/shared';\nimport {LabelAria, LabelAriaProps, useLabel} from './useLabel';\nimport {mergeProps, useSlotId} from '@react-aria/utils';\n\nexport interface AriaFieldProps extends LabelAriaProps, HelpTextProps, Omit<Validation<any>, 'isRequired'> {}\n\nexport interface FieldAria extends LabelAria {\n /** Props for the description element, if any. */\n descriptionProps: DOMAttributes,\n /** Props for the error message element, if any. */\n errorMessageProps: DOMAttributes\n}\n\n/**\n * Provides the accessibility implementation for input fields.\n * Fields accept user input, gain context from their label, and may display a description or error message.\n * @param props - Props for the Field.\n */\nexport function useField(props: AriaFieldProps): FieldAria {\n let {description, errorMessage, isInvalid, validationState} = props;\n let {labelProps, fieldProps} = useLabel(props);\n\n let descriptionId = useSlotId([Boolean(description), Boolean(errorMessage), isInvalid, validationState]);\n let errorMessageId = useSlotId([Boolean(description), Boolean(errorMessage), isInvalid, validationState]);\n\n fieldProps = mergeProps(fieldProps, {\n 'aria-describedby': [\n descriptionId,\n // Use aria-describedby for error message because aria-errormessage is unsupported using VoiceOver or NVDA. See https://github.com/adobe/react-spectrum/issues/1346#issuecomment-740136268\n errorMessageId,\n props['aria-describedby']\n ].filter(Boolean).join(' ') || undefined\n });\n\n return {\n labelProps,\n fieldProps,\n descriptionProps: {\n id: descriptionId\n },\n errorMessageProps: {\n id: errorMessageId\n }\n };\n}\n"],"names":[],"version":3,"file":"useField.main.js.map"}
@@ -0,0 +1,53 @@
1
+ import {useLabel as $d191a55c9702f145$export$8467354a121f1b9f} from "./useLabel.mjs";
2
+ import {useSlotId as $2kC82$useSlotId, mergeProps as $2kC82$mergeProps} from "@react-aria/utils";
3
+
4
+ /*
5
+ * Copyright 2021 Adobe. All rights reserved.
6
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License. You may obtain a copy
8
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software distributed under
11
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
12
+ * OF ANY KIND, either express or implied. See the License for the specific language
13
+ * governing permissions and limitations under the License.
14
+ */
15
+
16
+ function $2baaea4c71418dea$export$294aa081a6c6f55d(props) {
17
+ let { description: description, errorMessage: errorMessage, isInvalid: isInvalid, validationState: validationState } = props;
18
+ let { labelProps: labelProps, fieldProps: fieldProps } = (0, $d191a55c9702f145$export$8467354a121f1b9f)(props);
19
+ let descriptionId = (0, $2kC82$useSlotId)([
20
+ Boolean(description),
21
+ Boolean(errorMessage),
22
+ isInvalid,
23
+ validationState
24
+ ]);
25
+ let errorMessageId = (0, $2kC82$useSlotId)([
26
+ Boolean(description),
27
+ Boolean(errorMessage),
28
+ isInvalid,
29
+ validationState
30
+ ]);
31
+ fieldProps = (0, $2kC82$mergeProps)(fieldProps, {
32
+ 'aria-describedby': [
33
+ descriptionId,
34
+ // Use aria-describedby for error message because aria-errormessage is unsupported using VoiceOver or NVDA. See https://github.com/adobe/react-spectrum/issues/1346#issuecomment-740136268
35
+ errorMessageId,
36
+ props['aria-describedby']
37
+ ].filter(Boolean).join(' ') || undefined
38
+ });
39
+ return {
40
+ labelProps: labelProps,
41
+ fieldProps: fieldProps,
42
+ descriptionProps: {
43
+ id: descriptionId
44
+ },
45
+ errorMessageProps: {
46
+ id: errorMessageId
47
+ }
48
+ };
49
+ }
50
+
51
+
52
+ export {$2baaea4c71418dea$export$294aa081a6c6f55d as useField};
53
+ //# sourceMappingURL=useField.module.js.map
@@ -0,0 +1,53 @@
1
+ import {useLabel as $d191a55c9702f145$export$8467354a121f1b9f} from "./useLabel.module.js";
2
+ import {useSlotId as $2kC82$useSlotId, mergeProps as $2kC82$mergeProps} from "@react-aria/utils";
3
+
4
+ /*
5
+ * Copyright 2021 Adobe. All rights reserved.
6
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License. You may obtain a copy
8
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software distributed under
11
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
12
+ * OF ANY KIND, either express or implied. See the License for the specific language
13
+ * governing permissions and limitations under the License.
14
+ */
15
+
16
+ function $2baaea4c71418dea$export$294aa081a6c6f55d(props) {
17
+ let { description: description, errorMessage: errorMessage, isInvalid: isInvalid, validationState: validationState } = props;
18
+ let { labelProps: labelProps, fieldProps: fieldProps } = (0, $d191a55c9702f145$export$8467354a121f1b9f)(props);
19
+ let descriptionId = (0, $2kC82$useSlotId)([
20
+ Boolean(description),
21
+ Boolean(errorMessage),
22
+ isInvalid,
23
+ validationState
24
+ ]);
25
+ let errorMessageId = (0, $2kC82$useSlotId)([
26
+ Boolean(description),
27
+ Boolean(errorMessage),
28
+ isInvalid,
29
+ validationState
30
+ ]);
31
+ fieldProps = (0, $2kC82$mergeProps)(fieldProps, {
32
+ 'aria-describedby': [
33
+ descriptionId,
34
+ // Use aria-describedby for error message because aria-errormessage is unsupported using VoiceOver or NVDA. See https://github.com/adobe/react-spectrum/issues/1346#issuecomment-740136268
35
+ errorMessageId,
36
+ props['aria-describedby']
37
+ ].filter(Boolean).join(' ') || undefined
38
+ });
39
+ return {
40
+ labelProps: labelProps,
41
+ fieldProps: fieldProps,
42
+ descriptionProps: {
43
+ id: descriptionId
44
+ },
45
+ errorMessageProps: {
46
+ id: errorMessageId
47
+ }
48
+ };
49
+ }
50
+
51
+
52
+ export {$2baaea4c71418dea$export$294aa081a6c6f55d as useField};
53
+ //# sourceMappingURL=useField.module.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;AAAA;;;;;;;;;;CAUC;;AAoBM,SAAS,0CAAS,KAAqB;IAC5C,IAAI,eAAC,WAAW,gBAAE,YAAY,aAAE,SAAS,mBAAE,eAAe,EAAC,GAAG;IAC9D,IAAI,cAAC,UAAU,cAAE,UAAU,EAAC,GAAG,CAAA,GAAA,yCAAO,EAAE;IAExC,IAAI,gBAAgB,CAAA,GAAA,gBAAQ,EAAE;QAAC,QAAQ;QAAc,QAAQ;QAAe;QAAW;KAAgB;IACvG,IAAI,iBAAiB,CAAA,GAAA,gBAAQ,EAAE;QAAC,QAAQ;QAAc,QAAQ;QAAe;QAAW;KAAgB;IAExG,aAAa,CAAA,GAAA,iBAAS,EAAE,YAAY;QAClC,oBAAoB;YAClB;YACA,0LAA0L;YAC1L;YACA,KAAK,CAAC,mBAAmB;SAC1B,CAAC,MAAM,CAAC,SAAS,IAAI,CAAC,QAAQ;IACjC;IAEA,OAAO;oBACL;oBACA;QACA,kBAAkB;YAChB,IAAI;QACN;QACA,mBAAmB;YACjB,IAAI;QACN;IACF;AACF","sources":["packages/@react-aria/label/src/useField.ts"],"sourcesContent":["/*\n * Copyright 2021 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 {DOMAttributes, HelpTextProps, Validation} from '@react-types/shared';\nimport {LabelAria, LabelAriaProps, useLabel} from './useLabel';\nimport {mergeProps, useSlotId} from '@react-aria/utils';\n\nexport interface AriaFieldProps extends LabelAriaProps, HelpTextProps, Omit<Validation<any>, 'isRequired'> {}\n\nexport interface FieldAria extends LabelAria {\n /** Props for the description element, if any. */\n descriptionProps: DOMAttributes,\n /** Props for the error message element, if any. */\n errorMessageProps: DOMAttributes\n}\n\n/**\n * Provides the accessibility implementation for input fields.\n * Fields accept user input, gain context from their label, and may display a description or error message.\n * @param props - Props for the Field.\n */\nexport function useField(props: AriaFieldProps): FieldAria {\n let {description, errorMessage, isInvalid, validationState} = props;\n let {labelProps, fieldProps} = useLabel(props);\n\n let descriptionId = useSlotId([Boolean(description), Boolean(errorMessage), isInvalid, validationState]);\n let errorMessageId = useSlotId([Boolean(description), Boolean(errorMessage), isInvalid, validationState]);\n\n fieldProps = mergeProps(fieldProps, {\n 'aria-describedby': [\n descriptionId,\n // Use aria-describedby for error message because aria-errormessage is unsupported using VoiceOver or NVDA. See https://github.com/adobe/react-spectrum/issues/1346#issuecomment-740136268\n errorMessageId,\n props['aria-describedby']\n ].filter(Boolean).join(' ') || undefined\n });\n\n return {\n labelProps,\n fieldProps,\n descriptionProps: {\n id: descriptionId\n },\n errorMessageProps: {\n id: errorMessageId\n }\n };\n}\n"],"names":[],"version":3,"file":"useField.module.js.map"}
@@ -0,0 +1,44 @@
1
+ var $eXjoL$reactariautils = require("@react-aria/utils");
2
+
3
+
4
+ function $parcel$export(e, n, v, s) {
5
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
6
+ }
7
+
8
+ $parcel$export(module.exports, "useLabel", () => $ce7359c25a7dec1c$export$8467354a121f1b9f);
9
+ /*
10
+ * Copyright 2020 Adobe. All rights reserved.
11
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
12
+ * you may not use this file except in compliance with the License. You may obtain a copy
13
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
14
+ *
15
+ * Unless required by applicable law or agreed to in writing, software distributed under
16
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
17
+ * OF ANY KIND, either express or implied. See the License for the specific language
18
+ * governing permissions and limitations under the License.
19
+ */
20
+ function $ce7359c25a7dec1c$export$8467354a121f1b9f(props) {
21
+ let { id: id, label: label, 'aria-labelledby': ariaLabelledby, 'aria-label': ariaLabel, labelElementType: labelElementType = 'label' } = props;
22
+ id = (0, $eXjoL$reactariautils.useId)(id);
23
+ let labelId = (0, $eXjoL$reactariautils.useId)();
24
+ let labelProps = {};
25
+ if (label) {
26
+ ariaLabelledby = ariaLabelledby ? `${labelId} ${ariaLabelledby}` : labelId;
27
+ labelProps = {
28
+ id: labelId,
29
+ htmlFor: labelElementType === 'label' ? id : undefined
30
+ };
31
+ } else if (!ariaLabelledby && !ariaLabel) console.warn('If you do not provide a visible label, you must specify an aria-label or aria-labelledby attribute for accessibility');
32
+ let fieldProps = (0, $eXjoL$reactariautils.useLabels)({
33
+ id: id,
34
+ 'aria-label': ariaLabel,
35
+ 'aria-labelledby': ariaLabelledby
36
+ });
37
+ return {
38
+ labelProps: labelProps,
39
+ fieldProps: fieldProps
40
+ };
41
+ }
42
+
43
+
44
+ //# sourceMappingURL=useLabel.main.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;;AAAA;;;;;;;;;;CAUC;AA0BM,SAAS,0CAAS,KAAqB;IAC5C,IAAI,MACF,EAAE,SACF,KAAK,EACL,mBAAmB,cAAc,EACjC,cAAc,SAAS,oBACvB,mBAAmB,SACpB,GAAG;IAEJ,KAAK,CAAA,GAAA,2BAAI,EAAE;IACX,IAAI,UAAU,CAAA,GAAA,2BAAI;IAClB,IAAI,aAAa,CAAC;IAClB,IAAI,OAAO;QACT,iBAAiB,iBAAiB,CAAC,EAAE,QAAQ,CAAC,EAAE,eAAe,CAAC,GAAG;QACnE,aAAa;YACX,IAAI;YACJ,SAAS,qBAAqB,UAAU,KAAK;QAC/C;IACF,OAAO,IAAI,CAAC,kBAAkB,CAAC,WAC7B,QAAQ,IAAI,CAAC;IAGf,IAAI,aAAa,CAAA,GAAA,+BAAQ,EAAE;YACzB;QACA,cAAc;QACd,mBAAmB;IACrB;IAEA,OAAO;oBACL;oBACA;IACF;AACF","sources":["packages/@react-aria/label/src/useLabel.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 {AriaLabelingProps, DOMAttributes, DOMProps, LabelableProps} from '@react-types/shared';\nimport {ElementType, LabelHTMLAttributes} from 'react';\nimport {useId, useLabels} from '@react-aria/utils';\n\nexport interface LabelAriaProps extends LabelableProps, DOMProps, AriaLabelingProps {\n /**\n * The HTML element used to render the label, e.g. 'label', or 'span'.\n * @default 'label'\n */\n labelElementType?: ElementType\n}\n\nexport interface LabelAria {\n /** Props to apply to the label container element. */\n labelProps: DOMAttributes | LabelHTMLAttributes<HTMLLabelElement>,\n /** Props to apply to the field container element being labeled. */\n fieldProps: AriaLabelingProps & DOMProps\n}\n\n/**\n * Provides the accessibility implementation for labels and their associated elements.\n * Labels provide context for user inputs.\n * @param props - The props for labels and fields.\n */\nexport function useLabel(props: LabelAriaProps): LabelAria {\n let {\n id,\n label,\n 'aria-labelledby': ariaLabelledby,\n 'aria-label': ariaLabel,\n labelElementType = 'label'\n } = props;\n\n id = useId(id);\n let labelId = useId();\n let labelProps = {};\n if (label) {\n ariaLabelledby = ariaLabelledby ? `${labelId} ${ariaLabelledby}` : labelId;\n labelProps = {\n id: labelId,\n htmlFor: labelElementType === 'label' ? id : undefined\n };\n } else if (!ariaLabelledby && !ariaLabel) {\n console.warn('If you do not provide a visible label, you must specify an aria-label or aria-labelledby attribute for accessibility');\n }\n\n let fieldProps = useLabels({\n id,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledby\n });\n\n return {\n labelProps,\n fieldProps\n };\n}\n"],"names":[],"version":3,"file":"useLabel.main.js.map"}
@@ -0,0 +1,39 @@
1
+ import {useId as $83Elw$useId, useLabels as $83Elw$useLabels} from "@react-aria/utils";
2
+
3
+ /*
4
+ * Copyright 2020 Adobe. All rights reserved.
5
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License. You may obtain a copy
7
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software distributed under
10
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
11
+ * OF ANY KIND, either express or implied. See the License for the specific language
12
+ * governing permissions and limitations under the License.
13
+ */
14
+ function $d191a55c9702f145$export$8467354a121f1b9f(props) {
15
+ let { id: id, label: label, 'aria-labelledby': ariaLabelledby, 'aria-label': ariaLabel, labelElementType: labelElementType = 'label' } = props;
16
+ id = (0, $83Elw$useId)(id);
17
+ let labelId = (0, $83Elw$useId)();
18
+ let labelProps = {};
19
+ if (label) {
20
+ ariaLabelledby = ariaLabelledby ? `${labelId} ${ariaLabelledby}` : labelId;
21
+ labelProps = {
22
+ id: labelId,
23
+ htmlFor: labelElementType === 'label' ? id : undefined
24
+ };
25
+ } else if (!ariaLabelledby && !ariaLabel) console.warn('If you do not provide a visible label, you must specify an aria-label or aria-labelledby attribute for accessibility');
26
+ let fieldProps = (0, $83Elw$useLabels)({
27
+ id: id,
28
+ 'aria-label': ariaLabel,
29
+ 'aria-labelledby': ariaLabelledby
30
+ });
31
+ return {
32
+ labelProps: labelProps,
33
+ fieldProps: fieldProps
34
+ };
35
+ }
36
+
37
+
38
+ export {$d191a55c9702f145$export$8467354a121f1b9f as useLabel};
39
+ //# sourceMappingURL=useLabel.module.js.map
@@ -0,0 +1,39 @@
1
+ import {useId as $83Elw$useId, useLabels as $83Elw$useLabels} from "@react-aria/utils";
2
+
3
+ /*
4
+ * Copyright 2020 Adobe. All rights reserved.
5
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License. You may obtain a copy
7
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software distributed under
10
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
11
+ * OF ANY KIND, either express or implied. See the License for the specific language
12
+ * governing permissions and limitations under the License.
13
+ */
14
+ function $d191a55c9702f145$export$8467354a121f1b9f(props) {
15
+ let { id: id, label: label, 'aria-labelledby': ariaLabelledby, 'aria-label': ariaLabel, labelElementType: labelElementType = 'label' } = props;
16
+ id = (0, $83Elw$useId)(id);
17
+ let labelId = (0, $83Elw$useId)();
18
+ let labelProps = {};
19
+ if (label) {
20
+ ariaLabelledby = ariaLabelledby ? `${labelId} ${ariaLabelledby}` : labelId;
21
+ labelProps = {
22
+ id: labelId,
23
+ htmlFor: labelElementType === 'label' ? id : undefined
24
+ };
25
+ } else if (!ariaLabelledby && !ariaLabel) console.warn('If you do not provide a visible label, you must specify an aria-label or aria-labelledby attribute for accessibility');
26
+ let fieldProps = (0, $83Elw$useLabels)({
27
+ id: id,
28
+ 'aria-label': ariaLabel,
29
+ 'aria-labelledby': ariaLabelledby
30
+ });
31
+ return {
32
+ labelProps: labelProps,
33
+ fieldProps: fieldProps
34
+ };
35
+ }
36
+
37
+
38
+ export {$d191a55c9702f145$export$8467354a121f1b9f as useLabel};
39
+ //# sourceMappingURL=useLabel.module.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;AAAA;;;;;;;;;;CAUC;AA0BM,SAAS,0CAAS,KAAqB;IAC5C,IAAI,MACF,EAAE,SACF,KAAK,EACL,mBAAmB,cAAc,EACjC,cAAc,SAAS,oBACvB,mBAAmB,SACpB,GAAG;IAEJ,KAAK,CAAA,GAAA,YAAI,EAAE;IACX,IAAI,UAAU,CAAA,GAAA,YAAI;IAClB,IAAI,aAAa,CAAC;IAClB,IAAI,OAAO;QACT,iBAAiB,iBAAiB,CAAC,EAAE,QAAQ,CAAC,EAAE,eAAe,CAAC,GAAG;QACnE,aAAa;YACX,IAAI;YACJ,SAAS,qBAAqB,UAAU,KAAK;QAC/C;IACF,OAAO,IAAI,CAAC,kBAAkB,CAAC,WAC7B,QAAQ,IAAI,CAAC;IAGf,IAAI,aAAa,CAAA,GAAA,gBAAQ,EAAE;YACzB;QACA,cAAc;QACd,mBAAmB;IACrB;IAEA,OAAO;oBACL;oBACA;IACF;AACF","sources":["packages/@react-aria/label/src/useLabel.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 {AriaLabelingProps, DOMAttributes, DOMProps, LabelableProps} from '@react-types/shared';\nimport {ElementType, LabelHTMLAttributes} from 'react';\nimport {useId, useLabels} from '@react-aria/utils';\n\nexport interface LabelAriaProps extends LabelableProps, DOMProps, AriaLabelingProps {\n /**\n * The HTML element used to render the label, e.g. 'label', or 'span'.\n * @default 'label'\n */\n labelElementType?: ElementType\n}\n\nexport interface LabelAria {\n /** Props to apply to the label container element. */\n labelProps: DOMAttributes | LabelHTMLAttributes<HTMLLabelElement>,\n /** Props to apply to the field container element being labeled. */\n fieldProps: AriaLabelingProps & DOMProps\n}\n\n/**\n * Provides the accessibility implementation for labels and their associated elements.\n * Labels provide context for user inputs.\n * @param props - The props for labels and fields.\n */\nexport function useLabel(props: LabelAriaProps): LabelAria {\n let {\n id,\n label,\n 'aria-labelledby': ariaLabelledby,\n 'aria-label': ariaLabel,\n labelElementType = 'label'\n } = props;\n\n id = useId(id);\n let labelId = useId();\n let labelProps = {};\n if (label) {\n ariaLabelledby = ariaLabelledby ? `${labelId} ${ariaLabelledby}` : labelId;\n labelProps = {\n id: labelId,\n htmlFor: labelElementType === 'label' ? id : undefined\n };\n } else if (!ariaLabelledby && !ariaLabel) {\n console.warn('If you do not provide a visible label, you must specify an aria-label or aria-labelledby attribute for accessibility');\n }\n\n let fieldProps = useLabels({\n id,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledby\n });\n\n return {\n labelProps,\n fieldProps\n };\n}\n"],"names":[],"version":3,"file":"useLabel.module.js.map"}
package/package.json ADDED
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "@react-aria/label",
3
+ "version": "3.0.0-nightly-641446f65-240905",
4
+ "description": "Spectrum UI components in React",
5
+ "license": "Apache-2.0",
6
+ "main": "dist/main.js",
7
+ "module": "dist/module.js",
8
+ "exports": {
9
+ "types": "./dist/types.d.ts",
10
+ "import": "./dist/import.mjs",
11
+ "require": "./dist/main.js"
12
+ },
13
+ "types": "dist/types.d.ts",
14
+ "source": "src/index.ts",
15
+ "files": [
16
+ "dist",
17
+ "src"
18
+ ],
19
+ "sideEffects": false,
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "https://github.com/adobe/react-spectrum"
23
+ },
24
+ "dependencies": {
25
+ "@react-aria/utils": "^3.0.0-nightly-641446f65-240905",
26
+ "@react-types/shared": "^3.0.0-nightly-641446f65-240905",
27
+ "@swc/helpers": "^0.5.0"
28
+ },
29
+ "peerDependencies": {
30
+ "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0"
31
+ },
32
+ "publishConfig": {
33
+ "access": "public"
34
+ },
35
+ "stableVersion": "3.7.11"
36
+ }
package/src/index.ts ADDED
@@ -0,0 +1,17 @@
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
+ export type {AriaFieldProps, FieldAria} from './useField';
14
+ export type {LabelAriaProps, LabelAria} from './useLabel';
15
+
16
+ export {useField} from './useField';
17
+ export {useLabel} from './useLabel';
@@ -0,0 +1,57 @@
1
+ /*
2
+ * Copyright 2021 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 {DOMAttributes, HelpTextProps, Validation} from '@react-types/shared';
14
+ import {LabelAria, LabelAriaProps, useLabel} from './useLabel';
15
+ import {mergeProps, useSlotId} from '@react-aria/utils';
16
+
17
+ export interface AriaFieldProps extends LabelAriaProps, HelpTextProps, Omit<Validation<any>, 'isRequired'> {}
18
+
19
+ export interface FieldAria extends LabelAria {
20
+ /** Props for the description element, if any. */
21
+ descriptionProps: DOMAttributes,
22
+ /** Props for the error message element, if any. */
23
+ errorMessageProps: DOMAttributes
24
+ }
25
+
26
+ /**
27
+ * Provides the accessibility implementation for input fields.
28
+ * Fields accept user input, gain context from their label, and may display a description or error message.
29
+ * @param props - Props for the Field.
30
+ */
31
+ export function useField(props: AriaFieldProps): FieldAria {
32
+ let {description, errorMessage, isInvalid, validationState} = props;
33
+ let {labelProps, fieldProps} = useLabel(props);
34
+
35
+ let descriptionId = useSlotId([Boolean(description), Boolean(errorMessage), isInvalid, validationState]);
36
+ let errorMessageId = useSlotId([Boolean(description), Boolean(errorMessage), isInvalid, validationState]);
37
+
38
+ fieldProps = mergeProps(fieldProps, {
39
+ 'aria-describedby': [
40
+ descriptionId,
41
+ // Use aria-describedby for error message because aria-errormessage is unsupported using VoiceOver or NVDA. See https://github.com/adobe/react-spectrum/issues/1346#issuecomment-740136268
42
+ errorMessageId,
43
+ props['aria-describedby']
44
+ ].filter(Boolean).join(' ') || undefined
45
+ });
46
+
47
+ return {
48
+ labelProps,
49
+ fieldProps,
50
+ descriptionProps: {
51
+ id: descriptionId
52
+ },
53
+ errorMessageProps: {
54
+ id: errorMessageId
55
+ }
56
+ };
57
+ }
@@ -0,0 +1,69 @@
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 {AriaLabelingProps, DOMAttributes, DOMProps, LabelableProps} from '@react-types/shared';
14
+ import {ElementType, LabelHTMLAttributes} from 'react';
15
+ import {useId, useLabels} from '@react-aria/utils';
16
+
17
+ export interface LabelAriaProps extends LabelableProps, DOMProps, AriaLabelingProps {
18
+ /**
19
+ * The HTML element used to render the label, e.g. 'label', or 'span'.
20
+ * @default 'label'
21
+ */
22
+ labelElementType?: ElementType
23
+ }
24
+
25
+ export interface LabelAria {
26
+ /** Props to apply to the label container element. */
27
+ labelProps: DOMAttributes | LabelHTMLAttributes<HTMLLabelElement>,
28
+ /** Props to apply to the field container element being labeled. */
29
+ fieldProps: AriaLabelingProps & DOMProps
30
+ }
31
+
32
+ /**
33
+ * Provides the accessibility implementation for labels and their associated elements.
34
+ * Labels provide context for user inputs.
35
+ * @param props - The props for labels and fields.
36
+ */
37
+ export function useLabel(props: LabelAriaProps): LabelAria {
38
+ let {
39
+ id,
40
+ label,
41
+ 'aria-labelledby': ariaLabelledby,
42
+ 'aria-label': ariaLabel,
43
+ labelElementType = 'label'
44
+ } = props;
45
+
46
+ id = useId(id);
47
+ let labelId = useId();
48
+ let labelProps = {};
49
+ if (label) {
50
+ ariaLabelledby = ariaLabelledby ? `${labelId} ${ariaLabelledby}` : labelId;
51
+ labelProps = {
52
+ id: labelId,
53
+ htmlFor: labelElementType === 'label' ? id : undefined
54
+ };
55
+ } else if (!ariaLabelledby && !ariaLabel) {
56
+ console.warn('If you do not provide a visible label, you must specify an aria-label or aria-labelledby attribute for accessibility');
57
+ }
58
+
59
+ let fieldProps = useLabels({
60
+ id,
61
+ 'aria-label': ariaLabel,
62
+ 'aria-labelledby': ariaLabelledby
63
+ });
64
+
65
+ return {
66
+ labelProps,
67
+ fieldProps
68
+ };
69
+ }