@wistia/ui 0.8.13 → 0.8.14
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 +546 -501
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +24 -16
- package/dist/index.d.ts +24 -16
- package/dist/index.mjs +379 -335
- 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.14
|
|
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 = () => {
|
|
@@ -8274,9 +8309,9 @@ var Checkbox = forwardRef7(
|
|
|
8274
8309
|
Checkbox.displayName = "Checkbox";
|
|
8275
8310
|
|
|
8276
8311
|
// src/components/ClickRegion/ClickRegion.tsx
|
|
8277
|
-
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";
|
|
8278
8313
|
var ClickRegion = ({ children, targetRef }) => {
|
|
8279
|
-
|
|
8314
|
+
useEffect7(() => {
|
|
8280
8315
|
if (targetRef.current && targetRef.current.tagName === "A") {
|
|
8281
8316
|
targetRef.current.setAttribute("data-click-region-target-link", "");
|
|
8282
8317
|
} else if (targetRef.current && targetRef.current.tagName === "BUTTON") {
|
|
@@ -8284,7 +8319,7 @@ var ClickRegion = ({ children, targetRef }) => {
|
|
|
8284
8319
|
} else {
|
|
8285
8320
|
}
|
|
8286
8321
|
}, [targetRef]);
|
|
8287
|
-
const handleClick =
|
|
8322
|
+
const handleClick = useCallback7(
|
|
8288
8323
|
(event) => {
|
|
8289
8324
|
const node = targetRef.current;
|
|
8290
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")) {
|
|
@@ -8913,7 +8948,7 @@ Divider.displayName = "Divider";
|
|
|
8913
8948
|
|
|
8914
8949
|
// src/components/EditableHeading/EditableHeading.tsx
|
|
8915
8950
|
import styled31, { css as css27 } from "styled-components";
|
|
8916
|
-
import { useState as
|
|
8951
|
+
import { useState as useState7, useRef as useRef6 } from "react";
|
|
8917
8952
|
|
|
8918
8953
|
// src/components/Tooltip/Tooltip.tsx
|
|
8919
8954
|
import {
|
|
@@ -9017,7 +9052,7 @@ var Tooltip = ({
|
|
|
9017
9052
|
Tooltip.displayName = "Tooltip";
|
|
9018
9053
|
|
|
9019
9054
|
// src/components/Input/Input.tsx
|
|
9020
|
-
import { forwardRef as forwardRef10, cloneElement as cloneElement4, useRef as
|
|
9055
|
+
import { forwardRef as forwardRef10, cloneElement as cloneElement4, useRef as useRef5 } from "react";
|
|
9021
9056
|
import styled30, { css as css26 } from "styled-components";
|
|
9022
9057
|
import { isNil as isNil13, isNotNil as isNotNil16, isRecord as isRecord4 } from "@wistia/type-guards";
|
|
9023
9058
|
|
|
@@ -9162,7 +9197,7 @@ var Input = forwardRef10(
|
|
|
9162
9197
|
rightIcon,
|
|
9163
9198
|
...props
|
|
9164
9199
|
}, externalRef) => {
|
|
9165
|
-
const internalRef =
|
|
9200
|
+
const internalRef = useRef5();
|
|
9166
9201
|
const ref = (
|
|
9167
9202
|
// eslint-disable-next-line react-compiler/react-compiler
|
|
9168
9203
|
isNotNil16(externalRef) && isRecord4(externalRef) && "current" in externalRef ? externalRef : internalRef
|
|
@@ -9271,11 +9306,11 @@ var EditableHeading = ({
|
|
|
9271
9306
|
__forceEditing = false,
|
|
9272
9307
|
editingDisabled = false
|
|
9273
9308
|
}) => {
|
|
9274
|
-
const [isEditing, setIsEditing] =
|
|
9275
|
-
const [value, setValue] =
|
|
9276
|
-
const [previousValue, setPreviousValue] =
|
|
9277
|
-
const [headingHeight, setHeadingHeight] =
|
|
9278
|
-
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);
|
|
9279
9314
|
const handleSetEditing = (editing) => {
|
|
9280
9315
|
if (editingDisabled) return;
|
|
9281
9316
|
if (editing && headingRef.current) {
|
|
@@ -9354,7 +9389,7 @@ var EditableHeading = ({
|
|
|
9354
9389
|
};
|
|
9355
9390
|
|
|
9356
9391
|
// src/components/Form/Form.tsx
|
|
9357
|
-
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";
|
|
9358
9393
|
import styled33 from "styled-components";
|
|
9359
9394
|
import { isNotUndefined as isNotUndefined7, isUndefined as isUndefined3 } from "@wistia/type-guards";
|
|
9360
9395
|
|
|
@@ -9414,9 +9449,9 @@ var FormComponent = ({
|
|
|
9414
9449
|
fullWidth = false,
|
|
9415
9450
|
...props
|
|
9416
9451
|
}, forwardedRef) => {
|
|
9417
|
-
const [errors, setErrors] =
|
|
9418
|
-
const [hasSubmitted, setHasSubmitted] =
|
|
9419
|
-
const innerRef =
|
|
9452
|
+
const [errors, setErrors] = useState8({});
|
|
9453
|
+
const [hasSubmitted, setHasSubmitted] = useState8(false);
|
|
9454
|
+
const innerRef = useRef7();
|
|
9420
9455
|
const ref = forwardedRef ?? innerRef;
|
|
9421
9456
|
const autoId = useId2();
|
|
9422
9457
|
const id = props.id ?? autoId;
|
|
@@ -9492,12 +9527,12 @@ FormComponent.displayName = "Form";
|
|
|
9492
9527
|
var Form = forwardRef12(FormComponent);
|
|
9493
9528
|
|
|
9494
9529
|
// src/components/Form/useFormState.tsx
|
|
9495
|
-
import { useCallback as
|
|
9530
|
+
import { useCallback as useCallback8, useState as useState9 } from "react";
|
|
9496
9531
|
var useFormState = (action, initialData = {}) => {
|
|
9497
|
-
const [data, setData] =
|
|
9498
|
-
const [isPending, setIsPending] =
|
|
9499
|
-
const [error, setError] =
|
|
9500
|
-
const formAction =
|
|
9532
|
+
const [data, setData] = useState9(initialData);
|
|
9533
|
+
const [isPending, setIsPending] = useState9(false);
|
|
9534
|
+
const [error, setError] = useState9(null);
|
|
9535
|
+
const formAction = useCallback8(
|
|
9501
9536
|
async (nextFormData) => {
|
|
9502
9537
|
if (nextFormData === null) {
|
|
9503
9538
|
setData(initialData);
|
|
@@ -9528,14 +9563,14 @@ var useFormState = (action, initialData = {}) => {
|
|
|
9528
9563
|
};
|
|
9529
9564
|
|
|
9530
9565
|
// src/components/Form/FormErrorSummary.tsx
|
|
9531
|
-
import { useContext as useContext3, useRef as
|
|
9566
|
+
import { useContext as useContext3, useRef as useRef8 } from "react";
|
|
9532
9567
|
import { isArray, isNotUndefined as isNotUndefined8 } from "@wistia/type-guards";
|
|
9533
9568
|
import { jsx as jsx223, jsxs as jsxs22 } from "react/jsx-runtime";
|
|
9534
9569
|
var ErrorItem = ({ name, error, formId }) => {
|
|
9535
9570
|
return /* @__PURE__ */ jsx223("li", { children: /* @__PURE__ */ jsx223(Link, { href: `#${formId}-${name}`, children: error }) }, name);
|
|
9536
9571
|
};
|
|
9537
9572
|
var FormErrorSummary = ({ description }) => {
|
|
9538
|
-
const ref =
|
|
9573
|
+
const ref = useRef8(null);
|
|
9539
9574
|
const { formId, errors, hasSubmitted } = useContext3(FormContext);
|
|
9540
9575
|
const isValid = Object.keys(errors).length === 0;
|
|
9541
9576
|
if (isValid || !hasSubmitted) {
|
|
@@ -9635,7 +9670,7 @@ import { createContext as createContext4, useMemo as useMemo5 } from "react";
|
|
|
9635
9670
|
|
|
9636
9671
|
// src/components/FormGroup/FormGroup.tsx
|
|
9637
9672
|
import styled35 from "styled-components";
|
|
9638
|
-
import { useRef as
|
|
9673
|
+
import { useRef as useRef9 } from "react";
|
|
9639
9674
|
import { jsx as jsx225, jsxs as jsxs23 } from "react/jsx-runtime";
|
|
9640
9675
|
var StyledFieldset = styled35.fieldset`
|
|
9641
9676
|
border: 0;
|
|
@@ -9644,7 +9679,7 @@ var StyledLegend = styled35.legend`
|
|
|
9644
9679
|
margin-bottom: var(--space-01);
|
|
9645
9680
|
`;
|
|
9646
9681
|
var FormGroup = ({ children, label, ...props }) => {
|
|
9647
|
-
const ref =
|
|
9682
|
+
const ref = useRef9();
|
|
9648
9683
|
return /* @__PURE__ */ jsxs23(
|
|
9649
9684
|
Stack,
|
|
9650
9685
|
{
|
|
@@ -9888,7 +9923,7 @@ IconButton.displayName = "IconButton";
|
|
|
9888
9923
|
|
|
9889
9924
|
// src/components/InputClickToCopy/InputClickToCopy.tsx
|
|
9890
9925
|
import styled38 from "styled-components";
|
|
9891
|
-
import { forwardRef as forwardRef14, useEffect as
|
|
9926
|
+
import { forwardRef as forwardRef14, useEffect as useEffect8, useState as useState10 } from "react";
|
|
9892
9927
|
import { isFunction as isFunction3 } from "@wistia/type-guards";
|
|
9893
9928
|
import { jsx as jsx230 } from "react/jsx-runtime";
|
|
9894
9929
|
var StyledInput2 = styled38(Input)`
|
|
@@ -9903,8 +9938,8 @@ var StyledInput2 = styled38(Input)`
|
|
|
9903
9938
|
var COPY_SUCCESS_DURATION = 2e3;
|
|
9904
9939
|
var InputClickToCopy = forwardRef14(
|
|
9905
9940
|
({ value, onCopy, ...props }, ref) => {
|
|
9906
|
-
const [isCopied, setIsCopied] =
|
|
9907
|
-
|
|
9941
|
+
const [isCopied, setIsCopied] = useState10(false);
|
|
9942
|
+
useEffect8(() => {
|
|
9908
9943
|
if (isCopied) {
|
|
9909
9944
|
const timeout = setTimeout(() => {
|
|
9910
9945
|
setIsCopied(false);
|
|
@@ -10142,7 +10177,7 @@ var MenuLabel = ({ children, ...props }) => {
|
|
|
10142
10177
|
MenuLabel.displayName = "MenuLabel";
|
|
10143
10178
|
|
|
10144
10179
|
// src/components/Menu/SubMenu.tsx
|
|
10145
|
-
import { useState as
|
|
10180
|
+
import { useState as useState11 } from "react";
|
|
10146
10181
|
import styled43 from "styled-components";
|
|
10147
10182
|
import {
|
|
10148
10183
|
DropdownMenuPortal as DropdownMenuPortal2,
|
|
@@ -10328,7 +10363,7 @@ var SubMenu = ({
|
|
|
10328
10363
|
...props
|
|
10329
10364
|
}) => {
|
|
10330
10365
|
const { isSmAndUp } = useMq();
|
|
10331
|
-
const [isExpanded, setIsExpanded] =
|
|
10366
|
+
const [isExpanded, setIsExpanded] = useState11(false);
|
|
10332
10367
|
const { compact } = useMenuContext();
|
|
10333
10368
|
return isSmAndUp ? /* @__PURE__ */ jsxs27(DropdownMenuSub, { onOpenChange, children: [
|
|
10334
10369
|
/* @__PURE__ */ jsxs27(SubMenuTrigger, { ...props, children: [
|
|
@@ -10585,14 +10620,14 @@ import styled46 from "styled-components";
|
|
|
10585
10620
|
import { Content as DialogContent } from "@radix-ui/react-dialog";
|
|
10586
10621
|
|
|
10587
10622
|
// src/private/hooks/useFocusRestore/useFocusRestore.ts
|
|
10588
|
-
import { useRef as
|
|
10623
|
+
import { useRef as useRef10, useEffect as useEffect9 } from "react";
|
|
10589
10624
|
import { isNotNil as isNotNil22 } from "@wistia/type-guards";
|
|
10590
10625
|
var useFocusRestore = () => {
|
|
10591
|
-
const previouslyFocusedRef =
|
|
10592
|
-
|
|
10626
|
+
const previouslyFocusedRef = useRef10(null);
|
|
10627
|
+
useEffect9(() => {
|
|
10593
10628
|
previouslyFocusedRef.current = document.activeElement;
|
|
10594
10629
|
}, []);
|
|
10595
|
-
|
|
10630
|
+
useEffect9(() => {
|
|
10596
10631
|
return () => {
|
|
10597
10632
|
if (isNotNil22(previouslyFocusedRef.current)) {
|
|
10598
10633
|
setTimeout(() => {
|
|
@@ -11112,13 +11147,13 @@ import { Root as ToggleGroupRoot } from "@radix-ui/react-toggle-group";
|
|
|
11112
11147
|
import { isNil as isNil14 } from "@wistia/type-guards";
|
|
11113
11148
|
|
|
11114
11149
|
// src/components/SegmentedControl/useSelectedItemStyle.tsx
|
|
11115
|
-
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";
|
|
11116
11151
|
import { jsx as jsx248 } from "react/jsx-runtime";
|
|
11117
11152
|
var SelectedItemStyleContext = createContext7(null);
|
|
11118
11153
|
var SelectedItemStyleProvider = ({
|
|
11119
11154
|
children
|
|
11120
11155
|
}) => {
|
|
11121
|
-
const [selectedItemMeasurements, setSelectedItemMeasurements] =
|
|
11156
|
+
const [selectedItemMeasurements, setSelectedItemMeasurements] = useState12(null);
|
|
11122
11157
|
const selectedItemIndicatorStyle = useMemo8(
|
|
11123
11158
|
() => selectedItemMeasurements != null ? {
|
|
11124
11159
|
height: `${selectedItemMeasurements.offsetHeight}px`,
|
|
@@ -11235,7 +11270,7 @@ var SegmentedControl = forwardRef21(
|
|
|
11235
11270
|
SegmentedControl.displayName = "SegmentedControl";
|
|
11236
11271
|
|
|
11237
11272
|
// src/components/SegmentedControl/SegmentedControlItem.tsx
|
|
11238
|
-
import { forwardRef as forwardRef22, useEffect as
|
|
11273
|
+
import { forwardRef as forwardRef22, useEffect as useEffect10, useRef as useRef11 } from "react";
|
|
11239
11274
|
import styled54, { css as css33 } from "styled-components";
|
|
11240
11275
|
import { Item as ToggleGroupItem } from "@radix-ui/react-toggle-group";
|
|
11241
11276
|
import { isNotNil as isNotNil26 } from "@wistia/type-guards";
|
|
@@ -11307,7 +11342,7 @@ var SegmentedControlItem = forwardRef22(
|
|
|
11307
11342
|
({ disabled, icon, label, "aria-label": ariaLabel, value }, forwardedRef) => {
|
|
11308
11343
|
const selectedValue = useSegmentedControlValue();
|
|
11309
11344
|
const { setSelectedItemMeasurements } = useSelectedItemStyle();
|
|
11310
|
-
const buttonRef =
|
|
11345
|
+
const buttonRef = useRef11(null);
|
|
11311
11346
|
const combinedRef = mergeRefs([buttonRef, forwardedRef]);
|
|
11312
11347
|
const handleClick = (event) => {
|
|
11313
11348
|
const target = event.target;
|
|
@@ -11316,7 +11351,7 @@ var SegmentedControlItem = forwardRef22(
|
|
|
11316
11351
|
event.preventDefault();
|
|
11317
11352
|
}
|
|
11318
11353
|
};
|
|
11319
|
-
|
|
11354
|
+
useEffect10(() => {
|
|
11320
11355
|
const buttonElem = buttonRef.current;
|
|
11321
11356
|
if (!buttonElem) {
|
|
11322
11357
|
return void 0;
|
|
@@ -11733,22 +11768,29 @@ var StyledTable = styled59.table`
|
|
|
11733
11768
|
width: 100%;
|
|
11734
11769
|
border-collapse: collapse;
|
|
11735
11770
|
|
|
11771
|
+
${({ $divided }) => $divided && css35`
|
|
11772
|
+
tr {
|
|
11773
|
+
border-bottom: 1px solid var(--wui-color-border);
|
|
11774
|
+
}
|
|
11775
|
+
`}
|
|
11776
|
+
|
|
11736
11777
|
${({ $striped }) => $striped && css35`
|
|
11737
11778
|
tbody tr:nth-child(even) {
|
|
11738
11779
|
background-color: var(--wui-color-bg-surface-secondary);
|
|
11739
11780
|
}
|
|
11740
11781
|
`}
|
|
11741
11782
|
|
|
11742
|
-
${({ $
|
|
11743
|
-
|
|
11744
|
-
|
|
11783
|
+
${({ $visuallyHiddenHeader }) => $visuallyHiddenHeader && css35`
|
|
11784
|
+
thead {
|
|
11785
|
+
${visuallyHiddenStyle}
|
|
11745
11786
|
}
|
|
11746
11787
|
`}
|
|
11747
11788
|
`;
|
|
11748
11789
|
var Table = ({
|
|
11749
11790
|
children,
|
|
11750
|
-
striped = false,
|
|
11751
11791
|
divided = false,
|
|
11792
|
+
striped = false,
|
|
11793
|
+
visuallyHiddenHeader = false,
|
|
11752
11794
|
...props
|
|
11753
11795
|
}) => {
|
|
11754
11796
|
return /* @__PURE__ */ jsx255(
|
|
@@ -11756,6 +11798,7 @@ var Table = ({
|
|
|
11756
11798
|
{
|
|
11757
11799
|
$divided: divided,
|
|
11758
11800
|
$striped: striped,
|
|
11801
|
+
$visuallyHiddenHeader: visuallyHiddenHeader,
|
|
11759
11802
|
...props,
|
|
11760
11803
|
children
|
|
11761
11804
|
}
|
|
@@ -11771,9 +11814,9 @@ var TableSectionContext = createContext9(null);
|
|
|
11771
11814
|
|
|
11772
11815
|
// src/components/Table/TableBody.tsx
|
|
11773
11816
|
import { jsx as jsx256 } from "react/jsx-runtime";
|
|
11774
|
-
var
|
|
11817
|
+
var StyledTableBody = styled60.tbody``;
|
|
11775
11818
|
var TableBody = ({ children, ...props }) => {
|
|
11776
|
-
return /* @__PURE__ */ jsx256(TableSectionContext.Provider, { value: "body", children: /* @__PURE__ */ jsx256(
|
|
11819
|
+
return /* @__PURE__ */ jsx256(TableSectionContext.Provider, { value: "body", children: /* @__PURE__ */ jsx256(StyledTableBody, { ...props, children }) });
|
|
11777
11820
|
};
|
|
11778
11821
|
|
|
11779
11822
|
// src/components/Table/TableCell.tsx
|
|
@@ -11805,12 +11848,12 @@ var TableCell = ({ children, ...props }) => {
|
|
|
11805
11848
|
return /* @__PURE__ */ jsx257(StyledTd, { ...props, children });
|
|
11806
11849
|
};
|
|
11807
11850
|
|
|
11808
|
-
// src/components/Table/
|
|
11851
|
+
// src/components/Table/TableFoot.tsx
|
|
11809
11852
|
import styled62 from "styled-components";
|
|
11810
11853
|
import { jsx as jsx258 } from "react/jsx-runtime";
|
|
11811
|
-
var
|
|
11812
|
-
var
|
|
11813
|
-
return /* @__PURE__ */ jsx258(TableSectionContext.Provider, { value: "footer", children: /* @__PURE__ */ jsx258(
|
|
11854
|
+
var StyledTableFoot = styled62.tfoot``;
|
|
11855
|
+
var TableFoot = ({ children, ...props }) => {
|
|
11856
|
+
return /* @__PURE__ */ jsx258(TableSectionContext.Provider, { value: "footer", children: /* @__PURE__ */ jsx258(StyledTableFoot, { ...props, children }) });
|
|
11814
11857
|
};
|
|
11815
11858
|
|
|
11816
11859
|
// src/components/Table/TableHead.tsx
|
|
@@ -11824,13 +11867,13 @@ var TableHead = ({ children, ...props }) => {
|
|
|
11824
11867
|
// src/components/Table/TableRow.tsx
|
|
11825
11868
|
import styled64 from "styled-components";
|
|
11826
11869
|
import { jsx as jsx260 } from "react/jsx-runtime";
|
|
11827
|
-
var
|
|
11870
|
+
var StyledTableRow = styled64.tr``;
|
|
11828
11871
|
var TableRow = ({ children, ...props }) => {
|
|
11829
|
-
return /* @__PURE__ */ jsx260(
|
|
11872
|
+
return /* @__PURE__ */ jsx260(StyledTableRow, { ...props, children });
|
|
11830
11873
|
};
|
|
11831
11874
|
|
|
11832
11875
|
// src/components/Tabs/Tabs.tsx
|
|
11833
|
-
import { forwardRef as forwardRef27, useState as
|
|
11876
|
+
import { forwardRef as forwardRef27, useState as useState13 } from "react";
|
|
11834
11877
|
import { Root as TabsRoot } from "@radix-ui/react-tabs";
|
|
11835
11878
|
import { isNotNil as isNotNil29, isNil as isNil15 } from "@wistia/type-guards";
|
|
11836
11879
|
import styled69 from "styled-components";
|
|
@@ -11885,7 +11928,7 @@ var TabList = ({
|
|
|
11885
11928
|
TabList.displayName = "TabList";
|
|
11886
11929
|
|
|
11887
11930
|
// src/components/Tabs/TabItem.tsx
|
|
11888
|
-
import { forwardRef as forwardRef26, useEffect as
|
|
11931
|
+
import { forwardRef as forwardRef26, useEffect as useEffect11, useRef as useRef12 } from "react";
|
|
11889
11932
|
import styled67 from "styled-components";
|
|
11890
11933
|
import { Trigger as RadixTab } from "@radix-ui/react-tabs";
|
|
11891
11934
|
import { isNotNil as isNotNil28 } from "@wistia/type-guards";
|
|
@@ -11915,9 +11958,9 @@ var TabItem = forwardRef26(
|
|
|
11915
11958
|
({ disabled = false, icon, label, "aria-label": ariaLabel, value }, forwardedRef) => {
|
|
11916
11959
|
const selectedValue = useTabsValue();
|
|
11917
11960
|
const { setSelectedItemMeasurements } = useSelectedItemStyle();
|
|
11918
|
-
const buttonRef =
|
|
11961
|
+
const buttonRef = useRef12(null);
|
|
11919
11962
|
const combinedRef = mergeRefs([buttonRef, forwardedRef]);
|
|
11920
|
-
|
|
11963
|
+
useEffect11(() => {
|
|
11921
11964
|
const buttonElem = buttonRef.current;
|
|
11922
11965
|
if (!buttonElem) {
|
|
11923
11966
|
return void 0;
|
|
@@ -12029,7 +12072,7 @@ var Tabs = forwardRef27(
|
|
|
12029
12072
|
...props
|
|
12030
12073
|
}, ref) => {
|
|
12031
12074
|
const tabItems = extractTabItems(children);
|
|
12032
|
-
const [internalSelectedValue, setInternalSelectedValue] =
|
|
12075
|
+
const [internalSelectedValue, setInternalSelectedValue] = useState13(defaultSelectedValue);
|
|
12033
12076
|
const modeProps = defaultSelectedValue !== void 0 ? {
|
|
12034
12077
|
defaultValue: defaultSelectedValue,
|
|
12035
12078
|
onValueChange: setInternalSelectedValue
|
|
@@ -12834,7 +12877,7 @@ export {
|
|
|
12834
12877
|
Table,
|
|
12835
12878
|
TableBody,
|
|
12836
12879
|
TableCell,
|
|
12837
|
-
|
|
12880
|
+
TableFoot,
|
|
12838
12881
|
TableHead,
|
|
12839
12882
|
TableRow,
|
|
12840
12883
|
Tabs,
|
|
@@ -12855,6 +12898,7 @@ export {
|
|
|
12855
12898
|
useActiveMq,
|
|
12856
12899
|
useAriaLive,
|
|
12857
12900
|
useBoolean,
|
|
12901
|
+
useClipboard,
|
|
12858
12902
|
useFilePicker,
|
|
12859
12903
|
useFocusTrap,
|
|
12860
12904
|
useFormState,
|