@wistia/ui 0.8.12 → 0.8.13-beta.098b59ab.c299c8a
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.cjs +533 -493
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +25 -15
- package/dist/index.d.ts +25 -15
- package/dist/index.mjs +367 -328
- package/dist/index.mjs.map +1 -1
- package/package.json +16 -16
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
/*
|
|
3
|
-
* @license @wistia/ui v0.8.
|
|
3
|
+
* @license @wistia/ui v0.8.13-beta.098b59ab.c299c8a
|
|
4
4
|
*
|
|
5
5
|
* Copyright (c) 2024-2025, Wistia, Inc. and its affiliates.
|
|
6
6
|
*
|
|
@@ -1142,6 +1142,7 @@ var colorAliasTokens = css3`
|
|
|
1142
1142
|
// src/css/designTokens/borderRadius.tsx
|
|
1143
1143
|
import { css as css4 } from "styled-components";
|
|
1144
1144
|
var borderRadiusTokens = css4`
|
|
1145
|
+
--wui-border-radius-00: 0;
|
|
1145
1146
|
--wui-border-radius-01: 4px;
|
|
1146
1147
|
--wui-border-radius-02: 8px;
|
|
1147
1148
|
--wui-border-radius-03: 16px;
|
|
@@ -1967,6 +1968,43 @@ var useBoolean = (initialValue = false) => {
|
|
|
1967
1968
|
return [value, toggle, setTrue, setFalse, setValue];
|
|
1968
1969
|
};
|
|
1969
1970
|
|
|
1971
|
+
// src/hooks/useClipboard/useClipboard.ts
|
|
1972
|
+
import { useCallback as useCallback3 } from "react";
|
|
1973
|
+
|
|
1974
|
+
// src/private/hooks/useTimedToggle/useTimedToggle.ts
|
|
1975
|
+
import { useEffect as useEffect2, useRef as useRef2, useState as useState3 } from "react";
|
|
1976
|
+
var useTimedToggle = (initialValue) => {
|
|
1977
|
+
const [value, setValue] = useState3(false);
|
|
1978
|
+
const timeoutRef = useRef2();
|
|
1979
|
+
const initialValueRef = useRef2(initialValue);
|
|
1980
|
+
const toggleValue = (timeout) => {
|
|
1981
|
+
clearTimeout(timeoutRef.current);
|
|
1982
|
+
setValue(!initialValueRef.current);
|
|
1983
|
+
timeoutRef.current = window.setTimeout(() => setValue(initialValueRef.current), timeout);
|
|
1984
|
+
};
|
|
1985
|
+
useEffect2(() => () => clearTimeout(timeoutRef.current), []);
|
|
1986
|
+
return [value, toggleValue];
|
|
1987
|
+
};
|
|
1988
|
+
|
|
1989
|
+
// src/hooks/useClipboard/useClipboard.ts
|
|
1990
|
+
var useClipboard = (textToCopy, timeout = 1500) => {
|
|
1991
|
+
const [hasCopied, toggleHasCopied] = useTimedToggle(false);
|
|
1992
|
+
const [failedToCopy, toggleFailedToCopy] = useTimedToggle(false);
|
|
1993
|
+
const onCopy = useCallback3(async () => {
|
|
1994
|
+
try {
|
|
1995
|
+
await copyToClipboard(textToCopy);
|
|
1996
|
+
if (timeout && timeout > 0) {
|
|
1997
|
+
toggleHasCopied(timeout);
|
|
1998
|
+
}
|
|
1999
|
+
} catch (error) {
|
|
2000
|
+
if (error instanceof Error) {
|
|
2001
|
+
toggleFailedToCopy(timeout);
|
|
2002
|
+
}
|
|
2003
|
+
}
|
|
2004
|
+
}, [textToCopy, timeout, toggleHasCopied, toggleFailedToCopy]);
|
|
2005
|
+
return [onCopy, hasCopied, failedToCopy];
|
|
2006
|
+
};
|
|
2007
|
+
|
|
1970
2008
|
// src/hooks/useFilePicker/index.ts
|
|
1971
2009
|
import { useFilePicker, useImperativeFilePicker } from "use-file-picker";
|
|
1972
2010
|
import {
|
|
@@ -1977,11 +2015,241 @@ import {
|
|
|
1977
2015
|
PersistentFileAmountLimitValidator
|
|
1978
2016
|
} from "use-file-picker/validators";
|
|
1979
2017
|
|
|
2018
|
+
// src/hooks/useFocusTrap/useFocusTrap.ts
|
|
2019
|
+
import { useRef as useRef3, useCallback as useCallback4, useEffect as useEffect3 } from "react";
|
|
2020
|
+
import { isNotUndefined } from "@wistia/type-guards";
|
|
2021
|
+
|
|
2022
|
+
// src/hooks/useFocusTrap/helpers.ts
|
|
2023
|
+
var FOCUSABLE_ELEMENT_SELECTORS = 'a[href], area[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), iframe, object, [tabindex="0"], [contenteditable]';
|
|
2024
|
+
var coerceToString = (value) => value === null || value === void 0 ? "" : String(value);
|
|
2025
|
+
var isHiddenElement = (element) => {
|
|
2026
|
+
const { display, visibility } = window.getComputedStyle(element);
|
|
2027
|
+
const isHidden = display === "none" || element.style.display === "none" || visibility === "none" || element.style.visibility === "hidden";
|
|
2028
|
+
return element.offsetWidth <= 0 && element.offsetHeight <= 0 || isHidden;
|
|
2029
|
+
};
|
|
2030
|
+
var isVisibleElement = (element) => {
|
|
2031
|
+
let parentElement = element;
|
|
2032
|
+
while (parentElement) {
|
|
2033
|
+
if (parentElement === document.body) {
|
|
2034
|
+
break;
|
|
2035
|
+
}
|
|
2036
|
+
if (isHiddenElement(parentElement)) {
|
|
2037
|
+
return false;
|
|
2038
|
+
}
|
|
2039
|
+
parentElement = parentElement.parentNode;
|
|
2040
|
+
}
|
|
2041
|
+
return true;
|
|
2042
|
+
};
|
|
2043
|
+
var getElementTabIndex = (element) => {
|
|
2044
|
+
const tabIndex = element.getAttribute("tabindex");
|
|
2045
|
+
return Number.parseInt(tabIndex ?? void 0, 10);
|
|
2046
|
+
};
|
|
2047
|
+
var isTabIndexNaN = (element) => {
|
|
2048
|
+
const tabIndex = getElementTabIndex(element);
|
|
2049
|
+
return Number.isNaN(tabIndex);
|
|
2050
|
+
};
|
|
2051
|
+
var isFocusableElement = (element) => {
|
|
2052
|
+
const tabbableNodeRegEx = /input|select|textarea|button|object/;
|
|
2053
|
+
const nodeName = element.nodeName.toLowerCase();
|
|
2054
|
+
const isTabIndexNotNaN = !isTabIndexNaN(element);
|
|
2055
|
+
const isFocusable = (
|
|
2056
|
+
// @ts-expect-error - Disabled is specific to buttons and inputs, but we could be dealing with any number of types here. Disabled would be undefined for those, so ignoring.
|
|
2057
|
+
tabbableNodeRegEx.test(nodeName) && !element.disabled || (element instanceof HTMLAnchorElement ? element.href || isTabIndexNotNaN : isTabIndexNotNaN)
|
|
2058
|
+
);
|
|
2059
|
+
return Boolean(isFocusable) && isVisibleElement(element);
|
|
2060
|
+
};
|
|
2061
|
+
var isTabbableElement = (element) => {
|
|
2062
|
+
const tabIndex = getElementTabIndex(element);
|
|
2063
|
+
return (isTabIndexNaN(element) || tabIndex >= 0) && isFocusableElement(element);
|
|
2064
|
+
};
|
|
2065
|
+
var findTabbableDescendants = (element) => Array.from(element.querySelectorAll(FOCUSABLE_ELEMENT_SELECTORS)).filter(
|
|
2066
|
+
isTabbableElement
|
|
2067
|
+
);
|
|
2068
|
+
var focusLaterElements = [];
|
|
2069
|
+
var focusElement = null;
|
|
2070
|
+
var needToFocus = false;
|
|
2071
|
+
var handleBlur = () => {
|
|
2072
|
+
needToFocus = true;
|
|
2073
|
+
};
|
|
2074
|
+
var handleFocus = () => {
|
|
2075
|
+
if (needToFocus) {
|
|
2076
|
+
needToFocus = false;
|
|
2077
|
+
if (!focusElement) {
|
|
2078
|
+
return;
|
|
2079
|
+
}
|
|
2080
|
+
if (focusElement.contains(document.activeElement)) {
|
|
2081
|
+
return;
|
|
2082
|
+
}
|
|
2083
|
+
const element = findTabbableDescendants(focusElement)[0] ?? focusElement;
|
|
2084
|
+
element.focus();
|
|
2085
|
+
}
|
|
2086
|
+
};
|
|
2087
|
+
var markForFocusLater = () => {
|
|
2088
|
+
const element = document.activeElement;
|
|
2089
|
+
if (element !== null) {
|
|
2090
|
+
focusLaterElements.push(element);
|
|
2091
|
+
}
|
|
2092
|
+
};
|
|
2093
|
+
var returnFocus = () => {
|
|
2094
|
+
let toFocus = null;
|
|
2095
|
+
try {
|
|
2096
|
+
toFocus = focusLaterElements.pop();
|
|
2097
|
+
if (toFocus) {
|
|
2098
|
+
toFocus.focus();
|
|
2099
|
+
}
|
|
2100
|
+
} catch {
|
|
2101
|
+
console.warn(
|
|
2102
|
+
`You tried to return focus to ${coerceToString(toFocus)} but it is not in the DOM anymore`
|
|
2103
|
+
);
|
|
2104
|
+
}
|
|
2105
|
+
};
|
|
2106
|
+
var setupScopedFocus = (element) => {
|
|
2107
|
+
focusElement = element;
|
|
2108
|
+
document.addEventListener("focusout", handleBlur, false);
|
|
2109
|
+
document.addEventListener("focusin", handleFocus, true);
|
|
2110
|
+
};
|
|
2111
|
+
var teardownScopedFocus = () => {
|
|
2112
|
+
focusElement = null;
|
|
2113
|
+
document.removeEventListener("focusout", handleBlur);
|
|
2114
|
+
document.removeEventListener("focusin", handleFocus);
|
|
2115
|
+
};
|
|
2116
|
+
var scopeTab = (node, event) => {
|
|
2117
|
+
const tabbable = findTabbableDescendants(node);
|
|
2118
|
+
if (!tabbable.length) {
|
|
2119
|
+
event.preventDefault();
|
|
2120
|
+
return;
|
|
2121
|
+
}
|
|
2122
|
+
const finalTabbable = tabbable[event.shiftKey ? 0 : tabbable.length - 1];
|
|
2123
|
+
const leavingFinalTabbable = finalTabbable === document.activeElement || node === document.activeElement;
|
|
2124
|
+
if (!leavingFinalTabbable) {
|
|
2125
|
+
return;
|
|
2126
|
+
}
|
|
2127
|
+
event.preventDefault();
|
|
2128
|
+
const target = tabbable[event.shiftKey ? tabbable.length - 1 : 0];
|
|
2129
|
+
if (target) {
|
|
2130
|
+
target.focus();
|
|
2131
|
+
}
|
|
2132
|
+
};
|
|
2133
|
+
var createAriaHider = (containerNode, selector) => {
|
|
2134
|
+
selector ??= "body > :not(script)";
|
|
2135
|
+
const rootNodes = Array.from(document.querySelectorAll(selector)).map((node) => {
|
|
2136
|
+
if (node.contains(containerNode)) {
|
|
2137
|
+
return void 0;
|
|
2138
|
+
}
|
|
2139
|
+
const ariaHidden = node.getAttribute("aria-hidden");
|
|
2140
|
+
if (ariaHidden === null || ariaHidden === "false") {
|
|
2141
|
+
node.setAttribute("aria-hidden", "true");
|
|
2142
|
+
}
|
|
2143
|
+
return {
|
|
2144
|
+
node,
|
|
2145
|
+
ariaHidden
|
|
2146
|
+
};
|
|
2147
|
+
});
|
|
2148
|
+
return () => {
|
|
2149
|
+
rootNodes.forEach((item) => {
|
|
2150
|
+
if (!item) {
|
|
2151
|
+
return;
|
|
2152
|
+
}
|
|
2153
|
+
if (item.ariaHidden === null) {
|
|
2154
|
+
item.node.removeAttribute("aria-hidden");
|
|
2155
|
+
} else {
|
|
2156
|
+
item.node.setAttribute("aria-hidden", item.ariaHidden);
|
|
2157
|
+
}
|
|
2158
|
+
});
|
|
2159
|
+
};
|
|
2160
|
+
};
|
|
2161
|
+
|
|
2162
|
+
// src/hooks/useFocusTrap/useFocusTrap.ts
|
|
2163
|
+
var isRef = (val) => {
|
|
2164
|
+
return val !== null && typeof val === "object" && "current" in val;
|
|
2165
|
+
};
|
|
2166
|
+
var useFocusTrap = (active = true, options = {}) => {
|
|
2167
|
+
const ref = useRef3(null);
|
|
2168
|
+
const restoreAriaRef = useRef3(null);
|
|
2169
|
+
const setRef = useCallback4(
|
|
2170
|
+
(node) => {
|
|
2171
|
+
if (restoreAriaRef.current !== null) {
|
|
2172
|
+
restoreAriaRef.current();
|
|
2173
|
+
}
|
|
2174
|
+
if (ref.current) {
|
|
2175
|
+
returnFocus();
|
|
2176
|
+
teardownScopedFocus();
|
|
2177
|
+
}
|
|
2178
|
+
if (active && node !== null && node !== void 0) {
|
|
2179
|
+
setupScopedFocus(node);
|
|
2180
|
+
markForFocusLater();
|
|
2181
|
+
const processNode = (node2) => {
|
|
2182
|
+
restoreAriaRef.current = !(options.disableAriaHider ?? false) ? createAriaHider(node2) : null;
|
|
2183
|
+
let focusElement2 = null;
|
|
2184
|
+
if (isNotUndefined(options.focusSelector)) {
|
|
2185
|
+
if (isRef(options.focusSelector)) {
|
|
2186
|
+
focusElement2 = options.focusSelector.current;
|
|
2187
|
+
} else {
|
|
2188
|
+
focusElement2 = typeof options.focusSelector === "string" ? node2.querySelector(options.focusSelector) : options.focusSelector;
|
|
2189
|
+
}
|
|
2190
|
+
}
|
|
2191
|
+
if (!focusElement2) {
|
|
2192
|
+
const children = Array.from(
|
|
2193
|
+
node2.querySelectorAll(FOCUSABLE_ELEMENT_SELECTORS)
|
|
2194
|
+
);
|
|
2195
|
+
focusElement2 = // Prefer tabbable elements, But fallback to any focusable element
|
|
2196
|
+
children.find(isTabbableElement) ?? // But fallback to any focusable element
|
|
2197
|
+
children.find(isFocusableElement) ?? // Nothing found
|
|
2198
|
+
null;
|
|
2199
|
+
if (!focusElement2 && isFocusableElement(node2)) {
|
|
2200
|
+
focusElement2 = node2;
|
|
2201
|
+
}
|
|
2202
|
+
}
|
|
2203
|
+
if (focusElement2) {
|
|
2204
|
+
focusElement2.focus();
|
|
2205
|
+
}
|
|
2206
|
+
if (!focusElement2 && process.env["NODE_ENV"] === "development") {
|
|
2207
|
+
console.warn(
|
|
2208
|
+
'[useFocusTrap]: Failed to find a focusable element after activating the focus trap. Make sure to include at an element that can recieve focus. As a fallback, you can also set "tabIndex={-1}" on the focus trap node.',
|
|
2209
|
+
node2
|
|
2210
|
+
);
|
|
2211
|
+
}
|
|
2212
|
+
};
|
|
2213
|
+
setTimeout(() => {
|
|
2214
|
+
if (node.ownerDocument) {
|
|
2215
|
+
processNode(node);
|
|
2216
|
+
}
|
|
2217
|
+
if (!node.ownerDocument && process.env["NODE_ENV"] === "development") {
|
|
2218
|
+
console.warn(
|
|
2219
|
+
"[useFocusTrap]: The focus trap is not part of the DOM yet, so it is unable to correctly set focus. Make sure to render the ref node.",
|
|
2220
|
+
node
|
|
2221
|
+
);
|
|
2222
|
+
}
|
|
2223
|
+
});
|
|
2224
|
+
ref.current = node;
|
|
2225
|
+
} else {
|
|
2226
|
+
ref.current = null;
|
|
2227
|
+
}
|
|
2228
|
+
},
|
|
2229
|
+
[active, options.focusSelector, options.disableAriaHider]
|
|
2230
|
+
);
|
|
2231
|
+
useEffect3(() => {
|
|
2232
|
+
if (!active) {
|
|
2233
|
+
return void 0;
|
|
2234
|
+
}
|
|
2235
|
+
const handleKeyDown = (event) => {
|
|
2236
|
+
if (event.key === "Tab" && ref.current) {
|
|
2237
|
+
scopeTab(ref.current, event);
|
|
2238
|
+
}
|
|
2239
|
+
};
|
|
2240
|
+
document.addEventListener("keydown", handleKeyDown);
|
|
2241
|
+
return () => {
|
|
2242
|
+
document.removeEventListener("keydown", handleKeyDown);
|
|
2243
|
+
};
|
|
2244
|
+
}, [active]);
|
|
2245
|
+
return setRef;
|
|
2246
|
+
};
|
|
2247
|
+
|
|
1980
2248
|
// src/hooks/useKey/useKey.ts
|
|
1981
|
-
import { useCallback as
|
|
2249
|
+
import { useCallback as useCallback5 } from "react";
|
|
1982
2250
|
|
|
1983
2251
|
// src/private/hooks/useEvent/useEvent.ts
|
|
1984
|
-
import { useEffect as
|
|
2252
|
+
import { useEffect as useEffect4, useRef as useRef4 } from "react";
|
|
1985
2253
|
|
|
1986
2254
|
// src/private/helpers/isValidRef/isValidRef.ts
|
|
1987
2255
|
import { isNotNil as isNotNil2, isRecord } from "@wistia/type-guards";
|
|
@@ -2000,15 +2268,15 @@ var isEventTargetSupported = (eventTarget) => (
|
|
|
2000
2268
|
!!(typeof eventTarget === "object" && eventTarget?.addEventListener)
|
|
2001
2269
|
);
|
|
2002
2270
|
var useEvent = (eventName, eventHandler, eventTarget = window, eventOptions = {}) => {
|
|
2003
|
-
const savedEventHandler =
|
|
2004
|
-
const savedEventOptions =
|
|
2005
|
-
|
|
2271
|
+
const savedEventHandler = useRef4();
|
|
2272
|
+
const savedEventOptions = useRef4();
|
|
2273
|
+
useEffect4(() => {
|
|
2006
2274
|
savedEventHandler.current = eventHandler;
|
|
2007
2275
|
}, [eventHandler]);
|
|
2008
|
-
|
|
2276
|
+
useEffect4(() => {
|
|
2009
2277
|
savedEventOptions.current = eventOptions;
|
|
2010
2278
|
}, [eventOptions]);
|
|
2011
|
-
|
|
2279
|
+
useEffect4(() => {
|
|
2012
2280
|
const target = isValidRef(eventTarget) ? eventTarget.current : eventTarget;
|
|
2013
2281
|
if (!eventName || !isEventTargetSupported(target)) {
|
|
2014
2282
|
return;
|
|
@@ -2028,7 +2296,7 @@ var useEvent = (eventName, eventHandler, eventTarget = window, eventOptions = {}
|
|
|
2028
2296
|
|
|
2029
2297
|
// src/hooks/useKey/useKey.ts
|
|
2030
2298
|
var useKey = (key, eventHandler, { eventName = "keydown", eventTarget, eventOptions } = {}) => {
|
|
2031
|
-
const memoizedEventHandler =
|
|
2299
|
+
const memoizedEventHandler = useCallback5(
|
|
2032
2300
|
(handlerEvent) => {
|
|
2033
2301
|
if (["INPUT", "TEXTAREA", "SELECT"].includes(document.activeElement?.nodeName ?? "") || document.activeElement?.isContentEditable) {
|
|
2034
2302
|
return;
|
|
@@ -2053,9 +2321,9 @@ var useKey = (key, eventHandler, { eventName = "keydown", eventTarget, eventOpti
|
|
|
2053
2321
|
};
|
|
2054
2322
|
|
|
2055
2323
|
// src/hooks/useLocalStorage/useLocalStorage.ts
|
|
2056
|
-
import { useState as
|
|
2324
|
+
import { useState as useState4 } from "react";
|
|
2057
2325
|
var useLocalStorage = (key, initialValue, storage = window.localStorage) => {
|
|
2058
|
-
const [storedValue, setStoredValue] =
|
|
2326
|
+
const [storedValue, setStoredValue] = useState4(() => {
|
|
2059
2327
|
try {
|
|
2060
2328
|
const item = storage.getItem(key);
|
|
2061
2329
|
return item !== null && !!item ? JSON.parse(item) : initialValue;
|
|
@@ -2095,40 +2363,11 @@ var useLockBodyScroll = (locked) => {
|
|
|
2095
2363
|
}, [locked]);
|
|
2096
2364
|
};
|
|
2097
2365
|
|
|
2098
|
-
// src/hooks/useOnClickOutside/useOnClickOutside.ts
|
|
2099
|
-
import { useEffect as useEffect3 } from "react";
|
|
2100
|
-
var useOnClickOutside = (ref, handler, eventTypes = ["mousedown", "touchend"]) => {
|
|
2101
|
-
useEffect3(() => {
|
|
2102
|
-
const listener = (event) => {
|
|
2103
|
-
if (!ref.current || ref.current.contains(event.target)) {
|
|
2104
|
-
return;
|
|
2105
|
-
}
|
|
2106
|
-
handler(event);
|
|
2107
|
-
};
|
|
2108
|
-
if (Array.isArray(eventTypes)) {
|
|
2109
|
-
eventTypes.forEach((eventType) => {
|
|
2110
|
-
document.addEventListener(eventType, listener);
|
|
2111
|
-
});
|
|
2112
|
-
} else {
|
|
2113
|
-
document.addEventListener(eventTypes, listener);
|
|
2114
|
-
}
|
|
2115
|
-
return () => {
|
|
2116
|
-
if (Array.isArray(eventTypes)) {
|
|
2117
|
-
eventTypes.forEach((eventType) => {
|
|
2118
|
-
document.removeEventListener(eventType, listener);
|
|
2119
|
-
});
|
|
2120
|
-
} else {
|
|
2121
|
-
document.removeEventListener(eventTypes, listener);
|
|
2122
|
-
}
|
|
2123
|
-
};
|
|
2124
|
-
}, [ref, handler, eventTypes]);
|
|
2125
|
-
};
|
|
2126
|
-
|
|
2127
2366
|
// src/hooks/useMq/useMq.ts
|
|
2128
2367
|
import { isBoolean } from "@wistia/type-guards";
|
|
2129
2368
|
|
|
2130
2369
|
// src/hooks/useWindowSize/useWindowSize.ts
|
|
2131
|
-
import { useState as
|
|
2370
|
+
import { useState as useState5, useLayoutEffect as useLayoutEffect2 } from "react";
|
|
2132
2371
|
import { debounce } from "throttle-debounce";
|
|
2133
2372
|
|
|
2134
2373
|
// src/private/helpers/isClient/isClient.ts
|
|
@@ -2136,7 +2375,7 @@ var isClient = () => typeof window !== "undefined" && typeof document !== "undef
|
|
|
2136
2375
|
|
|
2137
2376
|
// src/hooks/useWindowSize/useWindowSize.ts
|
|
2138
2377
|
var useWindowSize = (interval = 0) => {
|
|
2139
|
-
const [dimensions, setDimensions] =
|
|
2378
|
+
const [dimensions, setDimensions] = useState5({
|
|
2140
2379
|
width: isClient() ? window.innerWidth : 0,
|
|
2141
2380
|
height: isClient() ? window.innerHeight : 0
|
|
2142
2381
|
});
|
|
@@ -2191,8 +2430,37 @@ var useActiveMq = () => {
|
|
|
2191
2430
|
});
|
|
2192
2431
|
};
|
|
2193
2432
|
|
|
2433
|
+
// src/hooks/useOnClickOutside/useOnClickOutside.ts
|
|
2434
|
+
import { useEffect as useEffect5 } from "react";
|
|
2435
|
+
var useOnClickOutside = (ref, handler, eventTypes = ["mousedown", "touchend"]) => {
|
|
2436
|
+
useEffect5(() => {
|
|
2437
|
+
const listener = (event) => {
|
|
2438
|
+
if (!ref.current || ref.current.contains(event.target)) {
|
|
2439
|
+
return;
|
|
2440
|
+
}
|
|
2441
|
+
handler(event);
|
|
2442
|
+
};
|
|
2443
|
+
if (Array.isArray(eventTypes)) {
|
|
2444
|
+
eventTypes.forEach((eventType) => {
|
|
2445
|
+
document.addEventListener(eventType, listener);
|
|
2446
|
+
});
|
|
2447
|
+
} else {
|
|
2448
|
+
document.addEventListener(eventTypes, listener);
|
|
2449
|
+
}
|
|
2450
|
+
return () => {
|
|
2451
|
+
if (Array.isArray(eventTypes)) {
|
|
2452
|
+
eventTypes.forEach((eventType) => {
|
|
2453
|
+
document.removeEventListener(eventType, listener);
|
|
2454
|
+
});
|
|
2455
|
+
} else {
|
|
2456
|
+
document.removeEventListener(eventTypes, listener);
|
|
2457
|
+
}
|
|
2458
|
+
};
|
|
2459
|
+
}, [ref, handler, eventTypes]);
|
|
2460
|
+
};
|
|
2461
|
+
|
|
2194
2462
|
// src/hooks/useToast/useToast.tsx
|
|
2195
|
-
import { useCallback as
|
|
2463
|
+
import { useCallback as useCallback6 } from "react";
|
|
2196
2464
|
import { toast as sonnerToast } from "sonner";
|
|
2197
2465
|
|
|
2198
2466
|
// src/private/components/Toast/Toast.tsx
|
|
@@ -2471,7 +2739,7 @@ Toast.displayName = "Toast";
|
|
|
2471
2739
|
// src/hooks/useToast/useToast.tsx
|
|
2472
2740
|
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
2473
2741
|
var useToast = () => {
|
|
2474
|
-
return
|
|
2742
|
+
return useCallback6(
|
|
2475
2743
|
({ message, action, colorScheme, icon, position = "bottom-left", duration = 3e3 }) => {
|
|
2476
2744
|
sonnerToast.custom(
|
|
2477
2745
|
() => {
|
|
@@ -2492,238 +2760,6 @@ var useToast = () => {
|
|
|
2492
2760
|
);
|
|
2493
2761
|
};
|
|
2494
2762
|
|
|
2495
|
-
// src/hooks/useFocusTrap/useFocusTrap.ts
|
|
2496
|
-
import { useRef as useRef3, useCallback as useCallback5, useEffect as useEffect4 } from "react";
|
|
2497
|
-
import { isNotUndefined } from "@wistia/type-guards";
|
|
2498
|
-
|
|
2499
|
-
// src/hooks/useFocusTrap/helpers.ts
|
|
2500
|
-
var FOCUSABLE_ELEMENT_SELECTORS = 'a[href], area[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), iframe, object, [tabindex="0"], [contenteditable]';
|
|
2501
|
-
var coerceToString = (value) => value === null || value === void 0 ? "" : String(value);
|
|
2502
|
-
var isHiddenElement = (element) => {
|
|
2503
|
-
const { display, visibility } = window.getComputedStyle(element);
|
|
2504
|
-
const isHidden = display === "none" || element.style.display === "none" || visibility === "none" || element.style.visibility === "hidden";
|
|
2505
|
-
return element.offsetWidth <= 0 && element.offsetHeight <= 0 || isHidden;
|
|
2506
|
-
};
|
|
2507
|
-
var isVisibleElement = (element) => {
|
|
2508
|
-
let parentElement = element;
|
|
2509
|
-
while (parentElement) {
|
|
2510
|
-
if (parentElement === document.body) {
|
|
2511
|
-
break;
|
|
2512
|
-
}
|
|
2513
|
-
if (isHiddenElement(parentElement)) {
|
|
2514
|
-
return false;
|
|
2515
|
-
}
|
|
2516
|
-
parentElement = parentElement.parentNode;
|
|
2517
|
-
}
|
|
2518
|
-
return true;
|
|
2519
|
-
};
|
|
2520
|
-
var getElementTabIndex = (element) => {
|
|
2521
|
-
const tabIndex = element.getAttribute("tabindex");
|
|
2522
|
-
return Number.parseInt(tabIndex ?? void 0, 10);
|
|
2523
|
-
};
|
|
2524
|
-
var isTabIndexNaN = (element) => {
|
|
2525
|
-
const tabIndex = getElementTabIndex(element);
|
|
2526
|
-
return Number.isNaN(tabIndex);
|
|
2527
|
-
};
|
|
2528
|
-
var isFocusableElement = (element) => {
|
|
2529
|
-
const tabbableNodeRegEx = /input|select|textarea|button|object/;
|
|
2530
|
-
const nodeName = element.nodeName.toLowerCase();
|
|
2531
|
-
const isTabIndexNotNaN = !isTabIndexNaN(element);
|
|
2532
|
-
const isFocusable = (
|
|
2533
|
-
// @ts-expect-error - Disabled is specific to buttons and inputs, but we could be dealing with any number of types here. Disabled would be undefined for those, so ignoring.
|
|
2534
|
-
tabbableNodeRegEx.test(nodeName) && !element.disabled || (element instanceof HTMLAnchorElement ? element.href || isTabIndexNotNaN : isTabIndexNotNaN)
|
|
2535
|
-
);
|
|
2536
|
-
return Boolean(isFocusable) && isVisibleElement(element);
|
|
2537
|
-
};
|
|
2538
|
-
var isTabbableElement = (element) => {
|
|
2539
|
-
const tabIndex = getElementTabIndex(element);
|
|
2540
|
-
return (isTabIndexNaN(element) || tabIndex >= 0) && isFocusableElement(element);
|
|
2541
|
-
};
|
|
2542
|
-
var findTabbableDescendants = (element) => Array.from(element.querySelectorAll(FOCUSABLE_ELEMENT_SELECTORS)).filter(
|
|
2543
|
-
isTabbableElement
|
|
2544
|
-
);
|
|
2545
|
-
var focusLaterElements = [];
|
|
2546
|
-
var focusElement = null;
|
|
2547
|
-
var needToFocus = false;
|
|
2548
|
-
var handleBlur = () => {
|
|
2549
|
-
needToFocus = true;
|
|
2550
|
-
};
|
|
2551
|
-
var handleFocus = () => {
|
|
2552
|
-
if (needToFocus) {
|
|
2553
|
-
needToFocus = false;
|
|
2554
|
-
if (!focusElement) {
|
|
2555
|
-
return;
|
|
2556
|
-
}
|
|
2557
|
-
if (focusElement.contains(document.activeElement)) {
|
|
2558
|
-
return;
|
|
2559
|
-
}
|
|
2560
|
-
const element = findTabbableDescendants(focusElement)[0] ?? focusElement;
|
|
2561
|
-
element.focus();
|
|
2562
|
-
}
|
|
2563
|
-
};
|
|
2564
|
-
var markForFocusLater = () => {
|
|
2565
|
-
const element = document.activeElement;
|
|
2566
|
-
if (element !== null) {
|
|
2567
|
-
focusLaterElements.push(element);
|
|
2568
|
-
}
|
|
2569
|
-
};
|
|
2570
|
-
var returnFocus = () => {
|
|
2571
|
-
let toFocus = null;
|
|
2572
|
-
try {
|
|
2573
|
-
toFocus = focusLaterElements.pop();
|
|
2574
|
-
if (toFocus) {
|
|
2575
|
-
toFocus.focus();
|
|
2576
|
-
}
|
|
2577
|
-
} catch {
|
|
2578
|
-
console.warn(
|
|
2579
|
-
`You tried to return focus to ${coerceToString(toFocus)} but it is not in the DOM anymore`
|
|
2580
|
-
);
|
|
2581
|
-
}
|
|
2582
|
-
};
|
|
2583
|
-
var setupScopedFocus = (element) => {
|
|
2584
|
-
focusElement = element;
|
|
2585
|
-
document.addEventListener("focusout", handleBlur, false);
|
|
2586
|
-
document.addEventListener("focusin", handleFocus, true);
|
|
2587
|
-
};
|
|
2588
|
-
var teardownScopedFocus = () => {
|
|
2589
|
-
focusElement = null;
|
|
2590
|
-
document.removeEventListener("focusout", handleBlur);
|
|
2591
|
-
document.removeEventListener("focusin", handleFocus);
|
|
2592
|
-
};
|
|
2593
|
-
var scopeTab = (node, event) => {
|
|
2594
|
-
const tabbable = findTabbableDescendants(node);
|
|
2595
|
-
if (!tabbable.length) {
|
|
2596
|
-
event.preventDefault();
|
|
2597
|
-
return;
|
|
2598
|
-
}
|
|
2599
|
-
const finalTabbable = tabbable[event.shiftKey ? 0 : tabbable.length - 1];
|
|
2600
|
-
const leavingFinalTabbable = finalTabbable === document.activeElement || node === document.activeElement;
|
|
2601
|
-
if (!leavingFinalTabbable) {
|
|
2602
|
-
return;
|
|
2603
|
-
}
|
|
2604
|
-
event.preventDefault();
|
|
2605
|
-
const target = tabbable[event.shiftKey ? tabbable.length - 1 : 0];
|
|
2606
|
-
if (target) {
|
|
2607
|
-
target.focus();
|
|
2608
|
-
}
|
|
2609
|
-
};
|
|
2610
|
-
var createAriaHider = (containerNode, selector) => {
|
|
2611
|
-
if (selector === void 0) {
|
|
2612
|
-
selector = "body > :not(script)";
|
|
2613
|
-
}
|
|
2614
|
-
const rootNodes = Array.from(document.querySelectorAll(selector)).map((node) => {
|
|
2615
|
-
if (node.contains(containerNode)) {
|
|
2616
|
-
return void 0;
|
|
2617
|
-
}
|
|
2618
|
-
const ariaHidden = node.getAttribute("aria-hidden");
|
|
2619
|
-
if (ariaHidden === null || ariaHidden === "false") {
|
|
2620
|
-
node.setAttribute("aria-hidden", "true");
|
|
2621
|
-
}
|
|
2622
|
-
return {
|
|
2623
|
-
node,
|
|
2624
|
-
ariaHidden
|
|
2625
|
-
};
|
|
2626
|
-
});
|
|
2627
|
-
return () => {
|
|
2628
|
-
rootNodes.forEach((item) => {
|
|
2629
|
-
if (!item) {
|
|
2630
|
-
return;
|
|
2631
|
-
}
|
|
2632
|
-
if (item.ariaHidden === null) {
|
|
2633
|
-
item.node.removeAttribute("aria-hidden");
|
|
2634
|
-
} else {
|
|
2635
|
-
item.node.setAttribute("aria-hidden", item.ariaHidden);
|
|
2636
|
-
}
|
|
2637
|
-
});
|
|
2638
|
-
};
|
|
2639
|
-
};
|
|
2640
|
-
|
|
2641
|
-
// src/hooks/useFocusTrap/useFocusTrap.ts
|
|
2642
|
-
var isRef = (val) => {
|
|
2643
|
-
return val !== null && typeof val === "object" && "current" in val;
|
|
2644
|
-
};
|
|
2645
|
-
var useFocusTrap = (active = true, options = {}) => {
|
|
2646
|
-
const ref = useRef3(null);
|
|
2647
|
-
const restoreAriaRef = useRef3(null);
|
|
2648
|
-
const setRef = useCallback5(
|
|
2649
|
-
(node) => {
|
|
2650
|
-
if (restoreAriaRef.current !== null) {
|
|
2651
|
-
restoreAriaRef.current();
|
|
2652
|
-
}
|
|
2653
|
-
if (ref.current) {
|
|
2654
|
-
returnFocus();
|
|
2655
|
-
teardownScopedFocus();
|
|
2656
|
-
}
|
|
2657
|
-
if (active && node !== null && node !== void 0) {
|
|
2658
|
-
setupScopedFocus(node);
|
|
2659
|
-
markForFocusLater();
|
|
2660
|
-
const processNode = (node2) => {
|
|
2661
|
-
restoreAriaRef.current = !(options.disableAriaHider ?? false) ? createAriaHider(node2) : null;
|
|
2662
|
-
let focusElement2 = null;
|
|
2663
|
-
if (isNotUndefined(options.focusSelector)) {
|
|
2664
|
-
if (isRef(options.focusSelector)) {
|
|
2665
|
-
focusElement2 = options.focusSelector.current;
|
|
2666
|
-
} else {
|
|
2667
|
-
focusElement2 = typeof options.focusSelector === "string" ? node2.querySelector(options.focusSelector) : options.focusSelector;
|
|
2668
|
-
}
|
|
2669
|
-
}
|
|
2670
|
-
if (!focusElement2) {
|
|
2671
|
-
const children = Array.from(
|
|
2672
|
-
node2.querySelectorAll(FOCUSABLE_ELEMENT_SELECTORS)
|
|
2673
|
-
);
|
|
2674
|
-
focusElement2 = // Prefer tabbable elements, But fallback to any focusable element
|
|
2675
|
-
children.find(isTabbableElement) ?? // But fallback to any focusable element
|
|
2676
|
-
children.find(isFocusableElement) ?? // Nothing found
|
|
2677
|
-
null;
|
|
2678
|
-
if (!focusElement2 && isFocusableElement(node2)) {
|
|
2679
|
-
focusElement2 = node2;
|
|
2680
|
-
}
|
|
2681
|
-
}
|
|
2682
|
-
if (focusElement2) {
|
|
2683
|
-
focusElement2.focus();
|
|
2684
|
-
}
|
|
2685
|
-
if (!focusElement2 && process.env["NODE_ENV"] === "development") {
|
|
2686
|
-
console.warn(
|
|
2687
|
-
'[useFocusTrap]: Failed to find a focusable element after activating the focus trap. Make sure to include at an element that can recieve focus. As a fallback, you can also set "tabIndex={-1}" on the focus trap node.',
|
|
2688
|
-
node2
|
|
2689
|
-
);
|
|
2690
|
-
}
|
|
2691
|
-
};
|
|
2692
|
-
setTimeout(() => {
|
|
2693
|
-
if (node.ownerDocument) {
|
|
2694
|
-
processNode(node);
|
|
2695
|
-
}
|
|
2696
|
-
if (!node.ownerDocument && process.env["NODE_ENV"] === "development") {
|
|
2697
|
-
console.warn(
|
|
2698
|
-
"[useFocusTrap]: The focus trap is not part of the DOM yet, so it is unable to correctly set focus. Make sure to render the ref node.",
|
|
2699
|
-
node
|
|
2700
|
-
);
|
|
2701
|
-
}
|
|
2702
|
-
});
|
|
2703
|
-
ref.current = node;
|
|
2704
|
-
} else {
|
|
2705
|
-
ref.current = null;
|
|
2706
|
-
}
|
|
2707
|
-
},
|
|
2708
|
-
[active, options.focusSelector, options.disableAriaHider]
|
|
2709
|
-
);
|
|
2710
|
-
useEffect4(() => {
|
|
2711
|
-
if (!active) {
|
|
2712
|
-
return void 0;
|
|
2713
|
-
}
|
|
2714
|
-
const handleKeyDown = (event) => {
|
|
2715
|
-
if (event.key === "Tab" && ref.current) {
|
|
2716
|
-
scopeTab(ref.current, event);
|
|
2717
|
-
}
|
|
2718
|
-
};
|
|
2719
|
-
document.addEventListener("keydown", handleKeyDown);
|
|
2720
|
-
return () => {
|
|
2721
|
-
document.removeEventListener("keydown", handleKeyDown);
|
|
2722
|
-
};
|
|
2723
|
-
}, [active]);
|
|
2724
|
-
return setRef;
|
|
2725
|
-
};
|
|
2726
|
-
|
|
2727
2763
|
// src/components/ActionButton/ActionButton.tsx
|
|
2728
2764
|
import { forwardRef as forwardRef3 } from "react";
|
|
2729
2765
|
import styled6, { css as css17 } from "styled-components";
|
|
@@ -7266,7 +7302,7 @@ var ActionButton = forwardRef3(
|
|
|
7266
7302
|
ActionButton.displayName = "ActionButton";
|
|
7267
7303
|
|
|
7268
7304
|
// src/components/Avatar/Avatar.tsx
|
|
7269
|
-
import { useState as
|
|
7305
|
+
import { useState as useState6, useMemo as useMemo3, useEffect as useEffect6 } from "react";
|
|
7270
7306
|
import { isNil as isNil8, isNotNil as isNotNil8 } from "@wistia/type-guards";
|
|
7271
7307
|
import styled9 from "styled-components";
|
|
7272
7308
|
|
|
@@ -7474,8 +7510,8 @@ var Avatar = ({
|
|
|
7474
7510
|
onImageLoad,
|
|
7475
7511
|
...props
|
|
7476
7512
|
}) => {
|
|
7477
|
-
const [imageLoadState, setImageLoadState] =
|
|
7478
|
-
|
|
7513
|
+
const [imageLoadState, setImageLoadState] = useState6("loading");
|
|
7514
|
+
useEffect6(() => {
|
|
7479
7515
|
setImageLoadState("loading");
|
|
7480
7516
|
}, [imageUrl]);
|
|
7481
7517
|
const handleImageLoad = () => {
|
|
@@ -7914,7 +7950,7 @@ var StyledCard = styled15(Box)`
|
|
|
7914
7950
|
background-color: ${({ $backgroundColor }) => $backgroundColor};
|
|
7915
7951
|
outline: 2px solid ${({ $borderColor }) => $borderColor};
|
|
7916
7952
|
outline-offset: -2px;
|
|
7917
|
-
border-radius: var(--wui
|
|
7953
|
+
border-radius: ${({ $borderRadius }) => `var(--wui-${$borderRadius})`};
|
|
7918
7954
|
display: flex;
|
|
7919
7955
|
height: ${({ $height }) => $height};
|
|
7920
7956
|
width: ${({ $width }) => $width};
|
|
@@ -7935,13 +7971,14 @@ var prominenceMap = {
|
|
|
7935
7971
|
};
|
|
7936
7972
|
var Card = ({
|
|
7937
7973
|
children,
|
|
7938
|
-
paddingSize = "space-04",
|
|
7939
|
-
gap = "space-03",
|
|
7940
|
-
direction = "column",
|
|
7941
|
-
colorScheme = "inherit",
|
|
7942
|
-
prominence = "secondary",
|
|
7943
7974
|
border = false,
|
|
7975
|
+
borderRadius = "border-radius-04",
|
|
7976
|
+
colorScheme = "inherit",
|
|
7977
|
+
direction = "column",
|
|
7978
|
+
gap = "space-03",
|
|
7944
7979
|
height,
|
|
7980
|
+
paddingSize = "space-04",
|
|
7981
|
+
prominence = "secondary",
|
|
7945
7982
|
width,
|
|
7946
7983
|
...props
|
|
7947
7984
|
}) => /* @__PURE__ */ jsx203(
|
|
@@ -7949,6 +7986,7 @@ var Card = ({
|
|
|
7949
7986
|
{
|
|
7950
7987
|
$backgroundColor: prominenceMap[prominence].backgroundColor,
|
|
7951
7988
|
$borderColor: border ? prominenceMap[prominence].borderColor : "transparent",
|
|
7989
|
+
$borderRadius: borderRadius,
|
|
7952
7990
|
$colorScheme: colorScheme,
|
|
7953
7991
|
$height: height,
|
|
7954
7992
|
$paddingSize: paddingSize,
|
|
@@ -8271,9 +8309,9 @@ var Checkbox = forwardRef7(
|
|
|
8271
8309
|
Checkbox.displayName = "Checkbox";
|
|
8272
8310
|
|
|
8273
8311
|
// src/components/ClickRegion/ClickRegion.tsx
|
|
8274
|
-
import { Children as Children3, cloneElement as cloneElement3, useCallback as
|
|
8312
|
+
import { Children as Children3, cloneElement as cloneElement3, useCallback as useCallback7, useEffect as useEffect7 } from "react";
|
|
8275
8313
|
var ClickRegion = ({ children, targetRef }) => {
|
|
8276
|
-
|
|
8314
|
+
useEffect7(() => {
|
|
8277
8315
|
if (targetRef.current && targetRef.current.tagName === "A") {
|
|
8278
8316
|
targetRef.current.setAttribute("data-click-region-target-link", "");
|
|
8279
8317
|
} else if (targetRef.current && targetRef.current.tagName === "BUTTON") {
|
|
@@ -8281,7 +8319,7 @@ var ClickRegion = ({ children, targetRef }) => {
|
|
|
8281
8319
|
} else {
|
|
8282
8320
|
}
|
|
8283
8321
|
}, [targetRef]);
|
|
8284
|
-
const handleClick =
|
|
8322
|
+
const handleClick = useCallback7(
|
|
8285
8323
|
(event) => {
|
|
8286
8324
|
const node = targetRef.current;
|
|
8287
8325
|
if (event.target instanceof HTMLAnchorElement && !event.target.hasAttribute("data-click-region-target-link") || event.target instanceof HTMLButtonElement && !event.target.hasAttribute("data-click-region-target-button")) {
|
|
@@ -8910,7 +8948,7 @@ Divider.displayName = "Divider";
|
|
|
8910
8948
|
|
|
8911
8949
|
// src/components/EditableHeading/EditableHeading.tsx
|
|
8912
8950
|
import styled31, { css as css27 } from "styled-components";
|
|
8913
|
-
import { useState as
|
|
8951
|
+
import { useState as useState7, useRef as useRef6 } from "react";
|
|
8914
8952
|
|
|
8915
8953
|
// src/components/Tooltip/Tooltip.tsx
|
|
8916
8954
|
import {
|
|
@@ -9014,7 +9052,7 @@ var Tooltip = ({
|
|
|
9014
9052
|
Tooltip.displayName = "Tooltip";
|
|
9015
9053
|
|
|
9016
9054
|
// src/components/Input/Input.tsx
|
|
9017
|
-
import { forwardRef as forwardRef10, cloneElement as cloneElement4, useRef as
|
|
9055
|
+
import { forwardRef as forwardRef10, cloneElement as cloneElement4, useRef as useRef5 } from "react";
|
|
9018
9056
|
import styled30, { css as css26 } from "styled-components";
|
|
9019
9057
|
import { isNil as isNil13, isNotNil as isNotNil16, isRecord as isRecord4 } from "@wistia/type-guards";
|
|
9020
9058
|
|
|
@@ -9159,7 +9197,7 @@ var Input = forwardRef10(
|
|
|
9159
9197
|
rightIcon,
|
|
9160
9198
|
...props
|
|
9161
9199
|
}, externalRef) => {
|
|
9162
|
-
const internalRef =
|
|
9200
|
+
const internalRef = useRef5();
|
|
9163
9201
|
const ref = (
|
|
9164
9202
|
// eslint-disable-next-line react-compiler/react-compiler
|
|
9165
9203
|
isNotNil16(externalRef) && isRecord4(externalRef) && "current" in externalRef ? externalRef : internalRef
|
|
@@ -9268,11 +9306,11 @@ var EditableHeading = ({
|
|
|
9268
9306
|
__forceEditing = false,
|
|
9269
9307
|
editingDisabled = false
|
|
9270
9308
|
}) => {
|
|
9271
|
-
const [isEditing, setIsEditing] =
|
|
9272
|
-
const [value, setValue] =
|
|
9273
|
-
const [previousValue, setPreviousValue] =
|
|
9274
|
-
const [headingHeight, setHeadingHeight] =
|
|
9275
|
-
const headingRef =
|
|
9309
|
+
const [isEditing, setIsEditing] = useState7(false);
|
|
9310
|
+
const [value, setValue] = useState7(children);
|
|
9311
|
+
const [previousValue, setPreviousValue] = useState7(children);
|
|
9312
|
+
const [headingHeight, setHeadingHeight] = useState7("60");
|
|
9313
|
+
const headingRef = useRef6(null);
|
|
9276
9314
|
const handleSetEditing = (editing) => {
|
|
9277
9315
|
if (editingDisabled) return;
|
|
9278
9316
|
if (editing && headingRef.current) {
|
|
@@ -9351,7 +9389,7 @@ var EditableHeading = ({
|
|
|
9351
9389
|
};
|
|
9352
9390
|
|
|
9353
9391
|
// src/components/Form/Form.tsx
|
|
9354
|
-
import { forwardRef as forwardRef12, useRef as
|
|
9392
|
+
import { forwardRef as forwardRef12, useRef as useRef7, useMemo as useMemo4, createContext as createContext3, useState as useState8, useId as useId2 } from "react";
|
|
9355
9393
|
import styled33 from "styled-components";
|
|
9356
9394
|
import { isNotUndefined as isNotUndefined7, isUndefined as isUndefined3 } from "@wistia/type-guards";
|
|
9357
9395
|
|
|
@@ -9411,9 +9449,9 @@ var FormComponent = ({
|
|
|
9411
9449
|
fullWidth = false,
|
|
9412
9450
|
...props
|
|
9413
9451
|
}, forwardedRef) => {
|
|
9414
|
-
const [errors, setErrors] =
|
|
9415
|
-
const [hasSubmitted, setHasSubmitted] =
|
|
9416
|
-
const innerRef =
|
|
9452
|
+
const [errors, setErrors] = useState8({});
|
|
9453
|
+
const [hasSubmitted, setHasSubmitted] = useState8(false);
|
|
9454
|
+
const innerRef = useRef7();
|
|
9417
9455
|
const ref = forwardedRef ?? innerRef;
|
|
9418
9456
|
const autoId = useId2();
|
|
9419
9457
|
const id = props.id ?? autoId;
|
|
@@ -9489,12 +9527,12 @@ FormComponent.displayName = "Form";
|
|
|
9489
9527
|
var Form = forwardRef12(FormComponent);
|
|
9490
9528
|
|
|
9491
9529
|
// src/components/Form/useFormState.tsx
|
|
9492
|
-
import { useCallback as
|
|
9530
|
+
import { useCallback as useCallback8, useState as useState9 } from "react";
|
|
9493
9531
|
var useFormState = (action, initialData = {}) => {
|
|
9494
|
-
const [data, setData] =
|
|
9495
|
-
const [isPending, setIsPending] =
|
|
9496
|
-
const [error, setError] =
|
|
9497
|
-
const formAction =
|
|
9532
|
+
const [data, setData] = useState9(initialData);
|
|
9533
|
+
const [isPending, setIsPending] = useState9(false);
|
|
9534
|
+
const [error, setError] = useState9(null);
|
|
9535
|
+
const formAction = useCallback8(
|
|
9498
9536
|
async (nextFormData) => {
|
|
9499
9537
|
if (nextFormData === null) {
|
|
9500
9538
|
setData(initialData);
|
|
@@ -9525,14 +9563,14 @@ var useFormState = (action, initialData = {}) => {
|
|
|
9525
9563
|
};
|
|
9526
9564
|
|
|
9527
9565
|
// src/components/Form/FormErrorSummary.tsx
|
|
9528
|
-
import { useContext as useContext3, useRef as
|
|
9566
|
+
import { useContext as useContext3, useRef as useRef8 } from "react";
|
|
9529
9567
|
import { isArray, isNotUndefined as isNotUndefined8 } from "@wistia/type-guards";
|
|
9530
9568
|
import { jsx as jsx223, jsxs as jsxs22 } from "react/jsx-runtime";
|
|
9531
9569
|
var ErrorItem = ({ name, error, formId }) => {
|
|
9532
9570
|
return /* @__PURE__ */ jsx223("li", { children: /* @__PURE__ */ jsx223(Link, { href: `#${formId}-${name}`, children: error }) }, name);
|
|
9533
9571
|
};
|
|
9534
9572
|
var FormErrorSummary = ({ description }) => {
|
|
9535
|
-
const ref =
|
|
9573
|
+
const ref = useRef8(null);
|
|
9536
9574
|
const { formId, errors, hasSubmitted } = useContext3(FormContext);
|
|
9537
9575
|
const isValid = Object.keys(errors).length === 0;
|
|
9538
9576
|
if (isValid || !hasSubmitted) {
|
|
@@ -9632,7 +9670,7 @@ import { createContext as createContext4, useMemo as useMemo5 } from "react";
|
|
|
9632
9670
|
|
|
9633
9671
|
// src/components/FormGroup/FormGroup.tsx
|
|
9634
9672
|
import styled35 from "styled-components";
|
|
9635
|
-
import { useRef as
|
|
9673
|
+
import { useRef as useRef9 } from "react";
|
|
9636
9674
|
import { jsx as jsx225, jsxs as jsxs23 } from "react/jsx-runtime";
|
|
9637
9675
|
var StyledFieldset = styled35.fieldset`
|
|
9638
9676
|
border: 0;
|
|
@@ -9641,7 +9679,7 @@ var StyledLegend = styled35.legend`
|
|
|
9641
9679
|
margin-bottom: var(--space-01);
|
|
9642
9680
|
`;
|
|
9643
9681
|
var FormGroup = ({ children, label, ...props }) => {
|
|
9644
|
-
const ref =
|
|
9682
|
+
const ref = useRef9();
|
|
9645
9683
|
return /* @__PURE__ */ jsxs23(
|
|
9646
9684
|
Stack,
|
|
9647
9685
|
{
|
|
@@ -9885,7 +9923,7 @@ IconButton.displayName = "IconButton";
|
|
|
9885
9923
|
|
|
9886
9924
|
// src/components/InputClickToCopy/InputClickToCopy.tsx
|
|
9887
9925
|
import styled38 from "styled-components";
|
|
9888
|
-
import { forwardRef as forwardRef14, useEffect as
|
|
9926
|
+
import { forwardRef as forwardRef14, useEffect as useEffect8, useState as useState10 } from "react";
|
|
9889
9927
|
import { isFunction as isFunction3 } from "@wistia/type-guards";
|
|
9890
9928
|
import { jsx as jsx230 } from "react/jsx-runtime";
|
|
9891
9929
|
var StyledInput2 = styled38(Input)`
|
|
@@ -9900,8 +9938,8 @@ var StyledInput2 = styled38(Input)`
|
|
|
9900
9938
|
var COPY_SUCCESS_DURATION = 2e3;
|
|
9901
9939
|
var InputClickToCopy = forwardRef14(
|
|
9902
9940
|
({ value, onCopy, ...props }, ref) => {
|
|
9903
|
-
const [isCopied, setIsCopied] =
|
|
9904
|
-
|
|
9941
|
+
const [isCopied, setIsCopied] = useState10(false);
|
|
9942
|
+
useEffect8(() => {
|
|
9905
9943
|
if (isCopied) {
|
|
9906
9944
|
const timeout = setTimeout(() => {
|
|
9907
9945
|
setIsCopied(false);
|
|
@@ -10139,7 +10177,7 @@ var MenuLabel = ({ children, ...props }) => {
|
|
|
10139
10177
|
MenuLabel.displayName = "MenuLabel";
|
|
10140
10178
|
|
|
10141
10179
|
// src/components/Menu/SubMenu.tsx
|
|
10142
|
-
import { useState as
|
|
10180
|
+
import { useState as useState11 } from "react";
|
|
10143
10181
|
import styled43 from "styled-components";
|
|
10144
10182
|
import {
|
|
10145
10183
|
DropdownMenuPortal as DropdownMenuPortal2,
|
|
@@ -10325,7 +10363,7 @@ var SubMenu = ({
|
|
|
10325
10363
|
...props
|
|
10326
10364
|
}) => {
|
|
10327
10365
|
const { isSmAndUp } = useMq();
|
|
10328
|
-
const [isExpanded, setIsExpanded] =
|
|
10366
|
+
const [isExpanded, setIsExpanded] = useState11(false);
|
|
10329
10367
|
const { compact } = useMenuContext();
|
|
10330
10368
|
return isSmAndUp ? /* @__PURE__ */ jsxs27(DropdownMenuSub, { onOpenChange, children: [
|
|
10331
10369
|
/* @__PURE__ */ jsxs27(SubMenuTrigger, { ...props, children: [
|
|
@@ -10582,14 +10620,14 @@ import styled46 from "styled-components";
|
|
|
10582
10620
|
import { Content as DialogContent } from "@radix-ui/react-dialog";
|
|
10583
10621
|
|
|
10584
10622
|
// src/private/hooks/useFocusRestore/useFocusRestore.ts
|
|
10585
|
-
import { useRef as
|
|
10623
|
+
import { useRef as useRef10, useEffect as useEffect9 } from "react";
|
|
10586
10624
|
import { isNotNil as isNotNil22 } from "@wistia/type-guards";
|
|
10587
10625
|
var useFocusRestore = () => {
|
|
10588
|
-
const previouslyFocusedRef =
|
|
10589
|
-
|
|
10626
|
+
const previouslyFocusedRef = useRef10(null);
|
|
10627
|
+
useEffect9(() => {
|
|
10590
10628
|
previouslyFocusedRef.current = document.activeElement;
|
|
10591
10629
|
}, []);
|
|
10592
|
-
|
|
10630
|
+
useEffect9(() => {
|
|
10593
10631
|
return () => {
|
|
10594
10632
|
if (isNotNil22(previouslyFocusedRef.current)) {
|
|
10595
10633
|
setTimeout(() => {
|
|
@@ -11109,13 +11147,13 @@ import { Root as ToggleGroupRoot } from "@radix-ui/react-toggle-group";
|
|
|
11109
11147
|
import { isNil as isNil14 } from "@wistia/type-guards";
|
|
11110
11148
|
|
|
11111
11149
|
// src/components/SegmentedControl/useSelectedItemStyle.tsx
|
|
11112
|
-
import { createContext as createContext7, useContext as useContext6, useMemo as useMemo8, useState as
|
|
11150
|
+
import { createContext as createContext7, useContext as useContext6, useMemo as useMemo8, useState as useState12 } from "react";
|
|
11113
11151
|
import { jsx as jsx248 } from "react/jsx-runtime";
|
|
11114
11152
|
var SelectedItemStyleContext = createContext7(null);
|
|
11115
11153
|
var SelectedItemStyleProvider = ({
|
|
11116
11154
|
children
|
|
11117
11155
|
}) => {
|
|
11118
|
-
const [selectedItemMeasurements, setSelectedItemMeasurements] =
|
|
11156
|
+
const [selectedItemMeasurements, setSelectedItemMeasurements] = useState12(null);
|
|
11119
11157
|
const selectedItemIndicatorStyle = useMemo8(
|
|
11120
11158
|
() => selectedItemMeasurements != null ? {
|
|
11121
11159
|
height: `${selectedItemMeasurements.offsetHeight}px`,
|
|
@@ -11232,7 +11270,7 @@ var SegmentedControl = forwardRef21(
|
|
|
11232
11270
|
SegmentedControl.displayName = "SegmentedControl";
|
|
11233
11271
|
|
|
11234
11272
|
// src/components/SegmentedControl/SegmentedControlItem.tsx
|
|
11235
|
-
import { forwardRef as forwardRef22, useEffect as
|
|
11273
|
+
import { forwardRef as forwardRef22, useEffect as useEffect10, useRef as useRef11 } from "react";
|
|
11236
11274
|
import styled54, { css as css33 } from "styled-components";
|
|
11237
11275
|
import { Item as ToggleGroupItem } from "@radix-ui/react-toggle-group";
|
|
11238
11276
|
import { isNotNil as isNotNil26 } from "@wistia/type-guards";
|
|
@@ -11304,7 +11342,7 @@ var SegmentedControlItem = forwardRef22(
|
|
|
11304
11342
|
({ disabled, icon, label, "aria-label": ariaLabel, value }, forwardedRef) => {
|
|
11305
11343
|
const selectedValue = useSegmentedControlValue();
|
|
11306
11344
|
const { setSelectedItemMeasurements } = useSelectedItemStyle();
|
|
11307
|
-
const buttonRef =
|
|
11345
|
+
const buttonRef = useRef11(null);
|
|
11308
11346
|
const combinedRef = mergeRefs([buttonRef, forwardedRef]);
|
|
11309
11347
|
const handleClick = (event) => {
|
|
11310
11348
|
const target = event.target;
|
|
@@ -11313,7 +11351,7 @@ var SegmentedControlItem = forwardRef22(
|
|
|
11313
11351
|
event.preventDefault();
|
|
11314
11352
|
}
|
|
11315
11353
|
};
|
|
11316
|
-
|
|
11354
|
+
useEffect10(() => {
|
|
11317
11355
|
const buttonElem = buttonRef.current;
|
|
11318
11356
|
if (!buttonElem) {
|
|
11319
11357
|
return void 0;
|
|
@@ -11827,7 +11865,7 @@ var TableRow = ({ children, ...props }) => {
|
|
|
11827
11865
|
};
|
|
11828
11866
|
|
|
11829
11867
|
// src/components/Tabs/Tabs.tsx
|
|
11830
|
-
import { forwardRef as forwardRef27, useState as
|
|
11868
|
+
import { forwardRef as forwardRef27, useState as useState13 } from "react";
|
|
11831
11869
|
import { Root as TabsRoot } from "@radix-ui/react-tabs";
|
|
11832
11870
|
import { isNotNil as isNotNil29, isNil as isNil15 } from "@wistia/type-guards";
|
|
11833
11871
|
import styled69 from "styled-components";
|
|
@@ -11882,7 +11920,7 @@ var TabList = ({
|
|
|
11882
11920
|
TabList.displayName = "TabList";
|
|
11883
11921
|
|
|
11884
11922
|
// src/components/Tabs/TabItem.tsx
|
|
11885
|
-
import { forwardRef as forwardRef26, useEffect as
|
|
11923
|
+
import { forwardRef as forwardRef26, useEffect as useEffect11, useRef as useRef12 } from "react";
|
|
11886
11924
|
import styled67 from "styled-components";
|
|
11887
11925
|
import { Trigger as RadixTab } from "@radix-ui/react-tabs";
|
|
11888
11926
|
import { isNotNil as isNotNil28 } from "@wistia/type-guards";
|
|
@@ -11912,9 +11950,9 @@ var TabItem = forwardRef26(
|
|
|
11912
11950
|
({ disabled = false, icon, label, "aria-label": ariaLabel, value }, forwardedRef) => {
|
|
11913
11951
|
const selectedValue = useTabsValue();
|
|
11914
11952
|
const { setSelectedItemMeasurements } = useSelectedItemStyle();
|
|
11915
|
-
const buttonRef =
|
|
11953
|
+
const buttonRef = useRef12(null);
|
|
11916
11954
|
const combinedRef = mergeRefs([buttonRef, forwardedRef]);
|
|
11917
|
-
|
|
11955
|
+
useEffect11(() => {
|
|
11918
11956
|
const buttonElem = buttonRef.current;
|
|
11919
11957
|
if (!buttonElem) {
|
|
11920
11958
|
return void 0;
|
|
@@ -12026,7 +12064,7 @@ var Tabs = forwardRef27(
|
|
|
12026
12064
|
...props
|
|
12027
12065
|
}, ref) => {
|
|
12028
12066
|
const tabItems = extractTabItems(children);
|
|
12029
|
-
const [internalSelectedValue, setInternalSelectedValue] =
|
|
12067
|
+
const [internalSelectedValue, setInternalSelectedValue] = useState13(defaultSelectedValue);
|
|
12030
12068
|
const modeProps = defaultSelectedValue !== void 0 ? {
|
|
12031
12069
|
defaultValue: defaultSelectedValue,
|
|
12032
12070
|
onValueChange: setInternalSelectedValue
|
|
@@ -12852,6 +12890,7 @@ export {
|
|
|
12852
12890
|
useActiveMq,
|
|
12853
12891
|
useAriaLive,
|
|
12854
12892
|
useBoolean,
|
|
12893
|
+
useClipboard,
|
|
12855
12894
|
useFilePicker,
|
|
12856
12895
|
useFocusTrap,
|
|
12857
12896
|
useFormState,
|