@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.js
CHANGED
|
@@ -16231,7 +16231,7 @@ var require_classnames = __commonJS({
|
|
|
16231
16231
|
"../../node_modules/classnames/index.js"(exports, module) {
|
|
16232
16232
|
(function() {
|
|
16233
16233
|
var hasOwn2 = {}.hasOwnProperty;
|
|
16234
|
-
function
|
|
16234
|
+
function classNames17() {
|
|
16235
16235
|
var classes = "";
|
|
16236
16236
|
for (var i = 0; i < arguments.length; i++) {
|
|
16237
16237
|
var arg = arguments[i];
|
|
@@ -16249,7 +16249,7 @@ var require_classnames = __commonJS({
|
|
|
16249
16249
|
return "";
|
|
16250
16250
|
}
|
|
16251
16251
|
if (Array.isArray(arg)) {
|
|
16252
|
-
return
|
|
16252
|
+
return classNames17.apply(null, arg);
|
|
16253
16253
|
}
|
|
16254
16254
|
if (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes("[native code]")) {
|
|
16255
16255
|
return arg.toString();
|
|
@@ -16272,14 +16272,14 @@ var require_classnames = __commonJS({
|
|
|
16272
16272
|
return value + newClass;
|
|
16273
16273
|
}
|
|
16274
16274
|
if (typeof module !== "undefined" && module.exports) {
|
|
16275
|
-
|
|
16276
|
-
module.exports =
|
|
16275
|
+
classNames17.default = classNames17;
|
|
16276
|
+
module.exports = classNames17;
|
|
16277
16277
|
} else if (typeof define === "function" && typeof define.amd === "object" && define.amd) {
|
|
16278
16278
|
define("classnames", [], function() {
|
|
16279
|
-
return
|
|
16279
|
+
return classNames17;
|
|
16280
16280
|
});
|
|
16281
16281
|
} else {
|
|
16282
|
-
window.classNames =
|
|
16282
|
+
window.classNames = classNames17;
|
|
16283
16283
|
}
|
|
16284
16284
|
})();
|
|
16285
16285
|
}
|
|
@@ -43162,6 +43162,203 @@ function useFormView() {
|
|
|
43162
43162
|
return context;
|
|
43163
43163
|
}
|
|
43164
43164
|
|
|
43165
|
+
// ../form-fields/dist/esm/field-layout/default-field-layout.js
|
|
43166
|
+
var import_classnames21 = __toESM(require_classnames());
|
|
43167
|
+
|
|
43168
|
+
// ../form-fields/dist/esm/ui/form/components/grid/responsive-grid.module.scss
|
|
43169
|
+
var responsive_grid_module_default = {};
|
|
43170
|
+
|
|
43171
|
+
// ../form-fields/dist/esm/utils/responsive-grid.js
|
|
43172
|
+
function placeResponsiveFields(fields, columns) {
|
|
43173
|
+
const groups = groupByDesktopRow(fields);
|
|
43174
|
+
const hasSmallLayout = fields.some((field) => field.layoutByBreakpoint?.small);
|
|
43175
|
+
const placement = {
|
|
43176
|
+
fields: /* @__PURE__ */ new Map(),
|
|
43177
|
+
rowOrder: /* @__PURE__ */ new Map()
|
|
43178
|
+
};
|
|
43179
|
+
if (!hasSmallLayout) {
|
|
43180
|
+
groups.forEach((group, index2) => {
|
|
43181
|
+
stackGroup(group, columns, placement);
|
|
43182
|
+
placement.rowOrder.set(group.row, index2);
|
|
43183
|
+
});
|
|
43184
|
+
return placement;
|
|
43185
|
+
}
|
|
43186
|
+
const smallLayoutOf = (field) => field.layoutByBreakpoint?.small ?? field.layout;
|
|
43187
|
+
const ranks = denseRanks(fields.map((field) => smallLayoutOf(field).row));
|
|
43188
|
+
const ranges = groups.map((group) => {
|
|
43189
|
+
const groupRanks = group.fields.map((field) => ranks.get(smallLayoutOf(field).row));
|
|
43190
|
+
return {
|
|
43191
|
+
min: Math.min(...groupRanks),
|
|
43192
|
+
max: Math.max(...groupRanks)
|
|
43193
|
+
};
|
|
43194
|
+
});
|
|
43195
|
+
const clusters = clusterOverlappingRanges(ranges);
|
|
43196
|
+
clusters.forEach((cluster) => {
|
|
43197
|
+
if (cluster.length > 1) {
|
|
43198
|
+
cluster.forEach((index3) => stackGroup(groups[index3], columns, placement));
|
|
43199
|
+
return;
|
|
43200
|
+
}
|
|
43201
|
+
const [index2] = cluster;
|
|
43202
|
+
groups[index2].fields.forEach((field) => {
|
|
43203
|
+
const small = smallLayoutOf(field);
|
|
43204
|
+
placement.fields.set(field.id, {
|
|
43205
|
+
large: toLargePlacement(field.layout),
|
|
43206
|
+
small: {
|
|
43207
|
+
...clampColumns(small, columns),
|
|
43208
|
+
subRow: ranks.get(small.row) - ranges[index2].min
|
|
43209
|
+
}
|
|
43210
|
+
});
|
|
43211
|
+
});
|
|
43212
|
+
});
|
|
43213
|
+
clusters.flatMap((cluster) => [
|
|
43214
|
+
...cluster
|
|
43215
|
+
].sort((one, other) => one - other)).forEach((index2, order) => placement.rowOrder.set(groups[index2].row, order));
|
|
43216
|
+
return placement;
|
|
43217
|
+
}
|
|
43218
|
+
function clusterOverlappingRanges(ranges) {
|
|
43219
|
+
const byMin = ranges.map((range3, index2) => ({
|
|
43220
|
+
...range3,
|
|
43221
|
+
index: index2
|
|
43222
|
+
})).sort((one, other) => one.min - other.min || one.index - other.index);
|
|
43223
|
+
const clusters = [];
|
|
43224
|
+
byMin.forEach(({ min: min4, max: max4, index: index2 }) => {
|
|
43225
|
+
const last6 = clusters.at(-1);
|
|
43226
|
+
if (last6 && min4 <= last6.max) {
|
|
43227
|
+
last6.indices.push(index2);
|
|
43228
|
+
last6.max = Math.max(last6.max, max4);
|
|
43229
|
+
} else {
|
|
43230
|
+
clusters.push({
|
|
43231
|
+
max: max4,
|
|
43232
|
+
indices: [
|
|
43233
|
+
index2
|
|
43234
|
+
]
|
|
43235
|
+
});
|
|
43236
|
+
}
|
|
43237
|
+
});
|
|
43238
|
+
return clusters.map(({ indices }) => indices);
|
|
43239
|
+
}
|
|
43240
|
+
function toResponsiveGridVariables({ large, small }) {
|
|
43241
|
+
const columnVariables = {
|
|
43242
|
+
"--form-col-lg": toColumn(large),
|
|
43243
|
+
"--form-col-sm": toColumn(small)
|
|
43244
|
+
};
|
|
43245
|
+
const offset = {
|
|
43246
|
+
"--form-row-offset-sm": small.subRow > 0 ? "1" : "0"
|
|
43247
|
+
};
|
|
43248
|
+
return {
|
|
43249
|
+
label: {
|
|
43250
|
+
...columnVariables,
|
|
43251
|
+
...offset,
|
|
43252
|
+
"--form-row-lg": toRow(large, 0, 1),
|
|
43253
|
+
"--form-row-sm": toRow(small, 0, 1)
|
|
43254
|
+
},
|
|
43255
|
+
input: {
|
|
43256
|
+
...columnVariables,
|
|
43257
|
+
"--form-row-offset-sm": "0",
|
|
43258
|
+
"--form-row-lg": toRow(large, 1, 1),
|
|
43259
|
+
"--form-row-sm": toRow(small, 1, 1)
|
|
43260
|
+
},
|
|
43261
|
+
container: {
|
|
43262
|
+
...columnVariables,
|
|
43263
|
+
...offset,
|
|
43264
|
+
"--form-row-lg": toRow(large, 0, 2),
|
|
43265
|
+
"--form-row-sm": toRow(small, 0, 2)
|
|
43266
|
+
}
|
|
43267
|
+
};
|
|
43268
|
+
}
|
|
43269
|
+
var responsiveGridCache = /* @__PURE__ */ new WeakMap();
|
|
43270
|
+
function getResponsiveGrid(form) {
|
|
43271
|
+
const cached = responsiveGridCache.get(form);
|
|
43272
|
+
if (cached) {
|
|
43273
|
+
return cached;
|
|
43274
|
+
}
|
|
43275
|
+
const placement = placeResponsiveFields(form.fields, form.grid.columns);
|
|
43276
|
+
const grid = {
|
|
43277
|
+
fields: new Map([
|
|
43278
|
+
...placement.fields
|
|
43279
|
+
].map(([fieldId, fieldPlacement]) => [
|
|
43280
|
+
fieldId,
|
|
43281
|
+
toResponsiveGridVariables(fieldPlacement)
|
|
43282
|
+
])),
|
|
43283
|
+
rows: new Map([
|
|
43284
|
+
...placement.rowOrder
|
|
43285
|
+
].map(([row, order]) => [
|
|
43286
|
+
row,
|
|
43287
|
+
{
|
|
43288
|
+
"--form-row-order-sm": String(order)
|
|
43289
|
+
}
|
|
43290
|
+
]))
|
|
43291
|
+
};
|
|
43292
|
+
responsiveGridCache.set(form, grid);
|
|
43293
|
+
return grid;
|
|
43294
|
+
}
|
|
43295
|
+
function groupByDesktopRow(fields) {
|
|
43296
|
+
const groups = /* @__PURE__ */ new Map();
|
|
43297
|
+
fields.forEach((field) => {
|
|
43298
|
+
const group = groups.get(field.layout.row);
|
|
43299
|
+
if (group) {
|
|
43300
|
+
group.push(field);
|
|
43301
|
+
} else {
|
|
43302
|
+
groups.set(field.layout.row, [
|
|
43303
|
+
field
|
|
43304
|
+
]);
|
|
43305
|
+
}
|
|
43306
|
+
});
|
|
43307
|
+
return [
|
|
43308
|
+
...groups
|
|
43309
|
+
].sort(([one], [other]) => one - other).map(([row, groupFields]) => ({
|
|
43310
|
+
row,
|
|
43311
|
+
fields: groupFields
|
|
43312
|
+
}));
|
|
43313
|
+
}
|
|
43314
|
+
function stackGroup(group, columns, placement) {
|
|
43315
|
+
group.fields.forEach((field, subRow) => {
|
|
43316
|
+
placement.fields.set(field.id, {
|
|
43317
|
+
large: toLargePlacement(field.layout),
|
|
43318
|
+
small: {
|
|
43319
|
+
column: 0,
|
|
43320
|
+
width: columns,
|
|
43321
|
+
subRow
|
|
43322
|
+
}
|
|
43323
|
+
});
|
|
43324
|
+
});
|
|
43325
|
+
}
|
|
43326
|
+
function denseRanks(rows) {
|
|
43327
|
+
return new Map([
|
|
43328
|
+
...new Set(rows)
|
|
43329
|
+
].sort((one, other) => one - other).map((row, rank) => [
|
|
43330
|
+
row,
|
|
43331
|
+
rank
|
|
43332
|
+
]));
|
|
43333
|
+
}
|
|
43334
|
+
function toLargePlacement({ column, width }) {
|
|
43335
|
+
return {
|
|
43336
|
+
column,
|
|
43337
|
+
width,
|
|
43338
|
+
subRow: 0
|
|
43339
|
+
};
|
|
43340
|
+
}
|
|
43341
|
+
function clampColumns({ column, width }, columns) {
|
|
43342
|
+
const clampedColumn = Math.min(Math.max(column, 0), columns - 1);
|
|
43343
|
+
return {
|
|
43344
|
+
column: clampedColumn,
|
|
43345
|
+
width: Math.min(Math.max(width, 1), columns - clampedColumn)
|
|
43346
|
+
};
|
|
43347
|
+
}
|
|
43348
|
+
function toColumn({ column, width }) {
|
|
43349
|
+
return `${column + 1} / span ${width}`;
|
|
43350
|
+
}
|
|
43351
|
+
function toRow({ subRow }, track, span) {
|
|
43352
|
+
return `${subRow * 2 + track + 1} / span ${span}`;
|
|
43353
|
+
}
|
|
43354
|
+
|
|
43355
|
+
// ../form-fields/dist/esm/ui/form/components/grid/use-responsive-grid.js
|
|
43356
|
+
function useResponsiveGrid() {
|
|
43357
|
+
const { cssMobileLayout, isMobile: isMobile2 } = useConfig();
|
|
43358
|
+
const form = useContext(FormViewContext);
|
|
43359
|
+
return cssMobileLayout && !isMobile2 && form ? getResponsiveGrid(form) : void 0;
|
|
43360
|
+
}
|
|
43361
|
+
|
|
43165
43362
|
// ../form-fields/dist/esm/ui/form/types/form-view.js
|
|
43166
43363
|
function isInputField2(field) {
|
|
43167
43364
|
return Boolean(field.target);
|
|
@@ -43196,6 +43393,7 @@ function calculateGridStyles(options) {
|
|
|
43196
43393
|
// ../form-fields/dist/esm/field-layout/default-field-layout.js
|
|
43197
43394
|
var DefaultFieldLayout = ({ fieldId, ...rest }) => {
|
|
43198
43395
|
const fieldView = useFieldView(fieldId);
|
|
43396
|
+
const responsiveGrid = useResponsiveGrid();
|
|
43199
43397
|
if (!fieldView) {
|
|
43200
43398
|
return null;
|
|
43201
43399
|
}
|
|
@@ -43205,30 +43403,58 @@ var DefaultFieldLayout = ({ fieldId, ...rest }) => {
|
|
|
43205
43403
|
"data-hook": dataHook,
|
|
43206
43404
|
"data-field-type": fieldType
|
|
43207
43405
|
};
|
|
43208
|
-
const
|
|
43209
|
-
layout
|
|
43210
|
-
});
|
|
43406
|
+
const cellProps = getCellProps(layout, responsiveGrid?.fields.get(fieldId));
|
|
43211
43407
|
if ("children" in rest) {
|
|
43212
43408
|
return /* @__PURE__ */ React172.createElement("div", {
|
|
43213
|
-
|
|
43409
|
+
...cellProps.container,
|
|
43214
43410
|
...dataAttributes
|
|
43215
43411
|
}, rest.children);
|
|
43216
43412
|
}
|
|
43217
43413
|
const { renderLabel, renderInput, renderDescription } = rest;
|
|
43218
|
-
return /* @__PURE__ */ React172.createElement(React172.Fragment, null, /* @__PURE__ */ React172.createElement("div", {
|
|
43219
|
-
|
|
43220
|
-
}, renderLabel()), /* @__PURE__ */ React172.createElement("div", {
|
|
43221
|
-
style: gridStyles.input,
|
|
43414
|
+
return /* @__PURE__ */ React172.createElement(React172.Fragment, null, /* @__PURE__ */ React172.createElement("div", cellProps.label, renderLabel()), /* @__PURE__ */ React172.createElement("div", {
|
|
43415
|
+
...cellProps.input,
|
|
43222
43416
|
...dataAttributes
|
|
43223
43417
|
}, renderInput(), renderDescription()));
|
|
43224
43418
|
};
|
|
43419
|
+
function getCellProps(layout, variables) {
|
|
43420
|
+
if (!variables) {
|
|
43421
|
+
const { label, input, container } = calculateGridStyles({
|
|
43422
|
+
layout
|
|
43423
|
+
});
|
|
43424
|
+
return {
|
|
43425
|
+
label: {
|
|
43426
|
+
style: label
|
|
43427
|
+
},
|
|
43428
|
+
input: {
|
|
43429
|
+
style: input
|
|
43430
|
+
},
|
|
43431
|
+
container: {
|
|
43432
|
+
style: container
|
|
43433
|
+
}
|
|
43434
|
+
};
|
|
43435
|
+
}
|
|
43436
|
+
return {
|
|
43437
|
+
label: {
|
|
43438
|
+
style: variables.label,
|
|
43439
|
+
className: (0, import_classnames21.default)(responsive_grid_module_default.cell, responsive_grid_module_default.label)
|
|
43440
|
+
},
|
|
43441
|
+
input: {
|
|
43442
|
+
style: variables.input,
|
|
43443
|
+
className: responsive_grid_module_default.cell
|
|
43444
|
+
},
|
|
43445
|
+
container: {
|
|
43446
|
+
style: variables.container,
|
|
43447
|
+
className: responsive_grid_module_default.cell
|
|
43448
|
+
}
|
|
43449
|
+
};
|
|
43450
|
+
}
|
|
43225
43451
|
|
|
43226
43452
|
// ../form-fields/dist/esm/ui/form/components/grid/grid.js
|
|
43227
|
-
var
|
|
43453
|
+
var import_classnames22 = __toESM(require_classnames());
|
|
43228
43454
|
|
|
43229
43455
|
// ../form-fields/dist/esm/animations/grid-animations.module.scss
|
|
43230
43456
|
var grid_animations_module_default = {};
|
|
43231
|
-
var Focusable = ({ children, fieldId }) => {
|
|
43457
|
+
var Focusable = ({ children, fieldId, className, style }) => {
|
|
43232
43458
|
const viewRef = useRef(null);
|
|
43233
43459
|
const { scrollTo } = useScroll();
|
|
43234
43460
|
const { focusedFieldId } = useFocusedField();
|
|
@@ -43242,17 +43468,21 @@ var Focusable = ({ children, fieldId }) => {
|
|
|
43242
43468
|
focusedFieldId
|
|
43243
43469
|
]);
|
|
43244
43470
|
return /* @__PURE__ */ React172.createElement("div", {
|
|
43245
|
-
ref: viewRef
|
|
43471
|
+
ref: viewRef,
|
|
43472
|
+
className,
|
|
43473
|
+
style
|
|
43246
43474
|
}, children);
|
|
43247
43475
|
};
|
|
43248
43476
|
|
|
43249
43477
|
// ../form-fields/dist/esm/ui/form/components/grid/grid-options.js
|
|
43250
|
-
var getGridStyle = ({ layout }) => {
|
|
43478
|
+
var getGridStyle = ({ layout, responsive = false }) => {
|
|
43251
43479
|
return {
|
|
43252
43480
|
display: "grid",
|
|
43253
43481
|
width: "100%",
|
|
43254
43482
|
gridTemplateColumns: `repeat(${layout.columns}, 1fr)`,
|
|
43255
|
-
|
|
43483
|
+
...responsive ? {} : {
|
|
43484
|
+
gridAutoRows: "minmax(min-content, max-content) 1fr"
|
|
43485
|
+
}
|
|
43256
43486
|
};
|
|
43257
43487
|
};
|
|
43258
43488
|
|
|
@@ -43262,6 +43492,7 @@ var grid_module_default = {};
|
|
|
43262
43492
|
// ../form-fields/dist/esm/ui/form/components/grid/grid.js
|
|
43263
43493
|
var Grid = ({ items, layout, isRTL }) => {
|
|
43264
43494
|
const { isMobile: isMobile2, enableAnimations } = useConfig();
|
|
43495
|
+
const responsiveGrid = useResponsiveGrid();
|
|
43265
43496
|
const reactElementsByRow = getReactElementsByRow(items);
|
|
43266
43497
|
return /* @__PURE__ */ React172.createElement("div", {
|
|
43267
43498
|
className: grid_module_default.container,
|
|
@@ -43269,16 +43500,21 @@ var Grid = ({ items, layout, isRTL }) => {
|
|
|
43269
43500
|
}, reactElementsByRow.map((rowData, index2) => {
|
|
43270
43501
|
const fieldId = rowData.firstFieldId;
|
|
43271
43502
|
const key = isMobile2 && fieldId || index2;
|
|
43503
|
+
const responsive = Boolean(responsiveGrid);
|
|
43272
43504
|
return /* @__PURE__ */ React172.createElement(Focusable, {
|
|
43273
43505
|
key: fieldId,
|
|
43274
|
-
fieldId
|
|
43506
|
+
fieldId,
|
|
43507
|
+
className: responsive ? responsive_grid_module_default.row : void 0,
|
|
43508
|
+
style: responsiveGrid?.rows.get(rowData.row)
|
|
43275
43509
|
}, /* @__PURE__ */ React172.createElement("div", {
|
|
43276
43510
|
key,
|
|
43277
43511
|
style: getGridStyle({
|
|
43278
|
-
layout
|
|
43512
|
+
layout,
|
|
43513
|
+
responsive
|
|
43279
43514
|
}),
|
|
43280
|
-
className: (0,
|
|
43281
|
-
[grid_animations_module_default.animations]: enableAnimations
|
|
43515
|
+
className: (0, import_classnames22.default)(grid_module_default.grid, grid_module_default.column, {
|
|
43516
|
+
[grid_animations_module_default.animations]: enableAnimations,
|
|
43517
|
+
[responsive_grid_module_default.grid]: responsive
|
|
43282
43518
|
})
|
|
43283
43519
|
}, rowData.elements));
|
|
43284
43520
|
}));
|
|
@@ -43296,7 +43532,8 @@ function getReactElementsByRow(items) {
|
|
|
43296
43532
|
elements: [
|
|
43297
43533
|
element
|
|
43298
43534
|
],
|
|
43299
|
-
firstFieldId: item.id
|
|
43535
|
+
firstFieldId: item.id,
|
|
43536
|
+
row
|
|
43300
43537
|
};
|
|
43301
43538
|
}
|
|
43302
43539
|
return result2;
|
|
@@ -50560,7 +50797,7 @@ var useFormBi = (form, bi2, biFormFillSessionId) => {
|
|
|
50560
50797
|
};
|
|
50561
50798
|
|
|
50562
50799
|
// ../form-viewer/dist/esm/components/root/form-viewer-provider.js
|
|
50563
|
-
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 }) => {
|
|
50800
|
+
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 }) => {
|
|
50564
50801
|
const translations = useMemo(() => ({
|
|
50565
50802
|
t: i18n.getFixedT(language, translationNamespace),
|
|
50566
50803
|
i18n
|
|
@@ -50592,7 +50829,8 @@ var FormViewerProvider = ({ i18n, bi: bi2, biFormFillSessionId, form, isMobile:
|
|
|
50592
50829
|
isEditor,
|
|
50593
50830
|
isComposer,
|
|
50594
50831
|
isRTL,
|
|
50595
|
-
enableAnimations
|
|
50832
|
+
enableAnimations,
|
|
50833
|
+
cssMobileLayout
|
|
50596
50834
|
}), [
|
|
50597
50835
|
language,
|
|
50598
50836
|
regionalFormat,
|
|
@@ -50605,7 +50843,8 @@ var FormViewerProvider = ({ i18n, bi: bi2, biFormFillSessionId, form, isMobile:
|
|
|
50605
50843
|
isEditor,
|
|
50606
50844
|
isComposer,
|
|
50607
50845
|
isRTL,
|
|
50608
|
-
enableAnimations
|
|
50846
|
+
enableAnimations,
|
|
50847
|
+
cssMobileLayout
|
|
50609
50848
|
]);
|
|
50610
50849
|
const forcedViewState = useMemo(() => forcedState ?? [], [
|
|
50611
50850
|
forcedState
|