@react-aria/label 3.4.3 → 3.5.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.
@@ -0,0 +1,97 @@
1
+ import {useSlotId as $iD7q0$useSlotId, mergeProps as $iD7q0$mergeProps, useId as $iD7q0$useId, useLabels as $iD7q0$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
+ * Copyright 2021 Adobe. All rights reserved.
15
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
16
+ * you may not use this file except in compliance with the License. You may obtain a copy
17
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
18
+ *
19
+ * Unless required by applicable law or agreed to in writing, software distributed under
20
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
21
+ * OF ANY KIND, either express or implied. See the License for the specific language
22
+ * governing permissions and limitations under the License.
23
+ */ /*
24
+ * Copyright 2020 Adobe. All rights reserved.
25
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
26
+ * you may not use this file except in compliance with the License. You may obtain a copy
27
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
28
+ *
29
+ * Unless required by applicable law or agreed to in writing, software distributed under
30
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
31
+ * OF ANY KIND, either express or implied. See the License for the specific language
32
+ * governing permissions and limitations under the License.
33
+ */
34
+ function $d191a55c9702f145$export$8467354a121f1b9f(props) {
35
+ let { id: id , label: label , "aria-labelledby": ariaLabelledby , "aria-label": ariaLabel , labelElementType: labelElementType = "label" } = props;
36
+ id = (0, $iD7q0$useId)(id);
37
+ let labelId = (0, $iD7q0$useId)();
38
+ let labelProps = {};
39
+ if (label) {
40
+ ariaLabelledby = ariaLabelledby ? `${ariaLabelledby} ${labelId}` : labelId;
41
+ labelProps = {
42
+ id: labelId,
43
+ htmlFor: labelElementType === "label" ? id : undefined
44
+ };
45
+ } 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");
46
+ let fieldProps = (0, $iD7q0$useLabels)({
47
+ id: id,
48
+ "aria-label": ariaLabel,
49
+ "aria-labelledby": ariaLabelledby
50
+ });
51
+ return {
52
+ labelProps: labelProps,
53
+ fieldProps: fieldProps
54
+ };
55
+ }
56
+
57
+
58
+
59
+ function $2baaea4c71418dea$export$294aa081a6c6f55d(props) {
60
+ let { description: description , errorMessage: errorMessage , validationState: validationState } = props;
61
+ let { labelProps: labelProps , fieldProps: fieldProps } = (0, $d191a55c9702f145$export$8467354a121f1b9f)(props);
62
+ let descriptionId = (0, $iD7q0$useSlotId)([
63
+ Boolean(description),
64
+ Boolean(errorMessage),
65
+ validationState
66
+ ]);
67
+ let errorMessageId = (0, $iD7q0$useSlotId)([
68
+ Boolean(description),
69
+ Boolean(errorMessage),
70
+ validationState
71
+ ]);
72
+ fieldProps = (0, $iD7q0$mergeProps)(fieldProps, {
73
+ "aria-describedby": [
74
+ descriptionId,
75
+ // 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
76
+ errorMessageId,
77
+ props["aria-describedby"]
78
+ ].filter(Boolean).join(" ") || undefined
79
+ });
80
+ return {
81
+ labelProps: labelProps,
82
+ fieldProps: fieldProps,
83
+ descriptionProps: {
84
+ id: descriptionId
85
+ },
86
+ errorMessageProps: {
87
+ id: errorMessageId
88
+ }
89
+ };
90
+ }
91
+
92
+
93
+
94
+
95
+
96
+ export {$2baaea4c71418dea$export$294aa081a6c6f55d as useField, $d191a55c9702f145$export$8467354a121f1b9f as useLabel};
97
+ //# sourceMappingURL=module.js.map
package/dist/main.js CHANGED
@@ -6,24 +6,53 @@ function $parcel$export(e, n, v, s) {
6
6
 
7
7
  $parcel$export(module.exports, "useField", () => $50e2f39368b9c636$export$294aa081a6c6f55d);
8
8
  $parcel$export(module.exports, "useLabel", () => $ce7359c25a7dec1c$export$8467354a121f1b9f);
9
-
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
+ * Copyright 2021 Adobe. All rights reserved.
21
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
22
+ * you may not use this file except in compliance with the License. You may obtain a copy
23
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
24
+ *
25
+ * Unless required by applicable law or agreed to in writing, software distributed under
26
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
27
+ * OF ANY KIND, either express or implied. See the License for the specific language
28
+ * governing permissions and limitations under the License.
29
+ */ /*
30
+ * Copyright 2020 Adobe. All rights reserved.
31
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
32
+ * you may not use this file except in compliance with the License. You may obtain a copy
33
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
34
+ *
35
+ * Unless required by applicable law or agreed to in writing, software distributed under
36
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
37
+ * OF ANY KIND, either express or implied. See the License for the specific language
38
+ * governing permissions and limitations under the License.
39
+ */
10
40
  function $ce7359c25a7dec1c$export$8467354a121f1b9f(props) {
11
- let { id: id , label: label , 'aria-labelledby': ariaLabelledby , 'aria-label': ariaLabel , labelElementType: labelElementType = 'label' } = props;
12
- id = $g2CPN$reactariautils.useId(id);
13
- let labelId = $g2CPN$reactariautils.useId();
14
- let labelProps = {
15
- };
41
+ let { id: id , label: label , "aria-labelledby": ariaLabelledby , "aria-label": ariaLabel , labelElementType: labelElementType = "label" } = props;
42
+ id = (0, $g2CPN$reactariautils.useId)(id);
43
+ let labelId = (0, $g2CPN$reactariautils.useId)();
44
+ let labelProps = {};
16
45
  if (label) {
17
46
  ariaLabelledby = ariaLabelledby ? `${ariaLabelledby} ${labelId}` : labelId;
18
47
  labelProps = {
19
48
  id: labelId,
20
- htmlFor: labelElementType === 'label' ? id : undefined
49
+ htmlFor: labelElementType === "label" ? id : undefined
21
50
  };
22
- } 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');
23
- let fieldProps = $g2CPN$reactariautils.useLabels({
51
+ } 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");
52
+ let fieldProps = (0, $g2CPN$reactariautils.useLabels)({
24
53
  id: id,
25
- 'aria-label': ariaLabel,
26
- 'aria-labelledby': ariaLabelledby
54
+ "aria-label": ariaLabel,
55
+ "aria-labelledby": ariaLabelledby
27
56
  });
28
57
  return {
29
58
  labelProps: labelProps,
@@ -35,24 +64,24 @@ function $ce7359c25a7dec1c$export$8467354a121f1b9f(props) {
35
64
 
36
65
  function $50e2f39368b9c636$export$294aa081a6c6f55d(props) {
37
66
  let { description: description , errorMessage: errorMessage , validationState: validationState } = props;
38
- let { labelProps: labelProps , fieldProps: fieldProps } = $ce7359c25a7dec1c$export$8467354a121f1b9f(props);
39
- let descriptionId = $g2CPN$reactariautils.useSlotId([
67
+ let { labelProps: labelProps , fieldProps: fieldProps } = (0, $ce7359c25a7dec1c$export$8467354a121f1b9f)(props);
68
+ let descriptionId = (0, $g2CPN$reactariautils.useSlotId)([
40
69
  Boolean(description),
41
70
  Boolean(errorMessage),
42
71
  validationState
43
72
  ]);
44
- let errorMessageId = $g2CPN$reactariautils.useSlotId([
73
+ let errorMessageId = (0, $g2CPN$reactariautils.useSlotId)([
45
74
  Boolean(description),
46
75
  Boolean(errorMessage),
47
76
  validationState
48
77
  ]);
49
- fieldProps = $g2CPN$reactariautils.mergeProps(fieldProps, {
50
- 'aria-describedby': [
78
+ fieldProps = (0, $g2CPN$reactariautils.mergeProps)(fieldProps, {
79
+ "aria-describedby": [
51
80
  descriptionId,
52
81
  // 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
53
82
  errorMessageId,
54
- props['aria-describedby']
55
- ].filter(Boolean).join(' ') || undefined
83
+ props["aria-describedby"]
84
+ ].filter(Boolean).join(" ") || undefined
56
85
  });
57
86
  return {
58
87
  labelProps: labelProps,
package/dist/main.js.map CHANGED
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;SEoCgB,yCAAQ,CAAC,KAAqB,EAAa,CAAC;IAC1D,GAAG,CAAC,CAAC,KACH,EAAE,UACF,KAAK,GACL,CAAiB,kBAAE,cAAc,GACjC,CAAY,aAAE,SAAS,qBACvB,gBAAgB,GAAG,CAAO,QAC5B,CAAC,GAAG,KAAK;IAET,EAAE,GAAG,2BAAK,CAAC,EAAE;IACb,GAAG,CAAC,OAAO,GAAG,2BAAK;IACnB,GAAG,CAAC,UAAU,GAAG,CAAC;IAAA,CAAC;IACnB,EAAE,EAAE,KAAK,EAAE,CAAC;QACV,cAAc,GAAG,cAAc,MAAM,cAAc,CAAC,CAAC,EAAE,OAAO,KAAK,OAAO;QAC1E,UAAU,GAAG,CAAC;YACZ,EAAE,EAAE,OAAO;YACX,OAAO,EAAE,gBAAgB,KAAK,CAAO,SAAG,EAAE,GAAG,SAAS;QACxD,CAAC;IACH,CAAC,MAAM,EAAE,GAAG,cAAc,KAAK,SAAS,EACtC,OAAO,CAAC,IAAI,CAAC,CAAsH;IAGrI,GAAG,CAAC,UAAU,GAAG,+BAAS,CAAC,CAAC;YAC1B,EAAE;QACF,CAAY,aAAE,SAAS;QACvB,CAAiB,kBAAE,cAAc;IACnC,CAAC;IAED,MAAM,CAAC,CAAC;oBACN,UAAU;oBACV,UAAU;IACZ,CAAC;AACH,CAAC;;;;SDtCe,yCAAQ,CAAC,KAAqB,EAAa,CAAC;IAC1D,GAAG,CAAC,CAAC,cAAA,WAAW,iBAAE,YAAY,oBAAE,eAAe,EAAA,CAAC,GAAG,KAAK;IACxD,GAAG,CAAC,CAAC,aAAA,UAAU,eAAE,UAAU,EAAA,CAAC,GAAG,yCAAQ,CAAC,KAAK;IAE7C,GAAG,CAAC,aAAa,GAAG,+BAAS,CAAC,CAAC;QAAA,OAAO,CAAC,WAAW;QAAG,OAAO,CAAC,YAAY;QAAG,eAAe;IAAA,CAAC;IAC5F,GAAG,CAAC,cAAc,GAAG,+BAAS,CAAC,CAAC;QAAA,OAAO,CAAC,WAAW;QAAG,OAAO,CAAC,YAAY;QAAG,eAAe;IAAA,CAAC;IAE7F,UAAU,GAAG,gCAAU,CAAC,UAAU,EAAE,CAAC;QACnC,CAAkB,mBAAE,CAAC;YACnB,aAAa;YACb,EAA0L,AAA1L,wLAA0L;YAC1L,cAAc;YACd,KAAK,CAAC,CAAkB;QAC1B,CAAC,CAAC,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,CAAG,OAAK,SAAS;IAC1C,CAAC;IAED,MAAM,CAAC,CAAC;oBACN,UAAU;oBACV,UAAU;QACV,gBAAgB,EAAE,CAAC;YACjB,EAAE,EAAE,aAAa;QACnB,CAAC;QACD,iBAAiB,EAAE,CAAC;YAClB,EAAE,EAAE,cAAc;QACpB,CAAC;IACH,CAAC;AACH,CAAC","sources":["packages/@react-aria/label/src/index.ts","packages/@react-aria/label/src/useField.ts","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\nexport type {AriaFieldProps, FieldAria} from './useField';\nexport type {LabelAriaProps, LabelAria} from './useLabel';\n\nexport {useField} from './useField';\nexport {useLabel} from './useLabel';\n","/*\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, '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, validationState} = props;\n let {labelProps, fieldProps} = useLabel(props);\n\n let descriptionId = useSlotId([Boolean(description), Boolean(errorMessage), validationState]);\n let errorMessageId = useSlotId([Boolean(description), Boolean(errorMessage), 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","/*\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 ? `${ariaLabelledby} ${labelId}` : 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":"main.js.map"}
1
+ {"mappings":";;;;;;;;AAAA;;;;;;;;;;ACAA;;;;;;;;;;ACAA;;;;;;;;;;CAUC,GAED;AAwBO,SAAS,0CAAS,KAAqB,EAAa;IACzD,IAAI,MACF,GAAE,SACF,MAAK,EACL,mBAAmB,eAAc,EACjC,cAAc,UAAS,oBACvB,mBAAmB,UACpB,GAAG;IAEJ,KAAK,CAAA,GAAA,2BAAI,EAAE;IACX,IAAI,UAAU,CAAA,GAAA,2BAAK,AAAD;IAClB,IAAI,aAAa,CAAC;IAClB,IAAI,OAAO;QACT,iBAAiB,iBAAiB,CAAC,EAAE,eAAe,CAAC,EAAE,QAAQ,CAAC,GAAG,OAAO;QAC1E,aAAa;YACX,IAAI;YACJ,SAAS,qBAAqB,UAAU,KAAK,SAAS;QACxD;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;;CD1DC,GAED;;AAkBO,SAAS,0CAAS,KAAqB,EAAa;IACzD,IAAI,eAAC,YAAW,gBAAE,aAAY,mBAAE,gBAAe,EAAC,GAAG;IACnD,IAAI,cAAC,WAAU,cAAE,WAAU,EAAC,GAAG,CAAA,GAAA,yCAAQ,AAAD,EAAE;IAExC,IAAI,gBAAgB,CAAA,GAAA,+BAAQ,EAAE;QAAC,QAAQ;QAAc,QAAQ;QAAe;KAAgB;IAC5F,IAAI,iBAAiB,CAAA,GAAA,+BAAQ,EAAE;QAAC,QAAQ;QAAc,QAAQ;QAAe;KAAgB;IAE7F,aAAa,CAAA,GAAA,gCAAU,AAAD,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;;CD9CC,GAED","sources":["packages/@react-aria/label/src/index.ts","packages/@react-aria/label/src/useField.ts","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\nexport type {AriaFieldProps, FieldAria} from './useField';\nexport type {LabelAriaProps, LabelAria} from './useLabel';\n\nexport {useField} from './useField';\nexport {useLabel} from './useLabel';\n","/*\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, '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, validationState} = props;\n let {labelProps, fieldProps} = useLabel(props);\n\n let descriptionId = useSlotId([Boolean(description), Boolean(errorMessage), validationState]);\n let errorMessageId = useSlotId([Boolean(description), Boolean(errorMessage), 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","/*\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 ? `${ariaLabelledby} ${labelId}` : 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":"main.js.map"}
package/dist/module.js CHANGED
@@ -1,23 +1,52 @@
1
1
  import {useSlotId as $iD7q0$useSlotId, mergeProps as $iD7q0$mergeProps, useId as $iD7q0$useId, useLabels as $iD7q0$useLabels} from "@react-aria/utils";
2
2
 
3
-
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
+ * Copyright 2021 Adobe. All rights reserved.
15
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
16
+ * you may not use this file except in compliance with the License. You may obtain a copy
17
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
18
+ *
19
+ * Unless required by applicable law or agreed to in writing, software distributed under
20
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
21
+ * OF ANY KIND, either express or implied. See the License for the specific language
22
+ * governing permissions and limitations under the License.
23
+ */ /*
24
+ * Copyright 2020 Adobe. All rights reserved.
25
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
26
+ * you may not use this file except in compliance with the License. You may obtain a copy
27
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
28
+ *
29
+ * Unless required by applicable law or agreed to in writing, software distributed under
30
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
31
+ * OF ANY KIND, either express or implied. See the License for the specific language
32
+ * governing permissions and limitations under the License.
33
+ */
4
34
  function $d191a55c9702f145$export$8467354a121f1b9f(props) {
5
- let { id: id , label: label , 'aria-labelledby': ariaLabelledby , 'aria-label': ariaLabel , labelElementType: labelElementType = 'label' } = props;
6
- id = $iD7q0$useId(id);
7
- let labelId = $iD7q0$useId();
8
- let labelProps = {
9
- };
35
+ let { id: id , label: label , "aria-labelledby": ariaLabelledby , "aria-label": ariaLabel , labelElementType: labelElementType = "label" } = props;
36
+ id = (0, $iD7q0$useId)(id);
37
+ let labelId = (0, $iD7q0$useId)();
38
+ let labelProps = {};
10
39
  if (label) {
11
40
  ariaLabelledby = ariaLabelledby ? `${ariaLabelledby} ${labelId}` : labelId;
12
41
  labelProps = {
13
42
  id: labelId,
14
- htmlFor: labelElementType === 'label' ? id : undefined
43
+ htmlFor: labelElementType === "label" ? id : undefined
15
44
  };
16
- } 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');
17
- let fieldProps = $iD7q0$useLabels({
45
+ } 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");
46
+ let fieldProps = (0, $iD7q0$useLabels)({
18
47
  id: id,
19
- 'aria-label': ariaLabel,
20
- 'aria-labelledby': ariaLabelledby
48
+ "aria-label": ariaLabel,
49
+ "aria-labelledby": ariaLabelledby
21
50
  });
22
51
  return {
23
52
  labelProps: labelProps,
@@ -29,24 +58,24 @@ function $d191a55c9702f145$export$8467354a121f1b9f(props) {
29
58
 
30
59
  function $2baaea4c71418dea$export$294aa081a6c6f55d(props) {
31
60
  let { description: description , errorMessage: errorMessage , validationState: validationState } = props;
32
- let { labelProps: labelProps , fieldProps: fieldProps } = $d191a55c9702f145$export$8467354a121f1b9f(props);
33
- let descriptionId = $iD7q0$useSlotId([
61
+ let { labelProps: labelProps , fieldProps: fieldProps } = (0, $d191a55c9702f145$export$8467354a121f1b9f)(props);
62
+ let descriptionId = (0, $iD7q0$useSlotId)([
34
63
  Boolean(description),
35
64
  Boolean(errorMessage),
36
65
  validationState
37
66
  ]);
38
- let errorMessageId = $iD7q0$useSlotId([
67
+ let errorMessageId = (0, $iD7q0$useSlotId)([
39
68
  Boolean(description),
40
69
  Boolean(errorMessage),
41
70
  validationState
42
71
  ]);
43
- fieldProps = $iD7q0$mergeProps(fieldProps, {
44
- 'aria-describedby': [
72
+ fieldProps = (0, $iD7q0$mergeProps)(fieldProps, {
73
+ "aria-describedby": [
45
74
  descriptionId,
46
75
  // 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
47
76
  errorMessageId,
48
- props['aria-describedby']
49
- ].filter(Boolean).join(' ') || undefined
77
+ props["aria-describedby"]
78
+ ].filter(Boolean).join(" ") || undefined
50
79
  });
51
80
  return {
52
81
  labelProps: labelProps,
@@ -1 +1 @@
1
- {"mappings":";;;SEoCgB,yCAAQ,CAAC,KAAqB,EAAa,CAAC;IAC1D,GAAG,CAAC,CAAC,KACH,EAAE,UACF,KAAK,GACL,CAAiB,kBAAE,cAAc,GACjC,CAAY,aAAE,SAAS,qBACvB,gBAAgB,GAAG,CAAO,QAC5B,CAAC,GAAG,KAAK;IAET,EAAE,GAAG,YAAK,CAAC,EAAE;IACb,GAAG,CAAC,OAAO,GAAG,YAAK;IACnB,GAAG,CAAC,UAAU,GAAG,CAAC;IAAA,CAAC;IACnB,EAAE,EAAE,KAAK,EAAE,CAAC;QACV,cAAc,GAAG,cAAc,MAAM,cAAc,CAAC,CAAC,EAAE,OAAO,KAAK,OAAO;QAC1E,UAAU,GAAG,CAAC;YACZ,EAAE,EAAE,OAAO;YACX,OAAO,EAAE,gBAAgB,KAAK,CAAO,SAAG,EAAE,GAAG,SAAS;QACxD,CAAC;IACH,CAAC,MAAM,EAAE,GAAG,cAAc,KAAK,SAAS,EACtC,OAAO,CAAC,IAAI,CAAC,CAAsH;IAGrI,GAAG,CAAC,UAAU,GAAG,gBAAS,CAAC,CAAC;YAC1B,EAAE;QACF,CAAY,aAAE,SAAS;QACvB,CAAiB,kBAAE,cAAc;IACnC,CAAC;IAED,MAAM,CAAC,CAAC;oBACN,UAAU;oBACV,UAAU;IACZ,CAAC;AACH,CAAC;;;;SDtCe,yCAAQ,CAAC,KAAqB,EAAa,CAAC;IAC1D,GAAG,CAAC,CAAC,cAAA,WAAW,iBAAE,YAAY,oBAAE,eAAe,EAAA,CAAC,GAAG,KAAK;IACxD,GAAG,CAAC,CAAC,aAAA,UAAU,eAAE,UAAU,EAAA,CAAC,GAAG,yCAAQ,CAAC,KAAK;IAE7C,GAAG,CAAC,aAAa,GAAG,gBAAS,CAAC,CAAC;QAAA,OAAO,CAAC,WAAW;QAAG,OAAO,CAAC,YAAY;QAAG,eAAe;IAAA,CAAC;IAC5F,GAAG,CAAC,cAAc,GAAG,gBAAS,CAAC,CAAC;QAAA,OAAO,CAAC,WAAW;QAAG,OAAO,CAAC,YAAY;QAAG,eAAe;IAAA,CAAC;IAE7F,UAAU,GAAG,iBAAU,CAAC,UAAU,EAAE,CAAC;QACnC,CAAkB,mBAAE,CAAC;YACnB,aAAa;YACb,EAA0L,AAA1L,wLAA0L;YAC1L,cAAc;YACd,KAAK,CAAC,CAAkB;QAC1B,CAAC,CAAC,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,CAAG,OAAK,SAAS;IAC1C,CAAC;IAED,MAAM,CAAC,CAAC;oBACN,UAAU;oBACV,UAAU;QACV,gBAAgB,EAAE,CAAC;YACjB,EAAE,EAAE,aAAa;QACnB,CAAC;QACD,iBAAiB,EAAE,CAAC;YAClB,EAAE,EAAE,cAAc;QACpB,CAAC;IACH,CAAC;AACH,CAAC","sources":["packages/@react-aria/label/src/index.ts","packages/@react-aria/label/src/useField.ts","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\nexport type {AriaFieldProps, FieldAria} from './useField';\nexport type {LabelAriaProps, LabelAria} from './useLabel';\n\nexport {useField} from './useField';\nexport {useLabel} from './useLabel';\n","/*\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, '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, validationState} = props;\n let {labelProps, fieldProps} = useLabel(props);\n\n let descriptionId = useSlotId([Boolean(description), Boolean(errorMessage), validationState]);\n let errorMessageId = useSlotId([Boolean(description), Boolean(errorMessage), 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","/*\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 ? `${ariaLabelledby} ${labelId}` : 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":"module.js.map"}
1
+ {"mappings":";;AAAA;;;;;;;;;;ACAA;;;;;;;;;;ACAA;;;;;;;;;;CAUC,GAED;AAwBO,SAAS,0CAAS,KAAqB,EAAa;IACzD,IAAI,MACF,GAAE,SACF,MAAK,EACL,mBAAmB,eAAc,EACjC,cAAc,UAAS,oBACvB,mBAAmB,UACpB,GAAG;IAEJ,KAAK,CAAA,GAAA,YAAI,EAAE;IACX,IAAI,UAAU,CAAA,GAAA,YAAK,AAAD;IAClB,IAAI,aAAa,CAAC;IAClB,IAAI,OAAO;QACT,iBAAiB,iBAAiB,CAAC,EAAE,eAAe,CAAC,EAAE,QAAQ,CAAC,GAAG,OAAO;QAC1E,aAAa;YACX,IAAI;YACJ,SAAS,qBAAqB,UAAU,KAAK,SAAS;QACxD;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;;CD1DC,GAED;;AAkBO,SAAS,0CAAS,KAAqB,EAAa;IACzD,IAAI,eAAC,YAAW,gBAAE,aAAY,mBAAE,gBAAe,EAAC,GAAG;IACnD,IAAI,cAAC,WAAU,cAAE,WAAU,EAAC,GAAG,CAAA,GAAA,yCAAQ,AAAD,EAAE;IAExC,IAAI,gBAAgB,CAAA,GAAA,gBAAQ,EAAE;QAAC,QAAQ;QAAc,QAAQ;QAAe;KAAgB;IAC5F,IAAI,iBAAiB,CAAA,GAAA,gBAAQ,EAAE;QAAC,QAAQ;QAAc,QAAQ;QAAe;KAAgB;IAE7F,aAAa,CAAA,GAAA,iBAAU,AAAD,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;;CD9CC,GAED","sources":["packages/@react-aria/label/src/index.ts","packages/@react-aria/label/src/useField.ts","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\nexport type {AriaFieldProps, FieldAria} from './useField';\nexport type {LabelAriaProps, LabelAria} from './useLabel';\n\nexport {useField} from './useField';\nexport {useLabel} from './useLabel';\n","/*\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, '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, validationState} = props;\n let {labelProps, fieldProps} = useLabel(props);\n\n let descriptionId = useSlotId([Boolean(description), Boolean(errorMessage), validationState]);\n let errorMessageId = useSlotId([Boolean(description), Boolean(errorMessage), 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","/*\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 ? `${ariaLabelledby} ${labelId}` : 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":"module.js.map"}
package/package.json CHANGED
@@ -1,10 +1,15 @@
1
1
  {
2
2
  "name": "@react-aria/label",
3
- "version": "3.4.3",
3
+ "version": "3.5.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
+ "exports": {
9
+ "types": "./dist/types.d.ts",
10
+ "import": "./dist/import.mjs",
11
+ "require": "./dist/main.js"
12
+ },
8
13
  "types": "dist/types.d.ts",
9
14
  "source": "src/index.ts",
10
15
  "files": [
@@ -17,10 +22,10 @@
17
22
  "url": "https://github.com/adobe/react-spectrum"
18
23
  },
19
24
  "dependencies": {
20
- "@babel/runtime": "^7.6.2",
21
- "@react-aria/utils": "^3.14.1",
22
- "@react-types/label": "^3.7.1",
23
- "@react-types/shared": "^3.16.0"
25
+ "@react-aria/utils": "^3.15.0",
26
+ "@react-types/label": "^3.7.2",
27
+ "@react-types/shared": "^3.17.0",
28
+ "@swc/helpers": "^0.4.14"
24
29
  },
25
30
  "peerDependencies": {
26
31
  "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0"
@@ -28,5 +33,5 @@
28
33
  "publishConfig": {
29
34
  "access": "public"
30
35
  },
31
- "gitHead": "2954307ddbefe149241685440c81f80ece6b2c83"
36
+ "gitHead": "a0efee84aa178cb1a202951dfd6d8de02b292307"
32
37
  }