@react-aria/label 3.4.4 → 3.5.1

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.
Files changed (2) hide show
  1. package/dist/import.mjs +97 -0
  2. package/package.json +10 -5
@@ -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/package.json CHANGED
@@ -1,10 +1,15 @@
1
1
  {
2
2
  "name": "@react-aria/label",
3
- "version": "3.4.4",
3
+ "version": "3.5.1",
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,9 +22,9 @@
17
22
  "url": "https://github.com/adobe/react-spectrum"
18
23
  },
19
24
  "dependencies": {
20
- "@react-aria/utils": "^3.14.2",
21
- "@react-types/label": "^3.7.1",
22
- "@react-types/shared": "^3.16.0",
25
+ "@react-aria/utils": "^3.16.0",
26
+ "@react-types/label": "^3.7.3",
27
+ "@react-types/shared": "^3.18.0",
23
28
  "@swc/helpers": "^0.4.14"
24
29
  },
25
30
  "peerDependencies": {
@@ -28,5 +33,5 @@
28
33
  "publishConfig": {
29
34
  "access": "public"
30
35
  },
31
- "gitHead": "5480d76bd815e239366f92852c76b6831ad2a4fd"
36
+ "gitHead": "9d1ba9bd8ebcd63bf3495ade16d349bcb71795ce"
32
37
  }