@salutejs/plasma-new-hope 0.252.0-canary.1738.13067280086.0 → 0.253.0-canary.1719.13069931199.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.
Files changed (115) hide show
  1. package/cjs/components/TextField/TextField.js +1 -1
  2. package/cjs/components/TextField/TextField.js.map +1 -1
  3. package/cjs/components/Toast/Toast.css +7 -7
  4. package/cjs/components/Toast/Toast.js +5 -2
  5. package/cjs/components/Toast/Toast.js.map +1 -1
  6. package/cjs/components/Toast/Toast.styles.js +11 -2
  7. package/cjs/components/Toast/Toast.styles.js.map +1 -1
  8. package/cjs/components/Toast/{Toast.styles_1nei944.css → Toast.styles_1kasmzh.css} +2 -2
  9. package/cjs/components/Toast/Toast.tokens.js +2 -1
  10. package/cjs/components/Toast/Toast.tokens.js.map +1 -1
  11. package/cjs/components/Toast/ToastController.css +6 -6
  12. package/cjs/components/Toast/ToastController.js +1 -13
  13. package/cjs/components/Toast/ToastController.js.map +1 -1
  14. package/cjs/components/Toast/ToastProvider/ToastProvider.js +22 -4
  15. package/cjs/components/Toast/ToastProvider/ToastProvider.js.map +1 -1
  16. package/cjs/components/Toast/utils.js +2 -0
  17. package/cjs/components/Toast/utils.js.map +1 -1
  18. package/cjs/components/Toast/variations/_pilled/base.js +1 -1
  19. package/cjs/components/Toast/variations/_pilled/base.js.map +1 -1
  20. package/cjs/components/Toast/variations/_pilled/base_13i59v3.css +1 -0
  21. package/cjs/index.css +8 -8
  22. package/emotion/cjs/components/TextField/TextField.js +2 -2
  23. package/emotion/cjs/components/Toast/Toast.js +5 -2
  24. package/emotion/cjs/components/Toast/Toast.styles.js +9 -6
  25. package/emotion/cjs/components/Toast/Toast.template-doc.mdx +22 -5
  26. package/emotion/cjs/components/Toast/Toast.tokens.js +2 -1
  27. package/emotion/cjs/components/Toast/ToastController.js +3 -16
  28. package/emotion/cjs/components/Toast/ToastProvider/ToastProvider.js +22 -4
  29. package/emotion/cjs/components/Toast/utils.js +2 -1
  30. package/emotion/cjs/components/Toast/variations/_pilled/base.js +1 -1
  31. package/emotion/cjs/examples/plasma_b2c/components/Toast/Toast.config.js +17 -7
  32. package/emotion/cjs/examples/plasma_b2c/components/Toast/Toast.stories.tsx +31 -14
  33. package/emotion/cjs/examples/plasma_web/components/Toast/Toast.config.js +17 -7
  34. package/emotion/cjs/examples/plasma_web/components/Toast/Toast.stories.tsx +31 -14
  35. package/emotion/es/components/TextField/TextField.js +2 -2
  36. package/emotion/es/components/Toast/Toast.js +5 -2
  37. package/emotion/es/components/Toast/Toast.styles.js +9 -6
  38. package/emotion/es/components/Toast/Toast.template-doc.mdx +22 -5
  39. package/emotion/es/components/Toast/Toast.tokens.js +2 -1
  40. package/emotion/es/components/Toast/ToastController.js +2 -14
  41. package/emotion/es/components/Toast/ToastProvider/ToastProvider.js +23 -5
  42. package/emotion/es/components/Toast/utils.js +1 -0
  43. package/emotion/es/components/Toast/variations/_pilled/base.js +1 -1
  44. package/emotion/es/examples/plasma_b2c/components/Toast/Toast.config.js +17 -7
  45. package/emotion/es/examples/plasma_b2c/components/Toast/Toast.stories.tsx +31 -14
  46. package/emotion/es/examples/plasma_web/components/Toast/Toast.config.js +17 -7
  47. package/emotion/es/examples/plasma_web/components/Toast/Toast.stories.tsx +31 -14
  48. package/es/components/TextField/TextField.js +1 -1
  49. package/es/components/TextField/TextField.js.map +1 -1
  50. package/es/components/Toast/Toast.css +7 -7
  51. package/es/components/Toast/Toast.js +5 -2
  52. package/es/components/Toast/Toast.js.map +1 -1
  53. package/es/components/Toast/Toast.styles.js +11 -2
  54. package/es/components/Toast/Toast.styles.js.map +1 -1
  55. package/es/components/Toast/{Toast.styles_1nei944.css → Toast.styles_1kasmzh.css} +2 -2
  56. package/es/components/Toast/Toast.tokens.js +2 -1
  57. package/es/components/Toast/Toast.tokens.js.map +1 -1
  58. package/es/components/Toast/ToastController.css +6 -6
  59. package/es/components/Toast/ToastController.js +2 -14
  60. package/es/components/Toast/ToastController.js.map +1 -1
  61. package/es/components/Toast/ToastProvider/ToastProvider.js +23 -5
  62. package/es/components/Toast/ToastProvider/ToastProvider.js.map +1 -1
  63. package/es/components/Toast/utils.js +2 -1
  64. package/es/components/Toast/utils.js.map +1 -1
  65. package/es/components/Toast/variations/_pilled/base.js +1 -1
  66. package/es/components/Toast/variations/_pilled/base.js.map +1 -1
  67. package/es/components/Toast/variations/_pilled/base_13i59v3.css +1 -0
  68. package/es/index.css +8 -8
  69. package/package.json +2 -2
  70. package/styled-components/cjs/components/TextField/TextField.js +1 -1
  71. package/styled-components/cjs/components/Toast/Toast.js +5 -2
  72. package/styled-components/cjs/components/Toast/Toast.styles.js +5 -2
  73. package/styled-components/cjs/components/Toast/Toast.template-doc.mdx +22 -5
  74. package/styled-components/cjs/components/Toast/Toast.tokens.js +2 -1
  75. package/styled-components/cjs/components/Toast/ToastController.js +3 -16
  76. package/styled-components/cjs/components/Toast/ToastProvider/ToastProvider.js +22 -4
  77. package/styled-components/cjs/components/Toast/utils.js +2 -1
  78. package/styled-components/cjs/components/Toast/variations/_pilled/base.js +1 -1
  79. package/styled-components/cjs/examples/plasma_b2c/components/Toast/Toast.config.js +12 -2
  80. package/styled-components/cjs/examples/plasma_b2c/components/Toast/Toast.stories.tsx +31 -14
  81. package/styled-components/cjs/examples/plasma_web/components/Toast/Toast.config.js +12 -2
  82. package/styled-components/cjs/examples/plasma_web/components/Toast/Toast.stories.tsx +31 -14
  83. package/styled-components/es/components/TextField/TextField.js +1 -1
  84. package/styled-components/es/components/Toast/Toast.js +5 -2
  85. package/styled-components/es/components/Toast/Toast.styles.js +5 -2
  86. package/styled-components/es/components/Toast/Toast.template-doc.mdx +22 -5
  87. package/styled-components/es/components/Toast/Toast.tokens.js +2 -1
  88. package/styled-components/es/components/Toast/ToastController.js +2 -14
  89. package/styled-components/es/components/Toast/ToastProvider/ToastProvider.js +23 -5
  90. package/styled-components/es/components/Toast/utils.js +1 -0
  91. package/styled-components/es/components/Toast/variations/_pilled/base.js +1 -1
  92. package/styled-components/es/examples/plasma_b2c/components/Toast/Toast.config.js +12 -2
  93. package/styled-components/es/examples/plasma_b2c/components/Toast/Toast.stories.tsx +31 -14
  94. package/styled-components/es/examples/plasma_web/components/Toast/Toast.config.js +12 -2
  95. package/styled-components/es/examples/plasma_web/components/Toast/Toast.stories.tsx +31 -14
  96. package/types/components/Toast/Toast.styles.d.ts +3 -1
  97. package/types/components/Toast/Toast.styles.d.ts.map +1 -1
  98. package/types/components/Toast/Toast.tokens.d.ts +2 -1
  99. package/types/components/Toast/Toast.tokens.d.ts.map +1 -1
  100. package/types/components/Toast/Toast.types.d.ts +8 -0
  101. package/types/components/Toast/Toast.types.d.ts.map +1 -1
  102. package/types/components/Toast/ToastController.d.ts.map +1 -1
  103. package/types/components/Toast/ToastProvider/ToastProvider.d.ts.map +1 -1
  104. package/types/components/Toast/utils.d.ts +1 -0
  105. package/types/components/Toast/utils.d.ts.map +1 -1
  106. package/types/examples/plasma_b2c/components/Toast/Toast.config.d.ts +10 -0
  107. package/types/examples/plasma_b2c/components/Toast/Toast.config.d.ts.map +1 -1
  108. package/types/examples/plasma_b2c/components/Toast/Toast.d.ts +2 -0
  109. package/types/examples/plasma_b2c/components/Toast/Toast.d.ts.map +1 -1
  110. package/types/examples/plasma_web/components/Toast/Toast.config.d.ts +10 -0
  111. package/types/examples/plasma_web/components/Toast/Toast.config.d.ts.map +1 -1
  112. package/types/examples/plasma_web/components/Toast/Toast.d.ts +2 -0
  113. package/types/examples/plasma_web/components/Toast/Toast.d.ts.map +1 -1
  114. package/cjs/components/Toast/variations/_pilled/base_199qghc.css +0 -1
  115. package/es/components/Toast/variations/_pilled/base_199qghc.css +0 -1
