@pdg/react-form 1.0.161 → 1.0.162

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.
@@ -5,6 +5,7 @@ declare const FormTag: React.ForwardRefExoticComponent<Omit<FormTextFieldProps<F
5
5
  formValueSeparator?: string;
6
6
  formValueSort?: boolean;
7
7
  limitTags?: number;
8
+ allowSpace?: boolean;
8
9
  getLimitTagsText?: (more: number) => ReactNode;
9
10
  onAppendTag?: (tag: string) => boolean;
10
11
  onRemoveTag?: (tag: string) => boolean;
@@ -8,6 +8,7 @@ export type FormTagProps = Omit<FormTextFieldProps<FormTagValue, false>, 'type'>
8
8
  formValueSeparator?: string;
9
9
  formValueSort?: boolean;
10
10
  limitTags?: number;
11
+ allowSpace?: boolean;
11
12
  getLimitTagsText?: (more: number) => ReactNode;
12
13
  onAppendTag?: (tag: string) => boolean;
13
14
  onRemoveTag?: (tag: string) => boolean;
@@ -1,4 +1,5 @@
1
1
  import { FormTextProps } from '../../FormText';
2
2
  export interface FormTagTextProps extends Omit<FormTextProps, 'value' | 'onChange'> {
3
+ allowSpace?: boolean;
3
4
  onAppendTag(tag: string): void;
4
5
  }
