@pdg/react-form 1.0.117 → 1.0.119

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.
@@ -24,6 +24,7 @@ export interface FormAutocompleteProps<T extends FormAutocompleteSingleValue, Mu
24
24
  disablePortal?: boolean;
25
25
  noOptionsText?: string;
26
26
  limitTags?: number;
27
+ getLimitTagsText?: (more: number) => ReactNode;
27
28
  openOnFocus?: boolean;
28
29
  disableClearable?: boolean;
29
30
  async?: boolean;
@@ -5,5 +5,9 @@ import { FormTextFieldProps } from '../FormTextField';
5
5
  declare const FormTag: React.ForwardRefExoticComponent<Omit<FormTextFieldProps<FormTagValue, false, FormTagValue>, "type"> & {
6
6
  formValueSeparator?: string | undefined;
7
7
  formValueSort?: boolean | undefined;
8
+ limitTags?: number | undefined;
9
+ getLimitTagsText?: ((more: number) => React.ReactNode) | undefined;
10
+ onAppendTag?: ((tag: string) => boolean) | undefined;
11
+ onRemoveTag?: ((tag: string) => boolean) | undefined;
8
12
  } & React.RefAttributes<FormTagCommands>>;
9
13
  export default FormTag;
@@ -1,3 +1,4 @@
1
+ import { ReactNode } from 'react';
1
2
  import { FormArrayValueItemCommands } from '../../@types';
2
3
  import { FormTextFieldCommands, FormTextFieldProps } from '../FormTextField';
3
4
  export type FormTagValue = string[];
@@ -6,5 +7,9 @@ export type FormTagCommands = FormTextFieldCommands<FormTagValue, false> & FormT
6
7
  export type FormTagProps = Omit<FormTextFieldProps<FormTagValue, false>, 'type'> & {
7
8
  formValueSeparator?: string;
8
9
  formValueSort?: boolean;
10
+ limitTags?: number;
11
+ getLimitTagsText?: (more: number) => ReactNode;
12
+ onAppendTag?: (tag: string) => boolean;
13
+ onRemoveTag?: (tag: string) => boolean;
9
14
  };
10
15
  export declare const FormTagDefaultProps: Pick<FormTagProps, 'value' | 'clear' | 'formValueSeparator'>;