@@ -4,21 +4,39 @@ import { action } from '@storybook/addon-actions';
4
4
  import styled from 'styled-components';
5
5
  import { disableProps } from '@salutejs/plasma-sb-utils';
6
6
 
7
- import { toastConfig } from '../../../../components/Toast';
8
- import { mergeConfig } from '../../../../engines';
9
- import { WithTheme, argTypesFromConfig } from '../../../_helpers';
7
+ import { WithTheme } from '../../../_helpers';
10
8
  import { Button } from '../Button/Button';
11
9
  import { PopupProvider } from '../Popup/Popup';
12
10
  import { addNotification } from '../../../../../src/components/Notification';
13
11
  import { NotificationsProvider } from '../Notification/Notification';
14
12
  import { Modal } from '../Modal/Modal';
15
13
 
16
- import { config } from './Toast.config';
17
14
  import { Toast, ToastController, ToastProvider, useToast } from './Toast';
18
15
 
16
+ const views = ['default', 'positive', 'negative'];
17
+ const closeIconTypes = ['default', 'thin'];
18
+
19
19
  const meta: Meta<typeof ToastController> = {
20
20
  title: 'b2c/Overlay/Toast',
21
21
  decorators: [WithTheme],
22
+ argTypes: {
23
+ view: {
24
+ options: views,
25
+ control: {
26
+ type: 'select',
27
+ },
28
+ },
29
+ closeIconType: {
30
+ options: closeIconTypes,
31
+ control: {
32
+ type: 'select',
33
+ },
34
+ },
35
+ textColor: {
36
+ control: 'color',
37
+ },
38
+ ...disableProps(['size']),
39
+ },
22
40
  };
