@wix/form-public 0.526.0 → 0.528.0

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.js CHANGED
@@ -38261,7 +38261,9 @@ var READONLY_FIELD_TYPES = {
38261
38261
  // ../form-fields/dist/esm/constants/field-types.js
38262
38262
  var FIELD_TYPES = {
38263
38263
  ...INPUT_FIELD_TYPES,
38264
- ...READONLY_FIELD_TYPES};
38264
+ ...READONLY_FIELD_TYPES,
38265
+ SUBMIT_BUTTON: "SUBMIT_BUTTON"
38266
+ };
38265
38267
 
38266
38268
  // ../form-fields/dist/esm/constants/empty-values.js
38267
38269
  var EMPTY_VALUE = null;
@@ -47234,6 +47236,52 @@ function makeInputValidation(identifier, inputOptions) {
47234
47236
  };
47235
47237
  }
47236
47238
 
47239
+ // ../form-fields/dist/esm/services/grid-defaults.js
47240
+ var GRID_DEFAULTS = {
47241
+ columns: 12,
47242
+ rowHeight: 24,
47243
+ margin: {
47244
+ vertical: 24,
47245
+ horizontal: 24
47246
+ },
47247
+ padding: {
47248
+ vertical: 0,
47249
+ horizontal: 0
47250
+ }
47251
+ };
47252
+
47253
+ // ../form-fields/dist/esm/services/complete-small-layout-items.js
47254
+ function completeSmallLayoutItems({ large, small, columns, submitFieldIds = [] }) {
47255
+ const placedFieldIds = new Set(small.map(({ fieldId }) => fieldId));
47256
+ const submitRows = small.filter(({ fieldId }) => fieldId && submitFieldIds.includes(fieldId)).map(({ row: row2 }) => row2 ?? 0);
47257
+ const insertRow = submitRows.length ? Math.max(...submitRows) : Math.max(0, ...small.map(({ row: row2, height }) => (row2 ?? 0) + (height ?? 1)));
47258
+ const unplaced = large.filter(({ fieldId }) => fieldId && !placedFieldIds.has(fieldId)).sort((one, other) => (one.row ?? 0) - (other.row ?? 0) || (one.column ?? 0) - (other.column ?? 0));
47259
+ if (!unplaced.length) {
47260
+ return small;
47261
+ }
47262
+ let row = insertRow;
47263
+ const appended = unplaced.map(({ fieldId, height }) => {
47264
+ const item = {
47265
+ fieldId,
47266
+ row,
47267
+ column: 0,
47268
+ width: columns ?? GRID_DEFAULTS.columns,
47269
+ height: height ?? 1
47270
+ };
47271
+ row += item.height;
47272
+ return item;
47273
+ });
47274
+ const insertedHeight = row - insertRow;
47275
+ const shifted = small.map((item) => (item.row ?? 0) >= insertRow ? {
47276
+ ...item,
47277
+ row: (item.row ?? 0) + insertedHeight
47278
+ } : item);
47279
+ return [
47280
+ ...shifted,
47281
+ ...appended
47282
+ ];
47283
+ }
47284
+
47237
47285
  // ../form-fields/dist/esm/types/image.js
