@wistia/ui 0.18.10-beta.5c9d9d20.4e8e531 → 0.18.10-beta.85f50c74.84b332c

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.10-beta.5c9d9d20.4e8e531
3
+ * @license @wistia/ui v0.18.10-beta.85f50c74.84b332c
4
4
  *
5
5
  * Copyright (c) 2024-2025, Wistia, Inc. and its affiliates.
6
6
  *
@@ -15146,8 +15146,20 @@ var import_react73 = require("react");
15146
15146
  var import_styled_components86 = require("styled-components");
15147
15147
  var import_type_guards49 = require("@wistia/type-guards");
15148
15148
  var import_jsx_runtime288 = require("react/jsx-runtime");
15149
+ var inlineErrorStyles = import_styled_components86.css`
15150
+ grid-template-rows: 1fr auto;
15151
+ grid-template-areas: 'label-description input' '. error';
15152
+ `;
15153
+ var inlineBaseGridAreaStyles = import_styled_components86.css`
15154
+ grid-template-rows: 1fr;
15155
+ grid-template-areas: 'label-description input';
15156
+ `;
15157
+ var blockGridErrorStyles = import_styled_components86.css`
15158
+ grid-template-rows: auto 1fr auto;
15159
+ grid-template-areas: 'label-description' 'input' 'error';
15160
+ `;
15149
15161
  var StyledFormField = import_styled_components86.styled.div`
15150
- --form-field-spacing: var(--wui-space-01);
15162
+ --form-field-spacing: var(--wui-space-02);
15151
15163
  --form-field-spacing-inline: var(--wui-space-02);
15152
15164
  --form-field-error-color: var(--wui-color-text-secondary-error);
15153
15165
 
@@ -15161,21 +15173,28 @@ var StyledFormField = import_styled_components86.styled.div`
15161
15173
  &[data-label-position='inline-compact'] {
15162
15174
  gap: var(--form-field-spacing-inline);
15163
15175
  grid-template-columns: auto 1fr;
15164
- grid-template-rows: 1fr auto;
15176
+ ${inlineBaseGridAreaStyles}
15177
+ ${({ $hasError }) => $hasError && inlineErrorStyles}
15165
15178
  }
15166
15179
 
15167
15180
  &[data-label-position='inline'] {
15168
15181
  gap: var(--form-field-spacing-inline);
15169
15182
  grid-template-columns: minmax(auto, 1fr) 1fr;
15170
- grid-template-rows: 1fr auto;
15183
+ ${inlineBaseGridAreaStyles}
15184
+ ${({ $hasError }) => $hasError && inlineErrorStyles}
15171
15185
  }
15172
15186
 
15173
15187
  &[data-label-position='block'] {
15174
15188
  gap: var(--form-field-spacing);
15175
15189
  grid-template-columns: 1fr;
15176
- grid-template-rows: 1fr;
15190
+ grid-template-rows: auto 1fr;
15191
+ grid-template-areas: 'label-description' 'input';
15192
+ ${({ $hasError }) => $hasError && blockGridErrorStyles}
15177
15193
  }
15178
15194
  `;
15195
+ var ErrorText = (0, import_styled_components86.styled)(Text)`
15196
+ grid-area: error;
15197
+ `;
15179
15198
  var StyledErrorList = import_styled_components86.styled.ul`
15180
15199
  margin: 0;
15181
15200
  padding: 0;
@@ -15183,17 +15202,19 @@ var StyledErrorList = import_styled_components86.styled.ul`
15183
15202
  display: flex;
15184
15203
  flex-direction: column;
15185
15204
  gap: var(--wui-space-01);
15205
+ grid-area: error;
15186
15206
  `;
