@wistia/ui 0.18.18-beta.718b4f5b.dc3bc8e → 0.18.18-beta.97557728.199753

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.18.18-beta.718b4f5b.dc3bc8e
3
+ * @license @wistia/ui v0.18.18-beta.97557728.199753
4
4
  *
5
5
  * Copyright (c) 2024-2025, Wistia, Inc. and its affiliates.
6
6
  *
@@ -15240,8 +15240,20 @@ var import_react73 = require("react");
15240
15240
  var import_styled_components87 = require("styled-components");
15241
15241
  var import_type_guards49 = require("@wistia/type-guards");
15242
15242
  var import_jsx_runtime293 = require("react/jsx-runtime");
15243
+ var inlineErrorStyles = import_styled_components87.css`
15244
+ grid-template-rows: 1fr auto;
15245
+ grid-template-areas: 'label-description input' '. error';
15246
+ `;
15247
+ var inlineBaseGridAreaStyles = import_styled_components87.css`
15248
+ grid-template-rows: 1fr;
15249
+ grid-template-areas: 'label-description input';
15250
+ `;
15251
+ var blockGridErrorStyles = import_styled_components87.css`
15252
+ grid-template-rows: auto 1fr auto;
15253
+ grid-template-areas: 'label-description' 'input' 'error';
15254
+ `;
15243
15255
  var StyledFormField = import_styled_components87.styled.div`
15244
- --form-field-spacing: var(--wui-space-01);
15256
+ --form-field-spacing: var(--wui-space-02);
15245
15257
  --form-field-spacing-inline: var(--wui-space-02);
15246
15258
  --form-field-error-color: var(--wui-color-text-secondary-error);
15247
15259
 
@@ -15255,21 +15267,28 @@ var StyledFormField = import_styled_components87.styled.div`
15255
15267
  &[data-label-position='inline-compact'] {
15256
15268
  gap: var(--form-field-spacing-inline);
15257
15269
  grid-template-columns: auto 1fr;
15258
- grid-template-rows: 1fr auto;
15270
+ ${inlineBaseGridAreaStyles}
15271
+ ${({ $hasError }) => $hasError && inlineErrorStyles}
15259
15272
  }
15260
15273
 
15261
15274
  &[data-label-position='inline'] {
15262
15275
  gap: var(--form-field-spacing-inline);
15263
15276
  grid-template-columns: minmax(auto, 1fr) 1fr;
15264
- grid-template-rows: 1fr auto;
15277
+ ${inlineBaseGridAreaStyles}
15278
+ ${({ $hasError }) => $hasError && inlineErrorStyles}
15265
15279
  }
15266
15280
 
15267
15281
  &[data-label-position='block'] {
15268
15282
  gap: var(--form-field-spacing);
15269
15283
  grid-template-columns: 1fr;
15270
- grid-template-rows: 1fr;
15284
+ grid-template-rows: auto 1fr;
15285
+ grid-template-areas: 'label-description' 'input';
15286
+ ${({ $hasError }) => $hasError && blockGridErrorStyles}
15271
15287
  }
15272
15288
  `;
15289
+ var ErrorText = (0, import_styled_components87.styled)(Text)`
15290
+ grid-area: error;
15291
+ `;
15273
15292
  var StyledErrorList = import_styled_components87.styled.ul`
15274
15293
  margin: 0;
15275
15294
  padding: 0;
@@ -15277,13 +15296,14 @@ var StyledErrorList = import_styled_components87.styled.ul`
15277
15296
  display: flex;
15278
15297
  flex-direction: column;
15279
15298
  gap: var(--wui-space-01);
15299
+ grid-area: error;
15280
15300
  `;
