@react-spectrum/numberfield 3.9.0 → 3.9.2

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,149 @@
1
+ var $2f3cded204daae76$exports = require("./StepButton.main.js");
2
+ require("./vars.07bdf9be.css");
3
+ var $3649bcbba015c4d7$exports = require("./stepper_vars_css.main.js");
4
+ var $3d7oE$reactspectrumutils = require("@react-spectrum/utils");
5
+ var $3d7oE$reactspectrumlabel = require("@react-spectrum/label");
6
+ var $3d7oE$reactariafocus = require("@react-aria/focus");
7
+ var $3d7oE$reactariautils = require("@react-aria/utils");
8
+ var $3d7oE$reactstatelynumberfield = require("@react-stately/numberfield");
9
+ var $3d7oE$react = require("react");
10
+ var $3d7oE$reactspectrumtextfield = require("@react-spectrum/textfield");
11
+ var $3d7oE$reactspectrumform = require("@react-spectrum/form");
12
+ var $3d7oE$reactariainteractions = require("@react-aria/interactions");
13
+ var $3d7oE$reactariai18n = require("@react-aria/i18n");
14
+ var $3d7oE$reactarianumberfield = require("@react-aria/numberfield");
15
+ var $3d7oE$reactspectrumprovider = require("@react-spectrum/provider");
16
+
17
+
18
+ function $parcel$interopDefault(a) {
19
+ return a && a.__esModule ? a.default : a;
20
+ }
21
+
22
+ function $parcel$export(e, n, v, s) {
23
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
24
+ }
25
+
26
+ $parcel$export(module.exports, "NumberField", () => $9b3df9c012d62e52$export$63c5fa0b2fdccd2e);
27
+ /*
28
+ * Copyright 2020 Adobe. All rights reserved.
29
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
30
+ * you may not use this file except in compliance with the License. You may obtain a copy
31
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
32
+ *
33
+ * Unless required by applicable law or agreed to in writing, software distributed under
34
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
35
+ * OF ANY KIND, either express or implied. See the License for the specific language
36
+ * governing permissions and limitations under the License.
37
+ */
38
+
39
+
40
+
41
+
42
+
43
+
44
+
45
+
46
+
47
+
48
+
49
+
50
+
51
+ function $9b3df9c012d62e52$var$NumberField(props, ref) {
52
+ props = (0, $3d7oE$reactspectrumprovider.useProviderProps)(props);
53
+ props = (0, $3d7oE$reactspectrumform.useFormProps)(props);
54
+ let provider = (0, $3d7oE$reactspectrumprovider.useProvider)();
55
+ let { isQuiet: isQuiet, isReadOnly: isReadOnly, isDisabled: isDisabled, hideStepper: hideStepper } = props;
56
+ let { styleProps: style } = (0, $3d7oE$reactspectrumutils.useStyleProps)(props);
57
+ let { locale: locale } = (0, $3d7oE$reactariai18n.useLocale)();
58
+ let state = (0, $3d7oE$reactstatelynumberfield.useNumberFieldState)({
59
+ ...props,
60
+ locale: locale
61
+ });
62
+ let inputRef = (0, $3d7oE$react.useRef)(null);
63
+ let domRef = (0, $3d7oE$reactspectrumutils.useFocusableRef)(ref, inputRef);
64
+ let { groupProps: groupProps, labelProps: labelProps, inputProps: inputProps, incrementButtonProps: incrementButtonProps, decrementButtonProps: decrementButtonProps, descriptionProps: descriptionProps, errorMessageProps: errorMessageProps, isInvalid: isInvalid, validationErrors: validationErrors, validationDetails: validationDetails } = (0, $3d7oE$reactarianumberfield.useNumberField)(props, state, inputRef);
65
+ let isMobile = provider.scale === "large";
66
+ let showStepper = !hideStepper;
67
+ let { isHovered: isHovered, hoverProps: hoverProps } = (0, $3d7oE$reactariainteractions.useHover)({
68
+ isDisabled: isDisabled
69
+ });
70
+ let validationState = props.validationState || (isInvalid ? "invalid" : undefined);
71
+ let className = (0, $3d7oE$reactspectrumutils.classNames)((0, ($parcel$interopDefault($3649bcbba015c4d7$exports))), "spectrum-Stepper", // because FocusRing won't pass along the className from Field, we have to handle that ourselves
72
+ !props.label && style.className ? style.className : "", {
73
+ "spectrum-Stepper--isQuiet": isQuiet,
74
+ "is-disabled": isDisabled,
75
+ "spectrum-Stepper--readonly": isReadOnly,
76
+ "is-invalid": validationState === "invalid" && !isDisabled,
77
+ "spectrum-Stepper--showStepper": showStepper,
78
+ "spectrum-Stepper--isMobile": isMobile,
79
+ "is-hovered": isHovered
80
+ });
81
+ return /*#__PURE__*/ (0, ($parcel$interopDefault($3d7oE$react))).createElement((0, $3d7oE$reactspectrumlabel.Field), {
82
+ ...props,
83
+ descriptionProps: descriptionProps,
84
+ errorMessageProps: errorMessageProps,
85
+ isInvalid: isInvalid,
86
+ validationErrors: validationErrors,
87
+ validationDetails: validationDetails,
88
+ labelProps: labelProps,
89
+ ref: domRef,
90
+ wrapperClassName: (0, $3d7oE$reactspectrumutils.classNames)((0, ($parcel$interopDefault($3649bcbba015c4d7$exports))), "spectrum-Stepper-container", {
91
+ "spectrum-Stepper-container--isMobile": isMobile
92
+ })
93
+ }, /*#__PURE__*/ (0, ($parcel$interopDefault($3d7oE$react))).createElement($9b3df9c012d62e52$var$NumberFieldInput, {
94
+ ...props,
95
+ groupProps: (0, $3d7oE$reactariautils.mergeProps)(groupProps, hoverProps),
96
+ inputProps: inputProps,
97
+ inputRef: inputRef,
98
+ incrementProps: incrementButtonProps,
99
+ decrementProps: decrementButtonProps,
100
+ className: className,
101
+ style: style,
102
+ state: state,
103
+ validationState: validationState
104
+ }));
105
+ }
106
+ const $9b3df9c012d62e52$var$NumberFieldInput = /*#__PURE__*/ (0, ($parcel$interopDefault($3d7oE$react))).forwardRef(function NumberFieldInput(props, ref) {
107
+ let { groupProps: groupProps, inputProps: inputProps, inputRef: inputRef, incrementProps: incrementProps, decrementProps: decrementProps, className: className, style: style, autoFocus: autoFocus, isQuiet: isQuiet, isDisabled: isDisabled, hideStepper: hideStepper, validationState: validationState, name: name, state: state } = props;
108
+ let showStepper = !hideStepper;
109
+ return /*#__PURE__*/ (0, ($parcel$interopDefault($3d7oE$react))).createElement((0, $3d7oE$reactariafocus.FocusRing), {
110
+ within: true,
111
+ isTextInput: true,
112
+ focusClass: (0, $3d7oE$reactspectrumutils.classNames)((0, ($parcel$interopDefault($3649bcbba015c4d7$exports))), "is-focused"),
113
+ focusRingClass: (0, $3d7oE$reactspectrumutils.classNames)((0, ($parcel$interopDefault($3649bcbba015c4d7$exports))), "focus-ring"),
114
+ autoFocus: autoFocus
115
+ }, /*#__PURE__*/ (0, ($parcel$interopDefault($3d7oE$react))).createElement("div", {
116
+ ...groupProps,
117
+ ref: ref,
118
+ style: style,
119
+ className: className
120
+ }, /*#__PURE__*/ (0, ($parcel$interopDefault($3d7oE$react))).createElement((0, $3d7oE$reactspectrumtextfield.TextFieldBase), {
121
+ UNSAFE_className: (0, $3d7oE$reactspectrumutils.classNames)((0, ($parcel$interopDefault($3649bcbba015c4d7$exports))), "spectrum-Stepper-field"),
122
+ inputClassName: (0, $3d7oE$reactspectrumutils.classNames)((0, ($parcel$interopDefault($3649bcbba015c4d7$exports))), "spectrum-Stepper-input"),
123
+ validationIconClassName: (0, $3d7oE$reactspectrumutils.classNames)((0, ($parcel$interopDefault($3649bcbba015c4d7$exports))), "spectrum-Stepper-icon"),
124
+ isQuiet: isQuiet,
125
+ inputRef: inputRef,
126
+ validationState: validationState,
127
+ inputProps: inputProps,
128
+ isDisabled: isDisabled,
129
+ disableFocusRing: true
130
+ }), showStepper && /*#__PURE__*/ (0, ($parcel$interopDefault($3d7oE$react))).createElement((0, ($parcel$interopDefault($3d7oE$react))).Fragment, null, /*#__PURE__*/ (0, ($parcel$interopDefault($3d7oE$react))).createElement((0, $2f3cded204daae76$exports.StepButton), {
131
+ direction: "up",
132
+ isQuiet: isQuiet,
133
+ ...incrementProps
134
+ }), /*#__PURE__*/ (0, ($parcel$interopDefault($3d7oE$react))).createElement((0, $2f3cded204daae76$exports.StepButton), {
135
+ direction: "down",
136
+ isQuiet: isQuiet,
137
+ ...decrementProps
138
+ })), name && /*#__PURE__*/ (0, ($parcel$interopDefault($3d7oE$react))).createElement("input", {
139
+ type: "hidden",
140
+ name: name,
141
+ value: isNaN(state.numberValue) ? "" : state.numberValue
142
+ })));
143
+ });
144
+ /**
145
+ * NumberFields allow users to enter a number, and increment or decrement the value using stepper buttons.
146
+ */ let $9b3df9c012d62e52$export$63c5fa0b2fdccd2e = /*#__PURE__*/ (0, ($parcel$interopDefault($3d7oE$react))).forwardRef($9b3df9c012d62e52$var$NumberField);
147
+
148
+
149
+ //# sourceMappingURL=NumberField.main.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;;AAoBD,SAAS,kCAAY,KAA+B,EAAE,GAA8B;IAClF,QAAQ,CAAA,GAAA,6CAAe,EAAE;IACzB,QAAQ,CAAA,GAAA,qCAAW,EAAE;IACrB,IAAI,WAAW,CAAA,GAAA,wCAAU;IACzB,IAAI,WACF,OAAO,cACP,UAAU,cACV,UAAU,eACV,WAAW,EACZ,GAAG;IAEJ,IAAI,EAAC,YAAY,KAAK,EAAC,GAAG,CAAA,GAAA,uCAAY,EAAE;IAExC,IAAI,UAAC,MAAM,EAAC,GAAG,CAAA,GAAA,8BAAQ;IACvB,IAAI,QAAQ,CAAA,GAAA,kDAAkB,EAAE;QAAC,GAAG,KAAK;gBAAE;IAAM;IACjD,IAAI,WAAW,CAAA,GAAA,mBAAK,EAAoB;IACxC,IAAI,SAAS,CAAA,GAAA,yCAAc,EAAe,KAAK;IAC/C,IAAI,cACF,UAAU,cACV,UAAU,cACV,UAAU,wBACV,oBAAoB,wBACpB,oBAAoB,oBACpB,gBAAgB,qBAChB,iBAAiB,aACjB,SAAS,oBACT,gBAAgB,qBAChB,iBAAiB,EAClB,GAAG,CAAA,GAAA,0CAAa,EAAE,OAAO,OAAO;IACjC,IAAI,WAAW,SAAS,KAAK,KAAK;IAClC,IAAI,cAAc,CAAC;IAEnB,IAAI,aAAC,SAAS,cAAE,UAAU,EAAC,GAAG,CAAA,GAAA,qCAAO,EAAE;oBAAC;IAAU;IAElD,IAAI,kBAAkB,MAAM,eAAe,IAAK,CAAA,YAAY,YAAY,SAAQ;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L,OAAO;QACP,WAAW;qBACX,0DAAC,CAAA,GAAA,2CAAY;QACX,kBACE,CAAA,GAAA,oCAAS,EACP,CAAA,GAAA,mDAAW,GACX;QAGJ,gBACE,CAAA,GAAA,oCAAS,EACP,CAAA,GAAA,mDAAW,GACX;QAGJ,yBACE,CAAA,GAAA,oCAAS,EACP,CAAA,GAAA,mDAAW,GACX;QAGJ,SAAS;QACT,UAAU;QACV,iBAAiB;QACjB,YAAY;QACZ,YAAY;QACZ,kBAAA;QACD,6BACD,oIACE,0DAAC,CAAA,GAAA,oCAAS;QAAE,WAAU;QAAK,SAAS;QAAU,GAAG,cAAc;sBAC/D,0DAAC,CAAA,GAAA,oCAAS;QAAE,WAAU;QAAO,SAAS;QAAU,GAAG,cAAc;SAGlE,sBAAQ,0DAAC;QAAM,MAAK;QAAS,MAAM;QAAM,OAAO,MAAM,MAAM,WAAW,IAAI,KAAK,MAAM,WAAW;;AAI1G;AAEA;;CAEC,GACD,IAAI,0DAAe,CAAA,GAAA,sCAAI,EAAE,UAAU,CAAC","sources":["packages/@react-spectrum/numberfield/src/NumberField.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 {AriaButtonProps} from '@react-types/button';\nimport {classNames, useFocusableRef, useStyleProps} from '@react-spectrum/utils';\nimport {Field} from '@react-spectrum/label';\nimport {FocusableRef} from '@react-types/shared';\nimport {FocusRing} from '@react-aria/focus';\nimport {mergeProps} from '@react-aria/utils';\nimport {NumberFieldState, useNumberFieldState} from '@react-stately/numberfield';\nimport React, {HTMLAttributes, InputHTMLAttributes, Ref, RefObject, useRef} from 'react';\nimport {SpectrumNumberFieldProps} from '@react-types/numberfield';\nimport {StepButton} from './StepButton';\nimport stepperStyle from '@adobe/spectrum-css-temp/components/stepper/vars.css';\nimport {TextFieldBase} from '@react-spectrum/textfield';\nimport {useFormProps} from '@react-spectrum/form';\nimport {useHover} from '@react-aria/interactions';\nimport {useLocale} from '@react-aria/i18n';\nimport {useNumberField} from '@react-aria/numberfield';\nimport {useProvider, useProviderProps} from '@react-spectrum/provider';\n\nfunction NumberField(props: SpectrumNumberFieldProps, ref: FocusableRef<HTMLElement>) {\n props = useProviderProps(props);\n props = useFormProps(props);\n let provider = useProvider();\n let {\n isQuiet,\n isReadOnly,\n isDisabled,\n hideStepper\n } = props;\n\n let {styleProps: style} = useStyleProps(props);\n\n let {locale} = useLocale();\n let state = useNumberFieldState({...props, locale});\n let inputRef = useRef<HTMLInputElement>(null);\n let domRef = useFocusableRef<HTMLElement>(ref, inputRef);\n let {\n groupProps,\n labelProps,\n inputProps,\n incrementButtonProps,\n decrementButtonProps,\n descriptionProps,\n errorMessageProps,\n isInvalid,\n validationErrors,\n validationDetails\n } = useNumberField(props, state, inputRef);\n let isMobile = provider.scale === 'large';\n let showStepper = !hideStepper;\n\n let {isHovered, hoverProps} = useHover({isDisabled});\n\n let validationState = props.validationState || (isInvalid ? 'invalid' : undefined);\n let className =\n classNames(\n stepperStyle,\n 'spectrum-Stepper',\n // because FocusRing won't pass along the className from Field, we have to handle that ourselves\n !props.label && style.className ? style.className : '',\n {\n 'spectrum-Stepper--isQuiet': isQuiet,\n 'is-disabled': isDisabled,\n 'spectrum-Stepper--readonly': isReadOnly,\n 'is-invalid': validationState === 'invalid' && !isDisabled,\n 'spectrum-Stepper--showStepper': showStepper,\n 'spectrum-Stepper--isMobile': isMobile,\n 'is-hovered': isHovered\n }\n );\n\n return (\n <Field\n {...props as Omit<SpectrumNumberFieldProps, 'onChange'>}\n descriptionProps={descriptionProps}\n errorMessageProps={errorMessageProps}\n isInvalid={isInvalid}\n validationErrors={validationErrors}\n validationDetails={validationDetails}\n labelProps={labelProps}\n ref={domRef}\n wrapperClassName={classNames(\n stepperStyle,\n 'spectrum-Stepper-container',\n {\n 'spectrum-Stepper-container--isMobile': isMobile\n }\n )}>\n <NumberFieldInput\n {...props}\n groupProps={mergeProps(groupProps, hoverProps)}\n inputProps={inputProps}\n inputRef={inputRef}\n incrementProps={incrementButtonProps}\n decrementProps={decrementButtonProps}\n className={className}\n style={style}\n state={state}\n validationState={validationState} />\n </Field>\n );\n}\n\n\ninterface NumberFieldInputProps extends SpectrumNumberFieldProps {\n groupProps: HTMLAttributes<HTMLDivElement>,\n inputProps: InputHTMLAttributes<HTMLInputElement>,\n inputRef: RefObject<HTMLInputElement | HTMLTextAreaElement>,\n incrementProps: AriaButtonProps,\n decrementProps: AriaButtonProps,\n className?: string,\n style?: React.CSSProperties,\n state: NumberFieldState\n}\n\nconst NumberFieldInput = React.forwardRef(function NumberFieldInput(props: NumberFieldInputProps, ref: Ref<HTMLDivElement>) {\n let {\n groupProps,\n inputProps,\n inputRef,\n incrementProps,\n decrementProps,\n className,\n style,\n autoFocus,\n isQuiet,\n isDisabled,\n hideStepper,\n validationState,\n name,\n state\n } = props;\n let showStepper = !hideStepper;\n\n return (\n <FocusRing\n within\n isTextInput\n focusClass={classNames(stepperStyle, 'is-focused')}\n focusRingClass={classNames(stepperStyle, 'focus-ring')}\n autoFocus={autoFocus}>\n <div\n {...groupProps}\n ref={ref}\n style={style}\n className={className}>\n <TextFieldBase\n UNSAFE_className={\n classNames(\n stepperStyle,\n 'spectrum-Stepper-field'\n )\n }\n inputClassName={\n classNames(\n stepperStyle,\n 'spectrum-Stepper-input'\n )\n }\n validationIconClassName={\n classNames(\n stepperStyle,\n 'spectrum-Stepper-icon'\n )\n }\n isQuiet={isQuiet}\n inputRef={inputRef}\n validationState={validationState}\n inputProps={inputProps}\n isDisabled={isDisabled}\n disableFocusRing />\n {showStepper &&\n <>\n <StepButton direction=\"up\" isQuiet={isQuiet} {...incrementProps} />\n <StepButton direction=\"down\" isQuiet={isQuiet} {...decrementProps} />\n </>\n }\n {name && <input type=\"hidden\" name={name} value={isNaN(state.numberValue) ? '' : state.numberValue} />}\n </div>\n </FocusRing>\n );\n});\n\n/**\n * NumberFields allow users to enter a number, and increment or decrement the value using stepper buttons.\n */\nlet _NumberField = React.forwardRef(NumberField);\nexport {_NumberField as NumberField};\n"],"names":[],"version":3,"file":"NumberField.main.js.map"}
@@ -0,0 +1,144 @@
1
+ import {StepButton as $7f00b388e0d3b2f6$export$b2f6b60c1d32d6aa} from "./StepButton.mjs";
2
+ import "./vars.07bdf9be.css";
3
+ import $5I0aR$stepper_vars_cssmodulejs from "./stepper_vars_css.mjs";
4
+ import {useStyleProps as $5I0aR$useStyleProps, useFocusableRef as $5I0aR$useFocusableRef, classNames as $5I0aR$classNames} from "@react-spectrum/utils";
5
+ import {Field as $5I0aR$Field} from "@react-spectrum/label";
6
+ import {FocusRing as $5I0aR$FocusRing} from "@react-aria/focus";
7
+ import {mergeProps as $5I0aR$mergeProps} from "@react-aria/utils";
8
+ import {useNumberFieldState as $5I0aR$useNumberFieldState} from "@react-stately/numberfield";
9
+ import $5I0aR$react, {useRef as $5I0aR$useRef} from "react";
10
+ import {TextFieldBase as $5I0aR$TextFieldBase} from "@react-spectrum/textfield";
11
+ import {useFormProps as $5I0aR$useFormProps} from "@react-spectrum/form";
12
+ import {useHover as $5I0aR$useHover} from "@react-aria/interactions";
13
+ import {useLocale as $5I0aR$useLocale} from "@react-aria/i18n";
14
+ import {useNumberField as $5I0aR$useNumberField} from "@react-aria/numberfield";
15
+ import {useProviderProps as $5I0aR$useProviderProps, useProvider as $5I0aR$useProvider} from "@react-spectrum/provider";
16
+
17
+
18
+ function $parcel$interopDefault(a) {
19
+ return a && a.__esModule ? a.default : a;
20
+ }
21
+ /*
22
+ * Copyright 2020 Adobe. All rights reserved.
23
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
24
+ * you may not use this file except in compliance with the License. You may obtain a copy
25
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
26
+ *
27
+ * Unless required by applicable law or agreed to in writing, software distributed under
28
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
29
+ * OF ANY KIND, either express or implied. See the License for the specific language
30
+ * governing permissions and limitations under the License.
31
+ */
32
+
33
+
34
+
35
+
36
+
37
+
38
+
39
+
40
+
41
+
42
+
43
+
44
+
45
+ function $48b879bdd771eb85$var$NumberField(props, ref) {
46
+ props = (0, $5I0aR$useProviderProps)(props);
47
+ props = (0, $5I0aR$useFormProps)(props);
48
+ let provider = (0, $5I0aR$useProvider)();
49
+ let { isQuiet: isQuiet, isReadOnly: isReadOnly, isDisabled: isDisabled, hideStepper: hideStepper } = props;
50
+ let { styleProps: style } = (0, $5I0aR$useStyleProps)(props);
51
+ let { locale: locale } = (0, $5I0aR$useLocale)();
52
+ let state = (0, $5I0aR$useNumberFieldState)({
53
+ ...props,
54
+ locale: locale
55
+ });
56
+ let inputRef = (0, $5I0aR$useRef)(null);
57
+ let domRef = (0, $5I0aR$useFocusableRef)(ref, inputRef);
58
+ let { groupProps: groupProps, labelProps: labelProps, inputProps: inputProps, incrementButtonProps: incrementButtonProps, decrementButtonProps: decrementButtonProps, descriptionProps: descriptionProps, errorMessageProps: errorMessageProps, isInvalid: isInvalid, validationErrors: validationErrors, validationDetails: validationDetails } = (0, $5I0aR$useNumberField)(props, state, inputRef);
59
+ let isMobile = provider.scale === "large";
60
+ let showStepper = !hideStepper;
61
+ let { isHovered: isHovered, hoverProps: hoverProps } = (0, $5I0aR$useHover)({
62
+ isDisabled: isDisabled
63
+ });
64
+ let validationState = props.validationState || (isInvalid ? "invalid" : undefined);
65
+ let className = (0, $5I0aR$classNames)((0, ($parcel$interopDefault($5I0aR$stepper_vars_cssmodulejs))), "spectrum-Stepper", // because FocusRing won't pass along the className from Field, we have to handle that ourselves
66
+ !props.label && style.className ? style.className : "", {
67
+ "spectrum-Stepper--isQuiet": isQuiet,
68
+ "is-disabled": isDisabled,
69
+ "spectrum-Stepper--readonly": isReadOnly,
70
+ "is-invalid": validationState === "invalid" && !isDisabled,
71
+ "spectrum-Stepper--showStepper": showStepper,
72
+ "spectrum-Stepper--isMobile": isMobile,
73
+ "is-hovered": isHovered
74
+ });
75
+ return /*#__PURE__*/ (0, $5I0aR$react).createElement((0, $5I0aR$Field), {
76
+ ...props,
77
+ descriptionProps: descriptionProps,
78
+ errorMessageProps: errorMessageProps,
79
+ isInvalid: isInvalid,
80
+ validationErrors: validationErrors,
81
+ validationDetails: validationDetails,
82
+ labelProps: labelProps,
83
+ ref: domRef,
84
+ wrapperClassName: (0, $5I0aR$classNames)((0, ($parcel$interopDefault($5I0aR$stepper_vars_cssmodulejs))), "spectrum-Stepper-container", {
85
+ "spectrum-Stepper-container--isMobile": isMobile
86
+ })
87
+ }, /*#__PURE__*/ (0, $5I0aR$react).createElement($48b879bdd771eb85$var$NumberFieldInput, {
88
+ ...props,
89
+ groupProps: (0, $5I0aR$mergeProps)(groupProps, hoverProps),
90
+ inputProps: inputProps,
91
+ inputRef: inputRef,
92
+ incrementProps: incrementButtonProps,
93
+ decrementProps: decrementButtonProps,
94
+ className: className,
95
+ style: style,
96
+ state: state,
97
+ validationState: validationState
98
+ }));
99
+ }
100
+ const $48b879bdd771eb85$var$NumberFieldInput = /*#__PURE__*/ (0, $5I0aR$react).forwardRef(function NumberFieldInput(props, ref) {
101
+ let { groupProps: groupProps, inputProps: inputProps, inputRef: inputRef, incrementProps: incrementProps, decrementProps: decrementProps, className: className, style: style, autoFocus: autoFocus, isQuiet: isQuiet, isDisabled: isDisabled, hideStepper: hideStepper, validationState: validationState, name: name, state: state } = props;
102
+ let showStepper = !hideStepper;
103
+ return /*#__PURE__*/ (0, $5I0aR$react).createElement((0, $5I0aR$FocusRing), {
104
+ within: true,
105
+ isTextInput: true,
106
+ focusClass: (0, $5I0aR$classNames)((0, ($parcel$interopDefault($5I0aR$stepper_vars_cssmodulejs))), "is-focused"),
107
+ focusRingClass: (0, $5I0aR$classNames)((0, ($parcel$interopDefault($5I0aR$stepper_vars_cssmodulejs))), "focus-ring"),
108
+ autoFocus: autoFocus
109
+ }, /*#__PURE__*/ (0, $5I0aR$react).createElement("div", {
110
+ ...groupProps,
111
+ ref: ref,
112
+ style: style,
113
+ className: className
114
+ }, /*#__PURE__*/ (0, $5I0aR$react).createElement((0, $5I0aR$TextFieldBase), {
115
+ UNSAFE_className: (0, $5I0aR$classNames)((0, ($parcel$interopDefault($5I0aR$stepper_vars_cssmodulejs))), "spectrum-Stepper-field"),
116
+ inputClassName: (0, $5I0aR$classNames)((0, ($parcel$interopDefault($5I0aR$stepper_vars_cssmodulejs))), "spectrum-Stepper-input"),
117
+ validationIconClassName: (0, $5I0aR$classNames)((0, ($parcel$interopDefault($5I0aR$stepper_vars_cssmodulejs))), "spectrum-Stepper-icon"),
118
+ isQuiet: isQuiet,
119
+ inputRef: inputRef,
120
+ validationState: validationState,
121
+ inputProps: inputProps,
122
+ isDisabled: isDisabled,
123
+ disableFocusRing: true
124
+ }), showStepper && /*#__PURE__*/ (0, $5I0aR$react).createElement((0, $5I0aR$react).Fragment, null, /*#__PURE__*/ (0, $5I0aR$react).createElement((0, $7f00b388e0d3b2f6$export$b2f6b60c1d32d6aa), {
125
+ direction: "up",
126
+ isQuiet: isQuiet,
127
+ ...incrementProps
128
+ }), /*#__PURE__*/ (0, $5I0aR$react).createElement((0, $7f00b388e0d3b2f6$export$b2f6b60c1d32d6aa), {
129
+ direction: "down",
130
+ isQuiet: isQuiet,
131
+ ...decrementProps
132
+ })), name && /*#__PURE__*/ (0, $5I0aR$react).createElement("input", {
133
+ type: "hidden",
134
+ name: name,
135
+ value: isNaN(state.numberValue) ? "" : state.numberValue
136
+ })));
137
+ });
138
+ /**
139
+ * NumberFields allow users to enter a number, and increment or decrement the value using stepper buttons.
140
+ */ let $48b879bdd771eb85$export$63c5fa0b2fdccd2e = /*#__PURE__*/ (0, $5I0aR$react).forwardRef($48b879bdd771eb85$var$NumberField);
141
+
142
+
143
+ export {$48b879bdd771eb85$export$63c5fa0b2fdccd2e as NumberField};
144
+ //# sourceMappingURL=NumberField.mjs.map
@@ -0,0 +1,144 @@
1
+ import {StepButton as $7f00b388e0d3b2f6$export$b2f6b60c1d32d6aa} from "./StepButton.module.js";
2
+ import "./vars.07bdf9be.css";
3
+ import $5I0aR$stepper_vars_cssmodulejs from "./stepper_vars_css.module.js";
4
+ import {useStyleProps as $5I0aR$useStyleProps, useFocusableRef as $5I0aR$useFocusableRef, classNames as $5I0aR$classNames} from "@react-spectrum/utils";
5
+ import {Field as $5I0aR$Field} from "@react-spectrum/label";
6
+ import {FocusRing as $5I0aR$FocusRing} from "@react-aria/focus";
7
+ import {mergeProps as $5I0aR$mergeProps} from "@react-aria/utils";
8
+ import {useNumberFieldState as $5I0aR$useNumberFieldState} from "@react-stately/numberfield";
9
+ import $5I0aR$react, {useRef as $5I0aR$useRef} from "react";
10
+ import {TextFieldBase as $5I0aR$TextFieldBase} from "@react-spectrum/textfield";
11
+ import {useFormProps as $5I0aR$useFormProps} from "@react-spectrum/form";
12
+ import {useHover as $5I0aR$useHover} from "@react-aria/interactions";
13
+ import {useLocale as $5I0aR$useLocale} from "@react-aria/i18n";
14
+ import {useNumberField as $5I0aR$useNumberField} from "@react-aria/numberfield";
15
+ import {useProviderProps as $5I0aR$useProviderProps, useProvider as $5I0aR$useProvider} from "@react-spectrum/provider";
16
+
17
+
18
+ function $parcel$interopDefault(a) {
19
+ return a && a.__esModule ? a.default : a;
20
+ }
21
+ /*
22
+ * Copyright 2020 Adobe. All rights reserved.
23
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
24
+ * you may not use this file except in compliance with the License. You may obtain a copy
25
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
26
+ *
27
+ * Unless required by applicable law or agreed to in writing, software distributed under
28
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
29
+ * OF ANY KIND, either express or implied. See the License for the specific language
30
+ * governing permissions and limitations under the License.
31
+ */
32
+
33
+
34
+
35
+
36
+
37
+
38
+
39
+
40
+
41
+
42
+
43
+
44
+
45
+ function $48b879bdd771eb85$var$NumberField(props, ref) {
46
+ props = (0, $5I0aR$useProviderProps)(props);
47
+ props = (0, $5I0aR$useFormProps)(props);
48
+ let provider = (0, $5I0aR$useProvider)();
49
+ let { isQuiet: isQuiet, isReadOnly: isReadOnly, isDisabled: isDisabled, hideStepper: hideStepper } = props;
50
+ let { styleProps: style } = (0, $5I0aR$useStyleProps)(props);
51
+ let { locale: locale } = (0, $5I0aR$useLocale)();
52
+ let state = (0, $5I0aR$useNumberFieldState)({
53
+ ...props,
54
+ locale: locale
55
+ });
56
+ let inputRef = (0, $5I0aR$useRef)(null);
57
+ let domRef = (0, $5I0aR$useFocusableRef)(ref, inputRef);
58
+ let { groupProps: groupProps, labelProps: labelProps, inputProps: inputProps, incrementButtonProps: incrementButtonProps, decrementButtonProps: decrementButtonProps, descriptionProps: descriptionProps, errorMessageProps: errorMessageProps, isInvalid: isInvalid, validationErrors: validationErrors, validationDetails: validationDetails } = (0, $5I0aR$useNumberField)(props, state, inputRef);
59
+ let isMobile = provider.scale === "large";
60
+ let showStepper = !hideStepper;
61
+ let { isHovered: isHovered, hoverProps: hoverProps } = (0, $5I0aR$useHover)({
62
+ isDisabled: isDisabled
63
+ });
64
+ let validationState = props.validationState || (isInvalid ? "invalid" : undefined);
65
+ let className = (0, $5I0aR$classNames)((0, ($parcel$interopDefault($5I0aR$stepper_vars_cssmodulejs))), "spectrum-Stepper", // because FocusRing won't pass along the className from Field, we have to handle that ourselves
66
+ !props.label && style.className ? style.className : "", {
67
+ "spectrum-Stepper--isQuiet": isQuiet,
68
+ "is-disabled": isDisabled,
69
+ "spectrum-Stepper--readonly": isReadOnly,
70
+ "is-invalid": validationState === "invalid" && !isDisabled,
71
+ "spectrum-Stepper--showStepper": showStepper,
72
+ "spectrum-Stepper--isMobile": isMobile,
73
+ "is-hovered": isHovered
74
+ });
75
+ return /*#__PURE__*/ (0, $5I0aR$react).createElement((0, $5I0aR$Field), {
76
+ ...props,
77
+ descriptionProps: descriptionProps,
78
+ errorMessageProps: errorMessageProps,
79
+ isInvalid: isInvalid,
80
+ validationErrors: validationErrors,
81
+ validationDetails: validationDetails,
82
+ labelProps: labelProps,
83
+ ref: domRef,
84
+ wrapperClassName: (0, $5I0aR$classNames)((0, ($parcel$interopDefault($5I0aR$stepper_vars_cssmodulejs))), "spectrum-Stepper-container", {
85
+ "spectrum-Stepper-container--isMobile": isMobile
86
+ })
87
+ }, /*#__PURE__*/ (0, $5I0aR$react).createElement($48b879bdd771eb85$var$NumberFieldInput, {
88
+ ...props,
89
+ groupProps: (0, $5I0aR$mergeProps)(groupProps, hoverProps),
90
+ inputProps: inputProps,
91
+ inputRef: inputRef,
92
+ incrementProps: incrementButtonProps,
93
+ decrementProps: decrementButtonProps,
94
+ className: className,
95
+ style: style,
96
+ state: state,
97
+ validationState: validationState
98
+ }));
99
+ }
100
+ const $48b879bdd771eb85$var$NumberFieldInput = /*#__PURE__*/ (0, $5I0aR$react).forwardRef(function NumberFieldInput(props, ref) {
101
+ let { groupProps: groupProps, inputProps: inputProps, inputRef: inputRef, incrementProps: incrementProps, decrementProps: decrementProps, className: className, style: style, autoFocus: autoFocus, isQuiet: isQuiet, isDisabled: isDisabled, hideStepper: hideStepper, validationState: validationState, name: name, state: state } = props;
102
+ let showStepper = !hideStepper;
103
+ return /*#__PURE__*/ (0, $5I0aR$react).createElement((0, $5I0aR$FocusRing), {
104
+ within: true,
105
+ isTextInput: true,
106
+ focusClass: (0, $5I0aR$classNames)((0, ($parcel$interopDefault($5I0aR$stepper_vars_cssmodulejs))), "is-focused"),
107
+ focusRingClass: (0, $5I0aR$classNames)((0, ($parcel$interopDefault($5I0aR$stepper_vars_cssmodulejs))), "focus-ring"),
108
+ autoFocus: autoFocus
109
+ }, /*#__PURE__*/ (0, $5I0aR$react).createElement("div", {
110
+ ...groupProps,
111
+ ref: ref,
112
+ style: style,
113
+ className: className
114
+ }, /*#__PURE__*/ (0, $5I0aR$react).createElement((0, $5I0aR$TextFieldBase), {
115
+ UNSAFE_className: (0, $5I0aR$classNames)((0, ($parcel$interopDefault($5I0aR$stepper_vars_cssmodulejs))), "spectrum-Stepper-field"),
116
+ inputClassName: (0, $5I0aR$classNames)((0, ($parcel$interopDefault($5I0aR$stepper_vars_cssmodulejs))), "spectrum-Stepper-input"),
117
+ validationIconClassName: (0, $5I0aR$classNames)((0, ($parcel$interopDefault($5I0aR$stepper_vars_cssmodulejs))), "spectrum-Stepper-icon"),
118
+ isQuiet: isQuiet,
119
+ inputRef: inputRef,
120
+ validationState: validationState,
121
+ inputProps: inputProps,
122
+ isDisabled: isDisabled,
123
+ disableFocusRing: true
124
+ }), showStepper && /*#__PURE__*/ (0, $5I0aR$react).createElement((0, $5I0aR$react).Fragment, null, /*#__PURE__*/ (0, $5I0aR$react).createElement((0, $7f00b388e0d3b2f6$export$b2f6b60c1d32d6aa), {
125
+ direction: "up",
126
+ isQuiet: isQuiet,
127
+ ...incrementProps
128
+ }), /*#__PURE__*/ (0, $5I0aR$react).createElement((0, $7f00b388e0d3b2f6$export$b2f6b60c1d32d6aa), {
129
+ direction: "down",
130
+ isQuiet: isQuiet,
131
+ ...decrementProps
132
+ })), name && /*#__PURE__*/ (0, $5I0aR$react).createElement("input", {
133
+ type: "hidden",
134
+ name: name,
135
+ value: isNaN(state.numberValue) ? "" : state.numberValue
136
+ })));
137
+ });
138
+ /**
139
+ * NumberFields allow users to enter a number, and increment or decrement the value using stepper buttons.
140
+ */ let $48b879bdd771eb85$export$63c5fa0b2fdccd2e = /*#__PURE__*/ (0, $5I0aR$react).forwardRef($48b879bdd771eb85$var$NumberField);
141
+
142
+
143
+ export {$48b879bdd771eb85$export$63c5fa0b2fdccd2e as NumberField};
144
+ //# sourceMappingURL=NumberField.module.js.map
@@ -0,0 +1 @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X;QAGJ,SAAS;QACT,UAAU;QACV,iBAAiB;QACjB,YAAY;QACZ,YAAY;QACZ,kBAAA;QACD,6BACD,gFACE,gCAAC,CAAA,GAAA,yCAAS;QAAE,WAAU;QAAK,SAAS;QAAU,GAAG,cAAc;sBAC/D,gCAAC,CAAA,GAAA,yCAAS;QAAE,WAAU;QAAO,SAAS;QAAU,GAAG,cAAc;SAGlE,sBAAQ,gCAAC;QAAM,MAAK;QAAS,MAAM;QAAM,OAAO,MAAM,MAAM,WAAW,IAAI,KAAK,MAAM,WAAW;;AAI1G;AAEA;;CAEC,GACD,IAAI,0DAAe,CAAA,GAAA,YAAI,EAAE,UAAU,CAAC","sources":["packages/@react-spectrum/numberfield/src/NumberField.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 {AriaButtonProps} from '@react-types/button';\nimport {classNames, useFocusableRef, useStyleProps} from '@react-spectrum/utils';\nimport {Field} from '@react-spectrum/label';\nimport {FocusableRef} from '@react-types/shared';\nimport {FocusRing} from '@react-aria/focus';\nimport {mergeProps} from '@react-aria/utils';\nimport {NumberFieldState, useNumberFieldState} from '@react-stately/numberfield';\nimport React, {HTMLAttributes, InputHTMLAttributes, Ref, RefObject, useRef} from 'react';\nimport {SpectrumNumberFieldProps} from '@react-types/numberfield';\nimport {StepButton} from './StepButton';\nimport stepperStyle from '@adobe/spectrum-css-temp/components/stepper/vars.css';\nimport {TextFieldBase} from '@react-spectrum/textfield';\nimport {useFormProps} from '@react-spectrum/form';\nimport {useHover} from '@react-aria/interactions';\nimport {useLocale} from '@react-aria/i18n';\nimport {useNumberField} from '@react-aria/numberfield';\nimport {useProvider, useProviderProps} from '@react-spectrum/provider';\n\nfunction NumberField(props: SpectrumNumberFieldProps, ref: FocusableRef<HTMLElement>) {\n props = useProviderProps(props);\n props = useFormProps(props);\n let provider = useProvider();\n let {\n isQuiet,\n isReadOnly,\n isDisabled,\n hideStepper\n } = props;\n\n let {styleProps: style} = useStyleProps(props);\n\n let {locale} = useLocale();\n let state = useNumberFieldState({...props, locale});\n let inputRef = useRef<HTMLInputElement>(null);\n let domRef = useFocusableRef<HTMLElement>(ref, inputRef);\n let {\n groupProps,\n labelProps,\n inputProps,\n incrementButtonProps,\n decrementButtonProps,\n descriptionProps,\n errorMessageProps,\n isInvalid,\n validationErrors,\n validationDetails\n } = useNumberField(props, state, inputRef);\n let isMobile = provider.scale === 'large';\n let showStepper = !hideStepper;\n\n let {isHovered, hoverProps} = useHover({isDisabled});\n\n let validationState = props.validationState || (isInvalid ? 'invalid' : undefined);\n let className =\n classNames(\n stepperStyle,\n 'spectrum-Stepper',\n // because FocusRing won't pass along the className from Field, we have to handle that ourselves\n !props.label && style.className ? style.className : '',\n {\n 'spectrum-Stepper--isQuiet': isQuiet,\n 'is-disabled': isDisabled,\n 'spectrum-Stepper--readonly': isReadOnly,\n 'is-invalid': validationState === 'invalid' && !isDisabled,\n 'spectrum-Stepper--showStepper': showStepper,\n 'spectrum-Stepper--isMobile': isMobile,\n 'is-hovered': isHovered\n }\n );\n\n return (\n <Field\n {...props as Omit<SpectrumNumberFieldProps, 'onChange'>}\n descriptionProps={descriptionProps}\n errorMessageProps={errorMessageProps}\n isInvalid={isInvalid}\n validationErrors={validationErrors}\n validationDetails={validationDetails}\n labelProps={labelProps}\n ref={domRef}\n wrapperClassName={classNames(\n stepperStyle,\n 'spectrum-Stepper-container',\n {\n 'spectrum-Stepper-container--isMobile': isMobile\n }\n )}>\n <NumberFieldInput\n {...props}\n groupProps={mergeProps(groupProps, hoverProps)}\n inputProps={inputProps}\n inputRef={inputRef}\n incrementProps={incrementButtonProps}\n decrementProps={decrementButtonProps}\n className={className}\n style={style}\n state={state}\n validationState={validationState} />\n </Field>\n );\n}\n\n\ninterface NumberFieldInputProps extends SpectrumNumberFieldProps {\n groupProps: HTMLAttributes<HTMLDivElement>,\n inputProps: InputHTMLAttributes<HTMLInputElement>,\n inputRef: RefObject<HTMLInputElement | HTMLTextAreaElement>,\n incrementProps: AriaButtonProps,\n decrementProps: AriaButtonProps,\n className?: string,\n style?: React.CSSProperties,\n state: NumberFieldState\n}\n\nconst NumberFieldInput = React.forwardRef(function NumberFieldInput(props: NumberFieldInputProps, ref: Ref<HTMLDivElement>) {\n let {\n groupProps,\n inputProps,\n inputRef,\n incrementProps,\n decrementProps,\n className,\n style,\n autoFocus,\n isQuiet,\n isDisabled,\n hideStepper,\n validationState,\n name,\n state\n } = props;\n let showStepper = !hideStepper;\n\n return (\n <FocusRing\n within\n isTextInput\n focusClass={classNames(stepperStyle, 'is-focused')}\n focusRingClass={classNames(stepperStyle, 'focus-ring')}\n autoFocus={autoFocus}>\n <div\n {...groupProps}\n ref={ref}\n style={style}\n className={className}>\n <TextFieldBase\n UNSAFE_className={\n classNames(\n stepperStyle,\n 'spectrum-Stepper-field'\n )\n }\n inputClassName={\n classNames(\n stepperStyle,\n 'spectrum-Stepper-input'\n )\n }\n validationIconClassName={\n classNames(\n stepperStyle,\n 'spectrum-Stepper-icon'\n )\n }\n isQuiet={isQuiet}\n inputRef={inputRef}\n validationState={validationState}\n inputProps={inputProps}\n isDisabled={isDisabled}\n disableFocusRing />\n {showStepper &&\n <>\n <StepButton direction=\"up\" isQuiet={isQuiet} {...incrementProps} />\n <StepButton direction=\"down\" isQuiet={isQuiet} {...decrementProps} />\n </>\n }\n {name && <input type=\"hidden\" name={name} value={isNaN(state.numberValue) ? '' : state.numberValue} />}\n </div>\n </FocusRing>\n );\n});\n\n/**\n * NumberFields allow users to enter a number, and increment or decrement the value using stepper buttons.\n */\nlet _NumberField = React.forwardRef(NumberField);\nexport {_NumberField as NumberField};\n"],"names":[],"version":3,"file":"NumberField.module.js.map"}
@@ -0,0 +1,90 @@
1
+ require("./vars.07bdf9be.css");
2
+ var $3649bcbba015c4d7$exports = require("./stepper_vars_css.main.js");
3
+ var $3rHYV$spectrumiconsworkflowAdd = require("@spectrum-icons/workflow/Add");
4
+ var $3rHYV$spectrumiconsuiChevronDownSmall = require("@spectrum-icons/ui/ChevronDownSmall");
5
+ var $3rHYV$spectrumiconsuiChevronUpSmall = require("@spectrum-icons/ui/ChevronUpSmall");
6
+ var $3rHYV$reactspectrumutils = require("@react-spectrum/utils");
7
+ var $3rHYV$reactariafocus = require("@react-aria/focus");
8
+ var $3rHYV$reactariautils = require("@react-aria/utils");
9
+ var $3rHYV$react = require("react");
10
+ var $3rHYV$spectrumiconsworkflowRemove = require("@spectrum-icons/workflow/Remove");
11
+ var $3rHYV$reactariabutton = require("@react-aria/button");
12
+ var $3rHYV$reactariainteractions = require("@react-aria/interactions");
13
+ var $3rHYV$reactspectrumprovider = require("@react-spectrum/provider");
14
+
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
+
24
+ $parcel$export(module.exports, "StepButton", () => $2f3cded204daae76$export$b2f6b60c1d32d6aa);
25
+ /*
26
+ * Copyright 2020 Adobe. All rights reserved.
27
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
28
+ * you may not use this file except in compliance with the License. You may obtain a copy
29
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
30
+ *
31
+ * Unless required by applicable law or agreed to in writing, software distributed under
32
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
33
+ * OF ANY KIND, either express or implied. See the License for the specific language
34
+ * governing permissions and limitations under the License.
35
+ */
36
+
37
+
38
+
39
+
40
+
41
+
42
+
43
+
44
+
45
+
46
+
47
+ function $2f3cded204daae76$var$StepButton(props, ref) {
48
+ props = (0, $3rHYV$reactspectrumprovider.useProviderProps)(props);
49
+ let { scale: scale } = (0, $3rHYV$reactspectrumprovider.useProvider)();
50
+ let { direction: direction, isDisabled: isDisabled, isQuiet: isQuiet } = props;
51
+ let domRef = (0, $3rHYV$reactspectrumutils.useFocusableRef)(ref);
52
+ /**
53
+ * Must use div for now because Safari pointer event bugs on disabled form elements.
54
+ * Link https://bugs.webkit.org/show_bug.cgi?id=219188.
55
+ */ let { buttonProps: buttonProps, isPressed: isPressed } = (0, $3rHYV$reactariabutton.useButton)({
56
+ ...props,
57
+ elementType: "div"
58
+ }, domRef);
59
+ let { hoverProps: hoverProps, isHovered: isHovered } = (0, $3rHYV$reactariainteractions.useHover)(props);
60
+ return /*#__PURE__*/ (0, ($parcel$interopDefault($3rHYV$react))).createElement((0, $3rHYV$reactariafocus.FocusRing), {
61
+ focusRingClass: (0, $3rHYV$reactspectrumutils.classNames)((0, ($parcel$interopDefault($3649bcbba015c4d7$exports))), "focus-ring")
62
+ }, /*#__PURE__*/ (0, ($parcel$interopDefault($3rHYV$react))).createElement("div", {
63
+ className: (0, $3rHYV$reactspectrumutils.classNames)((0, ($parcel$interopDefault($3649bcbba015c4d7$exports))), "spectrum-Stepper-button", {
64
+ "spectrum-Stepper-button--stepUp": direction === "up",
65
+ "spectrum-Stepper-button--stepDown": direction === "down",
66
+ "spectrum-Stepper-button--isQuiet": isQuiet,
67
+ "is-hovered": isHovered,
68
+ "is-active": isPressed,
69
+ "is-disabled": isDisabled
70
+ }),
71
+ ...(0, $3rHYV$reactariautils.mergeProps)(hoverProps, buttonProps),
72
+ ref: domRef
73
+ }, direction === "up" && scale === "large" && /*#__PURE__*/ (0, ($parcel$interopDefault($3rHYV$react))).createElement((0, ($parcel$interopDefault($3rHYV$spectrumiconsworkflowAdd))), {
74
+ UNSAFE_className: (0, $3rHYV$reactspectrumutils.classNames)((0, ($parcel$interopDefault($3649bcbba015c4d7$exports))), "spectrum-Stepper-button-icon", "spectrum-Stepper-stepUpIcon"),
75
+ size: "S"
76
+ }), direction === "up" && scale === "medium" && /*#__PURE__*/ (0, ($parcel$interopDefault($3rHYV$react))).createElement((0, ($parcel$interopDefault($3rHYV$spectrumiconsuiChevronUpSmall))), {
77
+ UNSAFE_className: (0, $3rHYV$reactspectrumutils.classNames)((0, ($parcel$interopDefault($3649bcbba015c4d7$exports))), "spectrum-Stepper-button-icon", "spectrum-Stepper-stepUpIcon")
78
+ }), direction === "down" && scale === "large" && /*#__PURE__*/ (0, ($parcel$interopDefault($3rHYV$react))).createElement((0, ($parcel$interopDefault($3rHYV$spectrumiconsworkflowRemove))), {
79
+ UNSAFE_className: (0, $3rHYV$reactspectrumutils.classNames)((0, ($parcel$interopDefault($3649bcbba015c4d7$exports))), "spectrum-Stepper-button-icon", "spectrum-Stepper-stepDownIcon"),
80
+ size: "S"
81
+ }), direction === "down" && scale === "medium" && /*#__PURE__*/ (0, ($parcel$interopDefault($3rHYV$react))).createElement((0, ($parcel$interopDefault($3rHYV$spectrumiconsuiChevronDownSmall))), {
82
+ UNSAFE_className: (0, $3rHYV$reactspectrumutils.classNames)((0, ($parcel$interopDefault($3649bcbba015c4d7$exports))), "spectrum-Stepper-button-icon", "spectrum-Stepper-stepDownIcon")
83
+ })));
84
+ }
85
+ /**
86
+ * Buttons for NumberField.
87
+ */ let $2f3cded204daae76$export$b2f6b60c1d32d6aa = /*#__PURE__*/ (0, ($parcel$interopDefault($3rHYV$react))).forwardRef($2f3cded204daae76$var$StepButton);
88
+
89
+
90
+ //# sourceMappingURL=StepButton.main.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;AAsBD,SAAS,iCAAW,KAAsB,EAAE,GAAiC;IAC3E,QAAQ,CAAA,GAAA,6CAAe,EAAE;IACzB,IAAI,SAAC,KAAK,EAAC,GAAG,CAA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EA;;CAEC,GACD,IAAI,0DAAc,CAAA,GAAA,sCAAI,EAAE,UAAU,CAAC","sources":["packages/@react-spectrum/numberfield/src/StepButton.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 Add from '@spectrum-icons/workflow/Add';\nimport {AriaButtonProps} from '@react-types/button';\nimport ChevronDownSmall from '@spectrum-icons/ui/ChevronDownSmall';\nimport ChevronUpSmall from '@spectrum-icons/ui/ChevronUpSmall';\nimport {classNames, useFocusableRef} from '@react-spectrum/utils';\nimport {FocusableRef} from '@react-types/shared';\nimport {FocusRing} from '@react-aria/focus';\nimport {mergeProps} from '@react-aria/utils';\nimport React, {ReactElement} from 'react';\nimport Remove from '@spectrum-icons/workflow/Remove';\nimport stepperStyle from '@adobe/spectrum-css-temp/components/stepper/vars.css';\nimport {useButton} from '@react-aria/button';\nimport {useHover} from '@react-aria/interactions';\nimport {useProvider, useProviderProps} from '@react-spectrum/provider';\n\ninterface StepButtonProps extends AriaButtonProps {\n isQuiet?: boolean,\n direction: 'up' | 'down'\n}\n\nfunction StepButton(props: StepButtonProps, ref: FocusableRef<HTMLDivElement>) {\n props = useProviderProps(props);\n let {scale} = useProvider();\n let {direction, isDisabled, isQuiet} = props;\n let domRef = useFocusableRef(ref);\n /**\n * Must use div for now because Safari pointer event bugs on disabled form elements.\n * Link https://bugs.webkit.org/show_bug.cgi?id=219188.\n */\n let {buttonProps, isPressed} = useButton({...props, elementType: 'div'}, domRef);\n let {hoverProps, isHovered} = useHover(props);\n return (\n <FocusRing focusRingClass={classNames(stepperStyle, 'focus-ring')}>\n <div\n className={\n classNames(\n stepperStyle,\n 'spectrum-Stepper-button',\n {\n 'spectrum-Stepper-button--stepUp': direction === 'up',\n 'spectrum-Stepper-button--stepDown': direction === 'down',\n 'spectrum-Stepper-button--isQuiet': isQuiet,\n 'is-hovered': isHovered,\n 'is-active': isPressed,\n 'is-disabled': isDisabled\n }\n )\n }\n {...mergeProps(hoverProps, buttonProps)}\n ref={domRef}>\n {direction === 'up' && scale === 'large' &&\n <Add UNSAFE_className={classNames(stepperStyle, 'spectrum-Stepper-button-icon', 'spectrum-Stepper-stepUpIcon')} size=\"S\" />\n }\n {direction === 'up' && scale === 'medium' &&\n <ChevronUpSmall UNSAFE_className={classNames(stepperStyle, 'spectrum-Stepper-button-icon', 'spectrum-Stepper-stepUpIcon')} />\n }\n {direction === 'down' && scale === 'large' &&\n <Remove UNSAFE_className={classNames(stepperStyle, 'spectrum-Stepper-button-icon', 'spectrum-Stepper-stepDownIcon')} size=\"S\" />\n }\n {direction === 'down' && scale === 'medium' &&\n <ChevronDownSmall UNSAFE_className={classNames(stepperStyle, 'spectrum-Stepper-button-icon', 'spectrum-Stepper-stepDownIcon')} />\n }\n </div>\n </FocusRing>\n );\n}\n\n/**\n * Buttons for NumberField.\n */\nlet _StepButton = React.forwardRef(StepButton) as (props: StepButtonProps & {ref?: FocusableRef<HTMLDivElement>}) => ReactElement;\nexport {_StepButton as StepButton};\n"],"names":[],"version":3,"file":"StepButton.main.js.map"}