@salutejs/plasma-new-hope 0.194.0-canary.1565.11870784206.0 → 0.194.0-canary.1568.11891833298.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (162) hide show
  1. package/cjs/components/Switch/Switch.css +2 -2
  2. package/cjs/components/Switch/Switch.tokens.js +7 -1
  3. package/cjs/components/Switch/Switch.tokens.js.map +1 -1
  4. package/cjs/components/Switch/_toggleSize/base.js +1 -1
  5. package/cjs/components/Switch/_toggleSize/base.js.map +1 -1
  6. package/cjs/components/Switch/_toggleSize/base_1d0b3t4.css +1 -0
  7. package/cjs/components/Switch/_view/base.js +1 -1
  8. package/cjs/components/Switch/_view/base.js.map +1 -1
  9. package/cjs/components/Switch/_view/base_15atbyp.css +1 -0
  10. package/cjs/components/TextField/TextField.js +3 -27
  11. package/cjs/components/TextField/TextField.js.map +1 -1
  12. package/cjs/index.css +2 -2
  13. package/cjs/utils/constants.js +0 -4
  14. package/cjs/utils/constants.js.map +1 -1
  15. package/emotion/cjs/components/Card/Card.api.mdx +184 -0
  16. package/emotion/cjs/components/Switch/Switch.tokens.js +7 -1
  17. package/emotion/cjs/components/Switch/_toggleSize/base.js +1 -1
  18. package/emotion/cjs/components/Switch/_view/base.js +1 -1
  19. package/emotion/cjs/components/TextField/TextField.js +4 -27
  20. package/emotion/cjs/components/TextField/TextField.template-doc.mdx +0 -330
  21. package/emotion/cjs/components/TextField/hooks/index.js +1 -8
  22. package/emotion/cjs/examples/plasma_b2c/components/Switch/Switch.config.js +8 -8
  23. package/emotion/cjs/examples/plasma_b2c/components/Switch/Switch.js +5 -2
  24. package/emotion/cjs/examples/plasma_b2c/components/Switch/Switch.outline.config.js +37 -0
  25. package/emotion/cjs/examples/plasma_b2c/components/Switch/Switch.stories.tsx +33 -1
  26. package/emotion/cjs/examples/plasma_b2c/components/TextField/TextField.stories.tsx +1 -253
  27. package/emotion/cjs/examples/plasma_web/components/Switch/Switch.config.js +8 -8
  28. package/emotion/cjs/examples/plasma_web/components/Switch/Switch.js +5 -2
  29. package/emotion/cjs/examples/plasma_web/components/Switch/Switch.outline.config.js +37 -0
  30. package/emotion/cjs/examples/plasma_web/components/Switch/Switch.stories.tsx +33 -1
  31. package/emotion/cjs/examples/plasma_web/components/TextField/TextField.stories.tsx +0 -252
  32. package/emotion/cjs/utils/constants.js +2 -4
  33. package/emotion/es/components/Card/Card.api.mdx +184 -0
  34. package/emotion/es/components/Switch/Switch.tokens.js +7 -1
  35. package/emotion/es/components/Switch/_toggleSize/base.js +1 -1
  36. package/emotion/es/components/Switch/_view/base.js +1 -1
  37. package/emotion/es/components/TextField/TextField.js +5 -28
  38. package/emotion/es/components/TextField/TextField.template-doc.mdx +0 -330
  39. package/emotion/es/components/TextField/hooks/index.js +1 -2
  40. package/emotion/es/examples/plasma_b2c/components/Switch/Switch.config.js +8 -8
  41. package/emotion/es/examples/plasma_b2c/components/Switch/Switch.js +4 -1
  42. package/emotion/es/examples/plasma_b2c/components/Switch/Switch.outline.config.js +31 -0
  43. package/emotion/es/examples/plasma_b2c/components/Switch/Switch.stories.tsx +33 -1
  44. package/emotion/es/examples/plasma_b2c/components/TextField/TextField.stories.tsx +1 -253
  45. package/emotion/es/examples/plasma_web/components/Switch/Switch.config.js +8 -8
  46. package/emotion/es/examples/plasma_web/components/Switch/Switch.js +4 -1
  47. package/emotion/es/examples/plasma_web/components/Switch/Switch.outline.config.js +31 -0
  48. package/emotion/es/examples/plasma_web/components/Switch/Switch.stories.tsx +33 -1
  49. package/emotion/es/examples/plasma_web/components/TextField/TextField.stories.tsx +0 -252
  50. package/emotion/es/utils/constants.js +1 -3
  51. package/es/components/Switch/Switch.css +2 -2
  52. package/es/components/Switch/Switch.tokens.js +7 -1
  53. package/es/components/Switch/Switch.tokens.js.map +1 -1
  54. package/es/components/Switch/_toggleSize/base.js +1 -1
  55. package/es/components/Switch/_toggleSize/base.js.map +1 -1
  56. package/es/components/Switch/_toggleSize/base_1d0b3t4.css +1 -0
  57. package/es/components/Switch/_view/base.js +1 -1
  58. package/es/components/Switch/_view/base.js.map +1 -1
  59. package/es/components/Switch/_view/base_15atbyp.css +1 -0
  60. package/es/components/TextField/TextField.js +3 -27
  61. package/es/components/TextField/TextField.js.map +1 -1
  62. package/es/index.css +2 -2
  63. package/es/utils/constants.js +1 -3
  64. package/es/utils/constants.js.map +1 -1
  65. package/package.json +2 -2
  66. package/styled-components/cjs/components/Card/Card.api.mdx +184 -0
  67. package/styled-components/cjs/components/Switch/Switch.tokens.js +7 -1
  68. package/styled-components/cjs/components/Switch/_toggleSize/base.js +1 -1
  69. package/styled-components/cjs/components/Switch/_view/base.js +1 -1
  70. package/styled-components/cjs/components/TextField/TextField.js +3 -26
  71. package/styled-components/cjs/components/TextField/TextField.template-doc.mdx +0 -330
  72. package/styled-components/cjs/components/TextField/hooks/index.js +1 -8
  73. package/styled-components/cjs/examples/plasma_b2c/components/Switch/Switch.config.js +1 -1
  74. package/styled-components/cjs/examples/plasma_b2c/components/Switch/Switch.js +5 -2
  75. package/styled-components/cjs/examples/plasma_b2c/components/Switch/Switch.outline.config.js +37 -0
  76. package/styled-components/cjs/examples/plasma_b2c/components/Switch/Switch.stories.tsx +33 -1
  77. package/styled-components/cjs/examples/plasma_b2c/components/TextField/TextField.stories.tsx +1 -253
  78. package/styled-components/cjs/examples/plasma_web/components/Switch/Switch.config.js +1 -1
  79. package/styled-components/cjs/examples/plasma_web/components/Switch/Switch.js +5 -2
  80. package/styled-components/cjs/examples/plasma_web/components/Switch/Switch.outline.config.js +37 -0
  81. package/styled-components/cjs/examples/plasma_web/components/Switch/Switch.stories.tsx +33 -1
  82. package/styled-components/cjs/examples/plasma_web/components/TextField/TextField.stories.tsx +0 -252
  83. package/styled-components/cjs/utils/constants.js +2 -4
  84. package/styled-components/es/components/Card/Card.api.mdx +184 -0
  85. package/styled-components/es/components/Switch/Switch.tokens.js +7 -1
  86. package/styled-components/es/components/Switch/_toggleSize/base.js +1 -1
  87. package/styled-components/es/components/Switch/_view/base.js +1 -1
  88. package/styled-components/es/components/TextField/TextField.js +4 -27
  89. package/styled-components/es/components/TextField/TextField.template-doc.mdx +0 -330
  90. package/styled-components/es/components/TextField/hooks/index.js +1 -2
  91. package/styled-components/es/examples/plasma_b2c/components/Switch/Switch.config.js +1 -1
  92. package/styled-components/es/examples/plasma_b2c/components/Switch/Switch.js +4 -1
  93. package/styled-components/es/examples/plasma_b2c/components/Switch/Switch.outline.config.js +31 -0
  94. package/styled-components/es/examples/plasma_b2c/components/Switch/Switch.stories.tsx +33 -1
  95. package/styled-components/es/examples/plasma_b2c/components/TextField/TextField.stories.tsx +1 -253
  96. package/styled-components/es/examples/plasma_web/components/Switch/Switch.config.js +1 -1
  97. package/styled-components/es/examples/plasma_web/components/Switch/Switch.js +4 -1
  98. package/styled-components/es/examples/plasma_web/components/Switch/Switch.outline.config.js +31 -0
  99. package/styled-components/es/examples/plasma_web/components/Switch/Switch.stories.tsx +33 -1
  100. package/styled-components/es/examples/plasma_web/components/TextField/TextField.stories.tsx +0 -252
  101. package/styled-components/es/utils/constants.js +1 -3
  102. package/types/components/Autocomplete/Autocomplete.types.d.ts +2 -2
  103. package/types/components/Autocomplete/Autocomplete.types.d.ts.map +1 -1
  104. package/types/components/Autocomplete/ui/TextField/TextField.styles.d.ts +92 -1676
  105. package/types/components/Autocomplete/ui/TextField/TextField.styles.d.ts.map +1 -1
  106. package/types/components/Combobox/ComboboxNew/ui/Target/Target.styles.d.ts +92 -1676
  107. package/types/components/Combobox/ComboboxNew/ui/Target/Target.styles.d.ts.map +1 -1
  108. package/types/components/DatePicker/SingleDate/SingleDate.styles.d.ts +92 -1676
  109. package/types/components/DatePicker/SingleDate/SingleDate.styles.d.ts.map +1 -1
  110. package/types/components/Range/Range.styles.d.ts +92 -1676
  111. package/types/components/Range/Range.styles.d.ts.map +1 -1
  112. package/types/components/Select/ui/Target/ui/Textfield/Textfield.styles.d.ts +92 -1676
  113. package/types/components/Select/ui/Target/ui/Textfield/Textfield.styles.d.ts.map +1 -1
  114. package/types/components/Slider/components/Double/Double.styles.d.ts +92 -1676
  115. package/types/components/Slider/components/Double/Double.styles.d.ts.map +1 -1
  116. package/types/components/Switch/Switch.tokens.d.ts +7 -1
  117. package/types/components/Switch/Switch.tokens.d.ts.map +1 -1
  118. package/types/components/Switch/_toggleSize/base.d.ts.map +1 -1
  119. package/types/components/Switch/_view/base.d.ts.map +1 -1
  120. package/types/components/TextField/TextField.d.ts.map +1 -1
  121. package/types/components/TextField/TextField.types.d.ts +1 -51
  122. package/types/components/TextField/TextField.types.d.ts.map +1 -1
  123. package/types/components/TextField/hooks/index.d.ts +0 -1
  124. package/types/components/TextField/hooks/index.d.ts.map +1 -1
  125. package/types/examples/plasma_b2c/components/Autocomplete/Autocomplete.d.ts +2 -64
  126. package/types/examples/plasma_b2c/components/Autocomplete/Autocomplete.d.ts.map +1 -1
  127. package/types/examples/plasma_b2c/components/Mask/Mask.d.ts +92 -2732
  128. package/types/examples/plasma_b2c/components/Mask/Mask.d.ts.map +1 -1
  129. package/types/examples/plasma_b2c/components/Switch/Switch.config.d.ts.map +1 -1
  130. package/types/examples/plasma_b2c/components/Switch/Switch.d.ts +20 -0
  131. package/types/examples/plasma_b2c/components/Switch/Switch.d.ts.map +1 -1
  132. package/types/examples/plasma_b2c/components/Switch/Switch.outline.config.d.ts +30 -0
  133. package/types/examples/plasma_b2c/components/Switch/Switch.outline.config.d.ts.map +1 -0
  134. package/types/examples/plasma_b2c/components/TextField/TextField.d.ts +92 -1676
  135. package/types/examples/plasma_b2c/components/TextField/TextField.d.ts.map +1 -1
  136. package/types/examples/plasma_web/components/Autocomplete/Autocomplete.d.ts +2 -64
  137. package/types/examples/plasma_web/components/Autocomplete/Autocomplete.d.ts.map +1 -1
  138. package/types/examples/plasma_web/components/Mask/Mask.d.ts +92 -2732
  139. package/types/examples/plasma_web/components/Mask/Mask.d.ts.map +1 -1
  140. package/types/examples/plasma_web/components/Switch/Switch.config.d.ts.map +1 -1
  141. package/types/examples/plasma_web/components/Switch/Switch.d.ts +20 -0
  142. package/types/examples/plasma_web/components/Switch/Switch.d.ts.map +1 -1
  143. package/types/examples/plasma_web/components/Switch/Switch.outline.config.d.ts +30 -0
  144. package/types/examples/plasma_web/components/Switch/Switch.outline.config.d.ts.map +1 -0
  145. package/types/examples/plasma_web/components/TextField/TextField.d.ts +92 -1676
  146. package/types/examples/plasma_web/components/TextField/TextField.d.ts.map +1 -1
  147. package/types/utils/constants.d.ts +0 -2
  148. package/types/utils/constants.d.ts.map +1 -1
  149. package/cjs/components/Switch/_toggleSize/base_6i0904.css +0 -1
  150. package/cjs/components/Switch/_view/base_yxkf3s.css +0 -1
  151. package/cjs/components/TextField/hooks/useValidation.js +0 -273
  152. package/cjs/components/TextField/hooks/useValidation.js.map +0 -1
  153. package/emotion/cjs/components/TextField/hooks/useValidation.js +0 -276
  154. package/emotion/es/components/TextField/hooks/useValidation.js +0 -270
  155. package/es/components/Switch/_toggleSize/base_6i0904.css +0 -1
  156. package/es/components/Switch/_view/base_yxkf3s.css +0 -1
  157. package/es/components/TextField/hooks/useValidation.js +0 -269
  158. package/es/components/TextField/hooks/useValidation.js.map +0 -1
  159. package/styled-components/cjs/components/TextField/hooks/useValidation.js +0 -276
  160. package/styled-components/es/components/TextField/hooks/useValidation.js +0 -270
  161. package/types/components/TextField/hooks/useValidation.d.ts +0 -7
  162. package/types/components/TextField/hooks/useValidation.d.ts.map +0 -1