package/dist/index.esm.js CHANGED
@@ -1345,7 +1345,7 @@ styleInject(css_248z$j);var FormTag = React.forwardRef(function (_a, ref) {
1345
1345
  /********************************************************************************************************************
1346
1346
  * FormState
1347
1347
  * ******************************************************************************************************************/
1348
- var className = _a.className, name = _a.name, initValue = _a.value, exceptValue = _a.exceptValue, required = _a.required, readOnly = _a.readOnly, maxLength = _a.maxLength, initDisabled = _a.disabled, initFullWidth = _a.fullWidth, initError = _a.error, helperText = _a.helperText, formValueSeparator = _a.formValueSeparator, formValueSort = _a.formValueSort, onValidate = _a.onValidate, onKeyDown = _a.onKeyDown, onChange = _a.onChange, onValue = _a.onValue, onBlur = _a.onBlur, props = __rest(_a, ["className", "name", "value", "exceptValue", "required", "readOnly", "maxLength", "disabled", "fullWidth", "error", "helperText", "formValueSeparator", "formValueSort", "onValidate", "onKeyDown", "onChange", "onValue", "onBlur"]);
1348
+ var className = _a.className, name = _a.name, initValue = _a.value, exceptValue = _a.exceptValue, required = _a.required, readOnly = _a.readOnly, maxLength = _a.maxLength, initDisabled = _a.disabled, initFullWidth = _a.fullWidth, initError = _a.error, helperText = _a.helperText, formValueSeparator = _a.formValueSeparator, formValueSort = _a.formValueSort, limitTags = _a.limitTags, getLimitTagsText = _a.getLimitTagsText, onAppendTag = _a.onAppendTag, onRemoveTag = _a.onRemoveTag, onValidate = _a.onValidate, onKeyDown = _a.onKeyDown, onChange = _a.onChange, onValue = _a.onValue, onBlur = _a.onBlur, props = __rest(_a, ["className", "name", "value", "exceptValue", "required", "readOnly", "maxLength", "disabled", "fullWidth", "error", "helperText", "formValueSeparator", "formValueSort", "limitTags", "getLimitTagsText", "onAppendTag", "onRemoveTag", "onValidate", "onKeyDown", "onChange", "onValue", "onBlur"]);
1349
1349
  var _b = useFormState(), formFullWidth = _b.fullWidth, formDisabled = _b.disabled, onAddValueItem = _b.onAddValueItem, onValueChange = _b.onValueChange, onValueChangeByUser = _b.onValueChangeByUser, onRequestSearchSubmit = _b.onRequestSearchSubmit, otherFormState = __rest(_b, ["fullWidth", "disabled", "onAddValueItem", "onValueChange", "onValueChangeByUser", "onRequestSearchSubmit"]);
1350
1350
  /********************************************************************************************************************
1351
1351
  * State - FormState
@@ -1438,6 +1438,8 @@ styleInject(css_248z$j);var FormTag = React.forwardRef(function (_a, ref) {
1438
1438
  setInputValue('');
1439
1439
  }
1440
1440
  else {
1441
+ if (onAppendTag && !onAppendTag(tag))
1442
+ return;
1441
1443
  valueSet.add(tag);
1442
1444
  var finalValue_1 = setValue(valueSet);
1443
1445
  nextTick(function () {
@@ -1446,9 +1448,11 @@ styleInject(css_248z$j);var FormTag = React.forwardRef(function (_a, ref) {
1446
1448
  onRequestSearchSubmit(name, finalValue_1);
1447
1449
  });
1448
1450
  }
1449
- }, [valueSet, setValue, onValueChangeByUser, name, onRequestSearchSubmit]);
1451
+ }, [valueSet, onAppendTag, setValue, onValueChangeByUser, name, onRequestSearchSubmit]);
1450
1452
  var removeTag = useCallback(function (tag) {
1451
1453
  if (valueSet.has(tag)) {
1454
+ if (onRemoveTag && !onRemoveTag(tag))
1455
+ return;
1452
1456
  valueSet.delete(tag);
1453
1457
  var finalValue_2 = setValue(valueSet);
1454
1458
  nextTick(function () {
@@ -1456,7 +1460,7 @@ styleInject(css_248z$j);var FormTag = React.forwardRef(function (_a, ref) {
1456
1460
  onRequestSearchSubmit(name, finalValue_2);
1457
1461
  });
1458
1462
  }
1459
- }, [valueSet, setValue, onValueChangeByUser, name, onRequestSearchSubmit]);
1463
+ }, [valueSet, onRemoveTag, setValue, onValueChangeByUser, name, onRequestSearchSubmit]);
1460
1464
  /********************************************************************************************************************
1461
1465
  * Event Handler
1462
1466
  * ******************************************************************************************************************/
@@ -1511,7 +1515,7 @@ styleInject(css_248z$j);var FormTag = React.forwardRef(function (_a, ref) {
1511
1515
  onValueChangeByUser: function () { },
1512
1516
  // eslint-disable-next-line
1513
1517
  onRequestSearchSubmit: function () { } }, otherFormState) },
1514
- React.createElement(Autocomplete, { options: [], multiple: true, freeSolo: true, value: value, readOnly: readOnly, disableClearable: true, disabled: disabled, renderTags: handleRenderTags, inputValue: inputValue, style: { display: fullWidth ? 'block' : 'inline-block', width: fullWidth ? '100%' : undefined }, renderInput: function (params) {
1518
+ React.createElement(Autocomplete, { options: [], multiple: true, freeSolo: true, value: value, readOnly: readOnly, disableClearable: true, limitTags: limitTags, getLimitTagsText: getLimitTagsText, disabled: disabled, renderTags: handleRenderTags, inputValue: inputValue, style: { display: fullWidth ? 'block' : 'inline-block', width: fullWidth ? '100%' : undefined }, renderInput: function (params) {
1515
1519
  var _a;
1516
1520
  var renderProps = __assign({}, props);
1517
1521
  renderProps.InputLabelProps = __assign(__assign({}, renderProps.InputLabelProps), { htmlFor: params.InputLabelProps.htmlFor, id: params.InputLabelProps.id });
@@ -3917,7 +3921,7 @@ FormTextEditor.defaultProps = FormTextEditorDefaultProps;var FormAutocompleteDef
3917
3921
  * ******************************************************************************************************************/
3918
3922
  var initVariant = _a.variant, initSize = _a.size, initColor = _a.color, initFocused = _a.focused, initLabelShrink = _a.labelShrink, initFullWidth = _a.fullWidth,
3919
3923
  //----------------------------------------------------------------------------------------------------------------
3920
- name = _a.name, labelIcon = _a.labelIcon, label = _a.label, initLoading = _a.loading, initItems = _a.items, initValue = _a.value, initData = _a.data, initError = _a.error, helperText = _a.helperText, initDisabled = _a.disabled, readOnly = _a.readOnly, required = _a.required, exceptValue = _a.exceptValue, width = _a.width, placeholder = _a.placeholder, multiple = _a.multiple, formValueSeparator = _a.formValueSeparator, formValueSort = _a.formValueSort, disablePortal = _a.disablePortal, noOptionsText = _a.noOptionsText, loadingText = _a.loadingText, limitTags = _a.limitTags, openOnFocus = _a.openOnFocus, disableClearable = _a.disableClearable, async = _a.async, initHidden = _a.hidden, onLoadItems = _a.onLoadItems, onAsyncLoadValueItem = _a.onAsyncLoadValueItem, onRenderItem = _a.onRenderItem, onRenderTag = _a.onRenderTag, onAddItem = _a.onAddItem, getOptionDisabled = _a.getOptionDisabled,
3924
+ name = _a.name, labelIcon = _a.labelIcon, label = _a.label, initLoading = _a.loading, initItems = _a.items, initValue = _a.value, initData = _a.data, initError = _a.error, helperText = _a.helperText, initDisabled = _a.disabled, readOnly = _a.readOnly, required = _a.required, exceptValue = _a.exceptValue, width = _a.width, placeholder = _a.placeholder, multiple = _a.multiple, formValueSeparator = _a.formValueSeparator, formValueSort = _a.formValueSort, disablePortal = _a.disablePortal, noOptionsText = _a.noOptionsText, loadingText = _a.loadingText, limitTags = _a.limitTags, getLimitTagsText = _a.getLimitTagsText, openOnFocus = _a.openOnFocus, disableClearable = _a.disableClearable, async = _a.async, initHidden = _a.hidden, onLoadItems = _a.onLoadItems, onAsyncLoadValueItem = _a.onAsyncLoadValueItem, onRenderItem = _a.onRenderItem, onRenderTag = _a.onRenderTag, onAddItem = _a.onAddItem, getOptionDisabled = _a.getOptionDisabled,
3921
3925
  //----------------------------------------------------------------------------------------------------------------
3922
3926
  onChange = _a.onChange, onValue = _a.onValue, onValidate = _a.onValidate,
3923
3927
  //----------------------------------------------------------------------------------------------------------------
@@ -4369,7 +4373,7 @@ FormTextEditor.defaultProps = FormTextEditorDefaultProps;var FormAutocompleteDef
4369
4373
  /********************************************************************************************************************
4370
4374
  * Render
4371
4375
  * ******************************************************************************************************************/
4372
- return (React.createElement(Autocomplete, { options: items || [], className: classNames(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.createElement("li", __assign({}, props, { key: "".concat(option.value) }), onRenderItem ? onRenderItem(option) : option.label)); }, onInputChange: function (event, newInputValue, reason) {
4376
+ return (React.createElement(Autocomplete, { options: items || [], className: classNames(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, getLimitTagsText: getLimitTagsText, onChange: function (e, value, reason, details) { return handleChange(value, reason, details); }, renderOption: function (props, option) { return (React.createElement("li", __assign({}, props, { key: "".concat(option.value) }), onRenderItem ? onRenderItem(option) : option.label)); }, onInputChange: function (event, newInputValue, reason) {
4373
4377
  if (reason === 'input') {
4374
4378
  setInputValue(newInputValue);
4375
4379
  }
package/dist/index.js CHANGED
@@ -1345,7 +1345,7 @@ styleInject(css_248z$j);var FormTag = React.forwardRef(function (_a, ref) {
1345
1345
  /********************************************************************************************************************
1346
1346
  * FormState
1347
1347
  * ******************************************************************************************************************/
1348
- var className = _a.className, name = _a.name, initValue = _a.value, exceptValue = _a.exceptValue, required = _a.required, readOnly = _a.readOnly, maxLength = _a.maxLength, initDisabled = _a.disabled, initFullWidth = _a.fullWidth, initError = _a.error, helperText = _a.helperText, formValueSeparator = _a.formValueSeparator, formValueSort = _a.formValueSort, onValidate = _a.onValidate, onKeyDown = _a.onKeyDown, onChange = _a.onChange, onValue = _a.onValue, onBlur = _a.onBlur, props = __rest(_a, ["className", "name", "value", "exceptValue", "required", "readOnly", "maxLength", "disabled", "fullWidth", "error", "helperText", "formValueSeparator", "formValueSort", "onValidate", "onKeyDown", "onChange", "onValue", "onBlur"]);
1348
+ var className = _a.className, name = _a.name, initValue = _a.value, exceptValue = _a.exceptValue, required = _a.required, readOnly = _a.readOnly, maxLength = _a.maxLength, initDisabled = _a.disabled, initFullWidth = _a.fullWidth, initError = _a.error, helperText = _a.helperText, formValueSeparator = _a.formValueSeparator, formValueSort = _a.formValueSort, limitTags = _a.limitTags, getLimitTagsText = _a.getLimitTagsText, onAppendTag = _a.onAppendTag, onRemoveTag = _a.onRemoveTag, onValidate = _a.onValidate, onKeyDown = _a.onKeyDown, onChange = _a.onChange, onValue = _a.onValue, onBlur = _a.onBlur, props = __rest(_a, ["className", "name", "value", "exceptValue", "required", "readOnly", "maxLength", "disabled", "fullWidth", "error", "helperText", "formValueSeparator", "formValueSort", "limitTags", "getLimitTagsText", "onAppendTag", "onRemoveTag", "onValidate", "onKeyDown", "onChange", "onValue", "onBlur"]);
1349
1349
  var _b = useFormState(), formFullWidth = _b.fullWidth, formDisabled = _b.disabled, onAddValueItem = _b.onAddValueItem, onValueChange = _b.onValueChange, onValueChangeByUser = _b.onValueChangeByUser, onRequestSearchSubmit = _b.onRequestSearchSubmit, otherFormState = __rest(_b, ["fullWidth", "disabled", "onAddValueItem", "onValueChange", "onValueChangeByUser", "onRequestSearchSubmit"]);
1350
1350
  /********************************************************************************************************************
1351
1351
  * State - FormState
@@ -1438,6 +1438,8 @@ styleInject(css_248z$j);var FormTag = React.forwardRef(function (_a, ref) {
1438
1438
  setInputValue('');
1439
1439
  }
1440
1440
  else {
1441
+ if (onAppendTag && !onAppendTag(tag))
1442
+ return;
1441
1443
  valueSet.add(tag);
1442
1444
  var finalValue_1 = setValue(valueSet);
1443
1445
  util.nextTick(function () {
@@ -1446,9 +1448,11 @@ styleInject(css_248z$j);var FormTag = React.forwardRef(function (_a, ref) {
1446
1448
  onRequestSearchSubmit(name, finalValue_1);
1447
1449
  });
1448
1450
  }
1449
- }, [valueSet, setValue, onValueChangeByUser, name, onRequestSearchSubmit]);
1451
+ }, [valueSet, onAppendTag, setValue, onValueChangeByUser, name, onRequestSearchSubmit]);
1450
1452
  var removeTag = React.useCallback(function (tag) {
1451
1453
  if (valueSet.has(tag)) {
1454
+ if (onRemoveTag && !onRemoveTag(tag))
1455
+ return;
1452
1456
  valueSet.delete(tag);
1453
1457
  var finalValue_2 = setValue(valueSet);
1454
1458
  util.nextTick(function () {
@@ -1456,7 +1460,7 @@ styleInject(css_248z$j);var FormTag = React.forwardRef(function (_a, ref) {
1456
1460
  onRequestSearchSubmit(name, finalValue_2);
1457
1461
  });
1458
1462
  }
1459
- }, [valueSet, setValue, onValueChangeByUser, name, onRequestSearchSubmit]);
1463
+ }, [valueSet, onRemoveTag, setValue, onValueChangeByUser, name, onRequestSearchSubmit]);
1460
1464
  /********************************************************************************************************************
1461
1465
  * Event Handler
1462
1466
  * ******************************************************************************************************************/
@@ -1511,7 +1515,7 @@ styleInject(css_248z$j);var FormTag = React.forwardRef(function (_a, ref) {
1511
1515
  onValueChangeByUser: function () { },
1512
1516
  // eslint-disable-next-line
1513
1517
  onRequestSearchSubmit: function () { } }, otherFormState) },
1514
- React.createElement(material.Autocomplete, { options: [], multiple: true, freeSolo: true, value: value, readOnly: readOnly, disableClearable: true, disabled: disabled, renderTags: handleRenderTags, inputValue: inputValue, style: { display: fullWidth ? 'block' : 'inline-block', width: fullWidth ? '100%' : undefined }, renderInput: function (params) {
1518
+ React.createElement(material.Autocomplete, { options: [], multiple: true, freeSolo: true, value: value, readOnly: readOnly, disableClearable: true, limitTags: limitTags, getLimitTagsText: getLimitTagsText, disabled: disabled, renderTags: handleRenderTags, inputValue: inputValue, style: { display: fullWidth ? 'block' : 'inline-block', width: fullWidth ? '100%' : undefined }, renderInput: function (params) {
1515
1519
  var _a;
1516
1520
  var renderProps = __assign({}, props);
1517
1521
  renderProps.InputLabelProps = __assign(__assign({}, renderProps.InputLabelProps), { htmlFor: params.InputLabelProps.htmlFor, id: params.InputLabelProps.id });
@@ -3917,7 +3921,7 @@ FormTextEditor.defaultProps = FormTextEditorDefaultProps;var FormAutocompleteDef
3917
3921
  * ******************************************************************************************************************/
3918
3922
  var initVariant = _a.variant, initSize = _a.size, initColor = _a.color, initFocused = _a.focused, initLabelShrink = _a.labelShrink, initFullWidth = _a.fullWidth,
3919
3923
  //----------------------------------------------------------------------------------------------------------------
3920
- name = _a.name, labelIcon = _a.labelIcon, label = _a.label, initLoading = _a.loading, initItems = _a.items, initValue = _a.value, initData = _a.data, initError = _a.error, helperText = _a.helperText, initDisabled = _a.disabled, readOnly = _a.readOnly, required = _a.required, exceptValue = _a.exceptValue, width = _a.width, placeholder = _a.placeholder, multiple = _a.multiple, formValueSeparator = _a.formValueSeparator, formValueSort = _a.formValueSort, disablePortal = _a.disablePortal, noOptionsText = _a.noOptionsText, loadingText = _a.loadingText, limitTags = _a.limitTags, openOnFocus = _a.openOnFocus, disableClearable = _a.disableClearable, async = _a.async, initHidden = _a.hidden, onLoadItems = _a.onLoadItems, onAsyncLoadValueItem = _a.onAsyncLoadValueItem, onRenderItem = _a.onRenderItem, onRenderTag = _a.onRenderTag, onAddItem = _a.onAddItem, getOptionDisabled = _a.getOptionDisabled,
3924
+ name = _a.name, labelIcon = _a.labelIcon, label = _a.label, initLoading = _a.loading, initItems = _a.items, initValue = _a.value, initData = _a.data, initError = _a.error, helperText = _a.helperText, initDisabled = _a.disabled, readOnly = _a.readOnly, required = _a.required, exceptValue = _a.exceptValue, width = _a.width, placeholder = _a.placeholder, multiple = _a.multiple, formValueSeparator = _a.formValueSeparator, formValueSort = _a.formValueSort, disablePortal = _a.disablePortal, noOptionsText = _a.noOptionsText, loadingText = _a.loadingText, limitTags = _a.limitTags, getLimitTagsText = _a.getLimitTagsText, openOnFocus = _a.openOnFocus, disableClearable = _a.disableClearable, async = _a.async, initHidden = _a.hidden, onLoadItems = _a.onLoadItems, onAsyncLoadValueItem = _a.onAsyncLoadValueItem, onRenderItem = _a.onRenderItem, onRenderTag = _a.onRenderTag, onAddItem = _a.onAddItem, getOptionDisabled = _a.getOptionDisabled,
3921
3925
  //----------------------------------------------------------------------------------------------------------------
3922
3926
  onChange = _a.onChange, onValue = _a.onValue, onValidate = _a.onValidate,
3923
3927
  //----------------------------------------------------------------------------------------------------------------
@@ -4369,7 +4373,7 @@ FormTextEditor.defaultProps = FormTextEditorDefaultProps;var FormAutocompleteDef
4369
4373
  /********************************************************************************************************************
4370
4374
  * Render
4371
4375
  * ******************************************************************************************************************/
4372
- return (React.createElement(material.Autocomplete, { options: items || [], className: classNames(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.createElement("li", __assign({}, props, { key: "".concat(option.value) }), onRenderItem ? onRenderItem(option) : option.label)); }, onInputChange: function (event, newInputValue, reason) {
4376
+ return (React.createElement(material.Autocomplete, { options: items || [], className: classNames(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, getLimitTagsText: getLimitTagsText, onChange: function (e, value, reason, details) { return handleChange(value, reason, details); }, renderOption: function (props, option) { return (React.createElement("li", __assign({}, props, { key: "".concat(option.value) }), onRenderItem ? onRenderItem(option) : option.label)); }, onInputChange: function (event, newInputValue, reason) {
4373
4377
  if (reason === 'input') {
4374
4378
  setInputValue(newInputValue);
4375
4379
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pdg/react-form",
3
3
  "title": "React Form",
4
- "version": "1.0.117",
4
+ "version": "1.0.119",
5
5
  "description": "React Form",
6
6
  "type": "module",
7
7
  "types": "dist/index.d.ts",