@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.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
|
|
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,
|
|
47366
|
+
const fieldView = createFieldView(_field, effectiveLayout, path, recursive, isMobile2, isSmallBreakpoint ? Breakpoint.SMALL : breakpoint);
|
|
47306
47367
|
if (fieldView) {
|
|
47307
47368
|
result2.push(fieldView);
|
|
47308
47369
|
}
|
|
@@ -51731,6 +51792,7 @@ var FIELDSET_RESET_STYLE = {
|
|
|
51731
51792
|
};
|
|
51732
51793
|
var AppointmentSlotPickerContext = createContext(void 0);
|
|
51733
51794
|
var getTimezoneNoteId = (inputId) => `${inputId}-timezone-note`;
|
|
51795
|
+
var getDateTitleId = (inputId) => `${inputId}-date-title`;
|
|
51734
51796
|
var useAppointmentSlotPickerContext = () => {
|
|
51735
51797
|
const context = useContext(AppointmentSlotPickerContext);
|
|
51736
51798
|
if (typeof context === "undefined") {
|
|
@@ -51859,15 +51921,13 @@ Dates.NextWeek = NextWeek;
|
|
|
51859
51921
|
Dates.Day = Day;
|
|
51860
51922
|
var RADIO_INPUT_SELECTOR = 'input[type="radio"]';
|
|
51861
51923
|
var Slots = ({ children, className, ...internal }) => {
|
|
51862
|
-
const { hasTimezoneNote } = internal;
|
|
51924
|
+
const { hasTimezoneNote, hasDateTitle } = internal;
|
|
51863
51925
|
const { slots, selectedSlotKey, selectSlot, selectedDateLabel, isReloadingSlots, timezoneLabel, pendingFocusIndex, consumePendingFocusIndex } = useAppointmentSlotPickerContext();
|
|
51864
51926
|
const { id: fieldId, disabled, readOnly, required, hasError } = useFieldPropsV2();
|
|
51865
51927
|
const { inputId, labelId: fieldLabelId, ariaDescribedBy } = useFieldAttributes();
|
|
51866
51928
|
const groupRef = useRef(null);
|
|
51867
|
-
const slotsLabelId = `${inputId}-slots-label`;
|
|
51868
|
-
const labelElement = findChildOfType(children, Slots.Label);
|
|
51869
51929
|
const slotElement = findChildOfType(children, Slots.Slot) ?? /* @__PURE__ */ React173.createElement(Slots.Slot, null);
|
|
51870
|
-
const
|
|
51930
|
+
const isLabelledByDateTitle = !!hasDateTitle && !!selectedDateLabel;
|
|
51871
51931
|
const describedBy = [
|
|
51872
51932
|
ariaDescribedBy,
|
|
51873
51933
|
hasTimezoneNote && timezoneLabel ? getTimezoneNoteId(inputId) : void 0
|
|
@@ -51907,29 +51967,14 @@ var Slots = ({ children, className, ...internal }) => {
|
|
|
51907
51967
|
isReadOnly: readOnly,
|
|
51908
51968
|
isRequired: required,
|
|
51909
51969
|
isInvalid: hasError,
|
|
51910
|
-
"aria-labelledby":
|
|
51970
|
+
"aria-labelledby": isLabelledByDateTitle ? getDateTitleId(inputId) : fieldLabelId,
|
|
51911
51971
|
"aria-describedby": describedBy,
|
|
51912
51972
|
"data-refetch": isReloadingSlots || void 0
|
|
51913
|
-
}, applyInternalProps(
|
|
51914
|
-
labelId: slotsLabelId
|
|
51915
|
-
}), slots.map((slot) => applyInternalProps(slotElement, {
|
|
51973
|
+
}, slots.map((slot) => applyInternalProps(slotElement, {
|
|
51916
51974
|
key: slot.key,
|
|
51917
51975
|
slot
|
|
51918
51976
|
}))));
|
|
51919
51977
|
};
|
|
51920
|
-
var SlotsLabel = ({ children, className, ...internal }) => {
|
|
51921
|
-
const { selectedDateLabel } = useAppointmentSlotPickerContext();
|
|
51922
|
-
const { labelId } = internal;
|
|
51923
|
-
if (!selectedDateLabel) {
|
|
51924
|
-
return null;
|
|
51925
|
-
}
|
|
51926
|
-
return /* @__PURE__ */ React173.createElement("div", {
|
|
51927
|
-
id: labelId,
|
|
51928
|
-
className
|
|
51929
|
-
}, children ? children({
|
|
51930
|
-
label: selectedDateLabel
|
|
51931
|
-
}) : selectedDateLabel);
|
|
51932
|
-
};
|
|
51933
51978
|
var Slot = ({ children, className, ...internal }) => {
|
|
51934
51979
|
const { slot } = internal;
|
|
51935
51980
|
return /* @__PURE__ */ React173.createElement(RadioField, {
|
|
@@ -51939,7 +51984,6 @@ var Slot = ({ children, className, ...internal }) => {
|
|
|
51939
51984
|
className
|
|
51940
51985
|
}, children ? children(slot) : slot.timeRange));
|
|
51941
51986
|
};
|
|
51942
|
-
Slots.Label = SlotsLabel;
|
|
51943
51987
|
Slots.Slot = Slot;
|
|
51944
51988
|
var import_cloneDeep = __toESM(require_cloneDeep());
|
|
51945
51989
|
var createIndicatorNode = (requiredIndicatorType, t, className) => {
|