@cloud-ru/uikit-product-mobile-alert 0.4.64 → 0.4.65

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 (50) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/cjs/components/AdaptiveAlert/AdaptiveAlert.d.ts +7 -0
  3. package/dist/cjs/components/AdaptiveAlert/AdaptiveAlert.js +28 -0
  4. package/dist/cjs/components/AdaptiveAlert/index.d.ts +1 -0
  5. package/dist/cjs/components/AdaptiveAlert/index.js +17 -0
  6. package/dist/cjs/components/MobileAlertTop/MobileAlertTop.d.ts +29 -0
  7. package/dist/cjs/components/MobileAlertTop/MobileAlertTop.js +85 -0
  8. package/dist/cjs/components/MobileAlertTop/constants.d.ts +8 -0
  9. package/dist/cjs/components/MobileAlertTop/constants.js +20 -0
  10. package/dist/cjs/components/MobileAlertTop/index.d.ts +1 -0
  11. package/dist/cjs/components/MobileAlertTop/index.js +17 -0
  12. package/dist/cjs/components/MobileAlertTop/styles.module.css +177 -0
  13. package/dist/cjs/components/index.d.ts +2 -0
  14. package/dist/cjs/components/index.js +18 -0
  15. package/dist/cjs/constants.d.ts +16 -0
  16. package/dist/cjs/constants.js +31 -0
  17. package/dist/cjs/helperComponents/AlertButton.d.ts +24 -0
  18. package/dist/cjs/helperComponents/AlertButton.js +12 -0
  19. package/dist/cjs/helperComponents/index.d.ts +1 -0
  20. package/dist/cjs/helperComponents/index.js +17 -0
  21. package/dist/cjs/helperComponents/styles.module.css +85 -0
  22. package/dist/cjs/index.d.ts +1 -0
  23. package/dist/cjs/index.js +17 -0
  24. package/dist/cjs/types.d.ts +4 -0
  25. package/dist/cjs/types.js +2 -0
  26. package/dist/esm/components/AdaptiveAlert/AdaptiveAlert.d.ts +7 -0
  27. package/dist/esm/components/AdaptiveAlert/AdaptiveAlert.js +24 -0
  28. package/dist/esm/components/AdaptiveAlert/index.d.ts +1 -0
  29. package/dist/esm/components/AdaptiveAlert/index.js +1 -0
  30. package/dist/esm/components/MobileAlertTop/MobileAlertTop.d.ts +29 -0
  31. package/dist/esm/components/MobileAlertTop/MobileAlertTop.js +79 -0
  32. package/dist/esm/components/MobileAlertTop/constants.d.ts +8 -0
  33. package/dist/esm/components/MobileAlertTop/constants.js +17 -0
  34. package/dist/esm/components/MobileAlertTop/index.d.ts +1 -0
  35. package/dist/esm/components/MobileAlertTop/index.js +1 -0
  36. package/dist/esm/components/MobileAlertTop/styles.module.css +177 -0
  37. package/dist/esm/components/index.d.ts +2 -0
  38. package/dist/esm/components/index.js +2 -0
  39. package/dist/esm/constants.d.ts +16 -0
  40. package/dist/esm/constants.js +28 -0
  41. package/dist/esm/helperComponents/AlertButton.d.ts +24 -0
  42. package/dist/esm/helperComponents/AlertButton.js +6 -0
  43. package/dist/esm/helperComponents/index.d.ts +1 -0
  44. package/dist/esm/helperComponents/index.js +1 -0
  45. package/dist/esm/helperComponents/styles.module.css +85 -0
  46. package/dist/esm/index.d.ts +1 -0
  47. package/dist/esm/index.js +1 -0
  48. package/dist/esm/types.d.ts +4 -0
  49. package/dist/esm/types.js +1 -0
  50. package/package.json +5 -4
