@wistia/ui 0.6.2 → 0.6.3-beta.4625fea3.f2024d4

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