@sima-land/ui-nucleons 40.2.2 → 40.3.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.
package/alert/index.d.ts CHANGED
@@ -18,6 +18,8 @@ export interface AlertProps extends WithBodyScrollLock {
18
18
  withDivideNavBar?: boolean;
19
19
  /** Нужна ли шапка. */
20
20
  withNavBar?: boolean;
21
+ /** Будет вызвана при закрытии окна нажатием на затемнение. */
22
+ onClose?: () => void;
21
23
  }
22
24
  /**
23
25
  * Компонент модального диалога.
package/alert/index.js CHANGED
@@ -62,11 +62,11 @@ exports.Alert = Alert;
62
62
  * @param props Свойства.
63
63
  * @return Элемент.
64
64
  */
65
- const AlertInner = ({ children, className, footer, navBarProps, title, withDivideNavBar, withNavBar = Boolean(title), withScrollDisable = false, scrollDisableOptions, }) => {
65
+ const AlertInner = ({ children, className, footer, navBarProps, title, withDivideNavBar, withNavBar = Boolean(title), withScrollDisable = false, scrollDisableOptions, onClose, }) => {
66
66
  const rootRef = (0, react_1.useRef)(null);
67
67
  const layer = (0, layer_1.useLayer)();
68
68
  (0, body_scroll_1.useBodyScrollLock)(rootRef, withScrollDisable, scrollDisableOptions);
69
- return (react_1.default.createElement("div", { ref: rootRef, className: cx('overlay'), style: { zIndex: layer } },
69
+ return (react_1.default.createElement("div", { ref: rootRef, className: cx('overlay'), style: { zIndex: layer }, onClick: e => e.target === e.currentTarget && (onClose === null || onClose === void 0 ? void 0 : onClose()), "data-testid": 'alert:overlay' },
70
70
  react_1.default.createElement("div", { className: cx('alert', className), "data-testid": 'alert' },
71
71
  withNavBar && (react_1.default.createElement(nav_bar_1.NavBar, Object.assign({}, navBarProps, { title: title, bottomBordered: withDivideNavBar, className: cx('header') }))),
72
72
  react_1.default.createElement("div", { className: cx('main') }, children),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sima-land/ui-nucleons",
3
- "version": "40.2.2",
3
+ "version": "40.3.0",
4
4
  "repository": "ssh://git@github.com:sima-land/ui-nucleons.git",
5
5
  "author": "www.sima-land.ru team",
6
6
  "license": "Apache-2.0",
@@ -41,7 +41,7 @@
41
41
  "@testing-library/react": "^12.0.0",
42
42
  "@types/classnames": "^2.2.11",
43
43
  "@types/enzyme": "^3.10.8",
44
- "@types/jest": "^26.0.20",
44
+ "@types/jest": "^27.0.2",
45
45
  "@types/lodash": "^4.14.168",
46
46
  "@types/react": "^17.0.2",
47
47
  "@types/react-dom": "^17.0.2",
@@ -50,7 +50,7 @@
50
50
  "@typescript-eslint/parser": "^4.15.2",
51
51
  "@wojtekmaj/enzyme-adapter-react-17": "^0.6.3",
52
52
  "babel-loader": "^8.0.5",
53
- "babel-preset-jest": "^26.6.2",
53
+ "babel-preset-jest": "^27.2.0",
54
54
  "classnames": "^2.2.6",
55
55
  "copyfiles": "^2.4.1",
56
56
  "css-loader": "^5.0.1",
@@ -62,8 +62,8 @@
62
62
  "file-loader": "^6.2.0",
63
63
  "husky": "^5.1.1",
64
64
  "identity-obj-proxy": "^3.0.0",
65
- "jest": "^26.6.3",
66
- "jest-css-modules-transform": "^4.2.0",
65
+ "jest": "^27.3.1",
66
+ "jest-css-modules-transform": "^4.3.0",
67
67
  "lint-staged": "^10.5.4",
68
68
  "prettier": "^2.3.2",
69
69
  "react": "^17.0.2",
@@ -74,7 +74,7 @@
74
74
  "sass-loader": "^10.1.0",
75
75
  "style-loader": "^2.0.0",
76
76
  "stylelint": "^13.8.0",
77
- "ts-jest": "^26.5.2",
77
+ "ts-jest": "^27.0.7",
78
78
  "typescript": "^4.4.3",
79
79
  "typescript-plugin-css-modules": "^3.2.0",
80
80
  "webpack": "^5.11.0"
@@ -1,11 +1,13 @@
1
1
  import React from 'react';
2
2
  export interface UnknownContentProps extends React.HTMLAttributes<HTMLDivElement> {
3
3
  /** Строка с html-версткой. */
4
- markup: string;
4
+ markup?: string;
5
+ /** Содержимое. */
6
+ children?: React.ReactNode;
5
7
  }
6
8
  /**
7
9
  * Компонент, стилизующий верстку по гайдам.
8
10
  * @param props Свойства.
9
11
  * @return Элемент.
10
12
  */
11
- export declare const UnknownContent: ({ markup, className }: UnknownContentProps) => JSX.Element;
13
+ export declare const UnknownContent: ({ markup, children, className }: UnknownContentProps) => JSX.Element;
@@ -1,16 +1,42 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
2
21
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
22
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
23
  };
5
24
  Object.defineProperty(exports, "__esModule", { value: true });
6
25
  exports.UnknownContent = void 0;
7
- const react_1 = __importDefault(require("react"));
26
+ const react_1 = __importStar(require("react"));
8
27
  const classnames_1 = __importDefault(require("classnames"));
9
28
  const unknown_content_module_scss_1 = __importDefault(require("./unknown-content.module.scss"));
29
+ const utils_1 = require("./utils");
10
30
  /**
11
31
  * Компонент, стилизующий верстку по гайдам.
12
32
  * @param props Свойства.
13
33
  * @return Элемент.
14
34
  */
15
- const UnknownContent = ({ markup, className }) => (react_1.default.createElement("div", { className: (0, classnames_1.default)(unknown_content_module_scss_1.default.root, className), dangerouslySetInnerHTML: { __html: markup } }));
35
+ const UnknownContent = ({ markup, children, className }) => {
36
+ const ref = (0, react_1.useRef)(null);
37
+ (0, react_1.useEffect)(() => {
38
+ ref.current && (0, utils_1.setTableRowLabels)(ref.current);
39
+ });
40
+ return (react_1.default.createElement("div", Object.assign({ ref: ref, className: (0, classnames_1.default)(unknown_content_module_scss_1.default.root, className) }, (children ? { children } : { dangerouslySetInnerHTML: { __html: markup || '' } }))));
41
+ };
16
42
  exports.UnknownContent = UnknownContent;
@@ -1,4 +1,5 @@
1
1
  @use '../colors';
2
+ @use '../breakpoints';
2
3
 
3
4
  .root {
4
5
  color: colors.$gray87;
@@ -12,149 +13,260 @@
12
13
  padding: 0;
13
14
  }
14
15
 
15
- // оформление заголовков
16
- h1 {
17
- font-weight: 700;
18
- font-size: 32px;
19
- line-height: 40px;
16
+ // ссылки
17
+ a {
18
+ color: colors.$brand-blue;
19
+ text-decoration: none;
20
+ &:hover {
21
+ color: colors.$brand-deep-blue;
22
+ }
20
23
  }
21
- h2 {
24
+
25
+ // параграф
26
+ p {
27
+ margin-bottom: 24px;
28
+ }
29
+
30
+ // курсив
31
+ i,
32
+ em {
33
+ font-style: normal; // да, вот так по гайдам
34
+ }
35
+
36
+ // заголовки
37
+ h1 {
22
38
  font-weight: 600;
23
39
  font-size: 24px;
24
40
  line-height: 32px;
41
+ margin-bottom: 32px;
25
42
  }
26
- h3 {
43
+ h2 {
27
44
  font-weight: 600;
28
45
  font-size: 20px;
29
46
  line-height: 28px;
47
+ margin-bottom: 24px;
48
+ }
49
+ h3 {
50
+ font-weight: 600;
51
+ font-size: 16px;
52
+ line-height: 24px;
53
+ margin-bottom: 24px;
30
54
  }
31
55
  h4 {
32
- font-weight: 700;
56
+ font-weight: 600;
33
57
  font-size: 16px;
34
58
  line-height: 24px;
59
+ color: colors.$gray38;
60
+ margin-bottom: 16px;
35
61
  }
36
62
  h5 {
37
63
  font-weight: normal;
38
64
  font-size: 14px;
39
65
  line-height: 20px;
66
+ color: colors.$gray38;
67
+ margin-bottom: 24px;
40
68
  }
41
-
42
- // отступы от заголовков
43
- * + h2 {
44
- margin-top: 80px;
45
- }
46
- * + h3 {
47
- margin-top: 64px;
48
- }
49
- * + h4 {
50
- margin-top: 24px;
51
- }
52
- h1 + * {
53
- margin-top: 80px;
54
- }
55
- h2 + * {
56
- margin-top: 32px;
57
- }
58
- h3 + * {
59
- margin-top: 24px;
60
- }
61
- h4 + * {
62
- margin-top: 16px;
69
+ h6 {
70
+ font-weight: normal;
71
+ font-size: 12px;
72
+ line-height: 16px;
73
+ margin-bottom: 24px;
63
74
  }
64
- h1,
65
- h2,
66
- h3,
67
- h4,
68
- h5 {
69
- + img,
70
- + video {
71
- margin-top: 48px;
75
+
76
+ @include breakpoints.up('xs') {
77
+ h1 {
78
+ font-weight: bold;
79
+ font-size: 32px;
80
+ line-height: 40px;
81
+ margin-bottom: 32px;
82
+ }
83
+ h2 {
84
+ font-weight: 600;
85
+ font-size: 24px;
86
+ line-height: 32px;
87
+ margin-bottom: 24px;
88
+ }
89
+ h3 {
90
+ font-weight: 600;
91
+ font-size: 20px;
92
+ line-height: 28px;
93
+ margin-bottom: 24px;
94
+ }
95
+ h4 {
96
+ font-weight: 600;
97
+ font-size: 16px;
98
+ line-height: 24px;
99
+ color: colors.$gray38;
100
+ margin-bottom: 16px;
101
+ }
102
+ h5 {
103
+ font-size: 14px;
104
+ line-height: 20px;
105
+ color: colors.$gray38;
106
+ margin-bottom: 24px;
107
+ }
108
+ h6 {
109
+ font-size: 12px;
110
+ line-height: 16px;
72
111
  }
73
- }
74
- h1 + h2 {
75
- margin-top: 80px;
76
- }
77
- h2 + h3 {
78
- margin-top: 24px;
79
- }
80
- h3 + h4 {
81
- margin-top: 24px;
82
112
  }
83
113
 
84
- // абзацы
85
- p + p {
86
- margin-top: 16px;
114
+ // списки
115
+ ol,
116
+ ul {
117
+ margin-bottom: 24px;
118
+ li + li {
119
+ margin-top: 16px;
120
+ }
87
121
  }
88
-
89
- // ссылки
90
- a {
91
- color: colors.$brand-blue;
92
- text-decoration: none;
93
- &:hover {
94
- color: colors.$brand-deep-blue;
122
+ ol {
123
+ display: block;
124
+ counter-reset: ordered-list;
125
+ list-style: none;
126
+ li {
127
+ display: flex;
128
+ flex-direction: row;
129
+ list-style-position: inside;
130
+ counter-increment: ordered-list;
131
+ }
132
+ li::before {
133
+ content: counter(ordered-list) '.';
134
+ display: block;
135
+ flex-grow: 0;
136
+ margin-right: 12px;
95
137
  }
96
138
  }
97
-
98
- // курсив
99
- i,
100
- em {
101
- font-style: normal; // да, вот так по гайдам
102
- color: colors.$gray38;
139
+ ul {
140
+ list-style: none;
141
+ li {
142
+ display: flex;
143
+ flex-direction: row;
144
+ list-style-position: inside;
145
+ counter-increment: ordered-list;
146
+ }
147
+ li::before {
148
+ display: block;
149
+ content: '—';
150
+ margin-right: 12px;
151
+ }
103
152
  }
104
153
 
105
154
  // таблицы
106
155
  table {
107
- border-collapse: collapse;
108
156
  width: 100%;
109
- margin: 32px 0;
110
- thead {
111
- color: colors.$gray38;
157
+ margin-bottom: 40px;
158
+ border-collapse: collapse;
159
+ }
160
+ @include breakpoints.up('xs') {
161
+ table {
162
+ thead {
163
+ color: colors.$gray38;
164
+ font-size: 14px;
165
+ line-height: 20px;
166
+ td,
167
+ th {
168
+ padding-top: 0;
169
+ }
170
+ }
112
171
  td {
113
- padding-top: 0;
172
+ border: 0;
173
+ padding: 24px 0;
174
+
175
+ // накидываем именно сюда чтобы работало в Safari
176
+ box-shadow: inset 0 -1px 0 colors.$gray12;
177
+ &:not(:last-child) {
178
+ padding-right: 32px;
179
+ }
114
180
  }
115
181
  }
116
- td {
117
- border: 0;
118
- padding: 24px 0;
119
-
120
- // накидываем именно сюда чтобы работало в Safari
182
+ }
183
+ @include breakpoints.down('xs') {
184
+ table,
185
+ tr,
186
+ th,
187
+ td,
188
+ thead,
189
+ tbody {
190
+ display: block;
191
+ }
192
+ table {
193
+ box-shadow: inset 0 1px 0 colors.$gray12;
194
+ }
195
+ thead {
196
+ position: absolute;
197
+ top: -9999px;
198
+ left: -9999px;
199
+ }
200
+ tr {
201
+ padding: 32px 0;
121
202
  box-shadow: inset 0 -1px 0 colors.$gray12;
122
- &:not(:last-child) {
123
- padding-right: 48px;
124
- }
125
203
  }
126
- tbody td:nth-child(2) {
127
- font-weight: 600; // @todo это видимо для какой-то конкретной таблицы было сделано, надо бы убрать
204
+ td + td {
205
+ margin-top: 24px;
206
+ }
207
+ td::before {
208
+ content: attr(data-table-column-title);
209
+ display: block;
210
+ font-size: 14px;
211
+ line-height: 20px;
212
+ color: colors.$gray38;
213
+ margin-bottom: 8px;
128
214
  }
129
215
  }
130
216
 
131
- // списки
132
- ul {
133
- list-style: none;
134
- li + li {
135
- margin-top: 16px;
136
- }
137
- li::before {
138
- display: inline-block;
139
- content: '—';
140
- margin-right: 10px;
141
- }
217
+ // медиа
218
+ img,
219
+ video {
220
+ display: block;
221
+ max-width: 100%;
222
+ margin-bottom: 32px;
142
223
  }
143
- ol {
144
- list-style-position: inside;
145
- li::before {
224
+ @include breakpoints.up('xs') {
225
+ margin-bottom: 40px;
226
+ }
227
+
228
+ // цитата
229
+ blockquote {
230
+ position: relative;
231
+ display: block;
232
+ font-weight: 600;
233
+ font-size: 16px;
234
+ line-height: 24px;
235
+ padding-left: 40px;
236
+ &::before {
146
237
  content: '';
147
- width: 8px;
148
- display: inline-block;
238
+ position: absolute;
239
+ left: 0;
240
+
241
+ /* stylelint-disable-next-line function-url-quotes */
242
+ background-image: url('data:image/svg+xml,%3Csvg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg"%3E%3Crect width="32" height="32"/%3E%3Cpath d="M15.1665 5.33301H8.36963L2.6665 26.0361H12.1196L15.1665 5.33301ZM28.9165 5.33301H22.1196L16.4165 26.0361H25.8696L28.9165 5.33301Z" fill="%23E0E0E0"/%3E%3C/svg%3E%0A');
243
+ width: 32px;
244
+ height: 32px;
149
245
  }
150
- li + li {
246
+ @include breakpoints.up('xs') {
247
+ font-size: 20px;
248
+ line-height: 28px;
249
+ padding-left: 72px;
250
+ &::before {
251
+ /* stylelint-disable-next-line function-url-quotes */
252
+ background-image: url('data:image/svg+xml,%3Csvg width="48" height="48" viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg"%3E%3Crect width="48" height="48"/%3E%3Cpath d="M22.75 8H12.5547L4 39.0547H18.1797L22.75 8ZM43.375 8H33.1797L24.625 39.0547H38.8047L43.375 8Z" fill="%23E0E0E0"/%3E%3C/svg%3E%0A');
253
+ width: 48px;
254
+ height: 48px;
255
+ }
256
+ }
257
+ * {
258
+ margin: 0;
259
+ }
260
+ cite {
261
+ display: block;
151
262
  margin-top: 16px;
263
+ font-style: normal;
264
+ font-weight: normal;
265
+ font-size: 16px;
266
+ line-height: 24px;
267
+ color: colors.$gray38;
152
268
  }
153
269
  }
154
- ul,
155
- ol {
156
- margin: 16px 0;
157
- }
158
270
 
159
271
  // горизонтальная черта
160
272
  hr {
@@ -162,27 +274,9 @@
162
274
  width: 100%;
163
275
  height: 1px;
164
276
  background: colors.$gray12;
165
- }
166
- * + hr {
167
- margin-top: 48px;
168
- }
169
-
170
- // цитата
171
- blockquote {
172
- display: block;
173
- padding-left: 32px;
174
- border-left: 4px solid colors.$brand-blue;
175
- margin: 40px 0;
176
- }
177
-
178
- // @todo неопознанные стили оставшиеся при переносе из карточки товара, выяснить что это и зачем нужно
179
- div {
180
- font-weight: 600;
181
- + p {
182
- margin-top: 8px;
277
+ margin-bottom: 32px;
278
+ @include breakpoints.up('xs') {
279
+ margin-bottom: 40px;
183
280
  }
184
281
  }
185
- p + div {
186
- margin-top: 16px;
187
- }
188
282
  }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Ищет в заданном элементе все ячейки таблиц и задает им атрибут "data-table-column-title".
3
+ * Необходимо для стилизации адаптивных таблиц по гайдам.
4
+ * @param element Элемент.
5
+ */
6
+ export declare const setTableRowLabels: (element: Element) => void;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.setTableRowLabels = void 0;
4
+ /**
5
+ * Ищет в заданном элементе все ячейки таблиц и задает им атрибут "data-table-column-title".
6
+ * Необходимо для стилизации адаптивных таблиц по гайдам.
7
+ * @param element Элемент.
8
+ */
9
+ const setTableRowLabels = (element) => {
10
+ element.querySelectorAll('tbody td').forEach(td => {
11
+ var _a;
12
+ // считаем, что parentNode есть всегда т.к. селектор это подразумевает
13
+ const index = [...td.parentNode.children].indexOf(td);
14
+ // считаем, что index не может быть равен -1 т.к. поиск внутри родительского элемента
15
+ td.setAttribute('data-table-column-title', ((_a = td.closest('table').querySelector(`thead td:nth-child(${index + 1})`)) === null || _a === void 0 ? void 0 : _a.textContent) || '');
16
+ });
17
+ };
18
+ exports.setTableRowLabels = setTableRowLabels;