@pdg/react-form 1.0.45 → 1.0.47

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.esm.js CHANGED
@@ -4564,6 +4564,8 @@ FormItemBase.displayName = 'FormItemBase';var FormCheckbox = React__default.forw
4564
4564
  //----------------------------------------------------------------------------------------------------------------
4565
4565
  className = _a.className, initStyle = _a.style, sx = _a.sx, props = __rest$3(_a, ["variant", "size", "color", "focused", "fullWidth", "name", "labelIcon", "label", "checked", "inputRef", "action", "readOnly", "disabled", "text", "error", "helperText", "value", "data", "uncheckedValue", "exceptValue", "hidden", "onChange", "onValidate", "className", "style", "sx"]);
4566
4566
  var id = useId();
4567
+ // Use ---------------------------------------------------------------------------------------------------------------
4568
+ var theme = useTheme();
4567
4569
  // FormState -------------------------------------------------------------------------------------------------------
4568
4570
  var _b = useFormState(), formVariant = _b.variant, formSize = _b.size, formColor = _b.color, formFocused = _b.focused, formFullWidth = _b.fullWidth, onAddValueItem = _b.onAddValueItem, onRemoveValueItem = _b.onRemoveValueItem, onValueChange = _b.onValueChange, onValueChangeByUser = _b.onValueChangeByUser, onRequestSearchSubmit = _b.onRequestSearchSubmit;
4569
4571
  // Memo - FormState ------------------------------------------------------------------------------------------------
@@ -4733,7 +4735,7 @@ FormItemBase.displayName = 'FormItemBase';var FormCheckbox = React__default.forw
4733
4735
  }
4734
4736
  }, [readOnly, setChecked, onValueChangeByUser, name, onRequestSearchSubmit]);
4735
4737
  // Render ----------------------------------------------------------------------------------------------------------
4736
- return (React__default.createElement(FormItemBase, { variant: variant, size: size, color: color, focused: focused, className: classNames$1(className, 'FormValueItem', 'FormCheckbox'), labelIcon: labelIcon, label: label, error: error, fullWidth: fullWidth, helperText: helperText, helperTextProps: { style: { marginLeft: 2 } }, style: style, sx: sx, hidden: hidden, controlHeight: height || (size === 'small' ? 35 : 39), controlVerticalCenter: true, control: React__default.createElement(FormControlLabel, { ref: resizeDetectorRef, control: React__default.createElement(Checkbox, __assign$6({ name: name, color: color, size: size, inputRef: initInputRef ? initInputRef : inputRef, action: initAction ? initAction : actionRef, checked: !!checked, checkedIcon: React__default.createElement(CheckBox, { color: error ? 'error' : undefined }), icon: React__default.createElement(CheckBoxOutlineBlank, { color: error ? 'error' : undefined }), onChange: handleChange, disabled: disabled || readOnly }, props)), label: React__default.createElement(Typography, { color: error ? 'error' : undefined, whiteSpace: 'nowrap' }, text) }) }));
4738
+ return (React__default.createElement(FormItemBase, { variant: variant, size: size, color: color, focused: focused, className: classNames$1(className, 'FormValueItem', 'FormCheckbox'), labelIcon: labelIcon, label: label, error: error, fullWidth: fullWidth, helperText: helperText, helperTextProps: { style: { marginLeft: 2 } }, style: style, sx: sx, hidden: hidden, controlHeight: height || (size === 'small' ? 35 : 39), controlVerticalCenter: true, control: React__default.createElement(FormControlLabel, { ref: resizeDetectorRef, control: React__default.createElement(Checkbox, __assign$6({ name: name, color: color, size: size, inputRef: initInputRef ? initInputRef : inputRef, action: initAction ? initAction : actionRef, checked: !!checked, checkedIcon: React__default.createElement(CheckBox, { color: error ? 'error' : undefined }), icon: React__default.createElement(CheckBoxOutlineBlank, { color: error ? 'error' : undefined }), onChange: handleChange, disabled: disabled || readOnly }, props)), label: React__default.createElement(Typography, { color: error ? 'error' : (readOnly || disabled) ? theme.palette.text.disabled : undefined, whiteSpace: 'nowrap' }, text) }) }));
4737
4739
  });
4738
4740
  FormCheckbox.displayName = 'FormCheckbox';
4739
4741
  FormCheckbox.defaultProps = FormCheckboxDefaultProps;var FormRadioGroupDefaultProps = {
@@ -7996,8 +7998,16 @@ FormTextEditor.defaultProps = FormTextEditorDefaultProps;var FormAutocompleteDef
7996
7998
  go();
7997
7999
  }
7998
8000
  }, [multiple, getFinalValue, value, setValue, onValueChangeByUser, name, onRequestSearchSubmit, onAddItem]);
8001
+ var handleGetOptionDisabled = useCallback(function (option) {
8002
+ if (getOptionDisabled) {
8003
+ return option.disabled || getOptionDisabled(option);
8004
+ }
8005
+ else {
8006
+ return !!option.disabled;
8007
+ }
8008
+ }, [getOptionDisabled]);
7999
8009
  // Render ----------------------------------------------------------------------------------------------------------
8000
- return (React__default.createElement(Autocomplete, { options: items || [], className: classNames$1(className, 'FormValueItem', 'FormAutocomplete'), sx: sx, multiple: multiple, fullWidth: !width && fullWidth, openOnFocus: openOnFocus, disableClearable: disableClearable, disablePortal: disablePortal, noOptionsText: noOptionsText, value: componentValue, style: style, isOptionEqualToValue: function (option, value) { return option.value === value.value; }, getOptionDisabled: getOptionDisabled, disabled: disabled, readOnly: readOnly, loading: loading || isOnGetItemLoading, loadingText: loadingText, limitTags: limitTags, onChange: function (e, value, reason, details) { return handleChange(value, reason, details); }, renderOption: function (props, option) { return (React__default.createElement("li", __assign$6({}, props, { key: option.value }), onRenderItem ? onRenderItem(option) : option.label)); }, onInputChange: function (event, newInputValue, reason) {
8010
+ return (React__default.createElement(Autocomplete, { options: items || [], className: classNames$1(className, 'FormValueItem', 'FormAutocomplete'), sx: sx, multiple: multiple, fullWidth: !width && fullWidth, openOnFocus: openOnFocus, disableClearable: disableClearable, disablePortal: disablePortal, noOptionsText: noOptionsText, value: componentValue, style: style, isOptionEqualToValue: function (option, value) { return option.value === value.value; }, getOptionDisabled: handleGetOptionDisabled, disabled: disabled, readOnly: readOnly, loading: loading || isOnGetItemLoading, loadingText: loadingText, limitTags: limitTags, onChange: function (e, value, reason, details) { return handleChange(value, reason, details); }, renderOption: function (props, option) { return (React__default.createElement("li", __assign$6({}, props, { key: option.value }), onRenderItem ? onRenderItem(option) : option.label)); }, onInputChange: function (event, newInputValue, reason) {
8001
8011
  if (reason === 'input') {
8002
8012
  setInputValue(newInputValue);
8003
8013
  }