@wix/form-public 0.96.0 → 0.98.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 +112 -68
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +113 -69
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -25986,7 +25986,7 @@ function useFieldAttributes2() {
|
|
|
25986
25986
|
|
|
25987
25987
|
// ../form-fields/dist/esm/ui/form/components/form/input-field.js
|
|
25988
25988
|
var InputField = (_ref) => {
|
|
25989
|
-
var _field$properties;
|
|
25989
|
+
var _field$properties, _field$properties2;
|
|
25990
25990
|
let {
|
|
25991
25991
|
field,
|
|
25992
25992
|
errors,
|
|
@@ -26058,6 +26058,7 @@ var InputField = (_ref) => {
|
|
|
26058
26058
|
const FieldComponent = componentsById[field.fieldType];
|
|
26059
26059
|
const fieldProps = {
|
|
26060
26060
|
...field.properties,
|
|
26061
|
+
readOnly: Boolean((_field$properties2 = field.properties) == null ? void 0 : _field$properties2.readOnly),
|
|
26061
26062
|
onChange: handleChange,
|
|
26062
26063
|
onBlur: _onBlur,
|
|
26063
26064
|
onFocus: _onFocus,
|
|
@@ -32049,13 +32050,30 @@ RichLabel.Required = Required;
|
|
|
32049
32050
|
|
|
32050
32051
|
// ../form-fields/dist/esm/ui/checkbox-field/checkbox-field-headless.js
|
|
32051
32052
|
var Checkbox = (_ref) => {
|
|
32053
|
+
let {
|
|
32054
|
+
children
|
|
32055
|
+
} = _ref;
|
|
32056
|
+
const {
|
|
32057
|
+
id,
|
|
32058
|
+
FieldLayout
|
|
32059
|
+
} = useFieldPropsV2();
|
|
32060
|
+
const checkboxElement = findChildOfType(children, Checkbox.Checkbox);
|
|
32061
|
+
const descriptionElement = findChildOfType(children, Checkbox.Description);
|
|
32062
|
+
const errorElement = findChildOfType(children, Checkbox.Error);
|
|
32063
|
+
return /* @__PURE__ */ React40__namespace.default.createElement(FieldLayout, {
|
|
32064
|
+
fieldId: id,
|
|
32065
|
+
renderLabel: () => null,
|
|
32066
|
+
renderInput: () => checkboxElement,
|
|
32067
|
+
renderDescription: () => /* @__PURE__ */ React40__namespace.default.createElement(React40__namespace.default.Fragment, null, descriptionElement, errorElement)
|
|
32068
|
+
});
|
|
32069
|
+
};
|
|
32070
|
+
var CheckboxContainer = (_ref2) => {
|
|
32052
32071
|
let {
|
|
32053
32072
|
children,
|
|
32054
32073
|
className
|
|
32055
|
-
} =
|
|
32074
|
+
} = _ref2;
|
|
32056
32075
|
const {
|
|
32057
32076
|
id,
|
|
32058
|
-
FieldLayout,
|
|
32059
32077
|
value,
|
|
32060
32078
|
onChange,
|
|
32061
32079
|
disabled,
|
|
@@ -32072,42 +32090,36 @@ var Checkbox = (_ref) => {
|
|
|
32072
32090
|
var _ref$current;
|
|
32073
32091
|
(_ref$current = ref.current) == null || _ref$current.focus();
|
|
32074
32092
|
}, id);
|
|
32075
|
-
const labelElement = findChildOfType(children,
|
|
32076
|
-
const inputElement = findChildOfType(children,
|
|
32077
|
-
const descriptionElement = findChildOfType(children, Checkbox.Description);
|
|
32078
|
-
const errorElement = findChildOfType(children, Checkbox.Error);
|
|
32093
|
+
const labelElement = findChildOfType(children, CheckboxContainer.Label);
|
|
32094
|
+
const inputElement = findChildOfType(children, CheckboxContainer.Input);
|
|
32079
32095
|
const handleChange = React40.useCallback((isSelected) => {
|
|
32080
32096
|
onChange(isSelected);
|
|
32081
32097
|
}, [onChange]);
|
|
32082
|
-
return /* @__PURE__ */ React40__namespace.default.createElement(
|
|
32083
|
-
|
|
32084
|
-
|
|
32085
|
-
|
|
32086
|
-
|
|
32087
|
-
|
|
32088
|
-
|
|
32089
|
-
|
|
32090
|
-
|
|
32091
|
-
|
|
32092
|
-
|
|
32093
|
-
|
|
32094
|
-
onFocus,
|
|
32095
|
-
className
|
|
32096
|
-
}, () => /* @__PURE__ */ React40__namespace.default.createElement(React40__namespace.default.Fragment, null, inputElement, labelElement)),
|
|
32097
|
-
renderDescription: () => /* @__PURE__ */ React40__namespace.default.createElement(React40__namespace.default.Fragment, null, descriptionElement, errorElement)
|
|
32098
|
-
});
|
|
32098
|
+
return /* @__PURE__ */ React40__namespace.default.createElement(reactAriaComponents.Checkbox, {
|
|
32099
|
+
ref,
|
|
32100
|
+
id: inputId,
|
|
32101
|
+
"aria-describedby": ariaDescribedBy,
|
|
32102
|
+
isSelected: Boolean(value),
|
|
32103
|
+
onChange: handleChange,
|
|
32104
|
+
isDisabled: disabled,
|
|
32105
|
+
isRequired: required,
|
|
32106
|
+
onBlur,
|
|
32107
|
+
onFocus,
|
|
32108
|
+
className
|
|
32109
|
+
}, () => /* @__PURE__ */ React40__namespace.default.createElement(React40__namespace.default.Fragment, null, inputElement, labelElement));
|
|
32099
32110
|
};
|
|
32100
|
-
var Input = (
|
|
32111
|
+
var Input = (_ref3) => {
|
|
32101
32112
|
let {
|
|
32102
32113
|
className
|
|
32103
|
-
} =
|
|
32114
|
+
} = _ref3;
|
|
32104
32115
|
return /* @__PURE__ */ React40__namespace.default.createElement("div", {
|
|
32105
32116
|
"aria-hidden": "true",
|
|
32106
32117
|
className
|
|
32107
32118
|
});
|
|
32108
32119
|
};
|
|
32109
|
-
|
|
32110
|
-
|
|
32120
|
+
CheckboxContainer.Label = RichLabel;
|
|
32121
|
+
CheckboxContainer.Input = Input;
|
|
32122
|
+
Checkbox.Checkbox = CheckboxContainer;
|
|
32111
32123
|
Checkbox.Description = Description;
|
|
32112
32124
|
Checkbox.Error = Error2;
|
|
32113
32125
|
|
|
@@ -32388,12 +32400,33 @@ var Options = (_ref2) => {
|
|
|
32388
32400
|
isOther: true
|
|
32389
32401
|
}));
|
|
32390
32402
|
};
|
|
32391
|
-
var
|
|
32403
|
+
var OptionInput = (_ref3) => {
|
|
32404
|
+
let {
|
|
32405
|
+
className
|
|
32406
|
+
} = _ref3;
|
|
32407
|
+
return /* @__PURE__ */ React40__namespace.default.createElement("div", {
|
|
32408
|
+
"aria-hidden": "true",
|
|
32409
|
+
className
|
|
32410
|
+
});
|
|
32411
|
+
};
|
|
32412
|
+
var OptionLabel = (_ref4) => {
|
|
32413
|
+
let {
|
|
32414
|
+
className,
|
|
32415
|
+
...internal
|
|
32416
|
+
} = _ref4;
|
|
32417
|
+
const {
|
|
32418
|
+
label
|
|
32419
|
+
} = internal;
|
|
32420
|
+
return /* @__PURE__ */ React40__namespace.default.createElement("span", {
|
|
32421
|
+
className
|
|
32422
|
+
}, label);
|
|
32423
|
+
};
|
|
32424
|
+
var Checkbox2 = (_ref5) => {
|
|
32392
32425
|
let {
|
|
32393
32426
|
children,
|
|
32394
32427
|
className,
|
|
32395
32428
|
...internal
|
|
32396
|
-
} =
|
|
32429
|
+
} = _ref5;
|
|
32397
32430
|
const {
|
|
32398
32431
|
value,
|
|
32399
32432
|
label,
|
|
@@ -32408,9 +32441,7 @@ var Option = (_ref3) => {
|
|
|
32408
32441
|
disabled,
|
|
32409
32442
|
hasError,
|
|
32410
32443
|
options,
|
|
32411
|
-
addOtherLabel
|
|
32412
|
-
addOtherPlaceholder,
|
|
32413
|
-
otherInputCharacterLimit
|
|
32444
|
+
addOtherLabel
|
|
32414
32445
|
} = props;
|
|
32415
32446
|
const checkboxRef = React40.useRef(null);
|
|
32416
32447
|
useFocusFieldEvent(() => {
|
|
@@ -32421,17 +32452,9 @@ var Option = (_ref3) => {
|
|
|
32421
32452
|
});
|
|
32422
32453
|
}
|
|
32423
32454
|
}, fieldId);
|
|
32424
|
-
const labelElement = findChildOfType(children,
|
|
32425
|
-
const inputElement = findChildOfType(children,
|
|
32426
|
-
const otherInputElement = findChildOfType(children, Option.OtherInput);
|
|
32455
|
+
const labelElement = findChildOfType(children, Checkbox2.Label);
|
|
32456
|
+
const inputElement = findChildOfType(children, Checkbox2.Input);
|
|
32427
32457
|
const _value = React40.useMemo(() => fieldValue || [], [fieldValue]);
|
|
32428
|
-
const isOtherSelected = React40.useMemo(() => {
|
|
32429
|
-
if (!isOther) {
|
|
32430
|
-
return false;
|
|
32431
|
-
}
|
|
32432
|
-
const optionsValues = getOptionsValues(options || []);
|
|
32433
|
-
return getIsOtherOptionSelected(_value, optionsValues);
|
|
32434
|
-
}, [isOther, _value, options]);
|
|
32435
32458
|
const actualValue = React40.useMemo(() => {
|
|
32436
32459
|
if (isOther) {
|
|
32437
32460
|
return _value.find((val) => val === label || val.startsWith(`${addOtherLabel}: `)) || label;
|
|
@@ -32457,6 +32480,49 @@ var Option = (_ref3) => {
|
|
|
32457
32480
|
"data-hook": `checkbox-${label}`
|
|
32458
32481
|
}, inputElement, applyInternalProps(labelElement, {
|
|
32459
32482
|
label
|
|
32483
|
+
}));
|
|
32484
|
+
};
|
|
32485
|
+
Checkbox2.Label = OptionLabel;
|
|
32486
|
+
Checkbox2.Input = OptionInput;
|
|
32487
|
+
var Option = (_ref6) => {
|
|
32488
|
+
let {
|
|
32489
|
+
children,
|
|
32490
|
+
...internal
|
|
32491
|
+
} = _ref6;
|
|
32492
|
+
const {
|
|
32493
|
+
value,
|
|
32494
|
+
label,
|
|
32495
|
+
isFirst = false,
|
|
32496
|
+
isOther = false,
|
|
32497
|
+
fieldId
|
|
32498
|
+
} = internal;
|
|
32499
|
+
const props = useFieldPropsV2();
|
|
32500
|
+
const {
|
|
32501
|
+
value: fieldValue,
|
|
32502
|
+
onChange,
|
|
32503
|
+
options,
|
|
32504
|
+
addOtherLabel,
|
|
32505
|
+
addOtherPlaceholder,
|
|
32506
|
+
otherInputCharacterLimit,
|
|
32507
|
+
disabled,
|
|
32508
|
+
hasError
|
|
32509
|
+
} = props;
|
|
32510
|
+
const checkboxElement = findChildOfType(children, Checkbox2);
|
|
32511
|
+
const otherInputElement = findChildOfType(children, OtherInput);
|
|
32512
|
+
const _value = React40.useMemo(() => fieldValue || [], [fieldValue]);
|
|
32513
|
+
const isOtherSelected = React40.useMemo(() => {
|
|
32514
|
+
if (!isOther) {
|
|
32515
|
+
return false;
|
|
32516
|
+
}
|
|
32517
|
+
const optionsValues = getOptionsValues(options || []);
|
|
32518
|
+
return getIsOtherOptionSelected(_value, optionsValues);
|
|
32519
|
+
}, [isOther, _value, options]);
|
|
32520
|
+
return /* @__PURE__ */ React40__namespace.default.createElement(React40__namespace.default.Fragment, null, applyInternalProps(checkboxElement, {
|
|
32521
|
+
value,
|
|
32522
|
+
label,
|
|
32523
|
+
isFirst,
|
|
32524
|
+
isOther,
|
|
32525
|
+
fieldId
|
|
32460
32526
|
}), isOther && isOtherSelected && applyInternalProps(otherInputElement, {
|
|
32461
32527
|
fieldValue: _value,
|
|
32462
32528
|
onChange,
|
|
@@ -32470,32 +32536,11 @@ var Option = (_ref3) => {
|
|
|
32470
32536
|
options
|
|
32471
32537
|
}));
|
|
32472
32538
|
};
|
|
32473
|
-
var
|
|
32474
|
-
let {
|
|
32475
|
-
className
|
|
32476
|
-
} = _ref4;
|
|
32477
|
-
return /* @__PURE__ */ React40__namespace.default.createElement("div", {
|
|
32478
|
-
"aria-hidden": "true",
|
|
32479
|
-
className
|
|
32480
|
-
});
|
|
32481
|
-
};
|
|
32482
|
-
var OptionLabel = (_ref5) => {
|
|
32483
|
-
let {
|
|
32484
|
-
className,
|
|
32485
|
-
...internal
|
|
32486
|
-
} = _ref5;
|
|
32487
|
-
const {
|
|
32488
|
-
label
|
|
32489
|
-
} = internal;
|
|
32490
|
-
return /* @__PURE__ */ React40__namespace.default.createElement("span", {
|
|
32491
|
-
className
|
|
32492
|
-
}, label);
|
|
32493
|
-
};
|
|
32494
|
-
var OtherInput = (_ref6) => {
|
|
32539
|
+
var OtherInput = (_ref7) => {
|
|
32495
32540
|
let {
|
|
32496
32541
|
className,
|
|
32497
32542
|
...internal
|
|
32498
|
-
} =
|
|
32543
|
+
} = _ref7;
|
|
32499
32544
|
const {
|
|
32500
32545
|
fieldValue,
|
|
32501
32546
|
onChange,
|
|
@@ -32546,8 +32591,7 @@ var OtherInput = (_ref6) => {
|
|
|
32546
32591
|
CheckboxGroup.Label = Label;
|
|
32547
32592
|
CheckboxGroup.Options = Options;
|
|
32548
32593
|
Options.Option = Option;
|
|
32549
|
-
Option.
|
|
32550
|
-
Option.Input = OptionInput;
|
|
32594
|
+
Option.Checkbox = Checkbox2;
|
|
32551
32595
|
Option.OtherInput = OtherInput;
|
|
32552
32596
|
CheckboxGroup.Description = Description;
|
|
32553
32597
|
CheckboxGroup.Error = Error2;
|