@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.cjs
CHANGED
|
@@ -51802,6 +51802,7 @@ var FIELDSET_RESET_STYLE = {
|
|
|
51802
51802
|
};
|
|
51803
51803
|
var AppointmentSlotPickerContext = React173.createContext(void 0);
|
|
51804
51804
|
var getTimezoneNoteId = (inputId) => `${inputId}-timezone-note`;
|
|
51805
|
+
var getDateTitleId = (inputId) => `${inputId}-date-title`;
|
|
51805
51806
|
var useAppointmentSlotPickerContext = () => {
|
|
51806
51807
|
const context = React173.useContext(AppointmentSlotPickerContext);
|
|
51807
51808
|
if (typeof context === "undefined") {
|
|
@@ -51930,15 +51931,13 @@ Dates.NextWeek = NextWeek;
|
|
|
51930
51931
|
Dates.Day = Day;
|
|
51931
51932
|
var RADIO_INPUT_SELECTOR = 'input[type="radio"]';
|
|
51932
51933
|
var Slots = ({ children, className, ...internal }) => {
|
|
51933
|
-
const { hasTimezoneNote } = internal;
|
|
51934
|
+
const { hasTimezoneNote, hasDateTitle } = internal;
|
|
51934
51935
|
const { slots, selectedSlotKey, selectSlot, selectedDateLabel, isReloadingSlots, timezoneLabel, pendingFocusIndex, consumePendingFocusIndex } = useAppointmentSlotPickerContext();
|
|
51935
51936
|
const { id: fieldId, disabled, readOnly, required, hasError } = useFieldPropsV2();
|
|
51936
51937
|
const { inputId, labelId: fieldLabelId, ariaDescribedBy } = useFieldAttributes();
|
|
51937
51938
|
const groupRef = React173.useRef(null);
|
|
51938
|
-
const slotsLabelId = `${inputId}-slots-label`;
|
|
51939
|
-
const labelElement = findChildOfType(children, Slots.Label);
|
|
51940
51939
|
const slotElement = findChildOfType(children, Slots.Slot) ?? /* @__PURE__ */ React173__default.default.createElement(Slots.Slot, null);
|
|
51941
|
-
const
|
|
51940
|
+
const isLabelledByDateTitle = !!hasDateTitle && !!selectedDateLabel;
|
|
51942
51941
|
const describedBy = [
|
|
51943
51942
|
ariaDescribedBy,
|
|
51944
51943
|
hasTimezoneNote && timezoneLabel ? getTimezoneNoteId(inputId) : void 0
|
|
@@ -51978,29 +51977,14 @@ var Slots = ({ children, className, ...internal }) => {
|
|
|
51978
51977
|
isReadOnly: readOnly,
|
|
51979
51978
|
isRequired: required,
|
|
51980
51979
|
isInvalid: hasError,
|
|
51981
|
-
"aria-labelledby":
|
|
51980
|
+
"aria-labelledby": isLabelledByDateTitle ? getDateTitleId(inputId) : fieldLabelId,
|
|
51982
51981
|
"aria-describedby": describedBy,
|
|
51983
51982
|
"data-refetch": isReloadingSlots || void 0
|
|
51984
|
-
}, applyInternalProps(
|
|
51985
|
-
labelId: slotsLabelId
|
|
51986
|
-
}), slots.map((slot) => applyInternalProps(slotElement, {
|
|
51983
|
+
}, slots.map((slot) => applyInternalProps(slotElement, {
|
|
51987
51984
|
key: slot.key,
|
|
51988
51985
|
slot
|
|
51989
51986
|
}))));
|
|
51990
51987
|
};
|
|
51991
|
-
var SlotsLabel = ({ children, className, ...internal }) => {
|
|
51992
|
-
const { selectedDateLabel } = useAppointmentSlotPickerContext();
|
|
51993
|
-
const { labelId } = internal;
|
|
51994
|
-
if (!selectedDateLabel) {
|
|
51995
|
-
return null;
|
|
51996
|
-
}
|
|
51997
|
-
return /* @__PURE__ */ React173__default.default.createElement("div", {
|
|
51998
|
-
id: labelId,
|
|
51999
|
-
className
|
|
52000
|
-
}, children ? children({
|
|
52001
|
-
label: selectedDateLabel
|
|
52002
|
-
}) : selectedDateLabel);
|
|
52003
|
-
};
|
|
52004
51988
|
var Slot = ({ children, className, ...internal }) => {
|
|
52005
51989
|
const { slot } = internal;
|
|
52006
51990
|
return /* @__PURE__ */ React173__default.default.createElement(reactAriaComponents.RadioField, {
|
|
@@ -52010,7 +51994,6 @@ var Slot = ({ children, className, ...internal }) => {
|
|
|
52010
51994
|
className
|
|
52011
51995
|
}, children ? children(slot) : slot.timeRange));
|
|
52012
51996
|
};
|
|
52013
|
-
Slots.Label = SlotsLabel;
|
|
52014
51997
|
Slots.Slot = Slot;
|
|
52015
51998
|
var import_cloneDeep = __toESM(require_cloneDeep());
|
|
52016
51999
|
var createIndicatorNode = (requiredIndicatorType, t, className) => {
|
|
@@ -55528,18 +55511,11 @@ function findProductWithDynamicPrice(products) {
|
|
|
55528
55511
|
function getCustomAmount(productValue, customAmountProduct) {
|
|
55529
55512
|
return productValue?.productId === customAmountProduct?.id ? String(productValue?.price ?? "") : "";
|
|
55530
55513
|
}
|
|
55531
|
-
function getProductValueOnCheckboxChange(productId, productValue, productsById) {
|
|
55532
|
-
const newValue = productValue?.productId === productId ? void 0 : productId;
|
|
55533
|
-
const product = newValue ? productsById[newValue] : void 0;
|
|
55534
|
-
return product ? [
|
|
55535
|
-
toProductValue(product, getProductPrice2(product))
|
|
55536
|
-
] : [];
|
|
55537
|
-
}
|
|
55538
55514
|
|
|
55539
55515
|
// ../form-fields/dist/esm/ui/donation-field/donation-field-headless.js
|
|
55540
55516
|
var Donation = ({ children }) => {
|
|
55541
|
-
const { id: id6, value, onChange,
|
|
55542
|
-
const { labelId } = useFieldAttributes();
|
|
55517
|
+
const { id: id6, value, onChange, required, onBlur, onFocus, validation, addOther, addOtherPlaceholder, FieldLayout } = useFieldPropsV2();
|
|
55518
|
+
const { inputId, labelId, ariaDescribedBy } = useFieldAttributes();
|
|
55543
55519
|
const { t } = useTranslation2();
|
|
55544
55520
|
const { currency, regionalFormat } = useConfig();
|
|
55545
55521
|
const productValue = value?.[0];
|
|
@@ -55559,13 +55535,15 @@ var Donation = ({ children }) => {
|
|
|
55559
55535
|
format: (source) => toLocaleDecimalSeparator(String(source ?? ""), regionalFormat),
|
|
55560
55536
|
regionalFormat
|
|
55561
55537
|
});
|
|
55562
|
-
const
|
|
55563
|
-
|
|
55538
|
+
const selectProduct = React173.useCallback((productId) => {
|
|
55539
|
+
const product = productId === void 0 ? void 0 : productsById[productId];
|
|
55540
|
+
onChange(product ? [
|
|
55541
|
+
toProductValue(product, getProductPrice2(product))
|
|
55542
|
+
] : []);
|
|
55564
55543
|
setCustomAmount("");
|
|
55565
55544
|
}, [
|
|
55566
55545
|
onChange,
|
|
55567
55546
|
productsById,
|
|
55568
|
-
productValue,
|
|
55569
55547
|
setCustomAmount
|
|
55570
55548
|
]);
|
|
55571
55549
|
const handleCustomAmountChange = React173.useCallback((amount) => {
|
|
@@ -55607,12 +55585,12 @@ var Donation = ({ children }) => {
|
|
|
55607
55585
|
const selectedValue = productValue?.productId || null;
|
|
55608
55586
|
const handleFocusCustomInput = React173.useCallback(() => {
|
|
55609
55587
|
if (customAmountProduct?.id && selectedValue !== customAmountProduct.id) {
|
|
55610
|
-
|
|
55588
|
+
selectProduct(customAmountProduct.id);
|
|
55611
55589
|
}
|
|
55612
55590
|
}, [
|
|
55613
55591
|
customAmountProduct?.id,
|
|
55614
55592
|
selectedValue,
|
|
55615
|
-
|
|
55593
|
+
selectProduct
|
|
55616
55594
|
]);
|
|
55617
55595
|
const labelElement = findChildOfType(children, Donation.Label);
|
|
55618
55596
|
const controlElement = findChildOfType(children, Donation.Control);
|
|
@@ -55621,17 +55599,17 @@ var Donation = ({ children }) => {
|
|
|
55621
55599
|
return /* @__PURE__ */ React173__default.default.createElement(FieldLayout, {
|
|
55622
55600
|
fieldId: id6,
|
|
55623
55601
|
renderLabel: () => labelElement,
|
|
55624
|
-
renderInput: () => /* @__PURE__ */ React173__default.default.createElement(
|
|
55625
|
-
|
|
55626
|
-
|
|
55627
|
-
|
|
55628
|
-
|
|
55629
|
-
isInvalid: hasError,
|
|
55630
|
-
isRequired: required,
|
|
55602
|
+
renderInput: () => /* @__PURE__ */ React173__default.default.createElement(FieldsetHeadless, {
|
|
55603
|
+
id: inputId,
|
|
55604
|
+
ariaLabelledBy: labelId,
|
|
55605
|
+
ariaDescribedBy,
|
|
55606
|
+
required,
|
|
55631
55607
|
onBlur,
|
|
55632
55608
|
onFocus
|
|
55633
55609
|
}, controlElement ? applyInternalProps(controlElement, {
|
|
55634
55610
|
productsById,
|
|
55611
|
+
selectedValue,
|
|
55612
|
+
onSelectProduct: selectProduct,
|
|
55635
55613
|
addOther,
|
|
55636
55614
|
customAmount,
|
|
55637
55615
|
onCustomAmountInputChange: handleCustomAmountInputChange,
|
|
@@ -55645,7 +55623,7 @@ var Donation = ({ children }) => {
|
|
|
55645
55623
|
});
|
|
55646
55624
|
};
|
|
55647
55625
|
var Control3 = ({ children, className, ...internal }) => {
|
|
55648
|
-
const { productsById, addOther, customAmount, onCustomAmountInputChange, currency, t, placeholder, customAmountProductId, onFocusCustomInput } = internal;
|
|
55626
|
+
const { productsById, selectedValue, onSelectProduct, addOther, customAmount, onCustomAmountInputChange, currency, t, placeholder, customAmountProductId, onFocusCustomInput } = internal;
|
|
55649
55627
|
const { hasError } = useFieldPropsV2();
|
|
55650
55628
|
const optionsElement = findChildOfType(children, Donation.Options);
|
|
55651
55629
|
const otherInputElement = findChildOfType(children, Donation.OtherInput);
|
|
@@ -55653,23 +55631,10 @@ var Control3 = ({ children, className, ...internal }) => {
|
|
|
55653
55631
|
className,
|
|
55654
55632
|
"data-invalid": hasError
|
|
55655
55633
|
}, optionsElement ? applyInternalProps(optionsElement, {
|
|
55656
|
-
productsById
|
|
55657
|
-
|
|
55658
|
-
|
|
55659
|
-
|
|
55660
|
-
position: "absolute",
|
|
55661
|
-
width: "1px",
|
|
55662
|
-
height: "1px",
|
|
55663
|
-
padding: "0",
|
|
55664
|
-
margin: "-1px",
|
|
55665
|
-
overflow: "hidden",
|
|
55666
|
-
clip: "rect(0, 0, 0, 0)",
|
|
55667
|
-
whiteSpace: "nowrap",
|
|
55668
|
-
border: "0"
|
|
55669
|
-
}
|
|
55670
|
-
}, /* @__PURE__ */ React173__default.default.createElement(reactAriaComponents.RadioButton, {
|
|
55671
|
-
"aria-label": t("donation.other-option.label", "Custom amount")
|
|
55672
|
-
}, t("donation.other-option.label", "Custom amount"))), otherInputElement && addOther ? applyInternalProps(otherInputElement, {
|
|
55634
|
+
productsById,
|
|
55635
|
+
selectedValue,
|
|
55636
|
+
onSelectProduct
|
|
55637
|
+
}) : null, otherInputElement && addOther ? applyInternalProps(otherInputElement, {
|
|
55673
55638
|
customAmount,
|
|
55674
55639
|
onCustomAmountInputChange,
|
|
55675
55640
|
currency,
|
|
@@ -55680,12 +55645,22 @@ var Control3 = ({ children, className, ...internal }) => {
|
|
|
55680
55645
|
}) : null);
|
|
55681
55646
|
};
|
|
55682
55647
|
var Options2 = ({ children, className, ...internal }) => {
|
|
55683
|
-
const { productsById } = internal;
|
|
55684
|
-
const { options, numberOfColumns } = useFieldPropsV2();
|
|
55648
|
+
const { productsById, selectedValue, onSelectProduct } = internal;
|
|
55649
|
+
const { options, numberOfColumns, disabled } = useFieldPropsV2();
|
|
55650
|
+
const { labelId } = useFieldAttributes();
|
|
55685
55651
|
const optionElement = findChildOfType(children, Options2.Option);
|
|
55686
|
-
return /* @__PURE__ */ React173__default.default.createElement(
|
|
55652
|
+
return /* @__PURE__ */ React173__default.default.createElement(reactAriaComponents.ToggleButtonGroup, {
|
|
55687
55653
|
className,
|
|
55688
|
-
"data-columns": numberOfColumns
|
|
55654
|
+
"data-columns": numberOfColumns,
|
|
55655
|
+
"aria-labelledby": labelId,
|
|
55656
|
+
selectionMode: "single",
|
|
55657
|
+
selectedKeys: selectedValue ? [
|
|
55658
|
+
selectedValue
|
|
55659
|
+
] : [],
|
|
55660
|
+
onSelectionChange: (keys3) => onSelectProduct([
|
|
55661
|
+
...keys3
|
|
55662
|
+
][0]),
|
|
55663
|
+
isDisabled: disabled
|
|
55689
55664
|
}, options.map((option2) => {
|
|
55690
55665
|
const product = productsById[option2.value];
|
|
55691
55666
|
const price = product?.fixedPriceOptions?.price;
|
|
@@ -55698,7 +55673,7 @@ var Options2 = ({ children, className, ...internal }) => {
|
|
|
55698
55673
|
};
|
|
55699
55674
|
var Option2 = ({ children, className, ...internal }) => {
|
|
55700
55675
|
const { value, price } = internal;
|
|
55701
|
-
const { id: id6 } = useFieldPropsV2();
|
|
55676
|
+
const { id: id6, hasError } = useFieldPropsV2();
|
|
55702
55677
|
const { currency, regionalFormat } = useConfig();
|
|
55703
55678
|
const valueElement = findChildOfType(children, Option2.Value);
|
|
55704
55679
|
const currencyElement = findChildOfType(children, Option2.Currency);
|
|
@@ -55709,17 +55684,17 @@ var Option2 = ({ children, className, ...internal }) => {
|
|
|
55709
55684
|
});
|
|
55710
55685
|
const ref = React173.useRef(null);
|
|
55711
55686
|
useFocusFieldEvent(() => {
|
|
55712
|
-
ref.current?.
|
|
55687
|
+
ref.current?.focus();
|
|
55713
55688
|
}, id6);
|
|
55714
55689
|
const renderedValue = valueElement ? applyInternalProps(valueElement, {
|
|
55715
55690
|
price
|
|
55716
55691
|
}) : null;
|
|
55717
|
-
return /* @__PURE__ */ React173__default.default.createElement(reactAriaComponents.
|
|
55718
|
-
value
|
|
55719
|
-
}, /* @__PURE__ */ React173__default.default.createElement(reactAriaComponents.RadioButton, {
|
|
55692
|
+
return /* @__PURE__ */ React173__default.default.createElement(reactAriaComponents.ToggleButton, {
|
|
55693
|
+
id: value,
|
|
55720
55694
|
className,
|
|
55721
|
-
ref
|
|
55722
|
-
|
|
55695
|
+
ref,
|
|
55696
|
+
"data-invalid": hasError || void 0
|
|
55697
|
+
}, /* @__PURE__ */ React173__default.default.createElement(React173__default.default.Fragment, null, isCurrencyPrefixed && currencyElement, renderedValue, !isCurrencyPrefixed && currencyElement));
|
|
55723
55698
|
};
|
|
55724
55699
|
var OptionValue = ({ className, ...internal }) => {
|
|
55725
55700
|
const { price } = internal;
|