@salutejs/plasma-new-hope 0.265.0-canary.1762.13366570528.0 → 0.265.0-dev.0
Sign up to get free protection for your applications and to get access to all the features.
- package/cjs/engines/linaria.js +4 -2
- package/cjs/engines/linaria.js.map +1 -1
- package/cjs/engines/utils.js +22 -0
- package/cjs/engines/utils.js.map +1 -1
- package/emotion/cjs/components/Checkbox/Checkbox.template-doc.mdx +0 -6
- package/emotion/cjs/engines/emotion.js +9 -3
- package/emotion/cjs/engines/utils.js +26 -1
- package/emotion/cjs/examples/plasma_b2c/components/Checkbox/Checkbox.config.js +12 -19
- package/emotion/cjs/examples/plasma_b2c/components/Checkbox/Checkbox.stories.tsx +5 -15
- package/emotion/cjs/examples/plasma_web/components/Checkbox/Checkbox.config.js +12 -19
- package/emotion/cjs/examples/plasma_web/components/Checkbox/Checkbox.stories.tsx +5 -15
- package/emotion/es/components/Checkbox/Checkbox.template-doc.mdx +0 -6
- package/emotion/es/engines/emotion.js +10 -4
- package/emotion/es/engines/utils.js +25 -0
- package/emotion/es/examples/plasma_b2c/components/Checkbox/Checkbox.config.js +12 -19
- package/emotion/es/examples/plasma_b2c/components/Checkbox/Checkbox.stories.tsx +5 -15
- package/emotion/es/examples/plasma_web/components/Checkbox/Checkbox.config.js +12 -19
- package/emotion/es/examples/plasma_web/components/Checkbox/Checkbox.stories.tsx +5 -15
- package/es/engines/linaria.js +5 -3
- package/es/engines/linaria.js.map +1 -1
- package/es/engines/utils.js +23 -2
- package/es/engines/utils.js.map +1 -1
- package/package.json +2 -2
- package/styled-components/cjs/components/Checkbox/Checkbox.template-doc.mdx +0 -6
- package/styled-components/cjs/engines/styled-components.js +9 -3
- package/styled-components/cjs/engines/utils.js +26 -1
- package/styled-components/cjs/examples/plasma_b2c/components/Checkbox/Checkbox.config.js +1 -8
- package/styled-components/cjs/examples/plasma_b2c/components/Checkbox/Checkbox.stories.tsx +5 -15
- package/styled-components/cjs/examples/plasma_web/components/Checkbox/Checkbox.config.js +1 -8
- package/styled-components/cjs/examples/plasma_web/components/Checkbox/Checkbox.stories.tsx +5 -15
- package/styled-components/es/components/Checkbox/Checkbox.template-doc.mdx +0 -6
- package/styled-components/es/engines/styled-components.js +10 -4
- package/styled-components/es/engines/utils.js +25 -0
- package/styled-components/es/examples/plasma_b2c/components/Checkbox/Checkbox.config.js +1 -8
- package/styled-components/es/examples/plasma_b2c/components/Checkbox/Checkbox.stories.tsx +5 -15
- package/styled-components/es/examples/plasma_web/components/Checkbox/Checkbox.config.js +1 -8
- package/styled-components/es/examples/plasma_web/components/Checkbox/Checkbox.stories.tsx +5 -15
- package/types/engines/emotion.d.ts.map +1 -1
- package/types/engines/linaria.d.ts.map +1 -1
- package/types/engines/styled-components.d.ts.map +1 -1
- package/types/engines/types.d.ts +4 -0
- package/types/engines/types.d.ts.map +1 -1
- package/types/engines/utils.d.ts +2 -1
- package/types/engines/utils.d.ts.map +1 -1
- package/types/examples/plasma_b2c/components/Checkbox/Checkbox.config.d.ts +1 -1
- package/types/examples/plasma_b2c/components/Checkbox/Checkbox.config.d.ts.map +1 -1
- package/types/examples/plasma_b2c/components/Checkbox/Checkbox.d.ts +1 -1
- package/types/examples/plasma_web/components/Checkbox/Checkbox.config.d.ts +1 -1
- package/types/examples/plasma_web/components/Checkbox/Checkbox.config.d.ts.map +1 -1
- package/types/examples/plasma_web/components/Checkbox/Checkbox.d.ts +1 -1
@@ -3,9 +3,12 @@ import type { ComponentProps } from 'react';
|
|
3
3
|
import type { StoryObj, Meta } from '@storybook/react';
|
4
4
|
import { action } from '@storybook/addon-actions';
|
5
5
|
|
6
|
-
import {
|
6
|
+
import { checkboxConfig } from '../../../../components/Checkbox';
|
7
|
+
import { mergeConfig } from '../../../../engines';
|
8
|
+
import { WithTheme, argTypesFromConfig } from '../../../_helpers';
|
7
9
|
import { Link } from '../Link/Link';
|
8
10
|
|
11
|
+
import { config } from './Checkbox.config';
|
9
12
|
import { Checkbox } from './Checkbox';
|
10
13
|
|
11
14
|
const onChange = action('onChange');
|
@@ -16,20 +19,7 @@ const meta: Meta<typeof Checkbox> = {
|
|
16
19
|
title: 'web/Data Entry/Checkbox',
|
17
20
|
decorators: [WithTheme],
|
18
21
|
component: Checkbox,
|
19
|
-
argTypes:
|
20
|
-
view: {
|
21
|
-
options: ['accent'],
|
22
|
-
control: {
|
23
|
-
type: 'radio',
|
24
|
-
},
|
25
|
-
},
|
26
|
-
size: {
|
27
|
-
options: ['m', 's'],
|
28
|
-
control: {
|
29
|
-
type: 'radio',
|
30
|
-
},
|
31
|
-
},
|
32
|
-
},
|
22
|
+
argTypes: argTypesFromConfig(mergeConfig(checkboxConfig, config)),
|
33
23
|
args: {
|
34
24
|
view: 'accent',
|
35
25
|
size: 'm',
|
package/es/engines/linaria.js
CHANGED
@@ -2,14 +2,15 @@ import { objectWithoutProperties as _objectWithoutProperties, toConsumableArray
|
|
2
2
|
import React, { forwardRef } from 'react';
|
3
3
|
import { cx } from '@linaria/core';
|
4
4
|
import 'focus-visible';
|
5
|
-
import { getStaticVariants, getDynamicVariants } from './utils.js';
|
5
|
+
import { getIntersectionStyles, getStaticVariants, getDynamicVariants } from './utils.js';
|
6
6
|
|
7
7
|
var _excluded = ["className"];
|
8
8
|
/* eslint-disable no-underscore-dangle */
|
9
9
|
var _component = function _component(componentConfig) {
|
10
10
|
var tag = componentConfig.tag,
|
11
11
|
base = componentConfig.base,
|
12
|
-
name = componentConfig.name
|
12
|
+
name = componentConfig.name,
|
13
|
+
intersections = componentConfig.intersections;
|
13
14
|
var staticVariants = getStaticVariants(componentConfig);
|
14
15
|
var dynamicVariants = getDynamicVariants(componentConfig);
|
15
16
|
var Root = tag;
|
@@ -17,7 +18,8 @@ var _component = function _component(componentConfig) {
|
|
17
18
|
var className = props.className,
|
18
19
|
rest = _objectWithoutProperties(props, _excluded);
|
19
20
|
var variants = dynamicVariants(rest);
|
20
|
-
var
|
21
|
+
var intersectionStyles = getIntersectionStyles(rest, intersections);
|
22
|
+
var cls = cx.apply(void 0, [className, base].concat(_toConsumableArray(staticVariants), _toConsumableArray(variants), _toConsumableArray(intersectionStyles)));
|
21
23
|
|
22
24
|
// styled-components do it inside
|
23
25
|
// filter props
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"linaria.js","sources":["../../src/engines/linaria.tsx"],"sourcesContent":["import React, { forwardRef } from 'react';\nimport { cx } from '@linaria/core';\n\n// TODO: #1008 Избавиться от импортов и переделать addFocus\nimport 'focus-visible';\nimport { getStaticVariants, getDynamicVariants } from './utils';\nimport type { ComponentConfig, HTMLAnyAttributes } from './types';\n\n/* eslint-disable no-underscore-dangle */\nexport const _component = (componentConfig: ComponentConfig) => {\n const { tag, base, name } = componentConfig;\n const staticVariants = getStaticVariants(componentConfig);\n const dynamicVariants = getDynamicVariants(componentConfig);\n const Root = tag as React.ElementType;\n\n const component = forwardRef<HTMLElement, HTMLAnyAttributes>((props, ref) => {\n const { className, ...rest } = props;\n const variants = dynamicVariants(rest);\n const cls = cx(className, base as string, ...(staticVariants as string[]), ...variants);\n\n // styled-components do it inside\n // filter props\n const baseProps: HTMLAnyAttributes = {};\n for (const key in rest) {\n if (!(key in componentConfig.variations)) {\n baseProps[key] = rest[key];\n }\n }\n\n baseProps.ref = ref;\n\n // styled-components do it inside\n // add props that should be attr( disabled for example)\n const htmlAttrs: HTMLAnyAttributes = {};\n for (const key in componentConfig.variations || {}) {\n if (key in rest) {\n const variant = componentConfig.variations[key];\n\n const { attrs } = variant;\n if (typeof attrs === 'boolean') {\n htmlAttrs[key] = rest[key];\n }\n }\n }\n\n return <Root className={cls} {...htmlAttrs} {...baseProps} />;\n });\n if (name) {\n component.displayName = name;\n }\n return component;\n};\n"],"names":["_component","componentConfig","tag","base","name","staticVariants","getStaticVariants","dynamicVariants","getDynamicVariants","Root","component","forwardRef","props","ref","className","rest","_objectWithoutProperties","_excluded","variants","cls","cx","apply","concat","_toConsumableArray","baseProps","key","variations","htmlAttrs","variant","attrs","React","createElement","_extends","displayName"],"mappings":";;;;;;;AAQA;IACaA,UAAU,GAAG,SAAbA,UAAUA,CAAIC,eAAgC,EAAK;AAC5D,EAAA,IAAQC,GAAG,
|
1
|
+
{"version":3,"file":"linaria.js","sources":["../../src/engines/linaria.tsx"],"sourcesContent":["import React, { forwardRef } from 'react';\nimport { cx } from '@linaria/core';\n\n// TODO: #1008 Избавиться от импортов и переделать addFocus\nimport 'focus-visible';\nimport { getStaticVariants, getDynamicVariants, getIntersectionStyles } from './utils';\nimport type { ComponentConfig, HTMLAnyAttributes } from './types';\n\n/* eslint-disable no-underscore-dangle */\nexport const _component = (componentConfig: ComponentConfig) => {\n const { tag, base, name, intersections } = componentConfig;\n const staticVariants = getStaticVariants(componentConfig);\n const dynamicVariants = getDynamicVariants(componentConfig);\n\n const Root = tag as React.ElementType;\n\n const component = forwardRef<HTMLElement, HTMLAnyAttributes>((props, ref) => {\n const { className, ...rest } = props;\n const variants = dynamicVariants(rest);\n const intersectionStyles = getIntersectionStyles(rest, intersections);\n\n const cls = cx(className, base as string, ...(staticVariants as string[]), ...variants, ...intersectionStyles);\n\n // styled-components do it inside\n // filter props\n const baseProps: HTMLAnyAttributes = {};\n for (const key in rest) {\n if (!(key in componentConfig.variations)) {\n baseProps[key] = rest[key];\n }\n }\n\n baseProps.ref = ref;\n\n // styled-components do it inside\n // add props that should be attr( disabled for example)\n const htmlAttrs: HTMLAnyAttributes = {};\n for (const key in componentConfig.variations || {}) {\n if (key in rest) {\n const variant = componentConfig.variations[key];\n\n const { attrs } = variant;\n if (typeof attrs === 'boolean') {\n htmlAttrs[key] = rest[key];\n }\n }\n }\n\n return <Root className={cls} {...htmlAttrs} {...baseProps} />;\n });\n if (name) {\n component.displayName = name;\n }\n return component;\n};\n"],"names":["_component","componentConfig","tag","base","name","intersections","staticVariants","getStaticVariants","dynamicVariants","getDynamicVariants","Root","component","forwardRef","props","ref","className","rest","_objectWithoutProperties","_excluded","variants","intersectionStyles","getIntersectionStyles","cls","cx","apply","concat","_toConsumableArray","baseProps","key","variations","htmlAttrs","variant","attrs","React","createElement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AAS,CAACC,GAAG,CAAC,GAAGZ,IAAI,CAACY,GAAG,CAAC,CAAA;AAC9B,OAAA;AACJ,KAAA;IAEAD,SAAS,CAACb,GAAG,GAAGA,GAAG,CAAA;;AAEnB;AACA;IACA,IAAMgB,SAA4B,GAAG,EAAE,CAAA;IACvC,KAAK,IAAMF,IAAG,IAAI3B,eAAe,CAAC4B,UAAU,IAAI,EAAE,EAAE;MAChD,IAAID,IAAG,IAAIZ,IAAI,EAAE;AACb,QAAA,IAAMe,OAAO,GAAG9B,eAAe,CAAC4B,UAAU,CAACD,IAAG,CAAC,CAAA;AAE/C,QAAA,IAAQI,KAAK,GAAKD,OAAO,CAAjBC,KAAK,CAAA;AACb,QAAA,IAAI,OAAOA,KAAK,KAAK,SAAS,EAAE;AAC5BF,UAAAA,SAAS,CAACF,IAAG,CAAC,GAAGZ,IAAI,CAACY,IAAG,CAAC,CAAA;AAC9B,SAAA;AACJ,OAAA;AACJ,KAAA;AAEA,IAAA,oBAAOK,KAAA,CAAAC,aAAA,CAACxB,IAAI,EAAAyB,QAAA,CAAA;AAACpB,MAAAA,SAAS,EAAEO,GAAAA;AAAI,KAAA,EAAKQ,SAAS,EAAMH,SAAS,CAAG,CAAC,CAAA;AACjE,GAAC,CAAC,CAAA;AACF,EAAA,IAAIvB,IAAI,EAAE;IACNO,SAAS,CAACyB,WAAW,GAAGhC,IAAI,CAAA;AAChC,GAAA;AACA,EAAA,OAAOO,SAAS,CAAA;AACpB;;;;"}
|
package/es/engines/utils.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { toConsumableArray as _toConsumableArray } from '../_virtual/_rollupPluginBabelHelpers.js';
|
1
|
+
import { slicedToArray as _slicedToArray, toConsumableArray as _toConsumableArray } from '../_virtual/_rollupPluginBabelHelpers.js';
|
2
2
|
|
3
3
|
var getStaticVariants = function getStaticVariants(config) {
|
4
4
|
if (!config.variations) {
|
@@ -30,6 +30,27 @@ var getDynamicVariants = function getDynamicVariants(config) {
|
|
30
30
|
return res;
|
31
31
|
};
|
32
32
|
};
|
33
|
+
var getIntersectionStyles = function getIntersectionStyles(props, intersections) {
|
34
|
+
if (!intersections) {
|
35
|
+
return [];
|
36
|
+
}
|
37
|
+
return intersections.reduce(function (styles, item) {
|
38
|
+
var hasMatchStyle = Object.entries(item).filter(function (_ref) {
|
39
|
+
var _ref2 = _slicedToArray(_ref, 1),
|
40
|
+
key = _ref2[0];
|
41
|
+
return key !== 'style';
|
42
|
+
}).every(function (_ref3) {
|
43
|
+
var _ref4 = _slicedToArray(_ref3, 2),
|
44
|
+
key = _ref4[0],
|
45
|
+
value = _ref4[1];
|
46
|
+
return props[key] === value;
|
47
|
+
});
|
48
|
+
if (hasMatchStyle) {
|
49
|
+
styles.push(item.style);
|
50
|
+
}
|
51
|
+
return styles;
|
52
|
+
}, []);
|
53
|
+
};
|
33
54
|
|
34
|
-
export { getDynamicVariants, getStaticVariants };
|
55
|
+
export { getDynamicVariants, getIntersectionStyles, getStaticVariants };
|
35
56
|
//# sourceMappingURL=utils.js.map
|
package/es/engines/utils.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"utils.js","sources":["../../src/engines/utils.ts"],"sourcesContent":["import type { ComponentConfig, HTMLAnyAttributes } from './types';\n\nexport const getStaticVariants = (config: ComponentConfig) => {\n if (!config.variations) {\n return [];\n }\n const res = [];\n const { variations } = config;\n\n // eslint-disable-next-line guard-for-in\n for (const key in variations) {\n const { css } = variations[key];\n css && res.push(css);\n }\n\n return res;\n};\n\nexport const getDynamicVariants = (config: ComponentConfig) => {\n return (props: HTMLAnyAttributes) => {\n const res = [];\n\n // eslint-disable-next-line guard-for-in\n for (const key in config.variations) {\n if (key in props) {\n const variant = config.variations[key];\n\n const css = variant[props[key]];\n // no css for { modifier: true }\n css && Array.isArray(css) ? res.push(...css) : res.push(css);\n }\n }\n\n return res;\n };\n};\n"],"names":["getStaticVariants","config","variations","res","key","css","push","getDynamicVariants","props","variant","Array","isArray","apply","_toCon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Content":["import type { ComponentConfig, HTMLAnyAttributes, Intersection } from './types';\n\nexport const getStaticVariants = (config: ComponentConfig) => {\n if (!config.variations) {\n return [];\n }\n const res = [];\n const { variations } = config;\n\n // eslint-disable-next-line guard-for-in\n for (const key in variations) {\n const { css } = variations[key];\n css && res.push(css);\n }\n\n return res;\n};\n\nexport const getDynamicVariants = (config: ComponentConfig) => {\n return (props: HTMLAnyAttributes) => {\n const res = [];\n\n // eslint-disable-next-line guard-for-in\n for (const key in config.variations) {\n if (key in props) {\n const variant = config.variations[key];\n\n const css = variant[props[key]];\n // no css for { modifier: true }\n css && Array.isArray(css) ? res.push(...css) : res.push(css);\n }\n }\n\n return res;\n };\n};\n\nexport const getIntersectionStyles = (props: Record<string, any>, intersections?: Intersection[]) => {\n if (!intersections) {\n return [];\n }\n\n return intersections.reduce((styles: string[], item) => {\n const hasMatchStyle = Object.entries(item)\n .filter(([key]) => key !== 'style')\n .every(([key, value]) => props[key] === value);\n\n if (hasMatchStyle) {\n styles.push(item.style);\n }\n\n return styles;\n }, []);\n};\n"],"names":["getStaticVariants","config","variations","res","key","css","push","getDynamicVariants","props","variant","Array","isArray","apply","_toConsumableArray","getIntersectionStyles","intersections","reduce","styles","item","hasMatchStyle","Object","entries","filter","_ref","_ref2","_slicedToArray","every","_ref3","_ref4","value","style"],"mappings":";;IAEaA,iBAAiB,GAAG,SAApBA,iBAAiBA,CAAIC,MAAuB,EAAK;AAC1D,EAAA,IAAI,CAACA,MAAM,CAACC,UAAU,EAAE;AACpB,IAAA,OAAO,EAAE,CAAA;AACb,GAAA;EACA,IAAMC,GAAG,GAAG,EAAE,CAAA;AACd,EAAA,IAAQD,UAAU,GAAKD,MAAM,CAArBC,UAAU,CAAA;;AAElB;AACA,EAAA,KAAK,IAAME,GAAG,IAAIF,UAAU,EAAE;AAC1B,IAAA,IAAQG,GAAG,GAAKH,UAAU,CAACE,GAAG,CAAC,CAAvBC,GAAG,CAAA;AACXA,IAAAA,GAAG,IAAIF,GAAG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AAK,OAAO,CAAA;AAAA,KAAA,CAAC,CAClCsB,KAAK,CAAC,UAAAC,KAAA,EAAA;AAAA,MAAA,IAAAC,KAAA,GAAAH,cAAA,CAAAE,KAAA,EAAA,CAAA,CAAA;AAAEvB,QAAAA,GAAG,GAAAwB,KAAA,CAAA,CAAA,CAAA;AAAEC,QAAAA,KAAK,GAAAD,KAAA,CAAA,CAAA,CAAA,CAAA;AAAA,MAAA,OAAMpB,KAAK,CAACJ,GAAG,CAAC,KAAKyB,KAAK,CAAA;KAAC,CAAA,CAAA;AAElD,IAAA,IAAIV,aAAa,EAAE;AACfF,MAAAA,MAAM,CAACX,IAAI,CAACY,IAAI,CAACY,KAAK,CAAC,CAAA;AAC3B,KAAA;AAEA,IAAA,OAAOb,MAAM,CAAA;GAChB,EAAE,EAAE,CAAC,CAAA;AACV;;;;"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@salutejs/plasma-new-hope",
|
3
|
-
"version": "0.265.0-
|
3
|
+
"version": "0.265.0-dev.0",
|
4
4
|
"description": "Salute Design System blueprint",
|
5
5
|
"main": "cjs/index.js",
|
6
6
|
"module": "es/index.js",
|
@@ -132,5 +132,5 @@
|
|
132
132
|
"sideEffects": [
|
133
133
|
"*.css"
|
134
134
|
],
|
135
|
-
"gitHead": "
|
135
|
+
"gitHead": "fc9dea07e7ae09381ffbf25bd78bea778755efe7"
|
136
136
|
}
|
@@ -9,12 +9,6 @@ import { PropsTable, Description } from '@site/src/components';
|
|
9
9
|
<Description name="Checkbox" />
|
10
10
|
<PropsTable name="Checkbox" exclude={['css', 'focused']} />
|
11
11
|
|
12
|
-
:::caution Устаревшие значения для свойства view
|
13
|
-
Актуальным значением для свойства `view` - является `accent`.
|
14
|
-
|
15
|
-
Все остальные значения `deprecated` и будут удалены в ближайшее время!
|
16
|
-
:::
|
17
|
-
|
18
12
|
## Использование
|
19
13
|
Компонент `Checkbox` может содержать лейбл и описание.
|
20
14
|
|
@@ -25,7 +25,7 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
25
25
|
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); }
|
26
26
|
var Root = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
27
27
|
componentId: "plasma-new-hope__sc-1xug4g9-0"
|
28
|
-
})(["", ";", ";", ";"], function (_ref) {
|
28
|
+
})(["", ";", ";", ";", ";"], function (_ref) {
|
29
29
|
var base = _ref.base;
|
30
30
|
return base;
|
31
31
|
}, function (_ref2) {
|
@@ -34,20 +34,26 @@ var Root = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
|
34
34
|
}, function (_ref3) {
|
35
35
|
var dynamicVariants = _ref3.dynamicVariants;
|
36
36
|
return dynamicVariants;
|
37
|
+
}, function (_ref4) {
|
38
|
+
var intersectionStyles = _ref4.intersectionStyles;
|
39
|
+
return intersectionStyles;
|
37
40
|
});
|
38
41
|
|
39
42
|
/* eslint-disable no-underscore-dangle */
|
40
43
|
var _component = exports._component = function _component(componentConfig) {
|
41
44
|
var tag = componentConfig.tag,
|
42
|
-
base = componentConfig.base
|
45
|
+
base = componentConfig.base,
|
46
|
+
intersections = componentConfig.intersections;
|
43
47
|
var staticVariants = (0, _utils.getStaticVariants)(componentConfig);
|
44
48
|
var dynamicVariants = (0, _utils.getDynamicVariants)(componentConfig);
|
45
49
|
return /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
50
|
+
var intersectionStyles = (0, _utils.getIntersectionStyles)(props, intersections);
|
46
51
|
return /*#__PURE__*/_react["default"].createElement(Root, _extends({
|
47
52
|
as: tag,
|
48
53
|
base: base,
|
49
54
|
staticVariants: staticVariants,
|
50
|
-
dynamicVariants: dynamicVariants
|
55
|
+
dynamicVariants: dynamicVariants,
|
56
|
+
intersectionStyles: intersectionStyles
|
51
57
|
}, props, {
|
52
58
|
ref: ref
|
53
59
|
}));
|
@@ -3,7 +3,11 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.getStaticVariants = exports.getDynamicVariants = void 0;
|
6
|
+
exports.getStaticVariants = exports.getIntersectionStyles = exports.getDynamicVariants = void 0;
|
7
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
8
|
+
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."); }
|
9
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
10
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
7
11
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
8
12
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
9
13
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
@@ -39,4 +43,25 @@ var getDynamicVariants = exports.getDynamicVariants = function getDynamicVariant
|
|
39
43
|
}
|
40
44
|
return res;
|
41
45
|
};
|
46
|
+
};
|
47
|
+
var getIntersectionStyles = exports.getIntersectionStyles = function getIntersectionStyles(props, intersections) {
|
48
|
+
if (!intersections) {
|
49
|
+
return [];
|
50
|
+
}
|
51
|
+
return intersections.reduce(function (styles, item) {
|
52
|
+
var hasMatchStyle = Object.entries(item).filter(function (_ref) {
|
53
|
+
var _ref2 = _slicedToArray(_ref, 1),
|
54
|
+
key = _ref2[0];
|
55
|
+
return key !== 'style';
|
56
|
+
}).every(function (_ref3) {
|
57
|
+
var _ref4 = _slicedToArray(_ref3, 2),
|
58
|
+
key = _ref4[0],
|
59
|
+
value = _ref4[1];
|
60
|
+
return props[key] === value;
|
61
|
+
});
|
62
|
+
if (hasMatchStyle) {
|
63
|
+
styles.push(item.style);
|
64
|
+
}
|
65
|
+
return styles;
|
66
|
+
}, []);
|
42
67
|
};
|
@@ -22,20 +22,13 @@ var config = exports.config = {
|
|
22
22
|
* Вид контрола.
|
23
23
|
*/
|
24
24
|
view: {
|
25
|
-
accent: /*#__PURE__*/(0, _styledComponents.css)(["", ":var(--text-accent);", ":var(--on-dark-text-primary);", ":var(--text-secondary);", ":transparent;", ":var(--text-secondary);"], _Checkbox.checkboxTokens.fillColor, _Checkbox.checkboxTokens.iconColor, _Checkbox.checkboxTokens.descriptionColor, _Checkbox.checkboxTokens.triggerBackgroundColor, _Checkbox.checkboxTokens.triggerBorderColor),
|
26
|
-
// deprecated
|
27
25
|
"default": /*#__PURE__*/(0, _styledComponents.css)(["", ":var(--text-primary);", ":var(--inverse-text-primary);", ":var(--text-secondary);", ":transparent;", ":var(--text-secondary);"], _Checkbox.checkboxTokens.fillColor, _Checkbox.checkboxTokens.iconColor, _Checkbox.checkboxTokens.descriptionColor, _Checkbox.checkboxTokens.triggerBackgroundColor, _Checkbox.checkboxTokens.triggerBorderColor),
|
28
|
-
// deprecated
|
29
26
|
secondary: /*#__PURE__*/(0, _styledComponents.css)(["", ":var(--text-secondary);", ":var(--inverse-text-primary);", ":var(--text-secondary);", ":transparent;", ":var(--text-secondary);"], _Checkbox.checkboxTokens.fillColor, _Checkbox.checkboxTokens.iconColor, _Checkbox.checkboxTokens.descriptionColor, _Checkbox.checkboxTokens.triggerBackgroundColor, _Checkbox.checkboxTokens.triggerBorderColor),
|
30
|
-
// deprecated
|
31
27
|
tertiary: /*#__PURE__*/(0, _styledComponents.css)(["", ":var(--text-tertiary);", ":var(--inverse-text-primary);", ":var(--text-secondary);", ":transparent;", ":var(--text-secondary);"], _Checkbox.checkboxTokens.fillColor, _Checkbox.checkboxTokens.iconColor, _Checkbox.checkboxTokens.descriptionColor, _Checkbox.checkboxTokens.triggerBackgroundColor, _Checkbox.checkboxTokens.triggerBorderColor),
|
32
|
-
// deprecated
|
33
28
|
paragraph: /*#__PURE__*/(0, _styledComponents.css)(["", ":var(--text-paragraph);", ":var(--inverse-text-primary);", ":var(--text-secondary);", ":transparent;", ":var(--text-secondary);"], _Checkbox.checkboxTokens.fillColor, _Checkbox.checkboxTokens.iconColor, _Checkbox.checkboxTokens.descriptionColor, _Checkbox.checkboxTokens.triggerBackgroundColor, _Checkbox.checkboxTokens.triggerBorderColor),
|
34
|
-
|
29
|
+
accent: /*#__PURE__*/(0, _styledComponents.css)(["", ":var(--text-accent);", ":var(--on-dark-text-primary);", ":var(--text-secondary);", ":transparent;", ":var(--text-secondary);"], _Checkbox.checkboxTokens.fillColor, _Checkbox.checkboxTokens.iconColor, _Checkbox.checkboxTokens.descriptionColor, _Checkbox.checkboxTokens.triggerBackgroundColor, _Checkbox.checkboxTokens.triggerBorderColor),
|
35
30
|
positive: /*#__PURE__*/(0, _styledComponents.css)(["", ":var(--text-positive);", ":var(--on-dark-text-primary);", ":var(--text-secondary);", ":transparent;", ":var(--text-secondary);"], _Checkbox.checkboxTokens.fillColor, _Checkbox.checkboxTokens.iconColor, _Checkbox.checkboxTokens.descriptionColor, _Checkbox.checkboxTokens.triggerBackgroundColor, _Checkbox.checkboxTokens.triggerBorderColor),
|
36
|
-
// deprecated
|
37
31
|
warning: /*#__PURE__*/(0, _styledComponents.css)(["", ":var(--text-warning);", ":var(--on-dark-text-primary);", ":var(--text-secondary);", ":transparent;", ":var(--text-secondary);"], _Checkbox.checkboxTokens.fillColor, _Checkbox.checkboxTokens.iconColor, _Checkbox.checkboxTokens.descriptionColor, _Checkbox.checkboxTokens.triggerBackgroundColor, _Checkbox.checkboxTokens.triggerBorderColor),
|
38
|
-
// deprecated
|
39
32
|
negative: /*#__PURE__*/(0, _styledComponents.css)(["", ":var(--text-negative);", ":var(--on-dark-text-primary);", ":var(--text-secondary);", ":transparent;", ":var(--text-secondary);"], _Checkbox.checkboxTokens.fillColor, _Checkbox.checkboxTokens.iconColor, _Checkbox.checkboxTokens.descriptionColor, _Checkbox.checkboxTokens.triggerBackgroundColor, _Checkbox.checkboxTokens.triggerBorderColor)
|
40
33
|
},
|
41
34
|
disabled: {
|
@@ -3,9 +3,12 @@ import type { ComponentProps } from 'react';
|
|
3
3
|
import type { StoryObj, Meta } from '@storybook/react';
|
4
4
|
import { action } from '@storybook/addon-actions';
|
5
5
|
|
6
|
-
import {
|
6
|
+
import { checkboxConfig } from '../../../../components/Checkbox';
|
7
|
+
import { mergeConfig } from '../../../../engines';
|
8
|
+
import { WithTheme, argTypesFromConfig } from '../../../_helpers';
|
7
9
|
import { Link } from '../Link/Link';
|
8
10
|
|
11
|
+
import { config } from './Checkbox.config';
|
9
12
|
import { Checkbox } from './Checkbox';
|
10
13
|
|
11
14
|
const onChange = action('onChange');
|
@@ -16,20 +19,7 @@ const meta: Meta<typeof Checkbox> = {
|
|
16
19
|
title: 'b2c/Data Entry/Checkbox',
|
17
20
|
decorators: [WithTheme],
|
18
21
|
component: Checkbox,
|
19
|
-
argTypes:
|
20
|
-
view: {
|
21
|
-
options: ['accent'],
|
22
|
-
control: {
|
23
|
-
type: 'radio',
|
24
|
-
},
|
25
|
-
},
|
26
|
-
size: {
|
27
|
-
options: ['m', 's'],
|
28
|
-
control: {
|
29
|
-
type: 'radio',
|
30
|
-
},
|
31
|
-
},
|
32
|
-
},
|
22
|
+
argTypes: argTypesFromConfig(mergeConfig(checkboxConfig, config)),
|
33
23
|
args: {
|
34
24
|
view: 'accent',
|
35
25
|
size: 'm',
|
@@ -22,20 +22,13 @@ var config = exports.config = {
|
|
22
22
|
* Вид контрола.
|
23
23
|
*/
|
24
24
|
view: {
|
25
|
-
accent: /*#__PURE__*/(0, _styledComponents.css)(["", ":var(--text-accent);", ":var(--on-dark-text-primary);", ":var(--text-secondary);", ":transparent;", ":var(--text-secondary);"], _Checkbox.checkboxTokens.fillColor, _Checkbox.checkboxTokens.iconColor, _Checkbox.checkboxTokens.descriptionColor, _Checkbox.checkboxTokens.triggerBackgroundColor, _Checkbox.checkboxTokens.triggerBorderColor),
|
26
|
-
// deprecated
|
27
25
|
"default": /*#__PURE__*/(0, _styledComponents.css)(["", ":var(--text-primary);", ":var(--inverse-text-primary);", ":var(--text-secondary);", ":transparent;", ":var(--text-secondary);"], _Checkbox.checkboxTokens.fillColor, _Checkbox.checkboxTokens.iconColor, _Checkbox.checkboxTokens.descriptionColor, _Checkbox.checkboxTokens.triggerBackgroundColor, _Checkbox.checkboxTokens.triggerBorderColor),
|
28
|
-
// deprecated
|
29
26
|
secondary: /*#__PURE__*/(0, _styledComponents.css)(["", ":var(--text-secondary);", ":var(--inverse-text-primary);", ":var(--text-secondary);", ":transparent;", ":var(--text-secondary);"], _Checkbox.checkboxTokens.fillColor, _Checkbox.checkboxTokens.iconColor, _Checkbox.checkboxTokens.descriptionColor, _Checkbox.checkboxTokens.triggerBackgroundColor, _Checkbox.checkboxTokens.triggerBorderColor),
|
30
|
-
// deprecated
|
31
27
|
tertiary: /*#__PURE__*/(0, _styledComponents.css)(["", ":var(--text-tertiary);", ":var(--inverse-text-primary);", ":var(--text-secondary);", ":transparent;", ":var(--text-secondary);"], _Checkbox.checkboxTokens.fillColor, _Checkbox.checkboxTokens.iconColor, _Checkbox.checkboxTokens.descriptionColor, _Checkbox.checkboxTokens.triggerBackgroundColor, _Checkbox.checkboxTokens.triggerBorderColor),
|
32
|
-
// deprecated
|
33
28
|
paragraph: /*#__PURE__*/(0, _styledComponents.css)(["", ":var(--text-paragraph);", ":var(--inverse-text-primary);", ":var(--text-secondary);", ":transparent;", ":var(--text-secondary);"], _Checkbox.checkboxTokens.fillColor, _Checkbox.checkboxTokens.iconColor, _Checkbox.checkboxTokens.descriptionColor, _Checkbox.checkboxTokens.triggerBackgroundColor, _Checkbox.checkboxTokens.triggerBorderColor),
|
34
|
-
|
29
|
+
accent: /*#__PURE__*/(0, _styledComponents.css)(["", ":var(--text-accent);", ":var(--on-dark-text-primary);", ":var(--text-secondary);", ":transparent;", ":var(--text-secondary);"], _Checkbox.checkboxTokens.fillColor, _Checkbox.checkboxTokens.iconColor, _Checkbox.checkboxTokens.descriptionColor, _Checkbox.checkboxTokens.triggerBackgroundColor, _Checkbox.checkboxTokens.triggerBorderColor),
|
35
30
|
positive: /*#__PURE__*/(0, _styledComponents.css)(["", ":var(--text-positive);", ":var(--on-dark-text-primary);", ":var(--text-secondary);", ":transparent;", ":var(--text-secondary);"], _Checkbox.checkboxTokens.fillColor, _Checkbox.checkboxTokens.iconColor, _Checkbox.checkboxTokens.descriptionColor, _Checkbox.checkboxTokens.triggerBackgroundColor, _Checkbox.checkboxTokens.triggerBorderColor),
|
36
|
-
// deprecated
|
37
31
|
warning: /*#__PURE__*/(0, _styledComponents.css)(["", ":var(--text-warning);", ":var(--on-dark-text-primary);", ":var(--text-secondary);", ":transparent;", ":var(--text-secondary);"], _Checkbox.checkboxTokens.fillColor, _Checkbox.checkboxTokens.iconColor, _Checkbox.checkboxTokens.descriptionColor, _Checkbox.checkboxTokens.triggerBackgroundColor, _Checkbox.checkboxTokens.triggerBorderColor),
|
38
|
-
// deprecated
|
39
32
|
negative: /*#__PURE__*/(0, _styledComponents.css)(["", ":var(--text-negative);", ":var(--on-dark-text-primary);", ":var(--text-secondary);", ":transparent;", ":var(--text-secondary);"], _Checkbox.checkboxTokens.fillColor, _Checkbox.checkboxTokens.iconColor, _Checkbox.checkboxTokens.descriptionColor, _Checkbox.checkboxTokens.triggerBackgroundColor, _Checkbox.checkboxTokens.triggerBorderColor)
|
40
33
|
},
|
41
34
|
disabled: {
|
@@ -3,9 +3,12 @@ import type { ComponentProps } from 'react';
|
|
3
3
|
import type { StoryObj, Meta } from '@storybook/react';
|
4
4
|
import { action } from '@storybook/addon-actions';
|
5
5
|
|
6
|
-
import {
|
6
|
+
import { checkboxConfig } from '../../../../components/Checkbox';
|
7
|
+
import { mergeConfig } from '../../../../engines';
|
8
|
+
import { WithTheme, argTypesFromConfig } from '../../../_helpers';
|
7
9
|
import { Link } from '../Link/Link';
|
8
10
|
|
11
|
+
import { config } from './Checkbox.config';
|
9
12
|
import { Checkbox } from './Checkbox';
|
10
13
|
|
11
14
|
const onChange = action('onChange');
|
@@ -16,20 +19,7 @@ const meta: Meta<typeof Checkbox> = {
|
|
16
19
|
title: 'web/Data Entry/Checkbox',
|
17
20
|
decorators: [WithTheme],
|
18
21
|
component: Checkbox,
|
19
|
-
argTypes:
|
20
|
-
view: {
|
21
|
-
options: ['accent'],
|
22
|
-
control: {
|
23
|
-
type: 'radio',
|
24
|
-
},
|
25
|
-
},
|
26
|
-
size: {
|
27
|
-
options: ['m', 's'],
|
28
|
-
control: {
|
29
|
-
type: 'radio',
|
30
|
-
},
|
31
|
-
},
|
32
|
-
},
|
22
|
+
argTypes: argTypesFromConfig(mergeConfig(checkboxConfig, config)),
|
33
23
|
args: {
|
34
24
|
view: 'accent',
|
35
25
|
size: 'm',
|
@@ -9,12 +9,6 @@ import { PropsTable, Description } from '@site/src/components';
|
|
9
9
|
<Description name="Checkbox" />
|
10
10
|
<PropsTable name="Checkbox" exclude={['css', 'focused']} />
|
11
11
|
|
12
|
-
:::caution Устаревшие значения для свойства view
|
13
|
-
Актуальным значением для свойства `view` - является `accent`.
|
14
|
-
|
15
|
-
Все остальные значения `deprecated` и будут удалены в ближайшее время!
|
16
|
-
:::
|
17
|
-
|
18
12
|
## Использование
|
19
13
|
Компонент `Checkbox` может содержать лейбл и описание.
|
20
14
|
|
@@ -1,11 +1,11 @@
|
|
1
1
|
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); }
|
2
2
|
import React, { forwardRef } from 'react';
|
3
3
|
import styled, { css } from 'styled-components';
|
4
|
-
import { getStaticVariants, getDynamicVariants } from './utils';
|
4
|
+
import { getStaticVariants, getDynamicVariants, getIntersectionStyles } from './utils';
|
5
5
|
export { styled, css };
|
6
6
|
var Root = /*#__PURE__*/styled.div.withConfig({
|
7
7
|
componentId: "plasma-new-hope__sc-1xug4g9-0"
|
8
|
-
})(["", ";", ";", ";"], function (_ref) {
|
8
|
+
})(["", ";", ";", ";", ";"], function (_ref) {
|
9
9
|
var base = _ref.base;
|
10
10
|
return base;
|
11
11
|
}, function (_ref2) {
|
@@ -14,20 +14,26 @@ var Root = /*#__PURE__*/styled.div.withConfig({
|
|
14
14
|
}, function (_ref3) {
|
15
15
|
var dynamicVariants = _ref3.dynamicVariants;
|
16
16
|
return dynamicVariants;
|
17
|
+
}, function (_ref4) {
|
18
|
+
var intersectionStyles = _ref4.intersectionStyles;
|
19
|
+
return intersectionStyles;
|
17
20
|
});
|
18
21
|
|
19
22
|
/* eslint-disable no-underscore-dangle */
|
20
23
|
export var _component = function _component(componentConfig) {
|
21
24
|
var tag = componentConfig.tag,
|
22
|
-
base = componentConfig.base
|
25
|
+
base = componentConfig.base,
|
26
|
+
intersections = componentConfig.intersections;
|
23
27
|
var staticVariants = getStaticVariants(componentConfig);
|
24
28
|
var dynamicVariants = getDynamicVariants(componentConfig);
|
25
29
|
return /*#__PURE__*/forwardRef(function (props, ref) {
|
30
|
+
var intersectionStyles = getIntersectionStyles(props, intersections);
|
26
31
|
return /*#__PURE__*/React.createElement(Root, _extends({
|
27
32
|
as: tag,
|
28
33
|
base: base,
|
29
34
|
staticVariants: staticVariants,
|
30
|
-
dynamicVariants: dynamicVariants
|
35
|
+
dynamicVariants: dynamicVariants,
|
36
|
+
intersectionStyles: intersectionStyles
|
31
37
|
}, props, {
|
32
38
|
ref: ref
|
33
39
|
}));
|
@@ -1,3 +1,7 @@
|
|
1
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
2
|
+
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."); }
|
3
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
4
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
1
5
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
2
6
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
3
7
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
@@ -33,4 +37,25 @@ export var getDynamicVariants = function getDynamicVariants(config) {
|
|
33
37
|
}
|
34
38
|
return res;
|
35
39
|
};
|
40
|
+
};
|
41
|
+
export var getIntersectionStyles = function getIntersectionStyles(props, intersections) {
|
42
|
+
if (!intersections) {
|
43
|
+
return [];
|
44
|
+
}
|
45
|
+
return intersections.reduce(function (styles, item) {
|
46
|
+
var hasMatchStyle = Object.entries(item).filter(function (_ref) {
|
47
|
+
var _ref2 = _slicedToArray(_ref, 1),
|
48
|
+
key = _ref2[0];
|
49
|
+
return key !== 'style';
|
50
|
+
}).every(function (_ref3) {
|
51
|
+
var _ref4 = _slicedToArray(_ref3, 2),
|
52
|
+
key = _ref4[0],
|
53
|
+
value = _ref4[1];
|
54
|
+
return props[key] === value;
|
55
|
+
});
|
56
|
+
if (hasMatchStyle) {
|
57
|
+
styles.push(item.style);
|
58
|
+
}
|
59
|
+
return styles;
|
60
|
+
}, []);
|
36
61
|
};
|
@@ -16,20 +16,13 @@ export var config = {
|
|
16
16
|
* Вид контрола.
|
17
17
|
*/
|
18
18
|
view: {
|
19
|
-
accent: /*#__PURE__*/css(["", ":var(--text-accent);", ":var(--on-dark-text-primary);", ":var(--text-secondary);", ":transparent;", ":var(--text-secondary);"], checkboxTokens.fillColor, checkboxTokens.iconColor, checkboxTokens.descriptionColor, checkboxTokens.triggerBackgroundColor, checkboxTokens.triggerBorderColor),
|
20
|
-
// deprecated
|
21
19
|
"default": /*#__PURE__*/css(["", ":var(--text-primary);", ":var(--inverse-text-primary);", ":var(--text-secondary);", ":transparent;", ":var(--text-secondary);"], checkboxTokens.fillColor, checkboxTokens.iconColor, checkboxTokens.descriptionColor, checkboxTokens.triggerBackgroundColor, checkboxTokens.triggerBorderColor),
|
22
|
-
// deprecated
|
23
20
|
secondary: /*#__PURE__*/css(["", ":var(--text-secondary);", ":var(--inverse-text-primary);", ":var(--text-secondary);", ":transparent;", ":var(--text-secondary);"], checkboxTokens.fillColor, checkboxTokens.iconColor, checkboxTokens.descriptionColor, checkboxTokens.triggerBackgroundColor, checkboxTokens.triggerBorderColor),
|
24
|
-
// deprecated
|
25
21
|
tertiary: /*#__PURE__*/css(["", ":var(--text-tertiary);", ":var(--inverse-text-primary);", ":var(--text-secondary);", ":transparent;", ":var(--text-secondary);"], checkboxTokens.fillColor, checkboxTokens.iconColor, checkboxTokens.descriptionColor, checkboxTokens.triggerBackgroundColor, checkboxTokens.triggerBorderColor),
|
26
|
-
// deprecated
|
27
22
|
paragraph: /*#__PURE__*/css(["", ":var(--text-paragraph);", ":var(--inverse-text-primary);", ":var(--text-secondary);", ":transparent;", ":var(--text-secondary);"], checkboxTokens.fillColor, checkboxTokens.iconColor, checkboxTokens.descriptionColor, checkboxTokens.triggerBackgroundColor, checkboxTokens.triggerBorderColor),
|
28
|
-
|
23
|
+
accent: /*#__PURE__*/css(["", ":var(--text-accent);", ":var(--on-dark-text-primary);", ":var(--text-secondary);", ":transparent;", ":var(--text-secondary);"], checkboxTokens.fillColor, checkboxTokens.iconColor, checkboxTokens.descriptionColor, checkboxTokens.triggerBackgroundColor, checkboxTokens.triggerBorderColor),
|
29
24
|
positive: /*#__PURE__*/css(["", ":var(--text-positive);", ":var(--on-dark-text-primary);", ":var(--text-secondary);", ":transparent;", ":var(--text-secondary);"], checkboxTokens.fillColor, checkboxTokens.iconColor, checkboxTokens.descriptionColor, checkboxTokens.triggerBackgroundColor, checkboxTokens.triggerBorderColor),
|
30
|
-
// deprecated
|
31
25
|
warning: /*#__PURE__*/css(["", ":var(--text-warning);", ":var(--on-dark-text-primary);", ":var(--text-secondary);", ":transparent;", ":var(--text-secondary);"], checkboxTokens.fillColor, checkboxTokens.iconColor, checkboxTokens.descriptionColor, checkboxTokens.triggerBackgroundColor, checkboxTokens.triggerBorderColor),
|
32
|
-
// deprecated
|
33
26
|
negative: /*#__PURE__*/css(["", ":var(--text-negative);", ":var(--on-dark-text-primary);", ":var(--text-secondary);", ":transparent;", ":var(--text-secondary);"], checkboxTokens.fillColor, checkboxTokens.iconColor, checkboxTokens.descriptionColor, checkboxTokens.triggerBackgroundColor, checkboxTokens.triggerBorderColor)
|
34
27
|
},
|
35
28
|
disabled: {
|
@@ -3,9 +3,12 @@ import type { ComponentProps } from 'react';
|
|
3
3
|
import type { StoryObj, Meta } from '@storybook/react';
|
4
4
|
import { action } from '@storybook/addon-actions';
|
5
5
|
|
6
|
-
import {
|
6
|
+
import { checkboxConfig } from '../../../../components/Checkbox';
|
7
|
+
import { mergeConfig } from '../../../../engines';
|
8
|
+
import { WithTheme, argTypesFromConfig } from '../../../_helpers';
|
7
9
|
import { Link } from '../Link/Link';
|
8
10
|
|
11
|
+
import { config } from './Checkbox.config';
|
9
12
|
import { Checkbox } from './Checkbox';
|
10
13
|
|
11
14
|
const onChange = action('onChange');
|
@@ -16,20 +19,7 @@ const meta: Meta<typeof Checkbox> = {
|
|
16
19
|
title: 'b2c/Data Entry/Checkbox',
|
17
20
|
decorators: [WithTheme],
|
18
21
|
component: Checkbox,
|
19
|
-
argTypes:
|
20
|
-
view: {
|
21
|
-
options: ['accent'],
|
22
|
-
control: {
|
23
|
-
type: 'radio',
|
24
|
-
},
|
25
|
-
},
|
26
|
-
size: {
|
27
|
-
options: ['m', 's'],
|
28
|
-
control: {
|
29
|
-
type: 'radio',
|
30
|
-
},
|
31
|
-
},
|
32
|
-
},
|
22
|
+
argTypes: argTypesFromConfig(mergeConfig(checkboxConfig, config)),
|
33
23
|
args: {
|
34
24
|
view: 'accent',
|
35
25
|
size: 'm',
|
@@ -16,20 +16,13 @@ export var config = {
|
|
16
16
|
* Вид контрола.
|
17
17
|
*/
|
18
18
|
view: {
|
19
|
-
accent: /*#__PURE__*/css(["", ":var(--text-accent);", ":var(--on-dark-text-primary);", ":var(--text-secondary);", ":transparent;", ":var(--text-secondary);"], checkboxTokens.fillColor, checkboxTokens.iconColor, checkboxTokens.descriptionColor, checkboxTokens.triggerBackgroundColor, checkboxTokens.triggerBorderColor),
|
20
|
-
// deprecated
|
21
19
|
"default": /*#__PURE__*/css(["", ":var(--text-primary);", ":var(--inverse-text-primary);", ":var(--text-secondary);", ":transparent;", ":var(--text-secondary);"], checkboxTokens.fillColor, checkboxTokens.iconColor, checkboxTokens.descriptionColor, checkboxTokens.triggerBackgroundColor, checkboxTokens.triggerBorderColor),
|
22
|
-
// deprecated
|
23
20
|
secondary: /*#__PURE__*/css(["", ":var(--text-secondary);", ":var(--inverse-text-primary);", ":var(--text-secondary);", ":transparent;", ":var(--text-secondary);"], checkboxTokens.fillColor, checkboxTokens.iconColor, checkboxTokens.descriptionColor, checkboxTokens.triggerBackgroundColor, checkboxTokens.triggerBorderColor),
|
24
|
-
// deprecated
|
25
21
|
tertiary: /*#__PURE__*/css(["", ":var(--text-tertiary);", ":var(--inverse-text-primary);", ":var(--text-secondary);", ":transparent;", ":var(--text-secondary);"], checkboxTokens.fillColor, checkboxTokens.iconColor, checkboxTokens.descriptionColor, checkboxTokens.triggerBackgroundColor, checkboxTokens.triggerBorderColor),
|
26
|
-
// deprecated
|
27
22
|
paragraph: /*#__PURE__*/css(["", ":var(--text-paragraph);", ":var(--inverse-text-primary);", ":var(--text-secondary);", ":transparent;", ":var(--text-secondary);"], checkboxTokens.fillColor, checkboxTokens.iconColor, checkboxTokens.descriptionColor, checkboxTokens.triggerBackgroundColor, checkboxTokens.triggerBorderColor),
|
28
|
-
|
23
|
+
accent: /*#__PURE__*/css(["", ":var(--text-accent);", ":var(--on-dark-text-primary);", ":var(--text-secondary);", ":transparent;", ":var(--text-secondary);"], checkboxTokens.fillColor, checkboxTokens.iconColor, checkboxTokens.descriptionColor, checkboxTokens.triggerBackgroundColor, checkboxTokens.triggerBorderColor),
|
29
24
|
positive: /*#__PURE__*/css(["", ":var(--text-positive);", ":var(--on-dark-text-primary);", ":var(--text-secondary);", ":transparent;", ":var(--text-secondary);"], checkboxTokens.fillColor, checkboxTokens.iconColor, checkboxTokens.descriptionColor, checkboxTokens.triggerBackgroundColor, checkboxTokens.triggerBorderColor),
|
30
|
-
// deprecated
|
31
25
|
warning: /*#__PURE__*/css(["", ":var(--text-warning);", ":var(--on-dark-text-primary);", ":var(--text-secondary);", ":transparent;", ":var(--text-secondary);"], checkboxTokens.fillColor, checkboxTokens.iconColor, checkboxTokens.descriptionColor, checkboxTokens.triggerBackgroundColor, checkboxTokens.triggerBorderColor),
|
32
|
-
// deprecated
|
33
26
|
negative: /*#__PURE__*/css(["", ":var(--text-negative);", ":var(--on-dark-text-primary);", ":var(--text-secondary);", ":transparent;", ":var(--text-secondary);"], checkboxTokens.fillColor, checkboxTokens.iconColor, checkboxTokens.descriptionColor, checkboxTokens.triggerBackgroundColor, checkboxTokens.triggerBorderColor)
|
34
27
|
},
|
35
28
|
disabled: {
|
@@ -3,9 +3,12 @@ import type { ComponentProps } from 'react';
|
|
3
3
|
import type { StoryObj, Meta } from '@storybook/react';
|
4
4
|
import { action } from '@storybook/addon-actions';
|
5
5
|
|
6
|
-
import {
|
6
|
+
import { checkboxConfig } from '../../../../components/Checkbox';
|
7
|
+
import { mergeConfig } from '../../../../engines';
|
8
|
+
import { WithTheme, argTypesFromConfig } from '../../../_helpers';
|
7
9
|
import { Link } from '../Link/Link';
|
8
10
|
|
11
|
+
import { config } from './Checkbox.config';
|
9
12
|
import { Checkbox } from './Checkbox';
|
10
13
|
|
11
14
|
const onChange = action('onChange');
|
@@ -16,20 +19,7 @@ const meta: Meta<typeof Checkbox> = {
|
|
16
19
|
title: 'web/Data Entry/Checkbox',
|
17
20
|
decorators: [WithTheme],
|
18
21
|
component: Checkbox,
|
19
|
-
argTypes:
|
20
|
-
view: {
|
21
|
-
options: ['accent'],
|
22
|
-
control: {
|
23
|
-
type: 'radio',
|
24
|
-
},
|
25
|
-
},
|
26
|
-
size: {
|
27
|
-
options: ['m', 's'],
|
28
|
-
control: {
|
29
|
-
type: 'radio',
|
30
|
-
},
|
31
|
-
},
|
32
|
-
},
|
22
|
+
argTypes: argTypesFromConfig(mergeConfig(checkboxConfig, config)),
|
33
23
|
args: {
|
34
24
|
view: 'accent',
|
35
25
|
size: 'm',
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"emotion.d.ts","sourceRoot":"","sources":["../../src/engines/emotion.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAE,GAAG,EAAoB,MAAM,gBAAgB,CAAC;AAIvD,OAAO,KAAK,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAElE,OAAO,EAAE,GAAG,EAAE,CAAC;
|
1
|
+
{"version":3,"file":"emotion.d.ts","sourceRoot":"","sources":["../../src/engines/emotion.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAE,GAAG,EAAoB,MAAM,gBAAgB,CAAC;AAIvD,OAAO,KAAK,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAElE,OAAO,EAAE,GAAG,EAAE,CAAC;AAef,eAAO,MAAM,UAAU,oBAAqB,eAAe,uGAsB1D,CAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"linaria.d.ts","sourceRoot":"","sources":["../../src/engines/linaria.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAI1C,OAAO,eAAe,CAAC;AAEvB,OAAO,KAAK,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAGlE,eAAO,MAAM,UAAU,oBAAqB,eAAe,
|
1
|
+
{"version":3,"file":"linaria.d.ts","sourceRoot":"","sources":["../../src/engines/linaria.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAI1C,OAAO,eAAe,CAAC;AAEvB,OAAO,KAAK,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAGlE,eAAO,MAAM,UAAU,oBAAqB,eAAe,uGA6C1D,CAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"styled-components.d.ts","sourceRoot":"","sources":["../../src/engines/styled-components.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAC1C,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAGhD,OAAO,KAAK,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAElE,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC;
|
1
|
+
{"version":3,"file":"styled-components.d.ts","sourceRoot":"","sources":["../../src/engines/styled-components.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAC1C,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAGhD,OAAO,KAAK,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAElE,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC;AAevB,eAAO,MAAM,UAAU,oBAAqB,eAAe,uGAoB1D,CAAC"}
|