@wix/form-public 0.97.0 → 0.99.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 +110 -67
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +6 -0
- package/dist/index.css.map +1 -1
- package/dist/index.js +111 -68
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -32050,13 +32050,30 @@ RichLabel.Required = Required;
|
|
|
32050
32050
|
|
|
32051
32051
|
// ../form-fields/dist/esm/ui/checkbox-field/checkbox-field-headless.js
|
|
32052
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) => {
|
|
32053
32071
|
let {
|
|
32054
32072
|
children,
|
|
32055
32073
|
className
|
|
32056
|
-
} =
|
|
32074
|
+
} = _ref2;
|
|
32057
32075
|
const {
|
|
32058
32076
|
id,
|
|
32059
|
-
FieldLayout,
|
|
32060
32077
|
value,
|
|
32061
32078
|
onChange,
|
|
32062
32079
|
disabled,
|
|
@@ -32073,42 +32090,36 @@ var Checkbox = (_ref) => {
|
|
|
32073
32090
|
var _ref$current;
|
|
32074
32091
|
(_ref$current = ref.current) == null || _ref$current.focus();
|
|
32075
32092
|
}, id);
|
|
32076
|
-
const labelElement = findChildOfType(children,
|
|
32077
|
-
const inputElement = findChildOfType(children,
|
|
32078
|
-
const descriptionElement = findChildOfType(children, Checkbox.Description);
|
|
32079
|
-
const errorElement = findChildOfType(children, Checkbox.Error);
|
|
32093
|
+
const labelElement = findChildOfType(children, CheckboxContainer.Label);
|
|
32094
|
+
const inputElement = findChildOfType(children, CheckboxContainer.Input);
|
|
32080
32095
|
const handleChange = React40.useCallback((isSelected) => {
|
|
32081
32096
|
onChange(isSelected);
|
|
32082
32097
|
}, [onChange]);
|
|
32083
|
-
return /* @__PURE__ */ React40__namespace.default.createElement(
|
|
32084
|
-
|
|
32085
|
-
|
|
32086
|
-
|
|
32087
|
-
|
|
32088
|
-
|
|
32089
|
-
|
|
32090
|
-
|
|
32091
|
-
|
|
32092
|
-
|
|
32093
|
-
|
|
32094
|
-
|
|
32095
|
-
onFocus,
|
|
32096
|
-
className
|
|
32097
|
-
}, () => /* @__PURE__ */ React40__namespace.default.createElement(React40__namespace.default.Fragment, null, inputElement, labelElement)),
|
|
32098
|
-
renderDescription: () => /* @__PURE__ */ React40__namespace.default.createElement(React40__namespace.default.Fragment, null, descriptionElement, errorElement)
|
|
32099
|
-
});
|
|
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));
|
|
32100
32110
|
};
|
|
32101
|
-
var Input = (
|
|
32111
|
+
var Input = (_ref3) => {
|
|
32102
32112
|
let {
|
|
32103
32113
|
className
|
|
32104
|
-
} =
|
|
32114
|
+
} = _ref3;
|
|
32105
32115
|
return /* @__PURE__ */ React40__namespace.default.createElement("div", {
|
|
32106
32116
|
"aria-hidden": "true",
|
|
32107
32117
|
className
|
|
32108
32118
|
});
|
|
32109
32119
|
};
|
|
32110
|
-
|
|
32111
|
-
|
|
32120
|
+
CheckboxContainer.Label = RichLabel;
|
|
32121
|
+
CheckboxContainer.Input = Input;
|
|
32122
|
+
Checkbox.Checkbox = CheckboxContainer;
|
|
32112
32123
|
Checkbox.Description = Description;
|
|
32113
32124
|
Checkbox.Error = Error2;
|
|
32114
32125
|
|
|
@@ -32389,12 +32400,33 @@ var Options = (_ref2) => {
|
|
|
32389
32400
|
isOther: true
|
|
32390
32401
|
}));
|
|
32391
32402
|
};
|
|
32392
|
-
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) => {
|
|
32393
32425
|
let {
|
|
32394
32426
|
children,
|
|
32395
32427
|
className,
|
|
32396
32428
|
...internal
|
|
32397
|
-
} =
|
|
32429
|
+
} = _ref5;
|
|
32398
32430
|
const {
|
|
32399
32431
|
value,
|
|
32400
32432
|
label,
|
|
@@ -32409,9 +32441,7 @@ var Option = (_ref3) => {
|
|
|
32409
32441
|
disabled,
|
|
32410
32442
|
hasError,
|
|
32411
32443
|
options,
|
|
32412
|
-
addOtherLabel
|
|
32413
|
-
addOtherPlaceholder,
|
|
32414
|
-
otherInputCharacterLimit
|
|
32444
|
+
addOtherLabel
|
|
32415
32445
|
} = props;
|
|
32416
32446
|
const checkboxRef = React40.useRef(null);
|
|
32417
32447
|
useFocusFieldEvent(() => {
|
|
@@ -32422,17 +32452,9 @@ var Option = (_ref3) => {
|
|
|
32422
32452
|
});
|
|
32423
32453
|
}
|
|
32424
32454
|
}, fieldId);
|
|
32425
|
-
const labelElement = findChildOfType(children,
|
|
32426
|
-
const inputElement = findChildOfType(children,
|
|
32427
|
-
const otherInputElement = findChildOfType(children, Option.OtherInput);
|
|
32455
|
+
const labelElement = findChildOfType(children, Checkbox2.Label);
|
|
32456
|
+
const inputElement = findChildOfType(children, Checkbox2.Input);
|
|
32428
32457
|
const _value = React40.useMemo(() => fieldValue || [], [fieldValue]);
|
|
32429
|
-
const isOtherSelected = React40.useMemo(() => {
|
|
32430
|
-
if (!isOther) {
|
|
32431
|
-
return false;
|
|
32432
|
-
}
|
|
32433
|
-
const optionsValues = getOptionsValues(options || []);
|
|
32434
|
-
return getIsOtherOptionSelected(_value, optionsValues);
|
|
32435
|
-
}, [isOther, _value, options]);
|
|
32436
32458
|
const actualValue = React40.useMemo(() => {
|
|
32437
32459
|
if (isOther) {
|
|
32438
32460
|
return _value.find((val) => val === label || val.startsWith(`${addOtherLabel}: `)) || label;
|
|
@@ -32458,6 +32480,49 @@ var Option = (_ref3) => {
|
|
|
32458
32480
|
"data-hook": `checkbox-${label}`
|
|
32459
32481
|
}, inputElement, applyInternalProps(labelElement, {
|
|
32460
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
|
|
32461
32526
|
}), isOther && isOtherSelected && applyInternalProps(otherInputElement, {
|
|
32462
32527
|
fieldValue: _value,
|
|
32463
32528
|
onChange,
|
|
@@ -32471,32 +32536,11 @@ var Option = (_ref3) => {
|
|
|
32471
32536
|
options
|
|
32472
32537
|
}));
|
|
32473
32538
|
};
|
|
32474
|
-
var
|
|
32475
|
-
let {
|
|
32476
|
-
className
|
|
32477
|
-
} = _ref4;
|
|
32478
|
-
return /* @__PURE__ */ React40__namespace.default.createElement("div", {
|
|
32479
|
-
"aria-hidden": "true",
|
|
32480
|
-
className
|
|
32481
|
-
});
|
|
32482
|
-
};
|
|
32483
|
-
var OptionLabel = (_ref5) => {
|
|
32484
|
-
let {
|
|
32485
|
-
className,
|
|
32486
|
-
...internal
|
|
32487
|
-
} = _ref5;
|
|
32488
|
-
const {
|
|
32489
|
-
label
|
|
32490
|
-
} = internal;
|
|
32491
|
-
return /* @__PURE__ */ React40__namespace.default.createElement("span", {
|
|
32492
|
-
className
|
|
32493
|
-
}, label);
|
|
32494
|
-
};
|
|
32495
|
-
var OtherInput = (_ref6) => {
|
|
32539
|
+
var OtherInput = (_ref7) => {
|
|
32496
32540
|
let {
|
|
32497
32541
|
className,
|
|
32498
32542
|
...internal
|
|
32499
|
-
} =
|
|
32543
|
+
} = _ref7;
|
|
32500
32544
|
const {
|
|
32501
32545
|
fieldValue,
|
|
32502
32546
|
onChange,
|
|
@@ -32547,8 +32591,7 @@ var OtherInput = (_ref6) => {
|
|
|
32547
32591
|
CheckboxGroup.Label = Label;
|
|
32548
32592
|
CheckboxGroup.Options = Options;
|
|
32549
32593
|
Options.Option = Option;
|
|
32550
|
-
Option.
|
|
32551
|
-
Option.Input = OptionInput;
|
|
32594
|
+
Option.Checkbox = Checkbox2;
|
|
32552
32595
|
Option.OtherInput = OtherInput;
|
|
32553
32596
|
CheckboxGroup.Description = Description;
|
|
32554
32597
|
CheckboxGroup.Error = Error2;
|