47238
47286
  var ImagePosition4 = /* @__PURE__ */ (function(ImagePosition5) {
47239
47287
  ImagePosition5["TOP"] = "top";
@@ -47274,19 +47322,19 @@ function toFieldLabelMediaSettings(view) {
47274
47322
  return Object.keys(mediaSettings).length ? mediaSettings : void 0;
47275
47323
  }
47276
47324
 
47325
+ // ../form-fields/dist/esm/services/submit-field-ids.js
47326
+ function getSubmitFieldIds(fields = []) {
47327
+ return fields.flatMap(({ id: id6, view }) => id6 && view?.fieldType === FIELD_TYPES.SUBMIT_BUTTON ? [
47328
+ id6
47329
+ ] : []);
47330
+ }
47331
+ function getSubmitFieldIdsV2(fields = []) {
47332
+ return fields.flatMap(({ id: id6, identifier }) => id6 && identifier === FIELD_TYPES.SUBMIT_BUTTON ? [
47333
+ id6
47334
+ ] : []);
47335
+ }
47336
+
47277
47337
  // ../form-fields/dist/esm/services/form-view.js
47278
- var GRID_DEFAULTS = {
47279
- columns: 12,
47280
- rowHeight: 24,
47281
- margin: {
47282
- vertical: 24,
47283
- horizontal: 24
47284
- },
47285
- padding: {
47286
- vertical: 0,
47287
- horizontal: 0
47288
- }
47289
- };
47290
47338
  function createFormView({ form, path = "", stepId, recursive = true, includeHiddenFields = false, isMobile: isMobile2 = false, breakpoint = DEFAULT_BREAKPOINT, useFieldsV2 = false, parentId = "" }) {
47291
47339
  const step = stepId ? form.steps?.find(({ id: id6 }) => id6 === stepId) : form.steps?.[0];
47292
47340
  const layout = step?.layout ?? {};
@@ -47298,11 +47346,24 @@ function createFormView({ form, path = "", stepId, recursive = true, includeHidd
47298
47346
  } else if ("name" in form) {
47299
47347
  nameView = form.name ?? "";
47300
47348
  }
47301
- const hasSmallLayout = layout.small?.items;
47349
+ const smallItems = layout.small?.items ?? [];
47350
+ const hasSmallLayout = smallItems.length > 0;
47302
47351
  const isSmallBreakpoint = isMobile2 && hasSmallLayout;
47352
+ const effectiveLayout = hasSmallLayout ? {
47353
+ ...layout,
47354
+ small: {
47355
+ ...layout.small,
47356
+ items: completeSmallLayoutItems({
47357
+ large: layout.large?.items ?? [],
47358
+ small: smallItems,
47359
+ columns: layout.large?.columns,
47360
+ submitFieldIds: useFieldsV2 && platformizedFields ? getSubmitFieldIdsV2(platformizedFields) : getSubmitFieldIds(fields)
47361
+ })
47362
+ }
47363
+ } : layout;
47303
47364
  const fieldViews = (useFieldsV2 && platformizedFields ? platformizedFields : fields).filter((field) => includeHiddenFields || !field.hidden).filter((field) => layout?.large?.items?.find((item) => field.id === item.fieldId)).reduce((result2, field) => {
47304
47365
  const _field = useFieldsV2 && platformizedFields ? transformFieldToV1(field) : field;
47305
- const fieldView = createFieldView(_field, layout, path, recursive, isMobile2, isSmallBreakpoint ? Breakpoint.SMALL : breakpoint);
47366
+ const fieldView = createFieldView(_field, effectiveLayout, path, recursive, isMobile2, isSmallBreakpoint ? Breakpoint.SMALL : breakpoint);
47306
47367
  if (fieldView) {
47307
47368
  result2.push(fieldView);
47308
47369
  }
@@ -52075,9 +52136,10 @@ var CheckboxContainer = ({ children, className }) => {
52075
52136
  }, /* @__PURE__ */ React173.createElement(CheckboxButton, {
52076
52137
  ref,
52077
52138
  className
52078
- }, ({ isSelected, isHovered }) => /* @__PURE__ */ React173.createElement(React173.Fragment, null, applyInternalProps(inputElement, {
52139
+ }, ({ isSelected, isHovered, isFocused }) => /* @__PURE__ */ React173.createElement(React173.Fragment, null, applyInternalProps(inputElement, {
52079
52140
  isSelected,
52080
- isHovered
52141
+ isHovered,
52142
+ isFocused
52081
52143
  }), labelElement)));
52082
52144
  };
52083
52145
  CheckboxContainer.RichTextLabel = RichTextLabel;
@@ -52265,9 +52327,10 @@ var Checkbox2 = ({ children, className, ...internal }) => {
52265
52327
  ref: checkboxRef,
52266
52328
  className,
52267
52329
  "data-hook": `checkbox-${label}`
52268
- }, ({ isSelected, isHovered }) => /* @__PURE__ */ React173.createElement(React173.Fragment, null, applyInternalProps(inputElement, {
52330
+ }, ({ isSelected, isHovered, isFocused }) => /* @__PURE__ */ React173.createElement(React173.Fragment, null, applyInternalProps(inputElement, {
52269
52331
  isSelected,
52270
- isHovered
52332
+ isHovered,
52333
+ isFocused
52271
52334
  }), applyInternalProps(labelElement, {
52272
52335
  label
52273
52336
  }))));
@@ -55944,9 +56007,10 @@ var GuestToggle = ({ children, className, ...internal }) => {
55944
56007
  onFocus
55945
56008
  }, /* @__PURE__ */ React173.createElement(CheckboxButton, {
55946
56009
  className
55947
- }, ({ isSelected, isHovered }) => /* @__PURE__ */ React173.createElement(React173.Fragment, null, applyInternalProps(inputElement, {
56010
+ }, ({ isSelected, isHovered, isFocused }) => /* @__PURE__ */ React173.createElement(React173.Fragment, null, applyInternalProps(inputElement, {
55948
56011
  isSelected,
55949
- isHovered
56012
+ isHovered,
56013
+ isFocused
55950
56014
  }), applyInternalProps(labelElement, {
55951
56015
  label
55952
56016
  }))));
@@ -56103,9 +56167,10 @@ var Option4 = ({ children, className, ...internal }) => {
56103
56167
  }, /* @__PURE__ */ React173.createElement(RadioButton, {
56104
56168
  ref: radioRef,
56105
56169
  className: radioClassName
56106
- }, ({ isSelected, isHovered }) => /* @__PURE__ */ React173.createElement(React173.Fragment, null, applyInternalProps(controlElement, {
56170
+ }, ({ isSelected, isHovered, isFocused }) => /* @__PURE__ */ React173.createElement(React173.Fragment, null, applyInternalProps(controlElement, {
56107
56171
  isSelected,
56108
- isHovered
56172
+ isHovered,
56173
+ isFocused
56109
56174
  }), applyInternalProps(labelElement, {
56110
56175
  label
56111
56176
  })))), isOther && isThisOptionSelected && otherInputElement);
@@ -56446,7 +56511,7 @@ var DropZoneSubtitle = ({ className, children }) => {
56446
56511
  limitReached
56447
56512
  }));
56448
56513
  };
56449
- var DropZoneButton = ({ className, children, "aria-roledescription": roleDescription, onHoverStart, onHoverEnd }) => {
56514
+ var DropZoneButton = ({ className, children, "aria-roledescription": roleDescription, onHoverStart, onHoverEnd, onFocusChange }) => {
56450
56515
  const { ariaDescribedBy, inputId, labelId, errorId } = useFieldAttributes();
56451
56516
  const { disabled, required, onFocus, hasError, errorMessage } = useFieldPropsV2();
56452
56517
  const { handleFileChange, accept, multiple, buttonRef, handleBlur, limitError, files } = useFileUploadContext();
@@ -56482,7 +56547,8 @@ var DropZoneButton = ({ className, children, "aria-roledescription": roleDescrip
56482
56547
  onFocus,
56483
56548
  onBlur: handleBlur,
56484
56549
  onHoverStart,
56485
- onHoverEnd
56550
+ onHoverEnd,
56551
+ onFocusChange
56486
56552
  }, children));
56487
56553
  };
56488
56554
  var DropZoneButtonText = ({ className }) => {
@@ -60062,9 +60128,10 @@ var Control7 = ({ children, className }) => {
60062
60128
  const phoneNumberElement = findChildOfType(children, PhoneInput.PhoneNumber);
60063
60129
  const hasCountryOptions2 = countries.length > 1;
60064
60130
  const isForcedOpen = useIsForcedOpenDropdown(id6) && !!popoverElement && hasCountryOptions2;
60065
- const controlClassName = typeof className === "function" ? ({ isHovered }) => className({
60131
+ const controlClassName = typeof className === "function" ? ({ isHovered, isFocusWithin }) => className({
60066
60132
  hasCountryOptions: hasCountryOptions2,
60067
- isHovered
60133
+ isHovered,
60134
+ isFocusWithin
60068
60135
  }) : className;
60069
60136
  const pickerProps = {
60070
60137
  triggerRef: controlRef,
@@ -60288,7 +60355,7 @@ var ProductOption = ({ children, className, ...internal }) => {
60288
60355
  ref: checkboxRef,
60289
60356
  className,
60290
60357
  "data-hook": "product"
60291
- }, ({ isHovered }) => /* @__PURE__ */ React173.createElement(React173.Fragment, null, imageElement ? applyInternalProps(imageElement, {
60358
+ }, ({ isHovered, isFocused }) => /* @__PURE__ */ React173.createElement(React173.Fragment, null, imageElement ? applyInternalProps(imageElement, {
60292
60359
  option: option2,
60293
60360
  imageResize
60294
60361
  }) : null, labelElement ? applyInternalProps(labelElement, {
@@ -60297,7 +60364,8 @@ var ProductOption = ({ children, className, ...internal }) => {
60297
60364
  price
60298
60365
  }) : null, applyInternalProps(inputElement, {
60299
60366
  isSelected,
60300
- isHovered
60367
+ isHovered,
60368
+ isFocused
60301
60369
  }))));
60302
60370
  };
60303
60371
  var OptionImage2 = ({ className, ...internal }) => {
@@ -60460,15 +60528,17 @@ var Rating = ({ className, children, ...internal }) => {
60460
60528
  return /* @__PURE__ */ React173.createElement(RadioField, {
60461
60529
  value
60462
60530
  }, /* @__PURE__ */ React173.createElement(RadioButton, {
60463
- className: ({ isHovered }) => typeof className === "function" ? className({
60531
+ className: ({ isHovered, isFocused }) => typeof className === "function" ? className({
60464
60532
  isSelected,
60465
- isHovered
60533
+ isHovered,
60534
+ isFocused
60466
60535
  }) : className ?? "",
60467
60536
  "data-active": isSelected || void 0,
60468
60537
  onHoverChange
60469
- }, ({ isHovered }) => /* @__PURE__ */ React173.createElement(React173.Fragment, null, typeof children === "function" ? children({
60538
+ }, ({ isHovered, isFocused }) => /* @__PURE__ */ React173.createElement(React173.Fragment, null, typeof children === "function" ? children({
60470
60539
  isSelected,
60471
- isHovered
60540
+ isHovered,
60541
+ isFocused
60472
60542
  }) : children, label ? /* @__PURE__ */ React173.createElement("span", {
60473
60543
  style: visuallyHiddenStyle
60474
60544
  }, label) : null)));
@@ -62214,7 +62284,7 @@ var UploadPreview = ({ className, imageAlt, ...internal }) => {
62214
62284
  "data-hook": "signature-image"
62215
62285
  }, value.displayName || imageAlt));
62216
62286
  };
62217
- var UploadButton = ({ children, className, onHoverStart, onHoverEnd, ...internal }) => {
62287
+ var UploadButton = ({ children, className, onHoverStart, onHoverEnd, onFocusChange, ...internal }) => {
62218
62288
  const { onSelectFiles, disabled, readOnly, onBlur, onFocus } = internal;
62219
62289
  const { inputId, ariaDescribedBy, labelId } = useFieldAttributes();
62220
62290
  const textId = useId2();
@@ -62241,7 +62311,8 @@ var UploadButton = ({ children, className, onHoverStart, onHoverEnd, ...internal
62241
62311
  "data-hook": "signature-upload",
62242
62312
  className,
62243
62313
  onHoverStart,
62244
- onHoverEnd
62314
+ onHoverEnd,
62315
+ onFocusChange
62245
62316
  }, content));
62246
62317
  };
62247
62318
  var UploadButtonText = ({ children, className, ...internal }) => {