23
41
 
24
42
  export default meta;
@@ -49,7 +67,6 @@ const StyledWrapper = styled.div`
49
67
  `;
50
68
 
51
69
  const ToastContainer = styled.div`
52
- position: fixed;
53
70
  transform: translateX(50%);
54
71
  `;
55
72
 
@@ -61,6 +78,7 @@ const Container = styled.div`
61
78
  export const ToastComponent: StoryComponent = {
62
79
  args: {
63
80
  text: 'Текст всплывающего уведомления',
81
+ textColor: undefined,
64
82
  view: 'default',
65
83
  closeIconType: 'default',
66
84
  size: 'm',
@@ -68,14 +86,6 @@ export const ToastComponent: StoryComponent = {
68
86
  enableContentLeft: true,
69
87
  pilled: false,
70
88
  },
71
- argTypes: {
72
- closeIconType: {
73
- options: ['default', 'thin'],
74
- control: {
75
- type: 'select',
76
- },
77
- },
78
- },
79
89
  render: ({ enableContentLeft, ...args }) => (
80
90
  <ToastContainer>
81
91
  <Toast contentLeft={enableContentLeft && <BellIcon width="1rem" height="1rem" />} {...args} />
@@ -94,6 +104,8 @@ const StoryLiveDemo = ({
94
104
  size,
95
105
  hasClose,
96
106
  enableContentLeft,
107
+ closeIconType,
108
+ textColor,
97
109
  }: StoryProps) => {
98
110
  const { showToast, hideToast } = useToast();
99
111
  const contentLeft = enableContentLeft && <BellIcon width="1rem" height="1rem" />;
@@ -114,6 +126,8 @@ const StoryLiveDemo = ({
114
126
  view,
115
127
  size,
116
128
  hasClose,
129
+ closeIconType,
130
+ textColor,
117
131
  onHide: action('onHide'),
118
132
  onShow: action('onShow'),
119
133
  });
@@ -141,7 +155,6 @@ export const LiveDemo: Story = {
141
155
  type: 'inline-radio',
142
156
  },
143
157
  },
144
- ...argTypesFromConfig(mergeConfig(toastConfig, config)),
145
158
  ...disableProps(['role', 'onShow', 'onHide', 'contentLeft']),
146
159
  },
147
160
  parameters: {
@@ -167,6 +180,8 @@ const StoryComplex = ({
167
180
  size,
168
181
  hasClose,
169
182
  enableContentLeft,
183
+ closeIconType,
184
+ textColor,
170
185
  }: StoryProps) => {
171
186
  const [isModalOpen, setIsModalOpen] = useState(false);
172
187
 
@@ -185,6 +200,8 @@ const StoryComplex = ({
185
200
  view,
186
201
  size,
187
202
  hasClose,
203
+ closeIconType,
204
+ textColor,
188
205
  onHide: action('onHide'),
189
206
  onShow: action('onShow'),
190
207
  });
@@ -15,14 +15,24 @@ var config = exports.config = {
15
15
  variations: {
16
16
  view: {
17
17
  "default": /*#__PURE__*/(0, _styledComponents.css)(["", ":var(--text-primary);", ":var(--surface-solid-card-brightness);", ":var(--text-secondary);", ":var(--text-secondary);"], _Toast.toastTokens.color, _Toast.toastTokens.background, _Toast.toastTokens.closeIconColor, _Toast.toastTokens.closeIconColorOnHover),
18
+ positive: /*#__PURE__*/(0, _styledComponents.css)(["", ":var(--text-primary);", ":var(--surface-solid-card-brightness);", ":var(--text-positive);", ":var(--text-secondary);", ":var(--text-secondary);"], _Toast.toastTokens.color, _Toast.toastTokens.background, _Toast.toastTokens.contentLeftColor, _Toast.toastTokens.closeIconColor, _Toast.toastTokens.closeIconColorOnHover),
19
+ negative: /*#__PURE__*/(0, _styledComponents.css)(["", ":var(--text-primary);", ":var(--surface-solid-card-brightness);", ":var(--text-negative);", ":var(--text-secondary);", ":var(--text-secondary);"], _Toast.toastTokens.color, _Toast.toastTokens.background, _Toast.toastTokens.contentLeftColor, _Toast.toastTokens.closeIconColor, _Toast.toastTokens.closeIconColorOnHover),
20
+ /**
21
+ * @deprecated
22
+ * светлый и темный фон регулировать через `view` компонента `ViewContainer`
23
+ */
18
24
  dark: /*#__PURE__*/(0, _styledComponents.css)(["", ":var(--on-dark-text-primary);", ":var(--on-dark-surface-solid-primary-brightness);", ":var(--on-dark-text-secondary);", ":var(--on-dark-text-secondary);"], _Toast.toastTokens.color, _Toast.toastTokens.background, _Toast.toastTokens.closeIconColor, _Toast.toastTokens.closeIconColorOnHover),
25
+ /**
26
+ * @deprecated
27
+ * светлый и темный фон регулировать через `view` компонента `ViewContainer`
28
+ */
19
29
  light: /*#__PURE__*/(0, _styledComponents.css)(["", ":var(--on-light-text-primary);", ":var(--on-light-surface-solid-primary-brightness);", ":var(--on-light-text-secondary);", ":var(--on-light-text-secondary);"], _Toast.toastTokens.color, _Toast.toastTokens.background, _Toast.toastTokens.closeIconColor, _Toast.toastTokens.closeIconColorOnHover)
20
30
  },
21
31
  size: {
22
- m: /*#__PURE__*/(0, _styledComponents.css)(["", ":0.75rem;", ":calc(100vw - 5rem);", ":0.5625rem 0.75rem;", ":var(--plasma-typo-body-xs-font-family);", ":var(--plasma-typo-body-xs-font-size);", ":var(--plasma-typo-body-xs-font-style);", ":var(--plasma-typo-body-xs-font-weight);", ":var(--plasma-typo-body-xs-letter-spacing);", ":var(--plasma-typo-body-xs-line-height);", ":-0.0625rem 0.375rem -0.0625rem -0.125rem;", ":-0.0625rem -0.25rem -0.0625rem 0.5rem;"], _Toast.toastTokens.borderRadius, _Toast.toastTokens.maxWidth, _Toast.toastTokens.padding, _Toast.toastTokens.fontFamily, _Toast.toastTokens.fontSize, _Toast.toastTokens.fontStyle, _Toast.toastTokens.fontWeight, _Toast.toastTokens.letterSpacing, _Toast.toastTokens.lineHeight, _Toast.toastTokens.leftContentMargin, _Toast.toastTokens.closeIconMargin)
32
+ m: /*#__PURE__*/(0, _styledComponents.css)(["", ":0.75rem;", ":calc(100vw - 5rem);", ":0.5625rem 0.75rem;", ":var(--plasma-typo-body-xs-font-family);", ":var(--plasma-typo-body-xs-font-size);", ":var(--plasma-typo-body-xs-font-style);", ":var(--plasma-typo-body-xs-font-weight);", ":var(--plasma-typo-body-xs-letter-spacing);", ":var(--plasma-typo-body-xs-line-height);", ":-0.0625rem 0.375rem -0.0625rem -0.125rem;", ":-0.0625rem -0.25rem -0.0625rem 0.5rem;"], _Toast.toastTokens.borderRadius, _Toast.toastTokens.maxWidth, _Toast.toastTokens.padding, _Toast.toastTokens.fontFamily, _Toast.toastTokens.fontSize, _Toast.toastTokens.fontStyle, _Toast.toastTokens.fontWeight, _Toast.toastTokens.letterSpacing, _Toast.toastTokens.lineHeight, _Toast.toastTokens.contentLeftMargin, _Toast.toastTokens.closeIconMargin)
23
33
  },
24
34
  pilled: {
25
- "true": /*#__PURE__*/(0, _styledComponents.css)(["", ":1.5rem;", ":-0.0625rem 0.375rem -0.0625rem -0.25rem;", ":-0.0625rem -0.25rem -0.0625rem 0.375rem;"], _Toast.toastTokens.pilledBorderRadius, _Toast.toastTokens.leftContentMargin, _Toast.toastTokens.closeIconMargin)
35
+ "true": /*#__PURE__*/(0, _styledComponents.css)(["", ":1.5rem;", ":-0.0625rem 0.375rem -0.0625rem -0.25rem;", ":-0.0625rem -0.25rem -0.0625rem 0.375rem;"], _Toast.toastTokens.pilledBorderRadius, _Toast.toastTokens.contentLeftMargin, _Toast.toastTokens.closeIconMargin)
26
36
  },
27
37
  closeIconType: {
28
38
  "default": /*#__PURE__*/(0, _styledComponents.css)(["", ":1rem;", ":1.5rem;"], _Toast.toastTokens.closeIconButtonSize, _Toast.toastTokens.closeIconSize),
@@ -4,21 +4,39 @@ import { action } from '@storybook/addon-actions';
4
4
  import styled from 'styled-components';
5
5
  import { disableProps } from '@salutejs/plasma-sb-utils';
6
6
 
7
- import { toastConfig } from '../../../../components/Toast';
8
- import { mergeConfig } from '../../../../engines';
9
- import { WithTheme, argTypesFromConfig } from '../../../_helpers';
7
+ import { WithTheme } from '../../../_helpers';
10
8
  import { Button } from '../Button/Button';
11
9
  import { PopupProvider } from '../Popup/Popup';
12
10
  import { addNotification } from '../../../../../src/components/Notification';
13
11
  import { NotificationsProvider } from '../Notification/Notification';
14
12
  import { Modal } from '../Modal/Modal';
15
13
 
16
- import { config } from './Toast.config';
17
14
  import { Toast, ToastController, ToastProvider, useToast } from './Toast';
18
15
 
16
+ const views = ['default', 'positive', 'negative'];
17
+ const closeIconTypes = ['default', 'thin'];
18
+
19
19
  const meta: Meta<typeof ToastController> = {
20
20
  title: 'web/Overlay/Toast',
21
21
  decorators: [WithTheme],
22
+ argTypes: {
23
+ view: {
24
+ options: views,
25
+ control: {
26
+ type: 'select',
27
+ },
28
+ },
29
+ closeIconType: {
30
+ options: closeIconTypes,
31
+ control: {
32
+ type: 'select',
33
+ },
34
+ },
35
+ textColor: {
36
+ control: 'color',
37
+ },
38
+ ...disableProps(['size']),
39
+ },
22
40
  };
23
41
 
24
42
  export default meta;
@@ -49,7 +67,6 @@ const StyledWrapper = styled.div`
49
67
  `;
50
68
 
51
69
  const ToastContainer = styled.div`
