@wix/form-public 0.516.0 → 0.517.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 +266 -27
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +30 -0
- package/dist/index.css.map +1 -1
- package/dist/index.js +266 -27
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -16241,7 +16241,7 @@ var require_classnames = __commonJS({
|
|
|
16241
16241
|
"../../node_modules/classnames/index.js"(exports, module) {
|
|
16242
16242
|
(function() {
|
|
16243
16243
|
var hasOwn2 = {}.hasOwnProperty;
|
|
16244
|
-
function
|
|
16244
|
+
function classNames17() {
|
|
16245
16245
|
var classes = "";
|
|
16246
16246
|
for (var i = 0; i < arguments.length; i++) {
|
|
16247
16247
|
var arg = arguments[i];
|
|
@@ -16259,7 +16259,7 @@ var require_classnames = __commonJS({
|
|
|
16259
16259
|
return "";
|
|
16260
16260
|
}
|
|
16261
16261
|
if (Array.isArray(arg)) {
|
|
16262
|
-
return
|
|
16262
|
+
return classNames17.apply(null, arg);
|
|
16263
16263
|
}
|
|
16264
16264
|
if (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes("[native code]")) {
|
|
16265
16265
|
return arg.toString();
|
|
@@ -16282,14 +16282,14 @@ var require_classnames = __commonJS({
|
|
|
16282
16282
|
return value + newClass;
|
|
16283
16283
|
}
|
|
16284
16284
|
if (typeof module !== "undefined" && module.exports) {
|
|
16285
|
-
|
|
16286
|
-
module.exports =
|
|
16285
|
+
classNames17.default = classNames17;
|
|
16286
|
+
module.exports = classNames17;
|
|
16287
16287
|
} else if (typeof define === "function" && typeof define.amd === "object" && define.amd) {
|
|
16288
16288
|
define("classnames", [], function() {
|
|
16289
|
-
return
|
|
16289
|
+
return classNames17;
|
|
16290
16290
|
});
|
|
16291
16291
|
} else {
|
|
16292
|
-
window.classNames =
|
|
16292
|
+
window.classNames = classNames17;
|
|
16293
16293
|
}
|
|
16294
16294
|
})();
|
|
16295
16295
|
}
|
|
@@ -43172,6 +43172,203 @@ function useFormView() {
|
|
|
43172
43172
|
return context;
|
|
43173
43173
|
}
|
|
43174
43174
|
|
|
43175
|
+
// ../form-fields/dist/esm/field-layout/default-field-layout.js
|
|
43176
|
+
var import_classnames21 = __toESM(require_classnames());
|
|
43177
|
+
|
|
43178
|
+
// ../form-fields/dist/esm/ui/form/components/grid/responsive-grid.module.scss
|
|
43179
|
+
var responsive_grid_module_default = {};
|
|
43180
|
+
|
|
43181
|
+
// ../form-fields/dist/esm/utils/responsive-grid.js
|
|
43182
|
+
function placeResponsiveFields(fields, columns) {
|
|
43183
|
+
const groups = groupByDesktopRow(fields);
|
|
43184
|
+
const hasSmallLayout = fields.some((field) => field.layoutByBreakpoint?.small);
|
|
43185
|
+
const placement = {
|
|
43186
|
+
fields: /* @__PURE__ */ new Map(),
|
|
43187
|
+
rowOrder: /* @__PURE__ */ new Map()
|
|
43188
|
+
};
|
|
43189
|
+
if (!hasSmallLayout) {
|
|
43190
|
+
groups.forEach((group, index2) => {
|
|
43191
|
+
stackGroup(group, columns, placement);
|
|
43192
|
+
placement.rowOrder.set(group.row, index2);
|
|
43193
|
+
});
|
|
43194
|
+
return placement;
|
|
43195
|
+
}
|
|
43196
|
+
const smallLayoutOf = (field) => field.layoutByBreakpoint?.small ?? field.layout;
|
|
43197
|
+
const ranks = denseRanks(fields.map((field) => smallLayoutOf(field).row));
|
|
43198
|
+
const ranges = groups.map((group) => {
|
|
43199
|
+
const groupRanks = group.fields.map((field) => ranks.get(smallLayoutOf(field).row));
|
|
43200
|
+
return {
|
|
43201
|
+
min: Math.min(...groupRanks),
|
|
43202
|
+
max: Math.max(...groupRanks)
|
|
43203
|
+
};
|
|
43204
|
+
});
|
|
43205
|
+
const clusters = clusterOverlappingRanges(ranges);
|
|
43206
|
+
clusters.forEach((cluster) => {
|
|
43207
|
+
if (cluster.length > 1) {
|
|
43208
|
+
cluster.forEach((index3) => stackGroup(groups[index3], columns, placement));
|
|
43209
|
+
return;
|
|
43210
|
+
}
|
|
43211
|
+
const [index2] = cluster;
|
|
43212
|
+
groups[index2].fields.forEach((field) => {
|
|
43213
|
+
const small = smallLayoutOf(field);
|
|
43214
|
+
placement.fields.set(field.id, {
|
|
43215
|
+
large: toLargePlacement(field.layout),
|
|
43216
|
+
small: {
|
|
43217
|
+
...clampColumns(small, columns),
|
|
43218
|
+
subRow: ranks.get(small.row) - ranges[index2].min
|
|
43219
|
+
}
|
|
43220
|
+
});
|
|
43221
|
+
});
|
|
43222
|
+
});
|
|
43223
|
+
clusters.flatMap((cluster) => [
|
|
43224
|
+
...cluster
|
|
43225
|
+
].sort((one, other) => one - other)).forEach((index2, order) => placement.rowOrder.set(groups[index2].row, order));
|
|
43226
|
+
return placement;
|
|
43227
|
+
}
|
|
43228
|
+
function clusterOverlappingRanges(ranges) {
|
|
43229
|
+
const byMin = ranges.map((range3, index2) => ({
|
|
43230
|
+
...range3,
|
|
43231
|
+
index: index2
|
|
43232
|
+
})).sort((one, other) => one.min - other.min || one.index - other.index);
|
|
43233
|
+
const clusters = [];
|
|
43234
|
+
byMin.forEach(({ min: min4, max: max4, index: index2 }) => {
|
|
43235
|
+
const last6 = clusters.at(-1);
|
|
43236
|
+
if (last6 && min4 <= last6.max) {
|
|
43237
|
+
last6.indices.push(index2);
|
|
43238
|
+
last6.max = Math.max(last6.max, max4);
|
|
43239
|
+
} else {
|
|
43240
|
+
clusters.push({
|
|
43241
|
+
max: max4,
|
|
43242
|
+
indices: [
|
|
43243
|
+
index2
|
|
43244
|
+
]
|
|
43245
|
+
});
|
|
43246
|
+
}
|
|
43247
|
+
});
|
|
43248
|
+
return clusters.map(({ indices }) => indices);
|
|
43249
|
+
}
|
|
43250
|
+
function toResponsiveGridVariables({ large, small }) {
|
|
43251
|
+
const columnVariables = {
|
|
43252
|
+
"--form-col-lg": toColumn(large),
|
|
43253
|
+
"--form-col-sm": toColumn(small)
|
|
43254
|
+
};
|
|
43255
|
+
const offset = {
|
|
43256
|
+
"--form-row-offset-sm": small.subRow > 0 ? "1" : "0"
|
|
43257
|
+
};
|
|
43258
|
+
return {
|
|
43259
|
+
label: {
|
|
43260
|
+
...columnVariables,
|
|
43261
|
+
...offset,
|
|
43262
|
+
"--form-row-lg": toRow(large, 0, 1),
|
|
43263
|
+
"--form-row-sm": toRow(small, 0, 1)
|
|
43264
|
+
},
|
|
43265
|
+
input: {
|
|
43266
|
+
...columnVariables,
|
|
43267
|
+
"--form-row-offset-sm": "0",
|
|
43268
|
+
"--form-row-lg": toRow(large, 1, 1),
|
|
43269
|
+
"--form-row-sm": toRow(small, 1, 1)
|
|
43270
|
+
},
|
|
43271
|
+
container: {
|
|
43272
|
+
...columnVariables,
|
|
43273
|
+
...offset,
|
|
43274
|
+
"--form-row-lg": toRow(large, 0, 2),
|
|
43275
|
+
"--form-row-sm": toRow(small, 0, 2)
|
|
43276
|
+
}
|
|
43277
|
+
};
|
|
43278
|
+
}
|
|
43279
|
+
var responsiveGridCache = /* @__PURE__ */ new WeakMap();
|
|
43280
|
+
function getResponsiveGrid(form) {
|
|
43281
|
+
const cached = responsiveGridCache.get(form);
|
|
43282
|
+
if (cached) {
|
|
43283
|
+
return cached;
|
|
43284
|
+
}
|
|
43285
|
+
const placement = placeResponsiveFields(form.fields, form.grid.columns);
|
|
43286
|
+
const grid = {
|
|
43287
|
+
fields: new Map([
|
|
43288
|
+
...placement.fields
|
|
43289
|
+
].map(([fieldId, fieldPlacement]) => [
|
|
43290
|
+
fieldId,
|
|
43291
|
+
toResponsiveGridVariables(fieldPlacement)
|
|
43292
|
+
])),
|
|
43293
|
+
rows: new Map([
|
|
43294
|
+
...placement.rowOrder
|
|
43295
|
+
].map(([row, order]) => [
|
|
43296
|
+
row,
|
|
43297
|
+
{
|
|
43298
|
+
"--form-row-order-sm": String(order)
|
|
43299
|
+
}
|
|
43300
|
+
]))
|
|
43301
|
+
};
|
|
43302
|
+
responsiveGridCache.set(form, grid);
|
|
43303
|
+
return grid;
|
|
43304
|
+
}
|
|
43305
|
+
function groupByDesktopRow(fields) {
|
|
43306
|
+
const groups = /* @__PURE__ */ new Map();
|
|
43307
|
+
fields.forEach((field) => {
|
|
43308
|
+
const group = groups.get(field.layout.row);
|
|
43309
|
+
if (group) {
|
|
43310
|
+
group.push(field);
|
|
43311
|
+
} else {
|
|
43312
|
+
groups.set(field.layout.row, [
|
|
43313
|
+
field
|
|
43314
|
+
]);
|
|
43315
|
+
}
|
|
43316
|
+
});
|
|
43317
|
+
return [
|
|
43318
|
+
...groups
|
|
43319
|
+
].sort(([one], [other]) => one - other).map(([row, groupFields]) => ({
|
|
43320
|
+
row,
|
|
43321
|
+
fields: groupFields
|
|
43322
|
+
}));
|
|
43323
|
+
}
|
|
43324
|
+
function stackGroup(group, columns, placement) {
|
|
43325
|
+
group.fields.forEach((field, subRow) => {
|
|
43326
|
+
placement.fields.set(field.id, {
|
|
43327
|
+
large: toLargePlacement(field.layout),
|
|
43328
|
+
small: {
|
|
43329
|
+
column: 0,
|
|
43330
|
+
width: columns,
|
|
43331
|
+
subRow
|
|
43332
|
+
}
|
|
43333
|
+
});
|
|
43334
|
+
});
|
|
43335
|
+
}
|
|
43336
|
+
function denseRanks(rows) {
|
|
43337
|
+
return new Map([
|
|
43338
|
+
...new Set(rows)
|
|
43339
|
+
].sort((one, other) => one - other).map((row, rank) => [
|
|
43340
|
+
row,
|
|
43341
|
+
rank
|
|
43342
|
+
]));
|
|
43343
|
+
}
|
|
43344
|
+
function toLargePlacement({ column, width }) {
|
|
43345
|
+
return {
|
|
43346
|
+
column,
|
|
43347
|
+
width,
|
|
43348
|
+
subRow: 0
|
|
43349
|
+
};
|
|
43350
|
+
}
|
|
43351
|
+
function clampColumns({ column, width }, columns) {
|
|
43352
|
+
const clampedColumn = Math.min(Math.max(column, 0), columns - 1);
|
|
43353
|
+
return {
|
|
43354
|
+
column: clampedColumn,
|
|
43355
|
+
width: Math.min(Math.max(width, 1), columns - clampedColumn)
|
|
43356
|
+
};
|
|
43357
|
+
}
|
|
43358
|
+
function toColumn({ column, width }) {
|
|
43359
|
+
return `${column + 1} / span ${width}`;
|
|
43360
|
+
}
|
|
43361
|
+
function toRow({ subRow }, track, span) {
|
|
43362
|
+
return `${subRow * 2 + track + 1} / span ${span}`;
|
|
43363
|
+
}
|
|
43364
|
+
|
|
43365
|
+
// ../form-fields/dist/esm/ui/form/components/grid/use-responsive-grid.js
|
|
43366
|
+
function useResponsiveGrid() {
|
|
43367
|
+
const { cssMobileLayout, isMobile: isMobile2 } = useConfig();
|
|
43368
|
+
const form = React172.useContext(FormViewContext);
|
|
43369
|
+
return cssMobileLayout && !isMobile2 && form ? getResponsiveGrid(form) : void 0;
|
|
43370
|
+
}
|
|
43371
|
+
|
|
43175
43372
|
// ../form-fields/dist/esm/ui/form/types/form-view.js
|
|
43176
43373
|
function isInputField2(field) {
|
|
43177
43374
|
return Boolean(field.target);
|
|
@@ -43206,6 +43403,7 @@ function calculateGridStyles(options) {
|
|
|
43206
43403
|
// ../form-fields/dist/esm/field-layout/default-field-layout.js
|
|
43207
43404
|
var DefaultFieldLayout = ({ fieldId, ...rest }) => {
|
|
43208
43405
|
const fieldView = useFieldView(fieldId);
|
|
43406
|
+
const responsiveGrid = useResponsiveGrid();
|
|
43209
43407
|
if (!fieldView) {
|
|
43210
43408
|
return null;
|
|
43211
43409
|
}
|
|
@@ -43215,30 +43413,58 @@ var DefaultFieldLayout = ({ fieldId, ...rest }) => {
|
|
|
43215
43413
|
"data-hook": dataHook,
|
|
43216
43414
|
"data-field-type": fieldType
|
|
43217
43415
|
};
|
|
43218
|
-
const
|
|
43219
|
-
layout
|
|
43220
|
-
});
|
|
43416
|
+
const cellProps = getCellProps(layout, responsiveGrid?.fields.get(fieldId));
|
|
43221
43417
|
if ("children" in rest) {
|
|
43222
43418
|
return /* @__PURE__ */ React172__default.default.createElement("div", {
|
|
43223
|
-
|
|
43419
|
+
...cellProps.container,
|
|
43224
43420
|
...dataAttributes
|
|
43225
43421
|
}, rest.children);
|
|
43226
43422
|
}
|
|
43227
43423
|
const { renderLabel, renderInput, renderDescription } = rest;
|
|
43228
|
-
return /* @__PURE__ */ React172__default.default.createElement(React172__default.default.Fragment, null, /* @__PURE__ */ React172__default.default.createElement("div", {
|
|
43229
|
-
|
|
43230
|
-
}, renderLabel()), /* @__PURE__ */ React172__default.default.createElement("div", {
|
|
43231
|
-
style: gridStyles.input,
|
|
43424
|
+
return /* @__PURE__ */ React172__default.default.createElement(React172__default.default.Fragment, null, /* @__PURE__ */ React172__default.default.createElement("div", cellProps.label, renderLabel()), /* @__PURE__ */ React172__default.default.createElement("div", {
|
|
43425
|
+
...cellProps.input,
|
|
43232
43426
|
...dataAttributes
|
|
43233
43427
|
}, renderInput(), renderDescription()));
|
|
43234
43428
|
};
|
|
43429
|
+
function getCellProps(layout, variables) {
|
|
43430
|
+
if (!variables) {
|
|
43431
|
+
const { label, input, container } = calculateGridStyles({
|
|
43432
|
+
layout
|
|
43433
|
+
});
|
|
43434
|
+
return {
|
|
43435
|
+
label: {
|
|
43436
|
+
style: label
|
|
43437
|
+
},
|
|
43438
|
+
input: {
|
|
43439
|
+
style: input
|
|
43440
|
+
},
|
|
43441
|
+
container: {
|
|
43442
|
+
style: container
|
|
43443
|
+
}
|
|
43444
|
+
};
|
|
43445
|
+
}
|
|
43446
|
+
return {
|
|
43447
|
+
label: {
|
|
43448
|
+
style: variables.label,
|
|
43449
|
+
className: (0, import_classnames21.default)(responsive_grid_module_default.cell, responsive_grid_module_default.label)
|
|
43450
|
+
},
|
|
43451
|
+
input: {
|
|
43452
|
+
style: variables.input,
|
|
43453
|
+
className: responsive_grid_module_default.cell
|
|
43454
|
+
},
|
|
43455
|
+
container: {
|
|
43456
|
+
style: variables.container,
|
|
43457
|
+
className: responsive_grid_module_default.cell
|
|
43458
|
+
}
|
|
43459
|
+
};
|
|
43460
|
+
}
|
|
43235
43461
|
|
|
43236
43462
|
// ../form-fields/dist/esm/ui/form/components/grid/grid.js
|
|
43237
|
-
var
|
|
43463
|
+
var import_classnames22 = __toESM(require_classnames());
|
|
43238
43464
|
|
|
43239
43465
|
// ../form-fields/dist/esm/animations/grid-animations.module.scss
|
|
43240
43466
|
var grid_animations_module_default = {};
|
|
43241
|
-
var Focusable = ({ children, fieldId }) => {
|
|
43467
|
+
var Focusable = ({ children, fieldId, className, style }) => {
|
|
43242
43468
|
const viewRef = React172.useRef(null);
|
|
43243
43469
|
const { scrollTo } = useScroll();
|
|
43244
43470
|
const { focusedFieldId } = useFocusedField();
|
|
@@ -43252,17 +43478,21 @@ var Focusable = ({ children, fieldId }) => {
|
|
|
43252
43478
|
focusedFieldId
|
|
43253
43479
|
]);
|
|
43254
43480
|
return /* @__PURE__ */ React172__default.default.createElement("div", {
|
|
43255
|
-
ref: viewRef
|
|
43481
|
+
ref: viewRef,
|
|
43482
|
+
className,
|
|
43483
|
+
style
|
|
43256
43484
|
}, children);
|
|
43257
43485
|
};
|
|
43258
43486
|
|
|
43259
43487
|
// ../form-fields/dist/esm/ui/form/components/grid/grid-options.js
|
|
43260
|
-
var getGridStyle = ({ layout }) => {
|
|
43488
|
+
var getGridStyle = ({ layout, responsive = false }) => {
|
|
43261
43489
|
return {
|
|
43262
43490
|
display: "grid",
|
|
43263
43491
|
width: "100%",
|
|
43264
43492
|
gridTemplateColumns: `repeat(${layout.columns}, 1fr)`,
|
|
43265
|
-
|
|
43493
|
+
...responsive ? {} : {
|
|
43494
|
+
gridAutoRows: "minmax(min-content, max-content) 1fr"
|
|
43495
|
+
}
|
|
43266
43496
|
};
|
|
43267
43497
|
};
|
|
43268
43498
|
|
|
@@ -43272,6 +43502,7 @@ var grid_module_default = {};
|
|
|
43272
43502
|
// ../form-fields/dist/esm/ui/form/components/grid/grid.js
|
|
43273
43503
|
var Grid = ({ items, layout, isRTL }) => {
|
|
43274
43504
|
const { isMobile: isMobile2, enableAnimations } = useConfig();
|
|
43505
|
+
const responsiveGrid = useResponsiveGrid();
|
|
43275
43506
|
const reactElementsByRow = getReactElementsByRow(items);
|
|
43276
43507
|
return /* @__PURE__ */ React172__default.default.createElement("div", {
|
|
43277
43508
|
className: grid_module_default.container,
|
|
@@ -43279,16 +43510,21 @@ var Grid = ({ items, layout, isRTL }) => {
|
|
|
43279
43510
|
}, reactElementsByRow.map((rowData, index2) => {
|
|
43280
43511
|
const fieldId = rowData.firstFieldId;
|
|
43281
43512
|
const key = isMobile2 && fieldId || index2;
|
|
43513
|
+
const responsive = Boolean(responsiveGrid);
|
|
43282
43514
|
return /* @__PURE__ */ React172__default.default.createElement(Focusable, {
|
|
43283
43515
|
key: fieldId,
|
|
43284
|
-
fieldId
|
|
43516
|
+
fieldId,
|
|
43517
|
+
className: responsive ? responsive_grid_module_default.row : void 0,
|
|
43518
|
+
style: responsiveGrid?.rows.get(rowData.row)
|
|
43285
43519
|
}, /* @__PURE__ */ React172__default.default.createElement("div", {
|
|
43286
43520
|
key,
|
|
43287
43521
|
style: getGridStyle({
|
|
43288
|
-
layout
|
|
43522
|
+
layout,
|
|
43523
|
+
responsive
|
|
43289
43524
|
}),
|
|
43290
|
-
className: (0,
|
|
43291
|
-
[grid_animations_module_default.animations]: enableAnimations
|
|
43525
|
+
className: (0, import_classnames22.default)(grid_module_default.grid, grid_module_default.column, {
|
|
43526
|
+
[grid_animations_module_default.animations]: enableAnimations,
|
|
43527
|
+
[responsive_grid_module_default.grid]: responsive
|
|
43292
43528
|
})
|
|
43293
43529
|
}, rowData.elements));
|
|
43294
43530
|
}));
|
|
@@ -43306,7 +43542,8 @@ function getReactElementsByRow(items) {
|
|
|
43306
43542
|
elements: [
|
|
43307
43543
|
element
|
|
43308
43544
|
],
|
|
43309
|
-
firstFieldId: item.id
|
|
43545
|
+
firstFieldId: item.id,
|
|
43546
|
+
row
|
|
43310
43547
|
};
|
|
43311
43548
|
}
|
|
43312
43549
|
return result2;
|
|
@@ -50570,7 +50807,7 @@ var useFormBi = (form, bi2, biFormFillSessionId) => {
|
|
|
50570
50807
|
};
|
|
50571
50808
|
|
|
50572
50809
|
// ../form-viewer/dist/esm/components/root/form-viewer-provider.js
|
|
50573
|
-
var FormViewerProvider = ({ i18n, bi: bi2, biFormFillSessionId, form, isMobile: isMobile2, isEditor, isComposer, isRTL, compId, PortalContainer, language, regionalFormat, externalData, forcedState, children, panorama, experiments, translationNamespace, currency, userData, WixRicosViewer, addressTemplates, fieldInitialData, enableAnimations, baseUrl }) => {
|
|
50810
|
+
var FormViewerProvider = ({ i18n, bi: bi2, biFormFillSessionId, form, isMobile: isMobile2, isEditor, isComposer, isRTL, compId, PortalContainer, language, regionalFormat, externalData, forcedState, children, panorama, experiments, translationNamespace, currency, userData, WixRicosViewer, addressTemplates, fieldInitialData, enableAnimations, cssMobileLayout, baseUrl }) => {
|
|
50574
50811
|
const translations = React172.useMemo(() => ({
|
|
50575
50812
|
t: i18n.getFixedT(language, translationNamespace),
|
|
50576
50813
|
i18n
|
|
@@ -50602,7 +50839,8 @@ var FormViewerProvider = ({ i18n, bi: bi2, biFormFillSessionId, form, isMobile:
|
|
|
50602
50839
|
isEditor,
|
|
50603
50840
|
isComposer,
|
|
50604
50841
|
isRTL,
|
|
50605
|
-
enableAnimations
|
|
50842
|
+
enableAnimations,
|
|
50843
|
+
cssMobileLayout
|
|
50606
50844
|
}), [
|
|
50607
50845
|
language,
|
|
50608
50846
|
regionalFormat,
|
|
@@ -50615,7 +50853,8 @@ var FormViewerProvider = ({ i18n, bi: bi2, biFormFillSessionId, form, isMobile:
|
|
|
50615
50853
|
isEditor,
|
|
50616
50854
|
isComposer,
|
|
50617
50855
|
isRTL,
|
|
50618
|
-
enableAnimations
|
|
50856
|
+
enableAnimations,
|
|
50857
|
+
cssMobileLayout
|
|
50619
50858
|
]);
|
|
50620
50859
|
const forcedViewState = React172.useMemo(() => forcedState ?? [], [
|
|
50621
50860
|
forcedState
|