@sima-land/ui-nucleons 45.0.0-alpha.4 → 45.0.0-alpha.5

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.
Files changed (190) hide show
  1. package/_internal/custom-scrollbar/index.js +5 -27
  2. package/_internal/dropdown-loading/index.js +2 -3
  3. package/_internal/page-scroll-lock/context.js +3 -25
  4. package/alert/index.d.ts +2 -2
  5. package/alert/index.js +4 -30
  6. package/arrow-button/index.js +18 -19
  7. package/autocomplete/autocomplete.js +49 -76
  8. package/autocomplete-deprecated/index.d.ts +1 -1
  9. package/autocomplete-deprecated/index.js +43 -67
  10. package/avatar/avatar.module.scss +3 -1
  11. package/avatar/index.d.ts +1 -1
  12. package/avatar/index.js +7 -33
  13. package/avatar/user.d.ts +1 -1
  14. package/avatar/user.js +8 -29
  15. package/base-input/base-input.js +5 -31
  16. package/base-input-deprecated/index.d.ts +2 -2
  17. package/base-input-deprecated/index.js +8 -34
  18. package/bordered-layout/index.d.ts +1 -1
  19. package/bordered-layout/index.js +2 -3
  20. package/bottom-bar/bottom-bar.js +2 -3
  21. package/box/index.d.ts +1 -1
  22. package/box/index.js +2 -2
  23. package/button/index.d.ts +2 -2
  24. package/button/index.js +6 -32
  25. package/card/index.js +2 -8
  26. package/card/slots.d.ts +1 -1
  27. package/card/slots.js +9 -31
  28. package/carousel/draggable.d.ts +1 -1
  29. package/carousel/draggable.js +5 -28
  30. package/carousel/index.d.ts +1 -1
  31. package/carousel/index.js +17 -43
  32. package/checkbox/index.d.ts +2 -2
  33. package/checkbox/index.js +3 -29
  34. package/checkbox-field/index.d.ts +2 -2
  35. package/checkbox-field/index.js +3 -31
  36. package/chips/index.d.ts +1 -1
  37. package/chips/index.js +3 -25
  38. package/chips/item.d.ts +1 -1
  39. package/chips/item.js +3 -5
  40. package/clean-buttons/index.js +6 -28
  41. package/dot-nav/index.d.ts +1 -1
  42. package/dot-nav/index.js +12 -34
  43. package/dropdown/index.d.ts +2 -2
  44. package/dropdown/index.js +3 -26
  45. package/dropdown-item/index.d.ts +1 -1
  46. package/dropdown-item/index.js +4 -9
  47. package/expandable/index.d.ts +2 -2
  48. package/expandable/index.js +8 -36
  49. package/field-block/index.js +2 -9
  50. package/field-grid/index.d.ts +1 -1
  51. package/field-grid/index.js +43 -65
  52. package/file-icon/index.d.ts +1 -1
  53. package/file-icon/index.js +5 -10
  54. package/group-overflow/index.js +6 -30
  55. package/helpers/define-slots.d.ts +1 -1
  56. package/helpers/events.d.ts +1 -1
  57. package/helpers/on.d.ts +1 -1
  58. package/hint/hint-view.js +3 -3
  59. package/hint/hint.js +3 -8
  60. package/hint-deprecated/index.d.ts +2 -2
  61. package/hint-deprecated/index.js +3 -26
  62. package/hooks/breakpoint/index.js +3 -25
  63. package/info-text/index.js +15 -42
  64. package/input/index.js +8 -30
  65. package/layout/layout.js +2 -2
  66. package/layout/legacy.d.ts +5 -5
  67. package/layout/legacy.js +3 -25
  68. package/link/index.d.ts +6 -3
  69. package/link/index.js +3 -25
  70. package/loading-overlay/index.d.ts +1 -1
  71. package/loading-overlay/index.js +2 -3
  72. package/masked-field/index.d.ts +2 -2
  73. package/masked-field/index.js +3 -25
  74. package/masked-input/masked-input.js +3 -25
  75. package/modal/index.d.ts +1 -1
  76. package/modal/index.js +3 -10
  77. package/modal/slots.js +6 -29
  78. package/modal-overlay/index.js +3 -26
  79. package/no-index/index.d.ts +3 -3
  80. package/no-index/index.js +4 -8
  81. package/no-index-mark/index.d.ts +2 -2
  82. package/no-index-mark/index.js +7 -6
  83. package/package.json +6 -11
  84. package/pagination/index.d.ts +4 -20
  85. package/pagination/index.js +8 -15
  86. package/pagination/pagination-item.d.ts +8 -0
  87. package/pagination/pagination-item.js +31 -0
  88. package/pagination/pagination-item.module.scss +49 -0
  89. package/pagination/pagination.d.ts +8 -0
  90. package/pagination/pagination.js +78 -0
  91. package/pagination/pagination.module.scss +14 -70
  92. package/pagination/types.d.ts +28 -0
  93. package/pagination/types.js +2 -0
  94. package/pagination/utils.d.ts +15 -43
  95. package/pagination/utils.js +38 -87
  96. package/{pagination → pagination-deprecated}/base-pagination.d.ts +6 -1
  97. package/{pagination → pagination-deprecated}/base-pagination.js +33 -33
  98. package/pagination-deprecated/index.d.ts +22 -0
  99. package/pagination-deprecated/index.js +15 -0
  100. package/{pagination → pagination-deprecated}/page-button.d.ts +2 -1
  101. package/{pagination → pagination-deprecated}/page-button.js +3 -5
  102. package/pagination-deprecated/pagination.module.scss +76 -0
  103. package/pagination-deprecated/utils.d.ts +58 -0
  104. package/pagination-deprecated/utils.js +124 -0
  105. package/panel/index.js +3 -6
  106. package/phone-input/images/armenia.png +0 -0
  107. package/phone-input/images/azerbaijan.png +0 -0
  108. package/phone-input/images/belarus.png +0 -0
  109. package/phone-input/images/georgia.png +0 -0
  110. package/phone-input/images/kazakhstan.png +0 -0
  111. package/phone-input/images/kyrgyzstan.png +0 -0
  112. package/phone-input/images/moldova.png +0 -0
  113. package/phone-input/images/other.png +0 -0
  114. package/phone-input/images/russia.png +0 -0
  115. package/phone-input/images/tajikistan.png +0 -0
  116. package/phone-input/images/turkmenistan.png +0 -0
  117. package/phone-input/images/ukraine.png +0 -0
  118. package/phone-input/images/uzbekistan.png +0 -0
  119. package/phone-input/phone-input.js +13 -37
  120. package/phone-input/presets.js +2 -0
  121. package/phone-input-deprecated/index.d.ts +1 -1
  122. package/phone-input-deprecated/index.js +31 -57
  123. package/plate/index.d.ts +2 -2
  124. package/plate/index.js +3 -25
  125. package/popup/popup-view.js +3 -6
  126. package/popup/popup.js +4 -26
  127. package/portal/index.d.ts +1 -1
  128. package/price/index.js +2 -2
  129. package/radio-button/index.js +2 -4
  130. package/range/index.d.ts +1 -1
  131. package/range/index.js +6 -33
  132. package/rating/index.d.ts +1 -1
  133. package/rating/index.js +4 -9
  134. package/readme.md +4 -67
  135. package/screen/index.d.ts +5 -5
  136. package/screen/index.js +11 -37
  137. package/screen/slots.d.ts +3 -3
  138. package/screen/slots.js +9 -31
  139. package/select/parts/block.js +6 -28
  140. package/select/parts/button.js +7 -29
  141. package/select/parts/menu.js +12 -33
  142. package/select/select.js +4 -28
  143. package/select-deprecated/index.d.ts +1 -1
  144. package/select-deprecated/index.js +32 -56
  145. package/side-page/index.js +4 -30
  146. package/side-page/slots.js +4 -4
  147. package/spinner/index.d.ts +1 -1
  148. package/spinner/index.js +3 -5
  149. package/spinner/spinner.module.scss +3 -1
  150. package/stepper/index.d.ts +2 -2
  151. package/stepper/index.js +11 -38
  152. package/stroked-svg/index.d.ts +2 -2
  153. package/stroked-svg/index.js +3 -27
  154. package/styling/sizes.module.scss +3 -1
  155. package/super-ellipse-clip-path/index.js +2 -8
  156. package/switcher-row/index.js +5 -10
  157. package/tabs/index.d.ts +1 -1
  158. package/tabs/index.js +4 -26
  159. package/text/index.d.ts +2 -2
  160. package/text/index.js +3 -25
  161. package/text-button/index.d.ts +2 -2
  162. package/text-button/index.js +4 -7
  163. package/text-field/index.d.ts +2 -2
  164. package/text-field/index.js +25 -55
  165. package/textarea/index.js +4 -26
  166. package/timer/index.d.ts +1 -1
  167. package/timer/index.js +3 -25
  168. package/toggle/index.d.ts +2 -2
  169. package/toggle/index.js +3 -27
  170. package/tooltip/index.d.ts +2 -2
  171. package/tooltip/index.js +4 -28
  172. package/top-bar/top-bar.js +5 -45
  173. package/top-bar/utils.d.ts +2 -2
  174. package/top-bar/utils.js +6 -28
  175. package/touch-slider/index.d.ts +1 -1
  176. package/touch-slider/index.js +2 -4
  177. package/unknown-content/index.d.ts +1 -1
  178. package/unknown-content/index.js +3 -25
  179. package/upload-area/upload-area.js +8 -38
  180. package/with-hint/index.d.ts +1 -1
  181. package/with-hint/index.js +3 -28
  182. package/with-hint/positioning-hint.d.ts +1 -1
  183. package/with-hint/positioning-hint.js +3 -25
  184. package/with-tooltip/index.d.ts +1 -1
  185. package/with-tooltip/index.js +6 -31
  186. package/with-tooltip/positioning-tooltip.d.ts +1 -1
  187. package/with-tooltip/positioning-tooltip.js +4 -26
  188. package/file-icon/unknown.svg +0 -9
  189. package/rating/star.svg +0 -3
  190. package/upload-area/upload.svg +0 -6