15187
15207
  var ErrorMessages = ({ errors, id }) => {
15188
15208
  const isErrorArray = (0, import_type_guards49.isArray)(errors);
15189
15209
  const isMultipleErrors = isErrorArray && errors.length > 1;
15190
15210
  if (!isErrorArray) {
15191
15211
  return /* @__PURE__ */ (0, import_jsx_runtime288.jsx)(
15192
- Text,
15212
+ ErrorText,
15193
15213
  {
15194
15214
  colorScheme: "error",
15195
15215
  id,
15196
15216
  prominence: "secondary",
15217
+ style: { gridArea: "error" },
15197
15218
  variant: "label4",
15198
15219
  children: errors
15199
15220
  },
@@ -15202,11 +15223,12 @@ var ErrorMessages = ({ errors, id }) => {
15202
15223
  }
15203
15224
  if (!isMultipleErrors) {
15204
15225
  return /* @__PURE__ */ (0, import_jsx_runtime288.jsx)(
15205
- Text,
15226
+ ErrorText,
15206
15227
  {
15207
15228
  colorScheme: "error",
15208
15229
  id,
15209
15230
  prominence: "secondary",
15231
+ style: { gridArea: "error" },
15210
15232
  variant: "label4",
15211
15233
  children: errors[0]
15212
15234
  },
@@ -15247,12 +15269,16 @@ var FormField = ({
15247
15269
  const descriptionId = `${computedId}-description`;
15248
15270
  const errorId = `${computedId}-error`;
15249
15271
  const ariaDescribedby = [descriptionId, errorId].filter(Boolean).join(" ") || void 0;
15272
+ const hasDescription = (0, import_type_guards49.isNotNil)(description);
15273
+ const hasError = (0, import_type_guards49.isNotNil)(computedError);
15274
+ const shouldRenderLabelDescriptionWrapper = !isIntegratedLabel || hasDescription;
15250
15275
  let childProps = {
15251
15276
  name,
15252
15277
  id: computedId,
15253
15278
  label: isIntegratedLabel ? label : void 0,
15254
15279
  "aria-describedby": ariaDescribedby,
15255
- "aria-invalid": (0, import_type_guards49.isNotNil)(computedError),
15280
+ "aria-invalid": hasError,
15281
+ style: { gridArea: "input" },
15256
15282
  ...props
15257
15283
  };
15258
15284
  if ((0, import_type_guards49.isUndefined)(value) && (0, import_type_guards49.isNotUndefined)(defaultValue)) {
@@ -15282,28 +15308,38 @@ var FormField = ({
15282
15308
  StyledFormField,
15283
15309
  {
15284
15310
  ...props,
15311
+ $hasError: hasError,
15285
15312
  "data-label-position": labelPosition ?? formState.labelPosition,
15286
15313
  children: [
15287
- !isIntegratedLabel && /* @__PURE__ */ (0, import_jsx_runtime288.jsx)(
15288
- Label,
15314
+ shouldRenderLabelDescriptionWrapper ? /* @__PURE__ */ (0, import_jsx_runtime288.jsxs)(
15315
+ Stack,
15289
15316
  {
15290
- htmlFor: computedId,
15291
- required,
15292
- children: label
15317
+ direction: "vertical",
15318
+ gap: "space-01",
15319
+ style: {
15320
+ gridArea: "label-description"
15321
+ },
15322
+ children: [
15323
+ !isIntegratedLabel && /* @__PURE__ */ (0, import_jsx_runtime288.jsx)(
15324
+ Label,
15325
+ {
15326
+ htmlFor: computedId,
15327
+ required,
15328
+ children: label
15329
+ }
15330
+ ),
15331
+ hasDescription ? /* @__PURE__ */ (0, import_jsx_runtime288.jsx)(FormControlLabelDescription, { id: descriptionId, children: description }) : null
15332
+ ]
15293
15333
  }
15294
- ),
15295
- (0, import_type_guards49.isNotNil)(description) ? /* @__PURE__ */ (0, import_jsx_runtime288.jsx)(FormControlLabelDescription, { id: descriptionId, children: description }) : null,
15334
+ ) : null,
15296
15335
  (0, import_react73.cloneElement)(children, childProps),
15297
- (0, import_type_guards49.isNotNil)(computedError) ? /* @__PURE__ */ (0, import_jsx_runtime288.jsxs)(import_jsx_runtime288.Fragment, { children: [
15298
- /* @__PURE__ */ (0, import_jsx_runtime288.jsx)("div", {}),
15299
- /* @__PURE__ */ (0, import_jsx_runtime288.jsx)(
15300
- ErrorMessages,
15301
- {
15302
- errors: computedError,
15303
- id: errorId
15304
- }
15305
- )
15306
- ] }) : null
15336
+ hasError ? /* @__PURE__ */ (0, import_jsx_runtime288.jsx)(
15337
+ ErrorMessages,
15338
+ {
15339
+ errors: computedError,
15340
+ id: errorId
15341
+ }
15342
+ ) : null
15307
15343
  ]
15308
15344
  }
15309
15345
  );