@wistia/ui 0.6.2 → 0.6.3-beta.5b311d65.bf5ea63

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.5b311d65.bf5ea63
4
4
  *
5
5
  * Copyright (c) 2024-2025, Wistia, Inc. and its affiliates.
6
6
  *
@@ -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
 
@@ -9586,8 +9624,9 @@ var SelectedItemIndicatorDiv = import_styled_components62.default.div`
9586
9624
  left: 0;
9587
9625
  position: absolute;
9588
9626
  top: 0;
9627
+ box-shadow: var(--wui-elevation-01);
9589
9628
  transition:
9590
- transform var(--wui-motion-duration-03) var(--wui-motion-ease-out),
9629
+ transform var(--wui-motion-duration-02) var(--wui-motion-ease-out),
9591
9630
  width var(--wui-motion-duration-02) var(--wui-motion-ease-out);
9592
9631
  z-index: ${Z_INDEX_TO_SIT_BEHIND_SIBLINGS};
9593
9632
  `;
@@ -9695,13 +9734,16 @@ var segmentedControlItemStyles = import_styled_components64.css`
9695
9734
  color: var(--wui-color-text-secondary);
9696
9735
  cursor: pointer;
9697
9736
  display: flex;
9737
+ gap: 2px;
9698
9738
  flex-grow: 1;
9699
9739
  flex-shrink: 1;
9700
9740
  font-size: var(--wui-typography-label-3-size);
9701
9741
  font-weight: var(--wui-typography-label-3-weight);
9742
+ line-height: var(--wui-typography-label-3-line-height);
9702
9743
  justify-content: center;
9703
- padding: 6px ${({ $hasLabel }) => $hasLabel ? "8px" : "6px"};
9744
+ padding: 6px ${({ $hasLabel }) => $hasLabel ? "12px" : "6px"};
9704
9745
  user-select: none;
9746
+ transition: background-color var(--wui-motion-duration-01) var(--wui-motion-ease);
9705
9747
 
9706
9748
  /* Icon component */
9707
9749
  svg {
@@ -9725,13 +9767,8 @@ var segmentedControlItemStyles = import_styled_components64.css`
9725
9767
  &[data-state='active'] {
9726
9768
  color: var(--wui-color-text-selected);
9727
9769
  cursor: default;
9728
- }
9729
-
9730
- &:focus-visible,
9731
- &[data-state='on'],
9732
- &[data-state='active'] {
9733
9770
  svg path {
9734
- fill: var(--wui-color-focus-ring);
9771
+ fill: var(--wui-color-icon-selected);
9735
9772
  }
9736
9773
  }
9737
9774
 
@@ -10414,6 +10451,7 @@ var StyledContent3 = (0, import_styled_components71.default)(import_react_select
10414
10451
  border-radius: var(--wui-select-content-border-radius);
10415
10452
  padding: var(--wui-select-option-padding);
10416
10453
  min-width: 200px;
10454
+ z-index: var(--wui-zindex-menu);
10417
10455
  `;
10418
10456
  var Select = (0, import_react55.forwardRef)(
10419
10457
  ({