@salutejs/plasma-new-hope 0.184.0-canary.1538.11686719130.0 → 0.184.0-canary.1539.11687316067.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (122) hide show
  1. package/cjs/components/Dropdown/Dropdown.js +4 -6
  2. package/cjs/components/Dropdown/Dropdown.js.map +1 -1
  3. package/cjs/components/Switch/Switch.css +11 -7
  4. package/cjs/components/Switch/Switch.js +16 -7
  5. package/cjs/components/Switch/Switch.js.map +1 -1
  6. package/cjs/components/Switch/Switch.styles.js +16 -4
  7. package/cjs/components/Switch/Switch.styles.js.map +1 -1
  8. package/cjs/components/Switch/Switch.styles_bei7bh.css +6 -0
  9. package/cjs/components/Switch/Switch.tokens.js +11 -0
  10. package/cjs/components/Switch/Switch.tokens.js.map +1 -1
  11. package/cjs/components/Switch/_focused/base.js +1 -1
  12. package/{es/components/Switch/_focused/base_j4murk.css → cjs/components/Switch/_focused/base_sz3n0x.css} +1 -1
  13. package/cjs/components/Switch/_size/base.js +1 -1
  14. package/cjs/components/Switch/_size/base.js.map +1 -1
  15. package/cjs/components/Switch/_size/base_1tcl212.css +1 -0
  16. package/cjs/components/Switch/_toggleSize/base.js +9 -0
  17. package/cjs/components/Switch/_toggleSize/base.js.map +1 -0
  18. package/cjs/components/Switch/_toggleSize/base_6i0904.css +1 -0
  19. package/cjs/components/Switch/_view/base.js +1 -1
  20. package/cjs/components/Switch/_view/base.js.map +1 -1
  21. package/cjs/components/Switch/_view/base_yxkf3s.css +1 -0
  22. package/cjs/index.css +11 -7
  23. package/emotion/cjs/components/Dropdown/Dropdown.js +4 -6
  24. package/emotion/cjs/components/Switch/Switch.js +17 -8
  25. package/emotion/cjs/components/Switch/Switch.styles.js +21 -5
  26. package/emotion/cjs/components/Switch/Switch.template-doc.mdx +37 -1
  27. package/emotion/cjs/components/Switch/Switch.tokens.js +11 -0
  28. package/emotion/cjs/components/Switch/_size/base.js +1 -1
  29. package/emotion/cjs/components/Switch/_toggleSize/base.js +10 -0
  30. package/emotion/cjs/components/Switch/_view/base.js +1 -1
  31. package/emotion/cjs/examples/plasma_b2c/components/Switch/Switch.config.js +11 -4
  32. package/emotion/cjs/examples/plasma_b2c/components/Switch/Switch.stories.tsx +7 -1
  33. package/emotion/cjs/examples/plasma_web/components/Switch/Switch.config.js +11 -4
  34. package/emotion/cjs/examples/plasma_web/components/Switch/Switch.stories.tsx +14 -1
  35. package/emotion/es/components/Dropdown/Dropdown.js +4 -6
  36. package/emotion/es/components/Switch/Switch.js +13 -4
  37. package/emotion/es/components/Switch/Switch.styles.js +20 -4
  38. package/emotion/es/components/Switch/Switch.template-doc.mdx +37 -1
  39. package/emotion/es/components/Switch/Switch.tokens.js +11 -0
  40. package/emotion/es/components/Switch/_size/base.js +2 -2
  41. package/emotion/es/components/Switch/_toggleSize/base.js +4 -0
  42. package/emotion/es/components/Switch/_view/base.js +2 -2
  43. package/emotion/es/examples/plasma_b2c/components/Switch/Switch.config.js +11 -4
  44. package/emotion/es/examples/plasma_b2c/components/Switch/Switch.stories.tsx +7 -1
  45. package/emotion/es/examples/plasma_web/components/Switch/Switch.config.js +11 -4
  46. package/emotion/es/examples/plasma_web/components/Switch/Switch.stories.tsx +14 -1
  47. package/es/components/Dropdown/Dropdown.js +4 -6
  48. package/es/components/Dropdown/Dropdown.js.map +1 -1
  49. package/es/components/Switch/Switch.css +11 -7
  50. package/es/components/Switch/Switch.js +17 -8
  51. package/es/components/Switch/Switch.js.map +1 -1
  52. package/es/components/Switch/Switch.styles.js +15 -5
  53. package/es/components/Switch/Switch.styles.js.map +1 -1
  54. package/es/components/Switch/Switch.styles_bei7bh.css +6 -0
  55. package/es/components/Switch/Switch.tokens.js +11 -0
  56. package/es/components/Switch/Switch.tokens.js.map +1 -1
  57. package/es/components/Switch/_focused/base.js +1 -1
  58. package/{cjs/components/Switch/_focused/base_j4murk.css → es/components/Switch/_focused/base_sz3n0x.css} +1 -1
  59. package/es/components/Switch/_size/base.js +1 -1
  60. package/es/components/Switch/_size/base.js.map +1 -1
  61. package/es/components/Switch/_size/base_1tcl212.css +1 -0
  62. package/es/components/Switch/_toggleSize/base.js +5 -0
  63. package/es/components/Switch/_toggleSize/base.js.map +1 -0
  64. package/es/components/Switch/_toggleSize/base_6i0904.css +1 -0
  65. package/es/components/Switch/_view/base.js +1 -1
  66. package/es/components/Switch/_view/base.js.map +1 -1
  67. package/es/components/Switch/_view/base_yxkf3s.css +1 -0
  68. package/es/index.css +11 -7
  69. package/package.json +2 -2
  70. package/styled-components/cjs/components/Dropdown/Dropdown.js +4 -6
  71. package/styled-components/cjs/components/Switch/Switch.js +17 -8
  72. package/styled-components/cjs/components/Switch/Switch.styles.js +11 -5
  73. package/styled-components/cjs/components/Switch/Switch.template-doc.mdx +37 -1
  74. package/styled-components/cjs/components/Switch/Switch.tokens.js +11 -0
  75. package/styled-components/cjs/components/Switch/_size/base.js +1 -1
  76. package/styled-components/cjs/components/Switch/_toggleSize/base.js +10 -0
  77. package/styled-components/cjs/components/Switch/_view/base.js +1 -1
  78. package/styled-components/cjs/examples/plasma_b2c/components/Switch/Switch.config.js +9 -2
  79. package/styled-components/cjs/examples/plasma_b2c/components/Switch/Switch.stories.tsx +7 -1
  80. package/styled-components/cjs/examples/plasma_web/components/Switch/Switch.config.js +9 -2
  81. package/styled-components/cjs/examples/plasma_web/components/Switch/Switch.stories.tsx +14 -1
  82. package/styled-components/es/components/Dropdown/Dropdown.js +4 -6
  83. package/styled-components/es/components/Switch/Switch.js +13 -4
  84. package/styled-components/es/components/Switch/Switch.styles.js +10 -4
  85. package/styled-components/es/components/Switch/Switch.template-doc.mdx +37 -1
  86. package/styled-components/es/components/Switch/Switch.tokens.js +11 -0
  87. package/styled-components/es/components/Switch/_size/base.js +2 -2
  88. package/styled-components/es/components/Switch/_toggleSize/base.js +4 -0
  89. package/styled-components/es/components/Switch/_view/base.js +2 -2
  90. package/styled-components/es/examples/plasma_b2c/components/Switch/Switch.config.js +9 -2
  91. package/styled-components/es/examples/plasma_b2c/components/Switch/Switch.stories.tsx +7 -1
  92. package/styled-components/es/examples/plasma_web/components/Switch/Switch.config.js +9 -2
  93. package/styled-components/es/examples/plasma_web/components/Switch/Switch.stories.tsx +14 -1
  94. package/types/components/Dropdown/Dropdown.d.ts.map +1 -1
  95. package/types/components/Dropdown/Dropdown.types.d.ts +0 -4
  96. package/types/components/Dropdown/Dropdown.types.d.ts.map +1 -1
  97. package/types/components/Switch/Switch.d.ts +3 -0
  98. package/types/components/Switch/Switch.d.ts.map +1 -1
  99. package/types/components/Switch/Switch.styles.d.ts +2 -0
  100. package/types/components/Switch/Switch.styles.d.ts.map +1 -1
  101. package/types/components/Switch/Switch.tokens.d.ts +9 -0
  102. package/types/components/Switch/Switch.tokens.d.ts.map +1 -1
  103. package/types/components/Switch/Switch.types.d.ts +10 -2
  104. package/types/components/Switch/Switch.types.d.ts.map +1 -1
  105. package/types/components/Switch/_size/base.d.ts.map +1 -1
  106. package/types/components/Switch/_toggleSize/base.d.ts +2 -0
  107. package/types/components/Switch/_toggleSize/base.d.ts.map +1 -0
  108. package/types/components/Switch/_view/base.d.ts.map +1 -1
  109. package/types/examples/plasma_b2c/components/Switch/Switch.config.d.ts +7 -0
  110. package/types/examples/plasma_b2c/components/Switch/Switch.config.d.ts.map +1 -1
  111. package/types/examples/plasma_b2c/components/Switch/Switch.d.ts +6 -0
  112. package/types/examples/plasma_b2c/components/Switch/Switch.d.ts.map +1 -1
  113. package/types/examples/plasma_web/components/Switch/Switch.config.d.ts +7 -0
  114. package/types/examples/plasma_web/components/Switch/Switch.config.d.ts.map +1 -1
  115. package/types/examples/plasma_web/components/Switch/Switch.d.ts +6 -0
  116. package/types/examples/plasma_web/components/Switch/Switch.d.ts.map +1 -1
  117. package/cjs/components/Switch/Switch.styles_1kk0qzz.css +0 -4
  118. package/cjs/components/Switch/_size/base_1rjzpi4.css +0 -1
  119. package/cjs/components/Switch/_view/base_1mtyz12.css +0 -1
  120. package/es/components/Switch/Switch.styles_1kk0qzz.css +0 -4
  121. package/es/components/Switch/_size/base_1rjzpi4.css +0 -1
  122. package/es/components/Switch/_view/base_1mtyz12.css +0 -1
