@wistia/ui 0.6.0-beta.ba89134f.7e9273d → 0.6.0-beta.bb5b72ea.8fc24a4
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 +64 -25
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +122 -5
- package/dist/index.d.ts +122 -5
- package/dist/index.mjs +69 -30
- package/dist/index.mjs.map +1 -1
- package/package.json +21 -20
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
/*
|
|
3
|
-
* @license @wistia/ui v0.6.0-beta.
|
|
3
|
+
* @license @wistia/ui v0.6.0-beta.bb5b72ea.8fc24a4
|
|
4
4
|
*
|
|
5
5
|
* Copyright (c) 2024-2025, Wistia, Inc. and its affiliates.
|
|
6
6
|
*
|
|
@@ -8135,9 +8135,18 @@ var FormContext = (0, import_react25.createContext)({
|
|
|
8135
8135
|
values: {},
|
|
8136
8136
|
errors: {},
|
|
8137
8137
|
hasSubmitted: false,
|
|
8138
|
-
formId: ""
|
|
8138
|
+
formId: "",
|
|
8139
|
+
labelPosition: "block"
|
|
8139
8140
|
});
|
|
8140
|
-
var FormComponent = ({
|
|
8141
|
+
var FormComponent = ({
|
|
8142
|
+
children,
|
|
8143
|
+
action,
|
|
8144
|
+
values = {},
|
|
8145
|
+
labelPosition = "block",
|
|
8146
|
+
validate,
|
|
8147
|
+
fullWidth = false,
|
|
8148
|
+
...props
|
|
8149
|
+
}, forwardedRef) => {
|
|
8141
8150
|
const [errors, setErrors] = (0, import_react25.useState)({});
|
|
8142
8151
|
const [hasSubmitted, setHasSubmitted] = (0, import_react25.useState)(false);
|
|
8143
8152
|
const innerRef = (0, import_react25.useRef)();
|
|
@@ -8189,19 +8198,20 @@ var FormComponent = ({ children, action, values = {}, validate, fullWidth = fals
|
|
|
8189
8198
|
values,
|
|
8190
8199
|
errors,
|
|
8191
8200
|
hasSubmitted,
|
|
8192
|
-
formId: id
|
|
8201
|
+
formId: id,
|
|
8202
|
+
labelPosition
|
|
8193
8203
|
};
|
|
8194
|
-
}, [values, errors, id, hasSubmitted]);
|
|
8204
|
+
}, [labelPosition, values, errors, id, hasSubmitted]);
|
|
8195
8205
|
return (
|
|
8196
8206
|
// @ts-expect-error - generic context providers are a giant pain
|
|
8197
8207
|
/* @__PURE__ */ (0, import_jsx_runtime189.jsx)(FormContext.Provider, { value: context, children: /* @__PURE__ */ (0, import_jsx_runtime189.jsx)(
|
|
8198
8208
|
Stack,
|
|
8199
8209
|
{
|
|
8200
|
-
gap: "space-05",
|
|
8201
8210
|
...props,
|
|
8202
8211
|
ref,
|
|
8203
8212
|
$fullWidth: fullWidth,
|
|
8204
8213
|
as: StyledForm,
|
|
8214
|
+
gap: "space-05",
|
|
8205
8215
|
id,
|
|
8206
8216
|
onBlur: handleBlur,
|
|
8207
8217
|
onReset: handleReset,
|
|
@@ -8255,7 +8265,7 @@ var import_react27 = require("react");
|
|
|
8255
8265
|
var import_type_guards27 = require("@wistia/type-guards");
|
|
8256
8266
|
var import_jsx_runtime190 = require("react/jsx-runtime");
|
|
8257
8267
|
var ErrorItem = ({ name, error, formId }) => {
|
|
8258
|
-
return /* @__PURE__ */ (0, import_jsx_runtime190.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime190.jsx)(Link, { href:
|
|
8268
|
+
return /* @__PURE__ */ (0, import_jsx_runtime190.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime190.jsx)(Link, { href: `#${formId}-${name}`, children: error }) }, name);
|
|
8259
8269
|
};
|
|
8260
8270
|
var FormErrorSummary = ({ description }) => {
|
|
8261
8271
|
const ref = (0, import_react27.useRef)(null);
|
|
@@ -8354,11 +8364,27 @@ CheckboxGroup.displayName = "CheckboxGroup";
|
|
|
8354
8364
|
var import_jsx_runtime193 = require("react/jsx-runtime");
|
|
8355
8365
|
var StyledFormField = import_styled_components48.default.div`
|
|
8356
8366
|
--form-field-spacing: var(--wui-space-01);
|
|
8367
|
+
--form-field-spacing-inline: var(--wui-space-02);
|
|
8357
8368
|
--form-field-error-color: var(--wui-color-text-secondary-error);
|
|
8358
8369
|
|
|
8359
|
-
display:
|
|
8360
|
-
flex-direction: column;
|
|
8370
|
+
display: grid;
|
|
8361
8371
|
gap: var(--form-field-spacing);
|
|
8372
|
+
justify-content: flex-start;
|
|
8373
|
+
align-items: center;
|
|
8374
|
+
grid-template-columns: auto 1fr;
|
|
8375
|
+
grid-template-rows: auto 1fr;
|
|
8376
|
+
|
|
8377
|
+
&[data-label-position='inline'] {
|
|
8378
|
+
gap: var(--form-field-spacing-inline);
|
|
8379
|
+
grid-template-columns: minmax(auto, 1fr) 1fr;
|
|
8380
|
+
grid-template-rows: 1fr auto;
|
|
8381
|
+
}
|
|
8382
|
+
|
|
8383
|
+
&[data-label-position='block'] {
|
|
8384
|
+
gap: var(--form-field-spacing);
|
|
8385
|
+
grid-template-columns: 1fr;
|
|
8386
|
+
grid-template-rows: 1fr;
|
|
8387
|
+
}
|
|
8362
8388
|
`;
|
|
8363
8389
|
var StyledErrorList = import_styled_components48.default.ul`
|
|
8364
8390
|
margin: 0;
|
|
@@ -8398,18 +8424,20 @@ var FormField = ({
|
|
|
8398
8424
|
name,
|
|
8399
8425
|
error,
|
|
8400
8426
|
value,
|
|
8427
|
+
labelPosition,
|
|
8428
|
+
id,
|
|
8401
8429
|
...props
|
|
8402
8430
|
}) => {
|
|
8403
8431
|
const formState = (0, import_react30.useContext)(FormContext);
|
|
8404
8432
|
const checkboxGroup = (0, import_react30.useContext)(CheckboxGroupContext);
|
|
8405
|
-
const
|
|
8406
|
-
const
|
|
8433
|
+
const isIntegratedLabel = children.type === Checkbox;
|
|
8434
|
+
const computedId = id ?? `${formState.formId}-${name}`;
|
|
8407
8435
|
const computedError = error ?? formState.errors[name];
|
|
8408
8436
|
const defaultValue = formState.values[name];
|
|
8409
8437
|
let childProps = {
|
|
8410
8438
|
name,
|
|
8411
|
-
id,
|
|
8412
|
-
label:
|
|
8439
|
+
id: computedId,
|
|
8440
|
+
label: isIntegratedLabel ? label : void 0,
|
|
8413
8441
|
...props
|
|
8414
8442
|
};
|
|
8415
8443
|
if ((0, import_type_guards28.isUndefined)(value) && (0, import_type_guards28.isNotUndefined)(defaultValue)) {
|
|
@@ -8433,21 +8461,31 @@ var FormField = ({
|
|
|
8433
8461
|
name: computedName,
|
|
8434
8462
|
onChange: handleChange,
|
|
8435
8463
|
"aria-invalid": (0, import_type_guards28.isNotNil)(error),
|
|
8436
|
-
"aria-describedby": (0, import_type_guards28.isNotNil)(error) ? `${
|
|
8464
|
+
"aria-describedby": (0, import_type_guards28.isNotNil)(error) ? `${computedId}-error` : void 0
|
|
8437
8465
|
};
|
|
8438
8466
|
}
|
|
8439
8467
|
import_react30.Children.only(children);
|
|
8440
|
-
return /* @__PURE__ */ (0, import_jsx_runtime193.jsxs)(
|
|
8441
|
-
|
|
8442
|
-
|
|
8443
|
-
|
|
8444
|
-
|
|
8445
|
-
|
|
8446
|
-
|
|
8447
|
-
|
|
8448
|
-
|
|
8449
|
-
|
|
8450
|
-
|
|
8468
|
+
return /* @__PURE__ */ (0, import_jsx_runtime193.jsxs)(
|
|
8469
|
+
StyledFormField,
|
|
8470
|
+
{
|
|
8471
|
+
...props,
|
|
8472
|
+
"data-label-position": labelPosition ?? formState.labelPosition,
|
|
8473
|
+
children: [
|
|
8474
|
+
!isIntegratedLabel && /* @__PURE__ */ (0, import_jsx_runtime193.jsx)(Label, { htmlFor: computedId, children: label }),
|
|
8475
|
+
(0, import_react30.cloneElement)(children, childProps),
|
|
8476
|
+
(0, import_type_guards28.isNotNil)(computedError) ? /* @__PURE__ */ (0, import_jsx_runtime193.jsxs)(import_jsx_runtime193.Fragment, { children: [
|
|
8477
|
+
/* @__PURE__ */ (0, import_jsx_runtime193.jsx)("div", {}),
|
|
8478
|
+
/* @__PURE__ */ (0, import_jsx_runtime193.jsx)(
|
|
8479
|
+
ErrorMessages,
|
|
8480
|
+
{
|
|
8481
|
+
errors: computedError,
|
|
8482
|
+
id: `${computedId}-error`
|
|
8483
|
+
}
|
|
8484
|
+
)
|
|
8485
|
+
] }) : null
|
|
8486
|
+
]
|
|
8487
|
+
}
|
|
8488
|
+
);
|
|
8451
8489
|
};
|
|
8452
8490
|
FormField.displayName = "FormField";
|
|
8453
8491
|
|
|
@@ -10403,6 +10441,7 @@ var StyledContent3 = (0, import_styled_components71.default)(import_react_select
|
|
|
10403
10441
|
border-radius: var(--wui-select-content-border-radius);
|
|
10404
10442
|
padding: var(--wui-select-option-padding);
|
|
10405
10443
|
min-width: 200px;
|
|
10444
|
+
z-index: var(--wui-zindex-menu);
|
|
10406
10445
|
`;
|
|
10407
10446
|
var Select = (0, import_react55.forwardRef)(
|
|
10408
10447
|
({
|