@@ -0,0 +1,184 @@
1
+ ---
2
+ id: card
3
+ title: Card
4
+ ---
5
+
6
+ отличия от https://plasma.sberdevices.ru/b2c/components/card/:
7
+ * избавляемся от CardBody
8
+ * убираем дублирование disabled
9
+
10
+ примеры дизайна https://www.figma.com/design/MXl0ZkXEqEhIFDS2H6b3yk/StarDS-Cards?node-id=2-690&node-type=instance&t=TJN8Nqyiky3Dfw2T-0
11
+
12
+ другие либы:
13
+ https://ant.design/components/card#
14
+ https://mui.com/material-ui/react-card/
15
+
16
+ ```tsx live
17
+ import React, { ReactNode } from "react";
18
+
19
+ /**
20
+ * Набор часто встречающихся скруглений.
21
+ */
22
+
23
+ export const radiuses = {
24
+ 250: 15.625,
25
+ 32: 2,
26
+ 28: 1.75,
27
+ 24: 1.5,
28
+ 20: 1.25,
29
+ 18: 1.125,
30
+ 16: 1,
31
+ 14: 0.875,
32
+ 12: 0.75,
33
+ 8: 0.5,
34
+ 0: 0,
35
+ };
36
+
37
+ export type Roundness = keyof typeof radiuses;
38
+
39
+ export interface RoundnessProps {
40
+ /** Скругленность */
41
+ roundness: Roundness;
42
+ }
43
+
44
+ interface Card {
45
+ /** Компонент в фокусе */
46
+ focused?: boolean;
47
+ /** Увеличение по фокусу */
48
+ scaleOnFocus?: boolean;
49
+ /** Компонент неактивен */
50
+ disabled?: boolean;
51
+ /** Добавить рамку при фокусе */
52
+ outlined?: boolean;
53
+ /** Цвет подложки */
54
+ background?: string;
55
+ /** Делает карточку квадратной */
56
+ square?: boolean;
57
+ /** Заголовок */
58
+ title?: string | ReactNode;
59
+ /** Подзаголовок */
60
+ subtitle?: string | ReactNode;
61
+ /** Расположение заголовка и подзаголовка, пока нет в дизайне */
62
+ titlePlacement?: "inner" | "outer";
63
+ /** Выравнивание заголовка и подзаголовка */
64
+ titleAlign?: "left" | "center";
65
+ /** Подвал, или вынести в
66
+ * <CardContent footer={<CardTimeline />} /> или <CardFooter><CardTimeline /></CardFooter>
67
+ * */
68
+ footer?: ReactNode;
69
+ }
70
+
71
+ const ratios = {
72
+ "1 / 1": "100",
73
+ "1/1": "100",
74
+ "3 / 4": "133.3333",
75
+ "3/4": "133.3333",
76
+ "4 / 3": "75",
77
+ "4/3": "75",
78
+ "9 / 16": "177.7778",
79
+ "9/16": "177.7778",
80
+ "16 / 9": "56.25",
81
+ "16/9": "56.25",
82
+ "1 / 2": "200",
83
+ "1/2": "200",
84
+ "2 / 1": "50",
85
+ "2/1": "50",
86
+ };
87
+
88
+ export type Ratio = keyof typeof ratios;
89
+
90
+ /**
91
+ * CardMedia из текущей реализации
92
+ * Стоит ли заменить пропсом `cover?: ReactNode;` в Card как в Ant?
93
+ * а width и height передавать в style...
94
+ *
95
+ * имхо, нет. у Card может быть title и subtitle под карточкой
96
+ * скорее всего, на них свойство height не должно распространяться
97
+ * стоит подождать финальный дизайн
98
+ */
99
+ interface CardMedia {
100
+ base?: "img" | "div";
101
+ height?: string | number;
102
+ ratio?: Ratio;
103
+ customRatio?: string;
104
+ }
105
+
106
+ interface CardContent {
107
+ topLeft?: string | ReactNode;
108
+ topRight?: string | ReactNode;
109
+ bottomLeft?: string | ReactNode;
110
+ bottomRight?: string | ReactNode;
111
+ children?: ReactNode;
112
+ }
113
+
114
+ /** или */
115
+ interface CardContent {
116
+ placement?: "top-left" | "top-right" | "bottom-left" | "bottom-right";
117
+ children?: ReactNode;
118
+ }
119
+
120
+ interface CardTimeline {
121
+ /**
122
+ * Описание, например время до конца фильма. Возможно,
123
+ * не нужно и стоит указывать bottomRight контент
124
+ */
125
+ text?: string;
126
+ progress?: string | number;
127
+ /**
128
+ * Не увеличивать высоту карточки
129
+ * @default true
130
+ */
131
+ inline?: boolean;
132
+ }
133
+ ```
134
+
135
+ ```tsx live
136
+ <Card title="Title" subtitle="Subtitle">
137
+ <CardContent placement="top-left">
138
+ <SomeIcon />
139
+ </CardContent>
140
+ <CardContent placement="top-right">
141
+ <SaveButton saved={isSaved} />
142
+ </CardContent>
143
+ <CardContent placement="bottom-right">18+</CardContent>
144
+ </Card>;
145
+
146
+ <Card title="Title" subtitle="Subtitle">
147
+ <CardContent
148
+ topLeft={<SomeIcon />}
149
+ topRight={<SaveButton saved={isSaved} />}
150
+ bottomRight="18+"
151
+ />
152
+ </Card>;
153
+
154
+ <Card title="Title" subtitle="Subtitle">
155
+ <CardMedia src={someSrc} alt="trailer" />
156
+ <CardContent
157
+ topLeft={<SomeIcon />}
158
+ topRight={<SaveButton saved={isSaved} />}
159
+ bottomRight="18+"
160
+ />
161
+ <CardTimeline text="еще 1ч 23мин" progress={56} />
162
+ </Card>;
163
+
164
+ <Card title="Title" subtitle="Subtitle">
165
+ <CardContent topLeft={<SomeIcon />} topRight={<SaveButton saved={isSaved} />}>
166
+ <CardMedia src={someSrc} alt="trailer" />
167
+ </CardContent>
168
+ <CardTimeline text="еще 1ч 23мин" progress={56} />
169
+ </Card>;
170
+
171
+ <Card
172
+ title="Title"
173
+ subtitle="Subtitle"
174
+ // как в ant, но кажется, что так менее гибко
175
+ cover={<CardMedia src={someSrc} alt="trailer" />}
176
+ square
177
+ >
178
+ <CardContent
179
+ topLeft={<SomeIcon />}
180
+ topRight={<SaveButton saved={isSaved} />}
181
+ />
182
+ <CardTimeline text="еще 1ч 23мин" progress={56} />
183
+ </Card>;
184
+ ```
@@ -23,6 +23,11 @@ export var tokens = {
23
23
  verticalGap: '--plasma-switch-vertical-gap',
24
24
  trackWidth: '--plasma-switch__track-width',
25
25
  trackHeight: '--plasma-switch__track-height',
26
+ trackBorderWidth: '--plasma-switch__track-border',
27
+ trackBorderColorOn: '--plasma-switch__track-checked_true-border-color',
28
+ trackBorderColorOnHover: '--plasma-switch__track-checked_true_hovered_true-border-color',
29
+ trackBorderColorOff: '--plasma-switch__track-checked_false-border-color',
30
+ trackBorderColorOffHover: '--plasma-switch__track-checked_false_hovered_true-border-color',
26
31
  trackBorderRadius: '--plasma-switch__track-border-radius',
27
32
  // NOTE: could be intersection with checked
28
33
  trackBackgroundColorOn: '--plasma-switch__track_checked_true-bg-color',
@@ -34,7 +39,8 @@ export var tokens = {
34
39
  thumbOffset: '--plasma-switch__thumb-offset',
35
40
  thumbBorderRadius: '--plasma-switch__thumb-border-radius',
36
41
  thumbPressScale: '--plasma-switch__thumb-scale',
37
- thumbBackgroundColor: '--plasma-switch__thumb-bg-color',
42
+ thumbBackgroundColorOn: '--plasma-switch__thumb_checked_true-bg-color',
43
+ thumbBackgroundColorOff: '--plasma-switch__thumb-checked_false-bg-color',
38
44
  thumbBoxShadow: '--plasma-switch__thumb-box-shadow',
39
45
  thumbBoxShadowOn: '--plasma-switch__thumb-box-shadow_checked_true',
40
46
  labelOffsetPrivate: '--plasma_private-switch__label-offset'
@@ -1,4 +1,4 @@
1
1
  import { css } from 'styled-components';
2
2
  import { tokens } from '../Switch.tokens';
3
3
  import { StyledTrigger } from '../Switch.styles';
4
- export var base = /*#__PURE__*/css(["", "{flex:0 0 var(", ");width:var(", ");height:var(", ");border-radius:var(", ");&::after{width:var(", ");height:var(", ");border-radius:var(", ");margin:auto var(", ");}}:active:not([disabled]) ", "::after{width:calc(var(", ") * var(", ",1));}"], StyledTrigger, tokens.trackWidth, tokens.trackWidth, tokens.trackHeight, tokens.trackBorderRadius, tokens.thumbSize, tokens.thumbSize, tokens.thumbBorderRadius, tokens.thumbOffset, StyledTrigger, tokens.thumbSize, tokens.thumbPressScale);
4
+ export var base = /*#__PURE__*/css(["", "{box-sizing:border-box;flex:0 0 var(", ");border-style:solid;border-width:var(", ");border-radius:var(", ");width:var(", ");height:var(", ");&::after{width:var(", ");height:var(", ");border-radius:var(", ");margin:auto var(", ");}}:active:not([disabled]) ", "::after{width:calc(var(", ") * var(", ",1));}"], StyledTrigger, tokens.trackWidth, tokens.trackBorderWidth, tokens.trackBorderRadius, tokens.trackWidth, tokens.trackHeight, tokens.thumbSize, tokens.thumbSize, tokens.thumbBorderRadius, tokens.thumbOffset, StyledTrigger, tokens.thumbSize, tokens.thumbPressScale);
@@ -1,4 +1,4 @@
1
1
  import { css } from 'styled-components';
2
2
  import { tokens } from '../Switch.tokens';
3
3
  import { StyledTrigger, StyledInput, StyledLabel, StyledDescription } from '../Switch.styles';
4
- export var base = /*#__PURE__*/css(["", "{background-color:var(", ");}", ":not([disabled]) ~ ", ":hover{background-color:var(", ",var(", "));}", ":checked ~ ", "{background-color:var(", ");}", ":checked:not([disabled]) ~ ", ":hover{background-color:var(", ",var(", "));}", "::after{background-color:var(", ");box-shadow:var(", ");}", ":checked ~ ", "::after{box-shadow:var(", ",var(", "));}", "{color:var(", ");}", "{color:var(", ");}"], StyledTrigger, tokens.trackBackgroundColorOff, StyledInput, StyledTrigger, tokens.trackBackgroundColorOffHover, tokens.trackBackgroundColorOff, StyledInput, StyledTrigger, tokens.trackBackgroundColorOn, StyledInput, StyledTrigger, tokens.trackBackgroundColorOnHover, tokens.trackBackgroundColorOn, StyledTrigger, tokens.thumbBackgroundColor, tokens.thumbBoxShadow, StyledInput, StyledTrigger, tokens.thumbBoxShadowOn, tokens.thumbBoxShadow, StyledLabel, tokens.labelColor, StyledDescription, tokens.descriptionColor);
4
+ export var base = /*#__PURE__*/css(["", "{background-color:var(", ");border-color:var(", ");}", ":not([disabled]) ~ ", ":hover{background-color:var(", ",var(", "));border-color:var(", ",var(", "));}", ":checked ~ ", "{background-color:var(", ");border-color:var(", ");}", ":checked:not([disabled]) ~ ", ":hover{background-color:var(", ",var(", "));border-color:var(", ",var(", "));}", "::after{background-color:var(", ");box-shadow:var(", ");}", ":checked ~ ", "::after{background-color:var(", ");box-shadow:var(", ",var(", "));}", "{color:var(", ");}", "{color:var(", ");}"], StyledTrigger, tokens.trackBackgroundColorOff, tokens.trackBorderColorOff, StyledInput, StyledTrigger, tokens.trackBackgroundColorOffHover, tokens.trackBackgroundColorOff, tokens.trackBorderColorOffHover, tokens.trackBorderColorOff, StyledInput, StyledTrigger, tokens.trackBackgroundColorOn, tokens.trackBorderColorOn, StyledInput, StyledTrigger, tokens.trackBackgroundColorOnHover, tokens.trackBackgroundColorOn, tokens.trackBorderColorOnHover, tokens.trackBorderColorOn, StyledTrigger, tokens.thumbBackgroundColorOff, tokens.thumbBoxShadow, StyledInput, StyledTrigger, tokens.thumbBackgroundColorOn, tokens.thumbBoxShadowOn, tokens.thumbBoxShadow, StyledLabel, tokens.labelColor, StyledDescription, tokens.descriptionColor);
@@ -1,4 +1,4 @@
1
- var _excluded = ["id", "className", "style", "contentLeft", "contentRight", "label", "labelPlacement", "textBefore", "textAfter", "placeholder", "leftHelper", "enumerationType", "requiredPlacement", "titleCaption", "hintTrigger", "hintText", "hintView", "hintSize", "hintTargetIcon", "hintPlacement", "hintHasArrow", "hintOffset", "hintWidth", "hintContentLeft", "view", "size", "readOnly", "disabled", "required", "clear", "optional", "hasDivider", "value", "chips", "validationType", "options", "passwordHidden", "onValidate", "onChange", "onBlur", "onChangeChips", "onSearch", "onKeyDown"];
1
+ var _excluded = ["id", "className", "style", "contentLeft", "contentRight", "label", "labelPlacement", "textBefore", "textAfter", "placeholder", "leftHelper", "enumerationType", "requiredPlacement", "titleCaption", "hintTrigger", "hintText", "hintView", "hintSize", "hintTargetIcon", "hintPlacement", "hintHasArrow", "hintOffset", "hintWidth", "hintContentLeft", "view", "size", "readOnly", "disabled", "required", "clear", "optional", "hasDivider", "value", "chips", "onChange", "onChangeChips", "onSearch", "onKeyDown"];
2
2
  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); }