52
- position: fixed;
53
70
  transform: translateX(50%);
54
71
  `;
55
72
 
@@ -61,6 +78,7 @@ const Container = styled.div`
61
78
  export const ToastComponent: StoryComponent = {
62
79
  args: {
63
80
  text: 'Текст всплывающего уведомления',
81
+ textColor: undefined,
64
82
  view: 'default',
65
83
  closeIconType: 'default',
66
84
  size: 'm',
@@ -68,14 +86,6 @@ export const ToastComponent: StoryComponent = {
68
86
  enableContentLeft: true,
69
87
  pilled: false,
70
88
  },
71
- argTypes: {
72
- closeIconType: {
73
- options: ['default', 'thin'],
74
- control: {
75
- type: 'select',
76
- },
77
- },
78
- },
79
89
  render: ({ enableContentLeft, ...args }) => (
80
90
  <ToastContainer>
81
91
  <Toast contentLeft={enableContentLeft && <BellIcon width="1rem" height="1rem" />} {...args} />
@@ -94,6 +104,8 @@ const StoryLiveDemo = ({
94
104
  size,
95
105
  hasClose,
96
106
  enableContentLeft,
107
+ closeIconType,
108
+ textColor,
97
109
  }: StoryProps) => {
98
110
  const { showToast, hideToast } = useToast();
99
111
  const contentLeft = enableContentLeft && <BellIcon width="1rem" height="1rem" />;
@@ -114,6 +126,8 @@ const StoryLiveDemo = ({
114
126
  view,
115
127
  size,
116
128
  hasClose,
129
+ closeIconType,
130
+ textColor,
117
131
  onHide: action('onHide'),
118
132
  onShow: action('onShow'),
119
133
  });
@@ -141,7 +155,6 @@ export const LiveDemo: Story = {
141
155
  type: 'inline-radio',
142
156
  },
143
157
  },
144
- ...argTypesFromConfig(mergeConfig(toastConfig, config)),
145
158
  ...disableProps(['role', 'onShow', 'onHide', 'contentLeft']),
146
159
  },
147
160
  parameters: {
@@ -167,6 +180,8 @@ const StoryComplex = ({
167
180
  size,
168
181
  hasClose,
169
182
  enableContentLeft,
183
+ closeIconType,
184
+ textColor,
170
185
  }: StoryProps) => {
171
186
  const [isModalOpen, setIsModalOpen] = useState(false);
172
187
 
@@ -185,6 +200,8 @@ const StoryComplex = ({
185
200
  view,
186
201
  size,
187
202
  hasClose,
203
+ closeIconType,
204
+ textColor,
188
205
  onHide: action('onHide'),
189
206
  onShow: action('onShow'),
190
207
  });
@@ -395,7 +395,7 @@ export var textFieldRoot = function textFieldRoot(Root) {
395
395
  ref: inputForkRef,
396
396
  id: innerId,
397
397
  value: outerValue,
398
- required: enumerationType === 'chip' ? chips.length === 0 && required : required,
398
+ required: required,
399
399
  "aria-labelledby": labelId,
400
400
  "aria-describedby": helperTextId,
401
401
  placeholder: innerPlaceholderValue,
@@ -1,5 +1,5 @@
1
1
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
- var _excluded = ["role", "width", "text", "hasClose", "contentLeft", "view", "size", "pilled", "className", "style", "closeIconType", "onCloseButtonClick"];
2
+ var _excluded = ["role", "width", "text", "hasClose", "contentLeft", "view", "size", "pilled", "className", "style", "closeIconType", "onCloseButtonClick", "textColor"];
3
3
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
4
4
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
5
5
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
@@ -35,6 +35,7 @@ export var toastRoot = function toastRoot(Root) {
35
35
  style = props.style,
36
36
  closeIconType = props.closeIconType,
37
37
  onCloseButtonClick = props.onCloseButtonClick,
38
+ textColor = props.textColor,
38
39
  rest = _objectWithoutProperties(props, _excluded);
39
40
  var pilledClass = pilled ? classes.toastPilled : undefined;
40
41
  var fixedWidth = !Number.isNaN(Number(width)) ? "".concat(width, "%") : width;
@@ -58,7 +59,9 @@ export var toastRoot = function toastRoot(Root) {
58
59
  role: role,
59
60
  "aria-live": ariaLive,
60
61
  "aria-atomic": ariaAtomic
61
- }, rest), contentLeft && /*#__PURE__*/React.createElement(StyledContentLeft, null, contentLeft), /*#__PURE__*/React.createElement(StyledContent, null, text), hasClose && /*#__PURE__*/React.createElement(CloseIconWrapper, {
62
+ }, rest), contentLeft && /*#__PURE__*/React.createElement(StyledContentLeft, null, contentLeft), /*#__PURE__*/React.createElement(StyledContent, {
63
+ textColor: textColor
64
+ }, text), hasClose && /*#__PURE__*/React.createElement(CloseIconWrapper, {
62
65
  view: "clear",
63
66
  size: "s",
64
67
  onClick: onCloseButtonClick,
@@ -34,7 +34,10 @@ export var StyledOverlay = /*#__PURE__*/styled(Overlay).withConfig({
34
34
  })(["&&.", "{animation:0.3s showFadeAnimation ease-out forwards;}&&.", "{animation:0.3s hideFadeAnimation ease-out forwards;}@keyframes showFadeAnimation{0%{opacity:0;}100%{opacity:1;}}@keyframes hideFadeAnimation{0%{opacity:1;}100%{opacity:0;}}"], /*#__PURE__*/String(classes.toastFadeShowed), /*#__PURE__*/String(classes.toastFadeHidden));
35
35
  export var StyledContentLeft = /*#__PURE__*/styled.div.withConfig({
36
36
  componentId: "plasma-new-hope__sc-19l9ekl-3"
37
- })(["display:flex;--plasma_private-left-content-margin:var(", ");margin:var(--plasma_private-left-content-margin);"], tokens.leftContentMargin);
37
+ })(["display:flex;--plasma_private-content-left-margin:var(", ");margin:var(--plasma_private-content-left-margin);color:var(", ");"], tokens.contentLeftMargin, tokens.contentLeftColor);
38
38
  export var StyledContent = /*#__PURE__*/styled.div.withConfig({
39
39
  componentId: "plasma-new-hope__sc-19l9ekl-4"
40
- })([""]);
40
+ })(["color:", ";"], function (_ref5) {
41
+ var textColor = _ref5.textColor;
42
+ return textColor || 'currentColor';
43
+ });
@@ -104,6 +104,10 @@ export interface ShowToastArgs {
104
104
  * Время отображения подсказки. Если не передать значение, подсказка будет отображаться пока ее не закроют.
105
105
  */
106
106
  timeout?: number;
107
+ /**
108
+ * Цвет текста (по умолчанию берётся цвет из view)
109
+ */
110
+ textColor?: string;
107
111
  /**
108
112
  * callback срабатывающий в момент события hideToast
109
113
  */
@@ -117,9 +121,11 @@ export interface ShowToastArgs {
117
121
 
118
122
  ## Пример использования
119
123
 
124
+ Для изменения цветовой темы компонента `Toast` используйте свойство `view` компонента `ViewContainer`.
125
+
120
126
  ```jsx live
121
127
  import React from 'react'
122
- import { useToast, ToastProvider, Button } from '@salutejs/{{ package }}'
128
+ import { useToast, ToastProvider, Button, ViewContainer } from '@salutejs/{{ package }}'
123
129
 
124
130
  export function App() {
125
131
 
@@ -130,12 +136,13 @@ export function App() {
130
136
  const onHide = () => {}
131
137
  const toastData = {
132
138
  text: 'Подсказка вызванная showToast',
139
+ textColor: 'cyan',
133
140
  position: 'bottom',
134
141
  role: 'status',
135
142
  hasClose: true,
136
143
  fade: false,
137
144
  size: 'm',
138
- view: 'dark',
145
+ view: 'default',
139
146
  timeout: 3000,
140
147
  onShow,
141
148
  onHide
@@ -145,9 +152,19 @@ export function App() {
145
152
  }
146
153
 
147
154
  return (
148
- <ToastProvider>
149
- <ToastExample />
150
- </ToastProvider>
155
+ <div style=\{{ display: 'flex', gap: '1rem' }}>
156
+ <ViewContainer view="onLight">
157
+ <ToastProvider>
158
+ <ToastExample />
159
+ </ToastProvider>
160
+ </ViewContainer>
161
+
162
+ <ViewContainer view="onDark">
163
+ <ToastProvider>
164
+ <ToastExample />
165
+ </ToastProvider>
166
+ </ViewContainer>
167
+ </div>
151
168
  )
152
169
  }
153
170
  ```
@@ -19,7 +19,8 @@ export var tokens = {
19
19
  letterSpacing: '--plasma-toast-letter-spacing',
20
20
  lineHeight: '--plasma-toast-lineheight',
21
21
  pilledBorderRadius: '--plasma-toast-pilled-border-radius',
22
- leftContentMargin: '--plasma-toast-left-content-margin',
22
+ contentLeftMargin: '--plasma-toast-content-left-margin',
23
+ contentLeftColor: '--plasma-toast-content-left-color',
23
24
  closeIconMargin: '--plasma-toast-close-icon-margin',
24
25
  closeIconColor: '--plasma-toast-close-icon-color',
25
26
  closeIconColorOnHover: '--plasma-toast-close-icon-color-on-hover',
@@ -7,7 +7,7 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
7
7
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
8
8
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
9
9
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
10
- import React, { useEffect } from 'react';
10
+ import React from 'react';
11
11
  import { classes } from './Toast.tokens';
12
12
  import { StyledOverlay, StyledRoot } from './Toast.styles';
13
13
  import { useToastInner } from './ToastProvider';
@@ -22,9 +22,7 @@ export var ToastControllerHoc = function ToastControllerHoc(ToastComponent) {
22
22
  rest = _objectWithoutProperties(props, _excluded);
23
23
  var _useToastInner = useToastInner(),
24
24
  hideToast = _useToastInner.hideToast,
25
- isVisible = _useToastInner.isVisible,
26
- hideTimeout = _useToastInner.hideTimeout,
27
- animationRunTimeout = _useToastInner.animationRunTimeout;
25
+ isVisible = _useToastInner.isVisible;
28
26
  var toastKey = "".concat(text).concat(position);
29
27
  var showedClass = isVisible ? classes.toastShowed : classes.toastHidden;
30
28
  var showedFadeClass = isVisible ? classes.toastFadeShowed : classes.toastFadeHidden;
@@ -32,16 +30,6 @@ export var ToastControllerHoc = function ToastControllerHoc(ToastComponent) {
32
30
  text: text,
33
31
  onCloseButtonClick: hideToast
34
32
  }, rest);
35
- useEffect(function () {
36
- return function () {
37
- if (hideTimeout !== null && hideTimeout !== void 0 && hideTimeout.current) {
38
- clearTimeout(hideTimeout.current);
39
- }
40
- if (animationRunTimeout !== null && animationRunTimeout !== void 0 && animationRunTimeout.current) {
41
- clearTimeout(animationRunTimeout.current);
42
- }
43
- };
44
- }, []);
45
33
  if (!text) {
46
34
  return null;
47
35
  }
@@ -6,7 +6,7 @@ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" !=
6
6
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
7
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
8
8
  import React, { createContext, useCallback, useContext, useEffect, useRef, useState } from 'react';
9
- import { DEFAULT_FADE, DEFAULT_POSITION, TIMER_DELAY } from '../utils';
9
+ import { DEFAULT_CLOSE_ICON_TYPE, DEFAULT_FADE, DEFAULT_POSITION, TIMER_DELAY } from '../utils';
10
10
  export var ToastContext = /*#__PURE__*/createContext(null);
11
11
  export var useToastInner = function useToastInner() {
12
12
  var context = useContext(ToastContext);
@@ -118,6 +118,9 @@ export var ToastProviderHoc = function ToastProviderHoc(ToastComponent) {
118
118
  size = _getShowToastCallSign.size,
119
119
  view = _getShowToastCallSign.view,
120
120
  width = _getShowToastCallSign.width,
121
+ _getShowToastCallSign4 = _getShowToastCallSign.closeIconType,
122
+ closeIconType = _getShowToastCallSign4 === void 0 ? DEFAULT_CLOSE_ICON_TYPE : _getShowToastCallSign4,
123
+ textColor = _getShowToastCallSign.textColor,
121
124
  onHide = _getShowToastCallSign.onHide,
122
125
  onShow = _getShowToastCallSign.onShow;
123
126
  setToastProps({
@@ -131,7 +134,9 @@ export var ToastProviderHoc = function ToastProviderHoc(ToastComponent) {
131
134
  pilled: pilled,
132
135
  hasClose: hasClose,
133
136
  size: size,
134
- view: view
137
+ view: view,
138
+ closeIconType: closeIconType,
139
+ textColor: textColor
135
140
  });
136
141
  setToastInfo({
137
142
  timeout: timeout,
@@ -145,13 +150,13 @@ export var ToastProviderHoc = function ToastProviderHoc(ToastComponent) {
145
150
  var onHide = toastInfo.onHide,
146
151
  timeout = toastInfo.timeout;
147
152
  var hideToast = useCallback(function () {
148
- if (!isVisible) {
149
- return;
150
- }
151
153
  if (hideTimeout !== null && hideTimeout !== void 0 && hideTimeout.current) {
152
154
  clearTimeout(hideTimeout.current);
153
155
  hideTimeout.current = null;
154
156
  }
157
+ if (!isVisible) {
158
+ return;
159
+ }
155
160
  onHide === null || onHide === void 0 || onHide();
156
161
  setIsVisible(false);
157
162
  animationRunTimeout.current = setTimeout(function () {
@@ -164,13 +169,26 @@ export var ToastProviderHoc = function ToastProviderHoc(ToastComponent) {
164
169
  clearTimeout(animationRunTimeout.current);
165
170
  animationRunTimeout.current = null;
166
171
  }
172
+ return function () {
173
+ if (animationRunTimeout !== null && animationRunTimeout !== void 0 && animationRunTimeout.current) {
174
+ clearTimeout(animationRunTimeout.current);
175
+ }
176
+ };
167
177
  }, [timeout]);
178
+
179
+ // очистка таймаутов перенесена из ToastController, т. к. в StrictМоde react делает дополнительный unmount
168
180
  useEffect(function () {
169
181
  if (timeout && isVisible) {
170
182
  hideTimeout.current = setTimeout(function () {
171
183
  hideToast();
172
184
  }, timeout);
173
185
  }
186
+ return function () {
187
+ if (hideTimeout !== null && hideTimeout !== void 0 && hideTimeout.current) {
188
+ clearTimeout(hideTimeout.current);
189
+ hideTimeout.current = null;
190
+ }
191
+ };
174
192
  }, [isVisible, timeout]);
175
193
  return /*#__PURE__*/React.createElement(ToastContext.Provider, {
176
194
  value: {
@@ -2,6 +2,7 @@ import { buttonConfig } from '../Button';
2
2
  import { component, mergeConfig } from '../../engines';
3
3
  export var DEFAULT_FADE = true;
4
4
  export var DEFAULT_POSITION = 'bottom';
5
+ export var DEFAULT_CLOSE_ICON_TYPE = 'default';
5
6
  export var TIMER_DELAY = 300;
6
7
  export var FADE_Z_INDEX = '9900';
7
8
  export var TOAST_Z_INDEX = '9901';
@@ -1,3 +1,3 @@
1
1
  import { css } from 'styled-components';
2
2
  import { classes, tokens } from '../../Toast.tokens';
3
- export var base = /*#__PURE__*/css(["&.", "{--plasma_private-left-content-margin:var(", ");--plasma_private-close-icon-margin:var(", ");border-radius:var(", ");}"], /*#__PURE__*/String(classes.toastPilled), tokens.leftContentMargin, tokens.closeIconMargin, tokens.pilledBorderRadius);
3
+ export var base = /*#__PURE__*/css(["&.", "{--plasma_private-content-left-margin:var(", ");--plasma_private-close-icon-margin:var(", ");border-radius:var(", ");}"], /*#__PURE__*/String(classes.toastPilled), tokens.contentLeftMargin, tokens.closeIconMargin, tokens.pilledBorderRadius);
@@ -9,14 +9,24 @@ export var config = {
9
9
  variations: {
10
10
  view: {
11
11
  "default": /*#__PURE__*/css(["", ":var(--text-primary);", ":var(--surface-solid-card-brightness);", ":var(--text-secondary);", ":var(--text-secondary);"], toastTokens.color, toastTokens.background, toastTokens.closeIconColor, toastTokens.closeIconColorOnHover),
12
+ positive: /*#__PURE__*/css(["", ":var(--text-primary);", ":var(--surface-solid-card-brightness);", ":var(--text-positive);", ":var(--text-secondary);", ":var(--text-secondary);"], toastTokens.color, toastTokens.background, toastTokens.contentLeftColor, toastTokens.closeIconColor, toastTokens.closeIconColorOnHover),
13
+ negative: /*#__PURE__*/css(["", ":var(--text-primary);", ":var(--surface-solid-card-brightness);", ":var(--text-negative);", ":var(--text-secondary);", ":var(--text-secondary);"], toastTokens.color, toastTokens.background, toastTokens.contentLeftColor, toastTokens.closeIconColor, toastTokens.closeIconColorOnHover),
14
+ /**
15
+ * @deprecated
16
+ * светлый и темный фон регулировать через `view` компонента `ViewContainer`
17
+ */
12
18
  dark: /*#__PURE__*/css(["", ":var(--on-dark-text-primary);", ":var(--on-dark-surface-solid-primary-brightness);", ":var(--on-dark-text-secondary);", ":var(--on-dark-text-secondary);"], toastTokens.color, toastTokens.background, toastTokens.closeIconColor, toastTokens.closeIconColorOnHover),
19
+ /**
20
+ * @deprecated
21
+ * светлый и темный фон регулировать через `view` компонента `ViewContainer`
22
+ */
13
23
  light: /*#__PURE__*/css(["", ":var(--on-light-text-primary);", ":var(--on-light-surface-solid-primary-brightness);", ":var(--on-light-text-secondary);", ":var(--on-light-text-secondary);"], toastTokens.color, toastTokens.background, toastTokens.closeIconColor, toastTokens.closeIconColorOnHover)
14
24
  },
15
25
  size: {
16
- m: /*#__PURE__*/css(["", ":0.75rem;", ":calc(100vw - 5rem);", ":0.5625rem 0.75rem;", ":var(--plasma-typo-body-xs-font-family);", ":var(--plasma-typo-body-xs-font-size);", ":var(--plasma-typo-body-xs-font-style);", ":var(--plasma-typo-body-xs-font-weight);", ":var(--plasma-typo-body-xs-letter-spacing);", ":var(--plasma-typo-body-xs-line-height);", ":-0.0625rem 0.375rem -0.0625rem -0.125rem;", ":-0.0625rem -0.25rem -0.0625rem 0.5rem;"], toastTokens.borderRadius, toastTokens.maxWidth, toastTokens.padding, toastTokens.fontFamily, toastTokens.fontSize, toastTokens.fontStyle, toastTokens.fontWeight, toastTokens.letterSpacing, toastTokens.lineHeight, toastTokens.leftContentMargin, toastTokens.closeIconMargin)
26
+ m: /*#__PURE__*/css(["", ":0.75rem;", ":calc(100vw - 5rem);", ":0.5625rem 0.75rem;", ":var(--plasma-typo-body-xs-font-family);", ":var(--plasma-typo-body-xs-font-size);", ":var(--plasma-typo-body-xs-font-style);", ":var(--plasma-typo-body-xs-font-weight);", ":var(--plasma-typo-body-xs-letter-spacing);", ":var(--plasma-typo-body-xs-line-height);", ":-0.0625rem 0.375rem -0.0625rem -0.125rem;", ":-0.0625rem -0.25rem -0.0625rem 0.5rem;"], toastTokens.borderRadius, toastTokens.maxWidth, toastTokens.padding, toastTokens.fontFamily, toastTokens.fontSize, toastTokens.fontStyle, toastTokens.fontWeight, toastTokens.letterSpacing, toastTokens.lineHeight, toastTokens.contentLeftMargin, toastTokens.closeIconMargin)
17
27
  },
18
28
  pilled: {
19
- "true": /*#__PURE__*/css(["", ":1.5rem;", ":-0.0625rem 0.375rem -0.0625rem -0.25rem;", ":-0.0625rem -0.25rem -0.0625rem 0.375rem;"], toastTokens.pilledBorderRadius, toastTokens.leftContentMargin, toastTokens.closeIconMargin)
29
+ "true": /*#__PURE__*/css(["", ":1.5rem;", ":-0.0625rem 0.375rem -0.0625rem -0.25rem;", ":-0.0625rem -0.25rem -0.0625rem 0.375rem;"], toastTokens.pilledBorderRadius, toastTokens.contentLeftMargin, toastTokens.closeIconMargin)
20
30
  },
21
31
  closeIconType: {
22
32
  "default": /*#__PURE__*/css(["", ":1rem;", ":1.5rem;"], toastTokens.closeIconButtonSize, toastTokens.closeIconSize),