@wix/form-public 0.527.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.cjs +76 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +76 -15
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -38271,7 +38271,9 @@ var READONLY_FIELD_TYPES = {
|
|
|
38271
38271
|
// ../form-fields/dist/esm/constants/field-types.js
|
|
38272
38272
|
var FIELD_TYPES = {
|
|
38273
38273
|
...INPUT_FIELD_TYPES,
|
|
38274
|
-
...READONLY_FIELD_TYPES
|
|
38274
|
+
...READONLY_FIELD_TYPES,
|
|
38275
|
+
SUBMIT_BUTTON: "SUBMIT_BUTTON"
|
|
38276
|
+
};
|
|
38275
38277
|
|
|
38276
38278
|
// ../form-fields/dist/esm/constants/empty-values.js
|
|
38277
38279
|
var EMPTY_VALUE = null;
|
|
@@ -47244,6 +47246,52 @@ function makeInputValidation(identifier, inputOptions) {
|
|
|
47244
47246
|
};
|
|
47245
47247
|
}
|
|
47246
47248
|
|
|
47249
|
+
// ../form-fields/dist/esm/services/grid-defaults.js
|
|
47250
|
+
var GRID_DEFAULTS = {
|
|
47251
|
+
columns: 12,
|
|
47252
|
+
rowHeight: 24,
|
|
47253
|
+
margin: {
|
|
47254
|
+
vertical: 24,
|
|
47255
|
+
horizontal: 24
|
|
47256
|
+
},
|
|
47257
|
+
padding: {
|
|
47258
|
+
vertical: 0,
|
|
47259
|
+
horizontal: 0
|
|
47260
|
+
}
|
|
47261
|
+
};
|
|
47262
|
+
|
|
47263
|
+
// ../form-fields/dist/esm/services/complete-small-layout-items.js
|
|
47264
|
+
function completeSmallLayoutItems({ large, small, columns, submitFieldIds = [] }) {
|
|
47265
|
+
const placedFieldIds = new Set(small.map(({ fieldId }) => fieldId));
|
|
47266
|
+
const submitRows = small.filter(({ fieldId }) => fieldId && submitFieldIds.includes(fieldId)).map(({ row: row2 }) => row2 ?? 0);
|
|
47267
|
+
const insertRow = submitRows.length ? Math.max(...submitRows) : Math.max(0, ...small.map(({ row: row2, height }) => (row2 ?? 0) + (height ?? 1)));
|
|
47268
|
+
const unplaced = large.filter(({ fieldId }) => fieldId && !placedFieldIds.has(fieldId)).sort((one, other) => (one.row ?? 0) - (other.row ?? 0) || (one.column ?? 0) - (other.column ?? 0));
|
|
47269
|
+
if (!unplaced.length) {
|
|
47270
|
+
return small;
|
|
47271
|
+
}
|
|
47272
|
+
let row = insertRow;
|
|
47273
|
+
const appended = unplaced.map(({ fieldId, height }) => {
|
|
47274
|
+
const item = {
|
|
47275
|
+
fieldId,
|
|
47276
|
+
row,
|
|
47277
|
+
column: 0,
|
|
47278
|
+
width: columns ?? GRID_DEFAULTS.columns,
|
|
47279
|
+
height: height ?? 1
|
|
47280
|
+
};
|
|
47281
|
+
row += item.height;
|
|
47282
|
+
return item;
|
|
47283
|
+
});
|
|
47284
|
+
const insertedHeight = row - insertRow;
|
|
47285
|
+
const shifted = small.map((item) => (item.row ?? 0) >= insertRow ? {
|
|
47286
|
+
...item,
|
|
47287
|
+
row: (item.row ?? 0) + insertedHeight
|
|
47288
|
+
} : item);
|
|
47289
|
+
return [
|
|
47290
|
+
...shifted,
|
|
47291
|
+
...appended
|
|
47292
|
+
];
|
|
47293
|
+
}
|
|
47294
|
+
|
|
47247
47295
|
// ../form-fields/dist/esm/types/image.js
|
|
47248
47296
|
var ImagePosition4 = /* @__PURE__ */ (function(ImagePosition5) {
|
|
47249
47297
|
ImagePosition5["TOP"] = "top";
|
|
@@ -47284,19 +47332,19 @@ function toFieldLabelMediaSettings(view) {
|
|
|
47284
47332
|
return Object.keys(mediaSettings).length ? mediaSettings : void 0;
|
|
47285
47333
|
}
|
|
47286
47334
|
|
|
47335
|
+
// ../form-fields/dist/esm/services/submit-field-ids.js
|
|
47336
|
+
function getSubmitFieldIds(fields = []) {
|
|
47337
|
+
return fields.flatMap(({ id: id6, view }) => id6 && view?.fieldType === FIELD_TYPES.SUBMIT_BUTTON ? [
|
|
47338
|
+
id6
|
|
47339
|
+
] : []);
|
|
47340
|
+
}
|
|
47341
|
+
function getSubmitFieldIdsV2(fields = []) {
|
|
47342
|
+
return fields.flatMap(({ id: id6, identifier }) => id6 && identifier === FIELD_TYPES.SUBMIT_BUTTON ? [
|
|
47343
|
+
id6
|
|
47344
|
+
] : []);
|
|
47345
|
+
}
|
|
47346
|
+
|
|
47287
47347
|
// ../form-fields/dist/esm/services/form-view.js
|
|
47288
|
-
var GRID_DEFAULTS = {
|
|
47289
|
-
columns: 12,
|
|
47290
|
-
rowHeight: 24,
|
|
47291
|
-
margin: {
|
|
47292
|
-
vertical: 24,
|
|
47293
|
-
horizontal: 24
|
|
47294
|
-
},
|
|
47295
|
-
padding: {
|
|
47296
|
-
vertical: 0,
|
|
47297
|
-
horizontal: 0
|
|
47298
|
-
}
|
|
47299
|
-
};
|
|
47300
47348
|
function createFormView({ form, path = "", stepId, recursive = true, includeHiddenFields = false, isMobile: isMobile2 = false, breakpoint = DEFAULT_BREAKPOINT, useFieldsV2 = false, parentId = "" }) {
|
|
47301
47349
|
const step = stepId ? form.steps?.find(({ id: id6 }) => id6 === stepId) : form.steps?.[0];
|
|
47302
47350
|
const layout = step?.layout ?? {};
|
|
@@ -47308,11 +47356,24 @@ function createFormView({ form, path = "", stepId, recursive = true, includeHidd
|
|
|
47308
47356
|
} else if ("name" in form) {
|
|
47309
47357
|
nameView = form.name ?? "";
|
|
47310
47358
|
}
|
|
47311
|
-
const
|
|
47359
|
+
const smallItems = layout.small?.items ?? [];
|
|
47360
|
+
const hasSmallLayout = smallItems.length > 0;
|
|
47312
47361
|
const isSmallBreakpoint = isMobile2 && hasSmallLayout;
|
|
47362
|
+
const effectiveLayout = hasSmallLayout ? {
|
|
47363
|
+
...layout,
|
|
47364
|
+
small: {
|
|
47365
|
+
...layout.small,
|
|
47366
|
+
items: completeSmallLayoutItems({
|
|
47367
|
+
large: layout.large?.items ?? [],
|
|
47368
|
+
small: smallItems,
|
|
47369
|
+
columns: layout.large?.columns,
|
|
47370
|
+
submitFieldIds: useFieldsV2 && platformizedFields ? getSubmitFieldIdsV2(platformizedFields) : getSubmitFieldIds(fields)
|
|
47371
|
+
})
|
|
47372
|
+
}
|
|
47373
|
+
} : layout;
|
|
47313
47374
|
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) => {
|
|
47314
47375
|
const _field = useFieldsV2 && platformizedFields ? transformFieldToV1(field) : field;
|
|
47315
|
-
const fieldView = createFieldView(_field,
|
|
47376
|
+
const fieldView = createFieldView(_field, effectiveLayout, path, recursive, isMobile2, isSmallBreakpoint ? Breakpoint.SMALL : breakpoint);
|
|
47316
47377
|
if (fieldView) {
|
|
47317
47378
|
result2.push(fieldView);
|
|
47318
47379
|
}
|