@wistia/ui 0.8.13 → 0.8.14-beta.2385e790.bd3e5c4
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 +562 -511
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +42 -27
- package/dist/index.d.ts +42 -27
- package/dist/index.mjs +393 -343
- package/dist/index.mjs.map +1 -1
- package/package.json +21 -21
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.14-beta.2385e790.bd3e5c4
|
|
4
4
|
*
|
|
5
5
|
* Copyright (c) 2024-2025, Wistia, Inc. and its affiliates.
|
|
6
6
|
*
|
|
@@ -1968,6 +1968,43 @@ var useBoolean = (initialValue = false) => {
|
|
|
1968
1968
|
return [value, toggle, setTrue, setFalse, setValue];
|
|
1969
1969
|
};
|
|
1970
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
|
+
|
|
1971
2008
|
// src/hooks/useFilePicker/index.ts
|
|
1972
2009
|
import { useFilePicker, useImperativeFilePicker } from "use-file-picker";
|
|
1973
2010
|
import {
|
|
@@ -1978,11 +2015,241 @@ import {
|
|
|
1978
2015
|
PersistentFileAmountLimitValidator
|
|
1979
2016
|
} from "use-file-picker/validators";
|
|
1980
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
|
+
|
|
1981
2248
|
// src/hooks/useKey/useKey.ts
|
|
1982
|
-
import { useCallback as
|
|
2249
|
+
import { useCallback as useCallback5 } from "react";
|
|
1983
2250
|
|
|
1984
2251
|
// src/private/hooks/useEvent/useEvent.ts
|
|
1985
|
-
import { useEffect as
|
|
2252
|
+
import { useEffect as useEffect4, useRef as useRef4 } from "react";
|
|
1986
2253
|
|
|
1987
2254
|
// src/private/helpers/isValidRef/isValidRef.ts
|
|
1988
2255
|
import { isNotNil as isNotNil2, isRecord } from "@wistia/type-guards";
|
|
@@ -2001,15 +2268,15 @@ var isEventTargetSupported = (eventTarget) => (
|
|
|
2001
2268
|
!!(typeof eventTarget === "object" && eventTarget?.addEventListener)
|
|
2002
2269
|
);
|
|
2003
2270
|
var useEvent = (eventName, eventHandler, eventTarget = window, eventOptions = {}) => {
|
|
2004
|
-
const savedEventHandler =
|
|
2005
|
-
const savedEventOptions =
|
|
2006
|
-
|
|
2271
|
+
const savedEventHandler = useRef4();
|
|
2272
|
+
const savedEventOptions = useRef4();
|
|
2273
|
+
useEffect4(() => {
|
|
2007
2274
|
savedEventHandler.current = eventHandler;
|
|
2008
2275
|
}, [eventHandler]);
|
|
2009
|
-
|
|
2276
|
+
useEffect4(() => {
|
|
2010
2277
|
savedEventOptions.current = eventOptions;
|
|
2011
2278
|
}, [eventOptions]);
|
|
2012
|
-
|
|
2279
|
+
useEffect4(() => {
|
|
2013
2280
|
const target = isValidRef(eventTarget) ? eventTarget.current : eventTarget;
|
|
2014
2281
|
if (!eventName || !isEventTargetSupported(target)) {
|
|
2015
2282
|
return;
|
|
@@ -2029,7 +2296,7 @@ var useEvent = (eventName, eventHandler, eventTarget = window, eventOptions = {}
|
|
|
2029
2296
|
|
|
2030
2297
|
// src/hooks/useKey/useKey.ts
|
|
2031
2298
|
var useKey = (key, eventHandler, { eventName = "keydown", eventTarget, eventOptions } = {}) => {
|
|
2032
|
-
const memoizedEventHandler =
|
|
2299
|
+
const memoizedEventHandler = useCallback5(
|
|
2033
2300
|
(handlerEvent) => {
|
|
2034
2301
|
if (["INPUT", "TEXTAREA", "SELECT"].includes(document.activeElement?.nodeName ?? "") || document.activeElement?.isContentEditable) {
|
|
2035
2302
|
return;
|
|
@@ -2054,9 +2321,9 @@ var useKey = (key, eventHandler, { eventName = "keydown", eventTarget, eventOpti
|
|
|
2054
2321
|
};
|
|
2055
2322
|
|
|
2056
2323
|
// src/hooks/useLocalStorage/useLocalStorage.ts
|
|
2057
|
-
import { useState as
|
|
2324
|
+
import { useState as useState4 } from "react";
|
|
2058
2325
|
var useLocalStorage = (key, initialValue, storage = window.localStorage) => {
|
|
2059
|
-
const [storedValue, setStoredValue] =
|
|
2326
|
+
const [storedValue, setStoredValue] = useState4(() => {
|
|
2060
2327
|
try {
|
|
2061
2328
|
const item = storage.getItem(key);
|
|
2062
2329
|
return item !== null && !!item ? JSON.parse(item) : initialValue;
|
|
@@ -2096,40 +2363,11 @@ var useLockBodyScroll = (locked) => {
|
|
|
2096
2363
|
}, [locked]);
|
|
2097
2364
|
};
|
|
2098
2365
|
|
|
2099
|
-
// src/hooks/useOnClickOutside/useOnClickOutside.ts
|
|
2100
|
-
import { useEffect as useEffect3 } from "react";
|
|
2101
|
-
var useOnClickOutside = (ref, handler, eventTypes = ["mousedown", "touchend"]) => {
|
|
2102
|
-
useEffect3(() => {
|
|
2103
|
-
const listener = (event) => {
|
|
2104
|
-
if (!ref.current || ref.current.contains(event.target)) {
|
|
2105
|
-
return;
|
|
2106
|
-
}
|
|
2107
|
-
handler(event);
|
|
2108
|
-
};
|
|
2109
|
-
if (Array.isArray(eventTypes)) {
|
|
2110
|
-
eventTypes.forEach((eventType) => {
|
|
2111
|
-
document.addEventListener(eventType, listener);
|
|
2112
|
-
});
|
|
2113
|
-
} else {
|
|
2114
|
-
document.addEventListener(eventTypes, listener);
|
|
2115
|
-
}
|
|
2116
|
-
return () => {
|
|
2117
|
-
if (Array.isArray(eventTypes)) {
|
|
2118
|
-
eventTypes.forEach((eventType) => {
|
|
2119
|
-
document.removeEventListener(eventType, listener);
|
|
2120
|
-
});
|
|
2121
|
-
} else {
|
|
2122
|
-
document.removeEventListener(eventTypes, listener);
|
|
2123
|
-
}
|
|
2124
|
-
};
|
|
2125
|
-
}, [ref, handler, eventTypes]);
|
|
2126
|
-
};
|
|
2127
|
-
|
|
2128
2366
|
// src/hooks/useMq/useMq.ts
|
|
2129
2367
|
import { isBoolean } from "@wistia/type-guards";
|
|
2130
2368
|
|
|
2131
2369
|
// src/hooks/useWindowSize/useWindowSize.ts
|
|
2132
|
-
import { useState as
|
|
2370
|
+
import { useState as useState5, useLayoutEffect as useLayoutEffect2 } from "react";
|
|
2133
2371
|
import { debounce } from "throttle-debounce";
|
|
2134
2372
|
|
|
2135
2373
|
// src/private/helpers/isClient/isClient.ts
|
|
@@ -2137,7 +2375,7 @@ var isClient = () => typeof window !== "undefined" && typeof document !== "undef
|
|
|
2137
2375
|
|
|
2138
2376
|
// src/hooks/useWindowSize/useWindowSize.ts
|
|
2139
2377
|
var useWindowSize = (interval = 0) => {
|
|
2140
|
-
const [dimensions, setDimensions] =
|
|
2378
|
+
const [dimensions, setDimensions] = useState5({
|
|
2141
2379
|
width: isClient() ? window.innerWidth : 0,
|
|
2142
2380
|
height: isClient() ? window.innerHeight : 0
|
|
2143
2381
|
});
|
|
@@ -2192,8 +2430,37 @@ var useActiveMq = () => {
|
|
|
2192
2430
|
});
|
|
2193
2431
|
};
|
|
2194
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
|
+
|
|
2195
2462
|
// src/hooks/useToast/useToast.tsx
|
|
2196
|
-
import { useCallback as
|
|
2463
|
+
import { useCallback as useCallback6 } from "react";
|
|
2197
2464
|
import { toast as sonnerToast } from "sonner";
|
|
2198
2465
|
|
|
2199
2466
|
// src/private/components/Toast/Toast.tsx
|
|
@@ -2472,7 +2739,7 @@ Toast.displayName = "Toast";
|
|
|
2472
2739
|
// src/hooks/useToast/useToast.tsx
|
|
2473
2740
|
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
2474
2741
|
var useToast = () => {
|
|
2475
|
-
return
|
|
2742
|
+
return useCallback6(
|
|
2476
2743
|
({ message, action, colorScheme, icon, position = "bottom-left", duration = 3e3 }) => {
|
|
2477
2744
|
sonnerToast.custom(
|
|
2478
2745
|
() => {
|
|
@@ -2493,238 +2760,6 @@ var useToast = () => {
|
|
|
2493
2760
|
);
|
|
2494
2761
|
};
|
|
2495
2762
|
|
|
2496
|
-
// src/hooks/useFocusTrap/useFocusTrap.ts
|
|
2497
|
-
import { useRef as useRef3, useCallback as useCallback5, useEffect as useEffect4 } from "react";
|
|
2498
|
-
import { isNotUndefined } from "@wistia/type-guards";
|
|
2499
|
-
|
|
2500
|
-
// src/hooks/useFocusTrap/helpers.ts
|
|
2501
|
-
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]';
|
|
2502
|
-
var coerceToString = (value) => value === null || value === void 0 ? "" : String(value);
|
|
2503
|
-
var isHiddenElement = (element) => {
|
|
2504
|
-
const { display, visibility } = window.getComputedStyle(element);
|
|
2505
|
-
const isHidden = display === "none" || element.style.display === "none" || visibility === "none" || element.style.visibility === "hidden";
|
|
2506
|
-
return element.offsetWidth <= 0 && element.offsetHeight <= 0 || isHidden;
|
|
2507
|
-
};
|
|
2508
|
-
var isVisibleElement = (element) => {
|
|
2509
|
-
let parentElement = element;
|
|
2510
|
-
while (parentElement) {
|
|
2511
|
-
if (parentElement === document.body) {
|
|
2512
|
-
break;
|
|
2513
|
-
}
|
|
2514
|
-
if (isHiddenElement(parentElement)) {
|
|
2515
|
-
return false;
|
|
2516
|
-
}
|
|
2517
|
-
parentElement = parentElement.parentNode;
|
|
2518
|
-
}
|
|
2519
|
-
return true;
|
|
2520
|
-
};
|
|
2521
|
-
var getElementTabIndex = (element) => {
|
|
2522
|
-
const tabIndex = element.getAttribute("tabindex");
|
|
2523
|
-
return Number.parseInt(tabIndex ?? void 0, 10);
|
|
2524
|
-
};
|
|
2525
|
-
var isTabIndexNaN = (element) => {
|
|
2526
|
-
const tabIndex = getElementTabIndex(element);
|
|
2527
|
-
return Number.isNaN(tabIndex);
|
|
2528
|
-
};
|
|
2529
|
-
var isFocusableElement = (element) => {
|
|
2530
|
-
const tabbableNodeRegEx = /input|select|textarea|button|object/;
|
|
2531
|
-
const nodeName = element.nodeName.toLowerCase();
|
|
2532
|
-
const isTabIndexNotNaN = !isTabIndexNaN(element);
|
|
2533
|
-
const isFocusable = (
|
|
2534
|
-
// @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.
|
|
2535
|
-
tabbableNodeRegEx.test(nodeName) && !element.disabled || (element instanceof HTMLAnchorElement ? element.href || isTabIndexNotNaN : isTabIndexNotNaN)
|
|
2536
|
-
);
|
|
2537
|
-
return Boolean(isFocusable) && isVisibleElement(element);
|
|
2538
|
-
};
|
|
2539
|
-
var isTabbableElement = (element) => {
|
|
2540
|
-
const tabIndex = getElementTabIndex(element);
|
|
2541
|
-
return (isTabIndexNaN(element) || tabIndex >= 0) && isFocusableElement(element);
|
|
2542
|
-
};
|
|
2543
|
-
var findTabbableDescendants = (element) => Array.from(element.querySelectorAll(FOCUSABLE_ELEMENT_SELECTORS)).filter(
|
|
2544
|
-
isTabbableElement
|
|
2545
|
-
);
|
|
2546
|
-
var focusLaterElements = [];
|
|
2547
|
-
var focusElement = null;
|
|
2548
|
-
var needToFocus = false;
|
|
2549
|
-
var handleBlur = () => {
|
|
2550
|
-
needToFocus = true;
|
|
2551
|
-
};
|
|
2552
|
-
var handleFocus = () => {
|
|
2553
|
-
if (needToFocus) {
|
|
2554
|
-
needToFocus = false;
|
|
2555
|
-
if (!focusElement) {
|
|
2556
|
-
return;
|
|
2557
|
-
}
|
|
2558
|
-
if (focusElement.contains(document.activeElement)) {
|
|
2559
|
-
return;
|
|
2560
|
-
}
|
|
2561
|
-
const element = findTabbableDescendants(focusElement)[0] ?? focusElement;
|
|
2562
|
-
element.focus();
|
|
2563
|
-
}
|
|
2564
|
-
};
|
|
2565
|
-
var markForFocusLater = () => {
|
|
2566
|
-
const element = document.activeElement;
|
|
2567
|
-
if (element !== null) {
|
|
2568
|
-
focusLaterElements.push(element);
|
|
2569
|
-
}
|
|
2570
|
-
};
|
|
2571
|
-
var returnFocus = () => {
|
|
2572
|
-
let toFocus = null;
|
|
2573
|
-
try {
|
|
2574
|
-
toFocus = focusLaterElements.pop();
|
|
2575
|
-
if (toFocus) {
|
|
2576
|
-
toFocus.focus();
|
|
2577
|
-
}
|
|
2578
|
-
} catch {
|
|
2579
|
-
console.warn(
|
|
2580
|
-
`You tried to return focus to ${coerceToString(toFocus)} but it is not in the DOM anymore`
|
|
2581
|
-
);
|
|
2582
|
-
}
|
|
2583
|
-
};
|
|
2584
|
-
var setupScopedFocus = (element) => {
|
|
2585
|
-
focusElement = element;
|
|
2586
|
-
document.addEventListener("focusout", handleBlur, false);
|
|
2587
|
-
document.addEventListener("focusin", handleFocus, true);
|
|
2588
|
-
};
|
|
2589
|
-
var teardownScopedFocus = () => {
|
|
2590
|
-
focusElement = null;
|
|
2591
|
-
document.removeEventListener("focusout", handleBlur);
|
|
2592
|
-
document.removeEventListener("focusin", handleFocus);
|
|
2593
|
-
};
|
|
2594
|
-
var scopeTab = (node, event) => {
|
|
2595
|
-
const tabbable = findTabbableDescendants(node);
|
|
2596
|
-
if (!tabbable.length) {
|
|
2597
|
-
event.preventDefault();
|
|
2598
|
-
return;
|
|
2599
|
-
}
|
|
2600
|
-
const finalTabbable = tabbable[event.shiftKey ? 0 : tabbable.length - 1];
|
|
2601
|
-
const leavingFinalTabbable = finalTabbable === document.activeElement || node === document.activeElement;
|
|
2602
|
-
if (!leavingFinalTabbable) {
|
|
2603
|
-
return;
|
|
2604
|
-
}
|
|
2605
|
-
event.preventDefault();
|
|
2606
|
-
const target = tabbable[event.shiftKey ? tabbable.length - 1 : 0];
|
|
2607
|
-
if (target) {
|
|
2608
|
-
target.focus();
|
|
2609
|
-
}
|
|
2610
|
-
};
|
|
2611
|
-
var createAriaHider = (containerNode, selector) => {
|
|
2612
|
-
if (selector === void 0) {
|
|
2613
|
-
selector = "body > :not(script)";
|
|
2614
|
-
}
|
|
2615
|
-
const rootNodes = Array.from(document.querySelectorAll(selector)).map((node) => {
|
|
2616
|
-
if (node.contains(containerNode)) {
|
|
2617
|
-
return void 0;
|
|
2618
|
-
}
|
|
2619
|
-
const ariaHidden = node.getAttribute("aria-hidden");
|
|
2620
|
-
if (ariaHidden === null || ariaHidden === "false") {
|
|
2621
|
-
node.setAttribute("aria-hidden", "true");
|
|
2622
|
-
}
|
|
2623
|
-
return {
|
|
2624
|
-
node,
|
|
2625
|
-
ariaHidden
|
|
2626
|
-
};
|
|
2627
|
-
});
|
|
2628
|
-
return () => {
|
|
2629
|
-
rootNodes.forEach((item) => {
|
|
2630
|
-
if (!item) {
|
|
2631
|
-
return;
|
|
2632
|
-
}
|
|
2633
|
-
if (item.ariaHidden === null) {
|
|
2634
|
-
item.node.removeAttribute("aria-hidden");
|
|
2635
|
-
} else {
|
|
2636
|
-
item.node.setAttribute("aria-hidden", item.ariaHidden);
|
|
2637
|
-
}
|
|
2638
|
-
});
|
|
2639
|
-
};
|
|
2640
|
-
};
|
|
2641
|
-
|
|
2642
|
-
// src/hooks/useFocusTrap/useFocusTrap.ts
|
|
2643
|
-
var isRef = (val) => {
|
|
2644
|
-
return val !== null && typeof val === "object" && "current" in val;
|
|
2645
|
-
};
|
|
2646
|
-
var useFocusTrap = (active = true, options = {}) => {
|
|
2647
|
-
const ref = useRef3(null);
|
|
2648
|
-
const restoreAriaRef = useRef3(null);
|
|
2649
|
-
const setRef = useCallback5(
|
|
2650
|
-
(node) => {
|
|
2651
|
-
if (restoreAriaRef.current !== null) {
|
|
2652
|
-
restoreAriaRef.current();
|
|
2653
|
-
}
|
|
2654
|
-
if (ref.current) {
|
|
2655
|
-
returnFocus();
|
|
2656
|
-
teardownScopedFocus();
|
|
2657
|
-
}
|
|
2658
|
-
if (active && node !== null && node !== void 0) {
|
|
2659
|
-
setupScopedFocus(node);
|
|
2660
|
-
markForFocusLater();
|
|
2661
|
-
const processNode = (node2) => {
|
|
2662
|
-
restoreAriaRef.current = !(options.disableAriaHider ?? false) ? createAriaHider(node2) : null;
|
|
2663
|
-
let focusElement2 = null;
|
|
2664
|
-
if (isNotUndefined(options.focusSelector)) {
|
|
2665
|
-
if (isRef(options.focusSelector)) {
|
|
2666
|
-
focusElement2 = options.focusSelector.current;
|
|
2667
|
-
} else {
|
|
2668
|
-
focusElement2 = typeof options.focusSelector === "string" ? node2.querySelector(options.focusSelector) : options.focusSelector;
|
|
2669
|
-
}
|
|
2670
|
-
}
|
|
2671
|
-
if (!focusElement2) {
|
|
2672
|
-
const children = Array.from(
|
|
2673
|
-
node2.querySelectorAll(FOCUSABLE_ELEMENT_SELECTORS)
|
|
2674
|
-
);
|
|
2675
|
-
focusElement2 = // Prefer tabbable elements, But fallback to any focusable element
|
|
2676
|
-
children.find(isTabbableElement) ?? // But fallback to any focusable element
|
|
2677
|
-
children.find(isFocusableElement) ?? // Nothing found
|
|
2678
|
-
null;
|
|
2679
|
-
if (!focusElement2 && isFocusableElement(node2)) {
|
|
2680
|
-
focusElement2 = node2;
|
|
2681
|
-
}
|
|
2682
|
-
}
|
|
2683
|
-
if (focusElement2) {
|
|
2684
|
-
focusElement2.focus();
|
|
2685
|
-
}
|
|
2686
|
-
if (!focusElement2 && process.env["NODE_ENV"] === "development") {
|
|
2687
|
-
console.warn(
|
|
2688
|
-
'[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.',
|
|
2689
|
-
node2
|
|
2690
|
-
);
|
|
2691
|
-
}
|
|
2692
|
-
};
|
|
2693
|
-
setTimeout(() => {
|
|
2694
|
-
if (node.ownerDocument) {
|
|
2695
|
-
processNode(node);
|
|
2696
|
-
}
|
|
2697
|
-
if (!node.ownerDocument && process.env["NODE_ENV"] === "development") {
|
|
2698
|
-
console.warn(
|
|
2699
|
-
"[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.",
|
|
2700
|
-
node
|
|
2701
|
-
);
|
|
2702
|
-
}
|
|
2703
|
-
});
|
|
2704
|
-
ref.current = node;
|
|
2705
|
-
} else {
|
|
2706
|
-
ref.current = null;
|
|
2707
|
-
}
|
|
2708
|
-
},
|
|
2709
|
-
[active, options.focusSelector, options.disableAriaHider]
|
|
2710
|
-
);
|
|
2711
|
-
useEffect4(() => {
|
|
2712
|
-
if (!active) {
|
|
2713
|
-
return void 0;
|
|
2714
|
-
}
|
|
2715
|
-
const handleKeyDown = (event) => {
|
|
2716
|
-
if (event.key === "Tab" && ref.current) {
|
|
2717
|
-
scopeTab(ref.current, event);
|
|
2718
|
-
}
|
|
2719
|
-
};
|
|
2720
|
-
document.addEventListener("keydown", handleKeyDown);
|
|
2721
|
-
return () => {
|
|
2722
|
-
document.removeEventListener("keydown", handleKeyDown);
|
|
2723
|
-
};
|
|
2724
|
-
}, [active]);
|
|
2725
|
-
return setRef;
|
|
2726
|
-
};
|
|
2727
|
-
|
|
2728
2763
|
// src/components/ActionButton/ActionButton.tsx
|
|
2729
2764
|
import { forwardRef as forwardRef3 } from "react";
|
|
2730
2765
|
import styled6, { css as css17 } from "styled-components";
|
|
@@ -7267,7 +7302,7 @@ var ActionButton = forwardRef3(
|
|
|
7267
7302
|
ActionButton.displayName = "ActionButton";
|
|
7268
7303
|
|
|
7269
7304
|
// src/components/Avatar/Avatar.tsx
|
|
7270
|
-
import { useState as
|
|
7305
|
+
import { useState as useState6, useMemo as useMemo3, useEffect as useEffect6 } from "react";
|
|
7271
7306
|
import { isNil as isNil8, isNotNil as isNotNil8 } from "@wistia/type-guards";
|
|
7272
7307
|
import styled9 from "styled-components";
|
|
7273
7308
|
|
|
@@ -7475,8 +7510,8 @@ var Avatar = ({
|
|
|
7475
7510
|
onImageLoad,
|
|
7476
7511
|
...props
|
|
7477
7512
|
}) => {
|
|
7478
|
-
const [imageLoadState, setImageLoadState] =
|
|
7479
|
-
|
|
7513
|
+
const [imageLoadState, setImageLoadState] = useState6("loading");
|
|
7514
|
+
useEffect6(() => {
|
|
7480
7515
|
setImageLoadState("loading");
|
|
7481
7516
|
}, [imageUrl]);
|
|
7482
7517
|
const handleImageLoad = () => {
|
|
@@ -7708,8 +7743,14 @@ var BoxComponent = forwardRef5(
|
|
|
7708
7743
|
flexMode,
|
|
7709
7744
|
...props
|
|
7710
7745
|
}, ref) => {
|
|
7746
|
+
const responsiveAlignContent = useResponsiveProp(alignContent);
|
|
7747
|
+
const responsiveAlignItems = useResponsiveProp(alignItems);
|
|
7748
|
+
const responsiveDirection = useResponsiveProp(direction);
|
|
7749
|
+
const responsiveFill = useResponsiveProp(fill);
|
|
7750
|
+
const responsiveGap = useResponsiveProp(gap);
|
|
7751
|
+
const responsiveJustifyContent = useResponsiveProp(justifyContent);
|
|
7711
7752
|
if (isNotUndefined5(height)) {
|
|
7712
|
-
if (
|
|
7753
|
+
if (responsiveFill === true || responsiveFill === "vertical") {
|
|
7713
7754
|
throw new Error('Cannot use height prop with fill="vertical" or fill={true}');
|
|
7714
7755
|
}
|
|
7715
7756
|
if (fillViewport === true || fillViewport === "vertical") {
|
|
@@ -7719,7 +7760,7 @@ var BoxComponent = forwardRef5(
|
|
|
7719
7760
|
}
|
|
7720
7761
|
}
|
|
7721
7762
|
if (isNotUndefined5(width)) {
|
|
7722
|
-
if (
|
|
7763
|
+
if (responsiveFill === true || responsiveFill === "horizontal") {
|
|
7723
7764
|
throw new Error('Cannot use width prop with fill="horizontal" or fill={true}');
|
|
7724
7765
|
}
|
|
7725
7766
|
if (fillViewport === true || fillViewport === "horizontal") {
|
|
@@ -7732,19 +7773,19 @@ var BoxComponent = forwardRef5(
|
|
|
7732
7773
|
StyledBoxComponent,
|
|
7733
7774
|
{
|
|
7734
7775
|
ref,
|
|
7735
|
-
$alignContent:
|
|
7736
|
-
$alignItems:
|
|
7776
|
+
$alignContent: responsiveAlignContent,
|
|
7777
|
+
$alignItems: responsiveAlignItems,
|
|
7737
7778
|
$alignSelf: alignSelf,
|
|
7738
7779
|
$basis: basis,
|
|
7739
|
-
$fillBox:
|
|
7780
|
+
$fillBox: responsiveFill,
|
|
7740
7781
|
$fillViewport: fillViewport,
|
|
7741
|
-
$flexDirection:
|
|
7782
|
+
$flexDirection: responsiveDirection,
|
|
7742
7783
|
$flexMode: flexMode,
|
|
7743
|
-
$gap:
|
|
7784
|
+
$gap: responsiveGap,
|
|
7744
7785
|
$grow: grow,
|
|
7745
7786
|
$height: height,
|
|
7746
7787
|
$inline: inline,
|
|
7747
|
-
$justifyContent:
|
|
7788
|
+
$justifyContent: responsiveJustifyContent,
|
|
7748
7789
|
$order: order,
|
|
7749
7790
|
$shrink: shrink,
|
|
7750
7791
|
$width: width,
|
|
@@ -8274,9 +8315,9 @@ var Checkbox = forwardRef7(
|
|
|
8274
8315
|
Checkbox.displayName = "Checkbox";
|
|
8275
8316
|
|
|
8276
8317
|
// src/components/ClickRegion/ClickRegion.tsx
|
|
8277
|
-
import { Children as Children3, cloneElement as cloneElement3, useCallback as
|
|
8318
|
+
import { Children as Children3, cloneElement as cloneElement3, useCallback as useCallback7, useEffect as useEffect7 } from "react";
|
|
8278
8319
|
var ClickRegion = ({ children, targetRef }) => {
|
|
8279
|
-
|
|
8320
|
+
useEffect7(() => {
|
|
8280
8321
|
if (targetRef.current && targetRef.current.tagName === "A") {
|
|
8281
8322
|
targetRef.current.setAttribute("data-click-region-target-link", "");
|
|
8282
8323
|
} else if (targetRef.current && targetRef.current.tagName === "BUTTON") {
|
|
@@ -8284,7 +8325,7 @@ var ClickRegion = ({ children, targetRef }) => {
|
|
|
8284
8325
|
} else {
|
|
8285
8326
|
}
|
|
8286
8327
|
}, [targetRef]);
|
|
8287
|
-
const handleClick =
|
|
8328
|
+
const handleClick = useCallback7(
|
|
8288
8329
|
(event) => {
|
|
8289
8330
|
const node = targetRef.current;
|
|
8290
8331
|
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")) {
|
|
@@ -8913,7 +8954,7 @@ Divider.displayName = "Divider";
|
|
|
8913
8954
|
|
|
8914
8955
|
// src/components/EditableHeading/EditableHeading.tsx
|
|
8915
8956
|
import styled31, { css as css27 } from "styled-components";
|
|
8916
|
-
import { useState as
|
|
8957
|
+
import { useState as useState7, useRef as useRef6 } from "react";
|
|
8917
8958
|
|
|
8918
8959
|
// src/components/Tooltip/Tooltip.tsx
|
|
8919
8960
|
import {
|
|
@@ -9017,7 +9058,7 @@ var Tooltip = ({
|
|
|
9017
9058
|
Tooltip.displayName = "Tooltip";
|
|
9018
9059
|
|
|
9019
9060
|
// src/components/Input/Input.tsx
|
|
9020
|
-
import { forwardRef as forwardRef10, cloneElement as cloneElement4, useRef as
|
|
9061
|
+
import { forwardRef as forwardRef10, cloneElement as cloneElement4, useRef as useRef5 } from "react";
|
|
9021
9062
|
import styled30, { css as css26 } from "styled-components";
|
|
9022
9063
|
import { isNil as isNil13, isNotNil as isNotNil16, isRecord as isRecord4 } from "@wistia/type-guards";
|
|
9023
9064
|
|
|
@@ -9162,7 +9203,7 @@ var Input = forwardRef10(
|
|
|
9162
9203
|
rightIcon,
|
|
9163
9204
|
...props
|
|
9164
9205
|
}, externalRef) => {
|
|
9165
|
-
const internalRef =
|
|
9206
|
+
const internalRef = useRef5();
|
|
9166
9207
|
const ref = (
|
|
9167
9208
|
// eslint-disable-next-line react-compiler/react-compiler
|
|
9168
9209
|
isNotNil16(externalRef) && isRecord4(externalRef) && "current" in externalRef ? externalRef : internalRef
|
|
@@ -9271,11 +9312,11 @@ var EditableHeading = ({
|
|
|
9271
9312
|
__forceEditing = false,
|
|
9272
9313
|
editingDisabled = false
|
|
9273
9314
|
}) => {
|
|
9274
|
-
const [isEditing, setIsEditing] =
|
|
9275
|
-
const [value, setValue] =
|
|
9276
|
-
const [previousValue, setPreviousValue] =
|
|
9277
|
-
const [headingHeight, setHeadingHeight] =
|
|
9278
|
-
const headingRef =
|
|
9315
|
+
const [isEditing, setIsEditing] = useState7(false);
|
|
9316
|
+
const [value, setValue] = useState7(children);
|
|
9317
|
+
const [previousValue, setPreviousValue] = useState7(children);
|
|
9318
|
+
const [headingHeight, setHeadingHeight] = useState7("60");
|
|
9319
|
+
const headingRef = useRef6(null);
|
|
9279
9320
|
const handleSetEditing = (editing) => {
|
|
9280
9321
|
if (editingDisabled) return;
|
|
9281
9322
|
if (editing && headingRef.current) {
|
|
@@ -9354,7 +9395,7 @@ var EditableHeading = ({
|
|
|
9354
9395
|
};
|
|
9355
9396
|
|
|
9356
9397
|
// src/components/Form/Form.tsx
|
|
9357
|
-
import { forwardRef as forwardRef12, useRef as
|
|
9398
|
+
import { forwardRef as forwardRef12, useRef as useRef7, useMemo as useMemo4, createContext as createContext3, useState as useState8, useId as useId2 } from "react";
|
|
9358
9399
|
import styled33 from "styled-components";
|
|
9359
9400
|
import { isNotUndefined as isNotUndefined7, isUndefined as isUndefined3 } from "@wistia/type-guards";
|
|
9360
9401
|
|
|
@@ -9414,9 +9455,9 @@ var FormComponent = ({
|
|
|
9414
9455
|
fullWidth = false,
|
|
9415
9456
|
...props
|
|
9416
9457
|
}, forwardedRef) => {
|
|
9417
|
-
const [errors, setErrors] =
|
|
9418
|
-
const [hasSubmitted, setHasSubmitted] =
|
|
9419
|
-
const innerRef =
|
|
9458
|
+
const [errors, setErrors] = useState8({});
|
|
9459
|
+
const [hasSubmitted, setHasSubmitted] = useState8(false);
|
|
9460
|
+
const innerRef = useRef7();
|
|
9420
9461
|
const ref = forwardedRef ?? innerRef;
|
|
9421
9462
|
const autoId = useId2();
|
|
9422
9463
|
const id = props.id ?? autoId;
|
|
@@ -9492,12 +9533,12 @@ FormComponent.displayName = "Form";
|
|
|
9492
9533
|
var Form = forwardRef12(FormComponent);
|
|
9493
9534
|
|
|
9494
9535
|
// src/components/Form/useFormState.tsx
|
|
9495
|
-
import { useCallback as
|
|
9536
|
+
import { useCallback as useCallback8, useState as useState9 } from "react";
|
|
9496
9537
|
var useFormState = (action, initialData = {}) => {
|
|
9497
|
-
const [data, setData] =
|
|
9498
|
-
const [isPending, setIsPending] =
|
|
9499
|
-
const [error, setError] =
|
|
9500
|
-
const formAction =
|
|
9538
|
+
const [data, setData] = useState9(initialData);
|
|
9539
|
+
const [isPending, setIsPending] = useState9(false);
|
|
9540
|
+
const [error, setError] = useState9(null);
|
|
9541
|
+
const formAction = useCallback8(
|
|
9501
9542
|
async (nextFormData) => {
|
|
9502
9543
|
if (nextFormData === null) {
|
|
9503
9544
|
setData(initialData);
|
|
@@ -9528,14 +9569,14 @@ var useFormState = (action, initialData = {}) => {
|
|
|
9528
9569
|
};
|
|
9529
9570
|
|
|
9530
9571
|
// src/components/Form/FormErrorSummary.tsx
|
|
9531
|
-
import { useContext as useContext3, useRef as
|
|
9572
|
+
import { useContext as useContext3, useRef as useRef8 } from "react";
|
|
9532
9573
|
import { isArray, isNotUndefined as isNotUndefined8 } from "@wistia/type-guards";
|
|
9533
9574
|
import { jsx as jsx223, jsxs as jsxs22 } from "react/jsx-runtime";
|
|
9534
9575
|
var ErrorItem = ({ name, error, formId }) => {
|
|
9535
9576
|
return /* @__PURE__ */ jsx223("li", { children: /* @__PURE__ */ jsx223(Link, { href: `#${formId}-${name}`, children: error }) }, name);
|
|
9536
9577
|
};
|
|
9537
9578
|
var FormErrorSummary = ({ description }) => {
|
|
9538
|
-
const ref =
|
|
9579
|
+
const ref = useRef8(null);
|
|
9539
9580
|
const { formId, errors, hasSubmitted } = useContext3(FormContext);
|
|
9540
9581
|
const isValid = Object.keys(errors).length === 0;
|
|
9541
9582
|
if (isValid || !hasSubmitted) {
|
|
@@ -9635,7 +9676,7 @@ import { createContext as createContext4, useMemo as useMemo5 } from "react";
|
|
|
9635
9676
|
|
|
9636
9677
|
// src/components/FormGroup/FormGroup.tsx
|
|
9637
9678
|
import styled35 from "styled-components";
|
|
9638
|
-
import { useRef as
|
|
9679
|
+
import { useRef as useRef9 } from "react";
|
|
9639
9680
|
import { jsx as jsx225, jsxs as jsxs23 } from "react/jsx-runtime";
|
|
9640
9681
|
var StyledFieldset = styled35.fieldset`
|
|
9641
9682
|
border: 0;
|
|
@@ -9644,7 +9685,7 @@ var StyledLegend = styled35.legend`
|
|
|
9644
9685
|
margin-bottom: var(--space-01);
|
|
9645
9686
|
`;
|
|
9646
9687
|
var FormGroup = ({ children, label, ...props }) => {
|
|
9647
|
-
const ref =
|
|
9688
|
+
const ref = useRef9();
|
|
9648
9689
|
return /* @__PURE__ */ jsxs23(
|
|
9649
9690
|
Stack,
|
|
9650
9691
|
{
|
|
@@ -9888,7 +9929,7 @@ IconButton.displayName = "IconButton";
|
|
|
9888
9929
|
|
|
9889
9930
|
// src/components/InputClickToCopy/InputClickToCopy.tsx
|
|
9890
9931
|
import styled38 from "styled-components";
|
|
9891
|
-
import { forwardRef as forwardRef14, useEffect as
|
|
9932
|
+
import { forwardRef as forwardRef14, useEffect as useEffect8, useState as useState10 } from "react";
|
|
9892
9933
|
import { isFunction as isFunction3 } from "@wistia/type-guards";
|
|
9893
9934
|
import { jsx as jsx230 } from "react/jsx-runtime";
|
|
9894
9935
|
var StyledInput2 = styled38(Input)`
|
|
@@ -9903,8 +9944,8 @@ var StyledInput2 = styled38(Input)`
|
|
|
9903
9944
|
var COPY_SUCCESS_DURATION = 2e3;
|
|
9904
9945
|
var InputClickToCopy = forwardRef14(
|
|
9905
9946
|
({ value, onCopy, ...props }, ref) => {
|
|
9906
|
-
const [isCopied, setIsCopied] =
|
|
9907
|
-
|
|
9947
|
+
const [isCopied, setIsCopied] = useState10(false);
|
|
9948
|
+
useEffect8(() => {
|
|
9908
9949
|
if (isCopied) {
|
|
9909
9950
|
const timeout = setTimeout(() => {
|
|
9910
9951
|
setIsCopied(false);
|
|
@@ -10142,7 +10183,7 @@ var MenuLabel = ({ children, ...props }) => {
|
|
|
10142
10183
|
MenuLabel.displayName = "MenuLabel";
|
|
10143
10184
|
|
|
10144
10185
|
// src/components/Menu/SubMenu.tsx
|
|
10145
|
-
import { useState as
|
|
10186
|
+
import { useState as useState11 } from "react";
|
|
10146
10187
|
import styled43 from "styled-components";
|
|
10147
10188
|
import {
|
|
10148
10189
|
DropdownMenuPortal as DropdownMenuPortal2,
|
|
@@ -10328,7 +10369,7 @@ var SubMenu = ({
|
|
|
10328
10369
|
...props
|
|
10329
10370
|
}) => {
|
|
10330
10371
|
const { isSmAndUp } = useMq();
|
|
10331
|
-
const [isExpanded, setIsExpanded] =
|
|
10372
|
+
const [isExpanded, setIsExpanded] = useState11(false);
|
|
10332
10373
|
const { compact } = useMenuContext();
|
|
10333
10374
|
return isSmAndUp ? /* @__PURE__ */ jsxs27(DropdownMenuSub, { onOpenChange, children: [
|
|
10334
10375
|
/* @__PURE__ */ jsxs27(SubMenuTrigger, { ...props, children: [
|
|
@@ -10585,14 +10626,14 @@ import styled46 from "styled-components";
|
|
|
10585
10626
|
import { Content as DialogContent } from "@radix-ui/react-dialog";
|
|
10586
10627
|
|
|
10587
10628
|
// src/private/hooks/useFocusRestore/useFocusRestore.ts
|
|
10588
|
-
import { useRef as
|
|
10629
|
+
import { useRef as useRef10, useEffect as useEffect9 } from "react";
|
|
10589
10630
|
import { isNotNil as isNotNil22 } from "@wistia/type-guards";
|
|
10590
10631
|
var useFocusRestore = () => {
|
|
10591
|
-
const previouslyFocusedRef =
|
|
10592
|
-
|
|
10632
|
+
const previouslyFocusedRef = useRef10(null);
|
|
10633
|
+
useEffect9(() => {
|
|
10593
10634
|
previouslyFocusedRef.current = document.activeElement;
|
|
10594
10635
|
}, []);
|
|
10595
|
-
|
|
10636
|
+
useEffect9(() => {
|
|
10596
10637
|
return () => {
|
|
10597
10638
|
if (isNotNil22(previouslyFocusedRef.current)) {
|
|
10598
10639
|
setTimeout(() => {
|
|
@@ -11112,13 +11153,13 @@ import { Root as ToggleGroupRoot } from "@radix-ui/react-toggle-group";
|
|
|
11112
11153
|
import { isNil as isNil14 } from "@wistia/type-guards";
|
|
11113
11154
|
|
|
11114
11155
|
// src/components/SegmentedControl/useSelectedItemStyle.tsx
|
|
11115
|
-
import { createContext as createContext7, useContext as useContext6, useMemo as useMemo8, useState as
|
|
11156
|
+
import { createContext as createContext7, useContext as useContext6, useMemo as useMemo8, useState as useState12 } from "react";
|
|
11116
11157
|
import { jsx as jsx248 } from "react/jsx-runtime";
|
|
11117
11158
|
var SelectedItemStyleContext = createContext7(null);
|
|
11118
11159
|
var SelectedItemStyleProvider = ({
|
|
11119
11160
|
children
|
|
11120
11161
|
}) => {
|
|
11121
|
-
const [selectedItemMeasurements, setSelectedItemMeasurements] =
|
|
11162
|
+
const [selectedItemMeasurements, setSelectedItemMeasurements] = useState12(null);
|
|
11122
11163
|
const selectedItemIndicatorStyle = useMemo8(
|
|
11123
11164
|
() => selectedItemMeasurements != null ? {
|
|
11124
11165
|
height: `${selectedItemMeasurements.offsetHeight}px`,
|
|
@@ -11235,7 +11276,7 @@ var SegmentedControl = forwardRef21(
|
|
|
11235
11276
|
SegmentedControl.displayName = "SegmentedControl";
|
|
11236
11277
|
|
|
11237
11278
|
// src/components/SegmentedControl/SegmentedControlItem.tsx
|
|
11238
|
-
import { forwardRef as forwardRef22, useEffect as
|
|
11279
|
+
import { forwardRef as forwardRef22, useEffect as useEffect10, useRef as useRef11 } from "react";
|
|
11239
11280
|
import styled54, { css as css33 } from "styled-components";
|
|
11240
11281
|
import { Item as ToggleGroupItem } from "@radix-ui/react-toggle-group";
|
|
11241
11282
|
import { isNotNil as isNotNil26 } from "@wistia/type-guards";
|
|
@@ -11307,7 +11348,7 @@ var SegmentedControlItem = forwardRef22(
|
|
|
11307
11348
|
({ disabled, icon, label, "aria-label": ariaLabel, value }, forwardedRef) => {
|
|
11308
11349
|
const selectedValue = useSegmentedControlValue();
|
|
11309
11350
|
const { setSelectedItemMeasurements } = useSelectedItemStyle();
|
|
11310
|
-
const buttonRef =
|
|
11351
|
+
const buttonRef = useRef11(null);
|
|
11311
11352
|
const combinedRef = mergeRefs([buttonRef, forwardedRef]);
|
|
11312
11353
|
const handleClick = (event) => {
|
|
11313
11354
|
const target = event.target;
|
|
@@ -11316,7 +11357,7 @@ var SegmentedControlItem = forwardRef22(
|
|
|
11316
11357
|
event.preventDefault();
|
|
11317
11358
|
}
|
|
11318
11359
|
};
|
|
11319
|
-
|
|
11360
|
+
useEffect10(() => {
|
|
11320
11361
|
const buttonElem = buttonRef.current;
|
|
11321
11362
|
if (!buttonElem) {
|
|
11322
11363
|
return void 0;
|
|
@@ -11733,22 +11774,29 @@ var StyledTable = styled59.table`
|
|
|
11733
11774
|
width: 100%;
|
|
11734
11775
|
border-collapse: collapse;
|
|
11735
11776
|
|
|
11777
|
+
${({ $divided }) => $divided && css35`
|
|
11778
|
+
tr {
|
|
11779
|
+
border-bottom: 1px solid var(--wui-color-border);
|
|
11780
|
+
}
|
|
11781
|
+
`}
|
|
11782
|
+
|
|
11736
11783
|
${({ $striped }) => $striped && css35`
|
|
11737
11784
|
tbody tr:nth-child(even) {
|
|
11738
11785
|
background-color: var(--wui-color-bg-surface-secondary);
|
|
11739
11786
|
}
|
|
11740
11787
|
`}
|
|
11741
11788
|
|
|
11742
|
-
${({ $
|
|
11743
|
-
|
|
11744
|
-
|
|
11789
|
+
${({ $visuallyHiddenHeader }) => $visuallyHiddenHeader && css35`
|
|
11790
|
+
thead {
|
|
11791
|
+
${visuallyHiddenStyle}
|
|
11745
11792
|
}
|
|
11746
11793
|
`}
|
|
11747
11794
|
`;
|
|
11748
11795
|
var Table = ({
|
|
11749
11796
|
children,
|
|
11750
|
-
striped = false,
|
|
11751
11797
|
divided = false,
|
|
11798
|
+
striped = false,
|
|
11799
|
+
visuallyHiddenHeader = false,
|
|
11752
11800
|
...props
|
|
11753
11801
|
}) => {
|
|
11754
11802
|
return /* @__PURE__ */ jsx255(
|
|
@@ -11756,6 +11804,7 @@ var Table = ({
|
|
|
11756
11804
|
{
|
|
11757
11805
|
$divided: divided,
|
|
11758
11806
|
$striped: striped,
|
|
11807
|
+
$visuallyHiddenHeader: visuallyHiddenHeader,
|
|
11759
11808
|
...props,
|
|
11760
11809
|
children
|
|
11761
11810
|
}
|
|
@@ -11771,9 +11820,9 @@ var TableSectionContext = createContext9(null);
|
|
|
11771
11820
|
|
|
11772
11821
|
// src/components/Table/TableBody.tsx
|
|
11773
11822
|
import { jsx as jsx256 } from "react/jsx-runtime";
|
|
11774
|
-
var
|
|
11823
|
+
var StyledTableBody = styled60.tbody``;
|
|
11775
11824
|
var TableBody = ({ children, ...props }) => {
|
|
11776
|
-
return /* @__PURE__ */ jsx256(TableSectionContext.Provider, { value: "body", children: /* @__PURE__ */ jsx256(
|
|
11825
|
+
return /* @__PURE__ */ jsx256(TableSectionContext.Provider, { value: "body", children: /* @__PURE__ */ jsx256(StyledTableBody, { ...props, children }) });
|
|
11777
11826
|
};
|
|
11778
11827
|
|
|
11779
11828
|
// src/components/Table/TableCell.tsx
|
|
@@ -11805,12 +11854,12 @@ var TableCell = ({ children, ...props }) => {
|
|
|
11805
11854
|
return /* @__PURE__ */ jsx257(StyledTd, { ...props, children });
|
|
11806
11855
|
};
|
|
11807
11856
|
|
|
11808
|
-
// src/components/Table/
|
|
11857
|
+
// src/components/Table/TableFoot.tsx
|
|
11809
11858
|
import styled62 from "styled-components";
|
|
11810
11859
|
import { jsx as jsx258 } from "react/jsx-runtime";
|
|
11811
|
-
var
|
|
11812
|
-
var
|
|
11813
|
-
return /* @__PURE__ */ jsx258(TableSectionContext.Provider, { value: "footer", children: /* @__PURE__ */ jsx258(
|
|
11860
|
+
var StyledTableFoot = styled62.tfoot``;
|
|
11861
|
+
var TableFoot = ({ children, ...props }) => {
|
|
11862
|
+
return /* @__PURE__ */ jsx258(TableSectionContext.Provider, { value: "footer", children: /* @__PURE__ */ jsx258(StyledTableFoot, { ...props, children }) });
|
|
11814
11863
|
};
|
|
11815
11864
|
|
|
11816
11865
|
// src/components/Table/TableHead.tsx
|
|
@@ -11824,13 +11873,13 @@ var TableHead = ({ children, ...props }) => {
|
|
|
11824
11873
|
// src/components/Table/TableRow.tsx
|
|
11825
11874
|
import styled64 from "styled-components";
|
|
11826
11875
|
import { jsx as jsx260 } from "react/jsx-runtime";
|
|
11827
|
-
var
|
|
11876
|
+
var StyledTableRow = styled64.tr``;
|
|
11828
11877
|
var TableRow = ({ children, ...props }) => {
|
|
11829
|
-
return /* @__PURE__ */ jsx260(
|
|
11878
|
+
return /* @__PURE__ */ jsx260(StyledTableRow, { ...props, children });
|
|
11830
11879
|
};
|
|
11831
11880
|
|
|
11832
11881
|
// src/components/Tabs/Tabs.tsx
|
|
11833
|
-
import { forwardRef as forwardRef27, useState as
|
|
11882
|
+
import { forwardRef as forwardRef27, useState as useState13 } from "react";
|
|
11834
11883
|
import { Root as TabsRoot } from "@radix-ui/react-tabs";
|
|
11835
11884
|
import { isNotNil as isNotNil29, isNil as isNil15 } from "@wistia/type-guards";
|
|
11836
11885
|
import styled69 from "styled-components";
|
|
@@ -11885,7 +11934,7 @@ var TabList = ({
|
|
|
11885
11934
|
TabList.displayName = "TabList";
|
|
11886
11935
|
|
|
11887
11936
|
// src/components/Tabs/TabItem.tsx
|
|
11888
|
-
import { forwardRef as forwardRef26, useEffect as
|
|
11937
|
+
import { forwardRef as forwardRef26, useEffect as useEffect11, useRef as useRef12 } from "react";
|
|
11889
11938
|
import styled67 from "styled-components";
|
|
11890
11939
|
import { Trigger as RadixTab } from "@radix-ui/react-tabs";
|
|
11891
11940
|
import { isNotNil as isNotNil28 } from "@wistia/type-guards";
|
|
@@ -11915,9 +11964,9 @@ var TabItem = forwardRef26(
|
|
|
11915
11964
|
({ disabled = false, icon, label, "aria-label": ariaLabel, value }, forwardedRef) => {
|
|
11916
11965
|
const selectedValue = useTabsValue();
|
|
11917
11966
|
const { setSelectedItemMeasurements } = useSelectedItemStyle();
|
|
11918
|
-
const buttonRef =
|
|
11967
|
+
const buttonRef = useRef12(null);
|
|
11919
11968
|
const combinedRef = mergeRefs([buttonRef, forwardedRef]);
|
|
11920
|
-
|
|
11969
|
+
useEffect11(() => {
|
|
11921
11970
|
const buttonElem = buttonRef.current;
|
|
11922
11971
|
if (!buttonElem) {
|
|
11923
11972
|
return void 0;
|
|
@@ -12029,7 +12078,7 @@ var Tabs = forwardRef27(
|
|
|
12029
12078
|
...props
|
|
12030
12079
|
}, ref) => {
|
|
12031
12080
|
const tabItems = extractTabItems(children);
|
|
12032
|
-
const [internalSelectedValue, setInternalSelectedValue] =
|
|
12081
|
+
const [internalSelectedValue, setInternalSelectedValue] = useState13(defaultSelectedValue);
|
|
12033
12082
|
const modeProps = defaultSelectedValue !== void 0 ? {
|
|
12034
12083
|
defaultValue: defaultSelectedValue,
|
|
12035
12084
|
onValueChange: setInternalSelectedValue
|
|
@@ -12834,7 +12883,7 @@ export {
|
|
|
12834
12883
|
Table,
|
|
12835
12884
|
TableBody,
|
|
12836
12885
|
TableCell,
|
|
12837
|
-
|
|
12886
|
+
TableFoot,
|
|
12838
12887
|
TableHead,
|
|
12839
12888
|
TableRow,
|
|
12840
12889
|
Tabs,
|
|
@@ -12855,6 +12904,7 @@ export {
|
|
|
12855
12904
|
useActiveMq,
|
|
12856
12905
|
useAriaLive,
|
|
12857
12906
|
useBoolean,
|
|
12907
|
+
useClipboard,
|
|
12858
12908
|
useFilePicker,
|
|
12859
12909
|
useFocusTrap,
|
|
12860
12910
|
useFormState,
|