@react-spectrum/numberfield 3.8.1 → 3.9.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.
- package/dist/import.mjs +8 -10
- package/dist/main.css +1 -1104
- package/dist/main.js +8 -10
- package/dist/main.js.map +1 -1
- package/dist/module.js +8 -10
- package/dist/module.js.map +1 -1
- package/package.json +16 -16
- package/src/NumberField.tsx +8 -8
- package/src/StepButton.tsx +9 -7
- package/dist/main.css.map +0 -1
package/dist/main.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
1
|
require("./main.css");
|
|
4
2
|
var $i8sTE$reactspectrumutils = require("@react-spectrum/utils");
|
|
5
3
|
var $i8sTE$reactspectrumlabel = require("@react-spectrum/label");
|
|
@@ -217,13 +215,14 @@ function $2f3cded204daae76$var$StepButton(props, ref) {
|
|
|
217
215
|
props = (0, $i8sTE$reactspectrumprovider.useProviderProps)(props);
|
|
218
216
|
let { scale: scale } = (0, $i8sTE$reactspectrumprovider.useProvider)();
|
|
219
217
|
let { direction: direction, isDisabled: isDisabled, isQuiet: isQuiet } = props;
|
|
218
|
+
let domRef = (0, $i8sTE$reactspectrumutils.useFocusableRef)(ref);
|
|
220
219
|
/**
|
|
221
220
|
* Must use div for now because Safari pointer event bugs on disabled form elements.
|
|
222
221
|
* Link https://bugs.webkit.org/show_bug.cgi?id=219188.
|
|
223
222
|
*/ let { buttonProps: buttonProps, isPressed: isPressed } = (0, $i8sTE$reactariabutton.useButton)({
|
|
224
223
|
...props,
|
|
225
224
|
elementType: "div"
|
|
226
|
-
},
|
|
225
|
+
}, domRef);
|
|
227
226
|
let { hoverProps: hoverProps, isHovered: isHovered } = (0, $i8sTE$reactariainteractions.useHover)(props);
|
|
228
227
|
return /*#__PURE__*/ (0, ($parcel$interopDefault($i8sTE$react))).createElement((0, $i8sTE$reactariafocus.FocusRing), {
|
|
229
228
|
focusRingClass: (0, $i8sTE$reactspectrumutils.classNames)((0, (/*@__PURE__*/$parcel$interopDefault($3649bcbba015c4d7$exports))), "focus-ring")
|
|
@@ -237,7 +236,7 @@ function $2f3cded204daae76$var$StepButton(props, ref) {
|
|
|
237
236
|
"is-disabled": isDisabled
|
|
238
237
|
}),
|
|
239
238
|
...(0, $i8sTE$reactariautils.mergeProps)(hoverProps, buttonProps),
|
|
240
|
-
ref:
|
|
239
|
+
ref: domRef
|
|
241
240
|
}, direction === "up" && scale === "large" && /*#__PURE__*/ (0, ($parcel$interopDefault($i8sTE$react))).createElement((0, ($parcel$interopDefault($i8sTE$spectrumiconsworkflowAdd))), {
|
|
242
241
|
UNSAFE_className: (0, $i8sTE$reactspectrumutils.classNames)((0, (/*@__PURE__*/$parcel$interopDefault($3649bcbba015c4d7$exports))), "spectrum-Stepper-button-icon", "spectrum-Stepper-stepUpIcon"),
|
|
243
242
|
size: "S"
|
|
@@ -273,7 +272,7 @@ function $9b3df9c012d62e52$var$NumberField(props, ref) {
|
|
|
273
272
|
...props,
|
|
274
273
|
locale: locale
|
|
275
274
|
});
|
|
276
|
-
let inputRef = (0, $i8sTE$react.useRef)();
|
|
275
|
+
let inputRef = (0, $i8sTE$react.useRef)(null);
|
|
277
276
|
let domRef = (0, $i8sTE$reactspectrumutils.useFocusableRef)(ref, inputRef);
|
|
278
277
|
let { groupProps: groupProps, labelProps: labelProps, inputProps: inputProps, incrementButtonProps: incrementButtonProps, decrementButtonProps: decrementButtonProps, descriptionProps: descriptionProps, errorMessageProps: errorMessageProps, isInvalid: isInvalid, validationErrors: validationErrors, validationDetails: validationDetails } = (0, $i8sTE$reactarianumberfield.useNumberField)(props, state, inputRef);
|
|
279
278
|
let isMobile = provider.scale === "large";
|
|
@@ -281,17 +280,16 @@ function $9b3df9c012d62e52$var$NumberField(props, ref) {
|
|
|
281
280
|
let { isHovered: isHovered, hoverProps: hoverProps } = (0, $i8sTE$reactariainteractions.useHover)({
|
|
282
281
|
isDisabled: isDisabled
|
|
283
282
|
});
|
|
284
|
-
let validationState = props.validationState || (isInvalid ? "invalid" :
|
|
285
|
-
let className = (0, $i8sTE$reactspectrumutils.classNames)((0, (/*@__PURE__*/$parcel$interopDefault($3649bcbba015c4d7$exports))), "spectrum-Stepper",
|
|
283
|
+
let validationState = props.validationState || (isInvalid ? "invalid" : undefined);
|
|
284
|
+
let className = (0, $i8sTE$reactspectrumutils.classNames)((0, (/*@__PURE__*/$parcel$interopDefault($3649bcbba015c4d7$exports))), "spectrum-Stepper", // because FocusRing won't pass along the className from Field, we have to handle that ourselves
|
|
285
|
+
!props.label && style.className ? style.className : "", {
|
|
286
286
|
"spectrum-Stepper--isQuiet": isQuiet,
|
|
287
287
|
"is-disabled": isDisabled,
|
|
288
288
|
"spectrum-Stepper--readonly": isReadOnly,
|
|
289
289
|
"is-invalid": validationState === "invalid" && !isDisabled,
|
|
290
290
|
"spectrum-Stepper--showStepper": showStepper,
|
|
291
291
|
"spectrum-Stepper--isMobile": isMobile,
|
|
292
|
-
"is-hovered": isHovered
|
|
293
|
-
// because FocusRing won't pass along the className from Field, we have to handle that ourselves
|
|
294
|
-
[style.className]: !props.label && style.className
|
|
292
|
+
"is-hovered": isHovered
|
|
295
293
|
});
|
|
296
294
|
return /*#__PURE__*/ (0, ($parcel$interopDefault($i8sTE$react))).createElement((0, $i8sTE$reactspectrumlabel.Field), {
|
|
297
295
|
...props,
|
package/dist/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC,GAED,0CAA0C;ACZ1C;;;;;;;;;;CAUC;;;;;;ACVD;;;;;;;;;;CAUC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACVD,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,I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AS;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/index.ts","packages/@react-spectrum/numberfield/src/NumberField.tsx","packages/@react-spectrum/numberfield/src/StepButton.tsx","packages/@adobe/spectrum-css-temp/components/stepper/vars.css"],"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\n/// <reference types=\"css-module-types\" />\n\nexport {NumberField} from './NumberField';\nexport type {SpectrumNumberFieldProps} from '@react-types/numberfield';\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 {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, 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>();\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' : null);\n let className =\n classNames(\n stepperStyle,\n 'spectrum-Stepper',\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 // because FocusRing won't pass along the className from Field, we have to handle that ourselves\n [style.className]: !props.label && style.className\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: RefObject<HTMLElement>) {\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 as RefObject<HTMLDivElement>}\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","/*\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} from '@react-spectrum/utils';\nimport {FocusRing} from '@react-aria/focus';\nimport {mergeProps} from '@react-aria/utils';\nimport React, {RefObject} 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: RefObject<HTMLDivElement>) {\n props = useProviderProps(props);\n let {scale} = useProvider();\n let {direction, isDisabled, isQuiet} = props;\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'}, ref);\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={ref}>\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);\nexport {_StepButton as StepButton};\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\n@import './index.css';\n@import './skin.css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A,GAAA,2CAAY;QACX,kBACE,CAAA,GAAA,oCAAS,EACP,CAAA,GAAA,gEAAW,GACX;QAGJ,gBACE,CAAA,GAAA,oCAAS,EACP,CAAA,GAAA,gEAAW,GACX;QAGJ,yBACE,CAAA,GAAA,oCAAS,EACP,CAAA,GAAA,gEAAW,GACX;QAGJ,SAAS;QACT,UAAU;QACV,iBAAiB;QACjB,YAAY;QACZ,YAAY;QACZ,kBAAA;QACD,6BACD,oIACE,0DAAC,CAAA,GAAA,yCAAS;QAAE,WAAU;QAAK,SAAS;QAAU,GAAG,cAAc;sBAC/D,0DAAC,CAAA,GAAA,yCAAS;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/index.ts","packages/@react-spectrum/numberfield/src/NumberField.tsx","packages/@react-spectrum/numberfield/src/StepButton.tsx","packages/@adobe/spectrum-css-temp/components/stepper/vars.css"],"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\n/// <reference types=\"css-module-types\" />\n\nexport {NumberField} from './NumberField';\nexport type {SpectrumNumberFieldProps} from '@react-types/numberfield';\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 {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","/*\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","/*\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\n@import './index.css';\n@import './skin.css';\n"],"names":[],"version":3,"file":"main.js.map"}
|
package/dist/module.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
1
|
import "./main.css";
|
|
4
2
|
import {useStyleProps as $k6K00$useStyleProps, useFocusableRef as $k6K00$useFocusableRef, classNames as $k6K00$classNames} from "@react-spectrum/utils";
|
|
5
3
|
import {Field as $k6K00$Field} from "@react-spectrum/label";
|
|
@@ -215,13 +213,14 @@ function $7f00b388e0d3b2f6$var$StepButton(props, ref) {
|
|
|
215
213
|
props = (0, $k6K00$useProviderProps)(props);
|
|
216
214
|
let { scale: scale } = (0, $k6K00$useProvider)();
|
|
217
215
|
let { direction: direction, isDisabled: isDisabled, isQuiet: isQuiet } = props;
|
|
216
|
+
let domRef = (0, $k6K00$useFocusableRef)(ref);
|
|
218
217
|
/**
|
|
219
218
|
* Must use div for now because Safari pointer event bugs on disabled form elements.
|
|
220
219
|
* Link https://bugs.webkit.org/show_bug.cgi?id=219188.
|
|
221
220
|
*/ let { buttonProps: buttonProps, isPressed: isPressed } = (0, $k6K00$useButton)({
|
|
222
221
|
...props,
|
|
223
222
|
elementType: "div"
|
|
224
|
-
},
|
|
223
|
+
}, domRef);
|
|
225
224
|
let { hoverProps: hoverProps, isHovered: isHovered } = (0, $k6K00$useHover)(props);
|
|
226
225
|
return /*#__PURE__*/ (0, $k6K00$react).createElement((0, $k6K00$FocusRing), {
|
|
227
226
|
focusRingClass: (0, $k6K00$classNames)((0, (/*@__PURE__*/$parcel$interopDefault($ba58a329f3e1a776$exports))), "focus-ring")
|
|
@@ -235,7 +234,7 @@ function $7f00b388e0d3b2f6$var$StepButton(props, ref) {
|
|
|
235
234
|
"is-disabled": isDisabled
|
|
236
235
|
}),
|
|
237
236
|
...(0, $k6K00$mergeProps)(hoverProps, buttonProps),
|
|
238
|
-
ref:
|
|
237
|
+
ref: domRef
|
|
239
238
|
}, direction === "up" && scale === "large" && /*#__PURE__*/ (0, $k6K00$react).createElement((0, $k6K00$spectrumiconsworkflowAdd), {
|
|
240
239
|
UNSAFE_className: (0, $k6K00$classNames)((0, (/*@__PURE__*/$parcel$interopDefault($ba58a329f3e1a776$exports))), "spectrum-Stepper-button-icon", "spectrum-Stepper-stepUpIcon"),
|
|
241
240
|
size: "S"
|
|
@@ -271,7 +270,7 @@ function $48b879bdd771eb85$var$NumberField(props, ref) {
|
|
|
271
270
|
...props,
|
|
272
271
|
locale: locale
|
|
273
272
|
});
|
|
274
|
-
let inputRef = (0, $k6K00$useRef)();
|
|
273
|
+
let inputRef = (0, $k6K00$useRef)(null);
|
|
275
274
|
let domRef = (0, $k6K00$useFocusableRef)(ref, inputRef);
|
|
276
275
|
let { groupProps: groupProps, labelProps: labelProps, inputProps: inputProps, incrementButtonProps: incrementButtonProps, decrementButtonProps: decrementButtonProps, descriptionProps: descriptionProps, errorMessageProps: errorMessageProps, isInvalid: isInvalid, validationErrors: validationErrors, validationDetails: validationDetails } = (0, $k6K00$useNumberField)(props, state, inputRef);
|
|
277
276
|
let isMobile = provider.scale === "large";
|
|
@@ -279,17 +278,16 @@ function $48b879bdd771eb85$var$NumberField(props, ref) {
|
|
|
279
278
|
let { isHovered: isHovered, hoverProps: hoverProps } = (0, $k6K00$useHover)({
|
|
280
279
|
isDisabled: isDisabled
|
|
281
280
|
});
|
|
282
|
-
let validationState = props.validationState || (isInvalid ? "invalid" :
|
|
283
|
-
let className = (0, $k6K00$classNames)((0, (/*@__PURE__*/$parcel$interopDefault($ba58a329f3e1a776$exports))), "spectrum-Stepper",
|
|
281
|
+
let validationState = props.validationState || (isInvalid ? "invalid" : undefined);
|
|
282
|
+
let className = (0, $k6K00$classNames)((0, (/*@__PURE__*/$parcel$interopDefault($ba58a329f3e1a776$exports))), "spectrum-Stepper", // because FocusRing won't pass along the className from Field, we have to handle that ourselves
|
|
283
|
+
!props.label && style.className ? style.className : "", {
|
|
284
284
|
"spectrum-Stepper--isQuiet": isQuiet,
|
|
285
285
|
"is-disabled": isDisabled,
|
|
286
286
|
"spectrum-Stepper--readonly": isReadOnly,
|
|
287
287
|
"is-invalid": validationState === "invalid" && !isDisabled,
|
|
288
288
|
"spectrum-Stepper--showStepper": showStepper,
|
|
289
289
|
"spectrum-Stepper--isMobile": isMobile,
|
|
290
|
-
"is-hovered": isHovered
|
|
291
|
-
// because FocusRing won't pass along the className from Field, we have to handle that ourselves
|
|
292
|
-
[style.className]: !props.label && style.className
|
|
290
|
+
"is-hovered": isHovered
|
|
293
291
|
});
|
|
294
292
|
return /*#__PURE__*/ (0, $k6K00$react).createElement((0, $k6K00$Field), {
|
|
295
293
|
...props,
|
package/dist/module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC,GAED,0CAA0C;ACZ1C;;;;;;;;;;CAUC;;;;;;ACVD;;;;;;;;;;CAUC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACVD,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA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AC,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/index.ts","packages/@react-spectrum/numberfield/src/NumberField.tsx","packages/@react-spectrum/numberfield/src/StepButton.tsx","packages/@adobe/spectrum-css-temp/components/stepper/vars.css"],"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\n/// <reference types=\"css-module-types\" />\n\nexport {NumberField} from './NumberField';\nexport type {SpectrumNumberFieldProps} from '@react-types/numberfield';\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 {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, 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>();\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' : null);\n let className =\n classNames(\n stepperStyle,\n 'spectrum-Stepper',\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 // because FocusRing won't pass along the className from Field, we have to handle that ourselves\n [style.className]: !props.label && style.className\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: RefObject<HTMLElement>) {\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 as RefObject<HTMLDivElement>}\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","/*\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} from '@react-spectrum/utils';\nimport {FocusRing} from '@react-aria/focus';\nimport {mergeProps} from '@react-aria/utils';\nimport React, {RefObject} 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: RefObject<HTMLDivElement>) {\n props = useProviderProps(props);\n let {scale} = useProvider();\n let {direction, isDisabled, isQuiet} = props;\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'}, ref);\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={ref}>\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);\nexport {_StepButton as StepButton};\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\n@import './index.css';\n@import './skin.css';\n"],"names":[],"version":3,"file":"module.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC,GAED,0CAA0C;ACZ1C;;;;;;;;;;CAUC;;;;;;ACVD;;;;;;;;;;CAUC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACVD,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AA3CA,4CAA8B,CAAC,gBAAgB,CAAC;AAChD,4CAA0B,CAAC,YAAY,CAAC;AACxC,4CAA+B,CAAC,iBAAiB,CAAC;AAClD,4CAAmC,CAAC,qBAAqB,CAAC;AAC1D,4CAA8B,CAAC,gBAAgB,CAAC;AAChD,4CAA8B,CAAC,gBAAgB,CAAC;AAChD,4CAAgC,CAAC,kBAAkB,CAAC;AACpD,4CAA+B,CAAC,iBAAiB,CAAC;AAClD,4CAA+B,CAAC,iBAAiB,CAAC;AAClD,4CAA+B,CAAC,iBAAiB,CAAC;AAClD,4CAA4B,CAAC,cAAc,CAAC;AAC5C,4CAAwC,CAAC,2BAA2B,EAAE,0CAAiC,CAAC;AACxG,4CAA4C,CAAC,8BAA8B,CAAC;AAC5E,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AAO;QACP,WAAW;qBACX,gCAAC,CAAA,GAAA,oBAAY;QACX,kBACE,CAAA,GAAA,iBAAS,EACP,CAAA,GAAA,gEAAW,GACX;QAGJ,gBACE,CAAA,GAAA,iBAAS,EACP,CAAA,GAAA,gEAAW,GACX;QAGJ,yBACE,CAAA,GAAA,iBAAS,EACP,CAAA,GAAA,gEAAW,GACX;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/index.ts","packages/@react-spectrum/numberfield/src/NumberField.tsx","packages/@react-spectrum/numberfield/src/StepButton.tsx","packages/@adobe/spectrum-css-temp/components/stepper/vars.css"],"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\n/// <reference types=\"css-module-types\" />\n\nexport {NumberField} from './NumberField';\nexport type {SpectrumNumberFieldProps} from '@react-types/numberfield';\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 {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","/*\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","/*\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\n@import './index.css';\n@import './skin.css';\n"],"names":[],"version":3,"file":"module.js.map"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-spectrum/numberfield",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.9.0",
|
|
4
4
|
"description": "Spectrum UI components in React",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/main.js",
|
|
@@ -36,22 +36,22 @@
|
|
|
36
36
|
"url": "https://github.com/adobe/react-spectrum"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@react-aria/button": "^3.9.
|
|
40
|
-
"@react-aria/focus": "^3.16.
|
|
41
|
-
"@react-aria/i18n": "^3.10.
|
|
42
|
-
"@react-aria/interactions": "^3.
|
|
43
|
-
"@react-aria/numberfield": "^3.
|
|
44
|
-
"@react-aria/utils": "^3.23.
|
|
45
|
-
"@react-spectrum/form": "^3.7.
|
|
46
|
-
"@react-spectrum/label": "^3.16.
|
|
47
|
-
"@react-spectrum/textfield": "^3.11.
|
|
48
|
-
"@react-spectrum/utils": "^3.11.
|
|
49
|
-
"@react-stately/numberfield": "^3.
|
|
39
|
+
"@react-aria/button": "^3.9.2",
|
|
40
|
+
"@react-aria/focus": "^3.16.1",
|
|
41
|
+
"@react-aria/i18n": "^3.10.1",
|
|
42
|
+
"@react-aria/interactions": "^3.21.0",
|
|
43
|
+
"@react-aria/numberfield": "^3.11.0",
|
|
44
|
+
"@react-aria/utils": "^3.23.1",
|
|
45
|
+
"@react-spectrum/form": "^3.7.3",
|
|
46
|
+
"@react-spectrum/label": "^3.16.3",
|
|
47
|
+
"@react-spectrum/textfield": "^3.11.3",
|
|
48
|
+
"@react-spectrum/utils": "^3.11.4",
|
|
49
|
+
"@react-stately/numberfield": "^3.9.0",
|
|
50
50
|
"@react-types/button": "^3.9.1",
|
|
51
|
-
"@react-types/numberfield": "^3.
|
|
51
|
+
"@react-types/numberfield": "^3.8.0",
|
|
52
52
|
"@react-types/shared": "^3.22.0",
|
|
53
|
-
"@spectrum-icons/ui": "^3.6.
|
|
54
|
-
"@spectrum-icons/workflow": "^4.2.
|
|
53
|
+
"@spectrum-icons/ui": "^3.6.4",
|
|
54
|
+
"@spectrum-icons/workflow": "^4.2.9",
|
|
55
55
|
"@swc/helpers": "^0.5.0"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
@@ -66,5 +66,5 @@
|
|
|
66
66
|
"publishConfig": {
|
|
67
67
|
"access": "public"
|
|
68
68
|
},
|
|
69
|
-
"gitHead": "
|
|
69
|
+
"gitHead": "f040ff62678e6a31375b96c05396df0bae660350"
|
|
70
70
|
}
|
package/src/NumberField.tsx
CHANGED
|
@@ -17,7 +17,7 @@ import {FocusableRef} from '@react-types/shared';
|
|
|
17
17
|
import {FocusRing} from '@react-aria/focus';
|
|
18
18
|
import {mergeProps} from '@react-aria/utils';
|
|
19
19
|
import {NumberFieldState, useNumberFieldState} from '@react-stately/numberfield';
|
|
20
|
-
import React, {HTMLAttributes, InputHTMLAttributes, RefObject, useRef} from 'react';
|
|
20
|
+
import React, {HTMLAttributes, InputHTMLAttributes, Ref, RefObject, useRef} from 'react';
|
|
21
21
|
import {SpectrumNumberFieldProps} from '@react-types/numberfield';
|
|
22
22
|
import {StepButton} from './StepButton';
|
|
23
23
|
import stepperStyle from '@adobe/spectrum-css-temp/components/stepper/vars.css';
|
|
@@ -43,7 +43,7 @@ function NumberField(props: SpectrumNumberFieldProps, ref: FocusableRef<HTMLElem
|
|
|
43
43
|
|
|
44
44
|
let {locale} = useLocale();
|
|
45
45
|
let state = useNumberFieldState({...props, locale});
|
|
46
|
-
let inputRef = useRef<HTMLInputElement>();
|
|
46
|
+
let inputRef = useRef<HTMLInputElement>(null);
|
|
47
47
|
let domRef = useFocusableRef<HTMLElement>(ref, inputRef);
|
|
48
48
|
let {
|
|
49
49
|
groupProps,
|
|
@@ -62,11 +62,13 @@ function NumberField(props: SpectrumNumberFieldProps, ref: FocusableRef<HTMLElem
|
|
|
62
62
|
|
|
63
63
|
let {isHovered, hoverProps} = useHover({isDisabled});
|
|
64
64
|
|
|
65
|
-
let validationState = props.validationState || (isInvalid ? 'invalid' :
|
|
65
|
+
let validationState = props.validationState || (isInvalid ? 'invalid' : undefined);
|
|
66
66
|
let className =
|
|
67
67
|
classNames(
|
|
68
68
|
stepperStyle,
|
|
69
69
|
'spectrum-Stepper',
|
|
70
|
+
// because FocusRing won't pass along the className from Field, we have to handle that ourselves
|
|
71
|
+
!props.label && style.className ? style.className : '',
|
|
70
72
|
{
|
|
71
73
|
'spectrum-Stepper--isQuiet': isQuiet,
|
|
72
74
|
'is-disabled': isDisabled,
|
|
@@ -74,9 +76,7 @@ function NumberField(props: SpectrumNumberFieldProps, ref: FocusableRef<HTMLElem
|
|
|
74
76
|
'is-invalid': validationState === 'invalid' && !isDisabled,
|
|
75
77
|
'spectrum-Stepper--showStepper': showStepper,
|
|
76
78
|
'spectrum-Stepper--isMobile': isMobile,
|
|
77
|
-
'is-hovered': isHovered
|
|
78
|
-
// because FocusRing won't pass along the className from Field, we have to handle that ourselves
|
|
79
|
-
[style.className]: !props.label && style.className
|
|
79
|
+
'is-hovered': isHovered
|
|
80
80
|
}
|
|
81
81
|
);
|
|
82
82
|
|
|
@@ -124,7 +124,7 @@ interface NumberFieldInputProps extends SpectrumNumberFieldProps {
|
|
|
124
124
|
state: NumberFieldState
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
-
const NumberFieldInput = React.forwardRef(function NumberFieldInput(props: NumberFieldInputProps, ref:
|
|
127
|
+
const NumberFieldInput = React.forwardRef(function NumberFieldInput(props: NumberFieldInputProps, ref: Ref<HTMLDivElement>) {
|
|
128
128
|
let {
|
|
129
129
|
groupProps,
|
|
130
130
|
inputProps,
|
|
@@ -152,7 +152,7 @@ const NumberFieldInput = React.forwardRef(function NumberFieldInput(props: Numbe
|
|
|
152
152
|
autoFocus={autoFocus}>
|
|
153
153
|
<div
|
|
154
154
|
{...groupProps}
|
|
155
|
-
ref={ref
|
|
155
|
+
ref={ref}
|
|
156
156
|
style={style}
|
|
157
157
|
className={className}>
|
|
158
158
|
<TextFieldBase
|
package/src/StepButton.tsx
CHANGED
|
@@ -14,10 +14,11 @@ import Add from '@spectrum-icons/workflow/Add';
|
|
|
14
14
|
import {AriaButtonProps} from '@react-types/button';
|
|
15
15
|
import ChevronDownSmall from '@spectrum-icons/ui/ChevronDownSmall';
|
|
16
16
|
import ChevronUpSmall from '@spectrum-icons/ui/ChevronUpSmall';
|
|
17
|
-
import {classNames} from '@react-spectrum/utils';
|
|
17
|
+
import {classNames, useFocusableRef} from '@react-spectrum/utils';
|
|
18
|
+
import {FocusableRef} from '@react-types/shared';
|
|
18
19
|
import {FocusRing} from '@react-aria/focus';
|
|
19
20
|
import {mergeProps} from '@react-aria/utils';
|
|
20
|
-
import React, {
|
|
21
|
+
import React, {ReactElement} from 'react';
|
|
21
22
|
import Remove from '@spectrum-icons/workflow/Remove';
|
|
22
23
|
import stepperStyle from '@adobe/spectrum-css-temp/components/stepper/vars.css';
|
|
23
24
|
import {useButton} from '@react-aria/button';
|
|
@@ -25,19 +26,20 @@ import {useHover} from '@react-aria/interactions';
|
|
|
25
26
|
import {useProvider, useProviderProps} from '@react-spectrum/provider';
|
|
26
27
|
|
|
27
28
|
interface StepButtonProps extends AriaButtonProps {
|
|
28
|
-
isQuiet
|
|
29
|
+
isQuiet?: boolean,
|
|
29
30
|
direction: 'up' | 'down'
|
|
30
31
|
}
|
|
31
32
|
|
|
32
|
-
function StepButton(props: StepButtonProps, ref:
|
|
33
|
+
function StepButton(props: StepButtonProps, ref: FocusableRef<HTMLDivElement>) {
|
|
33
34
|
props = useProviderProps(props);
|
|
34
35
|
let {scale} = useProvider();
|
|
35
36
|
let {direction, isDisabled, isQuiet} = props;
|
|
37
|
+
let domRef = useFocusableRef(ref);
|
|
36
38
|
/**
|
|
37
39
|
* Must use div for now because Safari pointer event bugs on disabled form elements.
|
|
38
40
|
* Link https://bugs.webkit.org/show_bug.cgi?id=219188.
|
|
39
41
|
*/
|
|
40
|
-
let {buttonProps, isPressed} = useButton({...props, elementType: 'div'},
|
|
42
|
+
let {buttonProps, isPressed} = useButton({...props, elementType: 'div'}, domRef);
|
|
41
43
|
let {hoverProps, isHovered} = useHover(props);
|
|
42
44
|
return (
|
|
43
45
|
<FocusRing focusRingClass={classNames(stepperStyle, 'focus-ring')}>
|
|
@@ -57,7 +59,7 @@ function StepButton(props: StepButtonProps, ref: RefObject<HTMLDivElement>) {
|
|
|
57
59
|
)
|
|
58
60
|
}
|
|
59
61
|
{...mergeProps(hoverProps, buttonProps)}
|
|
60
|
-
ref={
|
|
62
|
+
ref={domRef}>
|
|
61
63
|
{direction === 'up' && scale === 'large' &&
|
|
62
64
|
<Add UNSAFE_className={classNames(stepperStyle, 'spectrum-Stepper-button-icon', 'spectrum-Stepper-stepUpIcon')} size="S" />
|
|
63
65
|
}
|
|
@@ -78,5 +80,5 @@ function StepButton(props: StepButtonProps, ref: RefObject<HTMLDivElement>) {
|
|
|
78
80
|
/**
|
|
79
81
|
* Buttons for NumberField.
|
|
80
82
|
*/
|
|
81
|
-
let _StepButton = React.forwardRef(StepButton);
|
|
83
|
+
let _StepButton = React.forwardRef(StepButton) as (props: StepButtonProps & {ref?: FocusableRef<HTMLDivElement>}) => ReactElement;
|
|
82
84
|
export {_StepButton as StepButton};
|
package/dist/main.css.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":"AA4DA;;;;;AAIE;;;;AAIA;;;;AAIA;;;;AAIA;;;;AAIA;;;;AAIA;;;;AAIA;;;;AAIA;;;;AAIA;;;;AAKF;;;;;;;;AAOE;;;;;;;;;;;;;;AAiBF;;;AAII;;;;;AAQF;;;;AAKE;;;;;AAmBJ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BE;;;;AA2BA;;;;AAGA;;;;AAKA;;;;;;;AAYA;;;;AAAA;;;;AAKA;;;;;;;;AAWF;;;;;;;;;;;;;;AAoBE;;;;AAAA;;;;AAMA;;;;AAIA;;;;AAIA;;;;;AAKA;;;;;;;;;AAWE;;;;AAAA;;;;AAOJ;;;;;;;AASA;;;;;;;;;;;AAiBE;;;;AAKA;;;;AAKA;;;;AAIA;;;;AAKA;;;;AAAA;;;;AAMA;;;;AAAA;;;;AAMF;;;;;AAAA;;;;AAAA;;;;AAAA;;;;AAAA;;;;AAMA;;;;AAIA;;;;;;;AAYE;;;;AAKF;;;;;;AAMA;;;;;;;AAQA;;;;;;;;;;AAcA;;;;;;;;;;;;;;;AAqBA;;;;;;;;;;;AAaE;;;;;AAAA;;;;;AAMA;;;;AAKF;;;;;;;;AAWI;;;;AAAA;;;;AAMJ;;;;;;;;;;AAcE;;;;;;;AAOF;EAEI;;;;;AAOJ;;;;;AAKA;;;;;;;;;;AAkBE;;;;;;AAME;;;;;AAIA;;;;;AAKF;;;;;;AAUA;;;;;;AAMA;;;;AAIA;;;;AAGA;;;;AAIA;;;;AAEE;;;;AAAA;;;;AAAA;;;;AAAA;;;;AAOI;;;;;AASA;;;;;AAUA;;;;;AAAA;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;;;;;;;;;;EAaI;;;;EAAA;;;;EAME;;;;EAMF;;;;;EAME;;;;;EAIA;;;;;EAVF;;;;;EAME;;;;;EAIA;;;;;EAVF;;;;;EAME;;;;;EAIA;;;;;EAVF;;;;;EAME;;;;;EAIA;;;;;EAOA;;;;EAGA;;;;EAHA;;;;EAGA","sources":["packages/@adobe/spectrum-css-temp/components/stepper/vars.css"],"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\n@import './index.css';\n@import './skin.css';\n"],"names":[],"version":3,"file":"main.css.map"}
|