@true-engineering/true-react-common-ui-kit 4.0.0-alpha20 → 4.0.0-alpha21

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,9 +1,7 @@
1
1
  import { ITweakStyles } from '../../theme';
2
2
  import { IInputStyles } from '../Input';
3
- export declare const BUTTONS_WIDTH = 36;
4
- export declare const BUTTONS_GAP = 2;
5
- export declare const useStyles: import("../../theme").IUseStyles<"root" | "button" | "buttons" | "disabledButton" | "errorButton", unknown>;
6
3
  export declare const inputStyles: IInputStyles;
4
+ export declare const useStyles: import("../../theme").IUseStyles<"button" | "icon" | "buttons" | "disabledButton" | "errorButton", unknown>;
7
5
  export type IIncrementInputStyles = ITweakStyles<typeof useStyles, {
8
6
  tweakInput: IInputStyles;
9
7
  }>;
@@ -4,7 +4,7 @@ import { ICommonProps } from '../../types';
4
4
  import { IControlWrapperProps } from '../ControlWrapper';
5
5
  import { IChangeInputEvent } from './types';
6
6
  import { IInputStyles } from './Input.styles';
7
- export interface IInputBaseProps extends ICommonProps<IInputStyles>, Omit<InputHTMLAttributes<HTMLInputElement>, 'onChange' | 'size'>, Pick<IControlWrapperProps, 'label' | 'icon' | 'groupPlacement' | 'isInvalid' | 'isRequired' | 'isLoading' | 'isDisabled' | 'onIconClick' | 'size'>, Pick<Partial<ReactInputMaskBaseProps>, 'mask' | 'maskPlaceholder' | 'alwaysShowMask' | 'beforeMaskedStateChange'> {
7
+ export interface IInputBaseProps extends ICommonProps<IInputStyles>, Omit<InputHTMLAttributes<HTMLInputElement>, 'onChange' | 'size'>, Pick<IControlWrapperProps, 'label' | 'icon' | 'size' | 'groupPlacement' | 'isInvalid' | 'isRequired' | 'isLoading' | 'isDisabled' | 'onIconClick'>, Pick<Partial<ReactInputMaskBaseProps>, 'mask' | 'maskPlaceholder' | 'alwaysShowMask' | 'beforeMaskedStateChange'> {
8
8
  value?: string;
9
9
  units?: ReactNode;
10
10
  /** @default false */
@@ -10485,7 +10485,7 @@ function _ts_generator$5(thisArg, body) {
10485
10485
  }
10486
10486
  }
10487
10487
  var InputBase = /* @__PURE__ */ forwardRef(function(_param, ref) {
10488
- var _param_value = _param.value, value = _param_value === void 0 ? "" : _param_value, placeholder = _param.placeholder, label = _param.label, _param_type = _param.type, type = _param_type === void 0 ? "text" : _param_type, isDisabled = _param.isDisabled, autoComplete = _param.autoComplete, initialInputMode = _param.inputMode, isReadonly = _param.isReadonly, isInvalid = _param.isInvalid, isActive = _param.isActive, isClearable = _param.isClearable, isAutoSized = _param.isAutoSized, name = _param.name, tweakStyles = _param.tweakStyles, maxLength = _param.maxLength, shouldFocusOnMount = _param.shouldFocusOnMount, units = _param.units, testId = _param.testId, tabIndex = _param.tabIndex, shouldAlwaysShowPlaceholder = _param.shouldAlwaysShowPlaceholder, onChange = _param.onChange, onPaste = _param.onPaste, onFocus = _param.onFocus, onBlur = _param.onBlur, onKeyDown = _param.onKeyDown, mask = _param.mask, maskPlaceholder = _param.maskPlaceholder, alwaysShowMask = _param.alwaysShowMask, beforeMaskedStateChange = _param.beforeMaskedStateChange, data = _param.data, groupPlacement = _param.groupPlacement, icon = _param.icon, isLoading = _param.isLoading, isRequired = _param.isRequired, size2 = _param.size, onIconClick = _param.onIconClick, inputProps = _object_without_properties$i(_param, [
10488
+ var _param_value = _param.value, value = _param_value === void 0 ? "" : _param_value, placeholder = _param.placeholder, label = _param.label, _param_type = _param.type, type = _param_type === void 0 ? "text" : _param_type, isDisabled = _param.isDisabled, autoComplete = _param.autoComplete, initialInputMode = _param.inputMode, isReadonly = _param.isReadonly, isInvalid = _param.isInvalid, isActive = _param.isActive, isClearable = _param.isClearable, isAutoSized = _param.isAutoSized, name = _param.name, tweakStyles = _param.tweakStyles, maxLength = _param.maxLength, shouldFocusOnMount = _param.shouldFocusOnMount, units = _param.units, testId = _param.testId, tabIndex = _param.tabIndex, shouldAlwaysShowPlaceholder = _param.shouldAlwaysShowPlaceholder, onChange = _param.onChange, onPaste = _param.onPaste, onFocus = _param.onFocus, onBlur = _param.onBlur, onKeyDown = _param.onKeyDown, mask = _param.mask, maskPlaceholder = _param.maskPlaceholder, alwaysShowMask = _param.alwaysShowMask, beforeMaskedStateChange = _param.beforeMaskedStateChange, data = _param.data, groupPlacement = _param.groupPlacement, icon = _param.icon, isLoading = _param.isLoading, isRequired = _param.isRequired, size2 = _param.size, onIconClick = _param.onIconClick, children = _param.children, inputProps = _object_without_properties$i(_param, [
10489
10489
  "value",
10490
10490
  "placeholder",
10491
10491
  "label",
@@ -10521,7 +10521,8 @@ var InputBase = /* @__PURE__ */ forwardRef(function(_param, ref) {
10521
10521
  "isLoading",
10522
10522
  "isRequired",
10523
10523
  "size",
10524
- "onIconClick"
10524
+ "onIconClick",
10525
+ "children"
10525
10526
  ]);
10526
10527
  var classes = useStyles$G({
10527
10528
  theme: tweakStyles
@@ -10636,7 +10637,7 @@ var InputBase = /* @__PURE__ */ forwardRef(function(_param, ref) {
10636
10637
  })
10637
10638
  ]
10638
10639
  });
10639
- return /* @__PURE__ */ jsx(ControlWrapper, {
10640
+ return /* @__PURE__ */ jsxs(ControlWrapper, {
10640
10641
  label,
10641
10642
  isDisabled,
10642
10643
  isFocused: hasFocus,
@@ -10652,10 +10653,13 @@ var InputBase = /* @__PURE__ */ forwardRef(function(_param, ref) {
10652
10653
  isRequired,
10653
10654
  onIconClick,
10654
10655
  size: size2,
10655
- children: hasUnits || isAutoSized ? /* @__PURE__ */ jsx("div", {
10656
- className: classes.autoSizeWrapper,
10657
- children: inputContent
10658
- }) : inputContent
10656
+ children: [
10657
+ hasUnits || isAutoSized ? /* @__PURE__ */ jsx("div", {
10658
+ className: classes.autoSizeWrapper,
10659
+ children: inputContent
10660
+ }) : inputContent,
10661
+ children
10662
+ ]
10659
10663
  });
10660
10664
  });
10661
10665
  function _define_property$S(obj, key, value) {
@@ -27892,71 +27896,62 @@ function FlexibleTable(_param) {
27892
27896
  }))
27893
27897
  });
27894
27898
  }
27895
- var BUTTONS_WIDTH = 36;
27896
- var BUTTONS_GAP = 2;
27899
+ var inputStyles$2 = {
27900
+ tweakControlWrapper: {
27901
+ controlWrapper: {
27902
+ "--increment-buttons-width": "36px",
27903
+ "--increment-buttons-gap": "1px",
27904
+ "--increment-buttons-margin": "1px",
27905
+ "--increment-button-icon-size": "16px"
27906
+ }
27907
+ }
27908
+ };
27897
27909
  var useStyles$g = createThemedStyles("IncrementInput", {
27898
- root: {
27899
- display: "flex",
27900
- alignItems: "center",
27901
- position: "relative"
27902
- },
27903
27910
  buttons: {
27904
27911
  display: "flex",
27905
27912
  flexDirection: "column",
27906
- width: BUTTONS_WIDTH,
27907
- position: "absolute",
27908
- right: BUTTONS_GAP,
27909
- top: BUTTONS_GAP,
27910
- bottom: BUTTONS_GAP,
27913
+ height: "calc(100% - var(--increment-buttons-margin) * 2)",
27914
+ margin: "var(--increment-buttons-margin)",
27915
+ gap: "var(--increment-buttons-gap)",
27916
+ flexShrink: 0,
27917
+ order: 1e3,
27918
+ // сдвигаем кнопки на самый конец
27911
27919
  zIndex: dimensions.Z_INDEX.CONTROL_FOCUS + 1
27912
27920
  },
27913
27921
  button: {
27914
- width: "100%",
27915
- height: (dimensions.CONTROL.HEIGHT - 5) / 2,
27922
+ display: "flex",
27923
+ alignItems: "center",
27924
+ justifyContent: "center",
27925
+ width: "var(--increment-buttons-width)",
27926
+ flexGrow: 1,
27927
+ cursor: "pointer",
27916
27928
  border: "none",
27917
27929
  outline: "none",
27930
+ color: colors.FONT_MEDIUM,
27918
27931
  backgroundColor: colors.GREY_BACKGROUND,
27919
27932
  transition: animations.defaultTransition,
27920
- transitionProperty: "background-color",
27921
- color: colors.FONT_MEDIUM,
27922
- cursor: "pointer",
27923
- display: "flex",
27924
- alignItems: "center",
27925
- justifyContent: "center",
27926
- padding: [
27927
- 0,
27928
- 10
27929
- ],
27933
+ transitionProperty: "background-color, color",
27930
27934
  "&:hover, &:focus": {
27931
27935
  backgroundColor: colors.GREY_HOVER
27932
27936
  },
27933
27937
  "&:active": {
27934
27938
  backgroundColor: colors.GREY_ACTIVE
27935
- },
27936
- "&:first-child": {
27937
- marginBottom: 1
27938
27939
  }
27939
27940
  },
27940
27941
  disabledButton: {
27941
- backgroundColor: colors.CLASSIC_WHITE,
27942
- color: colors.FONT_DISABLED,
27943
27942
  cursor: "default",
27943
+ color: colors.FONT_DISABLED,
27944
+ backgroundColor: colors.CLASSIC_WHITE,
27944
27945
  "&:hover": {
27945
27946
  backgroundColor: colors.CLASSIC_WHITE
27946
27947
  }
27947
27948
  },
27948
- errorButton: {}
27949
- });
27950
- var inputStyles$2 = {
27951
- input: {
27952
- paddingRight: BUTTONS_WIDTH + BUTTONS_GAP
27953
- },
27954
- tweakControlWrapper: {
27955
- controls: {
27956
- paddingRight: BUTTONS_WIDTH + BUTTONS_GAP
27957
- }
27949
+ errorButton: {},
27950
+ icon: {
27951
+ width: "var(--increment-button-icon-size)",
27952
+ height: "var(--increment-button-icon-size)"
27958
27953
  }
27959
- };
27954
+ });
27960
27955
  function _define_property$k(obj, key, value) {
27961
27956
  if (key in obj) {
27962
27957
  Object.defineProperty(obj, key, {
@@ -28042,15 +28037,13 @@ function _object_without_properties_loose$7(source, excluded) {
28042
28037
  return target;
28043
28038
  }
28044
28039
  var IncrementInput = function(_param) {
28045
- var value = _param.value, onChange = _param.onChange, min2 = _param.min, max2 = _param.max, _param_step = _param.step, step = _param_step === void 0 ? 1 : _param_step, intPartPrecision = _param.intPartPrecision, data = _param.data, testId = _param.testId, tweakStyles = _param.tweakStyles, isDisabled = _param.isDisabled, isReadonly = _param.isReadonly, isInvalid = _param.isInvalid, props = _object_without_properties$7(_param, [
28040
+ var value = _param.value, onChange = _param.onChange, min2 = _param.min, max2 = _param.max, _param_step = _param.step, step = _param_step === void 0 ? 1 : _param_step, intPartPrecision = _param.intPartPrecision, tweakStyles = _param.tweakStyles, isDisabled = _param.isDisabled, isReadonly = _param.isReadonly, isInvalid = _param.isInvalid, props = _object_without_properties$7(_param, [
28046
28041
  "value",
28047
28042
  "onChange",
28048
28043
  "min",
28049
28044
  "max",
28050
28045
  "step",
28051
28046
  "intPartPrecision",
28052
- "data",
28053
- "testId",
28054
28047
  "tweakStyles",
28055
28048
  "isDisabled",
28056
28049
  "isReadonly",
@@ -28065,8 +28058,9 @@ var IncrementInput = function(_param) {
28065
28058
  var classes = useStyles$g({
28066
28059
  theme: tweakStyles
28067
28060
  });
28068
- var isIncreaseDisabled = isDisabled || isReadonly || intPartPrecision !== void 0 && getNumberLength((value !== null && value !== void 0 ? value : 0) + step) > intPartPrecision || max2 !== void 0 && value !== void 0 && value >= max2;
28069
- var isDecreaseDisabled = isDisabled || isReadonly || (min2 !== void 0 && value !== void 0 ? value <= min2 : false);
28061
+ var isEditDisabled = isDisabled || isReadonly;
28062
+ var isIncreaseDisabled = isEditDisabled || isNotEmpty(intPartPrecision) && getNumberLength((value !== null && value !== void 0 ? value : 0) + step) > intPartPrecision || isNotEmpty(max2) && isNotEmpty(value) && value >= max2;
28063
+ var isDecreaseDisabled = isEditDisabled || isNotEmpty(min2) && isNotEmpty(value) && value <= min2;
28070
28064
  var increment = function() {
28071
28065
  onChange(getNumberInRange((value !== null && value !== void 0 ? value : 0) + step, min2, max2));
28072
28066
  };
@@ -28081,45 +28075,45 @@ var IncrementInput = function(_param) {
28081
28075
  step
28082
28076
  ]);
28083
28077
  var _obj2, _obj1;
28084
- return /* @__PURE__ */ jsxs("div", _object_spread_props$i(_object_spread$j({
28085
- className: classes.root
28086
- }, addDataTestId(testId), addDataAttributes(data)), {
28087
- children: [
28088
- /* @__PURE__ */ jsx(NumberInput, _object_spread_props$i(_object_spread$j({}, props), {
28089
- isInvalid,
28090
- isDisabled,
28091
- isReadonly,
28092
- min: min2,
28093
- max: max2,
28094
- intPartPrecision,
28095
- onChange,
28096
- value,
28097
- tweakStyles: tweakInputStyles
28098
- })),
28099
- /* @__PURE__ */ jsxs("div", {
28100
- className: classes.buttons,
28101
- children: [
28102
- /* @__PURE__ */ jsx("button", {
28103
- className: clsx(classes.button, (_obj2 = {}, _define_property$k(_obj2, classes.disabledButton, isIncreaseDisabled), _define_property$k(_obj2, classes.errorButton, isInvalid), _obj2)),
28104
- type: "button",
28105
- disabled: isIncreaseDisabled,
28106
- onClick: increment,
28078
+ return /* @__PURE__ */ jsx(NumberInput, _object_spread_props$i(_object_spread$j({}, props), {
28079
+ isInvalid,
28080
+ isDisabled,
28081
+ isReadonly,
28082
+ min: min2,
28083
+ max: max2,
28084
+ intPartPrecision,
28085
+ onChange,
28086
+ value,
28087
+ tweakStyles: tweakInputStyles,
28088
+ children: /* @__PURE__ */ jsxs("div", {
28089
+ className: classes.buttons,
28090
+ children: [
28091
+ /* @__PURE__ */ jsx("button", {
28092
+ className: clsx(classes.button, (_obj2 = {}, _define_property$k(_obj2, classes.disabledButton, isIncreaseDisabled), _define_property$k(_obj2, classes.errorButton, isInvalid), _obj2)),
28093
+ type: "button",
28094
+ disabled: isIncreaseDisabled,
28095
+ onClick: increment,
28096
+ children: /* @__PURE__ */ jsx("div", {
28097
+ className: classes.icon,
28107
28098
  children: /* @__PURE__ */ jsx(Icon, {
28108
28099
  type: "plus"
28109
28100
  })
28110
- }),
28111
- /* @__PURE__ */ jsx("button", {
28112
- className: clsx(classes.button, (_obj1 = {}, _define_property$k(_obj1, classes.disabledButton, isDecreaseDisabled), _define_property$k(_obj1, classes.errorButton, isInvalid), _obj1)),
28113
- type: "button",
28114
- disabled: isDecreaseDisabled,
28115
- onClick: decrement,
28101
+ })
28102
+ }),
28103
+ /* @__PURE__ */ jsx("button", {
28104
+ className: clsx(classes.button, (_obj1 = {}, _define_property$k(_obj1, classes.disabledButton, isDecreaseDisabled), _define_property$k(_obj1, classes.errorButton, isInvalid), _obj1)),
28105
+ type: "button",
28106
+ disabled: isDecreaseDisabled,
28107
+ onClick: decrement,
28108
+ children: /* @__PURE__ */ jsx("div", {
28109
+ className: classes.icon,
28116
28110
  children: /* @__PURE__ */ jsx(Icon, {
28117
28111
  type: "minus"
28118
28112
  })
28119
28113
  })
28120
- ]
28121
- })
28122
- ]
28114
+ })
28115
+ ]
28116
+ })
28123
28117
  }));
28124
28118
  };
28125
28119
  var VERTICAL_OVERLAY_PADDING = 50;