@wistia/ui 0.6.2-beta.be728696.d49d6eb → 0.6.2
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 +25 -64
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +5 -122
- package/dist/index.d.ts +5 -122
- package/dist/index.mjs +30 -69
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
/*
|
|
3
|
-
* @license @wistia/ui v0.6.2
|
|
3
|
+
* @license @wistia/ui v0.6.2
|
|
4
4
|
*
|
|
5
5
|
* Copyright (c) 2024-2025, Wistia, Inc. and its affiliates.
|
|
6
6
|
*
|
|
@@ -8146,18 +8146,9 @@ var FormContext = (0, import_react25.createContext)({
|
|
|
8146
8146
|
values: {},
|
|
8147
8147
|
errors: {},
|
|
8148
8148
|
hasSubmitted: false,
|
|
8149
|
-
formId: ""
|
|
8150
|
-
labelPosition: "block"
|
|
8149
|
+
formId: ""
|
|
8151
8150
|
});
|
|
8152
|
-
var FormComponent = ({
|
|
8153
|
-
children,
|
|
8154
|
-
action,
|
|
8155
|
-
values = {},
|
|
8156
|
-
labelPosition = "block",
|
|
8157
|
-
validate,
|
|
8158
|
-
fullWidth = false,
|
|
8159
|
-
...props
|
|
8160
|
-
}, forwardedRef) => {
|
|
8151
|
+
var FormComponent = ({ children, action, values = {}, validate, fullWidth = false, ...props }, forwardedRef) => {
|
|
8161
8152
|
const [errors, setErrors] = (0, import_react25.useState)({});
|
|
8162
8153
|
const [hasSubmitted, setHasSubmitted] = (0, import_react25.useState)(false);
|
|
8163
8154
|
const innerRef = (0, import_react25.useRef)();
|
|
@@ -8209,20 +8200,19 @@ var FormComponent = ({
|
|
|
8209
8200
|
values,
|
|
8210
8201
|
errors,
|
|
8211
8202
|
hasSubmitted,
|
|
8212
|
-
formId: id
|
|
8213
|
-
labelPosition
|
|
8203
|
+
formId: id
|
|
8214
8204
|
};
|
|
8215
|
-
}, [
|
|
8205
|
+
}, [values, errors, id, hasSubmitted]);
|
|
8216
8206
|
return (
|
|
8217
8207
|
// @ts-expect-error - generic context providers are a giant pain
|
|
8218
8208
|
/* @__PURE__ */ (0, import_jsx_runtime189.jsx)(FormContext.Provider, { value: context, children: /* @__PURE__ */ (0, import_jsx_runtime189.jsx)(
|
|
8219
8209
|
Stack,
|
|
8220
8210
|
{
|
|
8211
|
+
gap: "space-05",
|
|
8221
8212
|
...props,
|
|
8222
8213
|
ref,
|
|
8223
8214
|
$fullWidth: fullWidth,
|
|
8224
8215
|
as: StyledForm,
|
|
8225
|
-
gap: "space-05",
|
|
8226
8216
|
id,
|
|
8227
8217
|
onBlur: handleBlur,
|
|
8228
8218
|
onReset: handleReset,
|
|
@@ -8276,7 +8266,7 @@ var import_react27 = require("react");
|
|
|
8276
8266
|
var import_type_guards27 = require("@wistia/type-guards");
|
|
8277
8267
|
var import_jsx_runtime190 = require("react/jsx-runtime");
|
|
8278
8268
|
var ErrorItem = ({ name, error, formId }) => {
|
|
8279
|
-
return /* @__PURE__ */ (0, import_jsx_runtime190.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime190.jsx)(Link, { href:
|
|
8269
|
+
return /* @__PURE__ */ (0, import_jsx_runtime190.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime190.jsx)(Link, { href: `${formId}-${name}`, children: error }) }, name);
|
|
8280
8270
|
};
|
|
8281
8271
|
var FormErrorSummary = ({ description }) => {
|
|
8282
8272
|
const ref = (0, import_react27.useRef)(null);
|
|
@@ -8375,27 +8365,11 @@ CheckboxGroup.displayName = "CheckboxGroup";
|
|
|
8375
8365
|
var import_jsx_runtime193 = require("react/jsx-runtime");
|
|
8376
8366
|
var StyledFormField = import_styled_components48.default.div`
|
|
8377
8367
|
--form-field-spacing: var(--wui-space-01);
|
|
8378
|
-
--form-field-spacing-inline: var(--wui-space-02);
|
|
8379
8368
|
--form-field-error-color: var(--wui-color-text-secondary-error);
|
|
8380
8369
|
|
|
8381
|
-
display:
|
|
8370
|
+
display: flex;
|
|
8371
|
+
flex-direction: column;
|
|
8382
8372
|
gap: var(--form-field-spacing);
|
|
8383
|
-
justify-content: flex-start;
|
|
8384
|
-
align-items: center;
|
|
8385
|
-
grid-template-columns: auto 1fr;
|
|
8386
|
-
grid-template-rows: auto 1fr;
|
|
8387
|
-
|
|
8388
|
-
&[data-label-position='inline'] {
|
|
8389
|
-
gap: var(--form-field-spacing-inline);
|
|
8390
|
-
grid-template-columns: minmax(auto, 1fr) 1fr;
|
|
8391
|
-
grid-template-rows: 1fr auto;
|
|
8392
|
-
}
|
|
8393
|
-
|
|
8394
|
-
&[data-label-position='block'] {
|
|
8395
|
-
gap: var(--form-field-spacing);
|
|
8396
|
-
grid-template-columns: 1fr;
|
|
8397
|
-
grid-template-rows: 1fr;
|
|
8398
|
-
}
|
|
8399
8373
|
`;
|
|
8400
8374
|
var StyledErrorList = import_styled_components48.default.ul`
|
|
8401
8375
|
margin: 0;
|
|
@@ -8435,20 +8409,18 @@ var FormField = ({
|
|
|
8435
8409
|
name,
|
|
8436
8410
|
error,
|
|
8437
8411
|
value,
|
|
8438
|
-
labelPosition,
|
|
8439
|
-
id,
|
|
8440
8412
|
...props
|
|
8441
8413
|
}) => {
|
|
8442
8414
|
const formState = (0, import_react30.useContext)(FormContext);
|
|
8443
8415
|
const checkboxGroup = (0, import_react30.useContext)(CheckboxGroupContext);
|
|
8444
|
-
const
|
|
8445
|
-
const
|
|
8416
|
+
const id = props.id ?? `${formState.formId}-${name}`;
|
|
8417
|
+
const isInlineLabel = children.type === Checkbox;
|
|
8446
8418
|
const computedError = error ?? formState.errors[name];
|
|
8447
8419
|
const defaultValue = formState.values[name];
|
|
8448
8420
|
let childProps = {
|
|
8449
8421
|
name,
|
|
8450
|
-
id
|
|
8451
|
-
label:
|
|
8422
|
+
id,
|
|
8423
|
+
label: isInlineLabel ? label : void 0,
|
|
8452
8424
|
...props
|
|
8453
8425
|
};
|
|
8454
8426
|
if ((0, import_type_guards28.isUndefined)(value) && (0, import_type_guards28.isNotUndefined)(defaultValue)) {
|
|
@@ -8472,31 +8444,21 @@ var FormField = ({
|
|
|
8472
8444
|
name: computedName,
|
|
8473
8445
|
onChange: handleChange,
|
|
8474
8446
|
"aria-invalid": (0, import_type_guards28.isNotNil)(error),
|
|
8475
|
-
"aria-describedby": (0, import_type_guards28.isNotNil)(error) ? `${
|
|
8447
|
+
"aria-describedby": (0, import_type_guards28.isNotNil)(error) ? `${id}-error` : void 0
|
|
8476
8448
|
};
|
|
8477
8449
|
}
|
|
8478
8450
|
import_react30.Children.only(children);
|
|
8479
|
-
return /* @__PURE__ */ (0, import_jsx_runtime193.jsxs)(
|
|
8480
|
-
|
|
8481
|
-
|
|
8482
|
-
|
|
8483
|
-
|
|
8484
|
-
|
|
8485
|
-
|
|
8486
|
-
|
|
8487
|
-
|
|
8488
|
-
|
|
8489
|
-
|
|
8490
|
-
ErrorMessages,
|
|
8491
|
-
{
|
|
8492
|
-
errors: computedError,
|
|
8493
|
-
id: `${computedId}-error`
|
|
8494
|
-
}
|
|
8495
|
-
)
|
|
8496
|
-
] }) : null
|
|
8497
|
-
]
|
|
8498
|
-
}
|
|
8499
|
-
);
|
|
8451
|
+
return /* @__PURE__ */ (0, import_jsx_runtime193.jsxs)(StyledFormField, { ...props, children: [
|
|
8452
|
+
!isInlineLabel && /* @__PURE__ */ (0, import_jsx_runtime193.jsx)(Label, { htmlFor: id, children: label }),
|
|
8453
|
+
(0, import_react30.cloneElement)(children, childProps),
|
|
8454
|
+
(0, import_type_guards28.isNotNil)(computedError) ? /* @__PURE__ */ (0, import_jsx_runtime193.jsx)(
|
|
8455
|
+
ErrorMessages,
|
|
8456
|
+
{
|
|
8457
|
+
errors: computedError,
|
|
8458
|
+
id: `${id}-error`
|
|
8459
|
+
}
|
|
8460
|
+
) : null
|
|
8461
|
+
] });
|
|
8500
8462
|
};
|
|
8501
8463
|
FormField.displayName = "FormField";
|
|
8502
8464
|
|
|
@@ -10452,7 +10414,6 @@ var StyledContent3 = (0, import_styled_components71.default)(import_react_select
|
|
|
10452
10414
|
border-radius: var(--wui-select-content-border-radius);
|
|
10453
10415
|
padding: var(--wui-select-option-padding);
|
|
10454
10416
|
min-width: 200px;
|
|
10455
|
-
z-index: var(--wui-zindex-menu);
|
|
10456
10417
|
`;
|
|
10457
10418
|
var Select = (0, import_react55.forwardRef)(
|
|
10458
10419
|
({
|