armtek-uikit-react 1.0.30 → 1.0.32

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.
package/assets/Badge.scss CHANGED
@@ -80,4 +80,11 @@ $horizontal_offset: calc(100% - 6px);
80
80
  right: $horizontal_offset;
81
81
  left: auto;
82
82
  bottom: auto;
83
+ }
84
+ .badge__item_center-right{
85
+ top: 50%;
86
+ transform: translateY(-50%);
87
+ left: calc(100% + 6px);
88
+ right: auto;
89
+ bottom: auto;
83
90
  }
package/assets/Chip.scss CHANGED
@@ -93,4 +93,8 @@ button.chip_primary{
93
93
  &:hover{
94
94
  background-color: $color-primary-dark;
95
95
  }
96
+ }
97
+ .chip_disabled{
98
+ pointer-events: none;
99
+ opacity: 0.5;
96
100
  }
@@ -20,7 +20,59 @@
20
20
  left:0;
21
21
  top:100%;
22
22
  width:100%;
23
+ background: #fff;
24
+ z-index: 100;
23
25
  }
24
26
  .options_inline{
25
27
  position: static;
28
+ }
29
+ .selectSummary__wrapper{
30
+ padding: calc($size-step * 2) calc($size-step * 2) 0;
31
+ & .selectSummary{
32
+ padding-bottom: $size-step;
33
+ border-top: 1px solid $color-gray-300;
34
+ }
35
+ }
36
+ .selectSummary{
37
+ background: #fff;
38
+ }
39
+ .selectSummary__row{
40
+ display: flex;
41
+ align-items: center;
42
+ justify-content: space-between;
43
+ }
44
+ .selectSummary__check{
45
+ margin-right: 60px;
46
+ font-size: 13px;
47
+ color: $color-gray-600;
48
+ cursor: pointer;
49
+ &:nth-child(2){
50
+ margin-right: auto;
51
+ }
52
+ }
53
+ .selectSummary__check_disabled{
54
+ opacity: 0.5;
55
+ cursor: default;
56
+ }
57
+ .selectSummary__checkLabel{
58
+ border-bottom: 1px dotted $color-gray-600;
59
+ }
60
+ .selectSummary__options{
61
+ border-bottom: 1px solid $color-gray-300;
62
+ padding: calc($size-step / 2) 0 calc($size-step) 0;
63
+ margin-bottom: calc($size-step / 2);
64
+ }
65
+ .selectSummary__optionList{
66
+ display: flex;
67
+ flex-wrap: wrap;
68
+ align-items: center;
69
+ }
70
+ .selectSummary__option{
71
+ margin-right: $size-step;
72
+ margin-top: $size-step;
73
+ }
74
+ .selectSummary__button{
75
+ width: 100px;
76
+ padding-left: 0;
77
+ padding-right: 0;
26
78
  }
@@ -100,6 +100,7 @@
100
100
  transition: 0.2s all ease;
101
101
  width: calc(100% - 2px);
102
102
  padding-top:8px;
