@wistia/ui 1.4.0-beta.6d6b0d49.f3e7b2c → 1.4.0-beta.8a83d969.4c2fe4e
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/index.js +11 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
/*
|
|
3
|
-
* @license @wistia/ui v1.4.0-beta.
|
|
3
|
+
* @license @wistia/ui v1.4.0-beta.8a83d969.4c2fe4e
|
|
4
4
|
*
|
|
5
5
|
* Copyright (c) 2024-2026, Wistia, Inc. and its affiliates.
|
|
6
6
|
*
|
|
@@ -8954,7 +8954,7 @@ const HexColorInput = ({ autoFocus = true }) => {
|
|
|
8954
8954
|
const inputRef = useRef(null);
|
|
8955
8955
|
const [textInputValue, setTextInputValue] = useState(valueAsHex);
|
|
8956
8956
|
const onChangeInputValue = useCallback((event) => {
|
|
8957
|
-
const newValue = (event.target.value
|
|
8957
|
+
const newValue = normalizeHexInput(event.target.value);
|
|
8958
8958
|
setTextInputValue(newValue);
|
|
8959
8959
|
if (!Boolean(parseHex(newValue))) return;
|
|
8960
8960
|
if (newValue.length < SIX_DIGIT_HEX_CODE_LENGTH) return;
|
|
@@ -8980,7 +8980,8 @@ const HexColorInput = ({ autoFocus = true }) => {
|
|
|
8980
8980
|
}, []);
|
|
8981
8981
|
const onKeyDown = useCallback((event) => {
|
|
8982
8982
|
const { key, target, metaKey, ctrlKey } = event;
|
|
8983
|
-
const
|
|
8983
|
+
const input = target;
|
|
8984
|
+
const { selectionStart, selectionEnd, value } = input;
|
|
8984
8985
|
if (metaKey || ctrlKey) return;
|
|
8985
8986
|
if (key === "ArrowUp" || key === "ArrowDown") {
|
|
8986
8987
|
event.preventDefault();
|
|
@@ -8998,7 +8999,7 @@ const HexColorInput = ({ autoFocus = true }) => {
|
|
|
8998
8999
|
event.preventDefault();
|
|
8999
9000
|
return;
|
|
9000
9001
|
}
|
|
9001
|
-
if (value.length >= SIX_DIGIT_HEX_CODE_LENGTH && selectionStart === selectionEnd)
|
|
9002
|
+
if (value.length >= SIX_DIGIT_HEX_CODE_LENGTH && selectionStart === selectionEnd) input.setSelectionRange(1, value.length);
|
|
9002
9003
|
}, [
|
|
9003
9004
|
valueAsHex,
|
|
9004
9005
|
onChangeNonDerivedValueAsHsv,
|
|
@@ -9019,8 +9020,12 @@ const HexColorInput = ({ autoFocus = true }) => {
|
|
|
9019
9020
|
inputElem.setSelectionRange(1, inputElem.value.length);
|
|
9020
9021
|
}, []);
|
|
9021
9022
|
const onFocusInput = useCallback(() => {
|
|
9022
|
-
|
|
9023
|
-
|
|
9023
|
+
const inputElem = inputRef.current;
|
|
9024
|
+
if (!inputElem) return;
|
|
9025
|
+
const valueOnFocus = inputElem.value;
|
|
9026
|
+
requestAnimationFrame(() => {
|
|
9027
|
+
if (inputRef.current?.value === valueOnFocus) selectAllButTheHash();
|
|
9028
|
+
});
|
|
9024
9029
|
}, [selectAllButTheHash]);
|
|
9025
9030
|
useEffect(() => {
|
|
9026
9031
|
if (!autoFocus) return;
|
|
@@ -9036,7 +9041,6 @@ const HexColorInput = ({ autoFocus = true }) => {
|
|
|
9036
9041
|
ref: inputRef,
|
|
9037
9042
|
"aria-label": "Hex color input",
|
|
9038
9043
|
autoComplete: "off",
|
|
9039
|
-
maxLength: SIX_DIGIT_HEX_CODE_LENGTH,
|
|
9040
9044
|
monospace: true,
|
|
9041
9045
|
onChange: onChangeInputValue,
|
|
9042
9046
|
onCopy,
|