3
3
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
4
4
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
@@ -24,7 +24,7 @@ import { base as hintSizeCSS } from './variations/_hint-size/base';
24
24
  import { Input, InputContainer, LeftHelper, Label, InputWrapper, InputLabelWrapper, StyledContentLeft, StyledContentRight, StyledChips, StyledTextBefore, StyledTextAfter, StyledIndicator, StyledOptionalText, InputPlaceholder, OuterLabelWrapper, TitleCaption, StyledHintWrapper, StyledIndicatorWrapper } from './TextField.styles';
25
25
  import { classes } from './TextField.tokens';
26
26
  import { TextFieldChip } from './ui';
27
- import { useKeyNavigation, useValidation } from './hooks';
27
+ import { useKeyNavigation } from './hooks';
28
28
  import { HintComponent } from './ui/Hint/Hint';
29
29
  var optionalText = 'optional';
30
30
  export var base = /*#__PURE__*/css(["display:block;"]);
@@ -77,12 +77,7 @@ export var textFieldRoot = function textFieldRoot(Root) {
77
77
  hasDivider = _ref.hasDivider,
78
78
  outerValue = _ref.value,
79
79
  values = _ref.chips,
80
- validationType = _ref.validationType,
81
- options = _ref.options,
82
- passwordHidden = _ref.passwordHidden,
83
- onValidate = _ref.onValidate,
84
80
  onChange = _ref.onChange,
85
- onBlur = _ref.onBlur,
86
81
  onChangeChips = _ref.onChangeChips,
87
82
  onSearch = _ref.onSearch,
88
83
  onKeyDown = _ref.onKeyDown,
@@ -132,7 +127,6 @@ export var textFieldRoot = function textFieldRoot(Root) {
132
127
  var hasValueClass = hasValue ? classes.hasValue : undefined;
133
128
  var wrapperWithoutLeftContent = !contentLeft && isChipsVisible ? classes.hasEmptyContentLeft : undefined;
134
129
  var wrapperWithoutRightContent = !contentRight && isChipsVisible ? classes.hasEmptyContentRight : undefined;
135
- var isPasswordHidden = validationType === 'password' && passwordHidden;
136
130
  var hintRef = useOutsideClick(function () {
137
131
  setIsHintVisible(false);
138
132
  });
@@ -175,13 +169,6 @@ export var textFieldRoot = function textFieldRoot(Root) {
175
169
  setChips(newChips);
176
170
  onChangeChips === null || onChangeChips === void 0 || onChangeChips(newValues);
177
171
  };
178
- var _useValidation = useValidation({
179
- validationType: validationType,
180
- options: options,
181
- onValidate: onValidate
182
- }),
183
- handleValidationBlur = _useValidation.handleValidationBlur,
184
- handleValidationKeyDown = _useValidation.handleValidationKeyDown;
185
172
  var _useKeyNavigation = useKeyNavigation({
186
173
  controlledRefs: controlledRefs,
187
174
  disabled: disabled,
@@ -211,12 +198,6 @@ export var textFieldRoot = function textFieldRoot(Root) {
211
198
  });
212
199
  inputRef.current.focus();
213
200
  };
214
- var handleInputBlur = function handleInputBlur(event) {
215
- if (onBlur) {
216
- onBlur(event);
217
- }
218
- handleValidationBlur(event);
219
- };
220
201
  var getRef = function getRef(element, index) {
221
202
  if (element && chipsRefs !== null && chipsRefs !== void 0 && chipsRefs.current) {
222
203
  chipsRefs.current[index] = element;
@@ -224,7 +205,6 @@ export var textFieldRoot = function textFieldRoot(Root) {
224
205
  };
225
206
  var handleOnKeyDown = function handleOnKeyDown(event) {
226
207
  handleInputKeydown(event);
227
- handleValidationKeyDown(event);
228
208
  if (onKeyDown) {
229
209
  onKeyDown(event);
230
210
  }
@@ -358,11 +338,8 @@ export var textFieldRoot = function textFieldRoot(Root) {
358
338
  readOnly: !disabled && readOnly,
359
339
  onInput: handleInput,
360
340
  onChange: handleChange,
361
- onKeyDown: handleOnKeyDown,
362
- onBlur: handleInputBlur
363
- }, rest, isPasswordHidden && {
364
- type: 'password'
365
- })), hasInnerLabel && /*#__PURE__*/React.createElement(Label, {
341
+ onKeyDown: handleOnKeyDown
342
+ }, rest)), hasInnerLabel && /*#__PURE__*/React.createElement(Label, {
366
343
  id: labelId,
367
344
  htmlFor: innerId
368
345
  }, innerLabelValue, optionalTextNode), placeholderShown && !hasValue && /*#__PURE__*/React.createElement(InputPlaceholder, null, innerPlaceholderValue, hasPlaceholderOptional && optionalTextNode)), textAfter && /*#__PURE__*/React.createElement(StyledTextAfter, null, textAfter)), contentRight && /*#__PURE__*/React.createElement(StyledContentRight, null, contentRight)), leftHelper && /*#__PURE__*/React.createElement(LeftHelper, {
@@ -5,9 +5,6 @@ title: TextField
5
5
 
6
6
  import { PropsTable, Description } from '@site/src/components';
7
7
 
8
- import Tabs from '@theme/Tabs';
9
- import TabItem from '@theme/TabItem';
10
-
11
8
  # TextField
12
9
  <Description name="TextField" />
13
10
  <PropsTable name="TextField" exclude={['$isFocused']} />
@@ -201,330 +198,3 @@ export function App() {
201
198
  );
202
199
  }
203
200
  ```
204
-
205
- ### Валидация
206
- Поддерживается валидация почты и пароля:
207
-
208
- <Tabs>
209
- <TabItem value="email" label="Email" default>
210
- Свойства доступные при валидации почты:
211
- ```tsx
212
- type ValidationProps = {
213
- /*
214
- * Тип валидации
215
- */
216
- validationType: 'email';
217
- /*
218
- * Опции валидации
219
- */
220
- options?: EmailValidationOptions;
221
- /*
222
- * Функция, вызываемая при валидации значения.
223
- * Вызывается при событии onBlur и по нажатию Enter, когда фокус на поле ввода
224
- */
225
- onValidate?: (args: OnValidateArgs) => void;
226
- }
227
- ```
228
- Свойство `options` имеет следующий вид:
229
- ```tsx
230
- type EmailValidationOptions = {
231
- /*
232
- * Пользовательское регулярное выражение, для проверки почты на валидность
233
- */
234
- customEmailRegex?: {
235
- value?: RegExp;
236
- errorMessage?: string;
237
- };
238
- /*
239
- * Минимальная длина почты
240
- */
241
- minLength?: {
242
- value?: number;
243
- errorMessage?: string;
244
- };
245
- /*
246
- * Максимальная длина почты
247
- */
248
- maxLength?: {
249
- value?: number;
250
- errorMessage?: string;
251
- };
252
- /*
253
- * Минимальная длина хоста (часть почты до `@`)
254
- */
255
- minHostLength?: {
256
- value?: number;
257
- errorMessage?: string;
258
- };
259
- /*
260
- * Максимальная длина хоста (часть почты до `@`)
261
- */
262
- maxHostLength?: {
263
- value?: number;
264
- errorMessage?: string;
265
- };
266
- /*
267
- * Минимальная длина домена (часть почты от `@` до `.` перед доменной зоной)
268
- */
269
- minDomainLength?: {
270
- value?: number;
271
- errorMessage?: string;
272
- };
273
- /*
274
- * Максимальная длина домена (часть почты от `@` до `.` перед доменной зоной)
275
- */
276
- maxDomainLength?: {
277
- value?: number;
278
- errorMessage?: string;
279
- };
280
- /*
281
- * Минимальная длина доменной зоны (часть почты от `.`; например `ru`, `com`...)
282
- */
283
- minZoneLength?: {
284
- value?: number;
285
- errorMessage?: string;
286
- };
287
- /*
288
- * Максимальная длина доменной зоны (часть почты от `.`; например `ru`, `com`...)
289
- */
290
- maxZoneLength?: {
291
- value?: number;
292
- errorMessage?: string;
293
- };
294
- /*
295
- * Список разрешенных доменов (например `['mail.ru', 'yahoo.ru', 'gmail.com']`)
296
- */
297
- whitelistDomains?: {
298
- value?: string[];
299
- errorMessage?: string;
300
- };
301
- /*
302
- * Список запрещенных доменов (например `['org.biz', 'expressmail.com']`)
303
- */
304
- blacklistDomains?: {
305
- value?: string[];
306
- errorMessage?: string;
307
- };
308
- };
309
- ```
310
-
311
- ```tsx live
312
- import React, { useState } from 'react';
313
- import { TextField } from '@salutejs/{{ package }}';
314
-
315
- export function App() {
316
- const options = {
317
- minLength: {
318
- value: 7,
319
- errorMessage: 'Почта слишком короткая',
320
- },
321
- maxLength: {
322
- value: 30,
323
- errorMessage: 'Почта слишком длинная',
324
- },
325
- minHostLength: {
326
- value: 2,
327
- errorMessage: 'Хост слишком короткий',
328
- },
329
- maxHostLength: {
330
- value: 12,
331
- errorMessage: 'Хост слишком длинный',
332
- },
333
- minDomainLength: {
334
- value: 3,
335
- errorMessage: 'Домен слишком короткий',
336
- },
337
- maxDomainLength: {
338
- value: 6,
339
- errorMessage: 'Домен слишком длинный',
340
- },
341
- minZoneLength: {
342
- value: 2,
343
- errorMessage: 'Доменная зона слишком короткая',
344
- },
345
- maxZoneLength: {
346
- value: 5,
347
- errorMessage: 'Доменная зона слишком длинная',
348
- },
349
- whitelistDomains: {
350
- value: ['plasma.ru', 'gmail.com', 'mail.ru'],
351
- errorMessage: 'Домен не разрешен',
352
- },
353
- blacklistDomains: {
354
- value: ['hah.ah', 'heh.eh'],
355
- errorMessage: 'Домен запрещен',
356
- },
357
- };
358
-
359
- const [error, setError] = useState('');
360
-
361
- const handleOnChange = () => {
362
- setError('');
363
- };
364
-
365
- const handleOnValidate = ({ errorMessage }: { errorMessage?: string }) => {
366
- setError(errorMessage || '');
367
- };
368
-
369
- return (
370
- <div>
371
- <TextField
372
- label="Валидация почты"
373
- placeholder="Заполните поле"
374
- validationType="email"
375
- options={options}
376
- view={error ? 'negative' : 'default}
377
- helperText={error || 'Валидация почты'}
378
- onChange={handleOnChange}
379
- onValidate={handleOnValidate}
380
- />
381
- </div>
382
- );
383
- }
384
- ```
385
- </TabItem>
386
-
387
- <TabItem value="password" label="Password" default>
388
- Свойства доступные при валидации пароля:
389
- ```tsx
390
- type ValidationProps = {
391
- /*
392
- * Тип валидации
393
- */
394
- validationType: 'password';
395
- /*
396
- * Опции валидации
397
- */
398
- options?: PasswordValidationOptions;
399
- /*
400
- * Состояние сокрытия оригинального пароля
401
- */
402
- passwordHidden?: boolean;
403
- /*
404
- * Функция, вызываемая при валидации значения.
405
- * Вызывается при событии onBlur и по нажатию Enter, когда фокус на поле ввода
406
- */
407
- onValidate?: (args: OnValidateArgs) => void;
408
- }
409
- ```
410
- Свойство `options` имеет следующий вид:
411
- ```tsx
412
- type PasswordValidationOptions = {
413
- /*
414
- * Минимальная длина пароля
415
- */
416
- minLength?: {
417
- value?: number;
418
- errorMessage?: string;
419
- };
420
- /*
421
- * Максимальная длина пароля
422
- */
423
- maxLength?: {
424
- value?: number;
425
- errorMessage?: string;
426
- };
427
- /*
428
- * Должны ли быть буквы верхнего регистра в пароле
429
- */
430
- includeUppercase?: {
431
- value?: boolean;
432
- errorMessage?: string;
433
- };
434
- /*
435
- * Должны ли быть буквы нижнего регистра в пароле
436
- */
437
- includeLowercase?: {
438
- value?: boolean;
439
- errorMessage?: string;
440
- };
441
- /*
442
- * Должны ли быть цифры в пароле
443
- */
444
- includeDigits?: {
445
- value?: boolean;
446
- errorMessage?: string;
447
- };
448
- /*
449
- * Должны ли быть специальные символы в пароле
450
- */
451
- includeSpecialSymbols?: {
452
- value?: boolean;
453
- errorMessage?: string;
454
- };
455
- };
456
- ```
457
-
458
- ```tsx live
459
- import React, { useState } from 'react';
460
- import { TextField, IconButton } from '@salutejs/{{ package }}';
461
- import { IconEyeFill, IconEyeClosedFill } from '@salutejs/plasma-icons';
462
-
463
- export function App() {
464
- const options = {
465
- minLength: {
466
- value: 5,
467
- errorMessage: 'Пароль слишком короткий',
468
- },
469
- maxLength: {
470
- value: 20,
471
- errorMessage: 'Пароль слишком длинный',
472
- },
473
- includeUppercase: {
474
- value: true,
475
- errorMessage: 'Пароль должен содержать хотя бы одну заглавную букву',
476
- },
477
- includeLowercase: {
478
- value: true,
479
- errorMessage: 'Пароль должен содержать хотя бы одну строчную букву',
480
- },
481
- includeDigits: {
482
- value: true,
483
- errorMessage: 'Пароль должен содержать хотя бы одну цифру',
484
- },
485
- includeSpecialSymbols: {
486
- value: true,
487
- errorMessage: 'Пароль должен содержать хотя бы один специальный символ',
488
- },
489
- };
490
-
491
- const [error, setError] = useState('');
492
- const [hidden, setHidden] = useState(false);
493
-
494
- const handleOnChange = () => {
495
- setError('');
496
- };
497
-
498
- const handleOnValidate = ({ errorMessage }: { errorMessage?: string }) => {
499
- setError(errorMessage || '');
500
- };
501
-
502
- const toggleShowPassword = () => setHidden(!hidden);
503
-
504
- const HideButton = () => (
505
- <IconButton size="s" view="clear" onClick={toggleShowPassword}>
506
- {hidden ? <IconEyeClosedFill size="xs" color="inherit" /> : <IconEyeFill size="xs" color="inherit" />}
507
- </IconButton>
508
- )
509
-
510
- return (
511
- <div>
512
- <TextField
513
- label="Валидация пароля"
514
- placeholder="Заполните поле"
515
- validationType="password"
516
- options={options}
517
- view={error ? 'negative' : 'default'}
518
- leftHelper={error || 'Валидация пароля'}
519
- onChange={handleOnChange}
520
- onValidate={handleOnValidate}
521
- passwordHidden={hidden}
522
- contentLeft={<HideButton />}
523
- />
524
- </div>
525
- );
526
- }
527
- ```
528
- </TabItem>
529
- </Tabs>
530
-
@@ -1,2 +1 @@
1
- export { useKeyNavigation } from './useKeyNavigation';
2
- export { useValidation } from './useValidation';
1
+ export { useKeyNavigation } from './useKeyNavigation';
@@ -19,7 +19,7 @@ export var config = {
19
19
  s: /*#__PURE__*/css(["", ":2rem;", ":1.25rem;", ":calc(var(", ") / 2);", ":1rem;", ":calc(var(", ") / 2);", ":0.125rem;", ":1.25;"], switchTokens.trackWidth, switchTokens.trackHeight, switchTokens.trackBorderRadius, switchTokens.trackHeight, switchTokens.thumbSize, switchTokens.thumbBorderRadius, switchTokens.thumbSize, switchTokens.thumbOffset, switchTokens.thumbPressScale)
20
20
  },
21
21
  view: {
22
- "default": /*#__PURE__*/css(["", ":var(--text-primary);", ":var(--text-secondary);", ":var(--surface-accent);", ":var(--surface-accent-hover);", ":var(--surface-transparent-tertiary);", ":var(--surface-transparent-tertiary-hover);", ":var(--on-dark-surface-solid-default);", ":0 1px 1px rgba(0,0,0,0.11);"], switchTokens.labelColor, switchTokens.descriptionColor, switchTokens.trackBackgroundColorOn, switchTokens.trackBackgroundColorOnHover, switchTokens.trackBackgroundColorOff, switchTokens.trackBackgroundColorOffHover, switchTokens.thumbBackgroundColor, switchTokens.thumbBoxShadow)
22
+ "default": /*#__PURE__*/css(["", ":var(--text-primary);", ":var(--text-secondary);", ":var(--surface-accent);", ":var(--surface-accent-hover);", ":var(--surface-transparent-tertiary);", ":var(--surface-transparent-tertiary-hover);", ":0rem;", ":var(--on-dark-surface-solid-default);", ":var(--on-dark-surface-solid-default);", ":0 1px 1px rgba(0,0,0,0.11);"], switchTokens.labelColor, switchTokens.descriptionColor, switchTokens.trackBackgroundColorOn, switchTokens.trackBackgroundColorOnHover, switchTokens.trackBackgroundColorOff, switchTokens.trackBackgroundColorOffHover, switchTokens.trackBorderWidth, switchTokens.thumbBackgroundColorOff, switchTokens.thumbBackgroundColorOn, switchTokens.thumbBoxShadow)
23
23
  },
24
24
  disabled: {
25
25
  "true": /*#__PURE__*/css(["", ":0.4;"], switchTokens.disabledOpacity)