@true-engineering/true-react-common-ui-kit 2.4.0 → 2.6.0

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,6 +1,6 @@
1
1
  import { ComponentStyles } from '../../types';
2
2
  import type { IDatePickerProps } from './DatePicker';
3
- interface IStyleProps {
3
+ export interface IDatePickerStyleProps {
4
4
  topPosition: NonNullable<IDatePickerProps['topPosition']>;
5
5
  leftPosition: NonNullable<IDatePickerProps['leftPosition']>;
6
6
  }
@@ -13,8 +13,8 @@ export declare const styles: {
13
13
  datepicker: {};
14
14
  popper: {
15
15
  zIndex: number;
16
- marginTop: ({ topPosition }: IStyleProps) => number;
17
- marginLeft: ({ leftPosition }: IStyleProps) => number;
16
+ marginTop: ({ topPosition }: IDatePickerStyleProps) => number;
17
+ marginLeft: ({ leftPosition }: IDatePickerStyleProps) => number;
18
18
  '&[data-placement^="bottom"]': {
19
19
  paddingTop: number;
20
20
  };
@@ -30,5 +30,4 @@ export declare const styles: {
30
30
  };
31
31
  tweakDateInput: {};
32
32
  };
33
- export declare type DatePickerStyles = ComponentStyles<typeof styles, IStyleProps>;
34
- export {};
33
+ export declare type DatePickerStyles = ComponentStyles<typeof styles, IDatePickerStyleProps>;
@@ -1,3 +1,4 @@
1
1
  export * from './FiltersPane';
2
2
  export * from './types';
3
3
  export * from './components';
4
+ export type { FiltersPaneStyles } from './FiltersPane.styles';
@@ -1,11 +1,11 @@
1
- import { FormEvent, FocusEvent, KeyboardEvent, ClipboardEvent } from 'react';
1
+ import { FormEvent, FocusEvent, KeyboardEvent, ClipboardEvent, ReactNode } from 'react';
2
2
  import { ICommonProps, IIcon } from '../../types';
3
3
  import { IReactInputMaskProps } from './types';
4
4
  import { InputStyles } from './Input.styles';
5
5
  export interface IInputProps extends ICommonProps, IReactInputMaskProps {
6
6
  tweakStyles?: InputStyles;
7
7
  value?: string;
8
- label?: string;
8
+ label?: ReactNode;
9
9
  placeholder?: string;
10
10
  /**
11
11
  * @default `text`
@@ -48,6 +48,7 @@ export interface IInputProps extends ICommonProps, IReactInputMaskProps {
48
48
  maxLength?: number;
49
49
  testId?: string;
50
50
  tabIndex?: number;
51
+ shouldAlwaysShowPlaceholder?: boolean;
51
52
  onChange(value: string, event: FormEvent<HTMLInputElement>): void;
52
53
  onFocus?(event: FocusEvent<HTMLInputElement>): void;
53
54
  onBlur?(event: FocusEvent<HTMLInputElement>): void;
@@ -7081,7 +7081,7 @@ var __generator$5 = globalThis && globalThis.__generator || function(thisArg, bo
7081
7081
  }
7082
7082
  };
7083
7083
  var Input = /* @__PURE__ */ forwardRef(function(param, ref) {
7084
- var _param_value = param.value, value = _param_value === void 0 ? "" : _param_value, label = param.label, placeholder = param.placeholder, _param_type = param.type, type = _param_type === void 0 ? "text" : _param_type, isDisabled = param.isDisabled, isReadonly = param.isReadonly, _param_hasFloatingLabel = param.hasFloatingLabel, hasFloatingLabel = _param_hasFloatingLabel === void 0 ? true : _param_hasFloatingLabel, _param_isInvalid = param.isInvalid, isInvalid = _param_isInvalid === void 0 ? false : _param_isInvalid, _param_isActive = param.isActive, isActive = _param_isActive === void 0 ? false : _param_isActive, _param_isClearable = param.isClearable, isClearable = _param_isClearable === void 0 ? false : _param_isClearable, infoMessage = param.infoMessage, errorMessage = param.errorMessage, _param_errorPosition = param.errorPosition, errorPosition = _param_errorPosition === void 0 ? "bottom" : _param_errorPosition, inlineStyle = param.inlineStyle, border = param.border, isRequired = param.isRequired, isLoading = param.isLoading, isAutoSizeable = param.isAutoSizeable, _param_defaultSize = param.defaultSize, defaultSize = _param_defaultSize === void 0 ? DEFAULT_SIZE : _param_defaultSize, iconType = param.iconType, name = param.name, hasRequiredLabel = param.hasRequiredLabel, data = param.data, tweakStyles = param.tweakStyles, maxLength = param.maxLength, shouldFocusOnMount = param.shouldFocusOnMount, units = param.units, testId = param.testId, tabIndex = param.tabIndex, onChange = param.onChange, onPaste = param.onPaste, onFocus = param.onFocus, onBlur = param.onBlur, onIconClick = param.onIconClick, onKeyDown = param.onKeyDown, mask = param.mask, maskPlaceholder = param.maskPlaceholder, alwaysShowMask = param.alwaysShowMask, beforeMaskedStateChange = param.beforeMaskedStateChange;
7084
+ var _param_value = param.value, value = _param_value === void 0 ? "" : _param_value, label = param.label, placeholder = param.placeholder, _param_type = param.type, type = _param_type === void 0 ? "text" : _param_type, isDisabled = param.isDisabled, isReadonly = param.isReadonly, _param_hasFloatingLabel = param.hasFloatingLabel, hasFloatingLabel = _param_hasFloatingLabel === void 0 ? true : _param_hasFloatingLabel, _param_isInvalid = param.isInvalid, isInvalid = _param_isInvalid === void 0 ? false : _param_isInvalid, _param_isActive = param.isActive, isActive = _param_isActive === void 0 ? false : _param_isActive, _param_isClearable = param.isClearable, isClearable = _param_isClearable === void 0 ? false : _param_isClearable, infoMessage = param.infoMessage, errorMessage = param.errorMessage, _param_errorPosition = param.errorPosition, errorPosition = _param_errorPosition === void 0 ? "bottom" : _param_errorPosition, inlineStyle = param.inlineStyle, border = param.border, isRequired = param.isRequired, isLoading = param.isLoading, isAutoSizeable = param.isAutoSizeable, _param_defaultSize = param.defaultSize, defaultSize = _param_defaultSize === void 0 ? DEFAULT_SIZE : _param_defaultSize, iconType = param.iconType, name = param.name, hasRequiredLabel = param.hasRequiredLabel, data = param.data, tweakStyles = param.tweakStyles, maxLength = param.maxLength, shouldFocusOnMount = param.shouldFocusOnMount, units = param.units, testId = param.testId, tabIndex = param.tabIndex, onChange = param.onChange, onPaste = param.onPaste, onFocus = param.onFocus, onBlur = param.onBlur, onIconClick = param.onIconClick, onKeyDown = param.onKeyDown, mask = param.mask, maskPlaceholder = param.maskPlaceholder, alwaysShowMask = param.alwaysShowMask, shouldAlwaysShowPlaceholder = param.shouldAlwaysShowPlaceholder, beforeMaskedStateChange = param.beforeMaskedStateChange;
7085
7085
  var _useTheme = useTheme("Input", styles$x, tweakStyles), classes = _useTheme.classes, componentStyles = _useTheme.componentStyles;
7086
7086
  var _useState = _sliced_to_array$l(useState(false), 2), isFocused = _useState[0], setFocused = _useState[1];
7087
7087
  var inputRef = useRef(null);
@@ -7125,8 +7125,8 @@ var Input = /* @__PURE__ */ forwardRef(function(param, ref) {
7125
7125
  var hasControls = hasClearIcon || iconType !== void 0 || isLoading;
7126
7126
  var hasValue = value !== void 0 && value !== "";
7127
7127
  var hasUnits = units !== void 0 && units !== "";
7128
- var hasLabel = isStringNotEmpty$1(label);
7129
- var hasPlaceholder = (!hasLabel || hasFocus && !isReadonly) && isStringNotEmpty$1(placeholder);
7128
+ var hasLabel = isReactNodeNotEmpty(label);
7129
+ var hasPlaceholder = (!hasLabel || hasFocus && !isReadonly || shouldAlwaysShowPlaceholder) && isStringNotEmpty$1(placeholder);
7130
7130
  var shouldShowUnits = (hasValue || isFocused && !hasPlaceholder) && hasUnits;
7131
7131
  var _obj;
7132
7132
  var props = _object_spread$A({
@@ -7071,7 +7071,7 @@
7071
7071
  }
7072
7072
  };
7073
7073
  var Input = /* @__PURE__ */ React.forwardRef(function(param, ref) {
7074
- var _param_value = param.value, value = _param_value === void 0 ? "" : _param_value, label = param.label, placeholder = param.placeholder, _param_type = param.type, type = _param_type === void 0 ? "text" : _param_type, isDisabled = param.isDisabled, isReadonly = param.isReadonly, _param_hasFloatingLabel = param.hasFloatingLabel, hasFloatingLabel = _param_hasFloatingLabel === void 0 ? true : _param_hasFloatingLabel, _param_isInvalid = param.isInvalid, isInvalid = _param_isInvalid === void 0 ? false : _param_isInvalid, _param_isActive = param.isActive, isActive = _param_isActive === void 0 ? false : _param_isActive, _param_isClearable = param.isClearable, isClearable = _param_isClearable === void 0 ? false : _param_isClearable, infoMessage = param.infoMessage, errorMessage = param.errorMessage, _param_errorPosition = param.errorPosition, errorPosition = _param_errorPosition === void 0 ? "bottom" : _param_errorPosition, inlineStyle = param.inlineStyle, border = param.border, isRequired = param.isRequired, isLoading = param.isLoading, isAutoSizeable = param.isAutoSizeable, _param_defaultSize = param.defaultSize, defaultSize = _param_defaultSize === void 0 ? DEFAULT_SIZE : _param_defaultSize, iconType = param.iconType, name = param.name, hasRequiredLabel = param.hasRequiredLabel, data = param.data, tweakStyles = param.tweakStyles, maxLength = param.maxLength, shouldFocusOnMount = param.shouldFocusOnMount, units = param.units, testId = param.testId, tabIndex = param.tabIndex, onChange = param.onChange, onPaste = param.onPaste, onFocus = param.onFocus, onBlur = param.onBlur, onIconClick = param.onIconClick, onKeyDown = param.onKeyDown, mask = param.mask, maskPlaceholder = param.maskPlaceholder, alwaysShowMask = param.alwaysShowMask, beforeMaskedStateChange = param.beforeMaskedStateChange;
7074
+ var _param_value = param.value, value = _param_value === void 0 ? "" : _param_value, label = param.label, placeholder = param.placeholder, _param_type = param.type, type = _param_type === void 0 ? "text" : _param_type, isDisabled = param.isDisabled, isReadonly = param.isReadonly, _param_hasFloatingLabel = param.hasFloatingLabel, hasFloatingLabel = _param_hasFloatingLabel === void 0 ? true : _param_hasFloatingLabel, _param_isInvalid = param.isInvalid, isInvalid = _param_isInvalid === void 0 ? false : _param_isInvalid, _param_isActive = param.isActive, isActive = _param_isActive === void 0 ? false : _param_isActive, _param_isClearable = param.isClearable, isClearable = _param_isClearable === void 0 ? false : _param_isClearable, infoMessage = param.infoMessage, errorMessage = param.errorMessage, _param_errorPosition = param.errorPosition, errorPosition = _param_errorPosition === void 0 ? "bottom" : _param_errorPosition, inlineStyle = param.inlineStyle, border = param.border, isRequired = param.isRequired, isLoading = param.isLoading, isAutoSizeable = param.isAutoSizeable, _param_defaultSize = param.defaultSize, defaultSize = _param_defaultSize === void 0 ? DEFAULT_SIZE : _param_defaultSize, iconType = param.iconType, name = param.name, hasRequiredLabel = param.hasRequiredLabel, data = param.data, tweakStyles = param.tweakStyles, maxLength = param.maxLength, shouldFocusOnMount = param.shouldFocusOnMount, units = param.units, testId = param.testId, tabIndex = param.tabIndex, onChange = param.onChange, onPaste = param.onPaste, onFocus = param.onFocus, onBlur = param.onBlur, onIconClick = param.onIconClick, onKeyDown = param.onKeyDown, mask = param.mask, maskPlaceholder = param.maskPlaceholder, alwaysShowMask = param.alwaysShowMask, shouldAlwaysShowPlaceholder = param.shouldAlwaysShowPlaceholder, beforeMaskedStateChange = param.beforeMaskedStateChange;
7075
7075
  var _useTheme = useTheme("Input", styles$x, tweakStyles), classes = _useTheme.classes, componentStyles = _useTheme.componentStyles;
7076
7076
  var _useState = _sliced_to_array$l(React.useState(false), 2), isFocused = _useState[0], setFocused = _useState[1];
7077
7077
  var inputRef = React.useRef(null);
@@ -7115,8 +7115,8 @@
7115
7115
  var hasControls = hasClearIcon || iconType !== void 0 || isLoading;
7116
7116
  var hasValue = value !== void 0 && value !== "";
7117
7117
  var hasUnits = units !== void 0 && units !== "";
7118
- var hasLabel = trueReactPlatformHelpers.isStringNotEmpty(label);
7119
- var hasPlaceholder = (!hasLabel || hasFocus && !isReadonly) && trueReactPlatformHelpers.isStringNotEmpty(placeholder);
7118
+ var hasLabel = trueReactPlatformHelpers.isReactNodeNotEmpty(label);
7119
+ var hasPlaceholder = (!hasLabel || hasFocus && !isReadonly || shouldAlwaysShowPlaceholder) && trueReactPlatformHelpers.isStringNotEmpty(placeholder);
7120
7120
  var shouldShowUnits = (hasValue || isFocused && !hasPlaceholder) && hasUnits;
7121
7121
  var _obj;
7122
7122
  var props = _object_spread$A({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@true-engineering/true-react-common-ui-kit",
3
- "version": "2.4.0",
3
+ "version": "2.6.0",
4
4
  "description": "True Engineering React UI Kit with theming support",
5
5
  "author": "True Engineering (https://trueengineering.ru)",
6
6
  "keywords": [
@@ -1,7 +1,7 @@
1
1
  import { ComponentStyles } from '../../types';
2
2
  import type { IDatePickerProps } from './DatePicker';
3
3
 
4
- interface IStyleProps {
4
+ export interface IDatePickerStyleProps {
5
5
  topPosition: NonNullable<IDatePickerProps['topPosition']>;
6
6
  leftPosition: NonNullable<IDatePickerProps['leftPosition']>;
7
7
  }
@@ -18,8 +18,8 @@ export const styles = {
18
18
 
19
19
  popper: {
20
20
  zIndex: 10,
21
- marginTop: ({ topPosition }: IStyleProps): number => topPosition,
22
- marginLeft: ({ leftPosition }: IStyleProps): number => leftPosition,
21
+ marginTop: ({ topPosition }: IDatePickerStyleProps): number => topPosition,
22
+ marginLeft: ({ leftPosition }: IDatePickerStyleProps): number => leftPosition,
23
23
 
24
24
  '&[data-placement^="bottom"]': {
25
25
  paddingTop: 6,
@@ -41,4 +41,4 @@ export const styles = {
41
41
  tweakDateInput: {},
42
42
  };
43
43
 
44
- export type DatePickerStyles = ComponentStyles<typeof styles, IStyleProps>;
44
+ export type DatePickerStyles = ComponentStyles<typeof styles, IDatePickerStyleProps>;
@@ -2,3 +2,4 @@ export * from './FiltersPane';
2
2
  export * from './types';
3
3
  // TODO : подумать над тем чтобы вынести это все наружу
4
4
  export * from './components';
5
+ export type { FiltersPaneStyles } from './FiltersPane.styles';
@@ -9,6 +9,7 @@ import {
9
9
  KeyboardEvent,
10
10
  ClipboardEvent,
11
11
  InputHTMLAttributes,
12
+ ReactNode,
12
13
  } from 'react';
13
14
  import InputMask from 'react-input-mask';
14
15
  import clsx from 'clsx';
@@ -30,7 +31,7 @@ import { InputStyles, styles } from './Input.styles';
30
31
  export interface IInputProps extends ICommonProps, IReactInputMaskProps {
31
32
  tweakStyles?: InputStyles;
32
33
  value?: string;
33
- label?: string;
34
+ label?: ReactNode;
34
35
  placeholder?: string;
35
36
  /**
36
37
  * @default `text`
@@ -82,7 +83,7 @@ export interface IInputProps extends ICommonProps, IReactInputMaskProps {
82
83
  maxLength?: number;
83
84
  testId?: string;
84
85
  tabIndex?: number;
85
-
86
+ shouldAlwaysShowPlaceholder?: boolean;
86
87
  onChange(value: string, event: FormEvent<HTMLInputElement>): void;
87
88
  onFocus?(event: FocusEvent<HTMLInputElement>): void;
88
89
  onBlur?(event: FocusEvent<HTMLInputElement>): void;
@@ -133,6 +134,7 @@ export const Input = forwardRef<HTMLInputElement, IInputProps>(
133
134
  mask,
134
135
  maskPlaceholder,
135
136
  alwaysShowMask,
137
+ shouldAlwaysShowPlaceholder,
136
138
  beforeMaskedStateChange,
137
139
  },
138
140
  ref,
@@ -169,9 +171,10 @@ export const Input = forwardRef<HTMLInputElement, IInputProps>(
169
171
  const hasControls = hasClearIcon || iconType !== undefined || isLoading;
170
172
  const hasValue = value !== undefined && value !== '';
171
173
  const hasUnits = units !== undefined && units !== '';
172
- const hasLabel = isStringNotEmpty(label);
174
+ const hasLabel = isReactNodeNotEmpty(label);
173
175
  const hasPlaceholder =
174
- (!hasLabel || (hasFocus && !isReadonly)) && isStringNotEmpty(placeholder);
176
+ (!hasLabel || (hasFocus && !isReadonly) || shouldAlwaysShowPlaceholder) &&
177
+ isStringNotEmpty(placeholder);
175
178
  const shouldShowUnits = (hasValue || (isFocused && !hasPlaceholder)) && hasUnits;
176
179
 
177
180
  const props: InputHTMLAttributes<HTMLInputElement> = {