@fluentui/react-spinbutton 9.2.71 → 9.2.73
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +25 -2
- package/lib/components/SpinButton/useSpinButton.js +17 -17
- package/lib/components/SpinButton/useSpinButton.js.map +1 -1
- package/lib-commonjs/components/SpinButton/useSpinButton.js +17 -17
- package/lib-commonjs/components/SpinButton/useSpinButton.js.map +1 -1
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
@@ -1,12 +1,35 @@
|
|
1
1
|
# Change Log - @fluentui/react-spinbutton
|
2
2
|
|
3
|
-
This log was last generated on
|
3
|
+
This log was last generated on Thu, 02 May 2024 11:31:30 GMT and should not be manually modified.
|
4
4
|
|
5
5
|
<!-- Start content -->
|
6
6
|
|
7
|
+
## [9.2.73](https://github.com/microsoft/fluentui/tree/@fluentui/react-spinbutton_v9.2.73)
|
8
|
+
|
9
|
+
Thu, 02 May 2024 11:31:30 GMT
|
10
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-spinbutton_v9.2.72..@fluentui/react-spinbutton_v9.2.73)
|
11
|
+
|
12
|
+
### Patches
|
13
|
+
|
14
|
+
- chore: upgrade @fluentui/react-icons to 2.0.237. ([PR #31139](https://github.com/microsoft/fluentui/pull/31139) by ololubek@microsoft.com)
|
15
|
+
- Bump @fluentui/react-field to v9.1.63 ([PR #31231](https://github.com/microsoft/fluentui/pull/31231) by beachball)
|
16
|
+
|
17
|
+
## [9.2.72](https://github.com/microsoft/fluentui/tree/@fluentui/react-spinbutton_v9.2.72)
|
18
|
+
|
19
|
+
Tue, 23 Apr 2024 08:17:48 GMT
|
20
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-spinbutton_v9.2.71..@fluentui/react-spinbutton_v9.2.72)
|
21
|
+
|
22
|
+
### Patches
|
23
|
+
|
24
|
+
- fix: SpinButton buttons now display correct visuals at bounds ([PR #31126](https://github.com/microsoft/fluentui/pull/31126) by seanmonahan@microsoft.com)
|
25
|
+
- Bump @fluentui/react-field to v9.1.62 ([PR #31113](https://github.com/microsoft/fluentui/pull/31113) by beachball)
|
26
|
+
- Bump @fluentui/react-jsx-runtime to v9.0.36 ([PR #31113](https://github.com/microsoft/fluentui/pull/31113) by beachball)
|
27
|
+
- Bump @fluentui/react-shared-contexts to v9.17.0 ([PR #31113](https://github.com/microsoft/fluentui/pull/31113) by beachball)
|
28
|
+
- Bump @fluentui/react-utilities to v9.18.7 ([PR #31113](https://github.com/microsoft/fluentui/pull/31113) by beachball)
|
29
|
+
|
7
30
|
## [9.2.71](https://github.com/microsoft/fluentui/tree/@fluentui/react-spinbutton_v9.2.71)
|
8
31
|
|
9
|
-
Wed, 17 Apr 2024 21:
|
32
|
+
Wed, 17 Apr 2024 21:53:57 GMT
|
10
33
|
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-spinbutton_v9.2.70..@fluentui/react-spinbutton_v9.2.71)
|
11
34
|
|
12
35
|
### Patches
|
@@ -181,6 +181,23 @@ const lerp = (start, end, percent)=>start + (end - start) * percent;
|
|
181
181
|
}
|
182
182
|
setTextValue(undefined);
|
183
183
|
};
|
184
|
+
let valueToDisplay;
|
185
|
+
if (textValue !== undefined) {
|
186
|
+
valueToDisplay = textValue;
|
187
|
+
} else if (value === null || currentValue === null) {
|
188
|
+
valueToDisplay = displayValue !== null && displayValue !== void 0 ? displayValue : '';
|
189
|
+
internalState.current.value = null;
|
190
|
+
internalState.current.atBound = 'none';
|
191
|
+
} else {
|
192
|
+
const roundedValue = precisionRound(currentValue, precision);
|
193
|
+
internalState.current.value = roundedValue;
|
194
|
+
internalState.current.atBound = getBound(roundedValue, min, max);
|
195
|
+
if (isControlled) {
|
196
|
+
valueToDisplay = displayValue !== null && displayValue !== void 0 ? displayValue : String(roundedValue);
|
197
|
+
} else {
|
198
|
+
valueToDisplay = String(roundedValue);
|
199
|
+
}
|
200
|
+
}
|
184
201
|
const state = {
|
185
202
|
size,
|
186
203
|
appearance,
|
@@ -228,23 +245,6 @@ const lerp = (start, end, percent)=>start + (end - start) * percent;
|
|
228
245
|
elementType: 'button'
|
229
246
|
})
|
230
247
|
};
|
231
|
-
let valueToDisplay;
|
232
|
-
if (textValue !== undefined) {
|
233
|
-
valueToDisplay = textValue;
|
234
|
-
} else if (value === null || currentValue === null) {
|
235
|
-
valueToDisplay = displayValue !== null && displayValue !== void 0 ? displayValue : '';
|
236
|
-
internalState.current.value = null;
|
237
|
-
internalState.current.atBound = 'none';
|
238
|
-
} else {
|
239
|
-
const roundedValue = precisionRound(currentValue, precision);
|
240
|
-
internalState.current.value = roundedValue;
|
241
|
-
internalState.current.atBound = getBound(roundedValue, min, max);
|
242
|
-
if (isControlled) {
|
243
|
-
valueToDisplay = displayValue !== null && displayValue !== void 0 ? displayValue : String(roundedValue);
|
244
|
-
} else {
|
245
|
-
valueToDisplay = String(roundedValue);
|
246
|
-
}
|
247
|
-
}
|
248
248
|
state.input.value = valueToDisplay;
|
249
249
|
state.input['aria-valuemin'] = min;
|
250
250
|
state.input['aria-valuemax'] = max;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["useSpinButton.tsx"],"sourcesContent":["import * as React from 'react';\nimport { useFieldControlProps_unstable } from '@fluentui/react-field';\nimport {\n getPartitionedNativeProps,\n mergeCallbacks,\n useControllableState,\n useTimeout,\n slot,\n} from '@fluentui/react-utilities';\nimport { ArrowUp, ArrowDown, End, Enter, Escape, Home, PageDown, PageUp } from '@fluentui/keyboard-keys';\nimport {\n SpinButtonProps,\n SpinButtonState,\n SpinButtonSpinState,\n SpinButtonChangeEvent,\n SpinButtonBounds,\n} from './SpinButton.types';\nimport { calculatePrecision, precisionRound, getBound, clamp } from '../../utils/index';\nimport { ChevronUp16Regular, ChevronDown16Regular } from '@fluentui/react-icons';\nimport { useOverrides_unstable as useOverrides } from '@fluentui/react-shared-contexts';\n\ntype InternalState = {\n value: number | null;\n spinState: SpinButtonSpinState;\n spinTime: number;\n spinDelay: number;\n previousTextValue?: string;\n atBound: SpinButtonBounds;\n};\n\nconst DEFAULT_SPIN_DELAY_MS = 150;\nconst MIN_SPIN_DELAY_MS = 80;\nconst MAX_SPIN_TIME_MS = 1000;\n\n// This is here to give an ease for the mouse held down case.\n// Exact easing it to be defined. Once it is we'll likely\n// pull this out into a util function in the SpinButton package.\nconst lerp = (start: number, end: number, percent: number): number => start + (end - start) * percent;\n\n/**\n * Create the state required to render SpinButton.\n *\n * The returned state can be modified with hooks such as useSpinButtonStyles_unstable,\n * before being passed to renderSpinButton_unstable.\n *\n * @param props - props from this instance of SpinButton\n * @param ref - reference to root HTMLElement of SpinButton\n */\nexport const useSpinButton_unstable = (props: SpinButtonProps, ref: React.Ref<HTMLInputElement>): SpinButtonState => {\n // Merge props from surrounding <Field>, if any\n props = useFieldControlProps_unstable(props, { supportsLabelFor: true, supportsRequired: true });\n\n const nativeProps = getPartitionedNativeProps({\n props,\n primarySlotTagName: 'input',\n excludedPropNames: ['defaultValue', 'max', 'min', 'onChange', 'size', 'value'],\n });\n\n const overrides = useOverrides();\n\n const {\n value,\n displayValue,\n defaultValue,\n min,\n max,\n step = 1,\n stepPage = 1,\n precision: precisionFromProps,\n onChange,\n size = 'medium',\n appearance = overrides.inputDefaultAppearance ?? 'outline',\n root,\n input,\n incrementButton,\n decrementButton,\n } = props;\n\n const precision = React.useMemo(() => {\n return precisionFromProps ?? Math.max(calculatePrecision(step), 0);\n }, [precisionFromProps, step]);\n\n const [currentValue, setCurrentValue] = useControllableState({\n state: value,\n defaultState: defaultValue,\n initialState: 0,\n });\n\n const isControlled = value !== undefined;\n\n const [textValue, setTextValue] = React.useState<string | undefined>(undefined);\n const [keyboardSpinState, setKeyboardSpinState] = React.useState<SpinButtonSpinState>('rest');\n\n const internalState = React.useRef<InternalState>({\n value: currentValue,\n spinState: 'rest',\n spinTime: 0,\n spinDelay: DEFAULT_SPIN_DELAY_MS,\n atBound: currentValue !== null ? getBound(precisionRound(currentValue, precision), min, max) : 'none',\n });\n\n const [setStepTimeout, clearStepTimeout] = useTimeout();\n\n const stepValue = (\n e: SpinButtonChangeEvent,\n direction: 'up' | 'down' | 'upPage' | 'downPage',\n startFrom?: string,\n ) => {\n let startValue = internalState.current.value;\n if (startFrom) {\n const num = parseFloat(startFrom);\n if (!isNaN(num)) {\n startValue = num;\n }\n }\n const val = startValue;\n const dir = direction === 'up' || direction === 'upPage' ? 1 : -1;\n const stepSize = direction === 'upPage' || direction === 'downPage' ? stepPage : step;\n\n if (val === null) {\n const stepStart = min === undefined ? 0 : min;\n const nullStep = clamp(stepStart + stepSize * dir, min, max);\n commit(e, nullStep);\n return;\n }\n\n let newValue = val + stepSize * dir;\n if (!Number.isNaN(newValue)) {\n newValue = clamp(newValue, min, max);\n }\n\n commit(e, newValue);\n\n if (internalState.current.spinState !== 'rest') {\n setStepTimeout(() => {\n // Ease the step speed a bit\n internalState.current.spinTime += internalState.current.spinDelay;\n internalState.current.spinDelay = lerp(\n DEFAULT_SPIN_DELAY_MS,\n MIN_SPIN_DELAY_MS,\n internalState.current.spinTime / MAX_SPIN_TIME_MS,\n );\n stepValue(e, direction);\n }, internalState.current.spinDelay);\n }\n };\n\n const handleInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n if (!internalState.current.previousTextValue) {\n internalState.current.previousTextValue = textValue ?? String(currentValue);\n }\n const newValue = e.target.value;\n setTextValue(newValue);\n };\n\n const handleIncrementMouseDown = (e: React.MouseEvent<HTMLButtonElement>) => {\n internalState.current.spinState = 'up';\n stepValue(e, 'up');\n };\n\n const handleDecrementMouseDown = (e: React.MouseEvent<HTMLButtonElement>) => {\n internalState.current.spinState = 'down';\n stepValue(e, 'down');\n };\n\n const handleStepMouseUpOrLeave = (e: React.MouseEvent<HTMLButtonElement>) => {\n clearStepTimeout();\n internalState.current.spinState = 'rest';\n internalState.current.spinDelay = DEFAULT_SPIN_DELAY_MS;\n internalState.current.spinTime = 0;\n };\n\n const handleBlur = (e: React.FocusEvent<HTMLInputElement>) => {\n commit(e, currentValue, textValue);\n internalState.current.previousTextValue = undefined;\n };\n\n const handleKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {\n let nextKeyboardSpinState: SpinButtonSpinState = 'rest';\n\n if (e.key === ArrowUp) {\n stepValue(e, 'up', textValue);\n nextKeyboardSpinState = 'up';\n } else if (e.key === ArrowDown) {\n stepValue(e, 'down', textValue);\n nextKeyboardSpinState = 'down';\n } else if (e.key === PageUp) {\n e.preventDefault();\n stepValue(e, 'upPage', textValue);\n nextKeyboardSpinState = 'up';\n } else if (e.key === PageDown) {\n e.preventDefault();\n stepValue(e, 'downPage', textValue);\n nextKeyboardSpinState = 'down';\n } else if (!e.shiftKey && e.key === Home && min !== undefined) {\n commit(e, min);\n nextKeyboardSpinState = 'down';\n } else if (!e.shiftKey && e.key === End && max !== undefined) {\n commit(e, max);\n nextKeyboardSpinState = 'up';\n } else if (e.key === Enter) {\n commit(e, currentValue, textValue);\n internalState.current.previousTextValue = undefined;\n } else if (e.key === Escape) {\n if (internalState.current.previousTextValue) {\n setTextValue(undefined);\n internalState.current.previousTextValue = undefined;\n }\n }\n\n if (keyboardSpinState !== nextKeyboardSpinState) {\n setKeyboardSpinState(nextKeyboardSpinState);\n }\n };\n\n const handleKeyUp = (e: React.KeyboardEvent<HTMLInputElement>) => {\n if (keyboardSpinState !== 'rest') {\n setKeyboardSpinState('rest');\n internalState.current.spinState = 'rest';\n }\n };\n\n const commit = (e: SpinButtonChangeEvent, newValue?: number | null, newDisplayValue?: string) => {\n const valueChanged = newValue !== undefined && currentValue !== newValue;\n const displayValueChanged =\n newDisplayValue !== undefined &&\n internalState.current.previousTextValue !== undefined &&\n internalState.current.previousTextValue !== newDisplayValue;\n\n let roundedValue;\n if (valueChanged) {\n roundedValue = precisionRound(newValue!, precision);\n setCurrentValue(roundedValue);\n } else if (displayValueChanged && !isControlled) {\n const nextValue = parseFloat(newDisplayValue as string);\n if (!isNaN(nextValue)) {\n setCurrentValue(precisionRound(nextValue, precision));\n }\n }\n\n if (valueChanged || displayValueChanged) {\n onChange?.(e, { value: roundedValue, displayValue: newDisplayValue });\n }\n\n setTextValue(undefined);\n };\n\n const state: SpinButtonState = {\n size,\n appearance,\n spinState: keyboardSpinState,\n atBound: internalState.current.atBound,\n\n components: {\n root: 'span',\n input: 'input',\n incrementButton: 'button',\n decrementButton: 'button',\n },\n root: slot.always(root, {\n defaultProps: nativeProps.root,\n elementType: 'span',\n }),\n input: slot.always(input, {\n defaultProps: {\n ref,\n autoComplete: 'off',\n role: 'spinbutton',\n appearance,\n type: 'text',\n ...nativeProps.primary,\n },\n elementType: 'input',\n }),\n incrementButton: slot.always(incrementButton, {\n defaultProps: {\n tabIndex: -1,\n children: <ChevronUp16Regular />,\n disabled: nativeProps.primary.disabled,\n 'aria-label': 'Increment value',\n type: 'button',\n },\n elementType: 'button',\n }),\n decrementButton: slot.always(decrementButton, {\n defaultProps: {\n tabIndex: -1,\n children: <ChevronDown16Regular />,\n disabled: nativeProps.primary.disabled,\n 'aria-label': 'Decrement value',\n type: 'button',\n },\n elementType: 'button',\n }),\n };\n\n let valueToDisplay;\n if (textValue !== undefined) {\n valueToDisplay = textValue;\n } else if (value === null || currentValue === null) {\n valueToDisplay = displayValue ?? '';\n internalState.current.value = null;\n internalState.current.atBound = 'none';\n } else {\n const roundedValue = precisionRound(currentValue, precision);\n internalState.current.value = roundedValue;\n internalState.current.atBound = getBound(roundedValue, min, max);\n if (isControlled) {\n valueToDisplay = displayValue ?? String(roundedValue);\n } else {\n valueToDisplay = String(roundedValue);\n }\n }\n\n state.input.value = valueToDisplay;\n state.input['aria-valuemin'] = min;\n state.input['aria-valuemax'] = max;\n state.input['aria-valuenow'] = currentValue ?? undefined;\n state.input['aria-valuetext'] = state.input['aria-valuetext'] ?? ((value !== undefined && displayValue) || undefined);\n state.input.onChange = mergeCallbacks(state.input.onChange, handleInputChange);\n state.input.onBlur = mergeCallbacks(state.input.onBlur, handleBlur);\n state.input.onKeyDown = mergeCallbacks(state.input.onKeyDown, handleKeyDown);\n state.input.onKeyUp = mergeCallbacks(state.input.onKeyUp, handleKeyUp);\n\n state.incrementButton.onMouseDown = mergeCallbacks(handleIncrementMouseDown, state.incrementButton.onMouseDown);\n state.incrementButton.onMouseUp = mergeCallbacks(state.incrementButton.onMouseUp, handleStepMouseUpOrLeave);\n state.incrementButton.onMouseLeave = mergeCallbacks(state.incrementButton.onMouseLeave, handleStepMouseUpOrLeave);\n\n state.decrementButton.onMouseDown = mergeCallbacks(handleDecrementMouseDown, state.decrementButton.onMouseDown);\n state.decrementButton.onMouseUp = mergeCallbacks(state.decrementButton.onMouseUp, handleStepMouseUpOrLeave);\n state.decrementButton.onMouseLeave = mergeCallbacks(state.decrementButton.onMouseLeave, handleStepMouseUpOrLeave);\n\n return state;\n};\n"],"names":["React","useFieldControlProps_unstable","getPartitionedNativeProps","mergeCallbacks","useControllableState","useTimeout","slot","ArrowUp","ArrowDown","End","Enter","Escape","Home","PageDown","PageUp","calculatePrecision","precisionRound","getBound","clamp","ChevronUp16Regular","ChevronDown16Regular","useOverrides_unstable","useOverrides","DEFAULT_SPIN_DELAY_MS","MIN_SPIN_DELAY_MS","MAX_SPIN_TIME_MS","lerp","start","end","percent","useSpinButton_unstable","props","ref","supportsLabelFor","supportsRequired","nativeProps","primarySlotTagName","excludedPropNames","overrides","value","displayValue","defaultValue","min","max","step","stepPage","precision","precisionFromProps","onChange","size","appearance","inputDefaultAppearance","root","input","incrementButton","decrementButton","useMemo","Math","currentValue","setCurrentValue","state","defaultState","initialState","isControlled","undefined","textValue","setTextValue","useState","keyboardSpinState","setKeyboardSpinState","internalState","useRef","spinState","spinTime","spinDelay","atBound","setStepTimeout","clearStepTimeout","stepValue","e","direction","startFrom","startValue","current","num","parseFloat","isNaN","val","dir","stepSize","stepStart","nullStep","commit","newValue","Number","handleInputChange","previousTextValue","String","target","handleIncrementMouseDown","handleDecrementMouseDown","handleStepMouseUpOrLeave","handleBlur","handleKeyDown","nextKeyboardSpinState","key","preventDefault","shiftKey","handleKeyUp","newDisplayValue","valueChanged","displayValueChanged","roundedValue","nextValue","components","always","defaultProps","elementType","autoComplete","role","type","primary","tabIndex","children","disabled","valueToDisplay","onBlur","onKeyDown","onKeyUp","onMouseDown","onMouseUp","onMouseLeave"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,6BAA6B,QAAQ,wBAAwB;AACtE,SACEC,yBAAyB,EACzBC,cAAc,EACdC,oBAAoB,EACpBC,UAAU,EACVC,IAAI,QACC,4BAA4B;AACnC,SAASC,OAAO,EAAEC,SAAS,EAAEC,GAAG,EAAEC,KAAK,EAAEC,MAAM,EAAEC,IAAI,EAAEC,QAAQ,EAAEC,MAAM,QAAQ,0BAA0B;AAQzG,SAASC,kBAAkB,EAAEC,cAAc,EAAEC,QAAQ,EAAEC,KAAK,QAAQ,oBAAoB;AACxF,SAASC,kBAAkB,EAAEC,oBAAoB,QAAQ,wBAAwB;AACjF,SAASC,yBAAyBC,YAAY,QAAQ,kCAAkC;AAWxF,MAAMC,wBAAwB;AAC9B,MAAMC,oBAAoB;AAC1B,MAAMC,mBAAmB;AAEzB,6DAA6D;AAC7D,yDAAyD;AACzD,gEAAgE;AAChE,MAAMC,OAAO,CAACC,OAAeC,KAAaC,UAA4BF,QAAQ,AAACC,CAAAA,MAAMD,KAAI,IAAKE;AAE9F;;;;;;;;CAQC,GACD,OAAO,MAAMC,yBAAyB,CAACC,OAAwBC;IAC7D,+CAA+C;IAC/CD,QAAQ9B,8BAA8B8B,OAAO;QAAEE,kBAAkB;QAAMC,kBAAkB;IAAK;IAE9F,MAAMC,cAAcjC,0BAA0B;QAC5C6B;QACAK,oBAAoB;QACpBC,mBAAmB;YAAC;YAAgB;YAAO;YAAO;YAAY;YAAQ;SAAQ;IAChF;IAEA,MAAMC,YAAYhB;QAaHgB;IAXf,MAAM,EACJC,KAAK,EACLC,YAAY,EACZC,YAAY,EACZC,GAAG,EACHC,GAAG,EACHC,OAAO,CAAC,EACRC,WAAW,CAAC,EACZC,WAAWC,kBAAkB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yE,MAAM,EAAExB;IACxD1C,MAAMP,KAAK,CAAC0E,SAAS,GAAG5H,eAAeyD,MAAMP,KAAK,CAAC0E,SAAS,EAAExB;IAC9D3C,MAAMP,KAAK,CAAC2E,OAAO,GAAG7H,eAAeyD,MAAMP,KAAK,CAAC2E,OAAO,EAAEpB;IAE1DhD,MAAMN,eAAe,CAAC2E,WAAW,GAAG9H,eAAegG,0BAA0BvC,MAAMN,eAAe,CAAC2E,WAAW;IAC9GrE,MAAMN,eAAe,CAAC4E,SAAS,GAAG/H,eAAeyD,MAAMN,eAAe,CAAC4E,SAAS,EAAE7B;IAClFzC,MAAMN,eAAe,CAAC6E,YAAY,GAAGhI,eAAeyD,MAAMN,eAAe,CAAC6E,YAAY,EAAE9B;IAExFzC,MAAML,eAAe,CAAC0E,WAAW,GAAG9H,eAAeiG,0BAA0BxC,MAAML,eAAe,CAAC0E,WAAW;IAC9GrE,MAAML,eAAe,CAAC2E,SAAS,GAAG/H,eAAeyD,MAAML,eAAe,CAAC2E,SAAS,EAAE7B;IAClFzC,MAAML,eAAe,CAAC4E,YAAY,GAAGhI,eAAeyD,MAAML,eAAe,CAAC4E,YAAY,EAAE9B;IAExF,OAAOzC;AACT,EAAE"}
|
1
|
+
{"version":3,"sources":["useSpinButton.tsx"],"sourcesContent":["import * as React from 'react';\nimport { useFieldControlProps_unstable } from '@fluentui/react-field';\nimport {\n getPartitionedNativeProps,\n mergeCallbacks,\n useControllableState,\n useTimeout,\n slot,\n} from '@fluentui/react-utilities';\nimport { ArrowUp, ArrowDown, End, Enter, Escape, Home, PageDown, PageUp } from '@fluentui/keyboard-keys';\nimport {\n SpinButtonProps,\n SpinButtonState,\n SpinButtonSpinState,\n SpinButtonChangeEvent,\n SpinButtonBounds,\n} from './SpinButton.types';\nimport { calculatePrecision, precisionRound, getBound, clamp } from '../../utils/index';\nimport { ChevronUp16Regular, ChevronDown16Regular } from '@fluentui/react-icons';\nimport { useOverrides_unstable as useOverrides } from '@fluentui/react-shared-contexts';\n\ntype InternalState = {\n value: number | null;\n spinState: SpinButtonSpinState;\n spinTime: number;\n spinDelay: number;\n previousTextValue?: string;\n atBound: SpinButtonBounds;\n};\n\nconst DEFAULT_SPIN_DELAY_MS = 150;\nconst MIN_SPIN_DELAY_MS = 80;\nconst MAX_SPIN_TIME_MS = 1000;\n\n// This is here to give an ease for the mouse held down case.\n// Exact easing it to be defined. Once it is we'll likely\n// pull this out into a util function in the SpinButton package.\nconst lerp = (start: number, end: number, percent: number): number => start + (end - start) * percent;\n\n/**\n * Create the state required to render SpinButton.\n *\n * The returned state can be modified with hooks such as useSpinButtonStyles_unstable,\n * before being passed to renderSpinButton_unstable.\n *\n * @param props - props from this instance of SpinButton\n * @param ref - reference to root HTMLElement of SpinButton\n */\nexport const useSpinButton_unstable = (props: SpinButtonProps, ref: React.Ref<HTMLInputElement>): SpinButtonState => {\n // Merge props from surrounding <Field>, if any\n props = useFieldControlProps_unstable(props, { supportsLabelFor: true, supportsRequired: true });\n\n const nativeProps = getPartitionedNativeProps({\n props,\n primarySlotTagName: 'input',\n excludedPropNames: ['defaultValue', 'max', 'min', 'onChange', 'size', 'value'],\n });\n\n const overrides = useOverrides();\n\n const {\n value,\n displayValue,\n defaultValue,\n min,\n max,\n step = 1,\n stepPage = 1,\n precision: precisionFromProps,\n onChange,\n size = 'medium',\n appearance = overrides.inputDefaultAppearance ?? 'outline',\n root,\n input,\n incrementButton,\n decrementButton,\n } = props;\n\n const precision = React.useMemo(() => {\n return precisionFromProps ?? Math.max(calculatePrecision(step), 0);\n }, [precisionFromProps, step]);\n\n const [currentValue, setCurrentValue] = useControllableState({\n state: value,\n defaultState: defaultValue,\n initialState: 0,\n });\n\n const isControlled = value !== undefined;\n\n const [textValue, setTextValue] = React.useState<string | undefined>(undefined);\n const [keyboardSpinState, setKeyboardSpinState] = React.useState<SpinButtonSpinState>('rest');\n\n const internalState = React.useRef<InternalState>({\n value: currentValue,\n spinState: 'rest',\n spinTime: 0,\n spinDelay: DEFAULT_SPIN_DELAY_MS,\n atBound: currentValue !== null ? getBound(precisionRound(currentValue, precision), min, max) : 'none',\n });\n\n const [setStepTimeout, clearStepTimeout] = useTimeout();\n\n const stepValue = (\n e: SpinButtonChangeEvent,\n direction: 'up' | 'down' | 'upPage' | 'downPage',\n startFrom?: string,\n ) => {\n let startValue = internalState.current.value;\n if (startFrom) {\n const num = parseFloat(startFrom);\n if (!isNaN(num)) {\n startValue = num;\n }\n }\n const val = startValue;\n const dir = direction === 'up' || direction === 'upPage' ? 1 : -1;\n const stepSize = direction === 'upPage' || direction === 'downPage' ? stepPage : step;\n\n if (val === null) {\n const stepStart = min === undefined ? 0 : min;\n const nullStep = clamp(stepStart + stepSize * dir, min, max);\n commit(e, nullStep);\n return;\n }\n\n let newValue = val + stepSize * dir;\n if (!Number.isNaN(newValue)) {\n newValue = clamp(newValue, min, max);\n }\n\n commit(e, newValue);\n\n if (internalState.current.spinState !== 'rest') {\n setStepTimeout(() => {\n // Ease the step speed a bit\n internalState.current.spinTime += internalState.current.spinDelay;\n internalState.current.spinDelay = lerp(\n DEFAULT_SPIN_DELAY_MS,\n MIN_SPIN_DELAY_MS,\n internalState.current.spinTime / MAX_SPIN_TIME_MS,\n );\n stepValue(e, direction);\n }, internalState.current.spinDelay);\n }\n };\n\n const handleInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n if (!internalState.current.previousTextValue) {\n internalState.current.previousTextValue = textValue ?? String(currentValue);\n }\n const newValue = e.target.value;\n setTextValue(newValue);\n };\n\n const handleIncrementMouseDown = (e: React.MouseEvent<HTMLButtonElement>) => {\n internalState.current.spinState = 'up';\n stepValue(e, 'up');\n };\n\n const handleDecrementMouseDown = (e: React.MouseEvent<HTMLButtonElement>) => {\n internalState.current.spinState = 'down';\n stepValue(e, 'down');\n };\n\n const handleStepMouseUpOrLeave = (e: React.MouseEvent<HTMLButtonElement>) => {\n clearStepTimeout();\n internalState.current.spinState = 'rest';\n internalState.current.spinDelay = DEFAULT_SPIN_DELAY_MS;\n internalState.current.spinTime = 0;\n };\n\n const handleBlur = (e: React.FocusEvent<HTMLInputElement>) => {\n commit(e, currentValue, textValue);\n internalState.current.previousTextValue = undefined;\n };\n\n const handleKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {\n let nextKeyboardSpinState: SpinButtonSpinState = 'rest';\n\n if (e.key === ArrowUp) {\n stepValue(e, 'up', textValue);\n nextKeyboardSpinState = 'up';\n } else if (e.key === ArrowDown) {\n stepValue(e, 'down', textValue);\n nextKeyboardSpinState = 'down';\n } else if (e.key === PageUp) {\n e.preventDefault();\n stepValue(e, 'upPage', textValue);\n nextKeyboardSpinState = 'up';\n } else if (e.key === PageDown) {\n e.preventDefault();\n stepValue(e, 'downPage', textValue);\n nextKeyboardSpinState = 'down';\n } else if (!e.shiftKey && e.key === Home && min !== undefined) {\n commit(e, min);\n nextKeyboardSpinState = 'down';\n } else if (!e.shiftKey && e.key === End && max !== undefined) {\n commit(e, max);\n nextKeyboardSpinState = 'up';\n } else if (e.key === Enter) {\n commit(e, currentValue, textValue);\n internalState.current.previousTextValue = undefined;\n } else if (e.key === Escape) {\n if (internalState.current.previousTextValue) {\n setTextValue(undefined);\n internalState.current.previousTextValue = undefined;\n }\n }\n\n if (keyboardSpinState !== nextKeyboardSpinState) {\n setKeyboardSpinState(nextKeyboardSpinState);\n }\n };\n\n const handleKeyUp = (e: React.KeyboardEvent<HTMLInputElement>) => {\n if (keyboardSpinState !== 'rest') {\n setKeyboardSpinState('rest');\n internalState.current.spinState = 'rest';\n }\n };\n\n const commit = (e: SpinButtonChangeEvent, newValue?: number | null, newDisplayValue?: string) => {\n const valueChanged = newValue !== undefined && currentValue !== newValue;\n const displayValueChanged =\n newDisplayValue !== undefined &&\n internalState.current.previousTextValue !== undefined &&\n internalState.current.previousTextValue !== newDisplayValue;\n\n let roundedValue;\n if (valueChanged) {\n roundedValue = precisionRound(newValue!, precision);\n setCurrentValue(roundedValue);\n } else if (displayValueChanged && !isControlled) {\n const nextValue = parseFloat(newDisplayValue as string);\n if (!isNaN(nextValue)) {\n setCurrentValue(precisionRound(nextValue, precision));\n }\n }\n\n if (valueChanged || displayValueChanged) {\n onChange?.(e, { value: roundedValue, displayValue: newDisplayValue });\n }\n\n setTextValue(undefined);\n };\n\n let valueToDisplay;\n if (textValue !== undefined) {\n valueToDisplay = textValue;\n } else if (value === null || currentValue === null) {\n valueToDisplay = displayValue ?? '';\n internalState.current.value = null;\n internalState.current.atBound = 'none';\n } else {\n const roundedValue = precisionRound(currentValue, precision);\n internalState.current.value = roundedValue;\n internalState.current.atBound = getBound(roundedValue, min, max);\n if (isControlled) {\n valueToDisplay = displayValue ?? String(roundedValue);\n } else {\n valueToDisplay = String(roundedValue);\n }\n }\n\n const state: SpinButtonState = {\n size,\n appearance,\n spinState: keyboardSpinState,\n atBound: internalState.current.atBound,\n\n components: {\n root: 'span',\n input: 'input',\n incrementButton: 'button',\n decrementButton: 'button',\n },\n root: slot.always(root, {\n defaultProps: nativeProps.root,\n elementType: 'span',\n }),\n input: slot.always(input, {\n defaultProps: {\n ref,\n autoComplete: 'off',\n role: 'spinbutton',\n appearance,\n type: 'text',\n ...nativeProps.primary,\n },\n elementType: 'input',\n }),\n incrementButton: slot.always(incrementButton, {\n defaultProps: {\n tabIndex: -1,\n children: <ChevronUp16Regular />,\n disabled: nativeProps.primary.disabled,\n 'aria-label': 'Increment value',\n type: 'button',\n },\n elementType: 'button',\n }),\n decrementButton: slot.always(decrementButton, {\n defaultProps: {\n tabIndex: -1,\n children: <ChevronDown16Regular />,\n disabled: nativeProps.primary.disabled,\n 'aria-label': 'Decrement value',\n type: 'button',\n },\n elementType: 'button',\n }),\n };\n\n state.input.value = valueToDisplay;\n state.input['aria-valuemin'] = min;\n state.input['aria-valuemax'] = max;\n state.input['aria-valuenow'] = currentValue ?? undefined;\n state.input['aria-valuetext'] = state.input['aria-valuetext'] ?? ((value !== undefined && displayValue) || undefined);\n state.input.onChange = mergeCallbacks(state.input.onChange, handleInputChange);\n state.input.onBlur = mergeCallbacks(state.input.onBlur, handleBlur);\n state.input.onKeyDown = mergeCallbacks(state.input.onKeyDown, handleKeyDown);\n state.input.onKeyUp = mergeCallbacks(state.input.onKeyUp, handleKeyUp);\n\n state.incrementButton.onMouseDown = mergeCallbacks(handleIncrementMouseDown, state.incrementButton.onMouseDown);\n state.incrementButton.onMouseUp = mergeCallbacks(state.incrementButton.onMouseUp, handleStepMouseUpOrLeave);\n state.incrementButton.onMouseLeave = mergeCallbacks(state.incrementButton.onMouseLeave, handleStepMouseUpOrLeave);\n\n state.decrementButton.onMouseDown = mergeCallbacks(handleDecrementMouseDown, state.decrementButton.onMouseDown);\n state.decrementButton.onMouseUp = mergeCallbacks(state.decrementButton.onMouseUp, handleStepMouseUpOrLeave);\n state.decrementButton.onMouseLeave = mergeCallbacks(state.decrementButton.onMouseLeave, handleStepMouseUpOrLeave);\n\n return state;\n};\n"],"names":["React","useFieldControlProps_unstable","getPartitionedNativeProps","mergeCallbacks","useControllableState","useTimeout","slot","ArrowUp","ArrowDown","End","Enter","Escape","Home","PageDown","PageUp","calculatePrecision","precisionRound","getBound","clamp","ChevronUp16Regular","ChevronDown16Regular","useOverrides_unstable","useOverrides","DEFAULT_SPIN_DELAY_MS","MIN_SPIN_DELAY_MS","MAX_SPIN_TIME_MS","lerp","start","end","percent","useSpinButton_unstable","props","ref","supportsLabelFor","supportsRequired","nativeProps","primarySlotTagName","excludedPropNames","overrides","value","displayValue","defaultValue","min","max","step","stepPage","precision","precisionFromProps","onChange","size","appearance","inputDefaultAppearance","root","input","incrementButton","decrementButton","useMemo","Math","currentValue","setCurrentValue","state","defaultState","initialState","isControlled","undefined","textValue","setTextValue","useState","keyboardSpinState","setKeyboardSpinState","internalState","useRef","spinState","spinTime","spinDelay","atBound","setStepTimeout","clearStepTimeout","stepValue","e","direction","startFrom","startValue","current","num","parseFloat","isNaN","val","dir","stepSize","stepStart","nullStep","commit","newValue","Number","handleInputChange","previousTextValue","String","target","handleIncrementMouseDown","handleDecrementMouseDown","handleStepMouseUpOrLeave","handleBlur","handleKeyDown","nextKeyboardSpinState","key","preventDefault","shiftKey","handleKeyUp","newDisplayValue","valueChanged","displayValueChanged","roundedValue","nextValue","valueToDisplay","components","always","defaultProps","elementType","autoComplete","role","type","primary","tabIndex","children","disabled","onBlur","onKeyDown","onKeyUp","onMouseDown","onMouseUp","onMouseLeave"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,6BAA6B,QAAQ,wBAAwB;AACtE,SACEC,yBAAyB,EACzBC,cAAc,EACdC,oBAAoB,EACpBC,UAAU,EACVC,IAAI,QACC,4BAA4B;AACnC,SAASC,OAAO,EAAEC,SAAS,EAAEC,GAAG,EAAEC,KAAK,EAAEC,MAAM,EAAEC,IAAI,EAAEC,QAAQ,EAAEC,MAAM,QAAQ,0BAA0B;AAQzG,SAASC,kBAAkB,EAAEC,cAAc,EAAEC,QAAQ,EAAEC,KAAK,QAAQ,oBAAoB;AACxF,SAASC,kBAAkB,EAAEC,oBAAoB,QAAQ,wBAAwB;AACjF,SAASC,yBAAyBC,YAAY,QAAQ,kCAAkC;AAWxF,MAAMC,wBAAwB;AAC9B,MAAMC,oBAAoB;AAC1B,MAAMC,mBAAmB;AAEzB,6DAA6D;AAC7D,yDAAyD;AACzD,gEAAgE;AAChE,MAAMC,OAAO,CAACC,OAAeC,KAAaC,UAA4BF,QAAQ,AAACC,CAAAA,MAAMD,KAAI,IAAKE;AAE9F;;;;;;;;CAQC,GACD,OAAO,MAAMC,yBAAyB,CAACC,OAAwBC;IAC7D,+CAA+C;IAC/CD,QAAQ9B,8BAA8B8B,OAAO;QAAEE,kBAAkB;QAAMC,kBAAkB;IAAK;IAE9F,MAAMC,cAAcjC,0BAA0B;QAC5C6B;QACAK,oBAAoB;QACpBC,mBAAmB;YAAC;YAAgB;YAAO;YAAO;YAAY;YAAQ;SAAQ;IAChF;IAEA,MAAMC,YAAYhB;QAaHgB;IAXf,MAAM,EACJC,KAAK,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AAMP,KAAK,CAACL,QAAQ,EAAE+C;IAC5DnC,MAAMP,KAAK,CAACyE,MAAM,GAAG3H,eAAeyD,MAAMP,KAAK,CAACyE,MAAM,EAAExB;IACxD1C,MAAMP,KAAK,CAAC0E,SAAS,GAAG5H,eAAeyD,MAAMP,KAAK,CAAC0E,SAAS,EAAExB;IAC9D3C,MAAMP,KAAK,CAAC2E,OAAO,GAAG7H,eAAeyD,MAAMP,KAAK,CAAC2E,OAAO,EAAEpB;IAE1DhD,MAAMN,eAAe,CAAC2E,WAAW,GAAG9H,eAAegG,0BAA0BvC,MAAMN,eAAe,CAAC2E,WAAW;IAC9GrE,MAAMN,eAAe,CAAC4E,SAAS,GAAG/H,eAAeyD,MAAMN,eAAe,CAAC4E,SAAS,EAAE7B;IAClFzC,MAAMN,eAAe,CAAC6E,YAAY,GAAGhI,eAAeyD,MAAMN,eAAe,CAAC6E,YAAY,EAAE9B;IAExFzC,MAAML,eAAe,CAAC0E,WAAW,GAAG9H,eAAeiG,0BAA0BxC,MAAML,eAAe,CAAC0E,WAAW;IAC9GrE,MAAML,eAAe,CAAC2E,SAAS,GAAG/H,eAAeyD,MAAML,eAAe,CAAC2E,SAAS,EAAE7B;IAClFzC,MAAML,eAAe,CAAC4E,YAAY,GAAGhI,eAAeyD,MAAML,eAAe,CAAC4E,YAAY,EAAE9B;IAExF,OAAOzC;AACT,EAAE"}
|
@@ -184,6 +184,23 @@ const useSpinButton_unstable = (props, ref)=>{
|
|
184
184
|
}
|
185
185
|
setTextValue(undefined);
|
186
186
|
};
|
187
|
+
let valueToDisplay;
|
188
|
+
if (textValue !== undefined) {
|
189
|
+
valueToDisplay = textValue;
|
190
|
+
} else if (value === null || currentValue === null) {
|
191
|
+
valueToDisplay = displayValue !== null && displayValue !== void 0 ? displayValue : '';
|
192
|
+
internalState.current.value = null;
|
193
|
+
internalState.current.atBound = 'none';
|
194
|
+
} else {
|
195
|
+
const roundedValue = (0, _index.precisionRound)(currentValue, precision);
|
196
|
+
internalState.current.value = roundedValue;
|
197
|
+
internalState.current.atBound = (0, _index.getBound)(roundedValue, min, max);
|
198
|
+
if (isControlled) {
|
199
|
+
valueToDisplay = displayValue !== null && displayValue !== void 0 ? displayValue : String(roundedValue);
|
200
|
+
} else {
|
201
|
+
valueToDisplay = String(roundedValue);
|
202
|
+
}
|
203
|
+
}
|
187
204
|
const state = {
|
188
205
|
size,
|
189
206
|
appearance,
|
@@ -231,23 +248,6 @@ const useSpinButton_unstable = (props, ref)=>{
|
|
231
248
|
elementType: 'button'
|
232
249
|
})
|
233
250
|
};
|
234
|
-
let valueToDisplay;
|
235
|
-
if (textValue !== undefined) {
|
236
|
-
valueToDisplay = textValue;
|
237
|
-
} else if (value === null || currentValue === null) {
|
238
|
-
valueToDisplay = displayValue !== null && displayValue !== void 0 ? displayValue : '';
|
239
|
-
internalState.current.value = null;
|
240
|
-
internalState.current.atBound = 'none';
|
241
|
-
} else {
|
242
|
-
const roundedValue = (0, _index.precisionRound)(currentValue, precision);
|
243
|
-
internalState.current.value = roundedValue;
|
244
|
-
internalState.current.atBound = (0, _index.getBound)(roundedValue, min, max);
|
245
|
-
if (isControlled) {
|
246
|
-
valueToDisplay = displayValue !== null && displayValue !== void 0 ? displayValue : String(roundedValue);
|
247
|
-
} else {
|
248
|
-
valueToDisplay = String(roundedValue);
|
249
|
-
}
|
250
|
-
}
|
251
251
|
state.input.value = valueToDisplay;
|
252
252
|
state.input['aria-valuemin'] = min;
|
253
253
|
state.input['aria-valuemax'] = max;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["useSpinButton.js"],"sourcesContent":["import * as React from 'react';\nimport { useFieldControlProps_unstable } from '@fluentui/react-field';\nimport { getPartitionedNativeProps, mergeCallbacks, useControllableState, useTimeout, slot } from '@fluentui/react-utilities';\nimport { ArrowUp, ArrowDown, End, Enter, Escape, Home, PageDown, PageUp } from '@fluentui/keyboard-keys';\nimport { calculatePrecision, precisionRound, getBound, clamp } from '../../utils/index';\nimport { ChevronUp16Regular, ChevronDown16Regular } from '@fluentui/react-icons';\nimport { useOverrides_unstable as useOverrides } from '@fluentui/react-shared-contexts';\nconst DEFAULT_SPIN_DELAY_MS = 150;\nconst MIN_SPIN_DELAY_MS = 80;\nconst MAX_SPIN_TIME_MS = 1000;\n// This is here to give an ease for the mouse held down case.\n// Exact easing it to be defined. Once it is we'll likely\n// pull this out into a util function in the SpinButton package.\nconst lerp = (start, end, percent)=>start + (end - start) * percent;\n/**\n * Create the state required to render SpinButton.\n *\n * The returned state can be modified with hooks such as useSpinButtonStyles_unstable,\n * before being passed to renderSpinButton_unstable.\n *\n * @param props - props from this instance of SpinButton\n * @param ref - reference to root HTMLElement of SpinButton\n */ export const useSpinButton_unstable = (props, ref)=>{\n // Merge props from surrounding <Field>, if any\n props = useFieldControlProps_unstable(props, {\n supportsLabelFor: true,\n supportsRequired: true\n });\n const nativeProps = getPartitionedNativeProps({\n props,\n primarySlotTagName: 'input',\n excludedPropNames: [\n 'defaultValue',\n 'max',\n 'min',\n 'onChange',\n 'size',\n 'value'\n ]\n });\n const overrides = useOverrides();\n var _overrides_inputDefaultAppearance;\n const { value, displayValue, defaultValue, min, max, step = 1, stepPage = 1, precision: precisionFromProps, onChange, size = 'medium', appearance = (_overrides_inputDefaultAppearance = overrides.inputDefaultAppearance) !== null && _overrides_inputDefaultAppearance !== void 0 ? _overrides_inputDefaultAppearance : 'outline', root, input, incrementButton, decrementButton } = props;\n const precision = React.useMemo(()=>{\n return precisionFromProps !== null && precisionFromProps !== void 0 ? precisionFromProps : Math.max(calculatePrecision(step), 0);\n }, [\n precisionFromProps,\n step\n ]);\n const [currentValue, setCurrentValue] = useControllableState({\n state: value,\n defaultState: defaultValue,\n initialState: 0\n });\n const isControlled = value !== undefined;\n const [textValue, setTextValue] = React.useState(undefined);\n const [keyboardSpinState, setKeyboardSpinState] = React.useState('rest');\n const internalState = React.useRef({\n value: currentValue,\n spinState: 'rest',\n spinTime: 0,\n spinDelay: DEFAULT_SPIN_DELAY_MS,\n atBound: currentValue !== null ? getBound(precisionRound(currentValue, precision), min, max) : 'none'\n });\n const [setStepTimeout, clearStepTimeout] = useTimeout();\n const stepValue = (e, direction, startFrom)=>{\n let startValue = internalState.current.value;\n if (startFrom) {\n const num = parseFloat(startFrom);\n if (!isNaN(num)) {\n startValue = num;\n }\n }\n const val = startValue;\n const dir = direction === 'up' || direction === 'upPage' ? 1 : -1;\n const stepSize = direction === 'upPage' || direction === 'downPage' ? stepPage : step;\n if (val === null) {\n const stepStart = min === undefined ? 0 : min;\n const nullStep = clamp(stepStart + stepSize * dir, min, max);\n commit(e, nullStep);\n return;\n }\n let newValue = val + stepSize * dir;\n if (!Number.isNaN(newValue)) {\n newValue = clamp(newValue, min, max);\n }\n commit(e, newValue);\n if (internalState.current.spinState !== 'rest') {\n setStepTimeout(()=>{\n // Ease the step speed a bit\n internalState.current.spinTime += internalState.current.spinDelay;\n internalState.current.spinDelay = lerp(DEFAULT_SPIN_DELAY_MS, MIN_SPIN_DELAY_MS, internalState.current.spinTime / MAX_SPIN_TIME_MS);\n stepValue(e, direction);\n }, internalState.current.spinDelay);\n }\n };\n const handleInputChange = (e)=>{\n if (!internalState.current.previousTextValue) {\n internalState.current.previousTextValue = textValue !== null && textValue !== void 0 ? textValue : String(currentValue);\n }\n const newValue = e.target.value;\n setTextValue(newValue);\n };\n const handleIncrementMouseDown = (e)=>{\n internalState.current.spinState = 'up';\n stepValue(e, 'up');\n };\n const handleDecrementMouseDown = (e)=>{\n internalState.current.spinState = 'down';\n stepValue(e, 'down');\n };\n const handleStepMouseUpOrLeave = (e)=>{\n clearStepTimeout();\n internalState.current.spinState = 'rest';\n internalState.current.spinDelay = DEFAULT_SPIN_DELAY_MS;\n internalState.current.spinTime = 0;\n };\n const handleBlur = (e)=>{\n commit(e, currentValue, textValue);\n internalState.current.previousTextValue = undefined;\n };\n const handleKeyDown = (e)=>{\n let nextKeyboardSpinState = 'rest';\n if (e.key === ArrowUp) {\n stepValue(e, 'up', textValue);\n nextKeyboardSpinState = 'up';\n } else if (e.key === ArrowDown) {\n stepValue(e, 'down', textValue);\n nextKeyboardSpinState = 'down';\n } else if (e.key === PageUp) {\n e.preventDefault();\n stepValue(e, 'upPage', textValue);\n nextKeyboardSpinState = 'up';\n } else if (e.key === PageDown) {\n e.preventDefault();\n stepValue(e, 'downPage', textValue);\n nextKeyboardSpinState = 'down';\n } else if (!e.shiftKey && e.key === Home && min !== undefined) {\n commit(e, min);\n nextKeyboardSpinState = 'down';\n } else if (!e.shiftKey && e.key === End && max !== undefined) {\n commit(e, max);\n nextKeyboardSpinState = 'up';\n } else if (e.key === Enter) {\n commit(e, currentValue, textValue);\n internalState.current.previousTextValue = undefined;\n } else if (e.key === Escape) {\n if (internalState.current.previousTextValue) {\n setTextValue(undefined);\n internalState.current.previousTextValue = undefined;\n }\n }\n if (keyboardSpinState !== nextKeyboardSpinState) {\n setKeyboardSpinState(nextKeyboardSpinState);\n }\n };\n const handleKeyUp = (e)=>{\n if (keyboardSpinState !== 'rest') {\n setKeyboardSpinState('rest');\n internalState.current.spinState = 'rest';\n }\n };\n const commit = (e, newValue, newDisplayValue)=>{\n const valueChanged = newValue !== undefined && currentValue !== newValue;\n const displayValueChanged = newDisplayValue !== undefined && internalState.current.previousTextValue !== undefined && internalState.current.previousTextValue !== newDisplayValue;\n let roundedValue;\n if (valueChanged) {\n roundedValue = precisionRound(newValue, precision);\n setCurrentValue(roundedValue);\n } else if (displayValueChanged && !isControlled) {\n const nextValue = parseFloat(newDisplayValue);\n if (!isNaN(nextValue)) {\n setCurrentValue(precisionRound(nextValue, precision));\n }\n }\n if (valueChanged || displayValueChanged) {\n onChange === null || onChange === void 0 ? void 0 : onChange(e, {\n value: roundedValue,\n displayValue: newDisplayValue\n });\n }\n setTextValue(undefined);\n };\n const state = {\n size,\n appearance,\n spinState: keyboardSpinState,\n atBound: internalState.current.atBound,\n components: {\n root: 'span',\n input: 'input',\n incrementButton: 'button',\n decrementButton: 'button'\n },\n root: slot.always(root, {\n defaultProps: nativeProps.root,\n elementType: 'span'\n }),\n input: slot.always(input, {\n defaultProps: {\n ref,\n autoComplete: 'off',\n role: 'spinbutton',\n appearance,\n type: 'text',\n ...nativeProps.primary\n },\n elementType: 'input'\n }),\n incrementButton: slot.always(incrementButton, {\n defaultProps: {\n tabIndex: -1,\n children: /*#__PURE__*/ React.createElement(ChevronUp16Regular, null),\n disabled: nativeProps.primary.disabled,\n 'aria-label': 'Increment value',\n type: 'button'\n },\n elementType: 'button'\n }),\n decrementButton: slot.always(decrementButton, {\n defaultProps: {\n tabIndex: -1,\n children: /*#__PURE__*/ React.createElement(ChevronDown16Regular, null),\n disabled: nativeProps.primary.disabled,\n 'aria-label': 'Decrement value',\n type: 'button'\n },\n elementType: 'button'\n })\n };\n let valueToDisplay;\n if (textValue !== undefined) {\n valueToDisplay = textValue;\n } else if (value === null || currentValue === null) {\n valueToDisplay = displayValue !== null && displayValue !== void 0 ? displayValue : '';\n internalState.current.value = null;\n internalState.current.atBound = 'none';\n } else {\n const roundedValue = precisionRound(currentValue, precision);\n internalState.current.value = roundedValue;\n internalState.current.atBound = getBound(roundedValue, min, max);\n if (isControlled) {\n valueToDisplay = displayValue !== null && displayValue !== void 0 ? displayValue : String(roundedValue);\n } else {\n valueToDisplay = String(roundedValue);\n }\n }\n state.input.value = valueToDisplay;\n state.input['aria-valuemin'] = min;\n state.input['aria-valuemax'] = max;\n state.input['aria-valuenow'] = currentValue !== null && currentValue !== void 0 ? currentValue : undefined;\n var _state_input_ariavaluetext;\n state.input['aria-valuetext'] = (_state_input_ariavaluetext = state.input['aria-valuetext']) !== null && _state_input_ariavaluetext !== void 0 ? _state_input_ariavaluetext : value !== undefined && displayValue || undefined;\n state.input.onChange = mergeCallbacks(state.input.onChange, handleInputChange);\n state.input.onBlur = mergeCallbacks(state.input.onBlur, handleBlur);\n state.input.onKeyDown = mergeCallbacks(state.input.onKeyDown, handleKeyDown);\n state.input.onKeyUp = mergeCallbacks(state.input.onKeyUp, handleKeyUp);\n state.incrementButton.onMouseDown = mergeCallbacks(handleIncrementMouseDown, state.incrementButton.onMouseDown);\n state.incrementButton.onMouseUp = mergeCallbacks(state.incrementButton.onMouseUp, handleStepMouseUpOrLeave);\n state.incrementButton.onMouseLeave = mergeCallbacks(state.incrementButton.onMouseLeave, handleStepMouseUpOrLeave);\n state.decrementButton.onMouseDown = mergeCallbacks(handleDecrementMouseDown, state.decrementButton.onMouseDown);\n state.decrementButton.onMouseUp = mergeCallbacks(state.decrementButton.onMouseUp, handleStepMouseUpOrLeave);\n state.decrementButton.onMouseLeave = mergeCallbacks(state.decrementButton.onMouseLeave, handleStepMouseUpOrLeave);\n return state;\n};\n"],"names":["useSpinButton_unstable","DEFAULT_SPIN_DELAY_MS","MIN_SPIN_DELAY_MS","MAX_SPIN_TIME_MS","lerp","start","end","percent","props","ref","useFieldControlProps_unstable","supportsLabelFor","supportsRequired","nativeProps","getPartitionedNativeProps","primarySlotTagName","excludedPropNames","overrides","useOverrides","_overrides_inputDefaultAppearance","value","displayValue","defaultValue","min","max","step","stepPage","precision","precisionFromProps","onChange","size","appearance","inputDefaultAppearance","root","input","incrementButton","decrementButton","React","useMemo","Math","calculatePrecision","currentValue","setCurrentValue","useControllableState","state","defaultState","initialState","isControlled","undefined","textValue","setTextValue","useState","keyboardSpinState","setKeyboardSpinState","internalState","useRef","spinState","spinTime","spinDelay","atBound","getBound","precisionRound","setStepTimeout","clearStepTimeout","useTimeout","stepValue","e","direction","startFrom","startValue","current","num","parseFloat","isNaN","val","dir","stepSize","stepStart","nullStep","clamp","commit","newValue","Number","handleInputChange","previousTextValue","String","target","handleIncrementMouseDown","handleDecrementMouseDown","handleStepMouseUpOrLeave","handleBlur","handleKeyDown","nextKeyboardSpinState","key","ArrowUp","ArrowDown","PageUp","preventDefault","PageDown","shiftKey","Home","End","Enter","Escape","handleKeyUp","newDisplayValue","valueChanged","displayValueChanged","roundedValue","nextValue","components","slot","always","defaultProps","elementType","autoComplete","role","type","primary","tabIndex","children","createElement","ChevronUp16Regular","disabled","ChevronDown16Regular","valueToDisplay","_state_input_ariavaluetext","mergeCallbacks","onBlur","onKeyDown","onKeyUp","onMouseDown","onMouseUp","onMouseLeave"],"mappings":";;;;+BAsBiBA;;;eAAAA;;;;iEAtBM;4BACuB;gCACoD;8BACnB;uBACX;4BACX;qCACH;AACtD,MAAMC,wBAAwB;AAC9B,MAAMC,oBAAoB;AAC1B,MAAMC,mBAAmB;AACzB,6DAA6D;AAC7D,yDAAyD;AACzD,gEAAgE;AAChE,MAAMC,OAAO,CAACC,OAAOC,KAAKC,UAAUF,QAAQ,AAACC,CAAAA,MAAMD,KAAI,IAAKE;AASjD,MAAMP,yBAAyB,CAACQ,OAAOC;IAC9C,+CAA+C;IAC/CD,QAAQE,IAAAA,yCAA6B,EAACF,OAAO;QACzCG,kBAAkB;QAClBC,kBAAkB;IACtB;IACA,MAAMC,cAAcC,IAAAA,yCAAyB,EAAC;QAC1CN;QACAO,oBAAoB;QACpBC,mBAAmB;YACf;YACA;YACA;YACA;YACA;YACA;SACH;IACL;IACA,MAAMC,YAAYC,IAAAA,0CAAY;IAC9B,IAAIC;IACJ,MAAM,EAAEC,KAAK,EAAEC,YAAY,EAAEC,YAAY,EAAEC,GAAG,EAAEC,GAAG,EAAEC,OAAO,CAAC,EAAEC,WAAW,CAAC,EAAEC,WAAWC,kBAAkB,EAAEC,QAAQ,EAAEC,OAAO,QAAQ,EAAEC,aAAa,AAACZ,CAAAA,oCAAoCF,UAAUe,sBAAsB,AAAD,MAAO,QAAQb,sCAAsC,KAAK,IAAIA,oCAAoC,SAAS,EAAEc,IAAI,EAAEC,KAAK,EAAEC,eAAe,EAAEC,eAAe,EAAE,GAAG5B;IACvX,MAAMmB,YAAYU,OAAMC,OAAO,CAAC;QAC5B,OAAOV,uBAAuB,QAAQA,uBAAuB,KAAK,IAAIA,qBAAqBW,KAAKf,GAAG,CAACgB,IAAAA,yBAAkB,EAACf,OAAO;IAClI,GAAG;QAC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AMV,KAAK,CAACL,QAAQ,GAAGkG,IAAAA,8BAAc,EAACnF,MAAMV,KAAK,CAACL,QAAQ,EAAEsD;IAC5DvC,MAAMV,KAAK,CAAC8F,MAAM,GAAGD,IAAAA,8BAAc,EAACnF,MAAMV,KAAK,CAAC8F,MAAM,EAAEtC;IACxD9C,MAAMV,KAAK,CAAC+F,SAAS,GAAGF,IAAAA,8BAAc,EAACnF,MAAMV,KAAK,CAAC+F,SAAS,EAAEtC;IAC9D/C,MAAMV,KAAK,CAACgG,OAAO,GAAGH,IAAAA,8BAAc,EAACnF,MAAMV,KAAK,CAACgG,OAAO,EAAE1B;IAC1D5D,MAAMT,eAAe,CAACgG,WAAW,GAAGJ,IAAAA,8BAAc,EAACxC,0BAA0B3C,MAAMT,eAAe,CAACgG,WAAW;IAC9GvF,MAAMT,eAAe,CAACiG,SAAS,GAAGL,IAAAA,8BAAc,EAACnF,MAAMT,eAAe,CAACiG,SAAS,EAAE3C;IAClF7C,MAAMT,eAAe,CAACkG,YAAY,GAAGN,IAAAA,8BAAc,EAACnF,MAAMT,eAAe,CAACkG,YAAY,EAAE5C;IACxF7C,MAAMR,eAAe,CAAC+F,WAAW,GAAGJ,IAAAA,8BAAc,EAACvC,0BAA0B5C,MAAMR,eAAe,CAAC+F,WAAW;IAC9GvF,MAAMR,eAAe,CAACgG,SAAS,GAAGL,IAAAA,8BAAc,EAACnF,MAAMR,eAAe,CAACgG,SAAS,EAAE3C;IAClF7C,MAAMR,eAAe,CAACiG,YAAY,GAAGN,IAAAA,8BAAc,EAACnF,MAAMR,eAAe,CAACiG,YAAY,EAAE5C;IACxF,OAAO7C;AACX"}
|
1
|
+
{"version":3,"sources":["useSpinButton.js"],"sourcesContent":["import * as React from 'react';\nimport { useFieldControlProps_unstable } from '@fluentui/react-field';\nimport { getPartitionedNativeProps, mergeCallbacks, useControllableState, useTimeout, slot } from '@fluentui/react-utilities';\nimport { ArrowUp, ArrowDown, End, Enter, Escape, Home, PageDown, PageUp } from '@fluentui/keyboard-keys';\nimport { calculatePrecision, precisionRound, getBound, clamp } from '../../utils/index';\nimport { ChevronUp16Regular, ChevronDown16Regular } from '@fluentui/react-icons';\nimport { useOverrides_unstable as useOverrides } from '@fluentui/react-shared-contexts';\nconst DEFAULT_SPIN_DELAY_MS = 150;\nconst MIN_SPIN_DELAY_MS = 80;\nconst MAX_SPIN_TIME_MS = 1000;\n// This is here to give an ease for the mouse held down case.\n// Exact easing it to be defined. Once it is we'll likely\n// pull this out into a util function in the SpinButton package.\nconst lerp = (start, end, percent)=>start + (end - start) * percent;\n/**\n * Create the state required to render SpinButton.\n *\n * The returned state can be modified with hooks such as useSpinButtonStyles_unstable,\n * before being passed to renderSpinButton_unstable.\n *\n * @param props - props from this instance of SpinButton\n * @param ref - reference to root HTMLElement of SpinButton\n */ export const useSpinButton_unstable = (props, ref)=>{\n // Merge props from surrounding <Field>, if any\n props = useFieldControlProps_unstable(props, {\n supportsLabelFor: true,\n supportsRequired: true\n });\n const nativeProps = getPartitionedNativeProps({\n props,\n primarySlotTagName: 'input',\n excludedPropNames: [\n 'defaultValue',\n 'max',\n 'min',\n 'onChange',\n 'size',\n 'value'\n ]\n });\n const overrides = useOverrides();\n var _overrides_inputDefaultAppearance;\n const { value, displayValue, defaultValue, min, max, step = 1, stepPage = 1, precision: precisionFromProps, onChange, size = 'medium', appearance = (_overrides_inputDefaultAppearance = overrides.inputDefaultAppearance) !== null && _overrides_inputDefaultAppearance !== void 0 ? _overrides_inputDefaultAppearance : 'outline', root, input, incrementButton, decrementButton } = props;\n const precision = React.useMemo(()=>{\n return precisionFromProps !== null && precisionFromProps !== void 0 ? precisionFromProps : Math.max(calculatePrecision(step), 0);\n }, [\n precisionFromProps,\n step\n ]);\n const [currentValue, setCurrentValue] = useControllableState({\n state: value,\n defaultState: defaultValue,\n initialState: 0\n });\n const isControlled = value !== undefined;\n const [textValue, setTextValue] = React.useState(undefined);\n const [keyboardSpinState, setKeyboardSpinState] = React.useState('rest');\n const internalState = React.useRef({\n value: currentValue,\n spinState: 'rest',\n spinTime: 0,\n spinDelay: DEFAULT_SPIN_DELAY_MS,\n atBound: currentValue !== null ? getBound(precisionRound(currentValue, precision), min, max) : 'none'\n });\n const [setStepTimeout, clearStepTimeout] = useTimeout();\n const stepValue = (e, direction, startFrom)=>{\n let startValue = internalState.current.value;\n if (startFrom) {\n const num = parseFloat(startFrom);\n if (!isNaN(num)) {\n startValue = num;\n }\n }\n const val = startValue;\n const dir = direction === 'up' || direction === 'upPage' ? 1 : -1;\n const stepSize = direction === 'upPage' || direction === 'downPage' ? stepPage : step;\n if (val === null) {\n const stepStart = min === undefined ? 0 : min;\n const nullStep = clamp(stepStart + stepSize * dir, min, max);\n commit(e, nullStep);\n return;\n }\n let newValue = val + stepSize * dir;\n if (!Number.isNaN(newValue)) {\n newValue = clamp(newValue, min, max);\n }\n commit(e, newValue);\n if (internalState.current.spinState !== 'rest') {\n setStepTimeout(()=>{\n // Ease the step speed a bit\n internalState.current.spinTime += internalState.current.spinDelay;\n internalState.current.spinDelay = lerp(DEFAULT_SPIN_DELAY_MS, MIN_SPIN_DELAY_MS, internalState.current.spinTime / MAX_SPIN_TIME_MS);\n stepValue(e, direction);\n }, internalState.current.spinDelay);\n }\n };\n const handleInputChange = (e)=>{\n if (!internalState.current.previousTextValue) {\n internalState.current.previousTextValue = textValue !== null && textValue !== void 0 ? textValue : String(currentValue);\n }\n const newValue = e.target.value;\n setTextValue(newValue);\n };\n const handleIncrementMouseDown = (e)=>{\n internalState.current.spinState = 'up';\n stepValue(e, 'up');\n };\n const handleDecrementMouseDown = (e)=>{\n internalState.current.spinState = 'down';\n stepValue(e, 'down');\n };\n const handleStepMouseUpOrLeave = (e)=>{\n clearStepTimeout();\n internalState.current.spinState = 'rest';\n internalState.current.spinDelay = DEFAULT_SPIN_DELAY_MS;\n internalState.current.spinTime = 0;\n };\n const handleBlur = (e)=>{\n commit(e, currentValue, textValue);\n internalState.current.previousTextValue = undefined;\n };\n const handleKeyDown = (e)=>{\n let nextKeyboardSpinState = 'rest';\n if (e.key === ArrowUp) {\n stepValue(e, 'up', textValue);\n nextKeyboardSpinState = 'up';\n } else if (e.key === ArrowDown) {\n stepValue(e, 'down', textValue);\n nextKeyboardSpinState = 'down';\n } else if (e.key === PageUp) {\n e.preventDefault();\n stepValue(e, 'upPage', textValue);\n nextKeyboardSpinState = 'up';\n } else if (e.key === PageDown) {\n e.preventDefault();\n stepValue(e, 'downPage', textValue);\n nextKeyboardSpinState = 'down';\n } else if (!e.shiftKey && e.key === Home && min !== undefined) {\n commit(e, min);\n nextKeyboardSpinState = 'down';\n } else if (!e.shiftKey && e.key === End && max !== undefined) {\n commit(e, max);\n nextKeyboardSpinState = 'up';\n } else if (e.key === Enter) {\n commit(e, currentValue, textValue);\n internalState.current.previousTextValue = undefined;\n } else if (e.key === Escape) {\n if (internalState.current.previousTextValue) {\n setTextValue(undefined);\n internalState.current.previousTextValue = undefined;\n }\n }\n if (keyboardSpinState !== nextKeyboardSpinState) {\n setKeyboardSpinState(nextKeyboardSpinState);\n }\n };\n const handleKeyUp = (e)=>{\n if (keyboardSpinState !== 'rest') {\n setKeyboardSpinState('rest');\n internalState.current.spinState = 'rest';\n }\n };\n const commit = (e, newValue, newDisplayValue)=>{\n const valueChanged = newValue !== undefined && currentValue !== newValue;\n const displayValueChanged = newDisplayValue !== undefined && internalState.current.previousTextValue !== undefined && internalState.current.previousTextValue !== newDisplayValue;\n let roundedValue;\n if (valueChanged) {\n roundedValue = precisionRound(newValue, precision);\n setCurrentValue(roundedValue);\n } else if (displayValueChanged && !isControlled) {\n const nextValue = parseFloat(newDisplayValue);\n if (!isNaN(nextValue)) {\n setCurrentValue(precisionRound(nextValue, precision));\n }\n }\n if (valueChanged || displayValueChanged) {\n onChange === null || onChange === void 0 ? void 0 : onChange(e, {\n value: roundedValue,\n displayValue: newDisplayValue\n });\n }\n setTextValue(undefined);\n };\n let valueToDisplay;\n if (textValue !== undefined) {\n valueToDisplay = textValue;\n } else if (value === null || currentValue === null) {\n valueToDisplay = displayValue !== null && displayValue !== void 0 ? displayValue : '';\n internalState.current.value = null;\n internalState.current.atBound = 'none';\n } else {\n const roundedValue = precisionRound(currentValue, precision);\n internalState.current.value = roundedValue;\n internalState.current.atBound = getBound(roundedValue, min, max);\n if (isControlled) {\n valueToDisplay = displayValue !== null && displayValue !== void 0 ? displayValue : String(roundedValue);\n } else {\n valueToDisplay = String(roundedValue);\n }\n }\n const state = {\n size,\n appearance,\n spinState: keyboardSpinState,\n atBound: internalState.current.atBound,\n components: {\n root: 'span',\n input: 'input',\n incrementButton: 'button',\n decrementButton: 'button'\n },\n root: slot.always(root, {\n defaultProps: nativeProps.root,\n elementType: 'span'\n }),\n input: slot.always(input, {\n defaultProps: {\n ref,\n autoComplete: 'off',\n role: 'spinbutton',\n appearance,\n type: 'text',\n ...nativeProps.primary\n },\n elementType: 'input'\n }),\n incrementButton: slot.always(incrementButton, {\n defaultProps: {\n tabIndex: -1,\n children: /*#__PURE__*/ React.createElement(ChevronUp16Regular, null),\n disabled: nativeProps.primary.disabled,\n 'aria-label': 'Increment value',\n type: 'button'\n },\n elementType: 'button'\n }),\n decrementButton: slot.always(decrementButton, {\n defaultProps: {\n tabIndex: -1,\n children: /*#__PURE__*/ React.createElement(ChevronDown16Regular, null),\n disabled: nativeProps.primary.disabled,\n 'aria-label': 'Decrement value',\n type: 'button'\n },\n elementType: 'button'\n })\n };\n state.input.value = valueToDisplay;\n state.input['aria-valuemin'] = min;\n state.input['aria-valuemax'] = max;\n state.input['aria-valuenow'] = currentValue !== null && currentValue !== void 0 ? currentValue : undefined;\n var _state_input_ariavaluetext;\n state.input['aria-valuetext'] = (_state_input_ariavaluetext = state.input['aria-valuetext']) !== null && _state_input_ariavaluetext !== void 0 ? _state_input_ariavaluetext : value !== undefined && displayValue || undefined;\n state.input.onChange = mergeCallbacks(state.input.onChange, handleInputChange);\n state.input.onBlur = mergeCallbacks(state.input.onBlur, handleBlur);\n state.input.onKeyDown = mergeCallbacks(state.input.onKeyDown, handleKeyDown);\n state.input.onKeyUp = mergeCallbacks(state.input.onKeyUp, handleKeyUp);\n state.incrementButton.onMouseDown = mergeCallbacks(handleIncrementMouseDown, state.incrementButton.onMouseDown);\n state.incrementButton.onMouseUp = mergeCallbacks(state.incrementButton.onMouseUp, handleStepMouseUpOrLeave);\n state.incrementButton.onMouseLeave = mergeCallbacks(state.incrementButton.onMouseLeave, handleStepMouseUpOrLeave);\n state.decrementButton.onMouseDown = mergeCallbacks(handleDecrementMouseDown, state.decrementButton.onMouseDown);\n state.decrementButton.onMouseUp = mergeCallbacks(state.decrementButton.onMouseUp, handleStepMouseUpOrLeave);\n state.decrementButton.onMouseLeave = mergeCallbacks(state.decrementButton.onMouseLeave, handleStepMouseUpOrLeave);\n return state;\n};\n"],"names":["useSpinButton_unstable","DEFAULT_SPIN_DELAY_MS","MIN_SPIN_DELAY_MS","MAX_SPIN_TIME_MS","lerp","start","end","percent","props","ref","useFieldControlProps_unstable","supportsLabelFor","supportsRequired","nativeProps","getPartitionedNativeProps","primarySlotTagName","excludedPropNames","overrides","useOverrides","_overrides_inputDefaultAppearance","value","displayValue","defaultValue","min","max","step","stepPage","precision","precisionFromProps","onChange","size","appearance","inputDefaultAppearance","root","input","incrementButton","decrementButton","React","useMemo","Math","calculatePrecision","currentValue","setCurrentValue","useControllableState","state","defaultState","initialState","isControlled","undefined","textValue","setTextValue","useState","keyboardSpinState","setKeyboardSpinState","internalState","useRef","spinState","spinTime","spinDelay","atBound","getBound","precisionRound","setStepTimeout","clearStepTimeout","useTimeout","stepValue","e","direction","startFrom","startValue","current","num","parseFloat","isNaN","val","dir","stepSize","stepStart","nullStep","clamp","commit","newValue","Number","handleInputChange","previousTextValue","String","target","handleIncrementMouseDown","handleDecrementMouseDown","handleStepMouseUpOrLeave","handleBlur","handleKeyDown","nextKeyboardSpinState","key","ArrowUp","ArrowDown","PageUp","preventDefault","PageDown","shiftKey","Home","End","Enter","Escape","handleKeyUp","newDisplayValue","valueChanged","displayValueChanged","roundedValue","nextValue","valueToDisplay","components","slot","always","defaultProps","elementType","autoComplete","role","type","primary","tabIndex","children","createElement","ChevronUp16Regular","disabled","ChevronDown16Regular","_state_input_ariavaluetext","mergeCallbacks","onBlur","onKeyDown","onKeyUp","onMouseDown","onMouseUp","onMouseLeave"],"mappings":";;;;+BAsBiBA;;;eAAAA;;;;iEAtBM;4BACuB;gCACoD;8BACnB;uBACX;4BACX;qCACH;AACtD,MAAMC,wBAAwB;AAC9B,MAAMC,oBAAoB;AAC1B,MAAMC,mBAAmB;AACzB,6DAA6D;AAC7D,yDAAyD;AACzD,gEAAgE;AAChE,MAAMC,OAAO,CAACC,OAAOC,KAAKC,UAAUF,QAAQ,AAACC,CAAAA,MAAMD,KAAI,IAAKE;AASjD,MAAMP,yBAAyB,CAACQ,OAAOC;IAC9C,+CAA+C;IAC/CD,QAAQE,IAAAA,yCAA6B,EAACF,OAAO;QACzCG,kBAAkB;QAClBC,kBAAkB;IACtB;IACA,MAAMC,cAAcC,IAAAA,yCAAyB,EAAC;QAC1CN;QACAO,oBAAoB;QACpBC,mBAAmB;YACf;YACA;YACA;YACA;YACA;YACA;SACH;IACL;IACA,MAAMC,YAAYC,IAAAA,0CAAY;IAC9B,IAAIC;IACJ,MAAM,EAAEC,KAAK,EAAEC,YAAY,EAAEC,YAAY,EAAEC,GAAG,EAAEC,GAAG,EAAEC,OAAO,CAAC,EAAEC,WAAW,CAAC,EAAEC,WAAWC,kBAAkB,EAAEC,QAAQ,EAAEC,OAAO,QAAQ,EAAEC,aAAa,AAACZ,CAAAA,oCAAoCF,UAAUe,sBAAsB,AAAD,MAAO,QAAQb,sCAAsC,KAAK,IAAIA,oCAAoC,SAAS,EAAEc,IAAI,EAAEC,KAAK,EAAEC,eAAe,EAAEC,eAAe,EAAE,GAAG5B;IACvX,MAAMmB,YAAYU,OAAMC,OAAO,CAAC;QAC5B,OAAOV,uBAAuB,QAAQA,uBAAuB,KAAK,IAAIA,qBAA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I React SpinButton component.",
|
5
5
|
"main": "lib-commonjs/index.js",
|
6
6
|
"module": "lib/index.js",
|
@@ -35,12 +35,12 @@
|
|
35
35
|
},
|
36
36
|
"dependencies": {
|
37
37
|
"@fluentui/keyboard-keys": "^9.0.7",
|
38
|
-
"@fluentui/react-field": "^9.1.
|
39
|
-
"@fluentui/react-icons": "^2.0.
|
40
|
-
"@fluentui/react-jsx-runtime": "^9.0.
|
41
|
-
"@fluentui/react-shared-contexts": "^9.
|
38
|
+
"@fluentui/react-field": "^9.1.63",
|
39
|
+
"@fluentui/react-icons": "^2.0.237",
|
40
|
+
"@fluentui/react-jsx-runtime": "^9.0.36",
|
41
|
+
"@fluentui/react-shared-contexts": "^9.17.0",
|
42
42
|
"@fluentui/react-theme": "^9.1.19",
|
43
|
-
"@fluentui/react-utilities": "^9.18.
|
43
|
+
"@fluentui/react-utilities": "^9.18.7",
|
44
44
|
"@griffel/react": "^1.5.14",
|
45
45
|
"@swc/helpers": "^0.5.1"
|
46
46
|
},
|