@react-aria/label 3.7.2 → 3.7.4
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/main.js +1 -0
- package/dist/main.js.map +1 -1
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +4 -5
- package/src/useField.ts +1 -1
package/dist/main.js
CHANGED
package/dist/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"
|
|
1
|
+
{"mappings":";;;;;;;;;AAAA;;;;;;;;;;ACAA;;;;;;;;;;ACAA;;;;;;;;;;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;;CD1DC;;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,+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;;CD9CC","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<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","/*\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":"main.js.map"}
|
package/dist/module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;AAAA;;;;;;;;;;ACAA;;;;;;;;;;ACAA;;;;;;;;;;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,U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Q;IACjC;IAEA,OAAO;oBACL;oBACA;QACA,kBAAkB;YAChB,IAAI;QACN;QACA,mBAAmB;YACjB,IAAI;QACN;IACF;AACF;;CD9CC","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<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","/*\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":"module.js.map"}
|
package/dist/types.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ export interface LabelAria {
|
|
|
19
19
|
* @param props - The props for labels and fields.
|
|
20
20
|
*/
|
|
21
21
|
export function useLabel(props: LabelAriaProps): LabelAria;
|
|
22
|
-
export interface AriaFieldProps extends LabelAriaProps, HelpTextProps, Omit<Validation
|
|
22
|
+
export interface AriaFieldProps extends LabelAriaProps, HelpTextProps, Omit<Validation<any>, 'isRequired'> {
|
|
23
23
|
}
|
|
24
24
|
export interface FieldAria extends LabelAria {
|
|
25
25
|
/** Props for the description element, if any. */
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +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,
|
|
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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-aria/label",
|
|
3
|
-
"version": "3.7.
|
|
3
|
+
"version": "3.7.4",
|
|
4
4
|
"description": "Spectrum UI components in React",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/main.js",
|
|
@@ -22,9 +22,8 @@
|
|
|
22
22
|
"url": "https://github.com/adobe/react-spectrum"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@react-aria/utils": "^3.
|
|
26
|
-
"@react-types/
|
|
27
|
-
"@react-types/shared": "^3.21.0",
|
|
25
|
+
"@react-aria/utils": "^3.23.0",
|
|
26
|
+
"@react-types/shared": "^3.22.0",
|
|
28
27
|
"@swc/helpers": "^0.5.0"
|
|
29
28
|
},
|
|
30
29
|
"peerDependencies": {
|
|
@@ -33,5 +32,5 @@
|
|
|
33
32
|
"publishConfig": {
|
|
34
33
|
"access": "public"
|
|
35
34
|
},
|
|
36
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "86b38c87868ce7f262e0df905e5ac4eb2653791d"
|
|
37
36
|
}
|
package/src/useField.ts
CHANGED
|
@@ -14,7 +14,7 @@ import {DOMAttributes, HelpTextProps, Validation} from '@react-types/shared';
|
|
|
14
14
|
import {LabelAria, LabelAriaProps, useLabel} from './useLabel';
|
|
15
15
|
import {mergeProps, useSlotId} from '@react-aria/utils';
|
|
16
16
|
|
|
17
|
-
export interface AriaFieldProps extends LabelAriaProps, HelpTextProps, Omit<Validation
|
|
17
|
+
export interface AriaFieldProps extends LabelAriaProps, HelpTextProps, Omit<Validation<any>, 'isRequired'> {}
|
|
18
18
|
|
|
19
19
|
export interface FieldAria extends LabelAria {
|
|
20
20
|
/** Props for the description element, if any. */
|