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

Sign up to get free protection for your applications and to get access to all the features.
Files changed (158) 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/Switch/Switch.tokens.js +7 -1
  16. package/emotion/cjs/components/Switch/_toggleSize/base.js +1 -1
  17. package/emotion/cjs/components/Switch/_view/base.js +1 -1
  18. package/emotion/cjs/components/TextField/TextField.js +4 -27
  19. package/emotion/cjs/components/TextField/TextField.template-doc.mdx +0 -330
  20. package/emotion/cjs/components/TextField/hooks/index.js +1 -8
  21. package/emotion/cjs/examples/plasma_b2c/components/Switch/Switch.config.js +8 -8
  22. package/emotion/cjs/examples/plasma_b2c/components/Switch/Switch.js +5 -2
  23. package/emotion/cjs/examples/plasma_b2c/components/Switch/Switch.outline.config.js +37 -0
  24. package/emotion/cjs/examples/plasma_b2c/components/Switch/Switch.stories.tsx +33 -1
  25. package/emotion/cjs/examples/plasma_b2c/components/TextField/TextField.stories.tsx +1 -253
  26. package/emotion/cjs/examples/plasma_web/components/Switch/Switch.config.js +8 -8
  27. package/emotion/cjs/examples/plasma_web/components/Switch/Switch.js +5 -2
  28. package/emotion/cjs/examples/plasma_web/components/Switch/Switch.outline.config.js +37 -0
  29. package/emotion/cjs/examples/plasma_web/components/Switch/Switch.stories.tsx +33 -1
  30. package/emotion/cjs/examples/plasma_web/components/TextField/TextField.stories.tsx +0 -252
  31. package/emotion/cjs/utils/constants.js +2 -4
  32. package/emotion/es/components/Switch/Switch.tokens.js +7 -1
  33. package/emotion/es/components/Switch/_toggleSize/base.js +1 -1
  34. package/emotion/es/components/Switch/_view/base.js +1 -1
  35. package/emotion/es/components/TextField/TextField.js +5 -28
  36. package/emotion/es/components/TextField/TextField.template-doc.mdx +0 -330
  37. package/emotion/es/components/TextField/hooks/index.js +1 -2
  38. package/emotion/es/examples/plasma_b2c/components/Switch/Switch.config.js +8 -8
  39. package/emotion/es/examples/plasma_b2c/components/Switch/Switch.js +4 -1
  40. package/emotion/es/examples/plasma_b2c/components/Switch/Switch.outline.config.js +31 -0
  41. package/emotion/es/examples/plasma_b2c/components/Switch/Switch.stories.tsx +33 -1
  42. package/emotion/es/examples/plasma_b2c/components/TextField/TextField.stories.tsx +1 -253
  43. package/emotion/es/examples/plasma_web/components/Switch/Switch.config.js +8 -8
  44. package/emotion/es/examples/plasma_web/components/Switch/Switch.js +4 -1
  45. package/emotion/es/examples/plasma_web/components/Switch/Switch.outline.config.js +31 -0
  46. package/emotion/es/examples/plasma_web/components/Switch/Switch.stories.tsx +33 -1
  47. package/emotion/es/examples/plasma_web/components/TextField/TextField.stories.tsx +0 -252
  48. package/emotion/es/utils/constants.js +1 -3
  49. package/es/components/Switch/Switch.css +2 -2
  50. package/es/components/Switch/Switch.tokens.js +7 -1
  51. package/es/components/Switch/Switch.tokens.js.map +1 -1
  52. package/es/components/Switch/_toggleSize/base.js +1 -1
  53. package/es/components/Switch/_toggleSize/base.js.map +1 -1
  54. package/es/components/Switch/_toggleSize/base_1d0b3t4.css +1 -0
  55. package/es/components/Switch/_view/base.js +1 -1
  56. package/es/components/Switch/_view/base.js.map +1 -1
  57. package/es/components/Switch/_view/base_15atbyp.css +1 -0
  58. package/es/components/TextField/TextField.js +3 -27
  59. package/es/components/TextField/TextField.js.map +1 -1
  60. package/es/index.css +2 -2
  61. package/es/utils/constants.js +1 -3
  62. package/es/utils/constants.js.map +1 -1
  63. package/package.json +2 -2
  64. package/styled-components/cjs/components/Switch/Switch.tokens.js +7 -1
  65. package/styled-components/cjs/components/Switch/_toggleSize/base.js +1 -1
  66. package/styled-components/cjs/components/Switch/_view/base.js +1 -1
  67. package/styled-components/cjs/components/TextField/TextField.js +3 -26
  68. package/styled-components/cjs/components/TextField/TextField.template-doc.mdx +0 -330
  69. package/styled-components/cjs/components/TextField/hooks/index.js +1 -8
  70. package/styled-components/cjs/examples/plasma_b2c/components/Switch/Switch.config.js +1 -1
  71. package/styled-components/cjs/examples/plasma_b2c/components/Switch/Switch.js +5 -2
  72. package/styled-components/cjs/examples/plasma_b2c/components/Switch/Switch.outline.config.js +37 -0
  73. package/styled-components/cjs/examples/plasma_b2c/components/Switch/Switch.stories.tsx +33 -1
  74. package/styled-components/cjs/examples/plasma_b2c/components/TextField/TextField.stories.tsx +1 -253
  75. package/styled-components/cjs/examples/plasma_web/components/Switch/Switch.config.js +1 -1
  76. package/styled-components/cjs/examples/plasma_web/components/Switch/Switch.js +5 -2
  77. package/styled-components/cjs/examples/plasma_web/components/Switch/Switch.outline.config.js +37 -0
  78. package/styled-components/cjs/examples/plasma_web/components/Switch/Switch.stories.tsx +33 -1
  79. package/styled-components/cjs/examples/plasma_web/components/TextField/TextField.stories.tsx +0 -252
  80. package/styled-components/cjs/utils/constants.js +2 -4
  81. package/styled-components/es/components/Switch/Switch.tokens.js +7 -1
  82. package/styled-components/es/components/Switch/_toggleSize/base.js +1 -1
  83. package/styled-components/es/components/Switch/_view/base.js +1 -1
  84. package/styled-components/es/components/TextField/TextField.js +4 -27
  85. package/styled-components/es/components/TextField/TextField.template-doc.mdx +0 -330
  86. package/styled-components/es/components/TextField/hooks/index.js +1 -2
  87. package/styled-components/es/examples/plasma_b2c/components/Switch/Switch.config.js +1 -1
  88. package/styled-components/es/examples/plasma_b2c/components/Switch/Switch.js +4 -1
  89. package/styled-components/es/examples/plasma_b2c/components/Switch/Switch.outline.config.js +31 -0
  90. package/styled-components/es/examples/plasma_b2c/components/Switch/Switch.stories.tsx +33 -1
  91. package/styled-components/es/examples/plasma_b2c/components/TextField/TextField.stories.tsx +1 -253
  92. package/styled-components/es/examples/plasma_web/components/Switch/Switch.config.js +1 -1
  93. package/styled-components/es/examples/plasma_web/components/Switch/Switch.js +4 -1
  94. package/styled-components/es/examples/plasma_web/components/Switch/Switch.outline.config.js +31 -0
  95. package/styled-components/es/examples/plasma_web/components/Switch/Switch.stories.tsx +33 -1
  96. package/styled-components/es/examples/plasma_web/components/TextField/TextField.stories.tsx +0 -252
  97. package/styled-components/es/utils/constants.js +1 -3
  98. package/types/components/Autocomplete/Autocomplete.types.d.ts +2 -2
  99. package/types/components/Autocomplete/Autocomplete.types.d.ts.map +1 -1
  100. package/types/components/Autocomplete/ui/TextField/TextField.styles.d.ts +92 -1676
  101. package/types/components/Autocomplete/ui/TextField/TextField.styles.d.ts.map +1 -1
  102. package/types/components/Combobox/ComboboxNew/ui/Target/Target.styles.d.ts +92 -1676
  103. package/types/components/Combobox/ComboboxNew/ui/Target/Target.styles.d.ts.map +1 -1
  104. package/types/components/DatePicker/SingleDate/SingleDate.styles.d.ts +92 -1676
  105. package/types/components/DatePicker/SingleDate/SingleDate.styles.d.ts.map +1 -1
  106. package/types/components/Range/Range.styles.d.ts +92 -1676
  107. package/types/components/Range/Range.styles.d.ts.map +1 -1
  108. package/types/components/Select/ui/Target/ui/Textfield/Textfield.styles.d.ts +92 -1676
  109. package/types/components/Select/ui/Target/ui/Textfield/Textfield.styles.d.ts.map +1 -1
  110. package/types/components/Slider/components/Double/Double.styles.d.ts +92 -1676
  111. package/types/components/Slider/components/Double/Double.styles.d.ts.map +1 -1
  112. package/types/components/Switch/Switch.tokens.d.ts +7 -1
  113. package/types/components/Switch/Switch.tokens.d.ts.map +1 -1
  114. package/types/components/Switch/_toggleSize/base.d.ts.map +1 -1
  115. package/types/components/Switch/_view/base.d.ts.map +1 -1
  116. package/types/components/TextField/TextField.d.ts.map +1 -1
  117. package/types/components/TextField/TextField.types.d.ts +1 -51
  118. package/types/components/TextField/TextField.types.d.ts.map +1 -1
  119. package/types/components/TextField/hooks/index.d.ts +0 -1
  120. package/types/components/TextField/hooks/index.d.ts.map +1 -1
  121. package/types/examples/plasma_b2c/components/Autocomplete/Autocomplete.d.ts +2 -64
  122. package/types/examples/plasma_b2c/components/Autocomplete/Autocomplete.d.ts.map +1 -1
  123. package/types/examples/plasma_b2c/components/Mask/Mask.d.ts +92 -2732
  124. package/types/examples/plasma_b2c/components/Mask/Mask.d.ts.map +1 -1
  125. package/types/examples/plasma_b2c/components/Switch/Switch.config.d.ts.map +1 -1
  126. package/types/examples/plasma_b2c/components/Switch/Switch.d.ts +20 -0
  127. package/types/examples/plasma_b2c/components/Switch/Switch.d.ts.map +1 -1
  128. package/types/examples/plasma_b2c/components/Switch/Switch.outline.config.d.ts +30 -0
  129. package/types/examples/plasma_b2c/components/Switch/Switch.outline.config.d.ts.map +1 -0
  130. package/types/examples/plasma_b2c/components/TextField/TextField.d.ts +92 -1676
  131. package/types/examples/plasma_b2c/components/TextField/TextField.d.ts.map +1 -1
  132. package/types/examples/plasma_web/components/Autocomplete/Autocomplete.d.ts +2 -64
  133. package/types/examples/plasma_web/components/Autocomplete/Autocomplete.d.ts.map +1 -1
  134. package/types/examples/plasma_web/components/Mask/Mask.d.ts +92 -2732
  135. package/types/examples/plasma_web/components/Mask/Mask.d.ts.map +1 -1
  136. package/types/examples/plasma_web/components/Switch/Switch.config.d.ts.map +1 -1
  137. package/types/examples/plasma_web/components/Switch/Switch.d.ts +20 -0
  138. package/types/examples/plasma_web/components/Switch/Switch.d.ts.map +1 -1
  139. package/types/examples/plasma_web/components/Switch/Switch.outline.config.d.ts +30 -0
  140. package/types/examples/plasma_web/components/Switch/Switch.outline.config.d.ts.map +1 -0
  141. package/types/examples/plasma_web/components/TextField/TextField.d.ts +92 -1676
  142. package/types/examples/plasma_web/components/TextField/TextField.d.ts.map +1 -1
  143. package/types/utils/constants.d.ts +0 -2
  144. package/types/utils/constants.d.ts.map +1 -1
  145. package/cjs/components/Switch/_toggleSize/base_6i0904.css +0 -1
  146. package/cjs/components/Switch/_view/base_yxkf3s.css +0 -1
  147. package/cjs/components/TextField/hooks/useValidation.js +0 -273
  148. package/cjs/components/TextField/hooks/useValidation.js.map +0 -1
  149. package/emotion/cjs/components/TextField/hooks/useValidation.js +0 -276
  150. package/emotion/es/components/TextField/hooks/useValidation.js +0 -270
  151. package/es/components/Switch/_toggleSize/base_6i0904.css +0 -1
  152. package/es/components/Switch/_view/base_yxkf3s.css +0 -1
  153. package/es/components/TextField/hooks/useValidation.js +0 -269
  154. package/es/components/TextField/hooks/useValidation.js.map +0 -1
  155. package/styled-components/cjs/components/TextField/hooks/useValidation.js +0 -276
  156. package/styled-components/es/components/TextField/hooks/useValidation.js +0 -270
  157. package/types/components/TextField/hooks/useValidation.d.ts +0 -7
  158. package/types/components/TextField/hooks/useValidation.d.ts.map +0 -1