@@ -1,6 +1,7 @@
1
- import React from 'react';
1
+ /// <reference types="react" />
2
2
  import { PageButtonProps } from './page-button';
3
3
  import { getPageButtons } from './utils';
4
+ /** @deprecated */
4
5
  interface RenderButtonProps extends PageButtonProps {
5
6
  type?: 'prev' | 'next' | 'more';
6
7
  isFirst?: boolean;
@@ -8,6 +9,7 @@ interface RenderButtonProps extends PageButtonProps {
8
9
  page?: number;
9
10
  selected?: boolean;
10
11
  }
12
+ /** @deprecated */
11
13
  export interface BasePaginationProps {
12
14
  total: number;
13
15
  current: number;
@@ -24,11 +26,13 @@ export interface BasePaginationProps {
24
26
  }) => boolean;
25
27
  calculateButtons?: typeof getPageButtons;
26
28
  }
29
+ /** @deprecated */
27
30
  export declare const BUTTON_TYPES: {
28
31
  readonly prev: "prev";
29
32
  readonly next: "next";
30
33
  readonly more: "more";
31
34
  };
35
+ /** @deprecated */
32
36
  export declare const BUTTON_CONTENTS: {
33
37
  readonly prev: JSX.Element;
34
38
  readonly next: JSX.Element;
@@ -46,6 +50,7 @@ export declare const BUTTON_CONTENTS: {
46
50
  * @param props.needNextButton Должна определить, нужно ла выводить кнопку "Назад".
47
51
  * @param props.calculateButtons Должна вернуть список кнопок (например ['prev', 1, 2, 3, 'next']).
48
52
  * @return Элемент.
53
+ * @deprecated
49
54
  */
50
55
  export declare const BasePagination: React.FC<BasePaginationProps>;
51
56
  export {};
@@ -15,31 +15,33 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  exports.BasePagination = exports.BUTTON_CONTENTS = exports.BUTTON_TYPES = void 0;
18
- const react_1 = __importDefault(require("react"));
18
+ const jsx_runtime_1 = require("react/jsx-runtime");
19
19
  const page_button_1 = require("./page-button");
20
20
  const utils_1 = require("./utils");
21
21
  const fp_1 = require("lodash/fp");
22
22
  const lodash_1 = require("lodash");
23
23
  const sizes_1 = require("../styling/sizes");
24
- const left_1 = __importDefault(require("@sima-land/ui-quarks/icons/16x16/Stroked/Arrows/left"));
25
- const right_1 = __importDefault(require("@sima-land/ui-quarks/icons/16x16/Stroked/Arrows/right"));
24
+ const Left_1 = __importDefault(require("@sima-land/ui-quarks/icons/16x16/Stroked/Arrows/Left"));
25
+ const Right_1 = __importDefault(require("@sima-land/ui-quarks/icons/16x16/Stroked/Arrows/Right"));
26
26
  const DEFAULTS = {
27
27
  renderButton: (_a, index) => {
28
28
  var { type, isFirst, isLast } = _a, restProps = __rest(_a, ["type", "isFirst", "isLast"]);
29
- return (react_1.default.createElement(page_button_1.PageButton, Object.assign({ key: index, rounded: resolveRounded({ type, isFirst, isLast }), className: getClassByType(type) }, restProps)));
29
+ return ((0, jsx_runtime_1.jsx)(page_button_1.PageButton, Object.assign({ rounded: resolveRounded({ type, isFirst, isLast }), className: getClassByType(type) }, restProps), index));
30
30
  },
31
31
  needPrevButton: ({ current }) => current > 1,
32
32
  needNextButton: ({ current, total }) => current < total,
33
33
  calculateButtons: utils_1.getPageButtons,
34
34
  };
35
+ /** @deprecated */
35
36
  exports.BUTTON_TYPES = {
36
37
  prev: 'prev',
37
38
  next: 'next',
38
39
  more: 'more',
39
40
  };
41
+ /** @deprecated */
40
42
  exports.BUTTON_CONTENTS = {
41
- prev: react_1.default.createElement(left_1.default, { className: (0, utils_1.cx)('icon') }),
42
- next: react_1.default.createElement(right_1.default, { className: (0, utils_1.cx)('icon') }),
43
+ prev: (0, jsx_runtime_1.jsx)(Left_1.default, { className: (0, utils_1.cx)('icon') }),
44
+ next: (0, jsx_runtime_1.jsx)(Right_1.default, { className: (0, utils_1.cx)('icon') }),
43
45
  more: '...',
44
46
  };
45
47
  /**
@@ -54,6 +56,7 @@ exports.BUTTON_CONTENTS = {
54
56
  * @param props.needNextButton Должна определить, нужно ла выводить кнопку "Назад".
55
57
  * @param props.calculateButtons Должна вернуть список кнопок (например ['prev', 1, 2, 3, 'next']).
56
58
  * @return Элемент.
59
+ * @deprecated
57
60
  */
58
61
  const BasePagination = ({ total, current, onButtonClick, isButtonSelected = (0, fp_1.eq)(current), renderButton = DEFAULTS.renderButton, needPrevButton = DEFAULTS.needPrevButton, needNextButton = DEFAULTS.needNextButton, calculateButtons = DEFAULTS.calculateButtons, }) => {
59
62
  const pageButtons = calculateButtons({
@@ -61,33 +64,30 @@ const BasePagination = ({ total, current, onButtonClick, isButtonSelected = (0,
61
64
  total,
62
65
  buttonKeys: exports.BUTTON_TYPES,
63
66
  });
64
- return (react_1.default.createElement("div", { className: (0, utils_1.cx)('base-pagination-wrapper') },
65
- needPrevButton({ current, total }) &&
66
- renderButton({
67
- 'aria-label': 'Назад',
68
- type: exports.BUTTON_TYPES.prev,
69
- children: exports.BUTTON_CONTENTS.prev,
70
- onClick: () => onButtonClick && onButtonClick(current - 1),
71
- page: current - 1,
72
- }),
73
- pageButtons.map(({ content, value }, index) => renderButton({
74
- type: content === exports.BUTTON_TYPES.more ? exports.BUTTON_TYPES.more : undefined,
75
- isFirst: index === 0,
76
- isLast: index === pageButtons.length - 1,
77
- children: (0, lodash_1.has)(exports.BUTTON_CONTENTS, content) ? exports.BUTTON_CONTENTS[content] : content,
78
- selected: isButtonSelected(content),
79
- 'aria-label': `Перейти на страницу ${value}`,
80
- onClick: () => onButtonClick && onButtonClick(value),
81
- page: value,
82
- }, index)),
83
- needNextButton({ current, total }) &&
84
- renderButton({
85
- 'aria-label': 'Вперед',
86
- type: exports.BUTTON_TYPES.next,
87
- children: exports.BUTTON_CONTENTS.next,
88
- onClick: () => onButtonClick && onButtonClick(current + 1),
89
- page: current + 1,
90
- })));
67
+ return ((0, jsx_runtime_1.jsxs)("div", Object.assign({ className: (0, utils_1.cx)('base-pagination-wrapper') }, { children: [needPrevButton({ current, total }) &&
68
+ renderButton({
69
+ 'aria-label': 'Назад',
70
+ type: exports.BUTTON_TYPES.prev,
71
+ children: exports.BUTTON_CONTENTS.prev,
72
+ onClick: () => onButtonClick && onButtonClick(current - 1),
73
+ page: current - 1,
74
+ }), pageButtons.map(({ content, value }, index) => renderButton({
75
+ type: content === exports.BUTTON_TYPES.more ? exports.BUTTON_TYPES.more : undefined,
76
+ isFirst: index === 0,
77
+ isLast: index === pageButtons.length - 1,
78
+ children: (0, lodash_1.has)(exports.BUTTON_CONTENTS, content) ? exports.BUTTON_CONTENTS[content] : content,
79
+ selected: isButtonSelected(content),
80
+ 'aria-label': `Перейти на страницу ${value}`,
81
+ onClick: () => onButtonClick && onButtonClick(value),
82
+ page: value,
83
+ }, index)), needNextButton({ current, total }) &&
84
+ renderButton({
85
+ 'aria-label': 'Вперед',
86
+ type: exports.BUTTON_TYPES.next,
87
+ children: exports.BUTTON_CONTENTS.next,
88
+ onClick: () => onButtonClick && onButtonClick(current + 1),
89
+ page: current + 1,
90
+ })] })));
91
91
  };
92
92
  exports.BasePagination = BasePagination;
93
93
  const resolveRounded = (0, fp_1.cond)([
@@ -0,0 +1,22 @@
1
+ /// <reference types="react" />
2
+ import { BasePaginationProps } from './base-pagination';
3
+ /** @deprecated */
4
+ export interface PaginationProps {
5
+ /** Общее количество страниц. */
6
+ total: number;
7
+ /** Индекс текущей страницы. */
8
+ current: number;
9
+ /** Сработает при выборе страницы. */
10
+ onChange?: (data: {
11
+ value: number;
12
+ }) => void;
13
+ /** Функция возвращающая компонент кнопки. */
14
+ renderButton?: BasePaginationProps['renderButton'];
15
+ }
16
+ /**
17
+ * Компонент списка кнопок навигации по страницам.
18
+ * @param props Свойства.
19
+ * @return Элемент.
20
+ * @deprecated
21
+ */
22
+ export declare const Pagination: React.FC<PaginationProps>;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Pagination = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const base_pagination_1 = require("./base-pagination");
6
+ /**
7
+ * Компонент списка кнопок навигации по страницам.
8
+ * @param props Свойства.
9
+ * @return Элемент.
10
+ * @deprecated
11
+ */
12
+ const Pagination = ({ total, current, onChange, renderButton, }) => ((0, jsx_runtime_1.jsx)(base_pagination_1.BasePagination, { total: total, current: current, renderButton: renderButton, onButtonClick: content => {
13
+ Number.isFinite(content) && onChange && onChange({ value: content });
14
+ } }));
15
+ exports.Pagination = Pagination;
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ /// <reference types="react" />
2
2
  export interface PageButtonProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'type'> {
3
3
  rounded?: 'all' | 'none' | 'left' | 'right';
4
4
  className?: string;
@@ -11,5 +11,6 @@ export interface PageButtonProps extends Omit<React.ButtonHTMLAttributes<HTMLBut
11
11
  * @param props.className CSS-класс.
12
12
  * @param props.rounded С какой стороны делать скругления.
13
13
  * @return Элемент.
14
+ * @deprecated
14
15
  */
15
16
  export declare const PageButton: React.FC<PageButtonProps>;
@@ -10,12 +10,9 @@ var __rest = (this && this.__rest) || function (s, e) {
10
10
  }
11
11
  return t;
12
12
  };
13
- var __importDefault = (this && this.__importDefault) || function (mod) {
14
- return (mod && mod.__esModule) ? mod : { "default": mod };
15
- };
16
13
  Object.defineProperty(exports, "__esModule", { value: true });
17
14
  exports.PageButton = void 0;
18
- const react_1 = __importDefault(require("react"));
15
+ const jsx_runtime_1 = require("react/jsx-runtime");
19
16
  const utils_1 = require("./utils");
20
17
  /**
21
18
  * Компонент кнопки страницы по умолчанию. Поддерживаются свойства элемента button.
@@ -24,9 +21,10 @@ const utils_1 = require("./utils");
24
21
  * @param props.className CSS-класс.
25
22
  * @param props.rounded С какой стороны делать скругления.
26
23
  * @return Элемент.
24
+ * @deprecated
27
25
  */
28
26
  const PageButton = (_a) => {
29
27
  var { selected, rounded = 'all', className } = _a, restProps = __rest(_a, ["selected", "rounded", "className"]);
30
- return (react_1.default.createElement("button", Object.assign({}, restProps, { type: 'button', className: (0, utils_1.cx)('page-button', selected && 'selected', rounded === 'all' && 'rounds-all', rounded === 'left' && 'rounds-left', rounded === 'right' && 'rounds-right', className) })));
28
+ return ((0, jsx_runtime_1.jsx)("button", Object.assign({}, restProps, { type: 'button', className: (0, utils_1.cx)('page-button', selected && 'selected', rounded === 'all' && 'rounds-all', rounded === 'left' && 'rounds-left', rounded === 'right' && 'rounds-right', className) })));
31
29
  };
32
30
  exports.PageButton = PageButton;
@@ -0,0 +1,76 @@
1
+ @use '../colors';
2
+
3
+ .page-select-form {
4
+ font-size: 12px;
5
+ .page-input-wrapper {
6
+ margin-left: 8px;
7
+ width: 64px;
8
+ .page-input {
9
+ text-align: center;
10
+ font-size: 16px;
11
+ }
12
+ }
13
+ .submit-button {
14
+ margin-left: 8px;
15
+ }
16
+ .cancel-button {
17
+ margin-left: 32px;
18
+ }
19
+ }
20
+
21
+ .page-button {
22
+ display: inline-block;
23
+ width: 38px;
24
+ height: 38px;
25
+ background: #fff;
26
+ border: 1px solid colors.$basic-gray12;
27
+ font-size: 14px;
28
+ outline: 0;
29
+ box-sizing: border-box;
30
+ padding: 0;
31
+ vertical-align: top;
32
+ user-select: none;
33
+ &.rounds-all {
34
+ border-radius: 4px;
35
+ }
36
+ &.rounds-left {
37
+ border-radius: 4px 0 0 4px;
38
+ }
39
+ &.rounds-right {
40
+ border-radius: 0 4px 4px 0;
41
+ &:not(.rounds-all) {
42
+ margin-right: 0;
43
+ }
44
+ }
45
+ &:disabled {
46
+ color: colors.$basic-gray24;
47
+ }
48
+ &:not(.rounds-all) {
49
+ margin-right: -1px;
50
+ }
51
+ &:not(.selected):not(:disabled):hover {
52
+ background: #f5f5f5;
53
+ cursor: pointer;
54
+ }
55
+ &.selected {
56
+ position: relative;
57
+ background: colors.$basic-gray87;
58
+ border-color: colors.$basic-gray87;
59
+ color: #fff;
60
+ cursor: default;
61
+ &::after {
62
+ content: '';
63
+ position: absolute;
64
+ top: 0;
65
+ left: 0;
66
+ width: 100%;
67
+ height: 100%;
68
+ box-shadow: inherit;
69
+ border-radius: inherit;
70
+ }
71
+ }
72
+ }
73
+
74
+ .icon {
75
+ vertical-align: middle;
76
+ }
@@ -0,0 +1,58 @@
1
+ interface IPageButton {
2
+ value: number;
3
+ content: string | number;
4
+ }
5
+ type State = {
6
+ current: number;
7
+ range: number;
8
+ total: number;
9
+ };
10
+ export declare const cx: (...args: import("classnames").ArgumentArray) => string;
11
+ /**
12
+ * Фабрика объектов с данными о кнопке страницы.
13
+ * @param value Номер целевой страницы.
14
+ * @param content Содержимое кнопки.
15
+ * @return Список кнопок.
16
+ * @deprecated
17
+ */
18
+ export declare const PageButton: (value: number, content?: string | number) => IPageButton;
19
+ /**
20
+ * Возвращает список кнопок навигации.
21
+ * @param props Свойства.
22
+ * @param props.current Номер текущей страницы.
23
+ * @param props.total Номер последней страницы.
24
+ * @param props.buttonKeys Значения, которые будут использованы для не числовых кнопок.
25
+ * @param props.buttonKeys.more Значение для отображения кнопки группы пропущенных чисел.
26
+ * @return Список кнопок.
27
+ * @deprecated
28
+ */
29
+ export declare const getPageButtons: ({ current, total, buttonKeys, }: {
30
+ current: number;
31
+ total: number;
32
+ buttonKeys?: {
33
+ more: string | number;
34
+ } | undefined;
35
+ }) => IPageButton[];
36
+ /**
37
+ * Возвращает корректный диапазон вокруг текущего значения в соответствии с дизайнерской задумкой.
38
+ * По возможности показывает начало/конец списка при смещении.
39
+ * При current = 4, range = 5 вместо [2,3,4,5,6] вернет [1,2,3,4,5].
40
+ * @param props Свойства.
41
+ * @param props.current Число вокруг которого нужно сформировать список.
42
+ * @param props.range Размер списка.
43
+ * @param props.total Максимальное значение.
44
+ * @return Список номеров.
45
+ * @deprecated
46
+ */
47
+ export declare const getCorrectRangeNumbers: ({ current, range: rangeSize, total }: State) => number[];
48
+ /**
49
+ * Возвращает список чисел вокруг заданного.
50
+ * @param props Свойства.
51
+ * @param props.current Число вокруг которого нужно сформировать список.
52
+ * @param props.range Размер списка.
53
+ * @param props.total Максимальное значение.
54
+ * @return Список номеров.
55
+ * @deprecated
56
+ */
57
+ export declare const getRangeNumbers: ({ current, range: rangeSize, total }: State) => number[];
58
+ export {};
@@ -0,0 +1,124 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getRangeNumbers = exports.getCorrectRangeNumbers = exports.getPageButtons = exports.PageButton = exports.cx = void 0;
7
+ const bind_1 = __importDefault(require("classnames/bind"));
8
+ const pagination_module_scss_1 = __importDefault(require("./pagination.module.scss"));
9
+ const lodash_1 = require("lodash");
10
+ exports.cx = bind_1.default.bind(pagination_module_scss_1.default);
11
+ /**
12
+ * Фабрика объектов с данными о кнопке страницы.
13
+ * @param value Номер целевой страницы.
14
+ * @param content Содержимое кнопки.
15
+ * @return Список кнопок.
16
+ * @deprecated
17
+ */
18
+ const PageButton = (value, content = value) => ({
19
+ value,
20
+ content,
21
+ });
22
+ exports.PageButton = PageButton;
23
+ /**
24
+ * Возвращает список кнопок навигации.
25
+ * @param props Свойства.
26
+ * @param props.current Номер текущей страницы.
27
+ * @param props.total Номер последней страницы.
28
+ * @param props.buttonKeys Значения, которые будут использованы для не числовых кнопок.
29
+ * @param props.buttonKeys.more Значение для отображения кнопки группы пропущенных чисел.
30
+ * @return Список кнопок.
31
+ * @deprecated
32
+ */
33
+ const getPageButtons = ({ current, total, buttonKeys = { more: '...' }, }) => {
34
+ const list = (0, exports.getCorrectRangeNumbers)({ current, range: 5, total }).map(v => (0, exports.PageButton)(v));
35
+ if (list.length > 0 && total > 5) {
36
+ // если находимся в середине множества (многоточия с обоих сторон) - диапазон уменьшается до 4
37
+ if (list[0].value > 1 && list[list.length - 1].value < total) {
38
+ list.shift();
39
+ }
40
+ if (list[0].value > 1) {
41
+ // формируем начало диапазона
42
+ if (list[0].value === 2) {
43
+ list.unshift((0, exports.PageButton)(1));
44
+ }
45
+ else {
46
+ list.unshift((0, exports.PageButton)(1),
47
+ // не выводим многоточие когда вместо него можно поставить одно число
48
+ list[0].value === 3 ? (0, exports.PageButton)(2) : (0, exports.PageButton)(list[0].value - 1, buttonKeys.more));
49
+ }
50
+ }
51
+ if (list[list.length - 1].value < total) {
52
+ // формируем конец диапазона
53
+ if (list[list.length - 1].value === total - 1) {
54
+ list.push((0, exports.PageButton)(total));
55
+ }
56
+ else {
57
+ list.push(
58
+ // не выводим многоточие когда вместо него можно поставить одно число
59
+ total - list[list.length - 1].value > 2
60
+ ? (0, exports.PageButton)(list[list.length - 1].value + 1, buttonKeys.more)
61
+ : (0, exports.PageButton)(total - 1), (0, exports.PageButton)(total));
62
+ }
63
+ }
64
+ }
65
+ return list;
66
+ };
67
+ exports.getPageButtons = getPageButtons;
68
+ /**
69
+ * Возвращает корректный диапазон вокруг текущего значения в соответствии с дизайнерской задумкой.
70
+ * По возможности показывает начало/конец списка при смещении.
71
+ * При current = 4, range = 5 вместо [2,3,4,5,6] вернет [1,2,3,4,5].
72
+ * @param props Свойства.
73
+ * @param props.current Число вокруг которого нужно сформировать список.
74
+ * @param props.range Размер списка.
75
+ * @param props.total Максимальное значение.
76
+ * @return Список номеров.
77
+ * @deprecated
78
+ */
79
+ const getCorrectRangeNumbers = ({ current, range: rangeSize, total }) => {
80
+ let result = [
81
+ ...(0, exports.getRangeNumbers)({
82
+ current,
83
+ range: rangeSize,
84
+ total,
85
+ }),
86
+ ];
87
+ if (total > rangeSize) {
88
+ if (current < rangeSize) {
89
+ result = (0, lodash_1.range)(1, rangeSize + 1);
90
+ }
91
+ else if (current > total - rangeSize + 1) {
92
+ result = (0, lodash_1.range)(total - rangeSize + 1, total + 1);
93
+ }
94
+ }
95
+ return result;
96
+ };
97
+ exports.getCorrectRangeNumbers = getCorrectRangeNumbers;
98
+ /**
99
+ * Возвращает список чисел вокруг заданного.
100
+ * @param props Свойства.
101
+ * @param props.current Число вокруг которого нужно сформировать список.
102
+ * @param props.range Размер списка.
103
+ * @param props.total Максимальное значение.
104
+ * @return Список номеров.
105
+ * @deprecated
106
+ */
107
+ const getRangeNumbers = ({ current, range: rangeSize, total }) => {
108
+ const pageNumbers = [];
109
+ const readyRange = Math.min(rangeSize, total) || 0;
110
+ const halfRange = Math.floor(readyRange / 2);
111
+ const correction = readyRange % 2;
112
+ let startIndex = current - halfRange - correction;
113
+ if (startIndex < 1) {
114
+ startIndex = 0;
115
+ }
116
+ else if (startIndex + readyRange > total) {
117
+ startIndex = total - readyRange;
118
+ }
119
+ for (let i = startIndex; i < startIndex + readyRange; i++) {
120
+ pageNumbers.push(i + 1);
121
+ }
122
+ return pageNumbers;
123
+ };
124
+ exports.getRangeNumbers = getRangeNumbers;
package/panel/index.js CHANGED
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.Panel = exports.LINK_COLOR_BY_TYPE = void 0;
7
- const react_1 = __importDefault(require("react"));
7
+ const jsx_runtime_1 = require("react/jsx-runtime");
8
8
  const colors_1 = require("../styling/colors");
9
9
  const bind_1 = __importDefault(require("classnames/bind"));
10
10
  const panel_module_scss_1 = __importDefault(require("./panel.module.scss"));
@@ -41,10 +41,7 @@ exports.LINK_COLOR_BY_TYPE = {
41
41
  function Panel({ type = 'info', adornmentStart, adornmentEnd, className, style, children, 'data-testid': testId = 'panel', }) {
42
42
  const textColor = PANEL_COLORS_BY_TYPE[type].textColor;
43
43
  const panelColor = PANEL_COLORS_BY_TYPE[type].panelColor;
44
- return (react_1.default.createElement("div", { className: cx('root', `type-${type}`, (0, colors_1.bgColor)(panelColor), (0, colors_1.color)(textColor), className), "data-testid": testId, style: style },
45
- adornmentStart && react_1.default.createElement("div", { className: cx('adornment') }, adornmentStart),
46
- react_1.default.createElement("div", { className: cx('main') }, children),
47
- adornmentEnd && react_1.default.createElement("div", { className: cx('adornment') }, adornmentEnd)));
44
+ return ((0, jsx_runtime_1.jsxs)("div", Object.assign({ className: cx('root', `type-${type}`, (0, colors_1.bgColor)(panelColor), (0, colors_1.color)(textColor), className), "data-testid": testId, style: style }, { children: [adornmentStart && (0, jsx_runtime_1.jsx)("div", Object.assign({ className: cx('adornment') }, { children: adornmentStart })), (0, jsx_runtime_1.jsx)("div", Object.assign({ className: cx('main') }, { children: children })), adornmentEnd && (0, jsx_runtime_1.jsx)("div", Object.assign({ className: cx('adornment') }, { children: adornmentEnd }))] })));
48
45
  }
49
46
  exports.Panel = Panel;
50
47
  /**
@@ -53,6 +50,6 @@ exports.Panel = Panel;
53
50
  * @return Элемент.
54
51
  */
55
52
  function PanelUnknownContent({ markup }) {
56
- return react_1.default.createElement("div", { className: cx('unknown-content'), dangerouslySetInnerHTML: { __html: markup } });
53
+ return (0, jsx_runtime_1.jsx)("div", { className: cx('unknown-content'), dangerouslySetInnerHTML: { __html: markup } });
57
54
  }
58
55
  Panel.UnknownContent = PanelUnknownContent;
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -1,27 +1,4 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
2
  var __rest = (this && this.__rest) || function (s, e) {
26
3
  var t = {};
27
4
  for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
@@ -38,7 +15,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
38
15
  };
39
16
  Object.defineProperty(exports, "__esModule", { value: true });
40
17
  exports.PhoneInput = void 0;
41
- const react_1 = __importStar(require("react"));
18
+ const jsx_runtime_1 = require("react/jsx-runtime");
19
+ const react_1 = require("react");
42
20
  const dropdown_item_1 = require("../dropdown-item");
43
21
  const hooks_1 = require("../hooks");
44
22
  const masked_input_1 = require("../masked-input");
@@ -46,8 +24,8 @@ const presets_1 = require("./presets");
46
24
  const utils_1 = require("./utils");
47
25
  const select_1 = require("../select");
48
26
  const utils_2 = require("../select/utils");
49
- const up_1 = __importDefault(require("@sima-land/ui-quarks/icons/16x16/Stroked/Arrows/up"));
50
- const down_1 = __importDefault(require("@sima-land/ui-quarks/icons/16x16/Stroked/Arrows/down"));
27
+ const Up_1 = __importDefault(require("@sima-land/ui-quarks/icons/16x16/Stroked/Arrows/Up"));
28
+ const Down_1 = __importDefault(require("@sima-land/ui-quarks/icons/16x16/Stroked/Arrows/Down"));
51
29
  const bind_1 = __importDefault(require("classnames/bind"));
52
30
  const phone_input_module_scss_1 = __importDefault(require("./phone-input.module.scss"));
53
31
  const cx = bind_1.default.bind(phone_input_module_scss_1.default);
@@ -96,7 +74,7 @@ function PhoneInput(_a) {
96
74
  setCountry(selected);
97
75
  setCleanValue('');
98
76
  }, []);
99
- return (react_1.default.createElement(select_1.Select, { opener: react_1.default.createElement(PhoneMaskedInput, Object.assign({}, props, { "data-testid": testId, country: country, inputRef: inputRef, blockRef: blockRef, label: label, mask: country.mask, onFocus: (event, data) => {
77
+ return ((0, jsx_runtime_1.jsx)(select_1.Select, Object.assign({ opener: (0, jsx_runtime_1.jsx)(PhoneMaskedInput, Object.assign({}, props, { "data-testid": testId, country: country, inputRef: inputRef, blockRef: blockRef, label: label, mask: country.mask, onFocus: (event, data) => {
100
78
  onFocus === null || onFocus === void 0 ? void 0 : onFocus(event, processData(data));
101
79
  }, onChange: (event, data) => {
102
80
  onChange === null || onChange === void 0 ? void 0 : onChange(event, processData(data));
@@ -105,11 +83,11 @@ function PhoneInput(_a) {
105
83
  }, value: cleanValue })), onValueChange: itemValue => {
106
84
  const item = presets_1.countriesList.find(c => c.id === itemValue);
107
85
  item && changeCountry(item);
108
- } }, presets_1.countriesList.map((item, index) => (react_1.default.createElement(dropdown_item_1.DropdownItem, { value: item.id, key: index, size: 'm', role: 'menuitem', onMouseDown: event => {
109
- // ВАЖНО: клик по блоку поля вызывает фокус на поле и preventDefault()
110
- // отменяем с помощью другого preventDefault()
111
- event.preventDefault();
112
- }, selected: item.id === country.id, startContent: react_1.default.createElement("img", { alt: '', width: 24, height: 24, src: item.imageSrc }), endContent: item.code }, item.name)))));
86
+ } }, { children: presets_1.countriesList.map((item, index) => ((0, jsx_runtime_1.jsx)(dropdown_item_1.DropdownItem, Object.assign({ value: item.id, size: 'm', role: 'menuitem', onMouseDown: event => {
87
+ // ВАЖНО: клик по блоку поля вызывает фокус на поле и preventDefault()
88
+ // отменяем с помощью другого preventDefault()
89
+ event.preventDefault();
90
+ }, selected: item.id === country.id, startContent: (0, jsx_runtime_1.jsx)("img", { alt: '', width: 24, height: 24, src: item.imageSrc }), endContent: item.code }, { children: item.name }), index))) })));
113
91
  }
114
92
  exports.PhoneInput = PhoneInput;
115
93
  /**
@@ -124,10 +102,8 @@ function PhoneMaskedInput(_a) {
124
102
  const [openerFocused, setOpenerFocused] = (0, react_1.useState)(false);
125
103
  (0, react_1.useImperativeHandle)(blockRefProp, () => blockRef.current);
126
104
  (0, react_1.useImperativeHandle)(select.anchorRef, () => blockRef.current);
127
- const ArrowSVG = select.opened ? up_1.default : down_1.default;
128
- return (react_1.default.createElement(masked_input_1.MaskedInput, Object.assign({}, props, {
105
+ const ArrowSVG = select.opened ? Up_1.default : Down_1.default;
106
+ return ((0, jsx_runtime_1.jsx)(masked_input_1.MaskedInput, Object.assign({}, props, {
129
107
  // ВАЖНО: undefined нужен для поведения по умолчанию если меню скрыто и кнопка не в фокусе
130
- focused: select.opened || openerFocused || undefined, blockRef: blockRef, baseInputProps: Object.assign({ restPlaceholder: country.id === presets_1.IDS.other ? '' : undefined }, props.baseInputProps), adornmentEnd: react_1.default.createElement("div", { ref: select.openerRef, tabIndex: 0, onFocus: () => setOpenerFocused(true), onBlur: () => setOpenerFocused(false), role: 'combobox', "aria-label": '\u0412\u044B\u0431\u043E\u0440 \u0441\u0442\u0440\u0430\u043D\u044B', className: cx('opener'), "data-testid": 'phone-input:menu-opener', onKeyDown: select.onKeyDown, onMouseDown: select.onMouseDown },
131
- react_1.default.createElement("img", { alt: '', width: 24, height: 24, src: country.imageSrc }),
132
- react_1.default.createElement(ArrowSVG, { className: phone_input_module_scss_1.default.arrow })) })));
108
+ focused: select.opened || openerFocused || undefined, blockRef: blockRef, baseInputProps: Object.assign({ restPlaceholder: country.id === presets_1.IDS.other ? '' : undefined }, props.baseInputProps), adornmentEnd: (0, jsx_runtime_1.jsxs)("div", Object.assign({ ref: select.openerRef, tabIndex: 0, onFocus: () => setOpenerFocused(true), onBlur: () => setOpenerFocused(false), role: 'combobox', "aria-label": '\u0412\u044B\u0431\u043E\u0440 \u0441\u0442\u0440\u0430\u043D\u044B', className: cx('opener'), "data-testid": 'phone-input:menu-opener', onKeyDown: select.onKeyDown, onMouseDown: select.onMouseDown }, { children: [(0, jsx_runtime_1.jsx)("img", { alt: '', width: 24, height: 24, src: country.imageSrc }), (0, jsx_runtime_1.jsx)(ArrowSVG, { className: phone_input_module_scss_1.default.arrow })] })) })));
133
109
  }