@react-spectrum/textfield 3.11.4 → 3.12.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,104 @@
1
+ import "./vars.07716e14.css";
2
+ import $264pK$textfield_vars_cssmodulejs from "./textfield_vars_css.mjs";
3
+ import $264pK$spectrumiconsuiAlertMedium from "@spectrum-icons/ui/AlertMedium";
4
+ import $264pK$spectrumiconsuiCheckmarkMedium from "@spectrum-icons/ui/CheckmarkMedium";
5
+ import {createFocusableRef as $264pK$createFocusableRef, classNames as $264pK$classNames} from "@react-spectrum/utils";
6
+ import {Field as $264pK$Field} from "@react-spectrum/label";
7
+ import {mergeProps as $264pK$mergeProps} from "@react-aria/utils";
8
+ import $264pK$react, {useRef as $264pK$useRef, useImperativeHandle as $264pK$useImperativeHandle, cloneElement as $264pK$cloneElement, forwardRef as $264pK$forwardRef} from "react";
9
+ import {useFocusRing as $264pK$useFocusRing} from "@react-aria/focus";
10
+ import {useHover as $264pK$useHover} from "@react-aria/interactions";
11
+
12
+
13
+ function $parcel$interopDefault(a) {
14
+ return a && a.__esModule ? a.default : a;
15
+ }
16
+ /*
17
+ * Copyright 2020 Adobe. All rights reserved.
18
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
19
+ * you may not use this file except in compliance with the License. You may obtain a copy
20
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
21
+ *
22
+ * Unless required by applicable law or agreed to in writing, software distributed under
23
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
24
+ * OF ANY KIND, either express or implied. See the License for the specific language
25
+ * governing permissions and limitations under the License.
26
+ */
27
+
28
+
29
+
30
+
31
+
32
+
33
+
34
+
35
+ function $599adb75312e6492$var$TextFieldBase(props, ref) {
36
+ let { validationState: validationState = props.isInvalid ? "invalid" : null, icon: icon, isQuiet: isQuiet = false, isDisabled: isDisabled, multiLine: multiLine, autoFocus: autoFocus, inputClassName: inputClassName, wrapperChildren: wrapperChildren, labelProps: labelProps, inputProps: inputProps, descriptionProps: descriptionProps, errorMessageProps: errorMessageProps, inputRef: userInputRef, isLoading: isLoading, loadingIndicator: loadingIndicator, validationIconClassName: validationIconClassName, disableFocusRing: disableFocusRing } = props;
37
+ let { hoverProps: hoverProps, isHovered: isHovered } = (0, $264pK$useHover)({
38
+ isDisabled: isDisabled
39
+ });
40
+ let domRef = (0, $264pK$useRef)(null);
41
+ let defaultInputRef = (0, $264pK$useRef)(null);
42
+ let inputRef = userInputRef || defaultInputRef;
43
+ // Expose imperative interface for ref
44
+ (0, $264pK$useImperativeHandle)(ref, ()=>({
45
+ ...(0, $264pK$createFocusableRef)(domRef, inputRef),
46
+ select () {
47
+ if (inputRef.current) inputRef.current.select();
48
+ },
49
+ getInputElement () {
50
+ return inputRef.current;
51
+ }
52
+ }));
53
+ let ElementType = multiLine ? "textarea" : "input";
54
+ let isInvalid = validationState === "invalid" && !isDisabled;
55
+ if (icon) {
56
+ let UNSAFE_className = (0, $264pK$classNames)((0, ($parcel$interopDefault($264pK$textfield_vars_cssmodulejs))), icon.props && icon.props.UNSAFE_className, "spectrum-Textfield-icon");
57
+ icon = /*#__PURE__*/ (0, $264pK$cloneElement)(icon, {
58
+ UNSAFE_className: UNSAFE_className,
59
+ size: "S"
60
+ });
61
+ }
62
+ let validationIcon = isInvalid ? /*#__PURE__*/ (0, $264pK$react).createElement((0, $264pK$spectrumiconsuiAlertMedium), null) : /*#__PURE__*/ (0, $264pK$react).createElement((0, $264pK$spectrumiconsuiCheckmarkMedium), null);
63
+ let validation = /*#__PURE__*/ (0, $264pK$cloneElement)(validationIcon, {
64
+ UNSAFE_className: (0, $264pK$classNames)((0, ($parcel$interopDefault($264pK$textfield_vars_cssmodulejs))), "spectrum-Textfield-validationIcon", validationIconClassName)
65
+ });
66
+ let { focusProps: focusProps, isFocusVisible: isFocusVisible } = (0, $264pK$useFocusRing)({
67
+ isTextInput: true,
68
+ autoFocus: autoFocus
69
+ });
70
+ let textField = /*#__PURE__*/ (0, $264pK$react).createElement("div", {
71
+ className: (0, $264pK$classNames)((0, ($parcel$interopDefault($264pK$textfield_vars_cssmodulejs))), "spectrum-Textfield", {
72
+ "spectrum-Textfield--invalid": isInvalid,
73
+ "spectrum-Textfield--valid": validationState === "valid" && !isDisabled,
74
+ "spectrum-Textfield--loadable": loadingIndicator,
75
+ "spectrum-Textfield--quiet": isQuiet,
76
+ "spectrum-Textfield--multiline": multiLine,
77
+ "focus-ring": !disableFocusRing && isFocusVisible
78
+ })
79
+ }, /*#__PURE__*/ (0, $264pK$react).createElement(ElementType, {
80
+ ...(0, $264pK$mergeProps)(inputProps, hoverProps, focusProps),
81
+ ref: inputRef,
82
+ rows: multiLine ? 1 : undefined,
83
+ className: (0, $264pK$classNames)((0, ($parcel$interopDefault($264pK$textfield_vars_cssmodulejs))), "spectrum-Textfield-input", {
84
+ "spectrum-Textfield-inputIcon": icon,
85
+ "is-hovered": isHovered
86
+ }, inputClassName)
87
+ }), icon, validationState && !isLoading && !isDisabled ? validation : null, isLoading && loadingIndicator, wrapperChildren);
88
+ return /*#__PURE__*/ (0, $264pK$react).createElement((0, $264pK$Field), {
89
+ ...props,
90
+ labelProps: labelProps,
91
+ descriptionProps: descriptionProps,
92
+ errorMessageProps: errorMessageProps,
93
+ wrapperClassName: (0, $264pK$classNames)((0, ($parcel$interopDefault($264pK$textfield_vars_cssmodulejs))), "spectrum-Textfield-wrapper", {
94
+ "spectrum-Textfield-wrapper--quiet": isQuiet
95
+ }),
96
+ showErrorIcon: false,
97
+ ref: domRef
98
+ }, textField);
99
+ }
100
+ const $599adb75312e6492$export$d22444a338b6e3c2 = /*#__PURE__*/ (0, $264pK$forwardRef)($599adb75312e6492$var$TextFieldBase);
101
+
102
+
103
+ export {$599adb75312e6492$export$d22444a338b6e3c2 as TextFieldBase};
104
+ //# sourceMappingURL=TextFieldBase.mjs.map
@@ -0,0 +1,104 @@
1
+ import "./vars.07716e14.css";
2
+ import $264pK$textfield_vars_cssmodulejs from "./textfield_vars_css.module.js";
3
+ import $264pK$spectrumiconsuiAlertMedium from "@spectrum-icons/ui/AlertMedium";
4
+ import $264pK$spectrumiconsuiCheckmarkMedium from "@spectrum-icons/ui/CheckmarkMedium";
5
+ import {createFocusableRef as $264pK$createFocusableRef, classNames as $264pK$classNames} from "@react-spectrum/utils";
6
+ import {Field as $264pK$Field} from "@react-spectrum/label";
7
+ import {mergeProps as $264pK$mergeProps} from "@react-aria/utils";
8
+ import $264pK$react, {useRef as $264pK$useRef, useImperativeHandle as $264pK$useImperativeHandle, cloneElement as $264pK$cloneElement, forwardRef as $264pK$forwardRef} from "react";
9
+ import {useFocusRing as $264pK$useFocusRing} from "@react-aria/focus";
10
+ import {useHover as $264pK$useHover} from "@react-aria/interactions";
11
+
12
+
13
+ function $parcel$interopDefault(a) {
14
+ return a && a.__esModule ? a.default : a;
15
+ }
16
+ /*
17
+ * Copyright 2020 Adobe. All rights reserved.
18
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
19
+ * you may not use this file except in compliance with the License. You may obtain a copy
20
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
21
+ *
22
+ * Unless required by applicable law or agreed to in writing, software distributed under
23
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
24
+ * OF ANY KIND, either express or implied. See the License for the specific language
25
+ * governing permissions and limitations under the License.
26
+ */
27
+
28
+
29
+
30
+
31
+
32
+
33
+
34
+
35
+ function $599adb75312e6492$var$TextFieldBase(props, ref) {
36
+ let { validationState: validationState = props.isInvalid ? "invalid" : null, icon: icon, isQuiet: isQuiet = false, isDisabled: isDisabled, multiLine: multiLine, autoFocus: autoFocus, inputClassName: inputClassName, wrapperChildren: wrapperChildren, labelProps: labelProps, inputProps: inputProps, descriptionProps: descriptionProps, errorMessageProps: errorMessageProps, inputRef: userInputRef, isLoading: isLoading, loadingIndicator: loadingIndicator, validationIconClassName: validationIconClassName, disableFocusRing: disableFocusRing } = props;
37
+ let { hoverProps: hoverProps, isHovered: isHovered } = (0, $264pK$useHover)({
38
+ isDisabled: isDisabled
39
+ });
40
+ let domRef = (0, $264pK$useRef)(null);
41
+ let defaultInputRef = (0, $264pK$useRef)(null);
42
+ let inputRef = userInputRef || defaultInputRef;
43
+ // Expose imperative interface for ref
44
+ (0, $264pK$useImperativeHandle)(ref, ()=>({
45
+ ...(0, $264pK$createFocusableRef)(domRef, inputRef),
46
+ select () {
47
+ if (inputRef.current) inputRef.current.select();
48
+ },
49
+ getInputElement () {
50
+ return inputRef.current;
51
+ }
52
+ }));
53
+ let ElementType = multiLine ? "textarea" : "input";
54
+ let isInvalid = validationState === "invalid" && !isDisabled;
55
+ if (icon) {
56
+ let UNSAFE_className = (0, $264pK$classNames)((0, ($parcel$interopDefault($264pK$textfield_vars_cssmodulejs))), icon.props && icon.props.UNSAFE_className, "spectrum-Textfield-icon");
57
+ icon = /*#__PURE__*/ (0, $264pK$cloneElement)(icon, {
58
+ UNSAFE_className: UNSAFE_className,
59
+ size: "S"
60
+ });
61
+ }
62
+ let validationIcon = isInvalid ? /*#__PURE__*/ (0, $264pK$react).createElement((0, $264pK$spectrumiconsuiAlertMedium), null) : /*#__PURE__*/ (0, $264pK$react).createElement((0, $264pK$spectrumiconsuiCheckmarkMedium), null);
63
+ let validation = /*#__PURE__*/ (0, $264pK$cloneElement)(validationIcon, {
64
+ UNSAFE_className: (0, $264pK$classNames)((0, ($parcel$interopDefault($264pK$textfield_vars_cssmodulejs))), "spectrum-Textfield-validationIcon", validationIconClassName)
65
+ });
66
+ let { focusProps: focusProps, isFocusVisible: isFocusVisible } = (0, $264pK$useFocusRing)({
67
+ isTextInput: true,
68
+ autoFocus: autoFocus
69
+ });
70
+ let textField = /*#__PURE__*/ (0, $264pK$react).createElement("div", {
71
+ className: (0, $264pK$classNames)((0, ($parcel$interopDefault($264pK$textfield_vars_cssmodulejs))), "spectrum-Textfield", {
72
+ "spectrum-Textfield--invalid": isInvalid,
73
+ "spectrum-Textfield--valid": validationState === "valid" && !isDisabled,
74
+ "spectrum-Textfield--loadable": loadingIndicator,
75
+ "spectrum-Textfield--quiet": isQuiet,
76
+ "spectrum-Textfield--multiline": multiLine,
77
+ "focus-ring": !disableFocusRing && isFocusVisible
78
+ })
79
+ }, /*#__PURE__*/ (0, $264pK$react).createElement(ElementType, {
80
+ ...(0, $264pK$mergeProps)(inputProps, hoverProps, focusProps),
81
+ ref: inputRef,
82
+ rows: multiLine ? 1 : undefined,
83
+ className: (0, $264pK$classNames)((0, ($parcel$interopDefault($264pK$textfield_vars_cssmodulejs))), "spectrum-Textfield-input", {
84
+ "spectrum-Textfield-inputIcon": icon,
85
+ "is-hovered": isHovered
86
+ }, inputClassName)
87
+ }), icon, validationState && !isLoading && !isDisabled ? validation : null, isLoading && loadingIndicator, wrapperChildren);
88
+ return /*#__PURE__*/ (0, $264pK$react).createElement((0, $264pK$Field), {
89
+ ...props,
90
+ labelProps: labelProps,
91
+ descriptionProps: descriptionProps,
92
+ errorMessageProps: errorMessageProps,
93
+ wrapperClassName: (0, $264pK$classNames)((0, ($parcel$interopDefault($264pK$textfield_vars_cssmodulejs))), "spectrum-Textfield-wrapper", {
94
+ "spectrum-Textfield-wrapper--quiet": isQuiet
95
+ }),
96
+ showErrorIcon: false,
97
+ ref: domRef
98
+ }, textField);
99
+ }
100
+ const $599adb75312e6492$export$d22444a338b6e3c2 = /*#__PURE__*/ (0, $264pK$forwardRef)($599adb75312e6492$var$TextFieldBase);
101
+
102
+
103
+ export {$599adb75312e6492$export$d22444a338b6e3c2 as TextFieldBase};
104
+ //# sourceMappingURL=TextFieldBase.module.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;AA6BD,SAAS,oCAAc,KAAyB,EAAE,GAAsB;IACtE,IAAI,mBACF,kBAAkB,MAAM,SAAS,GAAG,YAAY,YAChD,IAAI,WACJ,UAAU,mBACV,UAAU,aACV,SAAS,aACT,SAAS,kBACT,cAAc,mBACd,eAAe,cACf,UAAU,cACV,UAAU,oBACV,gBAAgB,qBAChB,iBAAiB,EACjB,UAAU,YAAY,aACtB,SAAS,oBACT,gBAAgB,2BAChB,uBAAuB,oBACvB,gBAAgB,EACjB,GAAG;IACJ,IAAI,cAAC,UAAU,aAAE,SAAS,EAAC,GAAG,CAAA,GAAA,eAAO,EAAE;oBAAC;IAAU;IAClD,IAAI,SAAS,CAAA,GAAA,aAAK,EAAkB;IACpC,IAAI,kBAAkB,CAAA,GAAA,aAAK,EAA0C;IACrE,IAAI,WAAW,gBAAgB;IAE/B,sCAAsC;IACtC,CAAA,GAAA,0BAAkB,EAAE,KAAK,IAAO,CAAA;YAC9B,GAAG,CAAA,GAAA,yBAAiB,EAAE,QAAQ,SAAS;YACvC;gBACE,IAAI,SAAS,OAAO,EAClB,SAAS,OAAO,CAAC,MAAM;YAE3B;YACA;gBACE,OAAO,SAAS,OAAO;YACzB;QACF,CAAA;IAEA,IAAI,cAAiC,YAAY,aAAa;IAC9D,IAAI,YAAY,oBAAoB,aAAa,CAAC;IAElD,IAAI,MAAM;QACR,IAAI,mBAAmB,CAAA,GAAA,iBAAS,EAC9B,CAAA,GAAA,2DAAK,GACL,KAAK,KAAK,IAAI,KAAK,KAAK,CAAC,gBAAgB,EACzC;QAGF,qBAAO,CAAA,GAAA,mBAAW,EAAE,MAAM;8BACxB;YACA,MAAM;QACR;IACF;IAEA,IAAI,iBAAiB,0BAAY,gCAAC,CAAA,GAAA,iCAAU,yBAAO,gCAAC,CAAA,GAAA,qCAAc;IAClE,IAAI,2BAAa,CAAA,GAAA,mBAAW,EAAE,gBAAgB;QAC5C,kBAAkB,CAAA,GAAA,iBAAS,EACzB,CAAA,GAAA,2DAAK,GACL,qCACA;IAEJ;IAEA,IAAI,cAAC,UAAU,kBAAE,cAAc,EAAC,GAAG,CAAA,GAAA,mBAAW,EAAE;QAC9C,aAAa;mBACb;IACF;IAEA,IAAI,0BACF,gCAAC;QACC,WACE,CAAA,GAAA,iBAAS,EACP,CAAA,GAAA,2DAAK,GACL,sBACA;YACE,+BAA+B;YAC/B,6BAA6B,oBAAoB,WAAW,CAAC;YAC7D,gCAAgC;YAChC,6BAA6B;YAC7B,iCAAiC;YACjC,cAAc,CAAC,oBAAoB;QACrC;qBAGJ,gCAAC;QACE,GAAG,CAAA,GAAA,iBAAS,EAAE,YAAY,YAAY,WAAW;QAClD,KAAK;QACL,MAAM,YAAY,IAAI;QACtB,WACE,CAAA,GAAA,iBAAS,EACP,CAAA,GAAA,2DAAK,GACL,4BACA;YACE,gCAAgC;YAChC,cAAc;QAChB,GACA;QAGL,MACA,mBAAmB,CAAC,aAAa,CAAC,aAAa,aAAa,MAC5D,aAAa,kBACb;IAIL,qBACE,gCAAC,CAAA,GAAA,YAAI;QACF,GAAG,KAAK;QACT,YAAY;QACZ,kBAAkB;QAClB,mBAAmB;QACnB,kBACE,CAAA,GAAA,iBAAS,EACP,CAAA,GAAA,2DAAK,GACL,8BACA;YACE,qCAAqC;QACvC;QAGJ,eAAe;QACf,KAAK;OACJ;AAGP;AAEA,MAAM,0DAAiB,CAAA,GAAA,iBAAS,EAAE","sources":["packages/@react-spectrum/textfield/src/TextFieldBase.tsx"],"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 AlertMedium from '@spectrum-icons/ui/AlertMedium';\nimport CheckmarkMedium from '@spectrum-icons/ui/CheckmarkMedium';\nimport {classNames, createFocusableRef} from '@react-spectrum/utils';\nimport {Field} from '@react-spectrum/label';\nimport {mergeProps} from '@react-aria/utils';\nimport {PressEvents, ValidationResult} from '@react-types/shared';\nimport React, {cloneElement, forwardRef, HTMLAttributes, InputHTMLAttributes, LabelHTMLAttributes, ReactElement, Ref, RefObject, TextareaHTMLAttributes, useImperativeHandle, useRef} from 'react';\nimport {SpectrumTextFieldProps, TextFieldRef} from '@react-types/textfield';\nimport styles from '@adobe/spectrum-css-temp/components/textfield/vars.css';\nimport {useFocusRing} from '@react-aria/focus';\nimport {useHover} from '@react-aria/interactions';\n\ninterface TextFieldBaseProps extends Omit<SpectrumTextFieldProps, 'onChange' | 'validate'>, PressEvents, Partial<ValidationResult> {\n wrapperChildren?: ReactElement | ReactElement[],\n inputClassName?: string,\n validationIconClassName?: string,\n multiLine?: boolean,\n labelProps?: LabelHTMLAttributes<HTMLLabelElement>,\n inputProps: InputHTMLAttributes<HTMLInputElement> | TextareaHTMLAttributes<HTMLTextAreaElement>,\n descriptionProps?: HTMLAttributes<HTMLElement>,\n errorMessageProps?: HTMLAttributes<HTMLElement>,\n inputRef?: RefObject<HTMLInputElement | HTMLTextAreaElement>,\n loadingIndicator?: ReactElement,\n isLoading?: boolean,\n disableFocusRing?: boolean\n}\n\nfunction TextFieldBase(props: TextFieldBaseProps, ref: Ref<TextFieldRef>) {\n let {\n validationState = props.isInvalid ? 'invalid' : null,\n icon,\n isQuiet = false,\n isDisabled,\n multiLine,\n autoFocus,\n inputClassName,\n wrapperChildren,\n labelProps,\n inputProps,\n descriptionProps,\n errorMessageProps,\n inputRef: userInputRef,\n isLoading,\n loadingIndicator,\n validationIconClassName,\n disableFocusRing\n } = props;\n let {hoverProps, isHovered} = useHover({isDisabled});\n let domRef = useRef<HTMLDivElement>(null);\n let defaultInputRef = useRef<HTMLInputElement | HTMLTextAreaElement>(null);\n let inputRef = userInputRef || defaultInputRef;\n\n // Expose imperative interface for ref\n useImperativeHandle(ref, () => ({\n ...createFocusableRef(domRef, inputRef),\n select() {\n if (inputRef.current) {\n inputRef.current.select();\n }\n },\n getInputElement() {\n return inputRef.current;\n }\n }));\n\n let ElementType: React.ElementType = multiLine ? 'textarea' : 'input';\n let isInvalid = validationState === 'invalid' && !isDisabled;\n\n if (icon) {\n let UNSAFE_className = classNames(\n styles,\n icon.props && icon.props.UNSAFE_className,\n 'spectrum-Textfield-icon'\n );\n\n icon = cloneElement(icon, {\n UNSAFE_className,\n size: 'S'\n });\n }\n\n let validationIcon = isInvalid ? <AlertMedium /> : <CheckmarkMedium />;\n let validation = cloneElement(validationIcon, {\n UNSAFE_className: classNames(\n styles,\n 'spectrum-Textfield-validationIcon',\n validationIconClassName\n )\n });\n\n let {focusProps, isFocusVisible} = useFocusRing({\n isTextInput: true,\n autoFocus\n });\n\n let textField = (\n <div\n className={\n classNames(\n styles,\n 'spectrum-Textfield',\n {\n 'spectrum-Textfield--invalid': isInvalid,\n 'spectrum-Textfield--valid': validationState === 'valid' && !isDisabled,\n 'spectrum-Textfield--loadable': loadingIndicator,\n 'spectrum-Textfield--quiet': isQuiet,\n 'spectrum-Textfield--multiline': multiLine,\n 'focus-ring': !disableFocusRing && isFocusVisible\n }\n )\n }>\n <ElementType\n {...mergeProps(inputProps, hoverProps, focusProps)}\n ref={inputRef as any}\n rows={multiLine ? 1 : undefined}\n className={\n classNames(\n styles,\n 'spectrum-Textfield-input',\n {\n 'spectrum-Textfield-inputIcon': icon,\n 'is-hovered': isHovered\n },\n inputClassName\n )\n } />\n {icon}\n {validationState && !isLoading && !isDisabled ? validation : null}\n {isLoading && loadingIndicator}\n {wrapperChildren}\n </div>\n );\n\n return (\n <Field\n {...props}\n labelProps={labelProps}\n descriptionProps={descriptionProps}\n errorMessageProps={errorMessageProps}\n wrapperClassName={\n classNames(\n styles,\n 'spectrum-Textfield-wrapper',\n {\n 'spectrum-Textfield-wrapper--quiet': isQuiet\n }\n )\n }\n showErrorIcon={false}\n ref={domRef}>\n {textField}\n </Field>\n );\n}\n\nconst _TextFieldBase = forwardRef(TextFieldBase);\nexport {_TextFieldBase as TextFieldBase};\n"],"names":[],"version":3,"file":"TextFieldBase.module.js.map"}
package/dist/import.mjs CHANGED
@@ -1,25 +1,7 @@
1
- import "./main.css";
2
- import {useLayoutEffect as $evhxb$useLayoutEffect, chain as $evhxb$chain, mergeProps as $evhxb$mergeProps} from "@react-aria/utils";
3
- import $evhxb$react, {useRef as $evhxb$useRef, useCallback as $evhxb$useCallback, useImperativeHandle as $evhxb$useImperativeHandle, cloneElement as $evhxb$cloneElement, forwardRef as $evhxb$forwardRef} from "react";
4
- import {useControlledState as $evhxb$useControlledState} from "@react-stately/utils";
5
- import {useFormProps as $evhxb$useFormProps} from "@react-spectrum/form";
6
- import {useProviderProps as $evhxb$useProviderProps} from "@react-spectrum/provider";
7
- import {useTextField as $evhxb$useTextField} from "@react-aria/textfield";
8
- import $evhxb$spectrumiconsuiAlertMedium from "@spectrum-icons/ui/AlertMedium";
9
- import $evhxb$spectrumiconsuiCheckmarkMedium from "@spectrum-icons/ui/CheckmarkMedium";
10
- import {createFocusableRef as $evhxb$createFocusableRef, classNames as $evhxb$classNames} from "@react-spectrum/utils";
11
- import {Field as $evhxb$Field} from "@react-spectrum/label";
12
- import {useFocusRing as $evhxb$useFocusRing} from "@react-aria/focus";
13
- import {useHover as $evhxb$useHover} from "@react-aria/interactions";
1
+ import {TextArea as $cc187bf91f8eea73$export$f5c9f3c2c4054eec} from "./TextArea.mjs";
2
+ import {TextField as $265457f9427aa380$export$2c73285ae9390cec} from "./TextField.mjs";
3
+ import {TextFieldBase as $599adb75312e6492$export$d22444a338b6e3c2} from "./TextFieldBase.mjs";
14
4
 
