@wix/form-public 0.529.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 +42 -50
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +0 -11
- package/dist/index.css.map +1 -1
- package/dist/index.js +43 -51
- 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;
|
|
@@ -55501,18 +55501,11 @@ function findProductWithDynamicPrice(products) {
|
|
|
55501
55501
|
function getCustomAmount(productValue, customAmountProduct) {
|
|
55502
55502
|
return productValue?.productId === customAmountProduct?.id ? String(productValue?.price ?? "") : "";
|
|
55503
55503
|
}
|
|
55504
|
-
function getProductValueOnCheckboxChange(productId, productValue, productsById) {
|
|
55505
|
-
const newValue = productValue?.productId === productId ? void 0 : productId;
|
|
55506
|
-
const product = newValue ? productsById[newValue] : void 0;
|
|
55507
|
-
return product ? [
|
|
55508
|
-
toProductValue(product, getProductPrice2(product))
|
|
55509
|
-
] : [];
|
|
55510
|
-
}
|
|
55511
55504
|
|
|
55512
55505
|
// ../form-fields/dist/esm/ui/donation-field/donation-field-headless.js
|
|
55513
55506
|
var Donation = ({ children }) => {
|
|
55514
|
-
const { id: id6, value, onChange,
|
|
55515
|
-
const { labelId } = useFieldAttributes();
|
|
55507
|
+
const { id: id6, value, onChange, required, onBlur, onFocus, validation, addOther, addOtherPlaceholder, FieldLayout } = useFieldPropsV2();
|
|
55508
|
+
const { inputId, labelId, ariaDescribedBy } = useFieldAttributes();
|
|
55516
55509
|
const { t } = useTranslation2();
|
|
55517
55510
|
const { currency, regionalFormat } = useConfig();
|
|
55518
55511
|
const productValue = value?.[0];
|
|
@@ -55532,13 +55525,15 @@ var Donation = ({ children }) => {
|
|
|
55532
55525
|
format: (source) => toLocaleDecimalSeparator(String(source ?? ""), regionalFormat),
|
|
55533
55526
|
regionalFormat
|
|
55534
55527
|
});
|
|
55535
|
-
const
|
|
55536
|
-
|
|
55528
|
+
const selectProduct = useCallback((productId) => {
|
|
55529
|
+
const product = productId === void 0 ? void 0 : productsById[productId];
|
|
55530
|
+
onChange(product ? [
|
|
55531
|
+
toProductValue(product, getProductPrice2(product))
|
|
55532
|
+
] : []);
|
|
55537
55533
|
setCustomAmount("");
|
|
55538
55534
|
}, [
|
|
55539
55535
|
onChange,
|
|
55540
55536
|
productsById,
|
|
55541
|
-
productValue,
|
|
55542
55537
|
setCustomAmount
|
|
55543
55538
|
]);
|
|
55544
55539
|
const handleCustomAmountChange = useCallback((amount) => {
|
|
@@ -55580,12 +55575,12 @@ var Donation = ({ children }) => {
|
|
|
55580
55575
|
const selectedValue = productValue?.productId || null;
|
|
55581
55576
|
const handleFocusCustomInput = useCallback(() => {
|
|
55582
55577
|
if (customAmountProduct?.id && selectedValue !== customAmountProduct.id) {
|
|
55583
|
-
|
|
55578
|
+
selectProduct(customAmountProduct.id);
|
|
55584
55579
|
}
|
|
55585
55580
|
}, [
|
|
55586
55581
|
customAmountProduct?.id,
|
|
55587
55582
|
selectedValue,
|
|
55588
|
-
|
|
55583
|
+
selectProduct
|
|
55589
55584
|
]);
|
|
55590
55585
|
const labelElement = findChildOfType(children, Donation.Label);
|
|
55591
55586
|
const controlElement = findChildOfType(children, Donation.Control);
|
|
@@ -55594,17 +55589,17 @@ var Donation = ({ children }) => {
|
|
|
55594
55589
|
return /* @__PURE__ */ React173.createElement(FieldLayout, {
|
|
55595
55590
|
fieldId: id6,
|
|
55596
55591
|
renderLabel: () => labelElement,
|
|
55597
|
-
renderInput: () => /* @__PURE__ */ React173.createElement(
|
|
55598
|
-
|
|
55599
|
-
|
|
55600
|
-
|
|
55601
|
-
|
|
55602
|
-
isInvalid: hasError,
|
|
55603
|
-
isRequired: required,
|
|
55592
|
+
renderInput: () => /* @__PURE__ */ React173.createElement(FieldsetHeadless, {
|
|
55593
|
+
id: inputId,
|
|
55594
|
+
ariaLabelledBy: labelId,
|
|
55595
|
+
ariaDescribedBy,
|
|
55596
|
+
required,
|
|
55604
55597
|
onBlur,
|
|
55605
55598
|
onFocus
|
|
55606
55599
|
}, controlElement ? applyInternalProps(controlElement, {
|
|
55607
55600
|
productsById,
|
|
55601
|
+
selectedValue,
|
|
55602
|
+
onSelectProduct: selectProduct,
|
|
55608
55603
|
addOther,
|
|
55609
55604
|
customAmount,
|
|
55610
55605
|
onCustomAmountInputChange: handleCustomAmountInputChange,
|
|
@@ -55618,7 +55613,7 @@ var Donation = ({ children }) => {
|
|
|
55618
55613
|
});
|
|
55619
55614
|
};
|
|
55620
55615
|
var Control3 = ({ children, className, ...internal }) => {
|
|
55621
|
-
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;
|
|
55622
55617
|
const { hasError } = useFieldPropsV2();
|
|
55623
55618
|
const optionsElement = findChildOfType(children, Donation.Options);
|
|
55624
55619
|
const otherInputElement = findChildOfType(children, Donation.OtherInput);
|
|
@@ -55626,23 +55621,10 @@ var Control3 = ({ children, className, ...internal }) => {
|
|
|
55626
55621
|
className,
|
|
55627
55622
|
"data-invalid": hasError
|
|
55628
55623
|
}, optionsElement ? applyInternalProps(optionsElement, {
|
|
55629
|
-
productsById
|
|
55630
|
-
|
|
55631
|
-
|
|
55632
|
-
|
|
55633
|
-
position: "absolute",
|
|
55634
|
-
width: "1px",
|
|
55635
|
-
height: "1px",
|
|
55636
|
-
padding: "0",
|
|
55637
|
-
margin: "-1px",
|
|
55638
|
-
overflow: "hidden",
|
|
55639
|
-
clip: "rect(0, 0, 0, 0)",
|
|
55640
|
-
whiteSpace: "nowrap",
|
|
55641
|
-
border: "0"
|
|
55642
|
-
}
|
|
55643
|
-
}, /* @__PURE__ */ React173.createElement(RadioButton, {
|
|
55644
|
-
"aria-label": t("donation.other-option.label", "Custom amount")
|
|
55645
|
-
}, t("donation.other-option.label", "Custom amount"))), otherInputElement && addOther ? applyInternalProps(otherInputElement, {
|
|
55624
|
+
productsById,
|
|
55625
|
+
selectedValue,
|
|
55626
|
+
onSelectProduct
|
|
55627
|
+
}) : null, otherInputElement && addOther ? applyInternalProps(otherInputElement, {
|
|
55646
55628
|
customAmount,
|
|
55647
55629
|
onCustomAmountInputChange,
|
|
55648
55630
|
currency,
|
|
@@ -55653,12 +55635,22 @@ var Control3 = ({ children, className, ...internal }) => {
|
|
|
55653
55635
|
}) : null);
|
|
55654
55636
|
};
|
|
55655
55637
|
var Options2 = ({ children, className, ...internal }) => {
|
|
55656
|
-
const { productsById } = internal;
|
|
55657
|
-
const { options, numberOfColumns } = useFieldPropsV2();
|
|
55638
|
+
const { productsById, selectedValue, onSelectProduct } = internal;
|
|
55639
|
+
const { options, numberOfColumns, disabled } = useFieldPropsV2();
|
|
55640
|
+
const { labelId } = useFieldAttributes();
|
|
55658
55641
|
const optionElement = findChildOfType(children, Options2.Option);
|
|
55659
|
-
return /* @__PURE__ */ React173.createElement(
|
|
55642
|
+
return /* @__PURE__ */ React173.createElement(ToggleButtonGroup, {
|
|
55660
55643
|
className,
|
|
55661
|
-
"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
|
|
55662
55654
|
}, options.map((option2) => {
|
|
55663
55655
|
const product = productsById[option2.value];
|
|
55664
55656
|
const price = product?.fixedPriceOptions?.price;
|
|
@@ -55671,7 +55663,7 @@ var Options2 = ({ children, className, ...internal }) => {
|
|
|
55671
55663
|
};
|
|
55672
55664
|
var Option2 = ({ children, className, ...internal }) => {
|
|
55673
55665
|
const { value, price } = internal;
|
|
55674
|
-
const { id: id6 } = useFieldPropsV2();
|
|
55666
|
+
const { id: id6, hasError } = useFieldPropsV2();
|
|
55675
55667
|
const { currency, regionalFormat } = useConfig();
|
|
55676
55668
|
const valueElement = findChildOfType(children, Option2.Value);
|
|
55677
55669
|
const currencyElement = findChildOfType(children, Option2.Currency);
|
|
@@ -55682,17 +55674,17 @@ var Option2 = ({ children, className, ...internal }) => {
|
|
|
55682
55674
|
});
|
|
55683
55675
|
const ref = useRef(null);
|
|
55684
55676
|
useFocusFieldEvent(() => {
|
|
55685
|
-
ref.current?.
|
|
55677
|
+
ref.current?.focus();
|
|
55686
55678
|
}, id6);
|
|
55687
55679
|
const renderedValue = valueElement ? applyInternalProps(valueElement, {
|
|
55688
55680
|
price
|
|
55689
55681
|
}) : null;
|
|
55690
|
-
return /* @__PURE__ */ React173.createElement(
|
|
55691
|
-
value
|
|
55692
|
-
}, /* @__PURE__ */ React173.createElement(RadioButton, {
|
|
55682
|
+
return /* @__PURE__ */ React173.createElement(ToggleButton, {
|
|
55683
|
+
id: value,
|
|
55693
55684
|
className,
|
|
55694
|
-
ref
|
|
55695
|
-
|
|
55685
|
+
ref,
|
|
55686
|
+
"data-invalid": hasError || void 0
|
|
55687
|
+
}, /* @__PURE__ */ React173.createElement(React173.Fragment, null, isCurrencyPrefixed && currencyElement, renderedValue, !isCurrencyPrefixed && currencyElement));
|
|
55696
55688
|
};
|
|
55697
55689
|
var OptionValue = ({ className, ...internal }) => {
|
|
55698
55690
|
const { price } = internal;
|