@wix/form-public 0.528.0 → 0.530.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 +47 -72
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +5 -14
- package/dist/index.css.map +1 -1
- package/dist/index.js +48 -73
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -7,7 +7,7 @@ import ReactDOM from 'react-dom';
|
|
|
7
7
|
import camelCase2 from 'lodash.camelcase';
|
|
8
8
|
import mapKeys from 'lodash.mapkeys';
|
|
9
9
|
import { jsx } from 'react/jsx-runtime';
|
|
10
|
-
import { CheckboxField, CheckboxButton, TextField, Input, ListBoxItem, Dialog, OverlayTriggerStateContext, ModalOverlay, Modal, SearchField, Group, RadioGroup as RadioGroup$1, Button, DropZone as DropZone$1, FileTrigger, useSlottedContext, PopoverContext, Popover, CollectionRendererContext, DefaultCollectionRenderer, ListBox, Autocomplete, RadioField, RadioButton, CheckboxGroup as CheckboxGroup$1, I18nProvider, DatePicker as DatePicker$1, Select, VisuallyHidden, NumberField, TimeField, SelectValue, CalendarCell, Calendar as Calendar$1, CalendarMonthPicker, CalendarYearPicker, CalendarGrid, DatePickerStateContext, DateInput as DateInput$1, DateSegment, TimeFieldStateContext, Text as Text$1, ProgressBar, ComboBox, DialogTrigger, TextArea as TextArea$1, ComboBoxStateContext } from 'react-aria-components';
|
|
10
|
+
import { CheckboxField, CheckboxButton, TextField, Input, ListBoxItem, Dialog, OverlayTriggerStateContext, ModalOverlay, Modal, SearchField, Group, RadioGroup as RadioGroup$1, Button, DropZone as DropZone$1, FileTrigger, useSlottedContext, PopoverContext, Popover, CollectionRendererContext, DefaultCollectionRenderer, ListBox, Autocomplete, RadioField, RadioButton, CheckboxGroup as CheckboxGroup$1, I18nProvider, DatePicker as DatePicker$1, Select, VisuallyHidden, NumberField, TimeField, SelectValue, CalendarCell, Calendar as Calendar$1, CalendarMonthPicker, CalendarYearPicker, CalendarGrid, DatePickerStateContext, DateInput as DateInput$1, DateSegment, TimeFieldStateContext, ToggleButton, ToggleButtonGroup, Text as Text$1, ProgressBar, ComboBox, DialogTrigger, TextArea as TextArea$1, ComboBoxStateContext } from 'react-aria-components';
|
|
11
11
|
|
|
12
12
|
var __create = Object.create;
|
|
13
13
|
var __defProp = Object.defineProperty;
|
|
@@ -51792,6 +51792,7 @@ var FIELDSET_RESET_STYLE = {
|
|
|
51792
51792
|
};
|
|
51793
51793
|
var AppointmentSlotPickerContext = createContext(void 0);
|
|
51794
51794
|
var getTimezoneNoteId = (inputId) => `${inputId}-timezone-note`;
|
|
51795
|
+
var getDateTitleId = (inputId) => `${inputId}-date-title`;
|
|
51795
51796
|
var useAppointmentSlotPickerContext = () => {
|
|
51796
51797
|
const context = useContext(AppointmentSlotPickerContext);
|
|
51797
51798
|
if (typeof context === "undefined") {
|
|
@@ -51920,15 +51921,13 @@ Dates.NextWeek = NextWeek;
|
|
|
51920
51921
|
Dates.Day = Day;
|
|
51921
51922
|
var RADIO_INPUT_SELECTOR = 'input[type="radio"]';
|
|
51922
51923
|
var Slots = ({ children, className, ...internal }) => {
|
|
51923
|
-
const { hasTimezoneNote } = internal;
|
|
51924
|
+
const { hasTimezoneNote, hasDateTitle } = internal;
|
|
51924
51925
|
const { slots, selectedSlotKey, selectSlot, selectedDateLabel, isReloadingSlots, timezoneLabel, pendingFocusIndex, consumePendingFocusIndex } = useAppointmentSlotPickerContext();
|
|
51925
51926
|
const { id: fieldId, disabled, readOnly, required, hasError } = useFieldPropsV2();
|
|
51926
51927
|
const { inputId, labelId: fieldLabelId, ariaDescribedBy } = useFieldAttributes();
|
|
51927
51928
|
const groupRef = useRef(null);
|
|
51928
|
-
const slotsLabelId = `${inputId}-slots-label`;
|
|
51929
|
-
const labelElement = findChildOfType(children, Slots.Label);
|
|
51930
51929
|
const slotElement = findChildOfType(children, Slots.Slot) ?? /* @__PURE__ */ React173.createElement(Slots.Slot, null);
|
|
51931
|
-
const
|
|
51930
|
+
const isLabelledByDateTitle = !!hasDateTitle && !!selectedDateLabel;
|
|
51932
51931
|
const describedBy = [
|
|
51933
51932
|
ariaDescribedBy,
|
|
51934
51933
|
hasTimezoneNote && timezoneLabel ? getTimezoneNoteId(inputId) : void 0
|
|
@@ -51968,29 +51967,14 @@ var Slots = ({ children, className, ...internal }) => {
|
|
|
51968
51967
|
isReadOnly: readOnly,
|
|
51969
51968
|
isRequired: required,
|
|
51970
51969
|
isInvalid: hasError,
|
|
51971
|
-
"aria-labelledby":
|
|
51970
|
+
"aria-labelledby": isLabelledByDateTitle ? getDateTitleId(inputId) : fieldLabelId,
|
|
51972
51971
|
"aria-describedby": describedBy,
|
|
51973
51972
|
"data-refetch": isReloadingSlots || void 0
|
|
51974
|
-
}, applyInternalProps(
|
|
51975
|
-
labelId: slotsLabelId
|
|
51976
|
-
}), slots.map((slot) => applyInternalProps(slotElement, {
|
|
51973
|
+
}, slots.map((slot) => applyInternalProps(slotElement, {
|
|
51977
51974
|
key: slot.key,
|
|
51978
51975
|
slot
|
|
51979
51976
|
}))));
|
|
51980
51977
|
};
|
|
51981
|
-
var SlotsLabel = ({ children, className, ...internal }) => {
|
|
51982
|
-
const { selectedDateLabel } = useAppointmentSlotPickerContext();
|
|
51983
|
-
const { labelId } = internal;
|
|
51984
|
-
if (!selectedDateLabel) {
|
|
51985
|
-
return null;
|
|
51986
|
-
}
|
|
51987
|
-
return /* @__PURE__ */ React173.createElement("div", {
|
|
51988
|
-
id: labelId,
|
|
51989
|
-
className
|
|
51990
|
-
}, children ? children({
|
|
51991
|
-
label: selectedDateLabel
|
|
51992
|
-
}) : selectedDateLabel);
|
|
51993
|
-
};
|
|
51994
51978
|
var Slot = ({ children, className, ...internal }) => {
|
|
51995
51979
|
const { slot } = internal;
|
|
51996
51980
|
return /* @__PURE__ */ React173.createElement(RadioField, {
|
|
@@ -52000,7 +51984,6 @@ var Slot = ({ children, className, ...internal }) => {
|
|
|
52000
51984
|
className
|
|
52001
51985
|
}, children ? children(slot) : slot.timeRange));
|
|
52002
51986
|
};
|
|
52003
|
-
Slots.Label = SlotsLabel;
|
|
52004
51987
|
Slots.Slot = Slot;
|
|
52005
51988
|
var import_cloneDeep = __toESM(require_cloneDeep());
|
|
52006
51989
|
var createIndicatorNode = (requiredIndicatorType, t, className) => {
|
|
@@ -55518,18 +55501,11 @@ function findProductWithDynamicPrice(products) {
|
|
|
55518
55501
|
function getCustomAmount(productValue, customAmountProduct) {
|
|
55519
55502
|
return productValue?.productId === customAmountProduct?.id ? String(productValue?.price ?? "") : "";
|
|
55520
55503
|
}
|
|
55521
|
-
function getProductValueOnCheckboxChange(productId, productValue, productsById) {
|
|
55522
|
-
const newValue = productValue?.productId === productId ? void 0 : productId;
|
|
55523
|
-
const product = newValue ? productsById[newValue] : void 0;
|
|
55524
|
-
return product ? [
|
|
55525
|
-
toProductValue(product, getProductPrice2(product))
|
|
55526
|
-
] : [];
|
|
55527
|
-
}
|
|
55528
55504
|
|
|
55529
55505
|
// ../form-fields/dist/esm/ui/donation-field/donation-field-headless.js
|
|
55530
55506
|
var Donation = ({ children }) => {
|
|
55531
|
-
const { id: id6, value, onChange,
|
|
55532
|
-
const { labelId } = useFieldAttributes();
|
|
55507
|
+
const { id: id6, value, onChange, required, onBlur, onFocus, validation, addOther, addOtherPlaceholder, FieldLayout } = useFieldPropsV2();
|
|
55508
|
+
const { inputId, labelId, ariaDescribedBy } = useFieldAttributes();
|
|
55533
55509
|
const { t } = useTranslation2();
|
|
55534
55510
|
const { currency, regionalFormat } = useConfig();
|
|
55535
55511
|
const productValue = value?.[0];
|
|
@@ -55549,13 +55525,15 @@ var Donation = ({ children }) => {
|
|
|
55549
55525
|
format: (source) => toLocaleDecimalSeparator(String(source ?? ""), regionalFormat),
|
|
55550
55526
|
regionalFormat
|
|
55551
55527
|
});
|
|
55552
|
-
const
|
|
55553
|
-
|
|
55528
|
+
const selectProduct = useCallback((productId) => {
|
|
55529
|
+
const product = productId === void 0 ? void 0 : productsById[productId];
|
|
55530
|
+
onChange(product ? [
|
|
55531
|
+
toProductValue(product, getProductPrice2(product))
|
|
55532
|
+
] : []);
|
|
55554
55533
|
setCustomAmount("");
|
|
55555
55534
|
}, [
|
|
55556
55535
|
onChange,
|
|
55557
55536
|
productsById,
|
|
55558
|
-
productValue,
|
|
55559
55537
|
setCustomAmount
|
|
55560
55538
|
]);
|
|
55561
55539
|
const handleCustomAmountChange = useCallback((amount) => {
|
|
@@ -55597,12 +55575,12 @@ var Donation = ({ children }) => {
|
|
|
55597
55575
|
const selectedValue = productValue?.productId || null;
|
|
55598
55576
|
const handleFocusCustomInput = useCallback(() => {
|
|
55599
55577
|
if (customAmountProduct?.id && selectedValue !== customAmountProduct.id) {
|
|
55600
|
-
|
|
55578
|
+
selectProduct(customAmountProduct.id);
|
|
55601
55579
|
}
|
|
55602
55580
|
}, [
|
|
55603
55581
|
customAmountProduct?.id,
|
|
55604
55582
|
selectedValue,
|
|
55605
|
-
|
|
55583
|
+
selectProduct
|
|
55606
55584
|
]);
|
|
55607
55585
|
const labelElement = findChildOfType(children, Donation.Label);
|
|
55608
55586
|
const controlElement = findChildOfType(children, Donation.Control);
|
|
@@ -55611,17 +55589,17 @@ var Donation = ({ children }) => {
|
|
|
55611
55589
|
return /* @__PURE__ */ React173.createElement(FieldLayout, {
|
|
55612
55590
|
fieldId: id6,
|
|
55613
55591
|
renderLabel: () => labelElement,
|
|
55614
|
-
renderInput: () => /* @__PURE__ */ React173.createElement(
|
|
55615
|
-
|
|
55616
|
-
|
|
55617
|
-
|
|
55618
|
-
|
|
55619
|
-
isInvalid: hasError,
|
|
55620
|
-
isRequired: required,
|
|
55592
|
+
renderInput: () => /* @__PURE__ */ React173.createElement(FieldsetHeadless, {
|
|
55593
|
+
id: inputId,
|
|
55594
|
+
ariaLabelledBy: labelId,
|
|
55595
|
+
ariaDescribedBy,
|
|
55596
|
+
required,
|
|
55621
55597
|
onBlur,
|
|
55622
55598
|
onFocus
|
|
55623
55599
|
}, controlElement ? applyInternalProps(controlElement, {
|
|
55624
55600
|
productsById,
|
|
55601
|
+
selectedValue,
|
|
55602
|
+
onSelectProduct: selectProduct,
|
|
55625
55603
|
addOther,
|
|
55626
55604
|
customAmount,
|
|
55627
55605
|
onCustomAmountInputChange: handleCustomAmountInputChange,
|
|
@@ -55635,7 +55613,7 @@ var Donation = ({ children }) => {
|
|
|
55635
55613
|
});
|
|
55636
55614
|
};
|
|
55637
55615
|
var Control3 = ({ children, className, ...internal }) => {
|
|
55638
|
-
const { productsById, addOther, customAmount, onCustomAmountInputChange, currency, t, placeholder, customAmountProductId, onFocusCustomInput } = internal;
|
|
55616
|
+
const { productsById, selectedValue, onSelectProduct, addOther, customAmount, onCustomAmountInputChange, currency, t, placeholder, customAmountProductId, onFocusCustomInput } = internal;
|
|
55639
55617
|
const { hasError } = useFieldPropsV2();
|
|
55640
55618
|
const optionsElement = findChildOfType(children, Donation.Options);
|
|
55641
55619
|
const otherInputElement = findChildOfType(children, Donation.OtherInput);
|
|
@@ -55643,23 +55621,10 @@ var Control3 = ({ children, className, ...internal }) => {
|
|
|
55643
55621
|
className,
|
|
55644
55622
|
"data-invalid": hasError
|
|
55645
55623
|
}, optionsElement ? applyInternalProps(optionsElement, {
|
|
55646
|
-
productsById
|
|
55647
|
-
|
|
55648
|
-
|
|
55649
|
-
|
|
55650
|
-
position: "absolute",
|
|
55651
|
-
width: "1px",
|
|
55652
|
-
height: "1px",
|
|
55653
|
-
padding: "0",
|
|
55654
|
-
margin: "-1px",
|
|
55655
|
-
overflow: "hidden",
|
|
55656
|
-
clip: "rect(0, 0, 0, 0)",
|
|
55657
|
-
whiteSpace: "nowrap",
|
|
55658
|
-
border: "0"
|
|
55659
|
-
}
|
|
55660
|
-
}, /* @__PURE__ */ React173.createElement(RadioButton, {
|
|
55661
|
-
"aria-label": t("donation.other-option.label", "Custom amount")
|
|
55662
|
-
}, t("donation.other-option.label", "Custom amount"))), otherInputElement && addOther ? applyInternalProps(otherInputElement, {
|
|
55624
|
+
productsById,
|
|
55625
|
+
selectedValue,
|
|
55626
|
+
onSelectProduct
|
|
55627
|
+
}) : null, otherInputElement && addOther ? applyInternalProps(otherInputElement, {
|
|
55663
55628
|
customAmount,
|
|
55664
55629
|
onCustomAmountInputChange,
|
|
55665
55630
|
currency,
|
|
@@ -55670,12 +55635,22 @@ var Control3 = ({ children, className, ...internal }) => {
|
|
|
55670
55635
|
}) : null);
|
|
55671
55636
|
};
|
|
55672
55637
|
var Options2 = ({ children, className, ...internal }) => {
|
|
55673
|
-
const { productsById } = internal;
|
|
55674
|
-
const { options, numberOfColumns } = useFieldPropsV2();
|
|
55638
|
+
const { productsById, selectedValue, onSelectProduct } = internal;
|
|
55639
|
+
const { options, numberOfColumns, disabled } = useFieldPropsV2();
|
|
55640
|
+
const { labelId } = useFieldAttributes();
|
|
55675
55641
|
const optionElement = findChildOfType(children, Options2.Option);
|
|
55676
|
-
return /* @__PURE__ */ React173.createElement(
|
|
55642
|
+
return /* @__PURE__ */ React173.createElement(ToggleButtonGroup, {
|
|
55677
55643
|
className,
|
|
55678
|
-
"data-columns": numberOfColumns
|
|
55644
|
+
"data-columns": numberOfColumns,
|
|
55645
|
+
"aria-labelledby": labelId,
|
|
55646
|
+
selectionMode: "single",
|
|
55647
|
+
selectedKeys: selectedValue ? [
|
|
55648
|
+
selectedValue
|
|
55649
|
+
] : [],
|
|
55650
|
+
onSelectionChange: (keys3) => onSelectProduct([
|
|
55651
|
+
...keys3
|
|
55652
|
+
][0]),
|
|
55653
|
+
isDisabled: disabled
|
|
55679
55654
|
}, options.map((option2) => {
|
|
55680
55655
|
const product = productsById[option2.value];
|
|
55681
55656
|
const price = product?.fixedPriceOptions?.price;
|
|
@@ -55688,7 +55663,7 @@ var Options2 = ({ children, className, ...internal }) => {
|
|
|
55688
55663
|
};
|
|
55689
55664
|
var Option2 = ({ children, className, ...internal }) => {
|
|
55690
55665
|
const { value, price } = internal;
|
|
55691
|
-
const { id: id6 } = useFieldPropsV2();
|
|
55666
|
+
const { id: id6, hasError } = useFieldPropsV2();
|
|
55692
55667
|
const { currency, regionalFormat } = useConfig();
|
|
55693
55668
|
const valueElement = findChildOfType(children, Option2.Value);
|
|
55694
55669
|
const currencyElement = findChildOfType(children, Option2.Currency);
|
|
@@ -55699,17 +55674,17 @@ var Option2 = ({ children, className, ...internal }) => {
|
|
|
55699
55674
|
});
|
|
55700
55675
|
const ref = useRef(null);
|
|
55701
55676
|
useFocusFieldEvent(() => {
|
|
55702
|
-
ref.current?.
|
|
55677
|
+
ref.current?.focus();
|
|
55703
55678
|
}, id6);
|
|
55704
55679
|
const renderedValue = valueElement ? applyInternalProps(valueElement, {
|
|
55705
55680
|
price
|
|
55706
55681
|
}) : null;
|
|
55707
|
-
return /* @__PURE__ */ React173.createElement(
|
|
55708
|
-
value
|
|
55709
|
-
}, /* @__PURE__ */ React173.createElement(RadioButton, {
|
|
55682
|
+
return /* @__PURE__ */ React173.createElement(ToggleButton, {
|
|
55683
|
+
id: value,
|
|
55710
55684
|
className,
|
|
55711
|
-
ref
|
|
55712
|
-
|
|
55685
|
+
ref,
|
|
55686
|
+
"data-invalid": hasError || void 0
|
|
55687
|
+
}, /* @__PURE__ */ React173.createElement(React173.Fragment, null, isCurrencyPrefixed && currencyElement, renderedValue, !isCurrencyPrefixed && currencyElement));
|
|
55713
55688
|
};
|
|
55714
55689
|
var OptionValue = ({ className, ...internal }) => {
|
|
55715
55690
|
const { price } = internal;
|