package/dist/index.esm.js CHANGED
@@ -1539,7 +1539,7 @@ FormText.displayName = 'FormText';var FormTagText = React.forwardRef(function (_
1539
1539
  /********************************************************************************************************************
1540
1540
  * Use
1541
1541
  * ******************************************************************************************************************/
1542
- var onKeyDown = _a.onKeyDown, onBlur = _a.onBlur, onAppendTag = _a.onAppendTag, props = __rest(_a, ["onKeyDown", "onBlur", "onAppendTag"]);
1542
+ var allowSpace = _a.allowSpace, onKeyDown = _a.onKeyDown, onBlur = _a.onBlur, onAppendTag = _a.onAppendTag, props = __rest(_a, ["allowSpace", "onKeyDown", "onBlur", "onAppendTag"]);
1543
1543
  var forceUpdate = useForceUpdate();
1544
1544
  /********************************************************************************************************************
1545
1545
  * Ref
@@ -1561,7 +1561,8 @@ FormText.displayName = 'FormText';var FormTagText = React.forwardRef(function (_
1561
1561
  * Event Handler
1562
1562
  * ******************************************************************************************************************/
1563
1563
  var handleKeyDown = useCallback(function (e) {
1564
- if ([' ', ',', 'Enter'].includes(e.key)) {
1564
+ var appendKeys = allowSpace ? [',', 'Enter'] : [' ', ',', 'Enter'];
1565
+ if (appendKeys.includes(e.key)) {
1565
1566
  e.preventDefault();
1566
1567
  e.stopPropagation();
1567
1568
  if (notEmpty(valueRef.current)) {
@@ -1572,10 +1573,10 @@ FormText.displayName = 'FormText';var FormTagText = React.forwardRef(function (_
1572
1573
  if (onKeyDown)
1573
1574
  onKeyDown(e);
1574
1575
  }
1575
- }, [appendTag, onKeyDown]);
1576
+ }, [allowSpace, appendTag, onKeyDown]);
1576
1577
  var handleChange = useCallback(function (value) {
1577
- valueRef.current = value.replace(/ /g, '').replace(/,/g, '');
1578
- }, []);
1578
+ valueRef.current = allowSpace ? value.replace(/,/g, '') : value.replace(/ /g, '').replace(/,/g, '');
1579
+ }, [allowSpace]);
1579
1580
  var handleBlur = useCallback(function (e) {
1580
1581
  if (notEmpty(valueRef.current)) {
1581
1582
  appendTag();
@@ -1599,7 +1600,7 @@ var FormTag = React.forwardRef(function (_a, ref) {
1599
1600
  * ******************************************************************************************************************/
1600
1601
  var initVariant = _a.variant, initSize = _a.size,
1601
1602
  //----------------------------------------------------------------------------------------------------------------
1602
- className = _a.className, name = _a.name, _b = _a.value, initValue = _b === void 0 ? _emptyValue : _b, exceptValue = _a.exceptValue, _c = _a.clear, clear = _c === void 0 ? true : _c, required = _a.required, readOnly = _a.readOnly, maxLength = _a.maxLength, initDisabled = _a.disabled, initFullWidth = _a.fullWidth, initError = _a.error, helperText = _a.helperText, _d = _a.formValueSeparator, formValueSeparator = _d === void 0 ? ',' : _d, formValueSort = _a.formValueSort, limitTags = _a.limitTags, getLimitTagsText = _a.getLimitTagsText, slotProps = _a.slotProps, onAppendTag = _a.onAppendTag, onRemoveTag = _a.onRemoveTag, onTagClick = _a.onTagClick, onValidate = _a.onValidate, onChange = _a.onChange, onValue = _a.onValue, props = __rest(_a, ["variant", "size", "className", "name", "value", "exceptValue", "clear", "required", "readOnly", "maxLength", "disabled", "fullWidth", "error", "helperText", "formValueSeparator", "formValueSort", "limitTags", "getLimitTagsText", "slotProps", "onAppendTag", "onRemoveTag", "onTagClick", "onValidate", "onChange", "onValue"]);
1603
+ className = _a.className, name = _a.name, _b = _a.value, initValue = _b === void 0 ? _emptyValue : _b, exceptValue = _a.exceptValue, _c = _a.clear, clear = _c === void 0 ? true : _c, required = _a.required, readOnly = _a.readOnly, maxLength = _a.maxLength, initDisabled = _a.disabled, initFullWidth = _a.fullWidth, initError = _a.error, helperText = _a.helperText, _d = _a.formValueSeparator, formValueSeparator = _d === void 0 ? ',' : _d, formValueSort = _a.formValueSort, limitTags = _a.limitTags, getLimitTagsText = _a.getLimitTagsText, allowSpace = _a.allowSpace, slotProps = _a.slotProps, onAppendTag = _a.onAppendTag, onRemoveTag = _a.onRemoveTag, onTagClick = _a.onTagClick, onValidate = _a.onValidate, onChange = _a.onChange, onValue = _a.onValue, props = __rest(_a, ["variant", "size", "className", "name", "value", "exceptValue", "clear", "required", "readOnly", "maxLength", "disabled", "fullWidth", "error", "helperText", "formValueSeparator", "formValueSort", "limitTags", "getLimitTagsText", "allowSpace", "slotProps", "onAppendTag", "onRemoveTag", "onTagClick", "onValidate", "onChange", "onValue"]);
1603
1604
  var _e = useFormState(), formVariant = _e.variant, formSize = _e.size, formFullWidth = _e.fullWidth, formDisabled = _e.disabled, onAddValueItem = _e.onAddValueItem, onValueChange = _e.onValueChange, onValueChangeByUser = _e.onValueChangeByUser, onRequestSearchSubmit = _e.onRequestSearchSubmit, otherFormState = __rest(_e, ["variant", "size", "fullWidth", "disabled", "onAddValueItem", "onValueChange", "onValueChangeByUser", "onRequestSearchSubmit"]);
1604
1605
  /********************************************************************************************************************
1605
1606
  * FormState - Variables
@@ -1745,9 +1746,10 @@ var FormTag = React.forwardRef(function (_a, ref) {
1745
1746
  delete htmlInputProps.value;
1746
1747
  var renderProps = __assign({ name: name, clear: clear, className: classNames(className, 'FormValueItem', 'FormTag'), error: error, disabled: disabled, fullWidth: fullWidth, required: required, exceptValue: exceptValue, slotProps: __assign(__assign({}, slotProps), { inputLabel: __assign(__assign({}, slotProps === null || slotProps === void 0 ? void 0 : slotProps.inputLabel), { htmlFor: params.InputLabelProps.htmlFor, id: params.InputLabelProps.id }), input: __assign(__assign({}, slotProps === null || slotProps === void 0 ? void 0 : slotProps.input), { style: __assign(__assign({}, (_a = slotProps === null || slotProps === void 0 ? void 0 : slotProps.input) === null || _a === void 0 ? void 0 : _a.style), (variant === 'outlined' && size === 'small'
1747
1748
  ? { paddingTop: 7, paddingBottom: 6, marginTop: -2 }
1748
- : undefined)), className: params.InputProps.className, ref: params.InputProps.ref, startAdornment: params.InputProps.startAdornment }), htmlInput: __assign(__assign(__assign({}, slotProps === null || slotProps === void 0 ? void 0 : slotProps.htmlInput), htmlInputProps), { style: __assign(__assign(__assign({}, (_b = slotProps === null || slotProps === void 0 ? void 0 : slotProps.htmlInput) === null || _b === void 0 ? void 0 : _b.style), htmlInputProps.style), (variant === 'outlined' && size === 'small' ? { marginTop: 4, paddingBottom: 2 } : undefined)) }) }), helperText: error ? errorHelperText : helperText, onAppendTag: appendTag }, props);
1749
+ : undefined)), className: params.InputProps.className, ref: params.InputProps.ref, startAdornment: params.InputProps.startAdornment }), htmlInput: __assign(__assign(__assign({}, slotProps === null || slotProps === void 0 ? void 0 : slotProps.htmlInput), htmlInputProps), { style: __assign(__assign(__assign({}, (_b = slotProps === null || slotProps === void 0 ? void 0 : slotProps.htmlInput) === null || _b === void 0 ? void 0 : _b.style), htmlInputProps.style), (variant === 'outlined' && size === 'small' ? { marginTop: 4, paddingBottom: 2 } : undefined)) }) }), helperText: error ? errorHelperText : helperText, allowSpace: allowSpace, onAppendTag: appendTag }, props);
1749
1750
  return React.createElement(FormTagText, __assign({ ref: handleRef }, renderProps));
1750
1751
  }, [
1752
+ allowSpace,
1751
1753
  appendTag,
1752
1754
  className,
1753
1755
  clear,
package/dist/index.js CHANGED
@@ -1539,7 +1539,7 @@ FormText.displayName = 'FormText';var FormTagText = React.forwardRef(function (_
1539
1539
  /********************************************************************************************************************
1540
1540
  * Use
1541
1541
  * ******************************************************************************************************************/
1542
- var onKeyDown = _a.onKeyDown, onBlur = _a.onBlur, onAppendTag = _a.onAppendTag, props = __rest(_a, ["onKeyDown", "onBlur", "onAppendTag"]);
1542
+ var allowSpace = _a.allowSpace, onKeyDown = _a.onKeyDown, onBlur = _a.onBlur, onAppendTag = _a.onAppendTag, props = __rest(_a, ["allowSpace", "onKeyDown", "onBlur", "onAppendTag"]);
1543
1543
  var forceUpdate = reactHook.useForceUpdate();
1544
1544
  /********************************************************************************************************************
1545
1545
  * Ref
@@ -1561,7 +1561,8 @@ FormText.displayName = 'FormText';var FormTagText = React.forwardRef(function (_
1561
1561
  * Event Handler
1562
1562
  * ******************************************************************************************************************/
1563
1563
  var handleKeyDown = React.useCallback(function (e) {
1564
- if ([' ', ',', 'Enter'].includes(e.key)) {
1564
+ var appendKeys = allowSpace ? [',', 'Enter'] : [' ', ',', 'Enter'];
1565
+ if (appendKeys.includes(e.key)) {
1565
1566
  e.preventDefault();
1566
1567
  e.stopPropagation();
1567
1568
  if (notEmpty(valueRef.current)) {
@@ -1572,10 +1573,10 @@ FormText.displayName = 'FormText';var FormTagText = React.forwardRef(function (_
1572
1573
  if (onKeyDown)
1573
1574
  onKeyDown(e);
1574
1575
  }
1575
- }, [appendTag, onKeyDown]);
1576
+ }, [allowSpace, appendTag, onKeyDown]);
1576
1577
  var handleChange = React.useCallback(function (value) {
1577
- valueRef.current = value.replace(/ /g, '').replace(/,/g, '');
1578
- }, []);
1578
+ valueRef.current = allowSpace ? value.replace(/,/g, '') : value.replace(/ /g, '').replace(/,/g, '');
1579
+ }, [allowSpace]);
1579
1580
  var handleBlur = React.useCallback(function (e) {
1580
1581
  if (notEmpty(valueRef.current)) {
1581
1582
  appendTag();
@@ -1599,7 +1600,7 @@ var FormTag = React.forwardRef(function (_a, ref) {
1599
1600
  * ******************************************************************************************************************/
1600
1601
  var initVariant = _a.variant, initSize = _a.size,
1601
1602
  //----------------------------------------------------------------------------------------------------------------
1602
- className = _a.className, name = _a.name, _b = _a.value, initValue = _b === void 0 ? _emptyValue : _b, exceptValue = _a.exceptValue, _c = _a.clear, clear = _c === void 0 ? true : _c, required = _a.required, readOnly = _a.readOnly, maxLength = _a.maxLength, initDisabled = _a.disabled, initFullWidth = _a.fullWidth, initError = _a.error, helperText = _a.helperText, _d = _a.formValueSeparator, formValueSeparator = _d === void 0 ? ',' : _d, formValueSort = _a.formValueSort, limitTags = _a.limitTags, getLimitTagsText = _a.getLimitTagsText, slotProps = _a.slotProps, onAppendTag = _a.onAppendTag, onRemoveTag = _a.onRemoveTag, onTagClick = _a.onTagClick, onValidate = _a.onValidate, onChange = _a.onChange, onValue = _a.onValue, props = __rest(_a, ["variant", "size", "className", "name", "value", "exceptValue", "clear", "required", "readOnly", "maxLength", "disabled", "fullWidth", "error", "helperText", "formValueSeparator", "formValueSort", "limitTags", "getLimitTagsText", "slotProps", "onAppendTag", "onRemoveTag", "onTagClick", "onValidate", "onChange", "onValue"]);
1603
+ className = _a.className, name = _a.name, _b = _a.value, initValue = _b === void 0 ? _emptyValue : _b, exceptValue = _a.exceptValue, _c = _a.clear, clear = _c === void 0 ? true : _c, required = _a.required, readOnly = _a.readOnly, maxLength = _a.maxLength, initDisabled = _a.disabled, initFullWidth = _a.fullWidth, initError = _a.error, helperText = _a.helperText, _d = _a.formValueSeparator, formValueSeparator = _d === void 0 ? ',' : _d, formValueSort = _a.formValueSort, limitTags = _a.limitTags, getLimitTagsText = _a.getLimitTagsText, allowSpace = _a.allowSpace, slotProps = _a.slotProps, onAppendTag = _a.onAppendTag, onRemoveTag = _a.onRemoveTag, onTagClick = _a.onTagClick, onValidate = _a.onValidate, onChange = _a.onChange, onValue = _a.onValue, props = __rest(_a, ["variant", "size", "className", "name", "value", "exceptValue", "clear", "required", "readOnly", "maxLength", "disabled", "fullWidth", "error", "helperText", "formValueSeparator", "formValueSort", "limitTags", "getLimitTagsText", "allowSpace", "slotProps", "onAppendTag", "onRemoveTag", "onTagClick", "onValidate", "onChange", "onValue"]);
1603
1604
  var _e = useFormState(), formVariant = _e.variant, formSize = _e.size, formFullWidth = _e.fullWidth, formDisabled = _e.disabled, onAddValueItem = _e.onAddValueItem, onValueChange = _e.onValueChange, onValueChangeByUser = _e.onValueChangeByUser, onRequestSearchSubmit = _e.onRequestSearchSubmit, otherFormState = __rest(_e, ["variant", "size", "fullWidth", "disabled", "onAddValueItem", "onValueChange", "onValueChangeByUser", "onRequestSearchSubmit"]);
1604
1605
  /********************************************************************************************************************
1605
1606
  * FormState - Variables
@@ -1745,9 +1746,10 @@ var FormTag = React.forwardRef(function (_a, ref) {
1745
1746
  delete htmlInputProps.value;
1746
1747
  var renderProps = __assign({ name: name, clear: clear, className: classNames(className, 'FormValueItem', 'FormTag'), error: error, disabled: disabled, fullWidth: fullWidth, required: required, exceptValue: exceptValue, slotProps: __assign(__assign({}, slotProps), { inputLabel: __assign(__assign({}, slotProps === null || slotProps === void 0 ? void 0 : slotProps.inputLabel), { htmlFor: params.InputLabelProps.htmlFor, id: params.InputLabelProps.id }), input: __assign(__assign({}, slotProps === null || slotProps === void 0 ? void 0 : slotProps.input), { style: __assign(__assign({}, (_a = slotProps === null || slotProps === void 0 ? void 0 : slotProps.input) === null || _a === void 0 ? void 0 : _a.style), (variant === 'outlined' && size === 'small'
1747
1748
  ? { paddingTop: 7, paddingBottom: 6, marginTop: -2 }
1748
- : undefined)), className: params.InputProps.className, ref: params.InputProps.ref, startAdornment: params.InputProps.startAdornment }), htmlInput: __assign(__assign(__assign({}, slotProps === null || slotProps === void 0 ? void 0 : slotProps.htmlInput), htmlInputProps), { style: __assign(__assign(__assign({}, (_b = slotProps === null || slotProps === void 0 ? void 0 : slotProps.htmlInput) === null || _b === void 0 ? void 0 : _b.style), htmlInputProps.style), (variant === 'outlined' && size === 'small' ? { marginTop: 4, paddingBottom: 2 } : undefined)) }) }), helperText: error ? errorHelperText : helperText, onAppendTag: appendTag }, props);
1749
+ : undefined)), className: params.InputProps.className, ref: params.InputProps.ref, startAdornment: params.InputProps.startAdornment }), htmlInput: __assign(__assign(__assign({}, slotProps === null || slotProps === void 0 ? void 0 : slotProps.htmlInput), htmlInputProps), { style: __assign(__assign(__assign({}, (_b = slotProps === null || slotProps === void 0 ? void 0 : slotProps.htmlInput) === null || _b === void 0 ? void 0 : _b.style), htmlInputProps.style), (variant === 'outlined' && size === 'small' ? { marginTop: 4, paddingBottom: 2 } : undefined)) }) }), helperText: error ? errorHelperText : helperText, allowSpace: allowSpace, onAppendTag: appendTag }, props);
1749
1750
  return React.createElement(FormTagText, __assign({ ref: handleRef }, renderProps));
1750
1751
  }, [
1752
+ allowSpace,
1751
1753
  appendTag,
1752
1754
  className,
1753
1755
  clear,
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.161",
4
+ "version": "1.0.162",
5
5
  "description": "React Form",
6
6
  "type": "module",
7
7
  "types": "dist/index.d.ts",