@pdg/react-form 1.0.66 → 1.0.68

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.
@@ -1,7 +1,8 @@
1
1
  import { CommonSxProps, FormValueItemCommands, FormValueItemProps } from '../../@types';
2
+ import { IAllProps } from '@tinymce/tinymce-react';
2
3
  export type FormTextEditorValue = string;
3
4
  export type FormTextEditorCommands = FormValueItemCommands<FormTextEditorValue, false>;
4
- export interface FormTextEditorProps extends CommonSxProps, Omit<FormValueItemProps<FormTextEditorValue, false>, 'fullWidth'> {
5
+ export interface FormTextEditorProps extends CommonSxProps, Omit<FormValueItemProps<FormTextEditorValue, false>, 'fullWidth'>, Partial<Pick<IAllProps, 'apiKey' | 'toolbar'>> {
5
6
  required?: boolean;
6
7
  menubar?: boolean;
7
8
  height?: number;
package/dist/index.esm.js CHANGED
@@ -4011,7 +4011,7 @@ function NumericFormat(props) {
4011
4011
  });
4012
4012
  NumberFormatCustom.displayName = 'NumberFormatCustom';var FormNumberDefaultProps = __assign$7(__assign$7({}, FormTextFieldDefaultProps), { clear: true });var FormNumber = React__default.forwardRef(function (_a, ref) {
4013
4013
  // State -------------------------------------------------------------------------------------------------------------
4014
- var className = _a.className, allowNegative = _a.allowNegative, thousandSeparator = _a.thousandSeparator, allowDecimal = _a.allowDecimal, decimalScale = _a.decimalScale, prefix = _a.prefix, suffix = _a.suffix, readOnly = _a.readOnly, tabIndex = _a.tabIndex, initMuiInputProps = _a.InputProps, initInputProps = _a.inputProps, initValue = _a.value, onChange = _a.onChange, props = __rest$4(_a, ["className", "allowNegative", "thousandSeparator", "allowDecimal", "decimalScale", "prefix", "suffix", "readOnly", "tabIndex", "InputProps", "inputProps", "value", "onChange"]);
4014
+ var className = _a.className, allowNegative = _a.allowNegative, thousandSeparator = _a.thousandSeparator, allowDecimal = _a.allowDecimal, decimalScale = _a.decimalScale, prefix = _a.prefix, suffix = _a.suffix, readOnly = _a.readOnly, tabIndex = _a.tabIndex, initMuiInputProps = _a.InputProps, initInputProps = _a.inputProps, initValue = _a.value, onChange = _a.onChange, onValue = _a.onValue, onValidate = _a.onValidate, props = __rest$4(_a, ["className", "allowNegative", "thousandSeparator", "allowDecimal", "decimalScale", "prefix", "suffix", "readOnly", "tabIndex", "InputProps", "inputProps", "value", "onChange", "onValue", "onValidate"]);
4015
4015
  var _b = useState(function () { return (empty(initValue) ? '' : "".concat(initValue)); }), strValue = _b[0], setStrValue = _b[1];
4016
4016
  // Effect ------------------------------------------------------------------------------------------------------------
4017
4017
  useEffect(function () {
@@ -4055,8 +4055,24 @@ NumberFormatCustom.displayName = 'NumberFormatCustom';var FormNumberDefaultProps
4055
4055
  onChange && onChange(newValue);
4056
4056
  setStrValue(value);
4057
4057
  }, [onChange]);
4058
+ var handleValue = useCallback(function (value) {
4059
+ var finalValue = empty(value) || value === '-' || value === '.' ? undefined : Number(value);
4060
+ if (onValue) {
4061
+ finalValue = onValue(finalValue);
4062
+ }
4063
+ return finalValue !== undefined ? finalValue.toString() : undefined;
4064
+ }, [onValue]);
4065
+ var handleValidate = useCallback(function (value) {
4066
+ if (onValidate) {
4067
+ var finalValue = empty(value) || value === '-' || value === '.' ? undefined : Number(value);
4068
+ return onValidate(finalValue);
4069
+ }
4070
+ else {
4071
+ return true;
4072
+ }
4073
+ }, [onValidate]);
4058
4074
  // Render ----------------------------------------------------------------------------------------------------------
4059
- return (React__default.createElement(FormTextField, __assign$7({ ref: ref, className: classNames$1(className, 'FormNumber'), disableReturnKey: true, InputProps: muiInputProps, readOnly: readOnly, value: strValue, onChange: handleChange }, props)));
4075
+ return (React__default.createElement(FormTextField, __assign$7({ ref: ref, className: classNames$1(className, 'FormNumber'), disableReturnKey: true, InputProps: muiInputProps, readOnly: readOnly, value: strValue, onChange: handleChange, onValue: handleValue, onValidate: handleValidate }, props)));
4060
4076
  });
4061
4077
  FormNumber.displayName = 'FormNumber';
4062
4078
  FormNumber.defaultProps = FormNumberDefaultProps;var FormSearchDefaultProps = __assign$7({}, FormTextDefaultProps);var css_248z$h = ".FormSearch input[type=search]::-webkit-search-decoration,\n.FormSearch input[type=search]::-webkit-search-cancel-button,\n.FormSearch input[type=search]::-webkit-search-results-button,\n.FormSearch input[type=search]::-webkit-search-results-decoration {\n -webkit-appearance: none;\n}";
@@ -7475,6 +7491,8 @@ var Editor = /** @class */ (function (_super) {
7475
7491
  styleInject(css_248z$c);var FormTextEditor = React__default.forwardRef(function (_a, ref) {
7476
7492
  // ID --------------------------------------------------------------------------------------------------------------
7477
7493
  var initVariant = _a.variant, initSize = _a.size, initColor = _a.color, initFocused = _a.focused,
7494
+ // ---------------------------------------------------------------------------------------------------------------
7495
+ apiKey = _a.apiKey, toolbar = _a.toolbar,
7478
7496
  //----------------------------------------------------------------------------------------------------------------
7479
7497
  menubar = _a.menubar, height = _a.height, hidden = _a.hidden, onImageUpload = _a.onImageUpload,
7480
7498
  //----------------------------------------------------------------------------------------------------------------
@@ -7648,7 +7666,7 @@ styleInject(css_248z$c);var FormTextEditor = React__default.forwardRef(function
7648
7666
  // Render ----------------------------------------------------------------------------------------------------------
7649
7667
  return (React__default.createElement(FormItemBase, { variant: variant, size: size, color: color, focused: focused, className: classNames$1(className, 'FormValueItem', 'FormTextEditor', !initialized && 'initializing'), labelIcon: labelIcon, label: label, error: error, required: required, fullWidth: true, helperText: error ? errorHelperText : helperText, helperTextProps: { style: { marginLeft: 5 } }, style: { width: '100%' }, hidden: hidden, controlHeight: height, control: React__default.createElement(React__default.Fragment, null,
7650
7668
  !initialized ? React__default.createElement(Skeleton, { variant: 'rectangular', width: '100%', height: height }) : null,
7651
- React__default.createElement(Editor, { ref: editorRef, value: value, disabled: readOnly || disabled, init: {
7669
+ React__default.createElement(Editor, { ref: editorRef, apiKey: apiKey, value: value, disabled: readOnly || disabled, init: {
7652
7670
  height: height,
7653
7671
  menubar: menubar,
7654
7672
  readonly: true,
@@ -7656,13 +7674,24 @@ styleInject(css_248z$c);var FormTextEditor = React__default.forwardRef(function
7656
7674
  contextmenu: false,
7657
7675
  content_style: 'body {font-size: 0.875rem; font-weight: 400; line-height: 1.5; color: hsl(0,0%,20%);} p {padding:0; margin:0}',
7658
7676
  plugins: [
7677
+ 'lists',
7659
7678
  'advlist',
7660
- 'advlist autolink lists link image',
7661
- 'charmap print preview anchor',
7662
- 'searchreplace visualblocks code',
7663
- 'insertdatetime media table paste wordcount',
7679
+ 'image',
7680
+ 'autolink',
7681
+ 'link',
7682
+ 'charmap',
7683
+ 'preview',
7684
+ 'anchor',
7685
+ 'searchreplace',
7686
+ 'visualblocks',
7687
+ 'code',
7688
+ 'insertdatetime',
7689
+ 'media',
7690
+ 'table',
7691
+ 'wordcount',
7664
7692
  ],
7665
- toolbar: 'undo redo | \
7693
+ toolbar: toolbar ||
7694
+ 'undo redo | \
7666
7695
  formatselect bullist numlist outdent indent | \
7667
7696
  bold italic | align | forecolor backcolor | \
7668
7697
  link image media | advtable | code',