@@ -7,14 +7,15 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.switchRoot = exports.switchConfig = void 0;
8
8
  var _react = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("react"));
9
9
  var _base = /*#__PURE__*/require("../Switch/_size/base");
10
- var _base2 = /*#__PURE__*/require("../Switch/_view/base");
11
- var _base3 = /*#__PURE__*/require("../Switch/_focused/base");
12
- var _base4 = /*#__PURE__*/require("../Switch/_disabled/base");
10
+ var _base2 = /*#__PURE__*/require("../Switch/_toggleSize/base");
11
+ var _base3 = /*#__PURE__*/require("../Switch/_view/base");
12
+ var _base4 = /*#__PURE__*/require("../Switch/_focused/base");
13
+ var _base5 = /*#__PURE__*/require("../Switch/_disabled/base");
13
14
  var _utils = /*#__PURE__*/require("../../utils");
14
15
  var _Switch = /*#__PURE__*/require("./Switch.styles");
15
16
  var _Switch2 = /*#__PURE__*/require("./Switch.tokens");
16
17
  var _StyledTrigger;
17
- var _excluded = ["size", "view", "focused", "outlined", "disabled", "labelPosition", "label", "id", "style", "className", "checked", "pressed", "defaultChecked"];
18
+ var _excluded = ["size", "toggleSize", "view", "focused", "outlined", "disabled", "labelPosition", "label", "description", "id", "style", "className", "checked", "pressed", "defaultChecked"];
18
19
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
19
20
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
20
21
  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); }
@@ -23,12 +24,14 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
23
24
  var switchRoot = exports.switchRoot = function switchRoot(Root) {
24
25
  return /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
25
26
  var size = props.size,
27
+ toggleSize = props.toggleSize,
26
28
  view = props.view,
27
29
  focused = props.focused,
28
30
  outlined = props.outlined,
29
31
  disabled = props.disabled,
30
32
  labelPosition = props.labelPosition,
31
33
  label = props.label,
34
+ description = props.description,
32
35
  id = props.id,
33
36
  style = props.style,
34
37
  className = props.className,
@@ -40,12 +43,15 @@ var switchRoot = exports.switchRoot = function switchRoot(Root) {
40
43
  return /*#__PURE__*/_react["default"].createElement(Root, {
41
44
  view: view,
42
45
  size: size,
46
+ toggleSize: toggleSize,
43
47
  disabled: disabled,
44
48
  focused: focused !== null && focused !== void 0 ? focused : outlined,
45
49
  labelPosition: labelPosition,
46
50
  id: id,
47
51
  style: style,
48
- className: (0, _utils.cx)(className, _Switch2.classes["".concat(labelPosition, "SwitchLabelPosition")])
52
+ className: (0, _utils.cx)(className)
53
+ }, /*#__PURE__*/_react["default"].createElement(_Switch.StyledContent, {
54
+ className: (0, _utils.cx)(_Switch2.classes["".concat(labelPosition, "SwitchLabelPosition")])
49
55
  }, /*#__PURE__*/_react["default"].createElement(_Switch.StyledInput, _extends({}, rest, {
50
56
  ref: ref,
51
57
  role: "switch",
@@ -58,7 +64,7 @@ var switchRoot = exports.switchRoot = function switchRoot(Root) {
58
64
  tabIndex: -1
59
65
  }, label), _StyledTrigger || (_StyledTrigger = /*#__PURE__*/_react["default"].createElement(_Switch.StyledTrigger, {
60
66
  "aria-hidden": true
61
- })));
67
+ }))), description && /*#__PURE__*/_react["default"].createElement(_Switch.StyledDescription, null, description));
62
68
  });
63
69
  };
64
70
  var switchConfig = exports.switchConfig = {
@@ -71,14 +77,17 @@ var switchConfig = exports.switchConfig = {
71
77
  css: _base.base
72
78
  },
73
79
  view: {
80
+ css: _base3.base
81
+ },
82
+ toggleSize: {
74
83
  css: _base2.base
75
84
  },
76
85
  disabled: {
77
- css: _base4.base,
86
+ css: _base5.base,
78
87
  attrs: true
79
88
  },
80
89
  focused: {
81
- css: _base3.base
90
+ css: _base4.base
82
91
  }
83
92
  },
