@wistia/ui 0.6.2 → 0.6.3-beta.3b2445dd.939209b
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 +149 -103
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +143 -24
- package/dist/index.d.ts +143 -24
- package/dist/index.mjs +149 -105
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -1
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
/*
|
|
3
|
-
* @license @wistia/ui v0.6.
|
|
3
|
+
* @license @wistia/ui v0.6.3-beta.3b2445dd.939209b
|
|
4
4
|
*
|
|
5
5
|
* Copyright (c) 2024-2025, Wistia, Inc. and its affiliates.
|
|
6
6
|
*
|
|
@@ -108,7 +108,9 @@ __export(index_exports, {
|
|
|
108
108
|
useActiveMq: () => useActiveMq,
|
|
109
109
|
useAriaLive: () => useAriaLive,
|
|
110
110
|
useBoolean: () => useBoolean,
|
|
111
|
+
useFilePicker: () => import_use_file_picker.useFilePicker,
|
|
111
112
|
useFormState: () => useFormState,
|
|
113
|
+
useImperativeFilePicker: () => import_use_file_picker.useImperativeFilePicker,
|
|
112
114
|
useKey: () => useKey,
|
|
113
115
|
useMq: () => useMq,
|
|
114
116
|
useToast: () => useToast,
|
|
@@ -2005,82 +2007,29 @@ var mq = {
|
|
|
2005
2007
|
xlAndDown
|
|
2006
2008
|
};
|
|
2007
2009
|
|
|
2008
|
-
// src/hooks/
|
|
2010
|
+
// src/hooks/useAriaLive/useAriaLive.tsx
|
|
2009
2011
|
var import_react3 = require("react");
|
|
2010
|
-
var useBoolean = (initialValue = false) => {
|
|
2011
|
-
const [value, setValue] = (0, import_react3.useState)(initialValue);
|
|
2012
|
-
const toggle = (0, import_react3.useCallback)(() => setValue((val) => !val), []);
|
|
2013
|
-
const setTrue = (0, import_react3.useCallback)(() => setValue(true), []);
|
|
2014
|
-
const setFalse = (0, import_react3.useCallback)(() => setValue(false), []);
|
|
2015
|
-
return [value, toggle, setTrue, setFalse, setValue];
|
|
2016
|
-
};
|
|
2017
|
-
|
|
2018
|
-
// src/hooks/useMq/useMq.ts
|
|
2019
2012
|
var import_type_guards5 = require("@wistia/type-guards");
|
|
2013
|
+
var useAriaLive = () => {
|
|
2014
|
+
const context = (0, import_react3.useContext)(AriaLiveContext);
|
|
2015
|
+
if ((0, import_type_guards5.isNil)(context)) {
|
|
2016
|
+
throw new Error("useAriaLive must be used within an AriaLiveProvider");
|
|
2017
|
+
}
|
|
2018
|
+
return context;
|
|
2019
|
+
};
|
|
2020
2020
|
|
|
2021
|
-
// src/hooks/
|
|
2021
|
+
// src/hooks/useBoolean/useBoolean.ts
|
|
2022
2022
|
var import_react4 = require("react");
|
|
2023
|
-
var
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
var useWindowSize = (interval = 0) => {
|
|
2030
|
-
const [dimensions, setDimensions] = (0, import_react4.useState)({
|
|
2031
|
-
width: isClient() ? window.innerWidth : 0,
|
|
2032
|
-
height: isClient() ? window.innerHeight : 0
|
|
2033
|
-
});
|
|
2034
|
-
(0, import_react4.useLayoutEffect)(() => {
|
|
2035
|
-
const handleResize = (0, import_throttle_debounce.debounce)(
|
|
2036
|
-
interval,
|
|
2037
|
-
() => setDimensions({
|
|
2038
|
-
width: window.innerWidth,
|
|
2039
|
-
height: window.innerHeight
|
|
2040
|
-
})
|
|
2041
|
-
);
|
|
2042
|
-
window.addEventListener("resize", handleResize);
|
|
2043
|
-
return () => window.removeEventListener("resize", handleResize);
|
|
2044
|
-
}, [interval]);
|
|
2045
|
-
return dimensions;
|
|
2023
|
+
var useBoolean = (initialValue = false) => {
|
|
2024
|
+
const [value, setValue] = (0, import_react4.useState)(initialValue);
|
|
2025
|
+
const toggle = (0, import_react4.useCallback)(() => setValue((val) => !val), []);
|
|
2026
|
+
const setTrue = (0, import_react4.useCallback)(() => setValue(true), []);
|
|
2027
|
+
const setFalse = (0, import_react4.useCallback)(() => setValue(false), []);
|
|
2028
|
+
return [value, toggle, setTrue, setFalse, setValue];
|
|
2046
2029
|
};
|
|
2047
2030
|
|
|
2048
|
-
// src/hooks/
|
|
2049
|
-
var
|
|
2050
|
-
var useMq = () => {
|
|
2051
|
-
const { width } = useWindowSize();
|
|
2052
|
-
const viewportWidth = width / REM_SIZE;
|
|
2053
|
-
const isXsAndUp = true;
|
|
2054
|
-
const isSmAndUp = viewportWidth >= Number.parseFloat(breakpoints.sm);
|
|
2055
|
-
const isMdAndUp = viewportWidth >= Number.parseFloat(breakpoints.md);
|
|
2056
|
-
const isLgAndUp = viewportWidth >= Number.parseFloat(breakpoints.lg);
|
|
2057
|
-
const isXlAndUp = viewportWidth >= Number.parseFloat(breakpoints.xl);
|
|
2058
|
-
const isXsAndDown = viewportWidth < Number.parseFloat(breakpoints.sm);
|
|
2059
|
-
const isSmAndDown = viewportWidth < Number.parseFloat(breakpoints.md);
|
|
2060
|
-
const isMdAndDown = viewportWidth < Number.parseFloat(breakpoints.lg);
|
|
2061
|
-
const isLgAndDown = viewportWidth < Number.parseFloat(breakpoints.xl);
|
|
2062
|
-
const isXlAndDown = true;
|
|
2063
|
-
return {
|
|
2064
|
-
isXlAndUp,
|
|
2065
|
-
isLgAndUp,
|
|
2066
|
-
isMdAndUp,
|
|
2067
|
-
isSmAndUp,
|
|
2068
|
-
isXsAndUp,
|
|
2069
|
-
isXsAndDown,
|
|
2070
|
-
isSmAndDown,
|
|
2071
|
-
isMdAndDown,
|
|
2072
|
-
isLgAndDown,
|
|
2073
|
-
isXlAndDown
|
|
2074
|
-
};
|
|
2075
|
-
};
|
|
2076
|
-
var useActiveMq = () => {
|
|
2077
|
-
const mq2 = useMq();
|
|
2078
|
-
const keys = Object.keys(mq2);
|
|
2079
|
-
return keys.filter((key) => {
|
|
2080
|
-
const value = mq2[key];
|
|
2081
|
-
return (0, import_type_guards5.isBoolean)(value) && value;
|
|
2082
|
-
});
|
|
2083
|
-
};
|
|
2031
|
+
// src/hooks/useFilePicker/index.ts
|
|
2032
|
+
var import_use_file_picker = require("use-file-picker");
|
|
2084
2033
|
|
|
2085
2034
|
// src/hooks/useKey/useKey.ts
|
|
2086
2035
|
var import_react6 = require("react");
|
|
@@ -2154,15 +2103,71 @@ var useKey = (key, eventHandler, { eventName = "keydown", eventTarget, eventOpti
|
|
|
2154
2103
|
useEvent(eventName, memoizedEventHandler, eventTarget, eventOptions);
|
|
2155
2104
|
};
|
|
2156
2105
|
|
|
2157
|
-
// src/hooks/
|
|
2158
|
-
var import_react7 = require("react");
|
|
2106
|
+
// src/hooks/useMq/useMq.ts
|
|
2159
2107
|
var import_type_guards7 = require("@wistia/type-guards");
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2108
|
+
|
|
2109
|
+
// src/hooks/useWindowSize/useWindowSize.ts
|
|
2110
|
+
var import_react7 = require("react");
|
|
2111
|
+
var import_throttle_debounce = require("throttle-debounce");
|
|
2112
|
+
|
|
2113
|
+
// src/private/helpers/isClient/isClient.ts
|
|
2114
|
+
var isClient = () => typeof window !== "undefined" && typeof document !== "undefined";
|
|
2115
|
+
|
|
2116
|
+
// src/hooks/useWindowSize/useWindowSize.ts
|
|
2117
|
+
var useWindowSize = (interval = 0) => {
|
|
2118
|
+
const [dimensions, setDimensions] = (0, import_react7.useState)({
|
|
2119
|
+
width: isClient() ? window.innerWidth : 0,
|
|
2120
|
+
height: isClient() ? window.innerHeight : 0
|
|
2121
|
+
});
|
|
2122
|
+
(0, import_react7.useLayoutEffect)(() => {
|
|
2123
|
+
const handleResize = (0, import_throttle_debounce.debounce)(
|
|
2124
|
+
interval,
|
|
2125
|
+
() => setDimensions({
|
|
2126
|
+
width: window.innerWidth,
|
|
2127
|
+
height: window.innerHeight
|
|
2128
|
+
})
|
|
2129
|
+
);
|
|
2130
|
+
window.addEventListener("resize", handleResize);
|
|
2131
|
+
return () => window.removeEventListener("resize", handleResize);
|
|
2132
|
+
}, [interval]);
|
|
2133
|
+
return dimensions;
|
|
2134
|
+
};
|
|
2135
|
+
|
|
2136
|
+
// src/hooks/useMq/useMq.ts
|
|
2137
|
+
var REM_SIZE = 16;
|
|
2138
|
+
var useMq = () => {
|
|
2139
|
+
const { width } = useWindowSize();
|
|
2140
|
+
const viewportWidth = width / REM_SIZE;
|
|
2141
|
+
const isXsAndUp = true;
|
|
2142
|
+
const isSmAndUp = viewportWidth >= Number.parseFloat(breakpoints.sm);
|
|
2143
|
+
const isMdAndUp = viewportWidth >= Number.parseFloat(breakpoints.md);
|
|
2144
|
+
const isLgAndUp = viewportWidth >= Number.parseFloat(breakpoints.lg);
|
|
2145
|
+
const isXlAndUp = viewportWidth >= Number.parseFloat(breakpoints.xl);
|
|
2146
|
+
const isXsAndDown = viewportWidth < Number.parseFloat(breakpoints.sm);
|
|
2147
|
+
const isSmAndDown = viewportWidth < Number.parseFloat(breakpoints.md);
|
|
2148
|
+
const isMdAndDown = viewportWidth < Number.parseFloat(breakpoints.lg);
|
|
2149
|
+
const isLgAndDown = viewportWidth < Number.parseFloat(breakpoints.xl);
|
|
2150
|
+
const isXlAndDown = true;
|
|
2151
|
+
return {
|
|
2152
|
+
isXlAndUp,
|
|
2153
|
+
isLgAndUp,
|
|
2154
|
+
isMdAndUp,
|
|
2155
|
+
isSmAndUp,
|
|
2156
|
+
isXsAndUp,
|
|
2157
|
+
isXsAndDown,
|
|
2158
|
+
isSmAndDown,
|
|
2159
|
+
isMdAndDown,
|
|
2160
|
+
isLgAndDown,
|
|
2161
|
+
isXlAndDown
|
|
2162
|
+
};
|
|
2163
|
+
};
|
|
2164
|
+
var useActiveMq = () => {
|
|
2165
|
+
const mq2 = useMq();
|
|
2166
|
+
const keys = Object.keys(mq2);
|
|
2167
|
+
return keys.filter((key) => {
|
|
2168
|
+
const value = mq2[key];
|
|
2169
|
+
return (0, import_type_guards7.isBoolean)(value) && value;
|
|
2170
|
+
});
|
|
2166
2171
|
};
|
|
2167
2172
|
|
|
2168
2173
|
// src/hooks/useToast/useToast.tsx
|
|
@@ -8146,9 +8151,18 @@ var FormContext = (0, import_react25.createContext)({
|
|
|
8146
8151
|
values: {},
|
|
8147
8152
|
errors: {},
|
|
8148
8153
|
hasSubmitted: false,
|
|
8149
|
-
formId: ""
|
|
8154
|
+
formId: "",
|
|
8155
|
+
labelPosition: "block"
|
|
8150
8156
|
});
|
|
8151
|
-
var FormComponent = ({
|
|
8157
|
+
var FormComponent = ({
|
|
8158
|
+
children,
|
|
8159
|
+
action,
|
|
8160
|
+
values = {},
|
|
8161
|
+
labelPosition = "block",
|
|
8162
|
+
validate,
|
|
8163
|
+
fullWidth = false,
|
|
8164
|
+
...props
|
|
8165
|
+
}, forwardedRef) => {
|
|
8152
8166
|
const [errors, setErrors] = (0, import_react25.useState)({});
|
|
8153
8167
|
const [hasSubmitted, setHasSubmitted] = (0, import_react25.useState)(false);
|
|
8154
8168
|
const innerRef = (0, import_react25.useRef)();
|
|
@@ -8200,19 +8214,20 @@ var FormComponent = ({ children, action, values = {}, validate, fullWidth = fals
|
|
|
8200
8214
|
values,
|
|
8201
8215
|
errors,
|
|
8202
8216
|
hasSubmitted,
|
|
8203
|
-
formId: id
|
|
8217
|
+
formId: id,
|
|
8218
|
+
labelPosition
|
|
8204
8219
|
};
|
|
8205
|
-
}, [values, errors, id, hasSubmitted]);
|
|
8220
|
+
}, [labelPosition, values, errors, id, hasSubmitted]);
|
|
8206
8221
|
return (
|
|
8207
8222
|
// @ts-expect-error - generic context providers are a giant pain
|
|
8208
8223
|
/* @__PURE__ */ (0, import_jsx_runtime189.jsx)(FormContext.Provider, { value: context, children: /* @__PURE__ */ (0, import_jsx_runtime189.jsx)(
|
|
8209
8224
|
Stack,
|
|
8210
8225
|
{
|
|
8211
|
-
gap: "space-05",
|
|
8212
8226
|
...props,
|
|
8213
8227
|
ref,
|
|
8214
8228
|
$fullWidth: fullWidth,
|
|
8215
8229
|
as: StyledForm,
|
|
8230
|
+
gap: "space-05",
|
|
8216
8231
|
id,
|
|
8217
8232
|
onBlur: handleBlur,
|
|
8218
8233
|
onReset: handleReset,
|
|
@@ -8266,7 +8281,7 @@ var import_react27 = require("react");
|
|
|
8266
8281
|
var import_type_guards27 = require("@wistia/type-guards");
|
|
8267
8282
|
var import_jsx_runtime190 = require("react/jsx-runtime");
|
|
8268
8283
|
var ErrorItem = ({ name, error, formId }) => {
|
|
8269
|
-
return /* @__PURE__ */ (0, import_jsx_runtime190.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime190.jsx)(Link, { href:
|
|
8284
|
+
return /* @__PURE__ */ (0, import_jsx_runtime190.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime190.jsx)(Link, { href: `#${formId}-${name}`, children: error }) }, name);
|
|
8270
8285
|
};
|
|
8271
8286
|
var FormErrorSummary = ({ description }) => {
|
|
8272
8287
|
const ref = (0, import_react27.useRef)(null);
|
|
@@ -8365,11 +8380,27 @@ CheckboxGroup.displayName = "CheckboxGroup";
|
|
|
8365
8380
|
var import_jsx_runtime193 = require("react/jsx-runtime");
|
|
8366
8381
|
var StyledFormField = import_styled_components48.default.div`
|
|
8367
8382
|
--form-field-spacing: var(--wui-space-01);
|
|
8383
|
+
--form-field-spacing-inline: var(--wui-space-02);
|
|
8368
8384
|
--form-field-error-color: var(--wui-color-text-secondary-error);
|
|
8369
8385
|
|
|
8370
|
-
display:
|
|
8371
|
-
flex-direction: column;
|
|
8386
|
+
display: grid;
|
|
8372
8387
|
gap: var(--form-field-spacing);
|
|
8388
|
+
justify-content: flex-start;
|
|
8389
|
+
align-items: center;
|
|
8390
|
+
grid-template-columns: auto 1fr;
|
|
8391
|
+
grid-template-rows: auto 1fr;
|
|
8392
|
+
|
|
8393
|
+
&[data-label-position='inline'] {
|
|
8394
|
+
gap: var(--form-field-spacing-inline);
|
|
8395
|
+
grid-template-columns: minmax(auto, 1fr) 1fr;
|
|
8396
|
+
grid-template-rows: 1fr auto;
|
|
8397
|
+
}
|
|
8398
|
+
|
|
8399
|
+
&[data-label-position='block'] {
|
|
8400
|
+
gap: var(--form-field-spacing);
|
|
8401
|
+
grid-template-columns: 1fr;
|
|
8402
|
+
grid-template-rows: 1fr;
|
|
8403
|
+
}
|
|
8373
8404
|
`;
|
|
8374
8405
|
var StyledErrorList = import_styled_components48.default.ul`
|
|
8375
8406
|
margin: 0;
|
|
@@ -8409,18 +8440,20 @@ var FormField = ({
|
|
|
8409
8440
|
name,
|
|
8410
8441
|
error,
|
|
8411
8442
|
value,
|
|
8443
|
+
labelPosition,
|
|
8444
|
+
id,
|
|
8412
8445
|
...props
|
|
8413
8446
|
}) => {
|
|
8414
8447
|
const formState = (0, import_react30.useContext)(FormContext);
|
|
8415
8448
|
const checkboxGroup = (0, import_react30.useContext)(CheckboxGroupContext);
|
|
8416
|
-
const
|
|
8417
|
-
const
|
|
8449
|
+
const isIntegratedLabel = children.type === Checkbox;
|
|
8450
|
+
const computedId = id ?? `${formState.formId}-${name}`;
|
|
8418
8451
|
const computedError = error ?? formState.errors[name];
|
|
8419
8452
|
const defaultValue = formState.values[name];
|
|
8420
8453
|
let childProps = {
|
|
8421
8454
|
name,
|
|
8422
|
-
id,
|
|
8423
|
-
label:
|
|
8455
|
+
id: computedId,
|
|
8456
|
+
label: isIntegratedLabel ? label : void 0,
|
|
8424
8457
|
...props
|
|
8425
8458
|
};
|
|
8426
8459
|
if ((0, import_type_guards28.isUndefined)(value) && (0, import_type_guards28.isNotUndefined)(defaultValue)) {
|
|
@@ -8444,21 +8477,31 @@ var FormField = ({
|
|
|
8444
8477
|
name: computedName,
|
|
8445
8478
|
onChange: handleChange,
|
|
8446
8479
|
"aria-invalid": (0, import_type_guards28.isNotNil)(error),
|
|
8447
|
-
"aria-describedby": (0, import_type_guards28.isNotNil)(error) ? `${
|
|
8480
|
+
"aria-describedby": (0, import_type_guards28.isNotNil)(error) ? `${computedId}-error` : void 0
|
|
8448
8481
|
};
|
|
8449
8482
|
}
|
|
8450
8483
|
import_react30.Children.only(children);
|
|
8451
|
-
return /* @__PURE__ */ (0, import_jsx_runtime193.jsxs)(
|
|
8452
|
-
|
|
8453
|
-
|
|
8454
|
-
|
|
8455
|
-
|
|
8456
|
-
|
|
8457
|
-
|
|
8458
|
-
|
|
8459
|
-
|
|
8460
|
-
|
|
8461
|
-
|
|
8484
|
+
return /* @__PURE__ */ (0, import_jsx_runtime193.jsxs)(
|
|
8485
|
+
StyledFormField,
|
|
8486
|
+
{
|
|
8487
|
+
...props,
|
|
8488
|
+
"data-label-position": labelPosition ?? formState.labelPosition,
|
|
8489
|
+
children: [
|
|
8490
|
+
!isIntegratedLabel && /* @__PURE__ */ (0, import_jsx_runtime193.jsx)(Label, { htmlFor: computedId, children: label }),
|
|
8491
|
+
(0, import_react30.cloneElement)(children, childProps),
|
|
8492
|
+
(0, import_type_guards28.isNotNil)(computedError) ? /* @__PURE__ */ (0, import_jsx_runtime193.jsxs)(import_jsx_runtime193.Fragment, { children: [
|
|
8493
|
+
/* @__PURE__ */ (0, import_jsx_runtime193.jsx)("div", {}),
|
|
8494
|
+
/* @__PURE__ */ (0, import_jsx_runtime193.jsx)(
|
|
8495
|
+
ErrorMessages,
|
|
8496
|
+
{
|
|
8497
|
+
errors: computedError,
|
|
8498
|
+
id: `${computedId}-error`
|
|
8499
|
+
}
|
|
8500
|
+
)
|
|
8501
|
+
] }) : null
|
|
8502
|
+
]
|
|
8503
|
+
}
|
|
8504
|
+
);
|
|
8462
8505
|
};
|
|
8463
8506
|
FormField.displayName = "FormField";
|
|
8464
8507
|
|
|
@@ -10414,6 +10457,7 @@ var StyledContent3 = (0, import_styled_components71.default)(import_react_select
|
|
|
10414
10457
|
border-radius: var(--wui-select-content-border-radius);
|
|
10415
10458
|
padding: var(--wui-select-option-padding);
|
|
10416
10459
|
min-width: 200px;
|
|
10460
|
+
z-index: var(--wui-zindex-menu);
|
|
10417
10461
|
`;
|
|
10418
10462
|
var Select = (0, import_react55.forwardRef)(
|
|
10419
10463
|
({
|
|
@@ -10656,7 +10700,9 @@ Image.displayName = "Image";
|
|
|
10656
10700
|
useActiveMq,
|
|
10657
10701
|
useAriaLive,
|
|
10658
10702
|
useBoolean,
|
|
10703
|
+
useFilePicker,
|
|
10659
10704
|
useFormState,
|
|
10705
|
+
useImperativeFilePicker,
|
|
10660
10706
|
useKey,
|
|
10661
10707
|
useMq,
|
|
10662
10708
|
useToast,
|