@@ -0,0 +1,17 @@
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./components"), exports);
@@ -0,0 +1,4 @@
1
+ import { ValueOf } from '@snack-uikit/utils';
2
+ import { APPEARANCE, SIZE } from './constants';
3
+ export type Appearance = ValueOf<typeof APPEARANCE>;
4
+ export type Size = ValueOf<typeof SIZE>;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,7 @@
1
+ import { WithLayoutType } from '@sbercloud/uikit-product-utils';
2
+ import { AlertProps, AlertTopProps } from '@snack-uikit/alert';
3
+ export type AdaptiveAlertProps = WithLayoutType<AlertProps>;
4
+ export declare function AdaptiveAlert({ layoutType, ...props }: AdaptiveAlertProps): import("react/jsx-runtime").JSX.Element;
5
+ export type AdaptiveAlertTopProps = WithLayoutType<AlertTopProps>;
6
+ export declare function AdaptiveAlertTop({ layoutType, ...props }: AdaptiveAlertTopProps): import("react/jsx-runtime").JSX.Element;
7
+ export type { AlertProps, AlertTopProps };
@@ -0,0 +1,24 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ import { Alert, AlertTop } from '@snack-uikit/alert';
14
+ import { MobileAlertTop } from '../MobileAlertTop';
15
+ export function AdaptiveAlert(_a) {
16
+ var { layoutType } = _a, props = __rest(_a, ["layoutType"]);
17
+ const isMobile = layoutType === 'mobile';
18
+ return _jsx(Alert, Object.assign({ truncate: isMobile ? { title: 2 } : undefined }, props));
19
+ }
20
+ export function AdaptiveAlertTop(_a) {
21
+ var { layoutType } = _a, props = __rest(_a, ["layoutType"]);
22
+ const isMobile = layoutType === 'mobile';
23
+ return isMobile ? _jsx(MobileAlertTop, Object.assign({}, props)) : _jsx(AlertTop, Object.assign({}, props));
24
+ }
@@ -0,0 +1 @@
1
+ export * from './AdaptiveAlert';
@@ -0,0 +1 @@
1
+ export * from './AdaptiveAlert';
@@ -0,0 +1,29 @@
1
+ import { ReactNode } from 'react';
2
+ import { LinkProps } from '@snack-uikit/link';
3
+ import { WithSupportProps } from '@snack-uikit/utils';
4
+ import { AlertButtonProps } from '../../helperComponents';
5
+ import { Appearance } from '../../types';
6
+ export type MobileAlertTopProps = WithSupportProps<{
7
+ /** Заголовок */
8
+ title?: string;
9
+ /** Описание */
10
+ description: ReactNode;
11
+ /** Cсылка */
12
+ link?: Pick<LinkProps, 'text' | 'target' | 'onClick' | 'href' | 'appearance'>;
13
+ /** Кнопка дополнительного действия */
14
+ action?: AlertButtonProps;
15
+ /** Колбек закрытия */
16
+ onClose?: () => void;
17
+ /** Внешний вид */
18
+ appearance?: Appearance;
19
+ /** CSS-класс */
20
+ className?: string;
21
+ truncate?: {
22
+ title?: number;
23
+ };
24
+ icon?: boolean;
25
+ }>;
26
+ /**
27
+ * Компонент для отображения уведомления вверху экрана.
28
+ */
29
+ export declare function MobileAlertTop({ title, description, link, onClose, appearance, action, className, ...rest }: MobileAlertTopProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,79 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
+ import cn from 'classnames';
14
+ import { useCallback, useRef, useState } from 'react';
15
+ import { ChevronDownSVG, ChevronUpSVG, CrossSVG } from '@sbercloud/uikit-product-icons';
16
+ import { Link } from '@snack-uikit/link';
17
+ import { extractSupportProps, isBrowser, useLayoutEffect } from '@snack-uikit/utils';
18
+ import { APPEARANCE, APPEARANCE_TO_COLOR_MAP } from '../../constants';
19
+ import { AlertButton } from '../../helperComponents';
20
+ import { APPEARANCE_TO_COLOR_MAP_INVERT } from './constants';
21
+ import styles from './styles.module.css';
22
+ const ONE_LINE_TEXT_HEIGHT = 20;
23
+ /**
24
+ * Компонент для отображения уведомления вверху экрана.
25
+ */
26
+ export function MobileAlertTop(_a) {
27
+ var { title, description, link, onClose, appearance = APPEARANCE.Neutral, action, className } = _a, rest = __rest(_a, ["title", "description", "link", "onClose", "appearance", "action", "className"]);
28
+ const titleRef = useRef(null);
29
+ const descriptionRef = useRef(null);
30
+ const [isExpanded, setIsExpanded] = useState(false);
31
+ const [isTitleLarge, setIsTitleLarge] = useState(false);
32
+ const [isDescriptionLarge, setIsDescriptionLarge] = useState(false);
33
+ const invertAppearance = APPEARANCE_TO_COLOR_MAP_INVERT[appearance];
34
+ const handleExpand = () => setIsExpanded(val => !val);
35
+ const canExpand = Boolean(isTitleLarge || isDescriptionLarge || link || action);
36
+ const showCloseButton = Boolean(onClose && ((canExpand && isExpanded) || !canExpand));
37
+ const showLink = Boolean(link && isExpanded);
38
+ const showAction = Boolean(action && isExpanded);
39
+ const handleClose = event => {
40
+ event.stopPropagation();
41
+ onClose === null || onClose === void 0 ? void 0 : onClose();
42
+ };
43
+ const handleActionButtonClick = event => {
44
+ var _a;
45
+ event.stopPropagation();
46
+ (_a = action === null || action === void 0 ? void 0 : action.onClick) === null || _a === void 0 ? void 0 : _a.call(action, event);
47
+ };
48
+ const handleLinkClick = event => {
49
+ var _a;
50
+ event.stopPropagation();
51
+ (_a = link === null || link === void 0 ? void 0 : link.onClick) === null || _a === void 0 ? void 0 : _a.call(link, event);
52
+ };
53
+ const updateIsLarge = useCallback(({ ref, setter }) => {
54
+ const element = ref.current;
55
+ if (element) {
56
+ const { offsetWidth, scrollWidth, offsetHeight } = element;
57
+ setter(offsetHeight > ONE_LINE_TEXT_HEIGHT || scrollWidth > offsetWidth);
58
+ }
59
+ }, []);
60
+ const observeElement = useCallback(({ ref, setter }) => {
61
+ const refElement = ref.current;
62
+ if (refElement && isBrowser()) {
63
+ const observer = new ResizeObserver(entities => entities.forEach(entity => {
64
+ if (entity.target === refElement) {
65
+ updateIsLarge({ ref, setter });
66
+ }
67
+ }));
68
+ observer.observe(refElement);
69
+ return () => observer.disconnect();
70
+ }
71
+ }, [updateIsLarge]);
72
+ useLayoutEffect(() => observeElement({ ref: titleRef, setter: setIsTitleLarge }), [observeElement]);
73
+ useLayoutEffect(() => updateIsLarge({ ref: titleRef, setter: setIsTitleLarge }), [title, updateIsLarge]);
74
+ useLayoutEffect(() => observeElement({ ref: descriptionRef, setter: setIsDescriptionLarge }), [observeElement]);
75
+ useLayoutEffect(() => updateIsLarge({ ref: descriptionRef, setter: setIsDescriptionLarge }), [description, updateIsLarge]);
76
+ return (
77
+ // eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions
78
+ _jsxs("div", Object.assign({ className: cn(styles.alertTop, className) }, extractSupportProps(rest), { "data-color": invertAppearance, role: 'alert', onClick: canExpand ? handleExpand : undefined, children: [_jsxs("div", { className: styles.contentWrapper, children: [_jsxs("div", { className: styles.contentLayout, children: [_jsxs("div", { className: styles.textLayout, "data-expanded": isExpanded || undefined, children: [title && (_jsx("div", { className: styles.title, ref: titleRef, "data-color": invertAppearance, "data-test-id": 'alert-top__title', children: title })), _jsx("div", { className: styles.description, ref: descriptionRef, "data-color": invertAppearance, "data-test-id": 'alert-top__description', "data-expanded": isExpanded || undefined, children: description })] }), showLink && (_jsx("span", { children: _jsx(Link, Object.assign({}, link, { onClick: handleLinkClick, appearance: APPEARANCE_TO_COLOR_MAP[appearance], textMode: 'on-accent', size: 'm', "data-test-id": 'alert-top__link' })) }))] }), showAction && (_jsx(AlertButton, Object.assign({}, action, { onClick: handleActionButtonClick, appearance: invertAppearance, variant: 'tonal' })))] }), _jsxs("div", { className: styles.actions, children: [canExpand && (_jsx("div", { className: styles.expandingIcon, "data-appearance": invertAppearance, "data-test-id": 'alert-top__expanding-icon', children: isExpanded ? _jsx(ChevronUpSVG, {}) : _jsx(ChevronDownSVG, {}) })), showCloseButton && (_jsx(AlertButton, { onClick: handleClose, appearance: invertAppearance, icon: _jsx(CrossSVG, {}), variant: 'tonal', dataTestId: 'alert-top__close-button' }))] })] })));
79
+ }
@@ -0,0 +1,8 @@
1
+ export declare const APPEARANCE_TO_COLOR_MAP_INVERT: {
2
+ readonly neutral: "invert-neutral";
3
+ readonly primary: "primary";
4
+ readonly error: "red";
5
+ readonly warning: "yellow";
6
+ readonly success: "green";
7
+ readonly info: "blue";
8
+ };
@@ -0,0 +1,17 @@
1
+ import { APPEARANCE } from '../../constants';
2
+ const COLOR = {
3
+ InvertNeutral: 'invert-neutral',
4
+ Primary: 'primary',
5
+ Red: 'red',
6
+ Yellow: 'yellow',
7
+ Green: 'green',
8
+ Blue: 'blue',
9
+ };
10
+ export const APPEARANCE_TO_COLOR_MAP_INVERT = {
11
+ [APPEARANCE.Neutral]: COLOR.InvertNeutral,
12
+ [APPEARANCE.Primary]: COLOR.Primary,
13
+ [APPEARANCE.Error]: COLOR.Red,
14
+ [APPEARANCE.Warning]: COLOR.Yellow,
15
+ [APPEARANCE.Success]: COLOR.Green,
16
+ [APPEARANCE.Info]: COLOR.Blue,
17
+ };
@@ -0,0 +1 @@
1
+ export * from './MobileAlertTop';
@@ -0,0 +1 @@
1
+ export * from './MobileAlertTop';
@@ -0,0 +1,177 @@
1
+ .alertTop{
2
+ padding-top:var(--space-alert-top-container-vertical-padding, 8px);
3
+ padding-bottom:var(--space-alert-top-container-vertical-padding, 8px);
4
+ padding-left:var(--space-alert-top-container-horizontal-padding, 16px);
5
+ padding-right:var(--space-alert-top-container-horizontal-padding, 16px);
6
+ gap:var(--space-alert-top-container-gap, 16px);
7
+ display:flex;
8
+ justify-content:space-between;
9
+ box-sizing:border-box;
10
+ gap:0;
11
+ }
12
+ .alertTop[data-color=invert-neutral]{
13
+ background-color:var(--sys-invert-neutral-background, #30303c);
14
+ }
15
+ .alertTop[data-color=primary]{
16
+ background-color:var(--sys-primary-accent-default, #389f74);
17
+ }
18
+ .alertTop[data-color=red]{
19
+ background-color:var(--sys-red-accent-default, #cb3f3e);
20
+ }
21
+ .alertTop[data-color=yellow]{
22
+ background-color:var(--sys-yellow-accent-default, #e2b134);
23
+ }
24
+ .alertTop[data-color=green]{
25
+ background-color:var(--sys-green-accent-default, #57b762);
26
+ }
27
+ .alertTop[data-color=blue]{
28
+ background-color:var(--sys-blue-accent-default, #5388d1);
29
+ }
30
+
31
+ .icon{
32
+ display:flex;
33
+ align-items:center;
34
+ justify-content:center;
35
+ }
36
+ .icon[data-color=invert-neutral]{
37
+ color:var(--sys-invert-neutral-text-main, #e6e8ef);
38
+ }
39
+ .icon[data-color=primary]{
40
+ color:var(--sys-primary-on-accent, #fbfffc);
41
+ }
42
+ .icon[data-color=red]{
43
+ color:var(--sys-red-on-accent, #fffbf9);
44
+ }
45
+ .icon[data-color=yellow]{
46
+ color:var(--sys-yellow-on-accent, #583f1f);
47
+ }
48
+ .icon[data-color=green]{
49
+ color:var(--sys-green-on-accent, #fcfefa);
50
+ }
51
+ .icon[data-color=blue]{
52
+ color:var(--sys-blue-on-accent, #fdfeff);
53
+ }
54
+ .icon svg{
55
+ width:var(--size-icon-container-s, 24px) !important;
56
+ height:var(--size-icon-container-s, 24px) !important;
57
+ }
58
+
59
+ .title{
60
+ font-family:var(--sans-title-s-font-family, SB Sans Interface);
61
+ font-weight:var(--sans-title-s-font-weight, Semibold);
62
+ line-height:var(--sans-title-s-line-height, 20px);
63
+ font-size:var(--sans-title-s-font-size, 14px);
64
+ letter-spacing:var(--sans-title-s-letter-spacing, 0.15px);
65
+ paragraph-spacing:var(--sans-title-s-paragraph-spacing, 7.7px);
66
+ word-wrap:break-word;
67
+ overflow:hidden;
68
+ text-overflow:ellipsis;
69
+ white-space:nowrap;
70
+ }
71
+ .title[data-color=invert-neutral]{
72
+ color:var(--sys-invert-neutral-text-main, #e6e8ef);
73
+ }
74
+ .title[data-color=primary]{
75
+ color:var(--sys-primary-on-accent, #fbfffc);
76
+ }
77
+ .title[data-color=red]{
78
+ color:var(--sys-red-on-accent, #fffbf9);
79
+ }
80
+ .title[data-color=yellow]{
81
+ color:var(--sys-yellow-on-accent, #583f1f);
82
+ }
83
+ .title[data-color=green]{
84
+ color:var(--sys-green-on-accent, #fcfefa);
85
+ }
86
+ .title[data-color=blue]{
87
+ color:var(--sys-blue-on-accent, #fdfeff);
88
+ }
89
+
90
+ .description{
91
+ font-family:var(--sans-body-m-font-family, SB Sans Interface);
92
+ font-weight:var(--sans-body-m-font-weight, Regular);
93
+ line-height:var(--sans-body-m-line-height, 20px);
94
+ font-size:var(--sans-body-m-font-size, 14px);
95
+ letter-spacing:var(--sans-body-m-letter-spacing, 0.1px);
96
+ paragraph-spacing:var(--sans-body-m-paragraph-spacing, 7.7px);
97
+ word-wrap:break-word;
98
+ overflow:hidden;
99
+ text-overflow:ellipsis;
100
+ white-space:nowrap;
101
+ }
102
+ .description[data-color=invert-neutral]{
103
+ color:var(--sys-invert-neutral-text-main, #e6e8ef);
104
+ }
105
+ .description[data-color=primary]{
106
+ color:var(--sys-primary-on-accent, #fbfffc);
107
+ }
108
+ .description[data-color=red]{
109
+ color:var(--sys-red-on-accent, #fffbf9);
110
+ }
111
+ .description[data-color=yellow]{
112
+ color:var(--sys-yellow-on-accent, #583f1f);
113
+ }
114
+ .description[data-color=green]{
115
+ color:var(--sys-green-on-accent, #fcfefa);
116
+ }
117
+ .description[data-color=blue]{
118
+ color:var(--sys-blue-on-accent, #fdfeff);
119
+ }
120
+
121
+ .contentWrapper{
122
+ display:flex;
123
+ flex-direction:column;
124
+ gap:var(--dimension-1m, 8px);
125
+ align-items:flex-start;
126
+ min-width:0;
127
+ justify-content:center;
128
+ }
129
+
130
+ .contentLayout{
131
+ gap:var(--space-alert-top-container-content-layout-gap, 2px);
132
+ display:flex;
133
+ flex-direction:column;
134
+ min-width:0;
135
+ width:100%;
136
+ }
137
+
138
+ .textLayout{
139
+ overflow:hidden;
140
+ }
141
+ .textLayout[data-expanded] .title, .textLayout[data-expanded] .description{
142
+ overflow:initial;
143
+ text-overflow:initial;
144
+ white-space:initial;
145
+ }
146
+
147
+ .actions{
148
+ display:flex;
149
+ flex-direction:column;
150
+ }
151
+
152
+ .expandingIcon{
153
+ display:flex;
154
+ align-items:center;
155
+ justify-content:center;
156
+ flex-shrink:0;
157
+ width:var(--dimension-5m, 40px);
158
+ height:var(--dimension-5m, 40px);
159
+ }
160
+ .expandingIcon[data-appearance=invert-neutral]{
161
+ color:var(--sys-invert-neutral-text-main, #e6e8ef);
162
+ }
163
+ .expandingIcon[data-appearance=primary]{
164
+ color:var(--sys-primary-on-accent, #fbfffc);
165
+ }
166
+ .expandingIcon[data-appearance=red]{
167
+ color:var(--sys-red-on-accent, #fffbf9);
168
+ }
169
+ .expandingIcon[data-appearance=yellow]{
170
+ color:var(--sys-yellow-on-accent, #583f1f);
171
+ }
172
+ .expandingIcon[data-appearance=green]{
173
+ color:var(--sys-green-on-accent, #fcfefa);
174
+ }
175
+ .expandingIcon[data-appearance=blue]{
176
+ color:var(--sys-blue-on-accent, #fdfeff);
177
+ }
@@ -0,0 +1,2 @@
1
+ export * from './AdaptiveAlert';
2
+ export * from './MobileAlertTop';
@@ -0,0 +1,2 @@
1
+ export * from './AdaptiveAlert';
2
+ export * from './MobileAlertTop';
@@ -0,0 +1,16 @@
1
+ import { LinkProps } from '@snack-uikit/link';
2
+ import { ValueOf } from '@snack-uikit/utils';
3
+ export declare const APPEARANCE: {
4
+ readonly Neutral: "neutral";
5
+ readonly Primary: "primary";
6
+ readonly Error: "error";
7
+ readonly Warning: "warning";
8
+ readonly Success: "success";
9
+ readonly Info: "info";
10
+ };
11
+ export declare const SIZE: {
12
+ readonly S: "s";
13
+ readonly M: "m";
14
+ };
15
+ export declare const APPEARANCE_TO_COLOR_MAP: Record<ValueOf<typeof APPEARANCE>, LinkProps['appearance']>;
16
+ export declare const APPEARANCE_TO_LINK_COLOR_MAP: Record<ValueOf<typeof APPEARANCE>, LinkProps['appearance']>;
@@ -0,0 +1,28 @@
1
+ export const APPEARANCE = {
2
+ Neutral: 'neutral',
3
+ Primary: 'primary',
4
+ Error: 'error',
5
+ Warning: 'warning',
6
+ Success: 'success',
7
+ Info: 'info',
8
+ };
9
+ export const SIZE = {
10
+ S: 's',
11
+ M: 'm',
12
+ };
13
+ export const APPEARANCE_TO_COLOR_MAP = {
14
+ [APPEARANCE.Neutral]: 'neutral',
15
+ [APPEARANCE.Primary]: 'primary',
16
+ [APPEARANCE.Error]: 'red',
17
+ [APPEARANCE.Warning]: 'yellow',
18
+ [APPEARANCE.Success]: 'green',
19
+ [APPEARANCE.Info]: 'blue',
20
+ };
21
+ export const APPEARANCE_TO_LINK_COLOR_MAP = {
22
+ [APPEARANCE.Neutral]: 'primary',
23
+ [APPEARANCE.Primary]: 'primary',
24
+ [APPEARANCE.Error]: 'red',
25
+ [APPEARANCE.Warning]: 'yellow',
26
+ [APPEARANCE.Success]: 'green',
27
+ [APPEARANCE.Info]: 'blue',
28
+ };
@@ -0,0 +1,24 @@
1
+ import { MouseEvent, ReactElement } from 'react';
2
+ import { LinkProps } from '@snack-uikit/link';
3
+ import { Size } from '../types';
4
+ type PrivateAlertButtonProps = {
5
+ /** Внешний вид */
6
+ appearance?: LinkProps['appearance'] | 'invert-neutral';
7
+ /** Текст кнопки */
8
+ text?: string;
9
+ /** Иконка в кнопке */
10
+ icon?: ReactElement;
11
+ /** Вариант отображения */
12
+ variant?: 'simple' | 'tonal';
13
+ /** Колбек клика */
14
+ onClick?(e: MouseEvent<HTMLButtonElement>): void;
15
+ /** Дата тест айди */
16
+ dataTestId?: string;
17
+ /** Управление состоянием загрузки */
18
+ loading?: boolean;
19
+ /** Размер */
20
+ size?: Size;
21
+ };
22
+ export type AlertButtonProps = Omit<PrivateAlertButtonProps, 'appearance' | 'variant'>;
23
+ export declare function AlertButton({ appearance, text, icon, onClick, dataTestId, loading }: PrivateAlertButtonProps): import("react/jsx-runtime").JSX.Element;
24
+ export {};
@@ -0,0 +1,6 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Sun } from '@snack-uikit/loaders';
3
+ import styles from './styles.module.css';
4
+ export function AlertButton({ appearance, text, icon, onClick, dataTestId, loading = false }) {
5
+ return (_jsxs("button", { type: 'button', onClick: onClick, className: styles.alertButton, "data-variant": 'tonal', "data-appearance": appearance, "data-test-id": dataTestId || 'alert__action-button', "data-icon-only": !text || undefined, "data-loading": loading, "data-size": 'm', children: [text && (_jsx("span", { className: styles.text, "data-size": 'm', children: text })), icon && (loading ? _jsx(Sun, { size: 's' }) : _jsx("span", { className: styles.icon, children: icon }))] }));
6
+ }
@@ -0,0 +1 @@
1
+ export * from './AlertButton';
@@ -0,0 +1 @@
1
+ export * from './AlertButton';
@@ -0,0 +1,85 @@
1
+ .alertButton{
2
+ cursor:pointer;
3
+ display:flex;
4
+ align-items:center;
5
+ justify-content:center;
6
+ box-sizing:border-box;
7
+ margin:0;
8
+ padding:0;
9
+ white-space:nowrap;
10
+ background:none;
11
+ border:0;
12
+ }
13
+ .alertButton .text[data-size=m]{
14
+ font-family:var(--sans-label-l-font-family, SB Sans Interface);
15
+ font-weight:var(--sans-label-l-font-weight, Semibold);
16
+ line-height:var(--sans-label-l-line-height, 20px);
17
+ font-size:var(--sans-label-l-font-size, 14px);
18
+ letter-spacing:var(--sans-label-l-letter-spacing, 0px);
19
+ paragraph-spacing:var(--sans-label-l-paragraph-spacing, 7.7px);
20
+ }
21
+ .alertButton .icon{
22
+ display:inline-flex;
23
+ align-items:center;
24
+ justify-content:center;
25
+ width:var(--size-icon-container-s, 24px);
26
+ height:var(--size-icon-container-s, 24px);
27
+ }
28
+ .alertButton .icon svg{
29
+ max-width:var(--size-icon-container-s, 24px);
30
+ max-height:var(--size-icon-container-s, 24px);
31
+ }
32
+ .alertButton[data-loading=true]{
33
+ cursor:not-allowed;
34
+ }
35
+ .alertButton[data-loading=true] > *{
36
+ cursor:not-allowed;
37
+ }
38
+ .alertButton[data-variant=tonal]{
39
+ height:var(--size-alert-top-button, 32px);
40
+ gap:var(--space-alert-top-button-gap, 4px);
41
+ border-radius:var(--radius-alert-top-button, 4px);
42
+ padding-left:var(--space-alert-top-button-horizontal-padding, 12px);
43
+ padding-right:var(--space-alert-top-button-horizontal-padding, 12px);
44
+ background:var(--sys-opacity-enabled, rgba(255, 255, 255, 0.1607843137));
45
+ }
46
+ .alertButton[data-variant=tonal][data-icon-only]{
47
+ border-radius:var(--radius-alert-top-button, 4px);
48
+ height:var(--size-alert-top-button, 32px);
49
+ width:var(--size-alert-top-button, 32px);
50
+ height:var(--dimension-5m, 40px);
51
+ width:var(--dimension-5m, 40px);
52
+ background:none;
53
+ }
54
+ .alertButton[data-variant=tonal]:hover{
55
+ opacity:unset;
56
+ background-color:var(--sys-opacity-hovered, rgba(255, 255, 255, 0.2392156863));
57
+ }
58
+ .alertButton[data-variant=tonal]:focus-visible{
59
+ outline-width:var(--border-state-focus-s-border-width, 2px);
60
+ outline-style:var(--border-state-focus-s-border-style, solid);
61
+ outline-color:var(--border-state-focus-s-border-color, );
62
+ background-color:var(--sys-opacity-hovered, rgba(255, 255, 255, 0.2392156863));
63
+ outline-color:var(--sys-available-on-complementary, #ffffff);
64
+ }
65
+ .alertButton[data-variant=tonal]:active{
66
+ background-color:var(--sys-opacity-activated, rgba(255, 255, 255, 0.3215686275));
67
+ }
68
+ .alertButton[data-variant=tonal][data-appearance=invert-neutral]{
69
+ color:var(--sys-invert-neutral-text-main, #e6e8ef);
70
+ }
71
+ .alertButton[data-variant=tonal][data-appearance=primary]{
72
+ color:var(--sys-primary-on-accent, #fbfffc);
73
+ }
74
+ .alertButton[data-variant=tonal][data-appearance=red]{
75
+ color:var(--sys-red-on-accent, #fffbf9);
76
+ }
77
+ .alertButton[data-variant=tonal][data-appearance=yellow]{
78
+ color:var(--sys-yellow-on-accent, #583f1f);
79
+ }
80
+ .alertButton[data-variant=tonal][data-appearance=green]{
81
+ color:var(--sys-green-on-accent, #fcfefa);
82
+ }
83
+ .alertButton[data-variant=tonal][data-appearance=blue]{
84
+ color:var(--sys-blue-on-accent, #fdfeff);
85
+ }
@@ -0,0 +1 @@
1
+ export * from './components';
@@ -0,0 +1 @@
1
+ export * from './components';
@@ -0,0 +1,4 @@
1
+ import { ValueOf } from '@snack-uikit/utils';
2
+ import { APPEARANCE, SIZE } from './constants';
3
+ export type Appearance = ValueOf<typeof APPEARANCE>;
4
+ export type Size = ValueOf<typeof SIZE>;
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloud-ru/uikit-product-mobile-alert",
3
3
  "title": "Mobile Alert",
4
- "version": "0.4.64",
4
+ "version": "0.4.65",
5
5
  "sideEffects": [
6
6
  "*.css",
7
7
  "*.woff",
@@ -30,19 +30,20 @@
30
30
  "name": "Akhremenko Grigorii",
31
31
  "url": "https://github.com/AGrigorii"
32
32
  },
33
+ "contributors": [],
33
34
  "license": "Apache-2.0",
34
35
  "publishConfig": {
35
36
  "access": "public"
36
37
  },
37
38
  "scripts": {},
38
39
  "dependencies": {
39
- "@cloud-ru/uikit-product-icons": "15.1.1",
40
- "@cloud-ru/uikit-product-utils": "7.0.0",
40
+ "@cloud-ru/uikit-product-icons": "15.1.2",
41
+ "@cloud-ru/uikit-product-utils": "7.0.1",
41
42
  "@snack-uikit/alert": "0.16.17",
42
43
  "@snack-uikit/link": "0.17.9",
43
44
  "@snack-uikit/loaders": "0.9.8",
44
45
  "@snack-uikit/utils": "3.10.1",
45
46
  "classnames": "2.5.1"
46
47
  },
47
- "gitHead": "e8bd79bc92b26a8f52611972eec98a867536ccd3"
48
+ "gitHead": "9c11b1e33e716c874534a1c162266c8591f2ed03"
48
49
  }