15281
15301
  var ErrorMessages = ({ errors, id }) => {
15282
15302
  const isErrorArray = (0, import_type_guards49.isArray)(errors);
15283
15303
  const isMultipleErrors = isErrorArray && errors.length > 1;
15284
15304
  if (!isErrorArray) {
15285
15305
  return /* @__PURE__ */ (0, import_jsx_runtime293.jsx)(
15286
- Text,
15306
+ ErrorText,
15287
15307
  {
15288
15308
  colorScheme: "error",
15289
15309
  id,
@@ -15296,7 +15316,7 @@ var ErrorMessages = ({ errors, id }) => {
15296
15316
  }
15297
15317
  if (!isMultipleErrors) {
15298
15318
  return /* @__PURE__ */ (0, import_jsx_runtime293.jsx)(
15299
- Text,
15319
+ ErrorText,
15300
15320
  {
15301
15321
  colorScheme: "error",
15302
15322
  id,
@@ -15341,12 +15361,16 @@ var FormField = ({
15341
15361
  const descriptionId = `${computedId}-description`;
15342
15362
  const errorId = `${computedId}-error`;
15343
15363
  const ariaDescribedby = [descriptionId, errorId].filter(Boolean).join(" ") || void 0;
15364
+ const hasDescription = (0, import_type_guards49.isNotNil)(description);
15365
+ const hasError = (0, import_type_guards49.isNotNil)(computedError);
15366
+ const shouldRenderLabelDescriptionWrapper = !isIntegratedLabel || hasDescription;
15344
15367
  let childProps = {
15345
15368
  name,
15346
15369
  id: computedId,
15347
15370
  label: isIntegratedLabel ? label : void 0,
15348
15371
  "aria-describedby": ariaDescribedby,
15349
- "aria-invalid": (0, import_type_guards49.isNotNil)(computedError),
15372
+ "aria-invalid": hasError,
15373
+ style: { gridArea: "input" },
15350
15374
  ...props
15351
15375
  };
15352
15376
  if ((0, import_type_guards49.isUndefined)(value) && (0, import_type_guards49.isNotUndefined)(defaultValue)) {
@@ -15376,28 +15400,38 @@ var FormField = ({
15376
15400
  StyledFormField,
15377
15401
  {
15378
15402
  ...props,
15403
+ $hasError: hasError,
15379
15404
  "data-label-position": labelPosition ?? formState.labelPosition,
15380
15405
  children: [
15381
- !isIntegratedLabel && /* @__PURE__ */ (0, import_jsx_runtime293.jsx)(
15382
- Label,
15406
+ shouldRenderLabelDescriptionWrapper ? /* @__PURE__ */ (0, import_jsx_runtime293.jsxs)(
15407
+ Stack,
15383
15408
  {
15384
- htmlFor: computedId,
15385
- required,
15386
- children: label
15409
+ direction: "vertical",
15410
+ gap: "space-01",
15411
+ style: {
15412
+ gridArea: "label-description"
15413
+ },
15414
+ children: [
15415
+ !isIntegratedLabel && /* @__PURE__ */ (0, import_jsx_runtime293.jsx)(
15416
+ Label,
15417
+ {
15418
+ htmlFor: computedId,
15419
+ required,
15420
+ children: label
15421
+ }
15422
+ ),
15423
+ hasDescription ? /* @__PURE__ */ (0, import_jsx_runtime293.jsx)(FormControlLabelDescription, { id: descriptionId, children: description }) : null
15424
+ ]
15387
15425
  }
15388
- ),
15389
- (0, import_type_guards49.isNotNil)(description) ? /* @__PURE__ */ (0, import_jsx_runtime293.jsx)(FormControlLabelDescription, { id: descriptionId, children: description }) : null,
15426
+ ) : null,
15390
15427
  (0, import_react73.cloneElement)(children, childProps),
15391
- (0, import_type_guards49.isNotNil)(computedError) ? /* @__PURE__ */ (0, import_jsx_runtime293.jsxs)(import_jsx_runtime293.Fragment, { children: [
15392
- /* @__PURE__ */ (0, import_jsx_runtime293.jsx)("div", {}),
15393
- /* @__PURE__ */ (0, import_jsx_runtime293.jsx)(
15394
- ErrorMessages,
15395
- {
15396
- errors: computedError,
15397
- id: errorId
15398
- }
15399
- )
15400
- ] }) : null
15428
+ hasError ? /* @__PURE__ */ (0, import_jsx_runtime293.jsx)(
15429
+ ErrorMessages,
15430
+ {
15431
+ errors: computedError,
15432
+ id: errorId
15433
+ }
15434
+ ) : null
15401
15435
  ]
15402
15436
  }
15403
15437
  );