@react-aria/color 3.0.9 → 3.1.1
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/types.d.ts.map +1 -1
- package/dist/useColorArea.main.js +4 -8
- package/dist/useColorArea.main.js.map +1 -1
- package/dist/useColorArea.mjs +4 -8
- package/dist/useColorArea.module.js +4 -8
- package/dist/useColorArea.module.js.map +1 -1
- package/dist/useColorField.main.js +4 -1
- package/dist/useColorField.main.js.map +1 -1
- package/dist/useColorField.mjs +5 -2
- package/dist/useColorField.module.js +5 -2
- package/dist/useColorField.module.js.map +1 -1
- package/dist/useColorSlider.main.js +2 -1
- package/dist/useColorSlider.main.js.map +1 -1
- package/dist/useColorSlider.mjs +2 -1
- package/dist/useColorSlider.module.js +2 -1
- package/dist/useColorSlider.module.js.map +1 -1
- package/dist/useColorWheel.main.js +3 -2
- package/dist/useColorWheel.main.js.map +1 -1
- package/dist/useColorWheel.mjs +3 -2
- package/dist/useColorWheel.module.js +3 -2
- package/dist/useColorWheel.module.js.map +1 -1
- package/package.json +14 -14
- package/src/useColorArea.ts +5 -7
- package/src/useColorField.ts +6 -2
- package/src/useColorSlider.ts +2 -1
- package/src/useColorWheel.ts +4 -2
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;ACwBA;IACE,kDAAkD;IAClD,cAAc,EAAE,aAAa,CAAC;IAC9B,mCAAmC;IACnC,UAAU,EAAE,aAAa,CAAC;IAC1B,oEAAoE;IACpE,WAAW,EAAE,oBAAoB,gBAAgB,CAAC,CAAC;IACnD,kEAAkE;IAClE,WAAW,EAAE,oBAAoB,gBAAgB,CAAC,CAAA;CACnD;AAED,qCAAsC,SAAQ,kBAAkB;IAC9D,uEAAuE;IACvE,SAAS,EAAE,UAAU,gBAAgB,GAAG,IAAI,CAAC,CAAC;IAC9C,uEAAuE;IACvE,SAAS,EAAE,UAAU,gBAAgB,GAAG,IAAI,CAAC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;ACxDD,2CAA4C,SAAQ,sBAAsB,EAAE,iBAAiB;CAAG;AAChG,sCAAuC,SAAQ,eAAe;CAAG;AAEjE;;;GAGG;AACH,qCAAqC,KAAK,EAAE,0BAA0B,EAAE,KAAK,EAAE,sBAAsB,EAAE,QAAQ,EAAE,UAAU,gBAAgB,GAAG,IAAI,CAAC,GAAG,qBAAqB,CAW1K;ACfD,YAAY,EAAC,kBAAkB,EAAE,mBAAmB,EAAE,oBAAoB,EAAC,MAAM,oBAAoB,CAAC","sources":["packages/@react-aria/color/src/packages/@react-aria/color/src/useColorAreaGradient.ts","packages/@react-aria/color/src/packages/@react-aria/color/src/useColorArea.ts","packages/@react-aria/color/src/packages/@react-aria/color/src/useColorSlider.ts","packages/@react-aria/color/src/packages/@react-aria/color/src/useColorWheel.ts","packages/@react-aria/color/src/packages/@react-aria/color/src/useColorField.ts","packages/@react-aria/color/src/packages/@react-aria/color/src/useColorSwatch.ts","packages/@react-aria/color/src/packages/@react-aria/color/src/useColorChannelField.ts","packages/@react-aria/color/src/packages/@react-aria/color/src/index.ts","packages/@react-aria/color/src/index.ts"],"sourcesContent":[null,null,null,null,null,null,null,null,"/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\nexport {useColorArea} from './useColorArea';\nexport {useColorSlider} from './useColorSlider';\nexport {useColorWheel} from './useColorWheel';\nexport {useColorField} from './useColorField';\nexport {useColorSwatch} from './useColorSwatch';\nexport {useColorChannelField} from './useColorChannelField';\nexport type {AriaColorAreaOptions, ColorAreaAria} from './useColorArea';\nexport type {AriaColorSliderOptions, ColorSliderAria} from './useColorSlider';\nexport type {AriaColorWheelOptions, ColorWheelAria} from './useColorWheel';\nexport type {AriaColorAreaProps, AriaColorFieldProps, AriaColorSliderProps} from '@react-types/color';\nexport type {ColorFieldAria} from './useColorField';\nexport type {AriaColorSwatchProps, ColorSwatchAria} from './useColorSwatch';\nexport type {AriaColorChannelFieldProps, ColorChannelFieldAria} from './useColorChannelField';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
|
|
@@ -34,7 +34,7 @@ $parcel$export(module.exports, "useColorArea", () => $47925bd68062ac17$export$2f
|
|
|
34
34
|
|
|
35
35
|
|
|
36
36
|
function $47925bd68062ac17$export$2f92a7a615a014f6(props, state) {
|
|
37
|
-
let { isDisabled: isDisabled, inputXRef: inputXRef, inputYRef: inputYRef, containerRef: containerRef, 'aria-label': ariaLabel, xName: xName, yName: yName } = props;
|
|
37
|
+
let { isDisabled: isDisabled, inputXRef: inputXRef, inputYRef: inputYRef, containerRef: containerRef, 'aria-label': ariaLabel, xName: xName, yName: yName, form: form } = props;
|
|
38
38
|
let stringFormatter = (0, $fZxfU$reactariai18n.useLocalizedStringFormatter)((0, ($parcel$interopDefault($4a33e168940636d5$exports))), '@react-aria/color');
|
|
39
39
|
let { addGlobalListener: addGlobalListener, removeGlobalListener: removeGlobalListener } = (0, $fZxfU$reactariautils.useGlobalListeners)();
|
|
40
40
|
let { direction: direction, locale: locale } = (0, $fZxfU$reactariai18n.useLocale)();
|
|
@@ -44,13 +44,7 @@ function $47925bd68062ac17$export$2f92a7a615a014f6(props, state) {
|
|
|
44
44
|
}, [
|
|
45
45
|
inputXRef
|
|
46
46
|
]);
|
|
47
|
-
(0, $fZxfU$reactariautils.useFormReset)(inputXRef,
|
|
48
|
-
state.xValue,
|
|
49
|
-
state.yValue
|
|
50
|
-
], ([x, y])=>{
|
|
51
|
-
let newColor = state.value.withChannelValue(state.channels.xChannel, x).withChannelValue(state.channels.yChannel, y);
|
|
52
|
-
state.setValue(newColor);
|
|
53
|
-
});
|
|
47
|
+
(0, $fZxfU$reactariautils.useFormReset)(inputXRef, state.defaultValue, state.setValue);
|
|
54
48
|
let [valueChangedViaKeyboard, setValueChangedViaKeyboard] = (0, $fZxfU$react.useState)(false);
|
|
55
49
|
let [valueChangedViaInputChangeEvent, setValueChangedViaInputChangeEvent] = (0, $fZxfU$react.useState)(false);
|
|
56
50
|
let { xChannel: xChannel, yChannel: yChannel, zChannel: zChannel } = state.channels;
|
|
@@ -365,6 +359,7 @@ function $47925bd68062ac17$export$2f92a7a615a014f6(props, state) {
|
|
|
365
359
|
disabled: isDisabled,
|
|
366
360
|
value: state.value.getChannelValue(xChannel),
|
|
367
361
|
name: xName,
|
|
362
|
+
form: form,
|
|
368
363
|
tabIndex: isMobile || !focusedInput || focusedInput === 'x' ? undefined : -1,
|
|
369
364
|
/*
|
|
370
365
|
So that only a single "2d slider" control shows up when listing form elements for screen readers,
|
|
@@ -389,6 +384,7 @@ function $47925bd68062ac17$export$2f92a7a615a014f6(props, state) {
|
|
|
389
384
|
disabled: isDisabled,
|
|
390
385
|
value: state.value.getChannelValue(yChannel),
|
|
391
386
|
name: yName,
|
|
387
|
+
form: form,
|
|
392
388
|
tabIndex: isMobile || focusedInput === 'y' ? undefined : -1,
|
|
393
389
|
/*
|
|
394
390
|
So that only a single "2d slider" control shows up when listing form elements for screen readers,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;AAsCM,SAAS,0CAAa,KAA2B,EAAE,KAAqB;IAC7E,IAAI,cACF,UAAU,aACV,SAAS,aACT,SAAS,gBACT,YAAY,EACZ,cAAc,SAAS,SACvB,KAAK,SACL,KAAK,EACN,GAAG;IACJ,IAAI,kBAAkB,CAAA,GAAA,gDAA0B,EAAE,CAAA,GAAA,mDAAW,GAAG;IAEhE,IAAI,qBAAC,iBAAiB,wBAAE,oBAAoB,EAAC,GAAG,CAAA,GAAA,wCAAiB;IAEjE,IAAI,aAAC,SAAS,U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K,CAAC,eAAe,CAAC;YACnC,MAAM;YACN,UAAW,YAAY,iBAAiB,MAAM,YAAY;YAC1D;;;;MAIA,GACA,eAAgB,YAAY,iBAAiB,OAAO,0BAA0B,YAAY;sBAC1F;QACF;IACF;AACF","sources":["packages/@react-aria/color/src/useColorArea.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaColorAreaProps, ColorChannel} from '@react-types/color';\nimport {ColorAreaState} from '@react-stately/color';\nimport {DOMAttributes, RefObject} from '@react-types/shared';\nimport {focusWithoutScrolling, isAndroid, isIOS, mergeProps, useFormReset, useGlobalListeners, useLabels} from '@react-aria/utils';\n// @ts-ignore\nimport intlMessages from '../intl/*.json';\nimport React, {ChangeEvent, InputHTMLAttributes, useCallback, useRef, useState} from 'react';\nimport {useColorAreaGradient} from './useColorAreaGradient';\nimport {useFocus, useFocusWithin, useKeyboard, useMove} from '@react-aria/interactions';\nimport {useLocale, useLocalizedStringFormatter} from '@react-aria/i18n';\nimport {useVisuallyHidden} from '@react-aria/visually-hidden';\n\nexport interface ColorAreaAria {\n /** Props for the color area container element. */\n colorAreaProps: DOMAttributes,\n /** Props for the thumb element. */\n thumbProps: DOMAttributes,\n /** Props for the visually hidden horizontal range input element. */\n xInputProps: InputHTMLAttributes<HTMLInputElement>,\n /** Props for the visually hidden vertical range input element. */\n yInputProps: InputHTMLAttributes<HTMLInputElement>\n}\n\nexport interface AriaColorAreaOptions extends AriaColorAreaProps {\n /** A ref to the input that represents the x axis of the color area. */\n inputXRef: RefObject<HTMLInputElement | null>,\n /** A ref to the input that represents the y axis of the color area. */\n inputYRef: RefObject<HTMLInputElement | null>,\n /** A ref to the color area containing element. */\n containerRef: RefObject<Element | null>\n}\n\n/**\n * Provides the behavior and accessibility implementation for a color area component.\n * Color area allows users to adjust two channels of an RGB, HSL or HSB color value against a two-dimensional gradient background.\n */\nexport function useColorArea(props: AriaColorAreaOptions, state: ColorAreaState): ColorAreaAria {\n let {\n isDisabled,\n inputXRef,\n inputYRef,\n containerRef,\n 'aria-label': ariaLabel,\n xName,\n yName\n } = props;\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/color');\n\n let {addGlobalListener, removeGlobalListener} = useGlobalListeners();\n\n let {direction, locale} = useLocale();\n\n let [focusedInput, setFocusedInput] = useState<'x' | 'y' | null>(null);\n let focusInput = useCallback((inputRef:RefObject<HTMLInputElement | null> = inputXRef) => {\n if (inputRef.current) {\n focusWithoutScrolling(inputRef.current);\n }\n }, [inputXRef]);\n\n useFormReset(inputXRef, [state.xValue, state.yValue], ([x, y]) => {\n let newColor = state.value\n .withChannelValue(state.channels.xChannel, x)\n .withChannelValue(state.channels.yChannel, y);\n state.setValue(newColor);\n });\n\n let [valueChangedViaKeyboard, setValueChangedViaKeyboard] = useState(false);\n let [valueChangedViaInputChangeEvent, setValueChangedViaInputChangeEvent] = useState(false);\n let {xChannel, yChannel, zChannel} = state.channels;\n let xChannelStep = state.xChannelStep;\n let yChannelStep = state.yChannelStep;\n\n let currentPosition = useRef<{x: number, y: number} | null>(null);\n\n let {keyboardProps} = useKeyboard({\n onKeyDown(e) {\n // these are the cases that useMove doesn't handle\n if (!/^(PageUp|PageDown|Home|End)$/.test(e.key)) {\n e.continuePropagation();\n return;\n }\n // same handling as useMove, don't need to stop propagation, useKeyboard will do that for us\n e.preventDefault();\n // remember to set this and unset it so that onChangeEnd is fired\n state.setDragging(true);\n setValueChangedViaKeyboard(true);\n let dir;\n switch (e.key) {\n case 'PageUp':\n state.incrementY(state.yChannelPageStep);\n dir = 'y';\n break;\n case 'PageDown':\n state.decrementY(state.yChannelPageStep);\n dir = 'y';\n break;\n case 'Home':\n direction === 'rtl' ? state.incrementX(state.xChannelPageStep) : state.decrementX(state.xChannelPageStep);\n dir = 'x';\n break;\n case 'End':\n direction === 'rtl' ? state.decrementX(state.xChannelPageStep) : state.incrementX(state.xChannelPageStep);\n dir = 'x';\n break;\n }\n state.setDragging(false);\n if (dir) {\n let input = dir === 'x' ? inputXRef : inputYRef;\n focusInput(input);\n setFocusedInput(dir);\n }\n }\n });\n\n let moveHandler = {\n onMoveStart() {\n currentPosition.current = null;\n state.setDragging(true);\n },\n onMove({deltaX, deltaY, pointerType, shiftKey}) {\n let {\n incrementX,\n decrementX,\n incrementY,\n decrementY,\n xChannelPageStep,\n xChannelStep,\n yChannelPageStep,\n yChannelStep,\n getThumbPosition,\n setColorFromPoint\n } = state;\n if (currentPosition.current == null) {\n currentPosition.current = getThumbPosition();\n }\n let {width, height} = containerRef.current?.getBoundingClientRect() || {width: 0, height: 0};\n let valueChanged = deltaX !== 0 || deltaY !== 0;\n if (pointerType === 'keyboard') {\n let deltaXValue = shiftKey && xChannelPageStep > xChannelStep ? xChannelPageStep : xChannelStep;\n let deltaYValue = shiftKey && yChannelPageStep > yChannelStep ? yChannelPageStep : yChannelStep;\n if ((deltaX > 0 && direction === 'ltr') || (deltaX < 0 && direction === 'rtl')) {\n incrementX(deltaXValue);\n } else if ((deltaX < 0 && direction === 'ltr') || (deltaX > 0 && direction === 'rtl')) {\n decrementX(deltaXValue);\n } else if (deltaY > 0) {\n decrementY(deltaYValue);\n } else if (deltaY < 0) {\n incrementY(deltaYValue);\n }\n setValueChangedViaKeyboard(valueChanged);\n // set the focused input based on which axis has the greater delta\n focusedInput = valueChanged && Math.abs(deltaY) > Math.abs(deltaX) ? 'y' : 'x';\n setFocusedInput(focusedInput);\n } else {\n currentPosition.current.x += (direction === 'rtl' ? -1 : 1) * deltaX / width ;\n currentPosition.current.y += deltaY / height;\n setColorFromPoint(currentPosition.current.x, currentPosition.current.y);\n }\n },\n onMoveEnd() {\n isOnColorArea.current = false;\n state.setDragging(false);\n let input = focusedInput === 'x' ? inputXRef : inputYRef;\n focusInput(input);\n }\n };\n let {moveProps: movePropsThumb} = useMove(moveHandler);\n\n let {focusWithinProps} = useFocusWithin({\n onFocusWithinChange: (focusWithin:boolean) => {\n if (!focusWithin) {\n setValueChangedViaKeyboard(false);\n setValueChangedViaInputChangeEvent(false);\n }\n }\n });\n\n let currentPointer = useRef<number | null | undefined>(undefined);\n let isOnColorArea = useRef<boolean>(false);\n let {moveProps: movePropsContainer} = useMove({\n onMoveStart() {\n if (isOnColorArea.current) {\n moveHandler.onMoveStart();\n }\n },\n onMove(e) {\n if (isOnColorArea.current) {\n moveHandler.onMove(e);\n }\n },\n onMoveEnd() {\n if (isOnColorArea.current) {\n moveHandler.onMoveEnd();\n }\n }\n });\n\n let onThumbDown = (id: number | null | undefined) => {\n if (!state.isDragging) {\n currentPointer.current = id;\n setValueChangedViaKeyboard(false);\n focusInput();\n state.setDragging(true);\n if (typeof PointerEvent !== 'undefined') {\n addGlobalListener(window, 'pointerup', onThumbUp, false);\n } else {\n addGlobalListener(window, 'mouseup', onThumbUp, false);\n addGlobalListener(window, 'touchend', onThumbUp, false);\n }\n }\n };\n\n let onThumbUp = (e) => {\n let id = e.pointerId ?? e.changedTouches?.[0].identifier;\n if (id === currentPointer.current) {\n setValueChangedViaKeyboard(false);\n focusInput();\n state.setDragging(false);\n currentPointer.current = undefined;\n isOnColorArea.current = false;\n\n if (typeof PointerEvent !== 'undefined') {\n removeGlobalListener(window, 'pointerup', onThumbUp, false);\n } else {\n removeGlobalListener(window, 'mouseup', onThumbUp, false);\n removeGlobalListener(window, 'touchend', onThumbUp, false);\n }\n }\n };\n\n let onColorAreaDown = (colorArea: Element, id: number | null | undefined, clientX: number, clientY: number) => {\n let rect = colorArea.getBoundingClientRect();\n let {width, height} = rect;\n let x = (clientX - rect.x) / width;\n let y = (clientY - rect.y) / height;\n if (direction === 'rtl') {\n x = 1 - x;\n }\n if (x >= 0 && x <= 1 && y >= 0 && y <= 1 && !state.isDragging && currentPointer.current === undefined) {\n isOnColorArea.current = true;\n setValueChangedViaKeyboard(false);\n currentPointer.current = id;\n state.setColorFromPoint(x, y);\n\n focusInput();\n state.setDragging(true);\n\n if (typeof PointerEvent !== 'undefined') {\n addGlobalListener(window, 'pointerup', onColorAreaUp, false);\n } else {\n addGlobalListener(window, 'mouseup', onColorAreaUp, false);\n addGlobalListener(window, 'touchend', onColorAreaUp, false);\n }\n }\n };\n\n let onColorAreaUp = (e) => {\n let id = e.pointerId ?? e.changedTouches?.[0].identifier;\n if (isOnColorArea.current && id === currentPointer.current) {\n isOnColorArea.current = false;\n setValueChangedViaKeyboard(false);\n currentPointer.current = undefined;\n state.setDragging(false);\n focusInput();\n\n if (typeof PointerEvent !== 'undefined') {\n removeGlobalListener(window, 'pointerup', onColorAreaUp, false);\n } else {\n removeGlobalListener(window, 'mouseup', onColorAreaUp, false);\n removeGlobalListener(window, 'touchend', onColorAreaUp, false);\n }\n }\n };\n\n let colorAreaInteractions = isDisabled ? {} : mergeProps({\n ...(typeof PointerEvent !== 'undefined' ? {\n onPointerDown: (e: React.PointerEvent) => {\n if (e.pointerType === 'mouse' && (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey)) {\n return;\n }\n onColorAreaDown(e.currentTarget, e.pointerId, e.clientX, e.clientY);\n }} : {\n onMouseDown: (e: React.MouseEvent) => {\n if (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey) {\n return;\n }\n onColorAreaDown(e.currentTarget, undefined, e.clientX, e.clientY);\n },\n onTouchStart: (e: React.TouchEvent) => {\n onColorAreaDown(e.currentTarget, e.changedTouches[0].identifier, e.changedTouches[0].clientX, e.changedTouches[0].clientY);\n }\n })\n }, movePropsContainer);\n\n let thumbInteractions = isDisabled ? {} : mergeProps({\n ...(typeof PointerEvent !== 'undefined' ? {\n onPointerDown: (e: React.PointerEvent) => {\n if (e.pointerType === 'mouse' && (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey)) {\n return;\n }\n onThumbDown(e.pointerId);\n }} : {\n onMouseDown: (e: React.MouseEvent) => {\n if (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey) {\n return;\n }\n onThumbDown(undefined);\n },\n onTouchStart: (e: React.TouchEvent) => {\n onThumbDown(e.changedTouches[0].identifier);\n }\n })\n }, focusWithinProps, keyboardProps, movePropsThumb);\n\n let {focusProps: xInputFocusProps} = useFocus({\n onFocus: () => {\n setFocusedInput('x');\n }\n });\n\n let {focusProps: yInputFocusProps} = useFocus({\n onFocus: () => {\n setFocusedInput('y');\n }\n });\n\n const onChange = (e: ChangeEvent<HTMLInputElement>) => {\n const {target} = e;\n setValueChangedViaInputChangeEvent(true);\n if (target === inputXRef.current) {\n state.setXValue(parseFloat(target.value));\n } else if (target === inputYRef.current) {\n state.setYValue(parseFloat(target.value));\n }\n };\n\n let isMobile = isIOS() || isAndroid();\n\n let value = state.getDisplayColor();\n const getAriaValueTextForChannel = useCallback((channel:ColorChannel) => {\n const isAfterInput = valueChangedViaInputChangeEvent || valueChangedViaKeyboard;\n return `${\n isAfterInput ?\n stringFormatter.format('colorNameAndValue', {name: value.getChannelName(channel, locale), value: value.formatChannelValue(channel, locale)})\n :\n [\n stringFormatter.format('colorNameAndValue', {name: value.getChannelName(channel, locale), value: value.formatChannelValue(channel, locale)}),\n stringFormatter.format('colorNameAndValue', {name: value.getChannelName(channel === yChannel ? xChannel : yChannel, locale), value: value.formatChannelValue(channel === yChannel ? xChannel : yChannel, locale)}),\n stringFormatter.format('colorNameAndValue', {name: value.getChannelName(zChannel, locale), value: value.formatChannelValue(zChannel, locale)})\n ].join(', ')\n }, ${value.getColorName(locale)}`;\n }, [locale, value, stringFormatter, valueChangedViaInputChangeEvent, valueChangedViaKeyboard, xChannel, yChannel, zChannel]);\n\n let colorPickerLabel = stringFormatter.format('colorPicker');\n\n let xInputLabellingProps = useLabels({\n ...props,\n 'aria-label': ariaLabel ? stringFormatter.format('colorInputLabel', {label: ariaLabel, channelLabel: colorPickerLabel}) : colorPickerLabel\n });\n\n let yInputLabellingProps = useLabels({\n ...props,\n 'aria-label': ariaLabel ? stringFormatter.format('colorInputLabel', {label: ariaLabel, channelLabel: colorPickerLabel}) : colorPickerLabel\n });\n\n let colorAreaLabellingProps = useLabels(\n {\n ...props,\n 'aria-label': ariaLabel ? `${ariaLabel}, ${colorPickerLabel}` : undefined\n },\n isMobile ? colorPickerLabel : undefined\n );\n\n let ariaRoleDescription = stringFormatter.format('twoDimensionalSlider');\n\n let {visuallyHiddenProps} = useVisuallyHidden({style: {\n opacity: '0.0001',\n width: '100%',\n height: '100%',\n pointerEvents: 'none'\n }});\n\n let {\n colorAreaStyleProps,\n thumbStyleProps\n } = useColorAreaGradient({\n direction,\n state,\n xChannel,\n yChannel,\n zChannel\n });\n\n return {\n colorAreaProps: {\n ...colorAreaLabellingProps,\n ...colorAreaInteractions,\n ...colorAreaStyleProps,\n role: 'group'\n },\n thumbProps: {\n ...thumbInteractions,\n ...thumbStyleProps,\n role: 'presentation'\n },\n xInputProps: {\n ...xInputLabellingProps,\n ...visuallyHiddenProps,\n ...xInputFocusProps,\n type: 'range',\n min: state.value.getChannelRange(xChannel).minValue,\n max: state.value.getChannelRange(xChannel).maxValue,\n step: xChannelStep,\n 'aria-roledescription': ariaRoleDescription,\n 'aria-valuetext': getAriaValueTextForChannel(xChannel),\n 'aria-orientation': 'horizontal',\n 'aria-describedby': props['aria-describedby'],\n 'aria-details': props['aria-details'],\n disabled: isDisabled,\n value: state.value.getChannelValue(xChannel),\n name: xName,\n tabIndex: (isMobile || !focusedInput || focusedInput === 'x' ? undefined : -1),\n /*\n So that only a single \"2d slider\" control shows up when listing form elements for screen readers,\n add aria-hidden=\"true\" to the unfocused control when the value has not changed via the keyboard,\n but remove aria-hidden to reveal the input for each channel when the value has changed with the keyboard.\n */\n 'aria-hidden': (isMobile || !focusedInput || focusedInput === 'x' || valueChangedViaKeyboard ? undefined : 'true'),\n onChange\n },\n yInputProps: {\n ...yInputLabellingProps,\n ...visuallyHiddenProps,\n ...yInputFocusProps,\n type: 'range',\n min: state.value.getChannelRange(yChannel).minValue,\n max: state.value.getChannelRange(yChannel).maxValue,\n step: yChannelStep,\n 'aria-roledescription': ariaRoleDescription,\n 'aria-valuetext': getAriaValueTextForChannel(yChannel),\n 'aria-orientation': 'vertical',\n 'aria-describedby': props['aria-describedby'],\n 'aria-details': props['aria-details'],\n disabled: isDisabled,\n value: state.value.getChannelValue(yChannel),\n name: yName,\n tabIndex: (isMobile || focusedInput === 'y' ? undefined : -1),\n /*\n So that only a single \"2d slider\" control shows up when listing form elements for screen readers,\n add aria-hidden=\"true\" to the unfocused input when the value has not changed via the keyboard,\n but remove aria-hidden to reveal the input for each channel when the value has changed with the keyboard.\n */\n 'aria-hidden': (isMobile || focusedInput === 'y' || valueChangedViaKeyboard ? undefined : 'true'),\n onChange\n }\n };\n}\n"],"names":[],"version":3,"file":"useColorArea.main.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;AAsCM,SAAS,0CAAa,KAA2B,EAAE,KAAqB;IAC7E,IAAI,cACF,UAAU,aACV,SAAS,aACT,SAAS,gBACT,YAAY,EACZ,cAAc,SAAS,SACvB,KAAK,SACL,KAAK,QACL,IAAI,EACL,GAAG;IACJ,IAAI,kBAAkB,CAAA,GAAA,gDAA0B,EAAE,CAAA,GAAA,mDAAW,GAAG;IAEhE,IAAI,qBAAC,iBAAiB,wBAAE,oBAAoB,EAAC,GAAG,CAAA,GAAA,wCAAiB;IAEjE,IAAI,aAAC,SAAS,UAAE,MAAM,EAAC,GAAG,CAAA,GAAA,8BAAQ;IAElC,IAAI,CAAC,cAAc,gBAAgB,GAAG,CAAA,GAAA,qBAAO,EAAoB;IACjE,IAAI,aAAa,CAAA,GAAA,wBAAU,EAAE,CAAC,WAA8C,SAAS;QACnF,IAAI,SAAS,OA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G,gBAAgB;YACnB,MAAM;YACN,KAAK,MAAM,KAAK,CAAC,eAAe,CAAC,UAAU,QAAQ;YACnD,KAAK,MAAM,KAAK,CAAC,eAAe,CAAC,UAAU,QAAQ;YACnD,MAAM;YACN,wBAAwB;YACxB,kBAAkB,2BAA2B;YAC7C,oBAAoB;YACpB,oBAAoB,KAAK,CAAC,mBAAmB;YAC7C,gBAAgB,KAAK,CAAC,eAAe;YACrC,UAAU;YACV,OAAO,MAAM,KAAK,CAAC,eAAe,CAAC;YACnC,MAAM;kBACN;YACA,UAAW,YAAY,CAAC,gBAAgB,iBAAiB,MAAM,YAAY;YAC3E;;;;MAIA,GACA,eAAgB,YAAY,CAAC,gBAAgB,iBAAiB,OAAO,0BAA0B,YAAY;sBAC3G;QACF;QACA,aAAa;YACX,GAAG,oBAAoB;YACvB,GAAG,mBAAmB;YACtB,GAAG,gBAAgB;YACnB,MAAM;YACN,KAAK,MAAM,KAAK,CAAC,eAAe,CAAC,UAAU,QAAQ;YACnD,KAAK,MAAM,KAAK,CAAC,eAAe,CAAC,UAAU,QAAQ;YACnD,MAAM;YACN,wBAAwB;YACxB,kBAAkB,2BAA2B;YAC7C,oBAAoB;YACpB,oBAAoB,KAAK,CAAC,mBAAmB;YAC7C,gBAAgB,KAAK,CAAC,eAAe;YACrC,UAAU;YACV,OAAO,MAAM,KAAK,CAAC,eAAe,CAAC;YACnC,MAAM;kBACN;YACA,UAAW,YAAY,iBAAiB,MAAM,YAAY;YAC1D;;;;MAIA,GACA,eAAgB,YAAY,iBAAiB,OAAO,0BAA0B,YAAY;sBAC1F;QACF;IACF;AACF","sources":["packages/@react-aria/color/src/useColorArea.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaColorAreaProps, ColorChannel} from '@react-types/color';\nimport {ColorAreaState} from '@react-stately/color';\nimport {DOMAttributes, RefObject} from '@react-types/shared';\nimport {focusWithoutScrolling, isAndroid, isIOS, mergeProps, useFormReset, useGlobalListeners, useLabels} from '@react-aria/utils';\n// @ts-ignore\nimport intlMessages from '../intl/*.json';\nimport React, {ChangeEvent, InputHTMLAttributes, useCallback, useRef, useState} from 'react';\nimport {useColorAreaGradient} from './useColorAreaGradient';\nimport {useFocus, useFocusWithin, useKeyboard, useMove} from '@react-aria/interactions';\nimport {useLocale, useLocalizedStringFormatter} from '@react-aria/i18n';\nimport {useVisuallyHidden} from '@react-aria/visually-hidden';\n\nexport interface ColorAreaAria {\n /** Props for the color area container element. */\n colorAreaProps: DOMAttributes,\n /** Props for the thumb element. */\n thumbProps: DOMAttributes,\n /** Props for the visually hidden horizontal range input element. */\n xInputProps: InputHTMLAttributes<HTMLInputElement>,\n /** Props for the visually hidden vertical range input element. */\n yInputProps: InputHTMLAttributes<HTMLInputElement>\n}\n\nexport interface AriaColorAreaOptions extends AriaColorAreaProps {\n /** A ref to the input that represents the x axis of the color area. */\n inputXRef: RefObject<HTMLInputElement | null>,\n /** A ref to the input that represents the y axis of the color area. */\n inputYRef: RefObject<HTMLInputElement | null>,\n /** A ref to the color area containing element. */\n containerRef: RefObject<Element | null>\n}\n\n/**\n * Provides the behavior and accessibility implementation for a color area component.\n * Color area allows users to adjust two channels of an RGB, HSL or HSB color value against a two-dimensional gradient background.\n */\nexport function useColorArea(props: AriaColorAreaOptions, state: ColorAreaState): ColorAreaAria {\n let {\n isDisabled,\n inputXRef,\n inputYRef,\n containerRef,\n 'aria-label': ariaLabel,\n xName,\n yName,\n form\n } = props;\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/color');\n\n let {addGlobalListener, removeGlobalListener} = useGlobalListeners();\n\n let {direction, locale} = useLocale();\n\n let [focusedInput, setFocusedInput] = useState<'x' | 'y' | null>(null);\n let focusInput = useCallback((inputRef:RefObject<HTMLInputElement | null> = inputXRef) => {\n if (inputRef.current) {\n focusWithoutScrolling(inputRef.current);\n }\n }, [inputXRef]);\n\n useFormReset(inputXRef, state.defaultValue, state.setValue);\n\n let [valueChangedViaKeyboard, setValueChangedViaKeyboard] = useState(false);\n let [valueChangedViaInputChangeEvent, setValueChangedViaInputChangeEvent] = useState(false);\n let {xChannel, yChannel, zChannel} = state.channels;\n let xChannelStep = state.xChannelStep;\n let yChannelStep = state.yChannelStep;\n\n let currentPosition = useRef<{x: number, y: number} | null>(null);\n\n let {keyboardProps} = useKeyboard({\n onKeyDown(e) {\n // these are the cases that useMove doesn't handle\n if (!/^(PageUp|PageDown|Home|End)$/.test(e.key)) {\n e.continuePropagation();\n return;\n }\n // same handling as useMove, don't need to stop propagation, useKeyboard will do that for us\n e.preventDefault();\n // remember to set this and unset it so that onChangeEnd is fired\n state.setDragging(true);\n setValueChangedViaKeyboard(true);\n let dir;\n switch (e.key) {\n case 'PageUp':\n state.incrementY(state.yChannelPageStep);\n dir = 'y';\n break;\n case 'PageDown':\n state.decrementY(state.yChannelPageStep);\n dir = 'y';\n break;\n case 'Home':\n direction === 'rtl' ? state.incrementX(state.xChannelPageStep) : state.decrementX(state.xChannelPageStep);\n dir = 'x';\n break;\n case 'End':\n direction === 'rtl' ? state.decrementX(state.xChannelPageStep) : state.incrementX(state.xChannelPageStep);\n dir = 'x';\n break;\n }\n state.setDragging(false);\n if (dir) {\n let input = dir === 'x' ? inputXRef : inputYRef;\n focusInput(input);\n setFocusedInput(dir);\n }\n }\n });\n\n let moveHandler = {\n onMoveStart() {\n currentPosition.current = null;\n state.setDragging(true);\n },\n onMove({deltaX, deltaY, pointerType, shiftKey}) {\n let {\n incrementX,\n decrementX,\n incrementY,\n decrementY,\n xChannelPageStep,\n xChannelStep,\n yChannelPageStep,\n yChannelStep,\n getThumbPosition,\n setColorFromPoint\n } = state;\n if (currentPosition.current == null) {\n currentPosition.current = getThumbPosition();\n }\n let {width, height} = containerRef.current?.getBoundingClientRect() || {width: 0, height: 0};\n let valueChanged = deltaX !== 0 || deltaY !== 0;\n if (pointerType === 'keyboard') {\n let deltaXValue = shiftKey && xChannelPageStep > xChannelStep ? xChannelPageStep : xChannelStep;\n let deltaYValue = shiftKey && yChannelPageStep > yChannelStep ? yChannelPageStep : yChannelStep;\n if ((deltaX > 0 && direction === 'ltr') || (deltaX < 0 && direction === 'rtl')) {\n incrementX(deltaXValue);\n } else if ((deltaX < 0 && direction === 'ltr') || (deltaX > 0 && direction === 'rtl')) {\n decrementX(deltaXValue);\n } else if (deltaY > 0) {\n decrementY(deltaYValue);\n } else if (deltaY < 0) {\n incrementY(deltaYValue);\n }\n setValueChangedViaKeyboard(valueChanged);\n // set the focused input based on which axis has the greater delta\n focusedInput = valueChanged && Math.abs(deltaY) > Math.abs(deltaX) ? 'y' : 'x';\n setFocusedInput(focusedInput);\n } else {\n currentPosition.current.x += (direction === 'rtl' ? -1 : 1) * deltaX / width ;\n currentPosition.current.y += deltaY / height;\n setColorFromPoint(currentPosition.current.x, currentPosition.current.y);\n }\n },\n onMoveEnd() {\n isOnColorArea.current = false;\n state.setDragging(false);\n let input = focusedInput === 'x' ? inputXRef : inputYRef;\n focusInput(input);\n }\n };\n let {moveProps: movePropsThumb} = useMove(moveHandler);\n\n let {focusWithinProps} = useFocusWithin({\n onFocusWithinChange: (focusWithin:boolean) => {\n if (!focusWithin) {\n setValueChangedViaKeyboard(false);\n setValueChangedViaInputChangeEvent(false);\n }\n }\n });\n\n let currentPointer = useRef<number | null | undefined>(undefined);\n let isOnColorArea = useRef<boolean>(false);\n let {moveProps: movePropsContainer} = useMove({\n onMoveStart() {\n if (isOnColorArea.current) {\n moveHandler.onMoveStart();\n }\n },\n onMove(e) {\n if (isOnColorArea.current) {\n moveHandler.onMove(e);\n }\n },\n onMoveEnd() {\n if (isOnColorArea.current) {\n moveHandler.onMoveEnd();\n }\n }\n });\n\n let onThumbDown = (id: number | null | undefined) => {\n if (!state.isDragging) {\n currentPointer.current = id;\n setValueChangedViaKeyboard(false);\n focusInput();\n state.setDragging(true);\n if (typeof PointerEvent !== 'undefined') {\n addGlobalListener(window, 'pointerup', onThumbUp, false);\n } else {\n addGlobalListener(window, 'mouseup', onThumbUp, false);\n addGlobalListener(window, 'touchend', onThumbUp, false);\n }\n }\n };\n\n let onThumbUp = (e) => {\n let id = e.pointerId ?? e.changedTouches?.[0].identifier;\n if (id === currentPointer.current) {\n setValueChangedViaKeyboard(false);\n focusInput();\n state.setDragging(false);\n currentPointer.current = undefined;\n isOnColorArea.current = false;\n\n if (typeof PointerEvent !== 'undefined') {\n removeGlobalListener(window, 'pointerup', onThumbUp, false);\n } else {\n removeGlobalListener(window, 'mouseup', onThumbUp, false);\n removeGlobalListener(window, 'touchend', onThumbUp, false);\n }\n }\n };\n\n let onColorAreaDown = (colorArea: Element, id: number | null | undefined, clientX: number, clientY: number) => {\n let rect = colorArea.getBoundingClientRect();\n let {width, height} = rect;\n let x = (clientX - rect.x) / width;\n let y = (clientY - rect.y) / height;\n if (direction === 'rtl') {\n x = 1 - x;\n }\n if (x >= 0 && x <= 1 && y >= 0 && y <= 1 && !state.isDragging && currentPointer.current === undefined) {\n isOnColorArea.current = true;\n setValueChangedViaKeyboard(false);\n currentPointer.current = id;\n state.setColorFromPoint(x, y);\n\n focusInput();\n state.setDragging(true);\n\n if (typeof PointerEvent !== 'undefined') {\n addGlobalListener(window, 'pointerup', onColorAreaUp, false);\n } else {\n addGlobalListener(window, 'mouseup', onColorAreaUp, false);\n addGlobalListener(window, 'touchend', onColorAreaUp, false);\n }\n }\n };\n\n let onColorAreaUp = (e) => {\n let id = e.pointerId ?? e.changedTouches?.[0].identifier;\n if (isOnColorArea.current && id === currentPointer.current) {\n isOnColorArea.current = false;\n setValueChangedViaKeyboard(false);\n currentPointer.current = undefined;\n state.setDragging(false);\n focusInput();\n\n if (typeof PointerEvent !== 'undefined') {\n removeGlobalListener(window, 'pointerup', onColorAreaUp, false);\n } else {\n removeGlobalListener(window, 'mouseup', onColorAreaUp, false);\n removeGlobalListener(window, 'touchend', onColorAreaUp, false);\n }\n }\n };\n\n let colorAreaInteractions = isDisabled ? {} : mergeProps({\n ...(typeof PointerEvent !== 'undefined' ? {\n onPointerDown: (e: React.PointerEvent) => {\n if (e.pointerType === 'mouse' && (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey)) {\n return;\n }\n onColorAreaDown(e.currentTarget, e.pointerId, e.clientX, e.clientY);\n }} : {\n onMouseDown: (e: React.MouseEvent) => {\n if (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey) {\n return;\n }\n onColorAreaDown(e.currentTarget, undefined, e.clientX, e.clientY);\n },\n onTouchStart: (e: React.TouchEvent) => {\n onColorAreaDown(e.currentTarget, e.changedTouches[0].identifier, e.changedTouches[0].clientX, e.changedTouches[0].clientY);\n }\n })\n }, movePropsContainer);\n\n let thumbInteractions = isDisabled ? {} : mergeProps({\n ...(typeof PointerEvent !== 'undefined' ? {\n onPointerDown: (e: React.PointerEvent) => {\n if (e.pointerType === 'mouse' && (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey)) {\n return;\n }\n onThumbDown(e.pointerId);\n }} : {\n onMouseDown: (e: React.MouseEvent) => {\n if (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey) {\n return;\n }\n onThumbDown(undefined);\n },\n onTouchStart: (e: React.TouchEvent) => {\n onThumbDown(e.changedTouches[0].identifier);\n }\n })\n }, focusWithinProps, keyboardProps, movePropsThumb);\n\n let {focusProps: xInputFocusProps} = useFocus({\n onFocus: () => {\n setFocusedInput('x');\n }\n });\n\n let {focusProps: yInputFocusProps} = useFocus({\n onFocus: () => {\n setFocusedInput('y');\n }\n });\n\n const onChange = (e: ChangeEvent<HTMLInputElement>) => {\n const {target} = e;\n setValueChangedViaInputChangeEvent(true);\n if (target === inputXRef.current) {\n state.setXValue(parseFloat(target.value));\n } else if (target === inputYRef.current) {\n state.setYValue(parseFloat(target.value));\n }\n };\n\n let isMobile = isIOS() || isAndroid();\n\n let value = state.getDisplayColor();\n const getAriaValueTextForChannel = useCallback((channel:ColorChannel) => {\n const isAfterInput = valueChangedViaInputChangeEvent || valueChangedViaKeyboard;\n return `${\n isAfterInput ?\n stringFormatter.format('colorNameAndValue', {name: value.getChannelName(channel, locale), value: value.formatChannelValue(channel, locale)})\n :\n [\n stringFormatter.format('colorNameAndValue', {name: value.getChannelName(channel, locale), value: value.formatChannelValue(channel, locale)}),\n stringFormatter.format('colorNameAndValue', {name: value.getChannelName(channel === yChannel ? xChannel : yChannel, locale), value: value.formatChannelValue(channel === yChannel ? xChannel : yChannel, locale)}),\n stringFormatter.format('colorNameAndValue', {name: value.getChannelName(zChannel, locale), value: value.formatChannelValue(zChannel, locale)})\n ].join(', ')\n }, ${value.getColorName(locale)}`;\n }, [locale, value, stringFormatter, valueChangedViaInputChangeEvent, valueChangedViaKeyboard, xChannel, yChannel, zChannel]);\n\n let colorPickerLabel = stringFormatter.format('colorPicker');\n\n let xInputLabellingProps = useLabels({\n ...props,\n 'aria-label': ariaLabel ? stringFormatter.format('colorInputLabel', {label: ariaLabel, channelLabel: colorPickerLabel}) : colorPickerLabel\n });\n\n let yInputLabellingProps = useLabels({\n ...props,\n 'aria-label': ariaLabel ? stringFormatter.format('colorInputLabel', {label: ariaLabel, channelLabel: colorPickerLabel}) : colorPickerLabel\n });\n\n let colorAreaLabellingProps = useLabels(\n {\n ...props,\n 'aria-label': ariaLabel ? `${ariaLabel}, ${colorPickerLabel}` : undefined\n },\n isMobile ? colorPickerLabel : undefined\n );\n\n let ariaRoleDescription = stringFormatter.format('twoDimensionalSlider');\n\n let {visuallyHiddenProps} = useVisuallyHidden({style: {\n opacity: '0.0001',\n width: '100%',\n height: '100%',\n pointerEvents: 'none'\n }});\n\n let {\n colorAreaStyleProps,\n thumbStyleProps\n } = useColorAreaGradient({\n direction,\n state,\n xChannel,\n yChannel,\n zChannel\n });\n\n return {\n colorAreaProps: {\n ...colorAreaLabellingProps,\n ...colorAreaInteractions,\n ...colorAreaStyleProps,\n role: 'group'\n },\n thumbProps: {\n ...thumbInteractions,\n ...thumbStyleProps,\n role: 'presentation'\n },\n xInputProps: {\n ...xInputLabellingProps,\n ...visuallyHiddenProps,\n ...xInputFocusProps,\n type: 'range',\n min: state.value.getChannelRange(xChannel).minValue,\n max: state.value.getChannelRange(xChannel).maxValue,\n step: xChannelStep,\n 'aria-roledescription': ariaRoleDescription,\n 'aria-valuetext': getAriaValueTextForChannel(xChannel),\n 'aria-orientation': 'horizontal',\n 'aria-describedby': props['aria-describedby'],\n 'aria-details': props['aria-details'],\n disabled: isDisabled,\n value: state.value.getChannelValue(xChannel),\n name: xName,\n form,\n tabIndex: (isMobile || !focusedInput || focusedInput === 'x' ? undefined : -1),\n /*\n So that only a single \"2d slider\" control shows up when listing form elements for screen readers,\n add aria-hidden=\"true\" to the unfocused control when the value has not changed via the keyboard,\n but remove aria-hidden to reveal the input for each channel when the value has changed with the keyboard.\n */\n 'aria-hidden': (isMobile || !focusedInput || focusedInput === 'x' || valueChangedViaKeyboard ? undefined : 'true'),\n onChange\n },\n yInputProps: {\n ...yInputLabellingProps,\n ...visuallyHiddenProps,\n ...yInputFocusProps,\n type: 'range',\n min: state.value.getChannelRange(yChannel).minValue,\n max: state.value.getChannelRange(yChannel).maxValue,\n step: yChannelStep,\n 'aria-roledescription': ariaRoleDescription,\n 'aria-valuetext': getAriaValueTextForChannel(yChannel),\n 'aria-orientation': 'vertical',\n 'aria-describedby': props['aria-describedby'],\n 'aria-details': props['aria-details'],\n disabled: isDisabled,\n value: state.value.getChannelValue(yChannel),\n name: yName,\n form,\n tabIndex: (isMobile || focusedInput === 'y' ? undefined : -1),\n /*\n So that only a single \"2d slider\" control shows up when listing form elements for screen readers,\n add aria-hidden=\"true\" to the unfocused input when the value has not changed via the keyboard,\n but remove aria-hidden to reveal the input for each channel when the value has changed with the keyboard.\n */\n 'aria-hidden': (isMobile || focusedInput === 'y' || valueChangedViaKeyboard ? undefined : 'true'),\n onChange\n }\n };\n}\n"],"names":[],"version":3,"file":"useColorArea.main.js.map"}
|
package/dist/useColorArea.mjs
CHANGED
|
@@ -28,7 +28,7 @@ function $parcel$interopDefault(a) {
|
|
|
28
28
|
|
|
29
29
|
|
|
30
30
|
function $60bd7d6e45dcddfa$export$2f92a7a615a014f6(props, state) {
|
|
31
|
-
let { isDisabled: isDisabled, inputXRef: inputXRef, inputYRef: inputYRef, containerRef: containerRef, 'aria-label': ariaLabel, xName: xName, yName: yName } = props;
|
|
31
|
+
let { isDisabled: isDisabled, inputXRef: inputXRef, inputYRef: inputYRef, containerRef: containerRef, 'aria-label': ariaLabel, xName: xName, yName: yName, form: form } = props;
|
|
32
32
|
let stringFormatter = (0, $8t1z9$useLocalizedStringFormatter)((0, ($parcel$interopDefault($8t1z9$intlStringsmodulejs))), '@react-aria/color');
|
|
33
33
|
let { addGlobalListener: addGlobalListener, removeGlobalListener: removeGlobalListener } = (0, $8t1z9$useGlobalListeners)();
|
|
34
34
|
let { direction: direction, locale: locale } = (0, $8t1z9$useLocale)();
|
|
@@ -38,13 +38,7 @@ function $60bd7d6e45dcddfa$export$2f92a7a615a014f6(props, state) {
|
|
|
38
38
|
}, [
|
|
39
39
|
inputXRef
|
|
40
40
|
]);
|
|
41
|
-
(0, $8t1z9$useFormReset)(inputXRef,
|
|
42
|
-
state.xValue,
|
|
43
|
-
state.yValue
|
|
44
|
-
], ([x, y])=>{
|
|
45
|
-
let newColor = state.value.withChannelValue(state.channels.xChannel, x).withChannelValue(state.channels.yChannel, y);
|
|
46
|
-
state.setValue(newColor);
|
|
47
|
-
});
|
|
41
|
+
(0, $8t1z9$useFormReset)(inputXRef, state.defaultValue, state.setValue);
|
|
48
42
|
let [valueChangedViaKeyboard, setValueChangedViaKeyboard] = (0, $8t1z9$useState)(false);
|
|
49
43
|
let [valueChangedViaInputChangeEvent, setValueChangedViaInputChangeEvent] = (0, $8t1z9$useState)(false);
|
|
50
44
|
let { xChannel: xChannel, yChannel: yChannel, zChannel: zChannel } = state.channels;
|
|
@@ -359,6 +353,7 @@ function $60bd7d6e45dcddfa$export$2f92a7a615a014f6(props, state) {
|
|
|
359
353
|
disabled: isDisabled,
|
|
360
354
|
value: state.value.getChannelValue(xChannel),
|
|
361
355
|
name: xName,
|
|
356
|
+
form: form,
|
|
362
357
|
tabIndex: isMobile || !focusedInput || focusedInput === 'x' ? undefined : -1,
|
|
363
358
|
/*
|
|
364
359
|
So that only a single "2d slider" control shows up when listing form elements for screen readers,
|
|
@@ -383,6 +378,7 @@ function $60bd7d6e45dcddfa$export$2f92a7a615a014f6(props, state) {
|
|
|
383
378
|
disabled: isDisabled,
|
|
384
379
|
value: state.value.getChannelValue(yChannel),
|
|
385
380
|
name: yName,
|
|
381
|
+
form: form,
|
|
386
382
|
tabIndex: isMobile || focusedInput === 'y' ? undefined : -1,
|
|
387
383
|
/*
|
|
388
384
|
So that only a single "2d slider" control shows up when listing form elements for screen readers,
|
|
@@ -28,7 +28,7 @@ function $parcel$interopDefault(a) {
|
|
|
28
28
|
|
|
29
29
|
|
|
30
30
|
function $60bd7d6e45dcddfa$export$2f92a7a615a014f6(props, state) {
|
|
31
|
-
let { isDisabled: isDisabled, inputXRef: inputXRef, inputYRef: inputYRef, containerRef: containerRef, 'aria-label': ariaLabel, xName: xName, yName: yName } = props;
|
|
31
|
+
let { isDisabled: isDisabled, inputXRef: inputXRef, inputYRef: inputYRef, containerRef: containerRef, 'aria-label': ariaLabel, xName: xName, yName: yName, form: form } = props;
|
|
32
32
|
let stringFormatter = (0, $8t1z9$useLocalizedStringFormatter)((0, ($parcel$interopDefault($8t1z9$intlStringsmodulejs))), '@react-aria/color');
|
|
33
33
|
let { addGlobalListener: addGlobalListener, removeGlobalListener: removeGlobalListener } = (0, $8t1z9$useGlobalListeners)();
|
|
34
34
|
let { direction: direction, locale: locale } = (0, $8t1z9$useLocale)();
|
|
@@ -38,13 +38,7 @@ function $60bd7d6e45dcddfa$export$2f92a7a615a014f6(props, state) {
|
|
|
38
38
|
}, [
|
|
39
39
|
inputXRef
|
|
40
40
|
]);
|
|
41
|
-
(0, $8t1z9$useFormReset)(inputXRef,
|
|
42
|
-
state.xValue,
|
|
43
|
-
state.yValue
|
|
44
|
-
], ([x, y])=>{
|
|
45
|
-
let newColor = state.value.withChannelValue(state.channels.xChannel, x).withChannelValue(state.channels.yChannel, y);
|
|
46
|
-
state.setValue(newColor);
|
|
47
|
-
});
|
|
41
|
+
(0, $8t1z9$useFormReset)(inputXRef, state.defaultValue, state.setValue);
|
|
48
42
|
let [valueChangedViaKeyboard, setValueChangedViaKeyboard] = (0, $8t1z9$useState)(false);
|
|
49
43
|
let [valueChangedViaInputChangeEvent, setValueChangedViaInputChangeEvent] = (0, $8t1z9$useState)(false);
|
|
50
44
|
let { xChannel: xChannel, yChannel: yChannel, zChannel: zChannel } = state.channels;
|
|
@@ -359,6 +353,7 @@ function $60bd7d6e45dcddfa$export$2f92a7a615a014f6(props, state) {
|
|
|
359
353
|
disabled: isDisabled,
|
|
360
354
|
value: state.value.getChannelValue(xChannel),
|
|
361
355
|
name: xName,
|
|
356
|
+
form: form,
|
|
362
357
|
tabIndex: isMobile || !focusedInput || focusedInput === 'x' ? undefined : -1,
|
|
363
358
|
/*
|
|
364
359
|
So that only a single "2d slider" control shows up when listing form elements for screen readers,
|
|
@@ -383,6 +378,7 @@ function $60bd7d6e45dcddfa$export$2f92a7a615a014f6(props, state) {
|
|
|
383
378
|
disabled: isDisabled,
|
|
384
379
|
value: state.value.getChannelValue(yChannel),
|
|
385
380
|
name: yName,
|
|
381
|
+
form: form,
|
|
386
382
|
tabIndex: isMobile || focusedInput === 'y' ? undefined : -1,
|
|
387
383
|
/*
|
|
388
384
|
So that only a single "2d slider" control shows up when listing form elements for screen readers,
|
|
@@ -1 +1 @@
|
|
|
1
|
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C3G;QACF;QACA,aAAa;YACX,GAAG,oBAAoB;YACvB,GAAG,mBAAmB;YACtB,GAAG,gBAAgB;YACnB,MAAM;YACN,KAAK,MAAM,KAAK,CAAC,eAAe,CAAC,UAAU,QAAQ;YACnD,KAAK,MAAM,KAAK,CAAC,eAAe,CAAC,UAAU,QAAQ;YACnD,MAAM;YACN,wBAAwB;YACxB,kBAAkB,2BAA2B;YAC7C,oBAAoB;YACpB,oBAAoB,KAAK,CAAC,mBAAmB;YAC7C,gBAAgB,KAAK,CAAC,eAAe;YACrC,UAAU;YACV,OAAO,MAAM,KAAK,CAAC,eAAe,CAAC;YACnC,MAAM;YACN,UAAW,YAAY,iBAAiB,MAAM,YAAY;YAC1D;;;;MAIA,GACA,eAAgB,YAAY,iBAAiB,OAAO,0BAA0B,YAAY;sBAC1F;QACF;IACF;AACF","sources":["packages/@react-aria/color/src/useColorArea.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaColorAreaProps, ColorChannel} from '@react-types/color';\nimport {ColorAreaState} from '@react-stately/color';\nimport {DOMAttributes, RefObject} from '@react-types/shared';\nimport {focusWithoutScrolling, isAndroid, isIOS, mergeProps, useFormReset, useGlobalListeners, useLabels} from '@react-aria/utils';\n// @ts-ignore\nimport intlMessages from '../intl/*.json';\nimport React, {ChangeEvent, InputHTMLAttributes, useCallback, useRef, useState} from 'react';\nimport {useColorAreaGradient} from './useColorAreaGradient';\nimport {useFocus, useFocusWithin, useKeyboard, useMove} from '@react-aria/interactions';\nimport {useLocale, useLocalizedStringFormatter} from '@react-aria/i18n';\nimport {useVisuallyHidden} from '@react-aria/visually-hidden';\n\nexport interface ColorAreaAria {\n /** Props for the color area container element. */\n colorAreaProps: DOMAttributes,\n /** Props for the thumb element. */\n thumbProps: DOMAttributes,\n /** Props for the visually hidden horizontal range input element. */\n xInputProps: InputHTMLAttributes<HTMLInputElement>,\n /** Props for the visually hidden vertical range input element. */\n yInputProps: InputHTMLAttributes<HTMLInputElement>\n}\n\nexport interface AriaColorAreaOptions extends AriaColorAreaProps {\n /** A ref to the input that represents the x axis of the color area. */\n inputXRef: RefObject<HTMLInputElement | null>,\n /** A ref to the input that represents the y axis of the color area. */\n inputYRef: RefObject<HTMLInputElement | null>,\n /** A ref to the color area containing element. */\n containerRef: RefObject<Element | null>\n}\n\n/**\n * Provides the behavior and accessibility implementation for a color area component.\n * Color area allows users to adjust two channels of an RGB, HSL or HSB color value against a two-dimensional gradient background.\n */\nexport function useColorArea(props: AriaColorAreaOptions, state: ColorAreaState): ColorAreaAria {\n let {\n isDisabled,\n inputXRef,\n inputYRef,\n containerRef,\n 'aria-label': ariaLabel,\n xName,\n yName\n } = props;\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/color');\n\n let {addGlobalListener, removeGlobalListener} = useGlobalListeners();\n\n let {direction, locale} = useLocale();\n\n let [focusedInput, setFocusedInput] = useState<'x' | 'y' | null>(null);\n let focusInput = useCallback((inputRef:RefObject<HTMLInputElement | null> = inputXRef) => {\n if (inputRef.current) {\n focusWithoutScrolling(inputRef.current);\n }\n }, [inputXRef]);\n\n useFormReset(inputXRef, [state.xValue, state.yValue], ([x, y]) => {\n let newColor = state.value\n .withChannelValue(state.channels.xChannel, x)\n .withChannelValue(state.channels.yChannel, y);\n state.setValue(newColor);\n });\n\n let [valueChangedViaKeyboard, setValueChangedViaKeyboard] = useState(false);\n let [valueChangedViaInputChangeEvent, setValueChangedViaInputChangeEvent] = useState(false);\n let {xChannel, yChannel, zChannel} = state.channels;\n let xChannelStep = state.xChannelStep;\n let yChannelStep = state.yChannelStep;\n\n let currentPosition = useRef<{x: number, y: number} | null>(null);\n\n let {keyboardProps} = useKeyboard({\n onKeyDown(e) {\n // these are the cases that useMove doesn't handle\n if (!/^(PageUp|PageDown|Home|End)$/.test(e.key)) {\n e.continuePropagation();\n return;\n }\n // same handling as useMove, don't need to stop propagation, useKeyboard will do that for us\n e.preventDefault();\n // remember to set this and unset it so that onChangeEnd is fired\n state.setDragging(true);\n setValueChangedViaKeyboard(true);\n let dir;\n switch (e.key) {\n case 'PageUp':\n state.incrementY(state.yChannelPageStep);\n dir = 'y';\n break;\n case 'PageDown':\n state.decrementY(state.yChannelPageStep);\n dir = 'y';\n break;\n case 'Home':\n direction === 'rtl' ? state.incrementX(state.xChannelPageStep) : state.decrementX(state.xChannelPageStep);\n dir = 'x';\n break;\n case 'End':\n direction === 'rtl' ? state.decrementX(state.xChannelPageStep) : state.incrementX(state.xChannelPageStep);\n dir = 'x';\n break;\n }\n state.setDragging(false);\n if (dir) {\n let input = dir === 'x' ? inputXRef : inputYRef;\n focusInput(input);\n setFocusedInput(dir);\n }\n }\n });\n\n let moveHandler = {\n onMoveStart() {\n currentPosition.current = null;\n state.setDragging(true);\n },\n onMove({deltaX, deltaY, pointerType, shiftKey}) {\n let {\n incrementX,\n decrementX,\n incrementY,\n decrementY,\n xChannelPageStep,\n xChannelStep,\n yChannelPageStep,\n yChannelStep,\n getThumbPosition,\n setColorFromPoint\n } = state;\n if (currentPosition.current == null) {\n currentPosition.current = getThumbPosition();\n }\n let {width, height} = containerRef.current?.getBoundingClientRect() || {width: 0, height: 0};\n let valueChanged = deltaX !== 0 || deltaY !== 0;\n if (pointerType === 'keyboard') {\n let deltaXValue = shiftKey && xChannelPageStep > xChannelStep ? xChannelPageStep : xChannelStep;\n let deltaYValue = shiftKey && yChannelPageStep > yChannelStep ? yChannelPageStep : yChannelStep;\n if ((deltaX > 0 && direction === 'ltr') || (deltaX < 0 && direction === 'rtl')) {\n incrementX(deltaXValue);\n } else if ((deltaX < 0 && direction === 'ltr') || (deltaX > 0 && direction === 'rtl')) {\n decrementX(deltaXValue);\n } else if (deltaY > 0) {\n decrementY(deltaYValue);\n } else if (deltaY < 0) {\n incrementY(deltaYValue);\n }\n setValueChangedViaKeyboard(valueChanged);\n // set the focused input based on which axis has the greater delta\n focusedInput = valueChanged && Math.abs(deltaY) > Math.abs(deltaX) ? 'y' : 'x';\n setFocusedInput(focusedInput);\n } else {\n currentPosition.current.x += (direction === 'rtl' ? -1 : 1) * deltaX / width ;\n currentPosition.current.y += deltaY / height;\n setColorFromPoint(currentPosition.current.x, currentPosition.current.y);\n }\n },\n onMoveEnd() {\n isOnColorArea.current = false;\n state.setDragging(false);\n let input = focusedInput === 'x' ? inputXRef : inputYRef;\n focusInput(input);\n }\n };\n let {moveProps: movePropsThumb} = useMove(moveHandler);\n\n let {focusWithinProps} = useFocusWithin({\n onFocusWithinChange: (focusWithin:boolean) => {\n if (!focusWithin) {\n setValueChangedViaKeyboard(false);\n setValueChangedViaInputChangeEvent(false);\n }\n }\n });\n\n let currentPointer = useRef<number | null | undefined>(undefined);\n let isOnColorArea = useRef<boolean>(false);\n let {moveProps: movePropsContainer} = useMove({\n onMoveStart() {\n if (isOnColorArea.current) {\n moveHandler.onMoveStart();\n }\n },\n onMove(e) {\n if (isOnColorArea.current) {\n moveHandler.onMove(e);\n }\n },\n onMoveEnd() {\n if (isOnColorArea.current) {\n moveHandler.onMoveEnd();\n }\n }\n });\n\n let onThumbDown = (id: number | null | undefined) => {\n if (!state.isDragging) {\n currentPointer.current = id;\n setValueChangedViaKeyboard(false);\n focusInput();\n state.setDragging(true);\n if (typeof PointerEvent !== 'undefined') {\n addGlobalListener(window, 'pointerup', onThumbUp, false);\n } else {\n addGlobalListener(window, 'mouseup', onThumbUp, false);\n addGlobalListener(window, 'touchend', onThumbUp, false);\n }\n }\n };\n\n let onThumbUp = (e) => {\n let id = e.pointerId ?? e.changedTouches?.[0].identifier;\n if (id === currentPointer.current) {\n setValueChangedViaKeyboard(false);\n focusInput();\n state.setDragging(false);\n currentPointer.current = undefined;\n isOnColorArea.current = false;\n\n if (typeof PointerEvent !== 'undefined') {\n removeGlobalListener(window, 'pointerup', onThumbUp, false);\n } else {\n removeGlobalListener(window, 'mouseup', onThumbUp, false);\n removeGlobalListener(window, 'touchend', onThumbUp, false);\n }\n }\n };\n\n let onColorAreaDown = (colorArea: Element, id: number | null | undefined, clientX: number, clientY: number) => {\n let rect = colorArea.getBoundingClientRect();\n let {width, height} = rect;\n let x = (clientX - rect.x) / width;\n let y = (clientY - rect.y) / height;\n if (direction === 'rtl') {\n x = 1 - x;\n }\n if (x >= 0 && x <= 1 && y >= 0 && y <= 1 && !state.isDragging && currentPointer.current === undefined) {\n isOnColorArea.current = true;\n setValueChangedViaKeyboard(false);\n currentPointer.current = id;\n state.setColorFromPoint(x, y);\n\n focusInput();\n state.setDragging(true);\n\n if (typeof PointerEvent !== 'undefined') {\n addGlobalListener(window, 'pointerup', onColorAreaUp, false);\n } else {\n addGlobalListener(window, 'mouseup', onColorAreaUp, false);\n addGlobalListener(window, 'touchend', onColorAreaUp, false);\n }\n }\n };\n\n let onColorAreaUp = (e) => {\n let id = e.pointerId ?? e.changedTouches?.[0].identifier;\n if (isOnColorArea.current && id === currentPointer.current) {\n isOnColorArea.current = false;\n setValueChangedViaKeyboard(false);\n currentPointer.current = undefined;\n state.setDragging(false);\n focusInput();\n\n if (typeof PointerEvent !== 'undefined') {\n removeGlobalListener(window, 'pointerup', onColorAreaUp, false);\n } else {\n removeGlobalListener(window, 'mouseup', onColorAreaUp, false);\n removeGlobalListener(window, 'touchend', onColorAreaUp, false);\n }\n }\n };\n\n let colorAreaInteractions = isDisabled ? {} : mergeProps({\n ...(typeof PointerEvent !== 'undefined' ? {\n onPointerDown: (e: React.PointerEvent) => {\n if (e.pointerType === 'mouse' && (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey)) {\n return;\n }\n onColorAreaDown(e.currentTarget, e.pointerId, e.clientX, e.clientY);\n }} : {\n onMouseDown: (e: React.MouseEvent) => {\n if (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey) {\n return;\n }\n onColorAreaDown(e.currentTarget, undefined, e.clientX, e.clientY);\n },\n onTouchStart: (e: React.TouchEvent) => {\n onColorAreaDown(e.currentTarget, e.changedTouches[0].identifier, e.changedTouches[0].clientX, e.changedTouches[0].clientY);\n }\n })\n }, movePropsContainer);\n\n let thumbInteractions = isDisabled ? {} : mergeProps({\n ...(typeof PointerEvent !== 'undefined' ? {\n onPointerDown: (e: React.PointerEvent) => {\n if (e.pointerType === 'mouse' && (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey)) {\n return;\n }\n onThumbDown(e.pointerId);\n }} : {\n onMouseDown: (e: React.MouseEvent) => {\n if (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey) {\n return;\n }\n onThumbDown(undefined);\n },\n onTouchStart: (e: React.TouchEvent) => {\n onThumbDown(e.changedTouches[0].identifier);\n }\n })\n }, focusWithinProps, keyboardProps, movePropsThumb);\n\n let {focusProps: xInputFocusProps} = useFocus({\n onFocus: () => {\n setFocusedInput('x');\n }\n });\n\n let {focusProps: yInputFocusProps} = useFocus({\n onFocus: () => {\n setFocusedInput('y');\n }\n });\n\n const onChange = (e: ChangeEvent<HTMLInputElement>) => {\n const {target} = e;\n setValueChangedViaInputChangeEvent(true);\n if (target === inputXRef.current) {\n state.setXValue(parseFloat(target.value));\n } else if (target === inputYRef.current) {\n state.setYValue(parseFloat(target.value));\n }\n };\n\n let isMobile = isIOS() || isAndroid();\n\n let value = state.getDisplayColor();\n const getAriaValueTextForChannel = useCallback((channel:ColorChannel) => {\n const isAfterInput = valueChangedViaInputChangeEvent || valueChangedViaKeyboard;\n return `${\n isAfterInput ?\n stringFormatter.format('colorNameAndValue', {name: value.getChannelName(channel, locale), value: value.formatChannelValue(channel, locale)})\n :\n [\n stringFormatter.format('colorNameAndValue', {name: value.getChannelName(channel, locale), value: value.formatChannelValue(channel, locale)}),\n stringFormatter.format('colorNameAndValue', {name: value.getChannelName(channel === yChannel ? xChannel : yChannel, locale), value: value.formatChannelValue(channel === yChannel ? xChannel : yChannel, locale)}),\n stringFormatter.format('colorNameAndValue', {name: value.getChannelName(zChannel, locale), value: value.formatChannelValue(zChannel, locale)})\n ].join(', ')\n }, ${value.getColorName(locale)}`;\n }, [locale, value, stringFormatter, valueChangedViaInputChangeEvent, valueChangedViaKeyboard, xChannel, yChannel, zChannel]);\n\n let colorPickerLabel = stringFormatter.format('colorPicker');\n\n let xInputLabellingProps = useLabels({\n ...props,\n 'aria-label': ariaLabel ? stringFormatter.format('colorInputLabel', {label: ariaLabel, channelLabel: colorPickerLabel}) : colorPickerLabel\n });\n\n let yInputLabellingProps = useLabels({\n ...props,\n 'aria-label': ariaLabel ? stringFormatter.format('colorInputLabel', {label: ariaLabel, channelLabel: colorPickerLabel}) : colorPickerLabel\n });\n\n let colorAreaLabellingProps = useLabels(\n {\n ...props,\n 'aria-label': ariaLabel ? `${ariaLabel}, ${colorPickerLabel}` : undefined\n },\n isMobile ? colorPickerLabel : undefined\n );\n\n let ariaRoleDescription = stringFormatter.format('twoDimensionalSlider');\n\n let {visuallyHiddenProps} = useVisuallyHidden({style: {\n opacity: '0.0001',\n width: '100%',\n height: '100%',\n pointerEvents: 'none'\n }});\n\n let {\n colorAreaStyleProps,\n thumbStyleProps\n } = useColorAreaGradient({\n direction,\n state,\n xChannel,\n yChannel,\n zChannel\n });\n\n return {\n colorAreaProps: {\n ...colorAreaLabellingProps,\n ...colorAreaInteractions,\n ...colorAreaStyleProps,\n role: 'group'\n },\n thumbProps: {\n ...thumbInteractions,\n ...thumbStyleProps,\n role: 'presentation'\n },\n xInputProps: {\n ...xInputLabellingProps,\n ...visuallyHiddenProps,\n ...xInputFocusProps,\n type: 'range',\n min: state.value.getChannelRange(xChannel).minValue,\n max: state.value.getChannelRange(xChannel).maxValue,\n step: xChannelStep,\n 'aria-roledescription': ariaRoleDescription,\n 'aria-valuetext': getAriaValueTextForChannel(xChannel),\n 'aria-orientation': 'horizontal',\n 'aria-describedby': props['aria-describedby'],\n 'aria-details': props['aria-details'],\n disabled: isDisabled,\n value: state.value.getChannelValue(xChannel),\n name: xName,\n tabIndex: (isMobile || !focusedInput || focusedInput === 'x' ? undefined : -1),\n /*\n So that only a single \"2d slider\" control shows up when listing form elements for screen readers,\n add aria-hidden=\"true\" to the unfocused control when the value has not changed via the keyboard,\n but remove aria-hidden to reveal the input for each channel when the value has changed with the keyboard.\n */\n 'aria-hidden': (isMobile || !focusedInput || focusedInput === 'x' || valueChangedViaKeyboard ? undefined : 'true'),\n onChange\n },\n yInputProps: {\n ...yInputLabellingProps,\n ...visuallyHiddenProps,\n ...yInputFocusProps,\n type: 'range',\n min: state.value.getChannelRange(yChannel).minValue,\n max: state.value.getChannelRange(yChannel).maxValue,\n step: yChannelStep,\n 'aria-roledescription': ariaRoleDescription,\n 'aria-valuetext': getAriaValueTextForChannel(yChannel),\n 'aria-orientation': 'vertical',\n 'aria-describedby': props['aria-describedby'],\n 'aria-details': props['aria-details'],\n disabled: isDisabled,\n value: state.value.getChannelValue(yChannel),\n name: yName,\n tabIndex: (isMobile || focusedInput === 'y' ? undefined : -1),\n /*\n So that only a single \"2d slider\" control shows up when listing form elements for screen readers,\n add aria-hidden=\"true\" to the unfocused input when the value has not changed via the keyboard,\n but remove aria-hidden to reveal the input for each channel when the value has changed with the keyboard.\n */\n 'aria-hidden': (isMobile || focusedInput === 'y' || valueChangedViaKeyboard ? undefined : 'true'),\n onChange\n }\n };\n}\n"],"names":[],"version":3,"file":"useColorArea.module.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;AAsCM,SAAS,0CAAa,KAA2B,EAAE,KAAqB;IAC7E,IAAI,cACF,UAAU,aACV,SAAS,aACT,SAAS,gBACT,YAAY,EACZ,cAAc,SAAS,SACvB,KAAK,SACL,KAAK,QACL,IAAI,EACL,GAAG;IACJ,I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YAAY,iBAAiB,MAAM,YAAY;YAC1D;;;;MAIA,GACA,eAAgB,YAAY,iBAAiB,OAAO,0BAA0B,YAAY;sBAC1F;QACF;IACF;AACF","sources":["packages/@react-aria/color/src/useColorArea.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaColorAreaProps, ColorChannel} from '@react-types/color';\nimport {ColorAreaState} from '@react-stately/color';\nimport {DOMAttributes, RefObject} from '@react-types/shared';\nimport {focusWithoutScrolling, isAndroid, isIOS, mergeProps, useFormReset, useGlobalListeners, useLabels} from '@react-aria/utils';\n// @ts-ignore\nimport intlMessages from '../intl/*.json';\nimport React, {ChangeEvent, InputHTMLAttributes, useCallback, useRef, useState} from 'react';\nimport {useColorAreaGradient} from './useColorAreaGradient';\nimport {useFocus, useFocusWithin, useKeyboard, useMove} from '@react-aria/interactions';\nimport {useLocale, useLocalizedStringFormatter} from '@react-aria/i18n';\nimport {useVisuallyHidden} from '@react-aria/visually-hidden';\n\nexport interface ColorAreaAria {\n /** Props for the color area container element. */\n colorAreaProps: DOMAttributes,\n /** Props for the thumb element. */\n thumbProps: DOMAttributes,\n /** Props for the visually hidden horizontal range input element. */\n xInputProps: InputHTMLAttributes<HTMLInputElement>,\n /** Props for the visually hidden vertical range input element. */\n yInputProps: InputHTMLAttributes<HTMLInputElement>\n}\n\nexport interface AriaColorAreaOptions extends AriaColorAreaProps {\n /** A ref to the input that represents the x axis of the color area. */\n inputXRef: RefObject<HTMLInputElement | null>,\n /** A ref to the input that represents the y axis of the color area. */\n inputYRef: RefObject<HTMLInputElement | null>,\n /** A ref to the color area containing element. */\n containerRef: RefObject<Element | null>\n}\n\n/**\n * Provides the behavior and accessibility implementation for a color area component.\n * Color area allows users to adjust two channels of an RGB, HSL or HSB color value against a two-dimensional gradient background.\n */\nexport function useColorArea(props: AriaColorAreaOptions, state: ColorAreaState): ColorAreaAria {\n let {\n isDisabled,\n inputXRef,\n inputYRef,\n containerRef,\n 'aria-label': ariaLabel,\n xName,\n yName,\n form\n } = props;\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/color');\n\n let {addGlobalListener, removeGlobalListener} = useGlobalListeners();\n\n let {direction, locale} = useLocale();\n\n let [focusedInput, setFocusedInput] = useState<'x' | 'y' | null>(null);\n let focusInput = useCallback((inputRef:RefObject<HTMLInputElement | null> = inputXRef) => {\n if (inputRef.current) {\n focusWithoutScrolling(inputRef.current);\n }\n }, [inputXRef]);\n\n useFormReset(inputXRef, state.defaultValue, state.setValue);\n\n let [valueChangedViaKeyboard, setValueChangedViaKeyboard] = useState(false);\n let [valueChangedViaInputChangeEvent, setValueChangedViaInputChangeEvent] = useState(false);\n let {xChannel, yChannel, zChannel} = state.channels;\n let xChannelStep = state.xChannelStep;\n let yChannelStep = state.yChannelStep;\n\n let currentPosition = useRef<{x: number, y: number} | null>(null);\n\n let {keyboardProps} = useKeyboard({\n onKeyDown(e) {\n // these are the cases that useMove doesn't handle\n if (!/^(PageUp|PageDown|Home|End)$/.test(e.key)) {\n e.continuePropagation();\n return;\n }\n // same handling as useMove, don't need to stop propagation, useKeyboard will do that for us\n e.preventDefault();\n // remember to set this and unset it so that onChangeEnd is fired\n state.setDragging(true);\n setValueChangedViaKeyboard(true);\n let dir;\n switch (e.key) {\n case 'PageUp':\n state.incrementY(state.yChannelPageStep);\n dir = 'y';\n break;\n case 'PageDown':\n state.decrementY(state.yChannelPageStep);\n dir = 'y';\n break;\n case 'Home':\n direction === 'rtl' ? state.incrementX(state.xChannelPageStep) : state.decrementX(state.xChannelPageStep);\n dir = 'x';\n break;\n case 'End':\n direction === 'rtl' ? state.decrementX(state.xChannelPageStep) : state.incrementX(state.xChannelPageStep);\n dir = 'x';\n break;\n }\n state.setDragging(false);\n if (dir) {\n let input = dir === 'x' ? inputXRef : inputYRef;\n focusInput(input);\n setFocusedInput(dir);\n }\n }\n });\n\n let moveHandler = {\n onMoveStart() {\n currentPosition.current = null;\n state.setDragging(true);\n },\n onMove({deltaX, deltaY, pointerType, shiftKey}) {\n let {\n incrementX,\n decrementX,\n incrementY,\n decrementY,\n xChannelPageStep,\n xChannelStep,\n yChannelPageStep,\n yChannelStep,\n getThumbPosition,\n setColorFromPoint\n } = state;\n if (currentPosition.current == null) {\n currentPosition.current = getThumbPosition();\n }\n let {width, height} = containerRef.current?.getBoundingClientRect() || {width: 0, height: 0};\n let valueChanged = deltaX !== 0 || deltaY !== 0;\n if (pointerType === 'keyboard') {\n let deltaXValue = shiftKey && xChannelPageStep > xChannelStep ? xChannelPageStep : xChannelStep;\n let deltaYValue = shiftKey && yChannelPageStep > yChannelStep ? yChannelPageStep : yChannelStep;\n if ((deltaX > 0 && direction === 'ltr') || (deltaX < 0 && direction === 'rtl')) {\n incrementX(deltaXValue);\n } else if ((deltaX < 0 && direction === 'ltr') || (deltaX > 0 && direction === 'rtl')) {\n decrementX(deltaXValue);\n } else if (deltaY > 0) {\n decrementY(deltaYValue);\n } else if (deltaY < 0) {\n incrementY(deltaYValue);\n }\n setValueChangedViaKeyboard(valueChanged);\n // set the focused input based on which axis has the greater delta\n focusedInput = valueChanged && Math.abs(deltaY) > Math.abs(deltaX) ? 'y' : 'x';\n setFocusedInput(focusedInput);\n } else {\n currentPosition.current.x += (direction === 'rtl' ? -1 : 1) * deltaX / width ;\n currentPosition.current.y += deltaY / height;\n setColorFromPoint(currentPosition.current.x, currentPosition.current.y);\n }\n },\n onMoveEnd() {\n isOnColorArea.current = false;\n state.setDragging(false);\n let input = focusedInput === 'x' ? inputXRef : inputYRef;\n focusInput(input);\n }\n };\n let {moveProps: movePropsThumb} = useMove(moveHandler);\n\n let {focusWithinProps} = useFocusWithin({\n onFocusWithinChange: (focusWithin:boolean) => {\n if (!focusWithin) {\n setValueChangedViaKeyboard(false);\n setValueChangedViaInputChangeEvent(false);\n }\n }\n });\n\n let currentPointer = useRef<number | null | undefined>(undefined);\n let isOnColorArea = useRef<boolean>(false);\n let {moveProps: movePropsContainer} = useMove({\n onMoveStart() {\n if (isOnColorArea.current) {\n moveHandler.onMoveStart();\n }\n },\n onMove(e) {\n if (isOnColorArea.current) {\n moveHandler.onMove(e);\n }\n },\n onMoveEnd() {\n if (isOnColorArea.current) {\n moveHandler.onMoveEnd();\n }\n }\n });\n\n let onThumbDown = (id: number | null | undefined) => {\n if (!state.isDragging) {\n currentPointer.current = id;\n setValueChangedViaKeyboard(false);\n focusInput();\n state.setDragging(true);\n if (typeof PointerEvent !== 'undefined') {\n addGlobalListener(window, 'pointerup', onThumbUp, false);\n } else {\n addGlobalListener(window, 'mouseup', onThumbUp, false);\n addGlobalListener(window, 'touchend', onThumbUp, false);\n }\n }\n };\n\n let onThumbUp = (e) => {\n let id = e.pointerId ?? e.changedTouches?.[0].identifier;\n if (id === currentPointer.current) {\n setValueChangedViaKeyboard(false);\n focusInput();\n state.setDragging(false);\n currentPointer.current = undefined;\n isOnColorArea.current = false;\n\n if (typeof PointerEvent !== 'undefined') {\n removeGlobalListener(window, 'pointerup', onThumbUp, false);\n } else {\n removeGlobalListener(window, 'mouseup', onThumbUp, false);\n removeGlobalListener(window, 'touchend', onThumbUp, false);\n }\n }\n };\n\n let onColorAreaDown = (colorArea: Element, id: number | null | undefined, clientX: number, clientY: number) => {\n let rect = colorArea.getBoundingClientRect();\n let {width, height} = rect;\n let x = (clientX - rect.x) / width;\n let y = (clientY - rect.y) / height;\n if (direction === 'rtl') {\n x = 1 - x;\n }\n if (x >= 0 && x <= 1 && y >= 0 && y <= 1 && !state.isDragging && currentPointer.current === undefined) {\n isOnColorArea.current = true;\n setValueChangedViaKeyboard(false);\n currentPointer.current = id;\n state.setColorFromPoint(x, y);\n\n focusInput();\n state.setDragging(true);\n\n if (typeof PointerEvent !== 'undefined') {\n addGlobalListener(window, 'pointerup', onColorAreaUp, false);\n } else {\n addGlobalListener(window, 'mouseup', onColorAreaUp, false);\n addGlobalListener(window, 'touchend', onColorAreaUp, false);\n }\n }\n };\n\n let onColorAreaUp = (e) => {\n let id = e.pointerId ?? e.changedTouches?.[0].identifier;\n if (isOnColorArea.current && id === currentPointer.current) {\n isOnColorArea.current = false;\n setValueChangedViaKeyboard(false);\n currentPointer.current = undefined;\n state.setDragging(false);\n focusInput();\n\n if (typeof PointerEvent !== 'undefined') {\n removeGlobalListener(window, 'pointerup', onColorAreaUp, false);\n } else {\n removeGlobalListener(window, 'mouseup', onColorAreaUp, false);\n removeGlobalListener(window, 'touchend', onColorAreaUp, false);\n }\n }\n };\n\n let colorAreaInteractions = isDisabled ? {} : mergeProps({\n ...(typeof PointerEvent !== 'undefined' ? {\n onPointerDown: (e: React.PointerEvent) => {\n if (e.pointerType === 'mouse' && (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey)) {\n return;\n }\n onColorAreaDown(e.currentTarget, e.pointerId, e.clientX, e.clientY);\n }} : {\n onMouseDown: (e: React.MouseEvent) => {\n if (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey) {\n return;\n }\n onColorAreaDown(e.currentTarget, undefined, e.clientX, e.clientY);\n },\n onTouchStart: (e: React.TouchEvent) => {\n onColorAreaDown(e.currentTarget, e.changedTouches[0].identifier, e.changedTouches[0].clientX, e.changedTouches[0].clientY);\n }\n })\n }, movePropsContainer);\n\n let thumbInteractions = isDisabled ? {} : mergeProps({\n ...(typeof PointerEvent !== 'undefined' ? {\n onPointerDown: (e: React.PointerEvent) => {\n if (e.pointerType === 'mouse' && (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey)) {\n return;\n }\n onThumbDown(e.pointerId);\n }} : {\n onMouseDown: (e: React.MouseEvent) => {\n if (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey) {\n return;\n }\n onThumbDown(undefined);\n },\n onTouchStart: (e: React.TouchEvent) => {\n onThumbDown(e.changedTouches[0].identifier);\n }\n })\n }, focusWithinProps, keyboardProps, movePropsThumb);\n\n let {focusProps: xInputFocusProps} = useFocus({\n onFocus: () => {\n setFocusedInput('x');\n }\n });\n\n let {focusProps: yInputFocusProps} = useFocus({\n onFocus: () => {\n setFocusedInput('y');\n }\n });\n\n const onChange = (e: ChangeEvent<HTMLInputElement>) => {\n const {target} = e;\n setValueChangedViaInputChangeEvent(true);\n if (target === inputXRef.current) {\n state.setXValue(parseFloat(target.value));\n } else if (target === inputYRef.current) {\n state.setYValue(parseFloat(target.value));\n }\n };\n\n let isMobile = isIOS() || isAndroid();\n\n let value = state.getDisplayColor();\n const getAriaValueTextForChannel = useCallback((channel:ColorChannel) => {\n const isAfterInput = valueChangedViaInputChangeEvent || valueChangedViaKeyboard;\n return `${\n isAfterInput ?\n stringFormatter.format('colorNameAndValue', {name: value.getChannelName(channel, locale), value: value.formatChannelValue(channel, locale)})\n :\n [\n stringFormatter.format('colorNameAndValue', {name: value.getChannelName(channel, locale), value: value.formatChannelValue(channel, locale)}),\n stringFormatter.format('colorNameAndValue', {name: value.getChannelName(channel === yChannel ? xChannel : yChannel, locale), value: value.formatChannelValue(channel === yChannel ? xChannel : yChannel, locale)}),\n stringFormatter.format('colorNameAndValue', {name: value.getChannelName(zChannel, locale), value: value.formatChannelValue(zChannel, locale)})\n ].join(', ')\n }, ${value.getColorName(locale)}`;\n }, [locale, value, stringFormatter, valueChangedViaInputChangeEvent, valueChangedViaKeyboard, xChannel, yChannel, zChannel]);\n\n let colorPickerLabel = stringFormatter.format('colorPicker');\n\n let xInputLabellingProps = useLabels({\n ...props,\n 'aria-label': ariaLabel ? stringFormatter.format('colorInputLabel', {label: ariaLabel, channelLabel: colorPickerLabel}) : colorPickerLabel\n });\n\n let yInputLabellingProps = useLabels({\n ...props,\n 'aria-label': ariaLabel ? stringFormatter.format('colorInputLabel', {label: ariaLabel, channelLabel: colorPickerLabel}) : colorPickerLabel\n });\n\n let colorAreaLabellingProps = useLabels(\n {\n ...props,\n 'aria-label': ariaLabel ? `${ariaLabel}, ${colorPickerLabel}` : undefined\n },\n isMobile ? colorPickerLabel : undefined\n );\n\n let ariaRoleDescription = stringFormatter.format('twoDimensionalSlider');\n\n let {visuallyHiddenProps} = useVisuallyHidden({style: {\n opacity: '0.0001',\n width: '100%',\n height: '100%',\n pointerEvents: 'none'\n }});\n\n let {\n colorAreaStyleProps,\n thumbStyleProps\n } = useColorAreaGradient({\n direction,\n state,\n xChannel,\n yChannel,\n zChannel\n });\n\n return {\n colorAreaProps: {\n ...colorAreaLabellingProps,\n ...colorAreaInteractions,\n ...colorAreaStyleProps,\n role: 'group'\n },\n thumbProps: {\n ...thumbInteractions,\n ...thumbStyleProps,\n role: 'presentation'\n },\n xInputProps: {\n ...xInputLabellingProps,\n ...visuallyHiddenProps,\n ...xInputFocusProps,\n type: 'range',\n min: state.value.getChannelRange(xChannel).minValue,\n max: state.value.getChannelRange(xChannel).maxValue,\n step: xChannelStep,\n 'aria-roledescription': ariaRoleDescription,\n 'aria-valuetext': getAriaValueTextForChannel(xChannel),\n 'aria-orientation': 'horizontal',\n 'aria-describedby': props['aria-describedby'],\n 'aria-details': props['aria-details'],\n disabled: isDisabled,\n value: state.value.getChannelValue(xChannel),\n name: xName,\n form,\n tabIndex: (isMobile || !focusedInput || focusedInput === 'x' ? undefined : -1),\n /*\n So that only a single \"2d slider\" control shows up when listing form elements for screen readers,\n add aria-hidden=\"true\" to the unfocused control when the value has not changed via the keyboard,\n but remove aria-hidden to reveal the input for each channel when the value has changed with the keyboard.\n */\n 'aria-hidden': (isMobile || !focusedInput || focusedInput === 'x' || valueChangedViaKeyboard ? undefined : 'true'),\n onChange\n },\n yInputProps: {\n ...yInputLabellingProps,\n ...visuallyHiddenProps,\n ...yInputFocusProps,\n type: 'range',\n min: state.value.getChannelRange(yChannel).minValue,\n max: state.value.getChannelRange(yChannel).maxValue,\n step: yChannelStep,\n 'aria-roledescription': ariaRoleDescription,\n 'aria-valuetext': getAriaValueTextForChannel(yChannel),\n 'aria-orientation': 'vertical',\n 'aria-describedby': props['aria-describedby'],\n 'aria-details': props['aria-details'],\n disabled: isDisabled,\n value: state.value.getChannelValue(yChannel),\n name: yName,\n form,\n tabIndex: (isMobile || focusedInput === 'y' ? undefined : -1),\n /*\n So that only a single \"2d slider\" control shows up when listing form elements for screen readers,\n add aria-hidden=\"true\" to the unfocused input when the value has not changed via the keyboard,\n but remove aria-hidden to reveal the input for each channel when the value has changed with the keyboard.\n */\n 'aria-hidden': (isMobile || focusedInput === 'y' || valueChangedViaKeyboard ? undefined : 'true'),\n onChange\n }\n };\n}\n"],"names":[],"version":3,"file":"useColorArea.module.js.map"}
|
|
@@ -70,13 +70,16 @@ function $58c850037bc7a7ce$export$77e32ca575a28fdf(props, state, ref) {
|
|
|
70
70
|
...props,
|
|
71
71
|
id: inputId,
|
|
72
72
|
value: inputValue,
|
|
73
|
-
|
|
73
|
+
// Intentionally invalid value that will be ignored by onChange during form reset
|
|
74
|
+
// This is handled separately below.
|
|
75
|
+
defaultValue: '!',
|
|
74
76
|
validate: undefined,
|
|
75
77
|
[(0, $grujV$reactstatelyform.privateValidationStateProp)]: state,
|
|
76
78
|
type: 'text',
|
|
77
79
|
autoComplete: 'off',
|
|
78
80
|
onChange: onChange
|
|
79
81
|
}, state, ref);
|
|
82
|
+
(0, $grujV$reactariautils.useFormReset)(ref, state.defaultColorValue, state.setColorValue);
|
|
80
83
|
inputProps = (0, $grujV$reactariautils.mergeProps)(inputProps, spinButtonProps, focusWithinProps, {
|
|
81
84
|
role: 'textbox',
|
|
82
85
|
'aria-valuemax': null,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;AAiCM,SAAS,0CACd,KAA0B,EAC1B,KAAsB,EACtB,GAAuC;IAE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B,EAAE,EAAE;QAC9B,MAAM;QACN,cAAc;kBACd;IACF,GAAG,OAAO;IAEV,aAAa,CAAA,GAAA,gCAAS,EAAE,YAAY,iBAAiB,kBAAkB;QACrE,MAAM;QACN,iBAAiB;QACjB,iBAAiB;QACjB,iBAAiB;QACjB,kBAAkB;QAClB,aAAa;QACb,YAAY;QACZ,QAAQ;IACV;IAEA,IAAI,uBAAuB,UACzB,UAAU,CAAC,gBAAgB,GAAG;IAGhC,OAAO;oBACL;QACA,GAAG,UAAU;IACf;AACF","sources":["packages/@react-aria/color/src/useColorField.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaColorFieldProps} from '@react-types/color';\nimport {ColorFieldState} from '@react-stately/color';\nimport {DOMAttributes, ValidationResult} from '@react-types/shared';\nimport {\n InputHTMLAttributes,\n LabelHTMLAttributes,\n RefObject,\n useCallback,\n useState\n} from 'react';\nimport {mergeProps, useId} from '@react-aria/utils';\nimport {privateValidationStateProp} from '@react-stately/form';\nimport {useFocusWithin, useScrollWheel} from '@react-aria/interactions';\nimport {useFormattedTextField} from '@react-aria/textfield';\nimport {useSpinButton} from '@react-aria/spinbutton';\n\nexport interface ColorFieldAria extends ValidationResult {\n /** Props for the label element. */\n labelProps: LabelHTMLAttributes<HTMLLabelElement>,\n /** Props for the input element. */\n inputProps: InputHTMLAttributes<HTMLInputElement>,\n /** Props for the text field's description element, if any. */\n descriptionProps: DOMAttributes,\n /** Props for the text field's error message element, if any. */\n errorMessageProps: DOMAttributes\n}\n\n/**\n * Provides the behavior and accessibility implementation for a color field component.\n * Color fields allow users to enter and adjust a hex color value.\n */\nexport function useColorField(\n props: AriaColorFieldProps,\n state: ColorFieldState,\n ref: RefObject<HTMLInputElement | null>\n): ColorFieldAria {\n let {\n isDisabled,\n isReadOnly,\n isRequired,\n isWheelDisabled,\n validationBehavior = 'aria'\n } = props;\n\n let {\n colorValue,\n inputValue,\n increment,\n decrement,\n incrementToMax,\n decrementToMin,\n commit\n } = state;\n\n let inputId = useId();\n let {spinButtonProps} = useSpinButton(\n {\n isDisabled,\n isReadOnly,\n isRequired,\n maxValue: 0xFFFFFF,\n minValue: 0,\n onIncrement: increment,\n onIncrementToMax: incrementToMax,\n onDecrement: decrement,\n onDecrementToMin: decrementToMin,\n value: colorValue ? colorValue.toHexInt() : undefined,\n textValue: colorValue ? colorValue.toString('hex') : undefined\n }\n );\n\n let [focusWithin, setFocusWithin] = useState(false);\n let {focusWithinProps} = useFocusWithin({isDisabled, onFocusWithinChange: setFocusWithin});\n\n let onWheel = useCallback((e) => {\n if (Math.abs(e.deltaY) <= Math.abs(e.deltaX)) {\n return;\n }\n if (e.deltaY > 0) {\n increment();\n } else if (e.deltaY < 0) {\n decrement();\n }\n }, [decrement, increment]);\n // If the input isn't supposed to receive input, disable scrolling.\n let scrollingDisabled = isWheelDisabled || isDisabled || isReadOnly || !focusWithin;\n useScrollWheel({onScroll: onWheel, isDisabled: scrollingDisabled}, ref);\n\n let onChange = value => {\n if (state.validate(value)) {\n state.setInputValue(value);\n }\n };\n\n let {inputProps, ...otherProps} = useFormattedTextField({\n ...props,\n id: inputId,\n value: inputValue,\n defaultValue:
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;AAiCM,SAAS,0CACd,KAA0B,EAC1B,KAAsB,EACtB,GAAuC;IAEvC,IAAI,cACF,UAAU,cACV,UAAU,cACV,UAAU,mBACV,eAAe,sBACf,qBAAqB,QACtB,GAAG;IAEJ,IAAI,cACF,UAAU,cACV,UAAU,aACV,SAAS,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,MAAM,iBAAiB,EAAE,MAAM,aAAa;IAE9D,aAAa,CAAA,GAAA,gCAAS,EAAE,YAAY,iBAAiB,kBAAkB;QACrE,MAAM;QACN,iBAAiB;QACjB,iBAAiB;QACjB,iBAAiB;QACjB,kBAAkB;QAClB,aAAa;QACb,YAAY;QACZ,QAAQ;IACV;IAEA,IAAI,uBAAuB,UACzB,UAAU,CAAC,gBAAgB,GAAG;IAGhC,OAAO;oBACL;QACA,GAAG,UAAU;IACf;AACF","sources":["packages/@react-aria/color/src/useColorField.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaColorFieldProps} from '@react-types/color';\nimport {ColorFieldState} from '@react-stately/color';\nimport {DOMAttributes, ValidationResult} from '@react-types/shared';\nimport {\n InputHTMLAttributes,\n LabelHTMLAttributes,\n RefObject,\n useCallback,\n useState\n} from 'react';\nimport {mergeProps, useFormReset, useId} from '@react-aria/utils';\nimport {privateValidationStateProp} from '@react-stately/form';\nimport {useFocusWithin, useScrollWheel} from '@react-aria/interactions';\nimport {useFormattedTextField} from '@react-aria/textfield';\nimport {useSpinButton} from '@react-aria/spinbutton';\n\nexport interface ColorFieldAria extends ValidationResult {\n /** Props for the label element. */\n labelProps: LabelHTMLAttributes<HTMLLabelElement>,\n /** Props for the input element. */\n inputProps: InputHTMLAttributes<HTMLInputElement>,\n /** Props for the text field's description element, if any. */\n descriptionProps: DOMAttributes,\n /** Props for the text field's error message element, if any. */\n errorMessageProps: DOMAttributes\n}\n\n/**\n * Provides the behavior and accessibility implementation for a color field component.\n * Color fields allow users to enter and adjust a hex color value.\n */\nexport function useColorField(\n props: AriaColorFieldProps,\n state: ColorFieldState,\n ref: RefObject<HTMLInputElement | null>\n): ColorFieldAria {\n let {\n isDisabled,\n isReadOnly,\n isRequired,\n isWheelDisabled,\n validationBehavior = 'aria'\n } = props;\n\n let {\n colorValue,\n inputValue,\n increment,\n decrement,\n incrementToMax,\n decrementToMin,\n commit\n } = state;\n\n let inputId = useId();\n let {spinButtonProps} = useSpinButton(\n {\n isDisabled,\n isReadOnly,\n isRequired,\n maxValue: 0xFFFFFF,\n minValue: 0,\n onIncrement: increment,\n onIncrementToMax: incrementToMax,\n onDecrement: decrement,\n onDecrementToMin: decrementToMin,\n value: colorValue ? colorValue.toHexInt() : undefined,\n textValue: colorValue ? colorValue.toString('hex') : undefined\n }\n );\n\n let [focusWithin, setFocusWithin] = useState(false);\n let {focusWithinProps} = useFocusWithin({isDisabled, onFocusWithinChange: setFocusWithin});\n\n let onWheel = useCallback((e) => {\n if (Math.abs(e.deltaY) <= Math.abs(e.deltaX)) {\n return;\n }\n if (e.deltaY > 0) {\n increment();\n } else if (e.deltaY < 0) {\n decrement();\n }\n }, [decrement, increment]);\n // If the input isn't supposed to receive input, disable scrolling.\n let scrollingDisabled = isWheelDisabled || isDisabled || isReadOnly || !focusWithin;\n useScrollWheel({onScroll: onWheel, isDisabled: scrollingDisabled}, ref);\n\n let onChange = value => {\n if (state.validate(value)) {\n state.setInputValue(value);\n }\n };\n\n let {inputProps, ...otherProps} = useFormattedTextField({\n ...props,\n id: inputId,\n value: inputValue,\n // Intentionally invalid value that will be ignored by onChange during form reset\n // This is handled separately below.\n defaultValue: '!',\n validate: undefined,\n [privateValidationStateProp]: state,\n type: 'text',\n autoComplete: 'off',\n onChange\n }, state, ref);\n\n useFormReset(ref, state.defaultColorValue, state.setColorValue);\n\n inputProps = mergeProps(inputProps, spinButtonProps, focusWithinProps, {\n role: 'textbox',\n 'aria-valuemax': null,\n 'aria-valuemin': null,\n 'aria-valuenow': null,\n 'aria-valuetext': null,\n autoCorrect: 'off',\n spellCheck: 'false',\n onBlur: commit\n });\n\n if (validationBehavior === 'native') {\n inputProps['aria-required'] = undefined;\n }\n\n return {\n inputProps,\n ...otherProps\n };\n}\n"],"names":[],"version":3,"file":"useColorField.main.js.map"}
|
package/dist/useColorField.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {useState as $f8mV7$useState, useCallback as $f8mV7$useCallback} from "react";
|
|
2
|
-
import {useId as $f8mV7$useId, mergeProps as $f8mV7$mergeProps} from "@react-aria/utils";
|
|
2
|
+
import {useId as $f8mV7$useId, useFormReset as $f8mV7$useFormReset, mergeProps as $f8mV7$mergeProps} from "@react-aria/utils";
|
|
3
3
|
import {privateValidationStateProp as $f8mV7$privateValidationStateProp} from "@react-stately/form";
|
|
4
4
|
import {useFocusWithin as $f8mV7$useFocusWithin, useScrollWheel as $f8mV7$useScrollWheel} from "@react-aria/interactions";
|
|
5
5
|
import {useFormattedTextField as $f8mV7$useFormattedTextField} from "@react-aria/textfield";
|
|
@@ -64,13 +64,16 @@ function $f6896b05b2ecad12$export$77e32ca575a28fdf(props, state, ref) {
|
|
|
64
64
|
...props,
|
|
65
65
|
id: inputId,
|
|
66
66
|
value: inputValue,
|
|
67
|
-
|
|
67
|
+
// Intentionally invalid value that will be ignored by onChange during form reset
|
|
68
|
+
// This is handled separately below.
|
|
69
|
+
defaultValue: '!',
|
|
68
70
|
validate: undefined,
|
|
69
71
|
[(0, $f8mV7$privateValidationStateProp)]: state,
|
|
70
72
|
type: 'text',
|
|
71
73
|
autoComplete: 'off',
|
|
72
74
|
onChange: onChange
|
|
73
75
|
}, state, ref);
|
|
76
|
+
(0, $f8mV7$useFormReset)(ref, state.defaultColorValue, state.setColorValue);
|
|
74
77
|
inputProps = (0, $f8mV7$mergeProps)(inputProps, spinButtonProps, focusWithinProps, {
|
|
75
78
|
role: 'textbox',
|
|
76
79
|
'aria-valuemax': null,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {useState as $f8mV7$useState, useCallback as $f8mV7$useCallback} from "react";
|
|
2
|
-
import {useId as $f8mV7$useId, mergeProps as $f8mV7$mergeProps} from "@react-aria/utils";
|
|
2
|
+
import {useId as $f8mV7$useId, useFormReset as $f8mV7$useFormReset, mergeProps as $f8mV7$mergeProps} from "@react-aria/utils";
|
|
3
3
|
import {privateValidationStateProp as $f8mV7$privateValidationStateProp} from "@react-stately/form";
|
|
4
4
|
import {useFocusWithin as $f8mV7$useFocusWithin, useScrollWheel as $f8mV7$useScrollWheel} from "@react-aria/interactions";
|
|
5
5
|
import {useFormattedTextField as $f8mV7$useFormattedTextField} from "@react-aria/textfield";
|
|
@@ -64,13 +64,16 @@ function $f6896b05b2ecad12$export$77e32ca575a28fdf(props, state, ref) {
|
|
|
64
64
|
...props,
|
|
65
65
|
id: inputId,
|
|
66
66
|
value: inputValue,
|
|
67
|
-
|
|
67
|
+
// Intentionally invalid value that will be ignored by onChange during form reset
|
|
68
|
+
// This is handled separately below.
|
|
69
|
+
defaultValue: '!',
|
|
68
70
|
validate: undefined,
|
|
69
71
|
[(0, $f8mV7$privateValidationStateProp)]: state,
|
|
70
72
|
type: 'text',
|
|
71
73
|
autoComplete: 'off',
|
|
72
74
|
onChange: onChange
|
|
73
75
|
}, state, ref);
|
|
76
|
+
(0, $f8mV7$useFormReset)(ref, state.defaultColorValue, state.setColorValue);
|
|
74
77
|
inputProps = (0, $f8mV7$mergeProps)(inputProps, spinButtonProps, focusWithinProps, {
|
|
75
78
|
role: 'textbox',
|
|
76
79
|
'aria-valuemax': null,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;AAiCM,SAAS,0CACd,KAA0B,EAC1B,KAAsB,EACtB,GAAuC;IAEvC,IAAI,cACF,UAAU,cACV,UAAU,cACV,UAAU,mBACV,eAAe,sBACf,qBAAqB,QACtB,GAAG;IAEJ,IAAI,cACF,UAAU,cACV,UAAU,a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B;QACrE,MAAM;QACN,iBAAiB;QACjB,iBAAiB;QACjB,iBAAiB;QACjB,kBAAkB;QAClB,aAAa;QACb,YAAY;QACZ,QAAQ;IACV;IAEA,IAAI,uBAAuB,UACzB,UAAU,CAAC,gBAAgB,GAAG;IAGhC,OAAO;oBACL;QACA,GAAG,UAAU;IACf;AACF","sources":["packages/@react-aria/color/src/useColorField.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaColorFieldProps} from '@react-types/color';\nimport {ColorFieldState} from '@react-stately/color';\nimport {DOMAttributes, ValidationResult} from '@react-types/shared';\nimport {\n InputHTMLAttributes,\n LabelHTMLAttributes,\n RefObject,\n useCallback,\n useState\n} from 'react';\nimport {mergeProps, useId} from '@react-aria/utils';\nimport {privateValidationStateProp} from '@react-stately/form';\nimport {useFocusWithin, useScrollWheel} from '@react-aria/interactions';\nimport {useFormattedTextField} from '@react-aria/textfield';\nimport {useSpinButton} from '@react-aria/spinbutton';\n\nexport interface ColorFieldAria extends ValidationResult {\n /** Props for the label element. */\n labelProps: LabelHTMLAttributes<HTMLLabelElement>,\n /** Props for the input element. */\n inputProps: InputHTMLAttributes<HTMLInputElement>,\n /** Props for the text field's description element, if any. */\n descriptionProps: DOMAttributes,\n /** Props for the text field's error message element, if any. */\n errorMessageProps: DOMAttributes\n}\n\n/**\n * Provides the behavior and accessibility implementation for a color field component.\n * Color fields allow users to enter and adjust a hex color value.\n */\nexport function useColorField(\n props: AriaColorFieldProps,\n state: ColorFieldState,\n ref: RefObject<HTMLInputElement | null>\n): ColorFieldAria {\n let {\n isDisabled,\n isReadOnly,\n isRequired,\n isWheelDisabled,\n validationBehavior = 'aria'\n } = props;\n\n let {\n colorValue,\n inputValue,\n increment,\n decrement,\n incrementToMax,\n decrementToMin,\n commit\n } = state;\n\n let inputId = useId();\n let {spinButtonProps} = useSpinButton(\n {\n isDisabled,\n isReadOnly,\n isRequired,\n maxValue: 0xFFFFFF,\n minValue: 0,\n onIncrement: increment,\n onIncrementToMax: incrementToMax,\n onDecrement: decrement,\n onDecrementToMin: decrementToMin,\n value: colorValue ? colorValue.toHexInt() : undefined,\n textValue: colorValue ? colorValue.toString('hex') : undefined\n }\n );\n\n let [focusWithin, setFocusWithin] = useState(false);\n let {focusWithinProps} = useFocusWithin({isDisabled, onFocusWithinChange: setFocusWithin});\n\n let onWheel = useCallback((e) => {\n if (Math.abs(e.deltaY) <= Math.abs(e.deltaX)) {\n return;\n }\n if (e.deltaY > 0) {\n increment();\n } else if (e.deltaY < 0) {\n decrement();\n }\n }, [decrement, increment]);\n // If the input isn't supposed to receive input, disable scrolling.\n let scrollingDisabled = isWheelDisabled || isDisabled || isReadOnly || !focusWithin;\n useScrollWheel({onScroll: onWheel, isDisabled: scrollingDisabled}, ref);\n\n let onChange = value => {\n if (state.validate(value)) {\n state.setInputValue(value);\n }\n };\n\n let {inputProps, ...otherProps} = useFormattedTextField({\n ...props,\n id: inputId,\n value: inputValue,\n defaultValue:
|
|
1
|
+
{"mappings":";;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;AAiCM,SAAS,0CACd,KAA0B,EAC1B,KAAsB,EACtB,GAAuC;IAEvC,IAAI,cACF,UAAU,cACV,UAAU,cACV,UAAU,mBACV,eAAe,sBACf,qBAAqB,QACtB,GAAG;IAEJ,IAAI,cACF,UAAU,cACV,UAAU,aACV,SAAS,aACT,SAAS,kBACT,cAAc,kBACd,cAAc,UACd,MAAM,EACP,GAAG;IAEJ,IAAI,UAAU,CAAA,GAAA,YAAI;IAClB,IAAI,mBAAC,eAAe,EAAC,G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AAiB;QACjB,iBAAiB;QACjB,kBAAkB;QAClB,aAAa;QACb,YAAY;QACZ,QAAQ;IACV;IAEA,IAAI,uBAAuB,UACzB,UAAU,CAAC,gBAAgB,GAAG;IAGhC,OAAO;oBACL;QACA,GAAG,UAAU;IACf;AACF","sources":["packages/@react-aria/color/src/useColorField.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaColorFieldProps} from '@react-types/color';\nimport {ColorFieldState} from '@react-stately/color';\nimport {DOMAttributes, ValidationResult} from '@react-types/shared';\nimport {\n InputHTMLAttributes,\n LabelHTMLAttributes,\n RefObject,\n useCallback,\n useState\n} from 'react';\nimport {mergeProps, useFormReset, useId} from '@react-aria/utils';\nimport {privateValidationStateProp} from '@react-stately/form';\nimport {useFocusWithin, useScrollWheel} from '@react-aria/interactions';\nimport {useFormattedTextField} from '@react-aria/textfield';\nimport {useSpinButton} from '@react-aria/spinbutton';\n\nexport interface ColorFieldAria extends ValidationResult {\n /** Props for the label element. */\n labelProps: LabelHTMLAttributes<HTMLLabelElement>,\n /** Props for the input element. */\n inputProps: InputHTMLAttributes<HTMLInputElement>,\n /** Props for the text field's description element, if any. */\n descriptionProps: DOMAttributes,\n /** Props for the text field's error message element, if any. */\n errorMessageProps: DOMAttributes\n}\n\n/**\n * Provides the behavior and accessibility implementation for a color field component.\n * Color fields allow users to enter and adjust a hex color value.\n */\nexport function useColorField(\n props: AriaColorFieldProps,\n state: ColorFieldState,\n ref: RefObject<HTMLInputElement | null>\n): ColorFieldAria {\n let {\n isDisabled,\n isReadOnly,\n isRequired,\n isWheelDisabled,\n validationBehavior = 'aria'\n } = props;\n\n let {\n colorValue,\n inputValue,\n increment,\n decrement,\n incrementToMax,\n decrementToMin,\n commit\n } = state;\n\n let inputId = useId();\n let {spinButtonProps} = useSpinButton(\n {\n isDisabled,\n isReadOnly,\n isRequired,\n maxValue: 0xFFFFFF,\n minValue: 0,\n onIncrement: increment,\n onIncrementToMax: incrementToMax,\n onDecrement: decrement,\n onDecrementToMin: decrementToMin,\n value: colorValue ? colorValue.toHexInt() : undefined,\n textValue: colorValue ? colorValue.toString('hex') : undefined\n }\n );\n\n let [focusWithin, setFocusWithin] = useState(false);\n let {focusWithinProps} = useFocusWithin({isDisabled, onFocusWithinChange: setFocusWithin});\n\n let onWheel = useCallback((e) => {\n if (Math.abs(e.deltaY) <= Math.abs(e.deltaX)) {\n return;\n }\n if (e.deltaY > 0) {\n increment();\n } else if (e.deltaY < 0) {\n decrement();\n }\n }, [decrement, increment]);\n // If the input isn't supposed to receive input, disable scrolling.\n let scrollingDisabled = isWheelDisabled || isDisabled || isReadOnly || !focusWithin;\n useScrollWheel({onScroll: onWheel, isDisabled: scrollingDisabled}, ref);\n\n let onChange = value => {\n if (state.validate(value)) {\n state.setInputValue(value);\n }\n };\n\n let {inputProps, ...otherProps} = useFormattedTextField({\n ...props,\n id: inputId,\n value: inputValue,\n // Intentionally invalid value that will be ignored by onChange during form reset\n // This is handled separately below.\n defaultValue: '!',\n validate: undefined,\n [privateValidationStateProp]: state,\n type: 'text',\n autoComplete: 'off',\n onChange\n }, state, ref);\n\n useFormReset(ref, state.defaultColorValue, state.setColorValue);\n\n inputProps = mergeProps(inputProps, spinButtonProps, focusWithinProps, {\n role: 'textbox',\n 'aria-valuemax': null,\n 'aria-valuemin': null,\n 'aria-valuenow': null,\n 'aria-valuetext': null,\n autoCorrect: 'off',\n spellCheck: 'false',\n onBlur: commit\n });\n\n if (validationBehavior === 'native') {\n inputProps['aria-required'] = undefined;\n }\n\n return {\n inputProps,\n ...otherProps\n };\n}\n"],"names":[],"version":3,"file":"useColorField.module.js.map"}
|
|
@@ -24,7 +24,7 @@ $parcel$export(module.exports, "useColorSlider", () => $afbb9647440a7f5b$export$
|
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
function $afbb9647440a7f5b$export$106b7a4e66508f66(props, state) {
|
|
27
|
-
let { trackRef: trackRef, inputRef: inputRef, orientation: orientation, channel: channel, 'aria-label': ariaLabel, name: name } = props;
|
|
27
|
+
let { trackRef: trackRef, inputRef: inputRef, orientation: orientation, channel: channel, 'aria-label': ariaLabel, name: name, form: form } = props;
|
|
28
28
|
let { locale: locale, direction: direction } = (0, $edxco$reactariai18n.useLocale)();
|
|
29
29
|
// Provide a default aria-label if there is no other label provided.
|
|
30
30
|
if (!props.label && !ariaLabel && !props['aria-labelledby']) ariaLabel = state.value.getChannelName(channel, locale);
|
|
@@ -38,6 +38,7 @@ function $afbb9647440a7f5b$export$106b7a4e66508f66(props, state) {
|
|
|
38
38
|
orientation: orientation,
|
|
39
39
|
isDisabled: props.isDisabled,
|
|
40
40
|
name: name,
|
|
41
|
+
form: form,
|
|
41
42
|
trackRef: trackRef,
|
|
42
43
|
inputRef: inputRef
|
|
43
44
|
}, state);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;AAmCM,SAAS,0CAAe,KAA6B,EAAE,KAAuB;IACnF,IAAI,YAAC,QAAQ,YAAE,QAAQ,eAAE,WAAW,WAAE,OAAO,EAAE,cAAc,SAAS,QAAE,IAAI,EAAC,GAAG;
|
|
1
|
+
{"mappings":";;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;AAmCM,SAAS,0CAAe,KAA6B,EAAE,KAAuB;IACnF,IAAI,YAAC,QAAQ,YAAE,QAAQ,eAAE,WAAW,WAAE,OAAO,EAAE,cAAc,SAAS,QAAE,IAAI,QAAE,IAAI,EAAC,GAAG;IAEtF,IAAI,UAAC,MAAM,aAAE,SAAS,E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C/B;QACF;oBACA;qBACA;IACF;AACF","sources":["packages/@react-aria/color/src/useColorSlider.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaColorSliderProps} from '@react-types/color';\nimport {ColorSliderState} from '@react-stately/color';\nimport {DOMAttributes, RefObject} from '@react-types/shared';\nimport {InputHTMLAttributes} from 'react';\nimport {mergeProps} from '@react-aria/utils';\nimport {useLocale} from '@react-aria/i18n';\nimport {useSlider, useSliderThumb} from '@react-aria/slider';\nimport {useVisuallyHidden} from '@react-aria/visually-hidden';\n\nexport interface AriaColorSliderOptions extends AriaColorSliderProps {\n /** A ref for the track element. */\n trackRef: RefObject<Element | null>,\n /** A ref for the input element. */\n inputRef: RefObject<HTMLInputElement | null>\n}\n\nexport interface ColorSliderAria {\n /** Props for the label element. */\n labelProps: DOMAttributes,\n /** Props for the track element. */\n trackProps: DOMAttributes,\n /** Props for the thumb element. */\n thumbProps: DOMAttributes,\n /** Props for the visually hidden range input element. */\n inputProps: InputHTMLAttributes<HTMLInputElement>,\n /** Props for the output element, displaying the value of the color slider. */\n outputProps: DOMAttributes\n}\n\n/**\n * Provides the behavior and accessibility implementation for a color slider component.\n * Color sliders allow users to adjust an individual channel of a color value.\n */\nexport function useColorSlider(props: AriaColorSliderOptions, state: ColorSliderState): ColorSliderAria {\n let {trackRef, inputRef, orientation, channel, 'aria-label': ariaLabel, name, form} = props;\n\n let {locale, direction} = useLocale();\n\n // Provide a default aria-label if there is no other label provided.\n if (!props.label && !ariaLabel && !props['aria-labelledby']) {\n ariaLabel = state.value.getChannelName(channel, locale);\n }\n\n // @ts-ignore - ignore unused incompatible props\n let {groupProps, trackProps, labelProps, outputProps} = useSlider({...props, 'aria-label': ariaLabel}, state, trackRef);\n let {inputProps, thumbProps} = useSliderThumb({\n index: 0,\n orientation,\n isDisabled: props.isDisabled,\n name,\n form,\n trackRef,\n inputRef\n }, state);\n\n let value = state.getDisplayColor();\n let generateBackground = () => {\n let to: string;\n if (orientation === 'vertical') {\n to = 'top';\n } else if (direction === 'ltr') {\n to = 'right';\n } else {\n to = 'left';\n }\n switch (channel) {\n case 'hue': {\n let stops = [0, 60, 120, 180, 240, 300, 360].map(hue => value.withChannelValue('hue', hue).toString('css')).join(', ');\n return `linear-gradient(to ${to}, ${stops})`;\n }\n case 'lightness': {\n // We have to add an extra color stop in the middle so that the hue shows up at all.\n // Otherwise it will always just be black to white.\n let min = state.getThumbMinValue(0);\n let max = state.getThumbMaxValue(0);\n let start = value.withChannelValue(channel, min).toString('css');\n let middle = value.withChannelValue(channel, (max - min) / 2).toString('css');\n let end = value.withChannelValue(channel, max).toString('css');\n return `linear-gradient(to ${to}, ${start}, ${middle}, ${end})`;\n }\n case 'saturation':\n case 'brightness':\n case 'red':\n case 'green':\n case 'blue':\n case 'alpha': {\n let start = value.withChannelValue(channel, state.getThumbMinValue(0)).toString('css');\n let end = value.withChannelValue(channel, state.getThumbMaxValue(0)).toString('css');\n return `linear-gradient(to ${to}, ${start}, ${end})`;\n }\n default:\n throw new Error('Unknown color channel: ' + channel);\n }\n };\n\n let forcedColorAdjustNoneStyle = {forcedColorAdjust: 'none'};\n\n if (channel === 'hue') {\n inputProps['aria-valuetext'] += `, ${value.getHueName(locale)}`;\n } else if (channel !== 'alpha') {\n inputProps['aria-valuetext'] += `, ${value.getColorName(locale)}`;\n }\n\n let {visuallyHiddenProps} = useVisuallyHidden({\n style: {\n opacity: '0.0001',\n width: '100%',\n height: '100%',\n pointerEvents: 'none'\n }\n });\n\n return {\n trackProps: {\n ...mergeProps(groupProps, trackProps),\n style: {\n ...trackProps.style,\n ...forcedColorAdjustNoneStyle,\n background: generateBackground()\n }\n },\n inputProps: {\n ...inputProps,\n style: {\n ...inputProps.style,\n ...visuallyHiddenProps.style\n }\n },\n thumbProps: {\n ...thumbProps,\n style: {\n ...thumbProps.style,\n ...forcedColorAdjustNoneStyle\n }\n },\n labelProps,\n outputProps\n };\n}\n"],"names":[],"version":3,"file":"useColorSlider.main.js.map"}
|
package/dist/useColorSlider.mjs
CHANGED
|
@@ -18,7 +18,7 @@ import {useVisuallyHidden as $6WsjB$useVisuallyHidden} from "@react-aria/visuall
|
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
function $40af666d6c251e36$export$106b7a4e66508f66(props, state) {
|
|
21
|
-
let { trackRef: trackRef, inputRef: inputRef, orientation: orientation, channel: channel, 'aria-label': ariaLabel, name: name } = props;
|
|
21
|
+
let { trackRef: trackRef, inputRef: inputRef, orientation: orientation, channel: channel, 'aria-label': ariaLabel, name: name, form: form } = props;
|
|
22
22
|
let { locale: locale, direction: direction } = (0, $6WsjB$useLocale)();
|
|
23
23
|
// Provide a default aria-label if there is no other label provided.
|
|
24
24
|
if (!props.label && !ariaLabel && !props['aria-labelledby']) ariaLabel = state.value.getChannelName(channel, locale);
|
|
@@ -32,6 +32,7 @@ function $40af666d6c251e36$export$106b7a4e66508f66(props, state) {
|
|
|
32
32
|
orientation: orientation,
|
|
33
33
|
isDisabled: props.isDisabled,
|
|
34
34
|
name: name,
|
|
35
|
+
form: form,
|
|
35
36
|
trackRef: trackRef,
|
|
36
37
|
inputRef: inputRef
|
|
37
38
|
}, state);
|
|
@@ -18,7 +18,7 @@ import {useVisuallyHidden as $6WsjB$useVisuallyHidden} from "@react-aria/visuall
|
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
function $40af666d6c251e36$export$106b7a4e66508f66(props, state) {
|
|
21
|
-
let { trackRef: trackRef, inputRef: inputRef, orientation: orientation, channel: channel, 'aria-label': ariaLabel, name: name } = props;
|
|
21
|
+
let { trackRef: trackRef, inputRef: inputRef, orientation: orientation, channel: channel, 'aria-label': ariaLabel, name: name, form: form } = props;
|
|
22
22
|
let { locale: locale, direction: direction } = (0, $6WsjB$useLocale)();
|
|
23
23
|
// Provide a default aria-label if there is no other label provided.
|
|
24
24
|
if (!props.label && !ariaLabel && !props['aria-labelledby']) ariaLabel = state.value.getChannelName(channel, locale);
|
|
@@ -32,6 +32,7 @@ function $40af666d6c251e36$export$106b7a4e66508f66(props, state) {
|
|
|
32
32
|
orientation: orientation,
|
|
33
33
|
isDisabled: props.isDisabled,
|
|
34
34
|
name: name,
|
|
35
|
+
form: form,
|
|
35
36
|
trackRef: trackRef,
|
|
36
37
|
inputRef: inputRef
|
|
37
38
|
}, state);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;AAAA;;;;;;;;;;CAUC;;;;AAmCM,SAAS,0CAAe,KAA6B,EAAE,KAAuB;IACnF,IAAI,YAAC,QAAQ,YAAE,QAAQ,eAAE,WAAW,WAAE,OAAO,EAAE,cAAc,SAAS,QAAE,IAAI,EAAC,GAAG;
|
|
1
|
+
{"mappings":";;;;;AAAA;;;;;;;;;;CAUC;;;;AAmCM,SAAS,0CAAe,KAA6B,EAAE,KAAuB;IACnF,IAAI,YAAC,QAAQ,YAAE,QAAQ,eAAE,WAAW,WAAE,OAAO,EAAE,cAAc,SAAS,QAAE,IAAI,QAAE,IAAI,EAAC,GAAG;IAEtF,IAAI,UAAC,MAAM,aAAE,SAAS,EAAC,GAAG,CAAA,GAAA,gBAAQ;IAElC,oEAAoE;IACpE,IAAI,CAAC,MAAM,KAAK,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,kBAAkB,EACzD,YAAY,MAAM,KAAK,CAAC,cAAc,CAAC,SAAS;IAGlD,gDAAgD;IAChD,IAAI,cAAC,UAAU,cAAE,UAAU,cAAE,UAAU,eAAE,WAAW,EAAC,GAAG,CAAA,GAAA,gBAAQ,EAAE;QAAC,GAAG,KAAK;QAAE,cAAc;IA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,MAAM,gBAAgB,CAAC,SAAS,MAAM,gBAAgB,CAAC,IAAI,QAAQ,CAAC;oBAC9E,OAAO,CAAC,mBAAmB,EAAE,GAAG,EAAE,EAAE,MAAM,EAAE,EAAE,IAAI,CAAC,CAAC;gBACtD;YACA;gBACE,MAAM,IAAI,MAAM,4BAA4B;QAChD;IACF;IAEA,IAAI,6BAA6B;QAAC,mBAAmB;IAAM;IAE3D,IAAI,YAAY,OACd,UAAU,CAAC,iBAAiB,IAAI,CAAC,EAAE,EAAE,MAAM,UAAU,CAAC,SAAS;SAC1D,IAAI,YAAY,SACrB,UAAU,CAAC,iBAAiB,IAAI,CAAC,EAAE,EAAE,MAAM,YAAY,CAAC,SAAS;IAGnE,IAAI,uBAAC,mBAAmB,EAAC,GAAG,CAAA,GAAA,wBAAgB,EAAE;QAC5C,OAAO;YACL,SAAS;YACT,OAAO;YACP,QAAQ;YACR,eAAe;QACjB;IACF;IAEA,OAAO;QACL,YAAY;YACV,GAAG,CAAA,GAAA,iBAAS,EAAE,YAAY,WAAW;YACrC,OAAO;gBACL,GAAG,WAAW,KAAK;gBACnB,GAAG,0BAA0B;gBAC7B,YAAY;YACd;QACF;QACA,YAAY;YACV,GAAG,UAAU;YACb,OAAO;gBACL,GAAG,WAAW,KAAK;gBACnB,GAAG,oBAAoB,KAAK;YAC9B;QACF;QACA,YAAY;YACV,GAAG,UAAU;YACb,OAAO;gBACL,GAAG,WAAW,KAAK;gBACnB,GAAG,0BAA0B;YAC/B;QACF;oBACA;qBACA;IACF;AACF","sources":["packages/@react-aria/color/src/useColorSlider.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaColorSliderProps} from '@react-types/color';\nimport {ColorSliderState} from '@react-stately/color';\nimport {DOMAttributes, RefObject} from '@react-types/shared';\nimport {InputHTMLAttributes} from 'react';\nimport {mergeProps} from '@react-aria/utils';\nimport {useLocale} from '@react-aria/i18n';\nimport {useSlider, useSliderThumb} from '@react-aria/slider';\nimport {useVisuallyHidden} from '@react-aria/visually-hidden';\n\nexport interface AriaColorSliderOptions extends AriaColorSliderProps {\n /** A ref for the track element. */\n trackRef: RefObject<Element | null>,\n /** A ref for the input element. */\n inputRef: RefObject<HTMLInputElement | null>\n}\n\nexport interface ColorSliderAria {\n /** Props for the label element. */\n labelProps: DOMAttributes,\n /** Props for the track element. */\n trackProps: DOMAttributes,\n /** Props for the thumb element. */\n thumbProps: DOMAttributes,\n /** Props for the visually hidden range input element. */\n inputProps: InputHTMLAttributes<HTMLInputElement>,\n /** Props for the output element, displaying the value of the color slider. */\n outputProps: DOMAttributes\n}\n\n/**\n * Provides the behavior and accessibility implementation for a color slider component.\n * Color sliders allow users to adjust an individual channel of a color value.\n */\nexport function useColorSlider(props: AriaColorSliderOptions, state: ColorSliderState): ColorSliderAria {\n let {trackRef, inputRef, orientation, channel, 'aria-label': ariaLabel, name, form} = props;\n\n let {locale, direction} = useLocale();\n\n // Provide a default aria-label if there is no other label provided.\n if (!props.label && !ariaLabel && !props['aria-labelledby']) {\n ariaLabel = state.value.getChannelName(channel, locale);\n }\n\n // @ts-ignore - ignore unused incompatible props\n let {groupProps, trackProps, labelProps, outputProps} = useSlider({...props, 'aria-label': ariaLabel}, state, trackRef);\n let {inputProps, thumbProps} = useSliderThumb({\n index: 0,\n orientation,\n isDisabled: props.isDisabled,\n name,\n form,\n trackRef,\n inputRef\n }, state);\n\n let value = state.getDisplayColor();\n let generateBackground = () => {\n let to: string;\n if (orientation === 'vertical') {\n to = 'top';\n } else if (direction === 'ltr') {\n to = 'right';\n } else {\n to = 'left';\n }\n switch (channel) {\n case 'hue': {\n let stops = [0, 60, 120, 180, 240, 300, 360].map(hue => value.withChannelValue('hue', hue).toString('css')).join(', ');\n return `linear-gradient(to ${to}, ${stops})`;\n }\n case 'lightness': {\n // We have to add an extra color stop in the middle so that the hue shows up at all.\n // Otherwise it will always just be black to white.\n let min = state.getThumbMinValue(0);\n let max = state.getThumbMaxValue(0);\n let start = value.withChannelValue(channel, min).toString('css');\n let middle = value.withChannelValue(channel, (max - min) / 2).toString('css');\n let end = value.withChannelValue(channel, max).toString('css');\n return `linear-gradient(to ${to}, ${start}, ${middle}, ${end})`;\n }\n case 'saturation':\n case 'brightness':\n case 'red':\n case 'green':\n case 'blue':\n case 'alpha': {\n let start = value.withChannelValue(channel, state.getThumbMinValue(0)).toString('css');\n let end = value.withChannelValue(channel, state.getThumbMaxValue(0)).toString('css');\n return `linear-gradient(to ${to}, ${start}, ${end})`;\n }\n default:\n throw new Error('Unknown color channel: ' + channel);\n }\n };\n\n let forcedColorAdjustNoneStyle = {forcedColorAdjust: 'none'};\n\n if (channel === 'hue') {\n inputProps['aria-valuetext'] += `, ${value.getHueName(locale)}`;\n } else if (channel !== 'alpha') {\n inputProps['aria-valuetext'] += `, ${value.getColorName(locale)}`;\n }\n\n let {visuallyHiddenProps} = useVisuallyHidden({\n style: {\n opacity: '0.0001',\n width: '100%',\n height: '100%',\n pointerEvents: 'none'\n }\n });\n\n return {\n trackProps: {\n ...mergeProps(groupProps, trackProps),\n style: {\n ...trackProps.style,\n ...forcedColorAdjustNoneStyle,\n background: generateBackground()\n }\n },\n inputProps: {\n ...inputProps,\n style: {\n ...inputProps.style,\n ...visuallyHiddenProps.style\n }\n },\n thumbProps: {\n ...thumbProps,\n style: {\n ...thumbProps.style,\n ...forcedColorAdjustNoneStyle\n }\n },\n labelProps,\n outputProps\n };\n}\n"],"names":[],"version":3,"file":"useColorSlider.module.js.map"}
|
|
@@ -26,7 +26,7 @@ $parcel$export(module.exports, "useColorWheel", () => $1d29bf243d4a9a53$export$9
|
|
|
26
26
|
|
|
27
27
|
|
|
28
28
|
function $1d29bf243d4a9a53$export$9064ff4e44b3729a(props, state, inputRef) {
|
|
29
|
-
let { isDisabled: isDisabled, innerRadius: innerRadius, outerRadius: outerRadius, 'aria-label': ariaLabel, name: name } = props;
|
|
29
|
+
let { isDisabled: isDisabled, innerRadius: innerRadius, outerRadius: outerRadius, 'aria-label': ariaLabel, name: name, form: form } = props;
|
|
30
30
|
let { addGlobalListener: addGlobalListener, removeGlobalListener: removeGlobalListener } = (0, $iWAp3$reactariautils.useGlobalListeners)();
|
|
31
31
|
let thumbRadius = (innerRadius + outerRadius) / 2;
|
|
32
32
|
let focusInput = (0, $iWAp3$react.useCallback)(()=>{
|
|
@@ -34,7 +34,7 @@ function $1d29bf243d4a9a53$export$9064ff4e44b3729a(props, state, inputRef) {
|
|
|
34
34
|
}, [
|
|
35
35
|
inputRef
|
|
36
36
|
]);
|
|
37
|
-
(0, $iWAp3$reactariautils.useFormReset)(inputRef, state.
|
|
37
|
+
(0, $iWAp3$reactariautils.useFormReset)(inputRef, state.defaultValue, state.setValue);
|
|
38
38
|
let currentPosition = (0, $iWAp3$react.useRef)(null);
|
|
39
39
|
let { keyboardProps: keyboardProps } = (0, $iWAp3$reactariainteractions.useKeyboard)({
|
|
40
40
|
onKeyDown (e) {
|
|
@@ -255,6 +255,7 @@ function $1d29bf243d4a9a53$export$9064ff4e44b3729a(props, state, inputRef) {
|
|
|
255
255
|
disabled: isDisabled,
|
|
256
256
|
value: `${state.value.getChannelValue('hue')}`,
|
|
257
257
|
name: name,
|
|
258
|
+
form: form,
|
|
258
259
|
onChange: (e)=>{
|
|
259
260
|
state.setHue(parseFloat(e.target.value));
|
|
260
261
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;AA+BM,SAAS,0CAAc,KAA4B,EAAE,KAAsB,EAAE,QAA4C;IAC9H,IAAI,cACF,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,QAAQ,EAAE,EAAE,MAAM,KAAK,CAAC,UAAU,CAAC,SAAS;YACvG,UAAU;YACV,OAAO,GAAG,MAAM,KAAK,CAAC,eAAe,CAAC,QAAQ;kBAC9C;YACA,UAAU,CAAC;gBACT,MAAM,MAAM,CAAC,WAAW,EAAE,MAAM,CAAC,KAAK;YACxC;YACA,OAAO,oBAAoB,KAAK;YAChC,qBAAqB,KAAK,CAAC,oBAAoB;YAC/C,oBAAoB,KAAK,CAAC,mBAAmB;YAC7C,gBAAgB,KAAK,CAAC,eAAe;QACvC;IAEJ;AACF;AAEA,2CAA2C;AAC3C,SAAS,iCAAW,EAAU,EAAE,EAAU,EAAE,CAAS;IACnD,OAAO,CAAC,EAAE,EAAE,GAAG,EAAE,EAAE,GAAG,GAAG,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,UAAU,EAAE,CAAC,IAAI,EAAE,GAAG,CAAC;AAC1G","sources":["packages/@react-aria/color/src/useColorWheel.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaColorWheelProps} from '@react-types/color';\nimport {ColorWheelState} from '@react-stately/color';\nimport {DOMAttributes, RefObject} from '@react-types/shared';\nimport {focusWithoutScrolling, mergeProps, useFormReset, useGlobalListeners, useLabels} from '@react-aria/utils';\nimport React, {ChangeEvent, InputHTMLAttributes, useCallback, useRef} from 'react';\nimport {useKeyboard, useMove} from '@react-aria/interactions';\nimport {useLocale} from '@react-aria/i18n';\nimport {useVisuallyHidden} from '@react-aria/visually-hidden';\n\nexport interface AriaColorWheelOptions extends AriaColorWheelProps {\n /** The outer radius of the color wheel. */\n outerRadius: number,\n /** The inner radius of the color wheel. */\n innerRadius: number\n}\n\nexport interface ColorWheelAria {\n /** Props for the track element. */\n trackProps: DOMAttributes,\n /** Props for the thumb element. */\n thumbProps: DOMAttributes,\n /** Props for the visually hidden range input element. */\n inputProps: InputHTMLAttributes<HTMLInputElement>\n}\n\n/**\n * Provides the behavior and accessibility implementation for a color wheel component.\n * Color wheels allow users to adjust the hue of an HSL or HSB color value on a circular track.\n */\nexport function useColorWheel(props: AriaColorWheelOptions, state: ColorWheelState, inputRef: RefObject<HTMLInputElement | null>): ColorWheelAria {\n let {\n isDisabled,\n innerRadius,\n outerRadius,\n 'aria-label': ariaLabel,\n name\n } = props;\n\n let {addGlobalListener, removeGlobalListener} = useGlobalListeners();\n\n let thumbRadius = (innerRadius + outerRadius) / 2;\n\n let focusInput = useCallback(() => {\n if (inputRef.current) {\n focusWithoutScrolling(inputRef.current);\n }\n }, [inputRef]);\n\n useFormReset(inputRef, state.hue, state.setHue);\n\n let currentPosition = useRef<{x: number, y: number} | null>(null);\n\n let {keyboardProps} = useKeyboard({\n onKeyDown(e) {\n // these are the cases that useMove doesn't handle\n if (!/^(PageUp|PageDown)$/.test(e.key)) {\n e.continuePropagation();\n return;\n }\n // same handling as useMove, don't need to stop propagation, useKeyboard will do that for us\n e.preventDefault();\n // remember to set this and unset it so that onChangeEnd is fired\n state.setDragging(true);\n switch (e.key) {\n case 'PageUp':\n e.preventDefault();\n state.increment(state.pageStep);\n break;\n case 'PageDown':\n e.preventDefault();\n state.decrement(state.pageStep);\n break;\n }\n state.setDragging(false);\n }\n });\n\n let moveHandler = {\n onMoveStart() {\n currentPosition.current = null;\n state.setDragging(true);\n },\n onMove({deltaX, deltaY, pointerType, shiftKey}) {\n if (currentPosition.current == null) {\n currentPosition.current = state.getThumbPosition(thumbRadius);\n }\n currentPosition.current.x += deltaX;\n currentPosition.current.y += deltaY;\n if (pointerType === 'keyboard') {\n if (deltaX > 0 || deltaY < 0) {\n state.increment(shiftKey ? state.pageStep : state.step);\n } else if (deltaX < 0 || deltaY > 0) {\n state.decrement(shiftKey ? state.pageStep : state.step);\n }\n } else {\n state.setHueFromPoint(currentPosition.current.x, currentPosition.current.y, thumbRadius);\n }\n },\n onMoveEnd() {\n isOnTrack.current = false;\n state.setDragging(false);\n focusInput();\n }\n };\n let {moveProps: movePropsThumb} = useMove(moveHandler);\n\n let currentPointer = useRef<number | null | undefined>(undefined);\n let isOnTrack = useRef<boolean>(false);\n let {moveProps: movePropsContainer} = useMove({\n onMoveStart() {\n if (isOnTrack.current) {\n moveHandler.onMoveStart();\n }\n },\n onMove(e) {\n if (isOnTrack.current) {\n moveHandler.onMove(e);\n }\n },\n onMoveEnd() {\n if (isOnTrack.current) {\n moveHandler.onMoveEnd();\n }\n }\n });\n\n let onThumbDown = (id: number | null | undefined) => {\n if (!state.isDragging) {\n currentPointer.current = id;\n focusInput();\n state.setDragging(true);\n\n if (typeof PointerEvent !== 'undefined') {\n addGlobalListener(window, 'pointerup', onThumbUp, false);\n } else {\n addGlobalListener(window, 'mouseup', onThumbUp, false);\n addGlobalListener(window, 'touchend', onThumbUp, false);\n }\n }\n };\n\n let onThumbUp = (e) => {\n let id = e.pointerId ?? e.changedTouches?.[0].identifier;\n if (id === currentPointer.current) {\n focusInput();\n state.setDragging(false);\n currentPointer.current = undefined;\n isOnTrack.current = false;\n\n if (typeof PointerEvent !== 'undefined') {\n removeGlobalListener(window, 'pointerup', onThumbUp, false);\n } else {\n removeGlobalListener(window, 'mouseup', onThumbUp, false);\n removeGlobalListener(window, 'touchend', onThumbUp, false);\n }\n }\n };\n\n let onTrackDown = (track: Element, id: number | null | undefined, pageX: number, pageY: number) => {\n let rect = track.getBoundingClientRect();\n let x = pageX - rect.x - rect.width / 2;\n let y = pageY - rect.y - rect.height / 2;\n let radius = Math.sqrt(x * x + y * y);\n if (innerRadius < radius && radius < outerRadius && !state.isDragging && currentPointer.current === undefined) {\n isOnTrack.current = true;\n currentPointer.current = id;\n state.setHueFromPoint(x, y, radius);\n\n focusInput();\n state.setDragging(true);\n\n if (typeof PointerEvent !== 'undefined') {\n addGlobalListener(window, 'pointerup', onTrackUp, false);\n } else {\n addGlobalListener(window, 'mouseup', onTrackUp, false);\n addGlobalListener(window, 'touchend', onTrackUp, false);\n }\n }\n };\n\n let onTrackUp = (e) => {\n let id = e.pointerId ?? e.changedTouches?.[0].identifier;\n if (isOnTrack.current && id === currentPointer.current) {\n isOnTrack.current = false;\n currentPointer.current = undefined;\n state.setDragging(false);\n focusInput();\n\n\n if (typeof PointerEvent !== 'undefined') {\n removeGlobalListener(window, 'pointerup', onTrackUp, false);\n } else {\n removeGlobalListener(window, 'mouseup', onTrackUp, false);\n removeGlobalListener(window, 'touchend', onTrackUp, false);\n }\n }\n };\n\n let trackInteractions = isDisabled ? {} : mergeProps({\n ...(typeof PointerEvent !== 'undefined' ? {\n onPointerDown: (e: React.PointerEvent) => {\n if (e.pointerType === 'mouse' && (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey)) {\n return;\n }\n onTrackDown(e.currentTarget, e.pointerId, e.clientX, e.clientY);\n }} : {\n onMouseDown: (e: React.MouseEvent) => {\n if (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey) {\n return;\n }\n onTrackDown(e.currentTarget, undefined, e.clientX, e.clientY);\n },\n onTouchStart: (e: React.TouchEvent) => {\n onTrackDown(e.currentTarget, e.changedTouches[0].identifier, e.changedTouches[0].clientX, e.changedTouches[0].clientY);\n }\n })\n }, movePropsContainer);\n\n let thumbInteractions = isDisabled ? {} : mergeProps({\n onMouseDown: (e: React.MouseEvent) => {\n if (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey) {\n return;\n }\n onThumbDown(undefined);\n },\n onPointerDown: (e: React.PointerEvent) => {\n if (e.pointerType === 'mouse' && (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey)) {\n return;\n }\n onThumbDown(e.pointerId);\n },\n onTouchStart: (e: React.TouchEvent) => {\n onThumbDown(e.changedTouches[0].identifier);\n }\n }, keyboardProps, movePropsThumb);\n let {x, y} = state.getThumbPosition(thumbRadius);\n\n // Provide a default aria-label if none is given\n let {locale} = useLocale();\n if (ariaLabel == null && props['aria-labelledby'] == null) {\n ariaLabel = state.value.getChannelName('hue', locale);\n }\n\n let inputLabellingProps = useLabels({\n ...props,\n 'aria-label': ariaLabel\n });\n\n let {minValue, maxValue, step} = state.value.getChannelRange('hue');\n\n let forcedColorAdjustNoneStyle = {\n forcedColorAdjust: 'none'\n };\n\n let {visuallyHiddenProps} = useVisuallyHidden({\n style: {\n opacity: '0.0001',\n width: '100%',\n height: '100%',\n pointerEvents: 'none'\n }\n });\n\n return {\n trackProps: {\n ...trackInteractions,\n style: {\n position: 'relative',\n touchAction: 'none',\n width: outerRadius * 2,\n height: outerRadius * 2,\n background: `\n conic-gradient(\n from 90deg,\n hsl(0, 100%, 50%),\n hsl(30, 100%, 50%),\n hsl(60, 100%, 50%),\n hsl(90, 100%, 50%),\n hsl(120, 100%, 50%),\n hsl(150, 100%, 50%),\n hsl(180, 100%, 50%),\n hsl(210, 100%, 50%),\n hsl(240, 100%, 50%),\n hsl(270, 100%, 50%),\n hsl(300, 100%, 50%),\n hsl(330, 100%, 50%),\n hsl(360, 100%, 50%)\n )\n `,\n clipPath: `path(evenodd, \"${circlePath(outerRadius, outerRadius, outerRadius)} ${circlePath(outerRadius, outerRadius, innerRadius)}\")`,\n ...forcedColorAdjustNoneStyle\n }\n },\n thumbProps: {\n ...thumbInteractions,\n style: {\n position: 'absolute',\n left: outerRadius + x,\n top: outerRadius + y,\n transform: 'translate(-50%, -50%)',\n touchAction: 'none',\n ...forcedColorAdjustNoneStyle\n }\n },\n inputProps: mergeProps(\n inputLabellingProps,\n {\n type: 'range',\n min: String(minValue),\n max: String(maxValue),\n step: String(step),\n 'aria-valuetext': `${state.value.formatChannelValue('hue', locale)}, ${state.value.getHueName(locale)}`,\n disabled: isDisabled,\n value: `${state.value.getChannelValue('hue')}`,\n name,\n onChange: (e: ChangeEvent<HTMLInputElement>) => {\n state.setHue(parseFloat(e.target.value));\n },\n style: visuallyHiddenProps.style,\n 'aria-errormessage': props['aria-errormessage'],\n 'aria-describedby': props['aria-describedby'],\n 'aria-details': props['aria-details']\n }\n )\n };\n}\n\n// Creates an SVG path string for a circle.\nfunction circlePath(cx: number, cy: number, r: number) {\n return `M ${cx}, ${cy} m ${-r}, 0 a ${r}, ${r}, 0, 1, 0, ${r * 2}, 0 a ${r}, ${r}, 0, 1, 0 ${-r * 2}, 0`;\n}\n"],"names":[],"version":3,"file":"useColorWheel.main.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;AA+BM,SAAS,0CAAc,KAA4B,EAAE,KAAsB,EAAE,QAA4C;IAC9H,IAAI,cACF,UAAU,eACV,WAAW,eACX,WAAW,EACX,cAAc,SAAS,QACvB,IAAI,QACJ,IAAI,EACL,GAAG;IAEJ,IAAI,qBAAC,iBAAiB,wBAAE,oBAAoB,EAAC,GAAG,CAAA,GAAA,wCAAiB;IAEjE,IAAI,cAAc,AAAC,CAAA,cAAc,WAAU,IAAK;IAEhD,IAAI,aAAa,CAAA,GAAA,wBAAU,EAAE;QAC3B,IAAI,SAAS,OAAO,EAClB,CAAA,GAAA,2CAAoB,EAAE,SAAS,OAAO;IAE1C,GAAG;QAAC;KAAS;IAEb,CAAA,GAAA,kCAAW,EAAE,UAAU,MAAM,YAAY,EAAE,MAAM,QAAQ;IAEzD,IAAI,kBAAkB,CAAA,GAAA,mBAAK,EAAiC;IAE5D,IAAI,iBAAC,aAAa,EAAC,GAAG,CAAA,GAAA,wCAAU,EAAE;QAChC,WAAU,CAAC;YACT,kDAAkD;YAClD,IAAI,CAAC,sBAAsB,IAAI,CAAC,EAAE,GAAG,GAAG;gBACtC,EAAE,mBAAm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IAAI,EAAE,GAAG,CAAC;AAC1G","sources":["packages/@react-aria/color/src/useColorWheel.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaColorWheelProps} from '@react-types/color';\nimport {ColorWheelState} from '@react-stately/color';\nimport {DOMAttributes, RefObject} from '@react-types/shared';\nimport {focusWithoutScrolling, mergeProps, useFormReset, useGlobalListeners, useLabels} from '@react-aria/utils';\nimport React, {ChangeEvent, InputHTMLAttributes, useCallback, useRef} from 'react';\nimport {useKeyboard, useMove} from '@react-aria/interactions';\nimport {useLocale} from '@react-aria/i18n';\nimport {useVisuallyHidden} from '@react-aria/visually-hidden';\n\nexport interface AriaColorWheelOptions extends AriaColorWheelProps {\n /** The outer radius of the color wheel. */\n outerRadius: number,\n /** The inner radius of the color wheel. */\n innerRadius: number\n}\n\nexport interface ColorWheelAria {\n /** Props for the track element. */\n trackProps: DOMAttributes,\n /** Props for the thumb element. */\n thumbProps: DOMAttributes,\n /** Props for the visually hidden range input element. */\n inputProps: InputHTMLAttributes<HTMLInputElement>\n}\n\n/**\n * Provides the behavior and accessibility implementation for a color wheel component.\n * Color wheels allow users to adjust the hue of an HSL or HSB color value on a circular track.\n */\nexport function useColorWheel(props: AriaColorWheelOptions, state: ColorWheelState, inputRef: RefObject<HTMLInputElement | null>): ColorWheelAria {\n let {\n isDisabled,\n innerRadius,\n outerRadius,\n 'aria-label': ariaLabel,\n name,\n form\n } = props;\n\n let {addGlobalListener, removeGlobalListener} = useGlobalListeners();\n\n let thumbRadius = (innerRadius + outerRadius) / 2;\n\n let focusInput = useCallback(() => {\n if (inputRef.current) {\n focusWithoutScrolling(inputRef.current);\n }\n }, [inputRef]);\n\n useFormReset(inputRef, state.defaultValue, state.setValue);\n\n let currentPosition = useRef<{x: number, y: number} | null>(null);\n\n let {keyboardProps} = useKeyboard({\n onKeyDown(e) {\n // these are the cases that useMove doesn't handle\n if (!/^(PageUp|PageDown)$/.test(e.key)) {\n e.continuePropagation();\n return;\n }\n // same handling as useMove, don't need to stop propagation, useKeyboard will do that for us\n e.preventDefault();\n // remember to set this and unset it so that onChangeEnd is fired\n state.setDragging(true);\n switch (e.key) {\n case 'PageUp':\n e.preventDefault();\n state.increment(state.pageStep);\n break;\n case 'PageDown':\n e.preventDefault();\n state.decrement(state.pageStep);\n break;\n }\n state.setDragging(false);\n }\n });\n\n let moveHandler = {\n onMoveStart() {\n currentPosition.current = null;\n state.setDragging(true);\n },\n onMove({deltaX, deltaY, pointerType, shiftKey}) {\n if (currentPosition.current == null) {\n currentPosition.current = state.getThumbPosition(thumbRadius);\n }\n currentPosition.current.x += deltaX;\n currentPosition.current.y += deltaY;\n if (pointerType === 'keyboard') {\n if (deltaX > 0 || deltaY < 0) {\n state.increment(shiftKey ? state.pageStep : state.step);\n } else if (deltaX < 0 || deltaY > 0) {\n state.decrement(shiftKey ? state.pageStep : state.step);\n }\n } else {\n state.setHueFromPoint(currentPosition.current.x, currentPosition.current.y, thumbRadius);\n }\n },\n onMoveEnd() {\n isOnTrack.current = false;\n state.setDragging(false);\n focusInput();\n }\n };\n let {moveProps: movePropsThumb} = useMove(moveHandler);\n\n let currentPointer = useRef<number | null | undefined>(undefined);\n let isOnTrack = useRef<boolean>(false);\n let {moveProps: movePropsContainer} = useMove({\n onMoveStart() {\n if (isOnTrack.current) {\n moveHandler.onMoveStart();\n }\n },\n onMove(e) {\n if (isOnTrack.current) {\n moveHandler.onMove(e);\n }\n },\n onMoveEnd() {\n if (isOnTrack.current) {\n moveHandler.onMoveEnd();\n }\n }\n });\n\n let onThumbDown = (id: number | null | undefined) => {\n if (!state.isDragging) {\n currentPointer.current = id;\n focusInput();\n state.setDragging(true);\n\n if (typeof PointerEvent !== 'undefined') {\n addGlobalListener(window, 'pointerup', onThumbUp, false);\n } else {\n addGlobalListener(window, 'mouseup', onThumbUp, false);\n addGlobalListener(window, 'touchend', onThumbUp, false);\n }\n }\n };\n\n let onThumbUp = (e) => {\n let id = e.pointerId ?? e.changedTouches?.[0].identifier;\n if (id === currentPointer.current) {\n focusInput();\n state.setDragging(false);\n currentPointer.current = undefined;\n isOnTrack.current = false;\n\n if (typeof PointerEvent !== 'undefined') {\n removeGlobalListener(window, 'pointerup', onThumbUp, false);\n } else {\n removeGlobalListener(window, 'mouseup', onThumbUp, false);\n removeGlobalListener(window, 'touchend', onThumbUp, false);\n }\n }\n };\n\n let onTrackDown = (track: Element, id: number | null | undefined, pageX: number, pageY: number) => {\n let rect = track.getBoundingClientRect();\n let x = pageX - rect.x - rect.width / 2;\n let y = pageY - rect.y - rect.height / 2;\n let radius = Math.sqrt(x * x + y * y);\n if (innerRadius < radius && radius < outerRadius && !state.isDragging && currentPointer.current === undefined) {\n isOnTrack.current = true;\n currentPointer.current = id;\n state.setHueFromPoint(x, y, radius);\n\n focusInput();\n state.setDragging(true);\n\n if (typeof PointerEvent !== 'undefined') {\n addGlobalListener(window, 'pointerup', onTrackUp, false);\n } else {\n addGlobalListener(window, 'mouseup', onTrackUp, false);\n addGlobalListener(window, 'touchend', onTrackUp, false);\n }\n }\n };\n\n let onTrackUp = (e) => {\n let id = e.pointerId ?? e.changedTouches?.[0].identifier;\n if (isOnTrack.current && id === currentPointer.current) {\n isOnTrack.current = false;\n currentPointer.current = undefined;\n state.setDragging(false);\n focusInput();\n\n\n if (typeof PointerEvent !== 'undefined') {\n removeGlobalListener(window, 'pointerup', onTrackUp, false);\n } else {\n removeGlobalListener(window, 'mouseup', onTrackUp, false);\n removeGlobalListener(window, 'touchend', onTrackUp, false);\n }\n }\n };\n\n let trackInteractions = isDisabled ? {} : mergeProps({\n ...(typeof PointerEvent !== 'undefined' ? {\n onPointerDown: (e: React.PointerEvent) => {\n if (e.pointerType === 'mouse' && (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey)) {\n return;\n }\n onTrackDown(e.currentTarget, e.pointerId, e.clientX, e.clientY);\n }} : {\n onMouseDown: (e: React.MouseEvent) => {\n if (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey) {\n return;\n }\n onTrackDown(e.currentTarget, undefined, e.clientX, e.clientY);\n },\n onTouchStart: (e: React.TouchEvent) => {\n onTrackDown(e.currentTarget, e.changedTouches[0].identifier, e.changedTouches[0].clientX, e.changedTouches[0].clientY);\n }\n })\n }, movePropsContainer);\n\n let thumbInteractions = isDisabled ? {} : mergeProps({\n onMouseDown: (e: React.MouseEvent) => {\n if (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey) {\n return;\n }\n onThumbDown(undefined);\n },\n onPointerDown: (e: React.PointerEvent) => {\n if (e.pointerType === 'mouse' && (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey)) {\n return;\n }\n onThumbDown(e.pointerId);\n },\n onTouchStart: (e: React.TouchEvent) => {\n onThumbDown(e.changedTouches[0].identifier);\n }\n }, keyboardProps, movePropsThumb);\n let {x, y} = state.getThumbPosition(thumbRadius);\n\n // Provide a default aria-label if none is given\n let {locale} = useLocale();\n if (ariaLabel == null && props['aria-labelledby'] == null) {\n ariaLabel = state.value.getChannelName('hue', locale);\n }\n\n let inputLabellingProps = useLabels({\n ...props,\n 'aria-label': ariaLabel\n });\n\n let {minValue, maxValue, step} = state.value.getChannelRange('hue');\n\n let forcedColorAdjustNoneStyle = {\n forcedColorAdjust: 'none'\n };\n\n let {visuallyHiddenProps} = useVisuallyHidden({\n style: {\n opacity: '0.0001',\n width: '100%',\n height: '100%',\n pointerEvents: 'none'\n }\n });\n\n return {\n trackProps: {\n ...trackInteractions,\n style: {\n position: 'relative',\n touchAction: 'none',\n width: outerRadius * 2,\n height: outerRadius * 2,\n background: `\n conic-gradient(\n from 90deg,\n hsl(0, 100%, 50%),\n hsl(30, 100%, 50%),\n hsl(60, 100%, 50%),\n hsl(90, 100%, 50%),\n hsl(120, 100%, 50%),\n hsl(150, 100%, 50%),\n hsl(180, 100%, 50%),\n hsl(210, 100%, 50%),\n hsl(240, 100%, 50%),\n hsl(270, 100%, 50%),\n hsl(300, 100%, 50%),\n hsl(330, 100%, 50%),\n hsl(360, 100%, 50%)\n )\n `,\n clipPath: `path(evenodd, \"${circlePath(outerRadius, outerRadius, outerRadius)} ${circlePath(outerRadius, outerRadius, innerRadius)}\")`,\n ...forcedColorAdjustNoneStyle\n }\n },\n thumbProps: {\n ...thumbInteractions,\n style: {\n position: 'absolute',\n left: outerRadius + x,\n top: outerRadius + y,\n transform: 'translate(-50%, -50%)',\n touchAction: 'none',\n ...forcedColorAdjustNoneStyle\n }\n },\n inputProps: mergeProps(\n inputLabellingProps,\n {\n type: 'range',\n min: String(minValue),\n max: String(maxValue),\n step: String(step),\n 'aria-valuetext': `${state.value.formatChannelValue('hue', locale)}, ${state.value.getHueName(locale)}`,\n disabled: isDisabled,\n value: `${state.value.getChannelValue('hue')}`,\n name,\n form,\n onChange: (e: ChangeEvent<HTMLInputElement>) => {\n state.setHue(parseFloat(e.target.value));\n },\n style: visuallyHiddenProps.style,\n 'aria-errormessage': props['aria-errormessage'],\n 'aria-describedby': props['aria-describedby'],\n 'aria-details': props['aria-details']\n }\n )\n };\n}\n\n// Creates an SVG path string for a circle.\nfunction circlePath(cx: number, cy: number, r: number) {\n return `M ${cx}, ${cy} m ${-r}, 0 a ${r}, ${r}, 0, 1, 0, ${r * 2}, 0 a ${r}, ${r}, 0, 1, 0 ${-r * 2}, 0`;\n}\n"],"names":[],"version":3,"file":"useColorWheel.main.js.map"}
|
package/dist/useColorWheel.mjs
CHANGED
|
@@ -20,7 +20,7 @@ import {useVisuallyHidden as $hcgPp$useVisuallyHidden} from "@react-aria/visuall
|
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
function $b4a0a4fdc900495e$export$9064ff4e44b3729a(props, state, inputRef) {
|
|
23
|
-
let { isDisabled: isDisabled, innerRadius: innerRadius, outerRadius: outerRadius, 'aria-label': ariaLabel, name: name } = props;
|
|
23
|
+
let { isDisabled: isDisabled, innerRadius: innerRadius, outerRadius: outerRadius, 'aria-label': ariaLabel, name: name, form: form } = props;
|
|
24
24
|
let { addGlobalListener: addGlobalListener, removeGlobalListener: removeGlobalListener } = (0, $hcgPp$useGlobalListeners)();
|
|
25
25
|
let thumbRadius = (innerRadius + outerRadius) / 2;
|
|
26
26
|
let focusInput = (0, $hcgPp$useCallback)(()=>{
|
|
@@ -28,7 +28,7 @@ function $b4a0a4fdc900495e$export$9064ff4e44b3729a(props, state, inputRef) {
|
|
|
28
28
|
}, [
|
|
29
29
|
inputRef
|
|
30
30
|
]);
|
|
31
|
-
(0, $hcgPp$useFormReset)(inputRef, state.
|
|
31
|
+
(0, $hcgPp$useFormReset)(inputRef, state.defaultValue, state.setValue);
|
|
32
32
|
let currentPosition = (0, $hcgPp$useRef)(null);
|
|
33
33
|
let { keyboardProps: keyboardProps } = (0, $hcgPp$useKeyboard)({
|
|
34
34
|
onKeyDown (e) {
|
|
@@ -249,6 +249,7 @@ function $b4a0a4fdc900495e$export$9064ff4e44b3729a(props, state, inputRef) {
|
|
|
249
249
|
disabled: isDisabled,
|
|
250
250
|
value: `${state.value.getChannelValue('hue')}`,
|
|
251
251
|
name: name,
|
|
252
|
+
form: form,
|
|
252
253
|
onChange: (e)=>{
|
|
253
254
|
state.setHue(parseFloat(e.target.value));
|
|
254
255
|
},
|
|
@@ -20,7 +20,7 @@ import {useVisuallyHidden as $hcgPp$useVisuallyHidden} from "@react-aria/visuall
|
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
function $b4a0a4fdc900495e$export$9064ff4e44b3729a(props, state, inputRef) {
|
|
23
|
-
let { isDisabled: isDisabled, innerRadius: innerRadius, outerRadius: outerRadius, 'aria-label': ariaLabel, name: name } = props;
|
|
23
|
+
let { isDisabled: isDisabled, innerRadius: innerRadius, outerRadius: outerRadius, 'aria-label': ariaLabel, name: name, form: form } = props;
|
|
24
24
|
let { addGlobalListener: addGlobalListener, removeGlobalListener: removeGlobalListener } = (0, $hcgPp$useGlobalListeners)();
|
|
25
25
|
let thumbRadius = (innerRadius + outerRadius) / 2;
|
|
26
26
|
let focusInput = (0, $hcgPp$useCallback)(()=>{
|
|
@@ -28,7 +28,7 @@ function $b4a0a4fdc900495e$export$9064ff4e44b3729a(props, state, inputRef) {
|
|
|
28
28
|
}, [
|
|
29
29
|
inputRef
|
|
30
30
|
]);
|
|
31
|
-
(0, $hcgPp$useFormReset)(inputRef, state.
|
|
31
|
+
(0, $hcgPp$useFormReset)(inputRef, state.defaultValue, state.setValue);
|
|
32
32
|
let currentPosition = (0, $hcgPp$useRef)(null);
|
|
33
33
|
let { keyboardProps: keyboardProps } = (0, $hcgPp$useKeyboard)({
|
|
34
34
|
onKeyDown (e) {
|
|
@@ -249,6 +249,7 @@ function $b4a0a4fdc900495e$export$9064ff4e44b3729a(props, state, inputRef) {
|
|
|
249
249
|
disabled: isDisabled,
|
|
250
250
|
value: `${state.value.getChannelValue('hue')}`,
|
|
251
251
|
name: name,
|
|
252
|
+
form: form,
|
|
252
253
|
onChange: (e)=>{
|
|
253
254
|
state.setHue(parseFloat(e.target.value));
|
|
254
255
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;AAAA;;;;;;;;;;CAUC;;;;;AA+BM,SAAS,0CAAc,KAA4B,EAAE,KAAsB,EAAE,QAA4C;IAC9H,IAAI,cACF,UAAU,eACV,WAAW,eACX,WAAW,EACX,cAAc,SAAS,QACvB,IAAI,EACL,GAAG;IAEJ,IAAI,qBAAC,iBAAiB,wBAAE,oBAAoB,EAAC,GAAG,CAAA,GAAA,yBAAiB;IAEjE,IAAI,cAAc,AAAC,CAAA,cAAc,WAAU,IAAK;IAEhD,IAAI,aAAa,CAAA,GAAA,kB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YAChC,qBAAqB,KAAK,CAAC,oBAAoB;YAC/C,oBAAoB,KAAK,CAAC,mBAAmB;YAC7C,gBAAgB,KAAK,CAAC,eAAe;QACvC;IAEJ;AACF;AAEA,2CAA2C;AAC3C,SAAS,iCAAW,EAAU,EAAE,EAAU,EAAE,CAAS;IACnD,OAAO,CAAC,EAAE,EAAE,GAAG,EAAE,EAAE,GAAG,GAAG,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,UAAU,EAAE,CAAC,IAAI,EAAE,GAAG,CAAC;AAC1G","sources":["packages/@react-aria/color/src/useColorWheel.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaColorWheelProps} from '@react-types/color';\nimport {ColorWheelState} from '@react-stately/color';\nimport {DOMAttributes, RefObject} from '@react-types/shared';\nimport {focusWithoutScrolling, mergeProps, useFormReset, useGlobalListeners, useLabels} from '@react-aria/utils';\nimport React, {ChangeEvent, InputHTMLAttributes, useCallback, useRef} from 'react';\nimport {useKeyboard, useMove} from '@react-aria/interactions';\nimport {useLocale} from '@react-aria/i18n';\nimport {useVisuallyHidden} from '@react-aria/visually-hidden';\n\nexport interface AriaColorWheelOptions extends AriaColorWheelProps {\n /** The outer radius of the color wheel. */\n outerRadius: number,\n /** The inner radius of the color wheel. */\n innerRadius: number\n}\n\nexport interface ColorWheelAria {\n /** Props for the track element. */\n trackProps: DOMAttributes,\n /** Props for the thumb element. */\n thumbProps: DOMAttributes,\n /** Props for the visually hidden range input element. */\n inputProps: InputHTMLAttributes<HTMLInputElement>\n}\n\n/**\n * Provides the behavior and accessibility implementation for a color wheel component.\n * Color wheels allow users to adjust the hue of an HSL or HSB color value on a circular track.\n */\nexport function useColorWheel(props: AriaColorWheelOptions, state: ColorWheelState, inputRef: RefObject<HTMLInputElement | null>): ColorWheelAria {\n let {\n isDisabled,\n innerRadius,\n outerRadius,\n 'aria-label': ariaLabel,\n name\n } = props;\n\n let {addGlobalListener, removeGlobalListener} = useGlobalListeners();\n\n let thumbRadius = (innerRadius + outerRadius) / 2;\n\n let focusInput = useCallback(() => {\n if (inputRef.current) {\n focusWithoutScrolling(inputRef.current);\n }\n }, [inputRef]);\n\n useFormReset(inputRef, state.hue, state.setHue);\n\n let currentPosition = useRef<{x: number, y: number} | null>(null);\n\n let {keyboardProps} = useKeyboard({\n onKeyDown(e) {\n // these are the cases that useMove doesn't handle\n if (!/^(PageUp|PageDown)$/.test(e.key)) {\n e.continuePropagation();\n return;\n }\n // same handling as useMove, don't need to stop propagation, useKeyboard will do that for us\n e.preventDefault();\n // remember to set this and unset it so that onChangeEnd is fired\n state.setDragging(true);\n switch (e.key) {\n case 'PageUp':\n e.preventDefault();\n state.increment(state.pageStep);\n break;\n case 'PageDown':\n e.preventDefault();\n state.decrement(state.pageStep);\n break;\n }\n state.setDragging(false);\n }\n });\n\n let moveHandler = {\n onMoveStart() {\n currentPosition.current = null;\n state.setDragging(true);\n },\n onMove({deltaX, deltaY, pointerType, shiftKey}) {\n if (currentPosition.current == null) {\n currentPosition.current = state.getThumbPosition(thumbRadius);\n }\n currentPosition.current.x += deltaX;\n currentPosition.current.y += deltaY;\n if (pointerType === 'keyboard') {\n if (deltaX > 0 || deltaY < 0) {\n state.increment(shiftKey ? state.pageStep : state.step);\n } else if (deltaX < 0 || deltaY > 0) {\n state.decrement(shiftKey ? state.pageStep : state.step);\n }\n } else {\n state.setHueFromPoint(currentPosition.current.x, currentPosition.current.y, thumbRadius);\n }\n },\n onMoveEnd() {\n isOnTrack.current = false;\n state.setDragging(false);\n focusInput();\n }\n };\n let {moveProps: movePropsThumb} = useMove(moveHandler);\n\n let currentPointer = useRef<number | null | undefined>(undefined);\n let isOnTrack = useRef<boolean>(false);\n let {moveProps: movePropsContainer} = useMove({\n onMoveStart() {\n if (isOnTrack.current) {\n moveHandler.onMoveStart();\n }\n },\n onMove(e) {\n if (isOnTrack.current) {\n moveHandler.onMove(e);\n }\n },\n onMoveEnd() {\n if (isOnTrack.current) {\n moveHandler.onMoveEnd();\n }\n }\n });\n\n let onThumbDown = (id: number | null | undefined) => {\n if (!state.isDragging) {\n currentPointer.current = id;\n focusInput();\n state.setDragging(true);\n\n if (typeof PointerEvent !== 'undefined') {\n addGlobalListener(window, 'pointerup', onThumbUp, false);\n } else {\n addGlobalListener(window, 'mouseup', onThumbUp, false);\n addGlobalListener(window, 'touchend', onThumbUp, false);\n }\n }\n };\n\n let onThumbUp = (e) => {\n let id = e.pointerId ?? e.changedTouches?.[0].identifier;\n if (id === currentPointer.current) {\n focusInput();\n state.setDragging(false);\n currentPointer.current = undefined;\n isOnTrack.current = false;\n\n if (typeof PointerEvent !== 'undefined') {\n removeGlobalListener(window, 'pointerup', onThumbUp, false);\n } else {\n removeGlobalListener(window, 'mouseup', onThumbUp, false);\n removeGlobalListener(window, 'touchend', onThumbUp, false);\n }\n }\n };\n\n let onTrackDown = (track: Element, id: number | null | undefined, pageX: number, pageY: number) => {\n let rect = track.getBoundingClientRect();\n let x = pageX - rect.x - rect.width / 2;\n let y = pageY - rect.y - rect.height / 2;\n let radius = Math.sqrt(x * x + y * y);\n if (innerRadius < radius && radius < outerRadius && !state.isDragging && currentPointer.current === undefined) {\n isOnTrack.current = true;\n currentPointer.current = id;\n state.setHueFromPoint(x, y, radius);\n\n focusInput();\n state.setDragging(true);\n\n if (typeof PointerEvent !== 'undefined') {\n addGlobalListener(window, 'pointerup', onTrackUp, false);\n } else {\n addGlobalListener(window, 'mouseup', onTrackUp, false);\n addGlobalListener(window, 'touchend', onTrackUp, false);\n }\n }\n };\n\n let onTrackUp = (e) => {\n let id = e.pointerId ?? e.changedTouches?.[0].identifier;\n if (isOnTrack.current && id === currentPointer.current) {\n isOnTrack.current = false;\n currentPointer.current = undefined;\n state.setDragging(false);\n focusInput();\n\n\n if (typeof PointerEvent !== 'undefined') {\n removeGlobalListener(window, 'pointerup', onTrackUp, false);\n } else {\n removeGlobalListener(window, 'mouseup', onTrackUp, false);\n removeGlobalListener(window, 'touchend', onTrackUp, false);\n }\n }\n };\n\n let trackInteractions = isDisabled ? {} : mergeProps({\n ...(typeof PointerEvent !== 'undefined' ? {\n onPointerDown: (e: React.PointerEvent) => {\n if (e.pointerType === 'mouse' && (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey)) {\n return;\n }\n onTrackDown(e.currentTarget, e.pointerId, e.clientX, e.clientY);\n }} : {\n onMouseDown: (e: React.MouseEvent) => {\n if (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey) {\n return;\n }\n onTrackDown(e.currentTarget, undefined, e.clientX, e.clientY);\n },\n onTouchStart: (e: React.TouchEvent) => {\n onTrackDown(e.currentTarget, e.changedTouches[0].identifier, e.changedTouches[0].clientX, e.changedTouches[0].clientY);\n }\n })\n }, movePropsContainer);\n\n let thumbInteractions = isDisabled ? {} : mergeProps({\n onMouseDown: (e: React.MouseEvent) => {\n if (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey) {\n return;\n }\n onThumbDown(undefined);\n },\n onPointerDown: (e: React.PointerEvent) => {\n if (e.pointerType === 'mouse' && (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey)) {\n return;\n }\n onThumbDown(e.pointerId);\n },\n onTouchStart: (e: React.TouchEvent) => {\n onThumbDown(e.changedTouches[0].identifier);\n }\n }, keyboardProps, movePropsThumb);\n let {x, y} = state.getThumbPosition(thumbRadius);\n\n // Provide a default aria-label if none is given\n let {locale} = useLocale();\n if (ariaLabel == null && props['aria-labelledby'] == null) {\n ariaLabel = state.value.getChannelName('hue', locale);\n }\n\n let inputLabellingProps = useLabels({\n ...props,\n 'aria-label': ariaLabel\n });\n\n let {minValue, maxValue, step} = state.value.getChannelRange('hue');\n\n let forcedColorAdjustNoneStyle = {\n forcedColorAdjust: 'none'\n };\n\n let {visuallyHiddenProps} = useVisuallyHidden({\n style: {\n opacity: '0.0001',\n width: '100%',\n height: '100%',\n pointerEvents: 'none'\n }\n });\n\n return {\n trackProps: {\n ...trackInteractions,\n style: {\n position: 'relative',\n touchAction: 'none',\n width: outerRadius * 2,\n height: outerRadius * 2,\n background: `\n conic-gradient(\n from 90deg,\n hsl(0, 100%, 50%),\n hsl(30, 100%, 50%),\n hsl(60, 100%, 50%),\n hsl(90, 100%, 50%),\n hsl(120, 100%, 50%),\n hsl(150, 100%, 50%),\n hsl(180, 100%, 50%),\n hsl(210, 100%, 50%),\n hsl(240, 100%, 50%),\n hsl(270, 100%, 50%),\n hsl(300, 100%, 50%),\n hsl(330, 100%, 50%),\n hsl(360, 100%, 50%)\n )\n `,\n clipPath: `path(evenodd, \"${circlePath(outerRadius, outerRadius, outerRadius)} ${circlePath(outerRadius, outerRadius, innerRadius)}\")`,\n ...forcedColorAdjustNoneStyle\n }\n },\n thumbProps: {\n ...thumbInteractions,\n style: {\n position: 'absolute',\n left: outerRadius + x,\n top: outerRadius + y,\n transform: 'translate(-50%, -50%)',\n touchAction: 'none',\n ...forcedColorAdjustNoneStyle\n }\n },\n inputProps: mergeProps(\n inputLabellingProps,\n {\n type: 'range',\n min: String(minValue),\n max: String(maxValue),\n step: String(step),\n 'aria-valuetext': `${state.value.formatChannelValue('hue', locale)}, ${state.value.getHueName(locale)}`,\n disabled: isDisabled,\n value: `${state.value.getChannelValue('hue')}`,\n name,\n onChange: (e: ChangeEvent<HTMLInputElement>) => {\n state.setHue(parseFloat(e.target.value));\n },\n style: visuallyHiddenProps.style,\n 'aria-errormessage': props['aria-errormessage'],\n 'aria-describedby': props['aria-describedby'],\n 'aria-details': props['aria-details']\n }\n )\n };\n}\n\n// Creates an SVG path string for a circle.\nfunction circlePath(cx: number, cy: number, r: number) {\n return `M ${cx}, ${cy} m ${-r}, 0 a ${r}, ${r}, 0, 1, 0, ${r * 2}, 0 a ${r}, ${r}, 0, 1, 0 ${-r * 2}, 0`;\n}\n"],"names":[],"version":3,"file":"useColorWheel.module.js.map"}
|
|
1
|
+
{"mappings":";;;;;;AAAA;;;;;;;;;;CAUC;;;;;AA+BM,SAAS,0CAAc,KAA4B,EAAE,KAAsB,EAAE,QAA4C;IAC9H,IAAI,cACF,UAAU,eACV,WAAW,eACX,WAAW,EACX,cAAc,SAAS,QACvB,IAAI,QACJ,IAAI,EACL,GAAG;IAEJ,IAAI,qBAAC,iBAAiB,wBAAE,oBAAoB,EAAC,GAAG,CAAA,GAAA,yBAAiB;IAEjE,IAAI,cAAc,AAAC,CAAA,cAAc,WAAU,IAAK;IAEhD,IAAI,aAAa,CAAA,GAAA,kBAAU,EAAE;QAC3B,IAAI,SAAS,OAAO,EAClB,CAAA,GAAA,4BAAoB,EAAE,SAAS,OAAO;IAE1C,GAAG;QAAC;KAAS;IAEb,CAAA,GAAA,mBAAW,EAAE,UAAU,MAAM,YAAY,EAAE,MAAM,QAAQ;IAEzD,IAAI,kBAAkB,CAAA,GAAA,aAAK,EAAiC;IAE5D,IAAI,iBAAC,aAAa,EAAC,GAAG,CAAA,GAAA,kBAAU,EAAE;QAChC,WAAU,CAAC;YACT,kDAAkD;YAClD,IAAI,CAAC,sBAAsB,IAAI,CAAC,EAAE,GAAG,GAAG;gBACtC,EAAE,mBAAmB;gBACrB;YACF;YACA,4FAA4F;YAC5F,EAAE,cAAc;YAChB,iEAAiE;YACjE,MAAM,WAAW,CAAC;YAClB,OAAQ,EAAE,GAAG;gBACX,KAAK;oBACH,EAAE,cAAc;oBAChB,MAAM,SAAS,CAAC,MAAM,QAAQ;oBAC9B;gBACF,KAAK;oBACH,EAAE,cAAc;oBAChB,MAAM,SAAS,CAAC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a,aAAa,EAAE,CAAC;gBACtI,GAAG,0BAA0B;YAC/B;QACF;QACA,YAAY;YACV,GAAG,iBAAiB;YACpB,OAAO;gBACL,UAAU;gBACV,MAAM,cAAc;gBACpB,KAAK,cAAc;gBACnB,WAAW;gBACX,aAAa;gBACb,GAAG,0BAA0B;YAC/B;QACF;QACA,YAAY,CAAA,GAAA,iBAAS,EACnB,qBACA;YACE,MAAM;YACN,KAAK,OAAO;YACZ,KAAK,OAAO;YACZ,MAAM,OAAO;YACb,kBAAkB,GAAG,MAAM,KAAK,CAAC,kBAAkB,CAAC,OAAO,QAAQ,EAAE,EAAE,MAAM,KAAK,CAAC,UAAU,CAAC,SAAS;YACvG,UAAU;YACV,OAAO,GAAG,MAAM,KAAK,CAAC,eAAe,CAAC,QAAQ;kBAC9C;kBACA;YACA,UAAU,CAAC;gBACT,MAAM,MAAM,CAAC,WAAW,EAAE,MAAM,CAAC,KAAK;YACxC;YACA,OAAO,oBAAoB,KAAK;YAChC,qBAAqB,KAAK,CAAC,oBAAoB;YAC/C,oBAAoB,KAAK,CAAC,mBAAmB;YAC7C,gBAAgB,KAAK,CAAC,eAAe;QACvC;IAEJ;AACF;AAEA,2CAA2C;AAC3C,SAAS,iCAAW,EAAU,EAAE,EAAU,EAAE,CAAS;IACnD,OAAO,CAAC,EAAE,EAAE,GAAG,EAAE,EAAE,GAAG,GAAG,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,UAAU,EAAE,CAAC,IAAI,EAAE,GAAG,CAAC;AAC1G","sources":["packages/@react-aria/color/src/useColorWheel.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaColorWheelProps} from '@react-types/color';\nimport {ColorWheelState} from '@react-stately/color';\nimport {DOMAttributes, RefObject} from '@react-types/shared';\nimport {focusWithoutScrolling, mergeProps, useFormReset, useGlobalListeners, useLabels} from '@react-aria/utils';\nimport React, {ChangeEvent, InputHTMLAttributes, useCallback, useRef} from 'react';\nimport {useKeyboard, useMove} from '@react-aria/interactions';\nimport {useLocale} from '@react-aria/i18n';\nimport {useVisuallyHidden} from '@react-aria/visually-hidden';\n\nexport interface AriaColorWheelOptions extends AriaColorWheelProps {\n /** The outer radius of the color wheel. */\n outerRadius: number,\n /** The inner radius of the color wheel. */\n innerRadius: number\n}\n\nexport interface ColorWheelAria {\n /** Props for the track element. */\n trackProps: DOMAttributes,\n /** Props for the thumb element. */\n thumbProps: DOMAttributes,\n /** Props for the visually hidden range input element. */\n inputProps: InputHTMLAttributes<HTMLInputElement>\n}\n\n/**\n * Provides the behavior and accessibility implementation for a color wheel component.\n * Color wheels allow users to adjust the hue of an HSL or HSB color value on a circular track.\n */\nexport function useColorWheel(props: AriaColorWheelOptions, state: ColorWheelState, inputRef: RefObject<HTMLInputElement | null>): ColorWheelAria {\n let {\n isDisabled,\n innerRadius,\n outerRadius,\n 'aria-label': ariaLabel,\n name,\n form\n } = props;\n\n let {addGlobalListener, removeGlobalListener} = useGlobalListeners();\n\n let thumbRadius = (innerRadius + outerRadius) / 2;\n\n let focusInput = useCallback(() => {\n if (inputRef.current) {\n focusWithoutScrolling(inputRef.current);\n }\n }, [inputRef]);\n\n useFormReset(inputRef, state.defaultValue, state.setValue);\n\n let currentPosition = useRef<{x: number, y: number} | null>(null);\n\n let {keyboardProps} = useKeyboard({\n onKeyDown(e) {\n // these are the cases that useMove doesn't handle\n if (!/^(PageUp|PageDown)$/.test(e.key)) {\n e.continuePropagation();\n return;\n }\n // same handling as useMove, don't need to stop propagation, useKeyboard will do that for us\n e.preventDefault();\n // remember to set this and unset it so that onChangeEnd is fired\n state.setDragging(true);\n switch (e.key) {\n case 'PageUp':\n e.preventDefault();\n state.increment(state.pageStep);\n break;\n case 'PageDown':\n e.preventDefault();\n state.decrement(state.pageStep);\n break;\n }\n state.setDragging(false);\n }\n });\n\n let moveHandler = {\n onMoveStart() {\n currentPosition.current = null;\n state.setDragging(true);\n },\n onMove({deltaX, deltaY, pointerType, shiftKey}) {\n if (currentPosition.current == null) {\n currentPosition.current = state.getThumbPosition(thumbRadius);\n }\n currentPosition.current.x += deltaX;\n currentPosition.current.y += deltaY;\n if (pointerType === 'keyboard') {\n if (deltaX > 0 || deltaY < 0) {\n state.increment(shiftKey ? state.pageStep : state.step);\n } else if (deltaX < 0 || deltaY > 0) {\n state.decrement(shiftKey ? state.pageStep : state.step);\n }\n } else {\n state.setHueFromPoint(currentPosition.current.x, currentPosition.current.y, thumbRadius);\n }\n },\n onMoveEnd() {\n isOnTrack.current = false;\n state.setDragging(false);\n focusInput();\n }\n };\n let {moveProps: movePropsThumb} = useMove(moveHandler);\n\n let currentPointer = useRef<number | null | undefined>(undefined);\n let isOnTrack = useRef<boolean>(false);\n let {moveProps: movePropsContainer} = useMove({\n onMoveStart() {\n if (isOnTrack.current) {\n moveHandler.onMoveStart();\n }\n },\n onMove(e) {\n if (isOnTrack.current) {\n moveHandler.onMove(e);\n }\n },\n onMoveEnd() {\n if (isOnTrack.current) {\n moveHandler.onMoveEnd();\n }\n }\n });\n\n let onThumbDown = (id: number | null | undefined) => {\n if (!state.isDragging) {\n currentPointer.current = id;\n focusInput();\n state.setDragging(true);\n\n if (typeof PointerEvent !== 'undefined') {\n addGlobalListener(window, 'pointerup', onThumbUp, false);\n } else {\n addGlobalListener(window, 'mouseup', onThumbUp, false);\n addGlobalListener(window, 'touchend', onThumbUp, false);\n }\n }\n };\n\n let onThumbUp = (e) => {\n let id = e.pointerId ?? e.changedTouches?.[0].identifier;\n if (id === currentPointer.current) {\n focusInput();\n state.setDragging(false);\n currentPointer.current = undefined;\n isOnTrack.current = false;\n\n if (typeof PointerEvent !== 'undefined') {\n removeGlobalListener(window, 'pointerup', onThumbUp, false);\n } else {\n removeGlobalListener(window, 'mouseup', onThumbUp, false);\n removeGlobalListener(window, 'touchend', onThumbUp, false);\n }\n }\n };\n\n let onTrackDown = (track: Element, id: number | null | undefined, pageX: number, pageY: number) => {\n let rect = track.getBoundingClientRect();\n let x = pageX - rect.x - rect.width / 2;\n let y = pageY - rect.y - rect.height / 2;\n let radius = Math.sqrt(x * x + y * y);\n if (innerRadius < radius && radius < outerRadius && !state.isDragging && currentPointer.current === undefined) {\n isOnTrack.current = true;\n currentPointer.current = id;\n state.setHueFromPoint(x, y, radius);\n\n focusInput();\n state.setDragging(true);\n\n if (typeof PointerEvent !== 'undefined') {\n addGlobalListener(window, 'pointerup', onTrackUp, false);\n } else {\n addGlobalListener(window, 'mouseup', onTrackUp, false);\n addGlobalListener(window, 'touchend', onTrackUp, false);\n }\n }\n };\n\n let onTrackUp = (e) => {\n let id = e.pointerId ?? e.changedTouches?.[0].identifier;\n if (isOnTrack.current && id === currentPointer.current) {\n isOnTrack.current = false;\n currentPointer.current = undefined;\n state.setDragging(false);\n focusInput();\n\n\n if (typeof PointerEvent !== 'undefined') {\n removeGlobalListener(window, 'pointerup', onTrackUp, false);\n } else {\n removeGlobalListener(window, 'mouseup', onTrackUp, false);\n removeGlobalListener(window, 'touchend', onTrackUp, false);\n }\n }\n };\n\n let trackInteractions = isDisabled ? {} : mergeProps({\n ...(typeof PointerEvent !== 'undefined' ? {\n onPointerDown: (e: React.PointerEvent) => {\n if (e.pointerType === 'mouse' && (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey)) {\n return;\n }\n onTrackDown(e.currentTarget, e.pointerId, e.clientX, e.clientY);\n }} : {\n onMouseDown: (e: React.MouseEvent) => {\n if (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey) {\n return;\n }\n onTrackDown(e.currentTarget, undefined, e.clientX, e.clientY);\n },\n onTouchStart: (e: React.TouchEvent) => {\n onTrackDown(e.currentTarget, e.changedTouches[0].identifier, e.changedTouches[0].clientX, e.changedTouches[0].clientY);\n }\n })\n }, movePropsContainer);\n\n let thumbInteractions = isDisabled ? {} : mergeProps({\n onMouseDown: (e: React.MouseEvent) => {\n if (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey) {\n return;\n }\n onThumbDown(undefined);\n },\n onPointerDown: (e: React.PointerEvent) => {\n if (e.pointerType === 'mouse' && (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey)) {\n return;\n }\n onThumbDown(e.pointerId);\n },\n onTouchStart: (e: React.TouchEvent) => {\n onThumbDown(e.changedTouches[0].identifier);\n }\n }, keyboardProps, movePropsThumb);\n let {x, y} = state.getThumbPosition(thumbRadius);\n\n // Provide a default aria-label if none is given\n let {locale} = useLocale();\n if (ariaLabel == null && props['aria-labelledby'] == null) {\n ariaLabel = state.value.getChannelName('hue', locale);\n }\n\n let inputLabellingProps = useLabels({\n ...props,\n 'aria-label': ariaLabel\n });\n\n let {minValue, maxValue, step} = state.value.getChannelRange('hue');\n\n let forcedColorAdjustNoneStyle = {\n forcedColorAdjust: 'none'\n };\n\n let {visuallyHiddenProps} = useVisuallyHidden({\n style: {\n opacity: '0.0001',\n width: '100%',\n height: '100%',\n pointerEvents: 'none'\n }\n });\n\n return {\n trackProps: {\n ...trackInteractions,\n style: {\n position: 'relative',\n touchAction: 'none',\n width: outerRadius * 2,\n height: outerRadius * 2,\n background: `\n conic-gradient(\n from 90deg,\n hsl(0, 100%, 50%),\n hsl(30, 100%, 50%),\n hsl(60, 100%, 50%),\n hsl(90, 100%, 50%),\n hsl(120, 100%, 50%),\n hsl(150, 100%, 50%),\n hsl(180, 100%, 50%),\n hsl(210, 100%, 50%),\n hsl(240, 100%, 50%),\n hsl(270, 100%, 50%),\n hsl(300, 100%, 50%),\n hsl(330, 100%, 50%),\n hsl(360, 100%, 50%)\n )\n `,\n clipPath: `path(evenodd, \"${circlePath(outerRadius, outerRadius, outerRadius)} ${circlePath(outerRadius, outerRadius, innerRadius)}\")`,\n ...forcedColorAdjustNoneStyle\n }\n },\n thumbProps: {\n ...thumbInteractions,\n style: {\n position: 'absolute',\n left: outerRadius + x,\n top: outerRadius + y,\n transform: 'translate(-50%, -50%)',\n touchAction: 'none',\n ...forcedColorAdjustNoneStyle\n }\n },\n inputProps: mergeProps(\n inputLabellingProps,\n {\n type: 'range',\n min: String(minValue),\n max: String(maxValue),\n step: String(step),\n 'aria-valuetext': `${state.value.formatChannelValue('hue', locale)}, ${state.value.getHueName(locale)}`,\n disabled: isDisabled,\n value: `${state.value.getChannelValue('hue')}`,\n name,\n form,\n onChange: (e: ChangeEvent<HTMLInputElement>) => {\n state.setHue(parseFloat(e.target.value));\n },\n style: visuallyHiddenProps.style,\n 'aria-errormessage': props['aria-errormessage'],\n 'aria-describedby': props['aria-describedby'],\n 'aria-details': props['aria-details']\n }\n )\n };\n}\n\n// Creates an SVG path string for a circle.\nfunction circlePath(cx: number, cy: number, r: number) {\n return `M ${cx}, ${cy} m ${-r}, 0 a ${r}, ${r}, 0, 1, 0, ${r * 2}, 0 a ${r}, ${r}, 0, 1, 0 ${-r * 2}, 0`;\n}\n"],"names":[],"version":3,"file":"useColorWheel.module.js.map"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-aria/color",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.1.1",
|
|
4
4
|
"description": "Spectrum UI components in React",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/main.js",
|
|
@@ -26,18 +26,18 @@
|
|
|
26
26
|
"url": "https://github.com/adobe/react-spectrum"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@react-aria/i18n": "^3.12.
|
|
30
|
-
"@react-aria/interactions": "^3.25.
|
|
31
|
-
"@react-aria/numberfield": "^3.
|
|
32
|
-
"@react-aria/slider": "^3.
|
|
33
|
-
"@react-aria/spinbutton": "^3.6.
|
|
34
|
-
"@react-aria/textfield": "^3.
|
|
35
|
-
"@react-aria/utils": "^3.
|
|
36
|
-
"@react-aria/visually-hidden": "^3.8.
|
|
37
|
-
"@react-stately/color": "^3.
|
|
38
|
-
"@react-stately/form": "^3.1
|
|
39
|
-
"@react-types/color": "^3.
|
|
40
|
-
"@react-types/shared": "^3.
|
|
29
|
+
"@react-aria/i18n": "^3.12.12",
|
|
30
|
+
"@react-aria/interactions": "^3.25.5",
|
|
31
|
+
"@react-aria/numberfield": "^3.12.1",
|
|
32
|
+
"@react-aria/slider": "^3.8.1",
|
|
33
|
+
"@react-aria/spinbutton": "^3.6.18",
|
|
34
|
+
"@react-aria/textfield": "^3.18.1",
|
|
35
|
+
"@react-aria/utils": "^3.30.1",
|
|
36
|
+
"@react-aria/visually-hidden": "^3.8.27",
|
|
37
|
+
"@react-stately/color": "^3.9.1",
|
|
38
|
+
"@react-stately/form": "^3.2.1",
|
|
39
|
+
"@react-types/color": "^3.1.1",
|
|
40
|
+
"@react-types/shared": "^3.32.0",
|
|
41
41
|
"@swc/helpers": "^0.5.0"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
@@ -47,5 +47,5 @@
|
|
|
47
47
|
"publishConfig": {
|
|
48
48
|
"access": "public"
|
|
49
49
|
},
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "2c58ed3ddd9be9100af9b1d0cfd137fcdc95ba2d"
|
|
51
51
|
}
|
package/src/useColorArea.ts
CHANGED
|
@@ -54,7 +54,8 @@ export function useColorArea(props: AriaColorAreaOptions, state: ColorAreaState)
|
|
|
54
54
|
containerRef,
|
|
55
55
|
'aria-label': ariaLabel,
|
|
56
56
|
xName,
|
|
57
|
-
yName
|
|
57
|
+
yName,
|
|
58
|
+
form
|
|
58
59
|
} = props;
|
|
59
60
|
let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/color');
|
|
60
61
|
|
|
@@ -69,12 +70,7 @@ export function useColorArea(props: AriaColorAreaOptions, state: ColorAreaState)
|
|
|
69
70
|
}
|
|
70
71
|
}, [inputXRef]);
|
|
71
72
|
|
|
72
|
-
useFormReset(inputXRef,
|
|
73
|
-
let newColor = state.value
|
|
74
|
-
.withChannelValue(state.channels.xChannel, x)
|
|
75
|
-
.withChannelValue(state.channels.yChannel, y);
|
|
76
|
-
state.setValue(newColor);
|
|
77
|
-
});
|
|
73
|
+
useFormReset(inputXRef, state.defaultValue, state.setValue);
|
|
78
74
|
|
|
79
75
|
let [valueChangedViaKeyboard, setValueChangedViaKeyboard] = useState(false);
|
|
80
76
|
let [valueChangedViaInputChangeEvent, setValueChangedViaInputChangeEvent] = useState(false);
|
|
@@ -431,6 +427,7 @@ export function useColorArea(props: AriaColorAreaOptions, state: ColorAreaState)
|
|
|
431
427
|
disabled: isDisabled,
|
|
432
428
|
value: state.value.getChannelValue(xChannel),
|
|
433
429
|
name: xName,
|
|
430
|
+
form,
|
|
434
431
|
tabIndex: (isMobile || !focusedInput || focusedInput === 'x' ? undefined : -1),
|
|
435
432
|
/*
|
|
436
433
|
So that only a single "2d slider" control shows up when listing form elements for screen readers,
|
|
@@ -456,6 +453,7 @@ export function useColorArea(props: AriaColorAreaOptions, state: ColorAreaState)
|
|
|
456
453
|
disabled: isDisabled,
|
|
457
454
|
value: state.value.getChannelValue(yChannel),
|
|
458
455
|
name: yName,
|
|
456
|
+
form,
|
|
459
457
|
tabIndex: (isMobile || focusedInput === 'y' ? undefined : -1),
|
|
460
458
|
/*
|
|
461
459
|
So that only a single "2d slider" control shows up when listing form elements for screen readers,
|
package/src/useColorField.ts
CHANGED
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
useCallback,
|
|
21
21
|
useState
|
|
22
22
|
} from 'react';
|
|
23
|
-
import {mergeProps, useId} from '@react-aria/utils';
|
|
23
|
+
import {mergeProps, useFormReset, useId} from '@react-aria/utils';
|
|
24
24
|
import {privateValidationStateProp} from '@react-stately/form';
|
|
25
25
|
import {useFocusWithin, useScrollWheel} from '@react-aria/interactions';
|
|
26
26
|
import {useFormattedTextField} from '@react-aria/textfield';
|
|
@@ -108,7 +108,9 @@ export function useColorField(
|
|
|
108
108
|
...props,
|
|
109
109
|
id: inputId,
|
|
110
110
|
value: inputValue,
|
|
111
|
-
|
|
111
|
+
// Intentionally invalid value that will be ignored by onChange during form reset
|
|
112
|
+
// This is handled separately below.
|
|
113
|
+
defaultValue: '!',
|
|
112
114
|
validate: undefined,
|
|
113
115
|
[privateValidationStateProp]: state,
|
|
114
116
|
type: 'text',
|
|
@@ -116,6 +118,8 @@ export function useColorField(
|
|
|
116
118
|
onChange
|
|
117
119
|
}, state, ref);
|
|
118
120
|
|
|
121
|
+
useFormReset(ref, state.defaultColorValue, state.setColorValue);
|
|
122
|
+
|
|
119
123
|
inputProps = mergeProps(inputProps, spinButtonProps, focusWithinProps, {
|
|
120
124
|
role: 'textbox',
|
|
121
125
|
'aria-valuemax': null,
|
package/src/useColorSlider.ts
CHANGED
|
@@ -44,7 +44,7 @@ export interface ColorSliderAria {
|
|
|
44
44
|
* Color sliders allow users to adjust an individual channel of a color value.
|
|
45
45
|
*/
|
|
46
46
|
export function useColorSlider(props: AriaColorSliderOptions, state: ColorSliderState): ColorSliderAria {
|
|
47
|
-
let {trackRef, inputRef, orientation, channel, 'aria-label': ariaLabel, name} = props;
|
|
47
|
+
let {trackRef, inputRef, orientation, channel, 'aria-label': ariaLabel, name, form} = props;
|
|
48
48
|
|
|
49
49
|
let {locale, direction} = useLocale();
|
|
50
50
|
|
|
@@ -60,6 +60,7 @@ export function useColorSlider(props: AriaColorSliderOptions, state: ColorSlider
|
|
|
60
60
|
orientation,
|
|
61
61
|
isDisabled: props.isDisabled,
|
|
62
62
|
name,
|
|
63
|
+
form,
|
|
63
64
|
trackRef,
|
|
64
65
|
inputRef
|
|
65
66
|
}, state);
|
package/src/useColorWheel.ts
CHANGED
|
@@ -45,7 +45,8 @@ export function useColorWheel(props: AriaColorWheelOptions, state: ColorWheelSta
|
|
|
45
45
|
innerRadius,
|
|
46
46
|
outerRadius,
|
|
47
47
|
'aria-label': ariaLabel,
|
|
48
|
-
name
|
|
48
|
+
name,
|
|
49
|
+
form
|
|
49
50
|
} = props;
|
|
50
51
|
|
|
51
52
|
let {addGlobalListener, removeGlobalListener} = useGlobalListeners();
|
|
@@ -58,7 +59,7 @@ export function useColorWheel(props: AriaColorWheelOptions, state: ColorWheelSta
|
|
|
58
59
|
}
|
|
59
60
|
}, [inputRef]);
|
|
60
61
|
|
|
61
|
-
useFormReset(inputRef, state.
|
|
62
|
+
useFormReset(inputRef, state.defaultValue, state.setValue);
|
|
62
63
|
|
|
63
64
|
let currentPosition = useRef<{x: number, y: number} | null>(null);
|
|
64
65
|
|
|
@@ -325,6 +326,7 @@ export function useColorWheel(props: AriaColorWheelOptions, state: ColorWheelSta
|
|
|
325
326
|
disabled: isDisabled,
|
|
326
327
|
value: `${state.value.getChannelValue('hue')}`,
|
|
327
328
|
name,
|
|
329
|
+
form,
|
|
328
330
|
onChange: (e: ChangeEvent<HTMLInputElement>) => {
|
|
329
331
|
state.setHue(parseFloat(e.target.value));
|
|
330
332
|
},
|