15
-
16
- function $parcel$interopDefault(a) {
17
- return a && a.__esModule ? a.default : a;
18
- }
19
-
20
- function $parcel$export(e, n, v, s) {
21
- Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
22
- }
23
5
  /*
24
6
  * Copyright 2020 Adobe. All rights reserved.
25
7
  * This file is licensed to you under the Apache License, Version 2.0 (the "License");
@@ -31,275 +13,6 @@ function $parcel$export(e, n, v, s) {
31
13
  * OF ANY KIND, either express or implied. See the License for the specific language
32
14
  * governing permissions and limitations under the License.
33
15
  */ /// <reference types="css-module-types" />
34
- /*
35
- * Copyright 2020 Adobe. All rights reserved.
36
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
37
- * you may not use this file except in compliance with the License. You may obtain a copy
38
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
39
- *
40
- * Unless required by applicable law or agreed to in writing, software distributed under
41
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
42
- * OF ANY KIND, either express or implied. See the License for the specific language
43
- * governing permissions and limitations under the License.
44
- */
45
-
46
- /*
47
- * Copyright 2020 Adobe. All rights reserved.
48
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
49
- * you may not use this file except in compliance with the License. You may obtain a copy
50
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
51
- *
52
- * Unless required by applicable law or agreed to in writing, software distributed under
53
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
54
- * OF ANY KIND, either express or implied. See the License for the specific language
55
- * governing permissions and limitations under the License.
56
- */
57
-
58
-
59
-
60
-
61
-
62
- var $c14528ddc146317f$exports = {};
63
-
64
- $parcel$export($c14528ddc146317f$exports, "focus-ring", () => $c14528ddc146317f$export$f39a09f249340e2a, (v) => $c14528ddc146317f$export$f39a09f249340e2a = v);
65
- $parcel$export($c14528ddc146317f$exports, "i18nFontFamily", () => $c14528ddc146317f$export$8c4ee2c50c22c514, (v) => $c14528ddc146317f$export$8c4ee2c50c22c514 = v);
66
- $parcel$export($c14528ddc146317f$exports, "is-disabled", () => $c14528ddc146317f$export$d35bc1e505d1ebbf, (v) => $c14528ddc146317f$export$d35bc1e505d1ebbf = v);
67
- $parcel$export($c14528ddc146317f$exports, "is-focused", () => $c14528ddc146317f$export$e7dc768d35940237, (v) => $c14528ddc146317f$export$e7dc768d35940237 = v);
68
- $parcel$export($c14528ddc146317f$exports, "is-hovered", () => $c14528ddc146317f$export$b8813cd5d7824ce7, (v) => $c14528ddc146317f$export$b8813cd5d7824ce7 = v);
69
- $parcel$export($c14528ddc146317f$exports, "is-placeholder", () => $c14528ddc146317f$export$e5b2f5233e4e5194, (v) => $c14528ddc146317f$export$e5b2f5233e4e5194 = v);
70
- $parcel$export($c14528ddc146317f$exports, "spectrum-FocusRing-ring", () => $c14528ddc146317f$export$4109102f950813a6, (v) => $c14528ddc146317f$export$4109102f950813a6 = v);
71
- $parcel$export($c14528ddc146317f$exports, "spectrum-FocusRing", () => $c14528ddc146317f$export$24c7f46a6e3605dd, (v) => $c14528ddc146317f$export$24c7f46a6e3605dd = v);
72
- $parcel$export($c14528ddc146317f$exports, "spectrum-FocusRing--quiet", () => $c14528ddc146317f$export$2927016961429360, (v) => $c14528ddc146317f$export$2927016961429360 = v);
73
- $parcel$export($c14528ddc146317f$exports, "spectrum-Textfield", () => $c14528ddc146317f$export$2c8a10299d8b3418, (v) => $c14528ddc146317f$export$2c8a10299d8b3418 = v);
74
- $parcel$export($c14528ddc146317f$exports, "spectrum-Textfield--invalid", () => $c14528ddc146317f$export$58e50b10d30123df, (v) => $c14528ddc146317f$export$58e50b10d30123df = v);
75
- $parcel$export($c14528ddc146317f$exports, "spectrum-Textfield--loadable", () => $c14528ddc146317f$export$14fd30fea6f1348c, (v) => $c14528ddc146317f$export$14fd30fea6f1348c = v);
76
- $parcel$export($c14528ddc146317f$exports, "spectrum-Textfield--multiline", () => $c14528ddc146317f$export$9699f1c538a448a0, (v) => $c14528ddc146317f$export$9699f1c538a448a0 = v);
77
- $parcel$export($c14528ddc146317f$exports, "spectrum-Textfield--quiet", () => $c14528ddc146317f$export$bffd5e3d61a81737, (v) => $c14528ddc146317f$export$bffd5e3d61a81737 = v);
78
- $parcel$export($c14528ddc146317f$exports, "spectrum-Textfield--valid", () => $c14528ddc146317f$export$c2abbc3f970170b7, (v) => $c14528ddc146317f$export$c2abbc3f970170b7 = v);
79
- $parcel$export($c14528ddc146317f$exports, "spectrum-Textfield-circleLoader", () => $c14528ddc146317f$export$82a249fb4d6127, (v) => $c14528ddc146317f$export$82a249fb4d6127 = v);
80
- $parcel$export($c14528ddc146317f$exports, "spectrum-Textfield-icon", () => $c14528ddc146317f$export$222d1ccd1870be1d, (v) => $c14528ddc146317f$export$222d1ccd1870be1d = v);
81
- $parcel$export($c14528ddc146317f$exports, "spectrum-Textfield-input", () => $c14528ddc146317f$export$1ac009feb2b0bd0c, (v) => $c14528ddc146317f$export$1ac009feb2b0bd0c = v);
82
- $parcel$export($c14528ddc146317f$exports, "spectrum-Textfield-inputIcon", () => $c14528ddc146317f$export$c1cdcaa5fe76a871, (v) => $c14528ddc146317f$export$c1cdcaa5fe76a871 = v);
83
- $parcel$export($c14528ddc146317f$exports, "spectrum-Textfield-validationIcon", () => $c14528ddc146317f$export$cf0ead5b44db0da3, (v) => $c14528ddc146317f$export$cf0ead5b44db0da3 = v);
84
- $parcel$export($c14528ddc146317f$exports, "spectrum-Textfield-wrapper", () => $c14528ddc146317f$export$dd1165e0e6012973, (v) => $c14528ddc146317f$export$dd1165e0e6012973 = v);
85
- $parcel$export($c14528ddc146317f$exports, "spectrum-Textfield-wrapper--quiet", () => $c14528ddc146317f$export$9fcb3d6af94a9d12, (v) => $c14528ddc146317f$export$9fcb3d6af94a9d12 = v);
86
- var $c14528ddc146317f$export$f39a09f249340e2a;
87
- var $c14528ddc146317f$export$8c4ee2c50c22c514;
88
- var $c14528ddc146317f$export$d35bc1e505d1ebbf;
89
- var $c14528ddc146317f$export$e7dc768d35940237;
90
- var $c14528ddc146317f$export$b8813cd5d7824ce7;
91
- var $c14528ddc146317f$export$e5b2f5233e4e5194;
92
- var $c14528ddc146317f$export$4109102f950813a6;
93
- var $c14528ddc146317f$export$24c7f46a6e3605dd;
94
- var $c14528ddc146317f$export$2927016961429360;
95
- var $c14528ddc146317f$export$2c8a10299d8b3418;
96
- var $c14528ddc146317f$export$58e50b10d30123df;
97
- var $c14528ddc146317f$export$14fd30fea6f1348c;
98
- var $c14528ddc146317f$export$9699f1c538a448a0;
99
- var $c14528ddc146317f$export$bffd5e3d61a81737;
100
- var $c14528ddc146317f$export$c2abbc3f970170b7;
101
- var $c14528ddc146317f$export$82a249fb4d6127;
102
- var $c14528ddc146317f$export$222d1ccd1870be1d;
103
- var $c14528ddc146317f$export$1ac009feb2b0bd0c;
104
- var $c14528ddc146317f$export$c1cdcaa5fe76a871;
105
- var $c14528ddc146317f$export$cf0ead5b44db0da3;
106
- var $c14528ddc146317f$export$dd1165e0e6012973;
107
- var $c14528ddc146317f$export$9fcb3d6af94a9d12;
108
- $c14528ddc146317f$export$f39a09f249340e2a = `YO3Nla_focus-ring`;
109
- $c14528ddc146317f$export$8c4ee2c50c22c514 = `YO3Nla_i18nFontFamily`;
110
- $c14528ddc146317f$export$d35bc1e505d1ebbf = `YO3Nla_is-disabled`;
111
- $c14528ddc146317f$export$e7dc768d35940237 = `YO3Nla_is-focused`;
112
- $c14528ddc146317f$export$b8813cd5d7824ce7 = `YO3Nla_is-hovered`;
113
- $c14528ddc146317f$export$e5b2f5233e4e5194 = `YO3Nla_is-placeholder`;
114
- $c14528ddc146317f$export$4109102f950813a6 = `YO3Nla_spectrum-FocusRing-ring`;
115
- $c14528ddc146317f$export$24c7f46a6e3605dd = `YO3Nla_spectrum-FocusRing ${$c14528ddc146317f$export$4109102f950813a6}`;
116
- $c14528ddc146317f$export$2927016961429360 = `YO3Nla_spectrum-FocusRing--quiet`;
117
- $c14528ddc146317f$export$2c8a10299d8b3418 = `YO3Nla_spectrum-Textfield ${$c14528ddc146317f$export$24c7f46a6e3605dd}`;
118
- $c14528ddc146317f$export$58e50b10d30123df = `YO3Nla_spectrum-Textfield--invalid`;
119
- $c14528ddc146317f$export$14fd30fea6f1348c = `YO3Nla_spectrum-Textfield--loadable`;
120
- $c14528ddc146317f$export$9699f1c538a448a0 = `YO3Nla_spectrum-Textfield--multiline`;
121
- $c14528ddc146317f$export$bffd5e3d61a81737 = `YO3Nla_spectrum-Textfield--quiet ${$c14528ddc146317f$export$2927016961429360}`;
122
- $c14528ddc146317f$export$c2abbc3f970170b7 = `YO3Nla_spectrum-Textfield--valid`;
123
- $c14528ddc146317f$export$82a249fb4d6127 = `YO3Nla_spectrum-Textfield-circleLoader`;
124
- $c14528ddc146317f$export$222d1ccd1870be1d = `YO3Nla_spectrum-Textfield-icon`;
125
- $c14528ddc146317f$export$1ac009feb2b0bd0c = `YO3Nla_spectrum-Textfield-input ${$c14528ddc146317f$export$8c4ee2c50c22c514}`;
126
- $c14528ddc146317f$export$c1cdcaa5fe76a871 = `YO3Nla_spectrum-Textfield-inputIcon`;
127
- $c14528ddc146317f$export$cf0ead5b44db0da3 = `YO3Nla_spectrum-Textfield-validationIcon`;
128
- $c14528ddc146317f$export$dd1165e0e6012973 = `YO3Nla_spectrum-Textfield-wrapper`;
129
- $c14528ddc146317f$export$9fcb3d6af94a9d12 = `YO3Nla_spectrum-Textfield-wrapper--quiet`;
130
-
131
-
132
-
133
-
134
- function $599adb75312e6492$var$TextFieldBase(props, ref) {
135
- let { validationState: validationState = props.isInvalid ? "invalid" : null, icon: icon, isQuiet: isQuiet = false, isDisabled: isDisabled, multiLine: multiLine, autoFocus: autoFocus, inputClassName: inputClassName, wrapperChildren: wrapperChildren, labelProps: labelProps, inputProps: inputProps, descriptionProps: descriptionProps, errorMessageProps: errorMessageProps, inputRef: userInputRef, isLoading: isLoading, loadingIndicator: loadingIndicator, validationIconClassName: validationIconClassName, disableFocusRing: disableFocusRing } = props;
136
- let { hoverProps: hoverProps, isHovered: isHovered } = (0, $evhxb$useHover)({
137
- isDisabled: isDisabled
138
- });
139
- let domRef = (0, $evhxb$useRef)(null);
140
- let defaultInputRef = (0, $evhxb$useRef)(null);
141
- let inputRef = userInputRef || defaultInputRef;
142
- // Expose imperative interface for ref
143
- (0, $evhxb$useImperativeHandle)(ref, ()=>({
144
- ...(0, $evhxb$createFocusableRef)(domRef, inputRef),
145
- select () {
146
- if (inputRef.current) inputRef.current.select();
147
- },
148
- getInputElement () {
149
- return inputRef.current;
150
- }
151
- }));
152
- let ElementType = multiLine ? "textarea" : "input";
153
- let isInvalid = validationState === "invalid" && !isDisabled;
154
- if (icon) {
155
- let UNSAFE_className = (0, $evhxb$classNames)((0, (/*@__PURE__*/$parcel$interopDefault($c14528ddc146317f$exports))), icon.props && icon.props.UNSAFE_className, "spectrum-Textfield-icon");
156
- icon = /*#__PURE__*/ (0, $evhxb$cloneElement)(icon, {
157
- UNSAFE_className: UNSAFE_className,
158
- size: "S"
159
- });
160
- }
161
- let validationIcon = isInvalid ? /*#__PURE__*/ (0, $evhxb$react).createElement((0, $evhxb$spectrumiconsuiAlertMedium), null) : /*#__PURE__*/ (0, $evhxb$react).createElement((0, $evhxb$spectrumiconsuiCheckmarkMedium), null);
162
- let validation = /*#__PURE__*/ (0, $evhxb$cloneElement)(validationIcon, {
163
- UNSAFE_className: (0, $evhxb$classNames)((0, (/*@__PURE__*/$parcel$interopDefault($c14528ddc146317f$exports))), "spectrum-Textfield-validationIcon", validationIconClassName)
164
- });
165
- let { focusProps: focusProps, isFocusVisible: isFocusVisible } = (0, $evhxb$useFocusRing)({
166
- isTextInput: true,
167
- autoFocus: autoFocus
168
- });
169
- let textField = /*#__PURE__*/ (0, $evhxb$react).createElement("div", {
170
- className: (0, $evhxb$classNames)((0, (/*@__PURE__*/$parcel$interopDefault($c14528ddc146317f$exports))), "spectrum-Textfield", {
171
- "spectrum-Textfield--invalid": isInvalid,
172
- "spectrum-Textfield--valid": validationState === "valid" && !isDisabled,
173
- "spectrum-Textfield--loadable": loadingIndicator,
174
- "spectrum-Textfield--quiet": isQuiet,
175
- "spectrum-Textfield--multiline": multiLine,
176
- "focus-ring": !disableFocusRing && isFocusVisible
177
- })
178
- }, /*#__PURE__*/ (0, $evhxb$react).createElement(ElementType, {
179
- ...(0, $evhxb$mergeProps)(inputProps, hoverProps, focusProps),
180
- ref: inputRef,
181
- rows: multiLine ? 1 : undefined,
182
- className: (0, $evhxb$classNames)((0, (/*@__PURE__*/$parcel$interopDefault($c14528ddc146317f$exports))), "spectrum-Textfield-input", {
183
- "spectrum-Textfield-inputIcon": icon,
184
- "is-hovered": isHovered
185
- }, inputClassName)
186
- }), icon, validationState && !isLoading && !isDisabled ? validation : null, isLoading && loadingIndicator, wrapperChildren);
187
- return /*#__PURE__*/ (0, $evhxb$react).createElement((0, $evhxb$Field), {
188
- ...props,
189
- labelProps: labelProps,
190
- descriptionProps: descriptionProps,
191
- errorMessageProps: errorMessageProps,
192
- wrapperClassName: (0, $evhxb$classNames)((0, (/*@__PURE__*/$parcel$interopDefault($c14528ddc146317f$exports))), "spectrum-Textfield-wrapper", {
193
- "spectrum-Textfield-wrapper--quiet": isQuiet
194
- }),
195
- showErrorIcon: false,
196
- ref: domRef
197
- }, textField);
198
- }
199
- const $599adb75312e6492$export$d22444a338b6e3c2 = /*#__PURE__*/ (0, $evhxb$forwardRef)($599adb75312e6492$var$TextFieldBase);
200
-
201
-
202
-
203
-
204
-
205
-
206
- function $cc187bf91f8eea73$var$TextArea(props, ref) {
207
- props = (0, $evhxb$useProviderProps)(props);
208
- props = (0, $evhxb$useFormProps)(props);
209
- let { isDisabled: isDisabled = false, isQuiet: isQuiet = false, isReadOnly: isReadOnly = false, isRequired: isRequired = false, onChange: onChange, ...otherProps } = props;
210
- var _props_defaultValue;
211
- // not in stately because this is so we know when to re-measure, which is a spectrum design
212
- let [inputValue, setInputValue] = (0, $evhxb$useControlledState)(props.value, (_props_defaultValue = props.defaultValue) !== null && _props_defaultValue !== void 0 ? _props_defaultValue : "", ()=>{});
213
- let inputRef = (0, $evhxb$useRef)(null);
214
- let onHeightChange = (0, $evhxb$useCallback)(()=>{
215
- // Quiet textareas always grow based on their text content.
216
- // Standard textareas also grow by default, unless an explicit height is set.
217
- if ((isQuiet || !props.height) && inputRef.current) {
218
- let input = inputRef.current;
219
- let prevAlignment = input.style.alignSelf;
220
- let prevOverflow = input.style.overflow;
221
- // Firefox scroll position is lost when overflow: 'hidden' is applied so we skip applying it.
222
- // The measure/applied height is also incorrect/reset if we turn on and off
223
- // overflow: hidden in Firefox https://bugzilla.mozilla.org/show_bug.cgi?id=1787062
224
- let isFirefox = "MozAppearance" in input.style;
225
- if (!isFirefox) input.style.overflow = "hidden";
226
- input.style.alignSelf = "start";
227
- input.style.height = "auto";
228
- // offsetHeight - clientHeight accounts for the border/padding.
229
- input.style.height = `${input.scrollHeight + (input.offsetHeight - input.clientHeight)}px`;
230
- input.style.overflow = prevOverflow;
231
- input.style.alignSelf = prevAlignment;
232
- }
233
- }, [
234
- isQuiet,
235
- inputRef,
236
- props.height
237
- ]);
238
- (0, $evhxb$useLayoutEffect)(()=>{
239
- if (inputRef.current) onHeightChange();
240
- }, [
241
- onHeightChange,
242
- inputValue,
243
- inputRef
244
- ]);
245
- if (props.placeholder) console.warn("Placeholders are deprecated due to accessibility issues. Please use help text instead. See the docs for details: https://react-spectrum.adobe.com/react-spectrum/TextArea.html#help-text");
246
- let result = (0, $evhxb$useTextField)({
247
- ...props,
248
- onChange: (0, $evhxb$chain)(onChange, setInputValue),
249
- inputElementType: "textarea"
250
- }, inputRef);
251
- return /*#__PURE__*/ (0, $evhxb$react).createElement((0, $599adb75312e6492$export$d22444a338b6e3c2), {
252
- ...otherProps,
253
- ref: ref,
254
- inputRef: inputRef,
255
- ...result,
256
- multiLine: true,
257
- isDisabled: isDisabled,
258
- isQuiet: isQuiet,
259
- isReadOnly: isReadOnly,
260
- isRequired: isRequired
261
- });
262
- }
263
- /**
264
- * TextAreas are multiline text inputs, useful for cases where users have
265
- * a sizable amount of text to enter. They allow for all customizations that
266
- * are available to text fields.
267
- */ let $cc187bf91f8eea73$export$f5c9f3c2c4054eec = /*#__PURE__*/ (0, $evhxb$react).forwardRef($cc187bf91f8eea73$var$TextArea);
268
-
269
-
270
- /*
271
- * Copyright 2020 Adobe. All rights reserved.
272
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
273
- * you may not use this file except in compliance with the License. You may obtain a copy
274
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
275
- *
276
- * Unless required by applicable law or agreed to in writing, software distributed under
277
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
278
- * OF ANY KIND, either express or implied. See the License for the specific language
279
- * governing permissions and limitations under the License.
280
- */
281
-
282
-
283
-
284
-
285
- function $265457f9427aa380$var$TextField(props, ref) {
286
- props = (0, $evhxb$useProviderProps)(props);
287
- props = (0, $evhxb$useFormProps)(props);
288
- let inputRef = (0, $evhxb$useRef)(null);
289
- let result = (0, $evhxb$useTextField)(props, inputRef);
290
- if (props.placeholder) console.warn("Placeholders are deprecated due to accessibility issues. Please use help text instead. See the docs for details: https://react-spectrum.adobe.com/react-spectrum/TextField.html#help-text");
291
- return /*#__PURE__*/ (0, $evhxb$react).createElement((0, $599adb75312e6492$export$d22444a338b6e3c2), {
292
- ...props,
293
- ...result,
294
- ref: ref,
295
- inputRef: inputRef
296
- });
297
- }
298
- /**
299
- * TextFields are text inputs that allow users to input custom text entries
300
- * with a keyboard. Various decorations can be displayed around the field to
301
- * communicate the entry requirements.
302
- */ const $265457f9427aa380$export$2c73285ae9390cec = /*#__PURE__*/ (0, $evhxb$forwardRef)($265457f9427aa380$var$TextField);
303
16
 
304
17
 
305
18