@@ -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)
@@ -1,5 +1,8 @@
1
1
  import { switchConfig } from '../../../../components/Switch';
2
2
  import { component, mergeConfig } from '../../../../engines';
3
3
  import { config } from './Switch.config';
4
+ import { config as outlineConfig } from './Switch.outline.config';
4
5
  var mergedConfig = /*#__PURE__*/mergeConfig(switchConfig, config);
5
- export var Switch = /*#__PURE__*/component(mergedConfig);
6
+ export var Switch = /*#__PURE__*/component(mergedConfig);
7
+ var mergedOutlineConfig = /*#__PURE__*/mergeConfig(switchConfig, outlineConfig);
8
+ export var SwitchOutline = /*#__PURE__*/component(mergedOutlineConfig);
@@ -0,0 +1,31 @@
1
+ import { css } from 'styled-components';
2
+ import { switchTokens } from '../../../../components/Switch';
3
+ export var config = {
4
+ defaults: {
5
+ view: 'default',
6
+ size: 'm',
7
+ toggleSize: 'l',
8
+ labelPosition: 'before',
9
+ focused: 'true'
10
+ },
11
+ variations: {
12
+ size: {
13
+ s: /*#__PURE__*/css(["", ":var(--plasma-typo-body-s-font-family);", ":var(--plasma-typo-body-s-font-style);", ":var(--plasma-typo-body-s-font-weight);", ":var(--plasma-typo-body-s-line-height);", ":var(--plasma-typo-body-s-font-size);", ":var(--plasma-typo-body-s-letter-spacing);", ":var(--plasma-typo-body-xs-font-family);", ":var(--plasma-typo-body-xs-font-style);", ":var(--plasma-typo-body-xs-font-weight);", ":var(--plasma-typo-body-xs-line-height);", ":var(--plasma-typo-body-xs-font-size);", ":var(--plasma-typo-body-xs-letter-spacing);", ":0.25rem;", ":0.75rem;"], switchTokens.fontFamily, switchTokens.fontStyle, switchTokens.fontWeight, switchTokens.lineHeight, switchTokens.fontSize, switchTokens.letterSpacing, switchTokens.descriptionFontFamily, switchTokens.descriptionFontStyle, switchTokens.descriptionFontWeight, switchTokens.descriptionLineHeight, switchTokens.descriptionFontSize, switchTokens.descriptionLetterSpacing, switchTokens.verticalGap, switchTokens.labelOffset),
14
+ m: /*#__PURE__*/css(["", ":var(--plasma-typo-body-m-font-family);", ":var(--plasma-typo-body-m-font-style);", ":var(--plasma-typo-body-m-font-weight);", ":var(--plasma-typo-body-m-line-height);", ":var(--plasma-typo-body-m-font-size);", ":var(--plasma-typo-body-m-letter-spacing);", ":var(--plasma-typo-body-s-font-family);", ":var(--plasma-typo-body-s-font-style);", ":var(--plasma-typo-body-s-font-weight);", ":var(--plasma-typo-body-s-line-height);", ":var(--plasma-typo-body-s-font-size);", ":var(--plasma-typo-body-xs-letter-spacing);", ":0.25rem;", ":0.75rem;"], switchTokens.fontFamily, switchTokens.fontStyle, switchTokens.fontWeight, switchTokens.lineHeight, switchTokens.fontSize, switchTokens.letterSpacing, switchTokens.descriptionFontFamily, switchTokens.descriptionFontStyle, switchTokens.descriptionFontWeight, switchTokens.descriptionLineHeight, switchTokens.descriptionFontSize, switchTokens.descriptionLetterSpacing, switchTokens.verticalGap, switchTokens.labelOffset),
15
+ l: /*#__PURE__*/css(["", ":var(--plasma-typo-body-l-font-family);", ":var(--plasma-typo-body-l-font-style);", ":var(--plasma-typo-body-l-font-weight);", ":var(--plasma-typo-body-l-line-height);", ":var(--plasma-typo-body-l-font-size);", ":var(--plasma-typo-body-l-letter-spacing);", ":var(--plasma-typo-body-m-font-family);", ":var(--plasma-typo-body-m-font-style);", ":var(--plasma-typo-body-m-font-weight);", ":var(--plasma-typo-body-m-line-height);", ":var(--plasma-typo-body-m-font-size);", ":var(--plasma-typo-body-xs-letter-spacing);", ":0.25rem;", ":0.75rem;"], switchTokens.fontFamily, switchTokens.fontStyle, switchTokens.fontWeight, switchTokens.lineHeight, switchTokens.fontSize, switchTokens.letterSpacing, switchTokens.descriptionFontFamily, switchTokens.descriptionFontStyle, switchTokens.descriptionFontWeight, switchTokens.descriptionLineHeight, switchTokens.descriptionFontSize, switchTokens.descriptionLetterSpacing, switchTokens.verticalGap, switchTokens.labelOffset)
16
+ },
17
+ toggleSize: {
18
+ l: /*#__PURE__*/css(["", ":2.75rem;", ":1.75rem;", ":calc(var(", ") / 2);", ":1.375rem;", ":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),
19
+ s: /*#__PURE__*/css(["", ":2rem;", ":1.25rem;", ":calc(var(", ") / 2);", ":0.875rem;", ":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
+ },
21
+ view: {
22
+ "default": /*#__PURE__*/css(["", ":var(--text-primary);", ":var(--text-secondary);", ":0.0625rem;", ":var(--outline-secondary);", ":var(--outline-secondary-hover);", ":var(--outline-accent);", ":var(--outline-accent-hover);", ":var(--text-tertiary);", ":var(--text-accent);", ":0 1px 1px rgba(0,0,0,0.11);"], switchTokens.labelColor, switchTokens.descriptionColor, switchTokens.trackBorderWidth, switchTokens.trackBorderColorOff, switchTokens.trackBorderColorOffHover, switchTokens.trackBorderColorOn, switchTokens.trackBorderColorOnHover, switchTokens.thumbBackgroundColorOff, switchTokens.thumbBackgroundColorOn, switchTokens.thumbBoxShadow)
23
+ },
24
+ disabled: {
25
+ "true": /*#__PURE__*/css(["", ":0.4;"], switchTokens.disabledOpacity)
26
+ },
27
+ focused: {
28
+ "true": /*#__PURE__*/css(["", ":var(--surface-accent);"], switchTokens.trackFocusColor)
29
+ }
30
+ }
31
+ };
@@ -9,7 +9,7 @@ import { mergeConfig } from '../../../../engines';
9
9
  import { WithTheme, argTypesFromConfig } from '../../../_helpers';
10
10
 
11
11
  import { config } from './Switch.config';
12
- import { Switch } from './Switch';
12
+ import { Switch, SwitchOutline } from './Switch';
13
13
 
14
14
  type SwitchProps = ComponentProps<typeof Switch>;
15
15
 
@@ -72,3 +72,35 @@ export const Default: StoryObj<SwitchProps> = {
72
72
  },
73
73
  render: (args) => <StoryDefault {...args} />,
74
74
  };
75
+
76
+ const StoryOutline = (args: SwitchProps) => {
77
+ const value = 'yes';
78
+ const name = 'agree';
79
+ const [checked, setChecked] = useState(true);
80
+
81
+ return (
82
+ <StyledWrapper>
83
+ <SwitchOutline
84
+ value={value}
85
+ name={name}
86
+ checked={checked}
87
+ onChange={(event) => {
88
+ setChecked(event.target.checked);
89
+ onChange(event);
90
+ }}
91
+ onFocus={onFocus}
92
+ onBlur={onBlur}
93
+ {...args}
94
+ />
95
+ </StyledWrapper>
96
+ );
97
+ };
98
+
99
+ export const Outline: StoryObj<SwitchProps> = {
100
+ args: {
101
+ size: 'm',
102
+ toggleSize: 'l',
103
+ disabled: false,
104
+ },
105
+ render: (args) => <StoryOutline {...args} />,
106
+ };