@wix/form-public 0.527.0 → 0.529.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 +81 -37
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +5 -3
- package/dist/index.css.map +1 -1
- package/dist/index.js +81 -37
- 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
|
}
|
|
@@ -51741,6 +51802,7 @@ var FIELDSET_RESET_STYLE = {
|
|
|
51741
51802
|
};
|
|
51742
51803
|
var AppointmentSlotPickerContext = React173.createContext(void 0);
|
|
51743
51804
|
var getTimezoneNoteId = (inputId) => `${inputId}-timezone-note`;
|
|
51805
|
+
var getDateTitleId = (inputId) => `${inputId}-date-title`;
|
|
51744
51806
|
var useAppointmentSlotPickerContext = () => {
|
|
51745
51807
|
const context = React173.useContext(AppointmentSlotPickerContext);
|
|
51746
51808
|
if (typeof context === "undefined") {
|
|
@@ -51869,15 +51931,13 @@ Dates.NextWeek = NextWeek;
|
|
|
51869
51931
|
Dates.Day = Day;
|
|
51870
51932
|
var RADIO_INPUT_SELECTOR = 'input[type="radio"]';
|
|
51871
51933
|
var Slots = ({ children, className, ...internal }) => {
|
|
51872
|
-
const { hasTimezoneNote } = internal;
|
|
51934
|
+
const { hasTimezoneNote, hasDateTitle } = internal;
|
|
51873
51935
|
const { slots, selectedSlotKey, selectSlot, selectedDateLabel, isReloadingSlots, timezoneLabel, pendingFocusIndex, consumePendingFocusIndex } = useAppointmentSlotPickerContext();
|
|
51874
51936
|
const { id: fieldId, disabled, readOnly, required, hasError } = useFieldPropsV2();
|
|
51875
51937
|
const { inputId, labelId: fieldLabelId, ariaDescribedBy } = useFieldAttributes();
|
|
51876
51938
|
const groupRef = React173.useRef(null);
|
|
51877
|
-
const slotsLabelId = `${inputId}-slots-label`;
|
|
51878
|
-
const labelElement = findChildOfType(children, Slots.Label);
|
|
51879
51939
|
const slotElement = findChildOfType(children, Slots.Slot) ?? /* @__PURE__ */ React173__default.default.createElement(Slots.Slot, null);
|
|
51880
|
-
const
|
|
51940
|
+
const isLabelledByDateTitle = !!hasDateTitle && !!selectedDateLabel;
|
|
51881
51941
|
const describedBy = [
|
|
51882
51942
|
ariaDescribedBy,
|
|
51883
51943
|
hasTimezoneNote && timezoneLabel ? getTimezoneNoteId(inputId) : void 0
|
|
@@ -51917,29 +51977,14 @@ var Slots = ({ children, className, ...internal }) => {
|
|
|
51917
51977
|
isReadOnly: readOnly,
|
|
51918
51978
|
isRequired: required,
|
|
51919
51979
|
isInvalid: hasError,
|
|
51920
|
-
"aria-labelledby":
|
|
51980
|
+
"aria-labelledby": isLabelledByDateTitle ? getDateTitleId(inputId) : fieldLabelId,
|
|
51921
51981
|
"aria-describedby": describedBy,
|
|
51922
51982
|
"data-refetch": isReloadingSlots || void 0
|
|
51923
|
-
}, applyInternalProps(
|
|
51924
|
-
labelId: slotsLabelId
|
|
51925
|
-
}), slots.map((slot) => applyInternalProps(slotElement, {
|
|
51983
|
+
}, slots.map((slot) => applyInternalProps(slotElement, {
|
|
51926
51984
|
key: slot.key,
|
|
51927
51985
|
slot
|
|
51928
51986
|
}))));
|
|
51929
51987
|
};
|
|
51930
|
-
var SlotsLabel = ({ children, className, ...internal }) => {
|
|
51931
|
-
const { selectedDateLabel } = useAppointmentSlotPickerContext();
|
|
51932
|
-
const { labelId } = internal;
|
|
51933
|
-
if (!selectedDateLabel) {
|
|
51934
|
-
return null;
|
|
51935
|
-
}
|
|
51936
|
-
return /* @__PURE__ */ React173__default.default.createElement("div", {
|
|
51937
|
-
id: labelId,
|
|
51938
|
-
className
|
|
51939
|
-
}, children ? children({
|
|
51940
|
-
label: selectedDateLabel
|
|
51941
|
-
}) : selectedDateLabel);
|
|
51942
|
-
};
|
|
51943
51988
|
var Slot = ({ children, className, ...internal }) => {
|
|
51944
51989
|
const { slot } = internal;
|
|
51945
51990
|
return /* @__PURE__ */ React173__default.default.createElement(reactAriaComponents.RadioField, {
|
|
@@ -51949,7 +51994,6 @@ var Slot = ({ children, className, ...internal }) => {
|
|
|
51949
51994
|
className
|
|
51950
51995
|
}, children ? children(slot) : slot.timeRange));
|
|
51951
51996
|
};
|
|
51952
|
-
Slots.Label = SlotsLabel;
|
|
51953
51997
|
Slots.Slot = Slot;
|
|
51954
51998
|
var import_cloneDeep = __toESM(require_cloneDeep());
|
|
51955
51999
|
var createIndicatorNode = (requiredIndicatorType, t, className) => {
|