84
93
  defaults: {
@@ -4,19 +4,25 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.base = exports.StyledTrigger = exports.StyledLabel = exports.StyledInput = void 0;
7
+ exports.base = exports.StyledTrigger = exports.StyledLabel = exports.StyledInput = exports.StyledDescription = exports.StyledContent = void 0;
8
8
  var _styledComponents = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("styled-components"));
9
9
  var _mixins = /*#__PURE__*/require("../../mixins");
10
10
  var _Switch = /*#__PURE__*/require("./Switch.tokens");
11
11
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
12
12
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
13
- var base = exports.base = /*#__PURE__*/(0, _styledComponents.css)(["position:relative;display:flex;align-items:center;cursor:pointer;-webkit-tap-highlight-color:rgba(0,0,0,0);&:focus{outline:0 none;}&.", "{justify-content:space-between;", ":0 var(", ") 0 0;}&.", "{justify-content:start;flex-direction:row-reverse;", ":0 0 0 var(", ");}"], _Switch.classes.beforeSwitchLabelPosition, _Switch.tokens.labelOffsetPrivate, _Switch.tokens.labelOffset, _Switch.classes.afterSwitchLabelPosition, _Switch.tokens.labelOffsetPrivate, _Switch.tokens.labelOffset);
14
- var StyledInput = exports.StyledInput = /*#__PURE__*/_styledComponents["default"].input.withConfig({
13
+ var base = exports.base = /*#__PURE__*/(0, _styledComponents.css)(["position:relative;display:flex;flex-direction:column;gap:var(", ");cursor:pointer;-webkit-tap-highlight-color:rgba(0,0,0,0);&:focus{outline:0 none;}"], _Switch.tokens.verticalGap);
14
+ var StyledContent = exports.StyledContent = /*#__PURE__*/_styledComponents["default"].div.withConfig({
15
15
  componentId: "plasma-new-hope__sc-i4fgom-0"
16
+ })(["width:100%;position:relative;display:flex;align-items:center;&.", "{justify-content:space-between;", ":0 var(", ") 0 0;}&.", "{justify-content:start;flex-direction:row-reverse;", ":0 0 0 var(", ");}"], _Switch.classes.beforeSwitchLabelPosition, _Switch.tokens.labelOffsetPrivate, _Switch.tokens.labelOffset, _Switch.classes.afterSwitchLabelPosition, _Switch.tokens.labelOffsetPrivate, _Switch.tokens.labelOffset);
17
+ var StyledDescription = exports.StyledDescription = /*#__PURE__*/_styledComponents["default"].div.withConfig({
18
+ componentId: "plasma-new-hope__sc-i4fgom-1"
19
+ })(["position:relative;"]);
20
+ var StyledInput = exports.StyledInput = /*#__PURE__*/_styledComponents["default"].input.withConfig({
21
+ componentId: "plasma-new-hope__sc-i4fgom-2"
16
22
  })(["position:absolute;right:0;margin:0;opacity:0;&:focus{outline:0 none;}"]);
17
23
  var StyledLabel = exports.StyledLabel = /*#__PURE__*/_styledComponents["default"].span.withConfig({
18
- componentId: "plasma-new-hope__sc-i4fgom-1"
24
+ componentId: "plasma-new-hope__sc-i4fgom-3"
19
25
  })(["user-select:none;", ""], /*#__PURE__*/(0, _mixins.applyEllipsis)());
20
26
  var StyledTrigger = exports.StyledTrigger = /*#__PURE__*/_styledComponents["default"].div.withConfig({
21
- componentId: "plasma-new-hope__sc-i4fgom-2"
27
+ componentId: "plasma-new-hope__sc-i4fgom-4"
22
28
  })(["position:relative;display:flex;align-items:center;transition:background-color 0.15s ease-in-out 0.1s;::after{content:'';position:absolute;right:auto;left:0;transition:width 0.15s ease-in-out 0s,left 0.3s ease-in-out 0s,right 0.3s ease-in-out 0s;}", ":checked ~ &::after{right:0;left:auto;}"], StyledInput);
@@ -18,7 +18,43 @@ import { Switch } from '@salutejs/{{ package }}';
18
18
 
19
19
  export function App() {
20
20
  return (
21
- <Switch label="Переключатель" defaultChecked />
21
+ <Switch description="Описание переключателя" label="Переключатель" defaultChecked />
22
+ );
23
+ }
24
+ ```
25
+
26
+ ## Примеры
27
+
28
+ ### Размер Switch
29
+ Размер компонента задается с помощью свойства `size`.
30
+
31
+ ```tsx live
32
+ import React from 'react';
33
+ import { Button } from '@salutejs/{{ package }}';
34
+
35
+ export function App() {
36
+ return (
37
+ <div>
38
+ <Switch size="s" description="Описание переключателя" label="Переключатель" defaultChecked />
39
+ <Switch size="m" description="Описание переключателя" label="Переключатель" defaultChecked />
40
+ <Switch size="l" description="Описание переключателя" label="Переключатель" defaultChecked />
41
+ </div>
42
+ );
43
+ }
44
+ ```
45
+
46
+ Размер переключателя задается с помощью свойства `toggleSize`.
47
+
48
+ ```tsx live
49
+ import React from 'react';
50
+ import { Button } from '@salutejs/{{ package }}';
51
+
52
+ export function App() {
53
+ return (
54
+ <div style=\{{ alignItems: "center" }}>
55
+ <Switch toggleSize="s" label="Переключатель" defaultChecked />
56
+ <Switch toggleSize="l" label="Переключатель" defaultChecked />
57
+ </div>
22
58
  );
23
59
  }
24
60
  ```
@@ -11,11 +11,22 @@ var tokens = exports.tokens = {
11
11
  fontWeight: '--plasma-switch-font-weight',
12
12
  letterSpacing: '--plasma-switch-letter-spacing',
13
13
  lineHeight: '--plasma-switch-line-height',
14
+ /* Токены description */
15
+ descriptionFontFamily: '--plasma-switch-description-font-family',
16
+ descriptionFontStyle: '--plasma-switch-description-font-style',
17
+ descriptionFontSize: '--plasma-switch-description-font-size',
18
+ descriptionFontWeight: '--plasma-switch-description-font-weight',
19
+ descriptionLetterSpacing: '--plasma-switch-description-letter-spacing',
20
+ descriptionLineHeight: '--plasma-switch-description-line-height',
14
21
  /* Цвет подписи */
15
22
  labelColor: '--plasma-switch__label-color',
16
23
  labelOffset: '--plasma-switch__label-offset',
24
+ /* Цвет описания */
25
+ descriptionColor: '--plasma-switch__description-color',
26
+ descriptionOffset: '--plasma-switch__description-offset',
17
27
  /** Прозрачность для всего компонента в состоянии disabled */
18
28
  disabledOpacity: '--plasma-switch-disabled-opacity',
29
+ verticalGap: '--plasma-switch-vertical-gap',
19
30
  trackWidth: '--plasma-switch__track-width',
20
31
  trackHeight: '--plasma-switch__track-height',
21
32
  trackBorderRadius: '--plasma-switch__track-border-radius',
@@ -7,4 +7,4 @@ exports.base = void 0;
7
7
  var _styledComponents = /*#__PURE__*/require("styled-components");
8
8
  var _Switch = /*#__PURE__*/require("../Switch.tokens");
9
9
  var _Switch2 = /*#__PURE__*/require("../Switch.styles");
10
- var base = exports.base = /*#__PURE__*/(0, _styledComponents.css)(["font-family:var(", ");font-style:var(", ");font-weight:var(", ");letter-spacing:var(", ");line-height:var(", ");font-size:var(", ");", "{flex:0 0 var(", ");width:var(", ");height:var(", ");border-radius:var(", ");&::after{width:var(", ");height:var(", ");border-radius:var(", ");margin:auto var(", ");}}", "{margin:var(", ",0);}:active:not([disabled]) ", "::after{width:calc(var(", ") * var(", ",1));}"], _Switch.tokens.fontFamily, _Switch.tokens.fontStyle, _Switch.tokens.fontWeight, _Switch.tokens.letterSpacing, _Switch.tokens.lineHeight, _Switch.tokens.fontSize, _Switch2.StyledTrigger, _Switch.tokens.trackWidth, _Switch.tokens.trackWidth, _Switch.tokens.trackHeight, _Switch.tokens.trackBorderRadius, _Switch.tokens.thumbSize, _Switch.tokens.thumbSize, _Switch.tokens.thumbBorderRadius, _Switch.tokens.thumbOffset, _Switch2.StyledLabel, _Switch.tokens.labelOffsetPrivate, _Switch2.StyledTrigger, _Switch.tokens.thumbSize, _Switch.tokens.thumbPressScale);
10
+ var base = exports.base = /*#__PURE__*/(0, _styledComponents.css)(["", "{font-family:var(", ");font-style:var(", ");font-weight:var(", ");letter-spacing:var(", ");line-height:var(", ");font-size:var(", ");}", "{font-family:var(", ");font-style:var(", ");font-weight:var(", ");letter-spacing:var(", ");line-height:var(", ");font-size:var(", ");}", "{margin:var(", ",0);}"], _Switch2.StyledContent, _Switch.tokens.fontFamily, _Switch.tokens.fontStyle, _Switch.tokens.fontWeight, _Switch.tokens.letterSpacing, _Switch.tokens.lineHeight, _Switch.tokens.fontSize, _Switch2.StyledDescription, _Switch.tokens.descriptionFontFamily, _Switch.tokens.descriptionFontStyle, _Switch.tokens.descriptionFontWeight, _Switch.tokens.descriptionLetterSpacing, _Switch.tokens.descriptionLineHeight, _Switch.tokens.descriptionFontSize, _Switch2.StyledLabel, _Switch.tokens.labelOffsetPrivate);
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.base = void 0;
7
+ var _styledComponents = /*#__PURE__*/require("styled-components");
8
+ var _Switch = /*#__PURE__*/require("../Switch.tokens");
9
+ var _Switch2 = /*#__PURE__*/require("../Switch.styles");
10
+ var base = exports.base = /*#__PURE__*/(0, _styledComponents.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));}"], _Switch2.StyledTrigger, _Switch.tokens.trackWidth, _Switch.tokens.trackWidth, _Switch.tokens.trackHeight, _Switch.tokens.trackBorderRadius, _Switch.tokens.thumbSize, _Switch.tokens.thumbSize, _Switch.tokens.thumbBorderRadius, _Switch.tokens.thumbOffset, _Switch2.StyledTrigger, _Switch.tokens.thumbSize, _Switch.tokens.thumbPressScale);
@@ -7,4 +7,4 @@ exports.base = void 0;
7
7
  var _styledComponents = /*#__PURE__*/require("styled-components");
8
8
  var _Switch = /*#__PURE__*/require("../Switch.tokens");
9
9
  var _Switch2 = /*#__PURE__*/require("../Switch.styles");
10
- var base = exports.base = /*#__PURE__*/(0, _styledComponents.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(", "));}"], _Switch2.StyledTrigger, _Switch.tokens.trackBackgroundColorOff, _Switch2.StyledInput, _Switch2.StyledTrigger, _Switch.tokens.trackBackgroundColorOffHover, _Switch.tokens.trackBackgroundColorOff, _Switch2.StyledInput, _Switch2.StyledTrigger, _Switch.tokens.trackBackgroundColorOn, _Switch2.StyledInput, _Switch2.StyledTrigger, _Switch.tokens.trackBackgroundColorOnHover, _Switch.tokens.trackBackgroundColorOn, _Switch2.StyledTrigger, _Switch.tokens.thumbBackgroundColor, _Switch.tokens.thumbBoxShadow, _Switch2.StyledInput, _Switch2.StyledTrigger, _Switch.tokens.thumbBoxShadowOn, _Switch.tokens.thumbBoxShadow);
10
+ var base = exports.base = /*#__PURE__*/(0, _styledComponents.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(", ");}"], _Switch2.StyledTrigger, _Switch.tokens.trackBackgroundColorOff, _Switch2.StyledInput, _Switch2.StyledTrigger, _Switch.tokens.trackBackgroundColorOffHover, _Switch.tokens.trackBackgroundColorOff, _Switch2.StyledInput, _Switch2.StyledTrigger, _Switch.tokens.trackBackgroundColorOn, _Switch2.StyledInput, _Switch2.StyledTrigger, _Switch.tokens.trackBackgroundColorOnHover, _Switch.tokens.trackBackgroundColorOn, _Switch2.StyledTrigger, _Switch.tokens.thumbBackgroundColor, _Switch.tokens.thumbBoxShadow, _Switch2.StyledInput, _Switch2.StyledTrigger, _Switch.tokens.thumbBoxShadowOn, _Switch.tokens.thumbBoxShadow, _Switch2.StyledLabel, _Switch.tokens.labelColor, _Switch2.StyledDescription, _Switch.tokens.descriptionColor);
@@ -10,15 +10,22 @@ var config = exports.config = {
10
10
  defaults: {
11
11
  view: 'default',
12
12
  size: 'm',
13
+ toggleSize: 'l',
13
14
  labelPosition: 'before',
14
15
  focused: 'true'
15
16
  },
16
17
  variations: {
17
18
  size: {
18
- m: /*#__PURE__*/(0, _styledComponents.css)(["", ":var(--plasma-typo-body1-font-family);", ":var(--plasma-typo-body1-font-style);", ":var(--plasma-typo-body1-font-weight);", ":var(--plasma-typo-body1-font-weight);", ":var(--plasma-typo-body1-line-height);", ":var(--plasma-typo-body1-font-size);", ":var(--plasma-typo-body1-letter-spacing);", ":2.75rem;", ":1.75rem;", ":calc(var(", ") / 2);", ":1.5rem;", ":calc(var(", ") / 2);", ":0.125rem;", ":1.25;", ":0.75rem;"], _Switch.switchTokens.fontFamily, _Switch.switchTokens.fontStyle, _Switch.switchTokens.fontWeight, _Switch.switchTokens.fontWeight, _Switch.switchTokens.lineHeight, _Switch.switchTokens.fontSize, _Switch.switchTokens.letterSpacing, _Switch.switchTokens.trackWidth, _Switch.switchTokens.trackHeight, _Switch.switchTokens.trackBorderRadius, _Switch.switchTokens.trackHeight, _Switch.switchTokens.thumbSize, _Switch.switchTokens.thumbBorderRadius, _Switch.switchTokens.thumbSize, _Switch.switchTokens.thumbOffset, _Switch.switchTokens.thumbPressScale, _Switch.switchTokens.labelOffset)
19
+ s: /*#__PURE__*/(0, _styledComponents.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;"], _Switch.switchTokens.fontFamily, _Switch.switchTokens.fontStyle, _Switch.switchTokens.fontWeight, _Switch.switchTokens.lineHeight, _Switch.switchTokens.fontSize, _Switch.switchTokens.letterSpacing, _Switch.switchTokens.descriptionFontFamily, _Switch.switchTokens.descriptionFontStyle, _Switch.switchTokens.descriptionFontWeight, _Switch.switchTokens.descriptionLineHeight, _Switch.switchTokens.descriptionFontSize, _Switch.switchTokens.descriptionLetterSpacing, _Switch.switchTokens.verticalGap, _Switch.switchTokens.labelOffset),
20
+ m: /*#__PURE__*/(0, _styledComponents.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;"], _Switch.switchTokens.fontFamily, _Switch.switchTokens.fontStyle, _Switch.switchTokens.fontWeight, _Switch.switchTokens.lineHeight, _Switch.switchTokens.fontSize, _Switch.switchTokens.letterSpacing, _Switch.switchTokens.descriptionFontFamily, _Switch.switchTokens.descriptionFontStyle, _Switch.switchTokens.descriptionFontWeight, _Switch.switchTokens.descriptionLineHeight, _Switch.switchTokens.descriptionFontSize, _Switch.switchTokens.descriptionLetterSpacing, _Switch.switchTokens.verticalGap, _Switch.switchTokens.labelOffset),
21
+ l: /*#__PURE__*/(0, _styledComponents.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;"], _Switch.switchTokens.fontFamily, _Switch.switchTokens.fontStyle, _Switch.switchTokens.fontWeight, _Switch.switchTokens.lineHeight, _Switch.switchTokens.fontSize, _Switch.switchTokens.letterSpacing, _Switch.switchTokens.descriptionFontFamily, _Switch.switchTokens.descriptionFontStyle, _Switch.switchTokens.descriptionFontWeight, _Switch.switchTokens.descriptionLineHeight, _Switch.switchTokens.descriptionFontSize, _Switch.switchTokens.descriptionLetterSpacing, _Switch.switchTokens.verticalGap, _Switch.switchTokens.labelOffset)
22
+ },
23
+ toggleSize: {
24
+ l: /*#__PURE__*/(0, _styledComponents.css)(["", ":2.75rem;", ":1.75rem;", ":calc(var(", ") / 2);", ":1.5rem;", ":calc(var(", ") / 2);", ":0.125rem;", ":1.25;"], _Switch.switchTokens.trackWidth, _Switch.switchTokens.trackHeight, _Switch.switchTokens.trackBorderRadius, _Switch.switchTokens.trackHeight, _Switch.switchTokens.thumbSize, _Switch.switchTokens.thumbBorderRadius, _Switch.switchTokens.thumbSize, _Switch.switchTokens.thumbOffset, _Switch.switchTokens.thumbPressScale),
25
+ s: /*#__PURE__*/(0, _styledComponents.css)(["", ":2rem;", ":1.25rem;", ":calc(var(", ") / 2);", ":1rem;", ":calc(var(", ") / 2);", ":0.125rem;", ":1.25;"], _Switch.switchTokens.trackWidth, _Switch.switchTokens.trackHeight, _Switch.switchTokens.trackBorderRadius, _Switch.switchTokens.trackHeight, _Switch.switchTokens.thumbSize, _Switch.switchTokens.thumbBorderRadius, _Switch.switchTokens.thumbSize, _Switch.switchTokens.thumbOffset, _Switch.switchTokens.thumbPressScale)
19
26
  },
20
27
  view: {
21
- "default": /*#__PURE__*/(0, _styledComponents.css)(["", ":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);"], _Switch.switchTokens.trackBackgroundColorOn, _Switch.switchTokens.trackBackgroundColorOnHover, _Switch.switchTokens.trackBackgroundColorOff, _Switch.switchTokens.trackBackgroundColorOffHover, _Switch.switchTokens.thumbBackgroundColor, _Switch.switchTokens.thumbBoxShadow)
28
+ "default": /*#__PURE__*/(0, _styledComponents.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);"], _Switch.switchTokens.labelColor, _Switch.switchTokens.descriptionColor, _Switch.switchTokens.trackBackgroundColorOn, _Switch.switchTokens.trackBackgroundColorOnHover, _Switch.switchTokens.trackBackgroundColorOff, _Switch.switchTokens.trackBackgroundColorOffHover, _Switch.switchTokens.thumbBackgroundColor, _Switch.switchTokens.thumbBoxShadow)
22
29
  },
23
30
  disabled: {
24
31
  "true": /*#__PURE__*/(0, _styledComponents.css)(["", ":0.4;"], _Switch.switchTokens.disabledOpacity)
@@ -18,7 +18,7 @@ const meta: Meta<SwitchProps> = {
18
18
  decorators: [WithTheme],
19
19
  component: Switch,
20
20
  argTypes: {
21
- ...argTypesFromConfig(mergeConfig(switchConfig, config), ['size', 'view', 'focused']),
21
+ ...argTypesFromConfig(mergeConfig(switchConfig, config), ['view', 'focused']),
22
22
  labelPosition: {
23
23
  options: ['before', 'after'],
24
24
  control: { type: 'select' },
@@ -26,6 +26,7 @@ const meta: Meta<SwitchProps> = {
26
26
  },
27
27
  args: {
28
28
  label: 'Label',
29
+ description: 'Description',
29
30
  labelPosition: 'before',
30
31
  },
31
32
  };
@@ -64,5 +65,10 @@ const StoryDefault = (args: SwitchProps) => {
64
65
  };
65
66
 
66
67
  export const Default: StoryObj<SwitchProps> = {
68
+ args: {
69
+ size: 'm',
70
+ toggleSize: 'l',
71
+ disabled: false,
72
+ },
67
73
  render: (args) => <StoryDefault {...args} />,
68
74
  };
@@ -10,15 +10,22 @@ var config = exports.config = {
10
10
  defaults: {
11
11
  view: 'default',
12
12
  size: 'm',
13
+ toggleSize: 'l',
13
14
  labelPosition: 'before',
14
15
  focused: 'true'
15
16
  },
16
17
  variations: {
17
18
  size: {
18
- m: /*#__PURE__*/(0, _styledComponents.css)(["", ":var(--plasma-typo-body1-font-family);", ":var(--plasma-typo-body1-font-style);", ":var(--plasma-typo-body1-font-weight);", ":var(--plasma-typo-body1-font-weight);", ":var(--plasma-typo-body1-line-height);", ":var(--plasma-typo-body1-font-size);", ":var(--plasma-typo-body1-letter-spacing);", ":2.75rem;", ":1.75rem;", ":calc(var(", ") / 2);", ":1.5rem;", ":calc(var(", ") / 2);", ":0.125rem;", ":1.25;", ":0.75rem;"], _Switch.switchTokens.fontFamily, _Switch.switchTokens.fontStyle, _Switch.switchTokens.fontWeight, _Switch.switchTokens.fontWeight, _Switch.switchTokens.lineHeight, _Switch.switchTokens.fontSize, _Switch.switchTokens.letterSpacing, _Switch.switchTokens.trackWidth, _Switch.switchTokens.trackHeight, _Switch.switchTokens.trackBorderRadius, _Switch.switchTokens.trackHeight, _Switch.switchTokens.thumbSize, _Switch.switchTokens.thumbBorderRadius, _Switch.switchTokens.thumbSize, _Switch.switchTokens.thumbOffset, _Switch.switchTokens.thumbPressScale, _Switch.switchTokens.labelOffset)
19
+ s: /*#__PURE__*/(0, _styledComponents.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;"], _Switch.switchTokens.fontFamily, _Switch.switchTokens.fontStyle, _Switch.switchTokens.fontWeight, _Switch.switchTokens.lineHeight, _Switch.switchTokens.fontSize, _Switch.switchTokens.letterSpacing, _Switch.switchTokens.descriptionFontFamily, _Switch.switchTokens.descriptionFontStyle, _Switch.switchTokens.descriptionFontWeight, _Switch.switchTokens.descriptionLineHeight, _Switch.switchTokens.descriptionFontSize, _Switch.switchTokens.descriptionLetterSpacing, _Switch.switchTokens.verticalGap, _Switch.switchTokens.labelOffset),
20
+ m: /*#__PURE__*/(0, _styledComponents.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;"], _Switch.switchTokens.fontFamily, _Switch.switchTokens.fontStyle, _Switch.switchTokens.fontWeight, _Switch.switchTokens.lineHeight, _Switch.switchTokens.fontSize, _Switch.switchTokens.letterSpacing, _Switch.switchTokens.descriptionFontFamily, _Switch.switchTokens.descriptionFontStyle, _Switch.switchTokens.descriptionFontWeight, _Switch.switchTokens.descriptionLineHeight, _Switch.switchTokens.descriptionFontSize, _Switch.switchTokens.descriptionLetterSpacing, _Switch.switchTokens.verticalGap, _Switch.switchTokens.labelOffset),
21
+ l: /*#__PURE__*/(0, _styledComponents.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;"], _Switch.switchTokens.fontFamily, _Switch.switchTokens.fontStyle, _Switch.switchTokens.fontWeight, _Switch.switchTokens.lineHeight, _Switch.switchTokens.fontSize, _Switch.switchTokens.letterSpacing, _Switch.switchTokens.descriptionFontFamily, _Switch.switchTokens.descriptionFontStyle, _Switch.switchTokens.descriptionFontWeight, _Switch.switchTokens.descriptionLineHeight, _Switch.switchTokens.descriptionFontSize, _Switch.switchTokens.descriptionLetterSpacing, _Switch.switchTokens.verticalGap, _Switch.switchTokens.labelOffset)
22
+ },
23
+ toggleSize: {
24
+ l: /*#__PURE__*/(0, _styledComponents.css)(["", ":2.75rem;", ":1.75rem;", ":calc(var(", ") / 2);", ":1.5rem;", ":calc(var(", ") / 2);", ":0.125rem;", ":1.25;"], _Switch.switchTokens.trackWidth, _Switch.switchTokens.trackHeight, _Switch.switchTokens.trackBorderRadius, _Switch.switchTokens.trackHeight, _Switch.switchTokens.thumbSize, _Switch.switchTokens.thumbBorderRadius, _Switch.switchTokens.thumbSize, _Switch.switchTokens.thumbOffset, _Switch.switchTokens.thumbPressScale),
25
+ s: /*#__PURE__*/(0, _styledComponents.css)(["", ":2rem;", ":1.25rem;", ":calc(var(", ") / 2);", ":1rem;", ":calc(var(", ") / 2);", ":0.125rem;", ":1.25;"], _Switch.switchTokens.trackWidth, _Switch.switchTokens.trackHeight, _Switch.switchTokens.trackBorderRadius, _Switch.switchTokens.trackHeight, _Switch.switchTokens.thumbSize, _Switch.switchTokens.thumbBorderRadius, _Switch.switchTokens.thumbSize, _Switch.switchTokens.thumbOffset, _Switch.switchTokens.thumbPressScale)
19
26
  },
20
27
  view: {
21
- "default": /*#__PURE__*/(0, _styledComponents.css)(["", ":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);"], _Switch.switchTokens.trackBackgroundColorOn, _Switch.switchTokens.trackBackgroundColorOnHover, _Switch.switchTokens.trackBackgroundColorOff, _Switch.switchTokens.trackBackgroundColorOffHover, _Switch.switchTokens.thumbBackgroundColor, _Switch.switchTokens.thumbBoxShadow)
28
+ "default": /*#__PURE__*/(0, _styledComponents.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);"], _Switch.switchTokens.labelColor, _Switch.switchTokens.descriptionColor, _Switch.switchTokens.trackBackgroundColorOn, _Switch.switchTokens.trackBackgroundColorOnHover, _Switch.switchTokens.trackBackgroundColorOff, _Switch.switchTokens.trackBackgroundColorOffHover, _Switch.switchTokens.thumbBackgroundColor, _Switch.switchTokens.thumbBoxShadow)
22
29
  },
23
30
  disabled: {
24
31
  "true": /*#__PURE__*/(0, _styledComponents.css)(["", ":0.4;"], _Switch.switchTokens.disabledOpacity)
@@ -17,9 +17,17 @@ const meta: Meta<SwitchProps> = {
17
17
  title: 'plasma_web/Switch',
18
18
  decorators: [WithTheme],
19
19
  component: Switch,
20
- argTypes: argTypesFromConfig(mergeConfig(switchConfig, config), ['size', 'view', 'focused']),
20
+ argTypes: {
21
+ ...argTypesFromConfig(mergeConfig(switchConfig, config), ['view', 'focused']),
22
+ labelPosition: {
23
+ options: ['before', 'after'],
24
+ control: { type: 'select' },
25
+ },
26
+ },
21
27
  args: {
22
28
  label: 'Label',
29
+ description: 'Description',
30
+ labelPosition: 'before',
23
31
  },
24
32
  };
25
33
 
@@ -57,5 +65,10 @@ const StoryDefault = (args: SwitchProps) => {
57
65
  };
58
66
 
59
67
  export const Default: StoryObj<SwitchProps> = {
68
+ args: {
69
+ size: 'm',
70
+ toggleSize: 'l',
71
+ disabled: false,
72
+ },
60
73
  render: (args) => <StoryDefault {...args} />,
61
74
  };
@@ -1,4 +1,4 @@
1
- var _excluded = ["items", "children", "placement", "offset", "closeOnOverlayClick", "onToggle", "size", "view", "itemRole", "className", "listWidth", "listHeight", "listOverflow", "closeOnSelect", "onHover", "onItemSelect", "onItemClick", "trigger", "variant", "hasArrow", "alwaysOpened", "portal"];
1
+ var _excluded = ["items", "children", "placement", "offset", "closeOnOverlayClick", "onToggle", "size", "view", "itemRole", "className", "listWidth", "listHeight", "listOverflow", "closeOnSelect", "onHover", "onItemSelect", "onItemClick", "trigger", "variant", "hasArrow", "portal"];
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."); }
@@ -57,8 +57,6 @@ export var dropdownRoot = function dropdownRoot(Root) {
57
57
  variant = _ref$variant === void 0 ? 'normal' : _ref$variant,
58
58
  _ref$hasArrow = _ref.hasArrow,
59
59
  hasArrow = _ref$hasArrow === void 0 ? true : _ref$hasArrow,
60
- _ref$alwaysOpened = _ref.alwaysOpened,
61
- alwaysOpened = _ref$alwaysOpened === void 0 ? false : _ref$alwaysOpened,
62
60
  portal = _ref.portal,
63
61
  rest = _objectWithoutProperties(_ref, _excluded);
64
62
  var _useReducer = useReducer(pathReducer, []),
@@ -79,7 +77,7 @@ export var dropdownRoot = function dropdownRoot(Root) {
79
77
 
80
78
  // Логика работы при клике за пределами выпадающего списка
81
79
  var targetRef = useOutsideClick(function (event) {
82
- if (!isCurrentListOpen || !closeOnOverlayClick || alwaysOpened) {
80
+ if (!isCurrentListOpen || !closeOnOverlayClick) {
83
81
  return;
84
82
  }
85
83
  dispatchPath({
@@ -93,7 +91,7 @@ export var dropdownRoot = function dropdownRoot(Root) {
93
91
  }
94
92
  }, floatingPopoverRef);
95
93
  var handleGlobalToggle = function handleGlobalToggle(opened, event) {
96
- if (alwaysOpened || opened) {
94
+ if (opened) {
97
95
  dispatchPath({
98
96
  type: 'opened_first_level'
99
97
  });
@@ -122,7 +120,7 @@ export var dropdownRoot = function dropdownRoot(Root) {
122
120
  onItemClick: onItemClick
123
121
  }),
124
122
  onKeyDown = _useKeyNavigation.onKeyDown;
125
- var isCurrentListOpen = alwaysOpened || Boolean(path[0]);
123
+ var isCurrentListOpen = Boolean(path[0]);
126
124
  return /*#__PURE__*/React.createElement(Context.Provider, {
127
125
  value: {
128
126
  focusedPath: focusedPath,
@@ -1,25 +1,28 @@
1
1
  var _StyledTrigger;
2
- var _excluded = ["size", "view", "focused", "outlined", "disabled", "labelPosition", "label", "id", "style", "className", "checked", "pressed", "defaultChecked"];
2
+ var _excluded = ["size", "toggleSize", "view", "focused", "outlined", "disabled", "labelPosition", "label", "description", "id", "style", "className", "checked", "pressed", "defaultChecked"];
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 _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; }
5
5
  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; }
6
6
  import React, { forwardRef } from 'react';
7
7
  import { base as sizeCSS } from '../Switch/_size/base';
8
+ import { base as toggleSizeCSS } from '../Switch/_toggleSize/base';
8
9
  import { base as viewCSS } from '../Switch/_view/base';
9
10
  import { base as focusedCSS } from '../Switch/_focused/base';
10
11
  import { base as disabledCSS } from '../Switch/_disabled/base';
11
12
  import { cx } from '../../utils';
12
- import { StyledInput, StyledLabel, StyledTrigger, base } from './Switch.styles';
13
+ import { StyledContent, StyledDescription, StyledInput, StyledLabel, StyledTrigger, base } from './Switch.styles';
13
14
  import { classes } from './Switch.tokens';
14
15
  export var switchRoot = function switchRoot(Root) {
15
16
  return /*#__PURE__*/forwardRef(function (props, ref) {
16
17
  var size = props.size,
18
+ toggleSize = props.toggleSize,
17
19
  view = props.view,
18
20
  focused = props.focused,
19
21
  outlined = props.outlined,
20
22
  disabled = props.disabled,
21
23
  labelPosition = props.labelPosition,
22
24
  label = props.label,
25
+ description = props.description,
23
26
  id = props.id,
24
27
  style = props.style,
25
28
  className = props.className,
@@ -31,12 +34,15 @@ export var switchRoot = function switchRoot(Root) {
31
34
  return /*#__PURE__*/React.createElement(Root, {
32
35
  view: view,
33
36
  size: size,
37
+ toggleSize: toggleSize,
34
38
  disabled: disabled,
35
39
  focused: focused !== null && focused !== void 0 ? focused : outlined,
36
40
  labelPosition: labelPosition,
37
41
  id: id,
38
42
  style: style,
39
- className: cx(className, classes["".concat(labelPosition, "SwitchLabelPosition")])
43
+ className: cx(className)
44
+ }, /*#__PURE__*/React.createElement(StyledContent, {
45
+ className: cx(classes["".concat(labelPosition, "SwitchLabelPosition")])
40
46
  }, /*#__PURE__*/React.createElement(StyledInput, _extends({}, rest, {
41
47
  ref: ref,
42
48
  role: "switch",
@@ -49,7 +55,7 @@ export var switchRoot = function switchRoot(Root) {
49
55
  tabIndex: -1
50
56
  }, label), _StyledTrigger || (_StyledTrigger = /*#__PURE__*/React.createElement(StyledTrigger, {
51
57
  "aria-hidden": true
52
- })));
58
+ }))), description && /*#__PURE__*/React.createElement(StyledDescription, null, description));
53
59
  });
54
60
  };
55
61
  export var switchConfig = {
@@ -64,6 +70,9 @@ export var switchConfig = {
64
70
  view: {
65
71
  css: viewCSS
66
72
  },
73
+ toggleSize: {
74
+ css: toggleSizeCSS
75
+ },
67
76
  disabled: {
68
77
  css: disabledCSS,
69
78
  attrs: true
@@ -2,13 +2,19 @@ import styled from 'styled-components';
2
2
  import { css } from 'styled-components';
3
3
  import { applyEllipsis } from '../../mixins';
4
4
  import { classes, tokens } from './Switch.tokens';
5
- export var base = /*#__PURE__*/css(["position:relative;display:flex;align-items:center;cursor:pointer;-webkit-tap-highlight-color:rgba(0,0,0,0);&:focus{outline:0 none;}&.", "{justify-content:space-between;", ":0 var(", ") 0 0;}&.", "{justify-content:start;flex-direction:row-reverse;", ":0 0 0 var(", ");}"], classes.beforeSwitchLabelPosition, tokens.labelOffsetPrivate, tokens.labelOffset, classes.afterSwitchLabelPosition, tokens.labelOffsetPrivate, tokens.labelOffset);
6
- export var StyledInput = /*#__PURE__*/styled.input.withConfig({
5
+ export var base = /*#__PURE__*/css(["position:relative;display:flex;flex-direction:column;gap:var(", ");cursor:pointer;-webkit-tap-highlight-color:rgba(0,0,0,0);&:focus{outline:0 none;}"], tokens.verticalGap);
6
+ export var StyledContent = /*#__PURE__*/styled.div.withConfig({
7
7
  componentId: "plasma-new-hope__sc-i4fgom-0"
8
+ })(["width:100%;position:relative;display:flex;align-items:center;&.", "{justify-content:space-between;", ":0 var(", ") 0 0;}&.", "{justify-content:start;flex-direction:row-reverse;", ":0 0 0 var(", ");}"], classes.beforeSwitchLabelPosition, tokens.labelOffsetPrivate, tokens.labelOffset, classes.afterSwitchLabelPosition, tokens.labelOffsetPrivate, tokens.labelOffset);
9
+ export var StyledDescription = /*#__PURE__*/styled.div.withConfig({
10
+ componentId: "plasma-new-hope__sc-i4fgom-1"
11
+ })(["position:relative;"]);
12
+ export var StyledInput = /*#__PURE__*/styled.input.withConfig({
13
+ componentId: "plasma-new-hope__sc-i4fgom-2"
8
14
  })(["position:absolute;right:0;margin:0;opacity:0;&:focus{outline:0 none;}"]);
9
15
  export var StyledLabel = /*#__PURE__*/styled.span.withConfig({
10
- componentId: "plasma-new-hope__sc-i4fgom-1"
16
+ componentId: "plasma-new-hope__sc-i4fgom-3"
11
17
  })(["user-select:none;", ""], /*#__PURE__*/applyEllipsis());
12
18
  export var StyledTrigger = /*#__PURE__*/styled.div.withConfig({
13
- componentId: "plasma-new-hope__sc-i4fgom-2"
19
+ componentId: "plasma-new-hope__sc-i4fgom-4"
14
20
  })(["position:relative;display:flex;align-items:center;transition:background-color 0.15s ease-in-out 0.1s;::after{content:'';position:absolute;right:auto;left:0;transition:width 0.15s ease-in-out 0s,left 0.3s ease-in-out 0s,right 0.3s ease-in-out 0s;}", ":checked ~ &::after{right:0;left:auto;}"], StyledInput);
@@ -18,7 +18,43 @@ import { Switch } from '@salutejs/{{ package }}';
18
18
 
19
19
  export function App() {
20
20
  return (
21
- <Switch label="Переключатель" defaultChecked />
21
+ <Switch description="Описание переключателя" label="Переключатель" defaultChecked />
22
+ );
23
+ }
24
+ ```
25
+
26
+ ## Примеры
27
+
28
+ ### Размер Switch
29
+ Размер компонента задается с помощью свойства `size`.
30
+
31
+ ```tsx live
32
+ import React from 'react';
33
+ import { Button } from '@salutejs/{{ package }}';
34
+
35
+ export function App() {
36
+ return (
37
+ <div>
38
+ <Switch size="s" description="Описание переключателя" label="Переключатель" defaultChecked />
39
+ <Switch size="m" description="Описание переключателя" label="Переключатель" defaultChecked />
40
+ <Switch size="l" description="Описание переключателя" label="Переключатель" defaultChecked />
41
+ </div>
42
+ );
43
+ }
44
+ ```
45
+
46
+ Размер переключателя задается с помощью свойства `toggleSize`.
47
+
48
+ ```tsx live
49
+ import React from 'react';
50
+ import { Button } from '@salutejs/{{ package }}';
51
+
52
+ export function App() {
53
+ return (
54
+ <div style=\{{ alignItems: "center" }}>
55
+ <Switch toggleSize="s" label="Переключатель" defaultChecked />
56
+ <Switch toggleSize="l" label="Переключатель" defaultChecked />
57
+ </div>
22
58
  );
23
59
  }
24
60
  ```
@@ -5,11 +5,22 @@ export var tokens = {
5
5
  fontWeight: '--plasma-switch-font-weight',
6
6
  letterSpacing: '--plasma-switch-letter-spacing',
7
7
  lineHeight: '--plasma-switch-line-height',
8
+ /* Токены description */
9
+ descriptionFontFamily: '--plasma-switch-description-font-family',
10
+ descriptionFontStyle: '--plasma-switch-description-font-style',
11
+ descriptionFontSize: '--plasma-switch-description-font-size',
12
+ descriptionFontWeight: '--plasma-switch-description-font-weight',
13
+ descriptionLetterSpacing: '--plasma-switch-description-letter-spacing',
14
+ descriptionLineHeight: '--plasma-switch-description-line-height',
8
15
  /* Цвет подписи */
9
16
  labelColor: '--plasma-switch__label-color',
10
17
  labelOffset: '--plasma-switch__label-offset',
18
+ /* Цвет описания */
19
+ descriptionColor: '--plasma-switch__description-color',
20
+ descriptionOffset: '--plasma-switch__description-offset',
11
21
  /** Прозрачность для всего компонента в состоянии disabled */
12
22
  disabledOpacity: '--plasma-switch-disabled-opacity',
23
+ verticalGap: '--plasma-switch-vertical-gap',
13
24
  trackWidth: '--plasma-switch__track-width',
14
25
  trackHeight: '--plasma-switch__track-height',
15
26
  trackBorderRadius: '--plasma-switch__track-border-radius',
@@ -1,4 +1,4 @@
1
1
  import { css } from 'styled-components';
2
2
  import { tokens } from '../Switch.tokens';
3
- import { StyledLabel, StyledTrigger } from '../Switch.styles';
4
- export var base = /*#__PURE__*/css(["font-family:var(", ");font-style:var(", ");font-weight:var(", ");letter-spacing:var(", ");line-height:var(", ");font-size:var(", ");", "{flex:0 0 var(", ");width:var(", ");height:var(", ");border-radius:var(", ");&::after{width:var(", ");height:var(", ");border-radius:var(", ");margin:auto var(", ");}}", "{margin:var(", ",0);}:active:not([disabled]) ", "::after{width:calc(var(", ") * var(", ",1));}"], tokens.fontFamily, tokens.fontStyle, tokens.fontWeight, tokens.letterSpacing, tokens.lineHeight, tokens.fontSize, StyledTrigger, tokens.trackWidth, tokens.trackWidth, tokens.trackHeight, tokens.trackBorderRadius, tokens.thumbSize, tokens.thumbSize, tokens.thumbBorderRadius, tokens.thumbOffset, StyledLabel, tokens.labelOffsetPrivate, StyledTrigger, tokens.thumbSize, tokens.thumbPressScale);
3
+ import { StyledContent, StyledDescription, StyledLabel } from '../Switch.styles';
4
+ export var base = /*#__PURE__*/css(["", "{font-family:var(", ");font-style:var(", ");font-weight:var(", ");letter-spacing:var(", ");line-height:var(", ");font-size:var(", ");}", "{font-family:var(", ");font-style:var(", ");font-weight:var(", ");letter-spacing:var(", ");line-height:var(", ");font-size:var(", ");}", "{margin:var(", ",0);}"], StyledContent, tokens.fontFamily, tokens.fontStyle, tokens.fontWeight, tokens.letterSpacing, tokens.lineHeight, tokens.fontSize, StyledDescription, tokens.descriptionFontFamily, tokens.descriptionFontStyle, tokens.descriptionFontWeight, tokens.descriptionLetterSpacing, tokens.descriptionLineHeight, tokens.descriptionFontSize, StyledLabel, tokens.labelOffsetPrivate);
@@ -0,0 +1,4 @@
1
+ import { css } from 'styled-components';
2
+ import { tokens } from '../Switch.tokens';
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);
@@ -1,4 +1,4 @@
1
1
  import { css } from 'styled-components';
2
2
  import { tokens } from '../Switch.tokens';
3
- import { StyledTrigger, StyledInput } 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(", "));}"], 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);
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);