103
+ line-height: 1.2;
103
104
  &_small{
104
105
  top: 4px;
105
106
  }
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name":"armtek-uikit-react","version":"1.0.30","description":"Armtek UIKit for React","repository":{"type":"git","url":"ssh://git@gl.corp:10022/int/uikit/uikit_react.git"},"author":"","license":"ISC","dependencies":{"rc-slider":"^10.2.1","react":"*","react-datepicker":"^4.16.0","react-dom":"*"},"peerDependencies":{"react":"*","react-dom":"*"},"scripts":{"pub":"npm version patch && npm publish"}}
1
+ {"name":"armtek-uikit-react","version":"1.0.32","description":"Armtek UIKit for React","repository":{"type":"git","url":"ssh://git@gl.corp:10022/int/uikit/uikit_react.git"},"author":"","license":"ISC","dependencies":{"rc-slider":"^10.2.1","react":"*","react-datepicker":"^4.16.0","react-dom":"*"},"peerDependencies":{"react":"*","react-dom":"*"},"scripts":{"pub":"npm version patch && npm publish"}}
@@ -17,7 +17,7 @@ const Adornment = props => {
17
17
  return /*#__PURE__*/_jsx(_Fragment, {
18
18
  children: /*#__PURE__*/_jsx("div", {
19
19
  ...spanProps,
20
- className: clsx(className, 'Arm-adornment', {
20
+ className: clsx(className, 'Arm-adornment', css.adornment, {
21
21
  [css['adornment_start']]: position === 'start',
22
22
  [css['adornment_end']]: position !== 'start'
23
23
  }),
@@ -4,8 +4,8 @@ export type BadgeProps = {
4
4
  color?: ColorType | ColorStatusType;
5
5
  children: ReactNode | string;
6
6
  shape?: ShapeType;
7
- position?: 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left';
8
- badgeText?: string;
7
+ position?: 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left' | 'center-right';
8
+ badgeText?: string | number;
9
9
  };
10
10
  declare function Badge(props: BadgeProps): import("react/jsx-runtime").JSX.Element;
11
11
  export default Badge;
package/ui/Badge/Badge.js CHANGED
@@ -3,7 +3,7 @@ import css from "./Badge.module.scss";
3
3
  import { jsx as _jsx } from "react/jsx-runtime";
4
4
  import { jsxs as _jsxs } from "react/jsx-runtime";
5
5
  import { Fragment as _Fragment } from "react/jsx-runtime";
6
- const BadgeClasses = ['badge', 'badge__item_primary', 'badge__item_secondary', 'badge__item_neutral', 'badge__item_error', 'badge__item_info', 'badge__item_warning', 'badge__item_success', 'badge__item_content', 'badge__item_content_circle', 'badge__item_content_square', 'badge__item_content_circle', 'badge__item_top-right', 'badge__item_top-left', 'badge__item_bottom-right', 'badge__item_bottom-left'];
6
+ const BadgeClasses = ['badge', 'badge__item_primary', 'badge__item_secondary', 'badge__item_neutral', 'badge__item_error', 'badge__item_info', 'badge__item_warning', 'badge__item_success', 'badge__item_content', 'badge__item_content_circle', 'badge__item_content_square', 'badge__item_content_circle', 'badge__item_top-right', 'badge__item_top-left', 'badge__item_bottom-right', 'badge__item_bottom-left', 'badge__item_center-right'];
7
7
 
8
8
  // const css = getCssPrefix(BadgeClasses)
9
9
 
@@ -21,9 +21,9 @@ function Badge(props) {
21
21
  children: props.children
22
22
  }), /*#__PURE__*/_jsx("span", {
23
23
  className: clsx(css.badge__item, css['badge__item_' + color], css['badge__item_' + shape], css['badge__item_' + position], {
24
- [css.badge__item_content]: !!props.badgeText && !shape,
25
- [css.badge__item_content_circle]: !!props.badgeText && shape === 'circle',
26
- [css.badge__item_content_square]: !!props.badgeText && shape === 'square'
24
+ [css.badge__item_content]: props.badgeText !== undefined && !shape,
25
+ [css.badge__item_content_circle]: !!props.badgeText !== undefined && shape === 'circle',
26
+ [css.badge__item_content_square]: !!props.badgeText !== undefined && shape === 'square'
27
27
  }),
28
28
  children: props.badgeText
29
29
  })]
package/ui/Chip/Chip.d.ts CHANGED
@@ -8,6 +8,8 @@ export type ChipProps<T extends ElementType = ElementType<HTMLAttributes<HTMLSpa
8
8
  icon?: string;
9
9
  variant?: Exclude<VariantType, 'transparent'>;
10
10
  as?: T;
11
+ disabled?: boolean;
12
+ className?: string;
11
13
  };
12
14
  declare function Chip<T extends ElementType>(props: ChipProps<T>): import("react/jsx-runtime").JSX.Element;
13
15
  export default Chip;
package/ui/Chip/Chip.js CHANGED
@@ -16,12 +16,16 @@ function Chip(props) {
16
16
  as,
17
17
  variant,
18
18
  color,
19
- children
19
+ className,
20
+ children,
21
+ disabled
20
22
  } = props;
21
23
  let Component = as || 'span';
22
24
  return /*#__PURE__*/_jsx(_Fragment, {
23
25
  children: /*#__PURE__*/_jsx(Component, {
24
- className: clsx('Arm-chip', css.chip, css['chip_' + size], css['chip_' + variant], css['chip_' + color]),
26
+ className: clsx('Arm-chip', className, {
27
+ [css.chip_disabled]: !!disabled
28
+ }, css.chip, css['chip_' + size], css['chip_' + variant], css['chip_' + color]),
25
29
  children: /*#__PURE__*/_jsxs("span", {
26
30
  className: css.chip__inner,
27
31
  children: [icon && /*#__PURE__*/_jsx("span", {
@@ -30,7 +34,9 @@ function Chip(props) {
30
34
  }), /*#__PURE__*/_jsx("span", {
31
35
  children: text || children
32
36
  }), onClose && /*#__PURE__*/_jsx("span", {
33
- className: clsx('material_icon_solid', css['chip__close_' + size], css['chip__close_' + color], css.chip__close),
37
+ className: clsx('material_icon_solid', {
38
+ [css.chip__close_disabled]: !!disabled
39
+ }, css['chip__close_' + size], css['chip__close_' + color], css.chip__close),
34
40
  onClick: onClose,
35
41
  children: "cancel"
36
42
  })]
@@ -5,6 +5,10 @@ type SelectBaseProps = {
5
5
  inline?: boolean;
6
6
  search?: boolean;
7
7
  open?: boolean;
8
+ listStyle?: SelectOptionsType<true>['listStyle'];
9
+ onSelectAll: () => void;
10
+ onClearAll: () => void;
11
+ onSubmit: () => void;
8
12
  };
9
13
  type SelectSingleProps = {
10
14
  multiple?: false;
@@ -22,4 +26,16 @@ type SelectProps = SelectMultipleProps | SelectSingleProps;
22
26
  type SelectPropsType = SelectBaseProps & SelectProps & Omit<TextFieldProps, 'value' | 'defaultValue' | 'onChange'>;
23
27
  export declare const getOptionValue: (option: OptionType) => string;
24
28
  declare function Select(props: SelectPropsType): import("react/jsx-runtime").JSX.Element;
29
+ type SelectOptionsType<T extends boolean> = {
30
+ options: OptionType[];
31
+ value?: T extends true ? string[] : string;
32
+ inline?: boolean;
33
+ multiple?: T;
34
+ onClick: (option: OptionType) => void;
35
+ listStyle?: 'checkbox' | 'default';
36
+ onSelectAll: () => void;
37
+ onClearAll: () => void;
38
+ onSubmit: () => void;
39
+ disabled?: boolean;
40
+ };
25
41
  export default Select;
@@ -8,6 +8,7 @@ import useClickOutside from "../../../lib/hooks/useClickOutside";
8
8
  import css from "./Select.module.scss";
9
9
  import ButtonIcon from "../../ButtonIcon";
10
10
  import Adornment from "../../Adornment";
11
+ import { SelectSummary, SelectSummaryChips } from "./SelectSummary";
11
12
  import { jsx as _jsx } from "react/jsx-runtime";
12
13
  import { Fragment as _Fragment } from "react/jsx-runtime";
13
14
  import { jsxs as _jsxs } from "react/jsx-runtime";
@@ -29,6 +30,10 @@ function Select(props) {
29
30
  onChange,
30
31
  search,
31
32
  open,
33
+ listStyle,
34
+ onSubmit,
35
+ onClearAll,
36
+ onSelectAll,
32
37
  ...inputProps
33
38
  } = props;
34
39
  let [active, setActive] = useState(false);
@@ -37,12 +42,12 @@ function Select(props) {
37
42
  let [q, setQ] = useState('');
38
43
  let selectRef = useRef(null);
39
44
  let optRef = useClickOutside(() => setActive(false));
40
- const handleActive = flag => {
41
- setActive(prev => flag !== undefined ? flag : !prev);
45
+ const handleOpen = flag => {
46
+ if (!inputProps.disabled) setActive(prev => flag !== undefined ? flag : !prev);
42
47
  };
43
48
  const handleSelect = option => {
44
49
  let v = getOptionValue(option);
45
- let mSelected = selected;
50
+ let mSelected = Array.isArray(selected) ? selected : [selected];
46
51
  let newValueS = v;
47
52
  let newValueM = mSelected.includes(v) ? mSelected.filter(item => item !== v) : mSelected.concat(v);
48
53
  setSelected(multiple ? newValueM : newValueS);
@@ -81,7 +86,6 @@ function Select(props) {
81
86
  children: [/*#__PURE__*/_jsx(Adornment, {
82
87
  children: endAdornment
83
88
  }), /*#__PURE__*/_jsx(ButtonIcon, {
84
- onClick: () => handleActive,
85
89
  size: 'small',
86
90
  variant: 'transparent',
87
91
  className: 'material_icon',
@@ -95,17 +99,33 @@ function Select(props) {
95
99
  // selectProps.onChange = handleChange
96
100
  // }
97
101
 
102
+ const handleSelectAll = () => {
103
+ let value = options.map(item => getOptionValue(item));
104
+ setSelected(value);
105
+ if (onChange) onChange(value);
106
+ };
107
+ const handleResetAll = () => {
108
+ setSelected([]);
109
+ if (onChange) onChange([]);
110
+ };
111
+ const handleSubmit = () => {
112
+ if (open === undefined) setActive(false);else if (onSubmit) {
113
+ onSubmit();
114
+ }
115
+ };
98
116
  let realValue = value !== undefined ? value : selected;
99
117
  let realActive = open !== undefined ? open : active;
100
118
  let selectedText = multiple ? options.filter(item => realValue == null ? void 0 : realValue.includes(getOptionValue(item))).map(item => item.text).join(', ') : ((_options$find = options.find(item => getOptionValue(item) === realValue)) == null ? void 0 : _options$find.text) || '';
101
119
  if (!!search) options = options.filter(item => item.text.toLowerCase().includes(q.toLowerCase()));
120
+ let valueArr = realValue ? Array.isArray(realValue) ? realValue : [realValue] : [];
121
+ let selectedOptions = options.filter(item => valueArr.includes(getOptionValue(item)));
102
122
  return /*#__PURE__*/_jsx(_Fragment, {
103
123
  children: /*#__PURE__*/_jsxs("div", {
104
124
  className: css.select,
105
125
  ref: optRef,
106
126
  children: [/*#__PURE__*/_jsxs("div", {
107
127
  className: css.select__input_wrapper,
108
- onClick: () => setActive(true),
128
+ onClick: () => handleOpen(true),
109
129
  children: [/*#__PURE__*/_jsx("select", {
110
130
  multiple: multiple,
111
131
  ref: selectRef,
@@ -130,12 +150,21 @@ function Select(props) {
130
150
  },
131
151
  editable: !!search
132
152
  })]
153
+ }), multiple && !realActive && /*#__PURE__*/_jsx(SelectSummaryChips, {
154
+ options: selectedOptions,
155
+ disabled: inputProps.disabled,
156
+ onDelete: handleSelect
133
157
  }), realActive && /*#__PURE__*/_jsx(SelectOptions, {
158
+ disabled: inputProps.disabled,
134
159
  options: options,
135
160
  multiple: multiple,
136
161
  value: realValue,
137
162
  inline: inline,
138
- onClick: handleSelect
163
+ listStyle: listStyle,
164
+ onClick: handleSelect,
165
+ onClearAll: handleResetAll,
166
+ onSelectAll: handleSelectAll,
167
+ onSubmit: handleSubmit
139
168
  })]
140
169
  })
141
170
  });
@@ -146,23 +175,38 @@ const SelectOptions = /*#__PURE__*/forwardRef((props, ref) => {
146
175
  value,
147
176
  multiple,
148
177
  inline,
149
- onClick
178
+ onClick,
179
+ listStyle,
180
+ disabled,
181
+ ...callbacks
150
182
  } = props;
151
183
  return /*#__PURE__*/_jsx(_Fragment, {
152
- children: /*#__PURE__*/_jsx("div", {
184
+ children: /*#__PURE__*/_jsxs("div", {
153
185
  ref: ref,
154
186
  className: clsx(css.options, {
155
187
  [css.options_inline]: !!inline
156
188
  }),
157
- children: options.map((item, index) => {
189
+ children: [options.map((item, index) => {
158
190
  let optValue = getOptionValue(item);
159
191
  let active = multiple === true && value ? value.includes(optValue) : optValue === value;
192
+ let checked = listStyle === 'checkbox' && !!multiple ? active : undefined;
160
193
  return /*#__PURE__*/_jsx(ListItem, {
194
+ disabled: disabled,
195
+ checked: checked,
161
196
  active: active,
162
197
  onClick: () => onClick(item),
163
198
  children: item.text
164
199
  }, index);
165
- })
200
+ }), listStyle === 'checkbox' && !!multiple && /*#__PURE__*/_jsx("div", {
201
+ className: css.selectSummary__wrapper,
202
+ children: /*#__PURE__*/_jsx(SelectSummary, {
203
+ options: options,
204
+ value: value,
205
+ onClose: onClick,
206
+ disabled: disabled,
207
+ ...callbacks
208
+ })
209
+ })]
166
210
  })
167
211
  });
168
212
  });
@@ -0,0 +1,21 @@
1
+ import { OptionType } from '../../../types/theme';
2
+ export type SelectSummaryProps = {
3
+ label_check_all?: string;
4
+ label_uncheck_all?: string;
5
+ label_submit?: string;
6
+ onClose: (option: OptionType) => void;
7
+ onSelectAll: () => void;
8
+ onClearAll: () => void;
9
+ onSubmit: () => void;
10
+ options: OptionType[];
11
+ value: string[];
12
+ disabled?: boolean;
13
+ };
14
+ export declare const SelectSummary: (props: SelectSummaryProps) => import("react/jsx-runtime").JSX.Element;
15
+ type SelectSummaryChipsProps = {
16
+ options: OptionType[];
17
+ disabled?: boolean;
18
+ onDelete: (option: OptionType) => void;
19
+ };
20
+ export declare const SelectSummaryChips: (props: SelectSummaryChipsProps) => import("react/jsx-runtime").JSX.Element;
21
+ export {};
@@ -0,0 +1,104 @@
1
+ import Badge from "../../Badge";
2
+ import Button from "../../Button";
3
+ import clsx from 'clsx';
4
+ import css from "./Select.module.scss";
5
+ import Chip from "../../Chip";
6
+ import { getOptionValue } from "./Select";
7
+ import { jsx as _jsx } from "react/jsx-runtime";
8
+ import { jsxs as _jsxs } from "react/jsx-runtime";
9
+ import { Fragment as _Fragment } from "react/jsx-runtime";
10
+ export const SelectSummary = props => {
11
+ let {
12
+ label_check_all = 'Выбрать все',
13
+ label_uncheck_all = 'Очистить все',
14
+ label_submit = 'Применить',
15
+ options,
16
+ value,
17
+ onClose,
18
+ onSubmit,
19
+ onClearAll,
20
+ onSelectAll,
21
+ disabled
22
+ } = props;
23
+ let valueArr = value ? Array.isArray(value) ? value : [value] : [];
24
+ let selectedOptions = options.filter(item => valueArr.includes(getOptionValue(item)));
25
+ let selectAllDisabled = disabled || selectedOptions.length === options.length;
26
+ let resetAllDisabled = disabled || selectedOptions.length === 0;
27
+ return /*#__PURE__*/_jsx(_Fragment, {
28
+ children: /*#__PURE__*/_jsxs("div", {
29
+ className: clsx('Arm-select-summary', css.selectSummary),
30
+ children: [/*#__PURE__*/_jsx("div", {
31
+ className: css.selectSummary__options,
32
+ children: /*#__PURE__*/_jsx(SelectSummaryChips, {
33
+ options: selectedOptions,
34
+ onDelete: onClose,
35
+ disabled: disabled
36
+ })
37
+ }), /*#__PURE__*/_jsxs("div", {
38
+ className: css.selectSummary__row,
39
+ children: [/*#__PURE__*/_jsx("div", {
40
+ className: clsx(css.selectSummary__check, {
41
+ [css.selectSummary__check_disabled]: selectAllDisabled
42
+ }),
43
+ children: /*#__PURE__*/_jsx(Badge, {
44
+ badgeText: options.length,
45
+ shape: 'square',
46
+ color: 'info',
47
+ position: 'center-right',
48
+ children: /*#__PURE__*/_jsx("span", {
49
+ className: css.selectSummary__checkLabel,
50
+ onClick: onSelectAll,
51
+ children: label_check_all
52
+ })
53
+ })
54
+ }), /*#__PURE__*/_jsx("div", {
55
+ className: clsx(css.selectSummary__check, {
56
+ [css.selectSummary__check_disabled]: resetAllDisabled
57
+ }),
58
+ children: /*#__PURE__*/_jsx(Badge, {
59
+ badgeText: selectedOptions.length,
60
+ shape: 'square',
61
+ color: 'info',
62
+ position: 'center-right',
63
+ children: /*#__PURE__*/_jsx("span", {
64
+ className: css.selectSummary__checkLabel,
65
+ onClick: onClearAll,
66
+ children: label_uncheck_all
67
+ })
68
+ })
69
+ }), /*#__PURE__*/_jsx("div", {
70
+ children: /*#__PURE__*/_jsx(Button, {
71
+ className: css.selectSummary__button,
72
+ disabled: disabled,
73
+ variant: 'transparent',
74
+ size: 'small',
75
+ onClick: onSubmit,
76
+ children: /*#__PURE__*/_jsx("span", {
77
+ children: label_submit
78
+ })
79
+ })
80
+ })]
81
+ })]
82
+ })
83
+ });
84
+ };
85
+ export const SelectSummaryChips = props => {
86
+ let {
87
+ options,
88
+ onDelete,
89
+ disabled
90
+ } = props;
91
+ return /*#__PURE__*/_jsx(_Fragment, {
92
+ children: /*#__PURE__*/_jsx("div", {
93
+ className: css.selectSummary__optionList,
94
+ children: options.map(option => {
95
+ return /*#__PURE__*/_jsx(Chip, {
96
+ disabled: disabled,
97
+ className: css.selectSummary__option,
98
+ text: option.text,
99
+ onClose: () => onDelete(option)
100
+ }, getOptionValue(option));
101
+ })
102
+ })
103
+ });
104
+ };
@@ -34,6 +34,7 @@ const ListItem = props => {
34
34
  children: [checked !== undefined && /*#__PURE__*/_jsx(Adornment, {
35
35
  position: 'start',
36
36
  children: /*#__PURE__*/_jsx(Checkbox, {
37
+ disabled: restProps.disabled,
37
38
  checked: checked,
38
39
  readOnly: true,
39
40
  size: 'small'