@salutejs/plasma-new-hope 0.314.0-dev.0 → 0.315.0-dev.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/components/Button/Button.js +1 -1
- package/cjs/components/Button/Button.js.map +1 -1
- package/emotion/cjs/components/Button/Button.js +1 -1
- package/emotion/es/components/Button/Button.js +1 -1
- package/es/components/Button/Button.js +1 -1
- package/es/components/Button/Button.js.map +1 -1
- package/package.json +2 -2
- package/styled-components/cjs/components/Button/Button.js +1 -1
- package/styled-components/es/components/Button/Button.js +1 -1
@@ -47,7 +47,7 @@ var buttonRoot = function buttonRoot(Root) {
|
|
47
47
|
stretching = _props$stretching === void 0 ? 'auto' : _props$stretching,
|
48
48
|
rest = _rollupPluginBabelHelpers.objectWithoutProperties(props, _excluded);
|
49
49
|
var txt = typeof children === 'string' ? children : text;
|
50
|
-
var hasRightContentMargin = Boolean(txt || value || contentRight);
|
50
|
+
var hasRightContentMargin = Boolean(children || txt || value || contentRight);
|
51
51
|
var hasLeftContentMargin = Boolean(contentLeft ? contentLeft && (txt || value) : txt || value);
|
52
52
|
var stretchingClass = stretch ? Button_tokens.classes.filledStretching : Button_tokens.classes["".concat(stretching, "Stretching")];
|
53
53
|
var contentRelaxedClass = contentPlacing === 'relaxed' ? Button_tokens.classes.contentRelaxed : undefined;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Button.js","sources":["../../../src/components/Button/Button.tsx"],"sourcesContent":["import React, { forwardRef } from 'react';\nimport type { CSSProperties } from 'react';\n\nimport type { RootProps } from '../../engines';\nimport { convertRoundnessMatrix } from '../../utils/roundness';\nimport { cx } from '../../utils';\n\nimport { base as viewCSS } from './variations/_view/base';\nimport { base as sizeCSS } from './variations/_size/base';\nimport { base as disabledCSS } from './variations/_disabled/base';\nimport { base as focusedCSS } from './variations/_focused/base';\nimport { base as stretchingCSS } from './variations/_stretching/base';\nimport { base as blurredCSS } from './variations/_blurred/base';\nimport type { ButtonProps, ContentPlacementMapper } from './Button.types';\nimport {\n base,\n ButtonText,\n ButtonValue,\n Loader,\n LoadWrap,\n StyledContentLeft,\n StyledContentRight,\n StyledSpinner,\n} from './Button.styles';\nimport { classes, tokens } from './Button.tokens';\n\nexport const buttonRoot = (Root: RootProps<HTMLButtonElement, ButtonProps>) =>\n forwardRef<HTMLButtonElement, ButtonProps>((props, ref) => {\n const {\n children,\n view,\n size,\n text,\n value,\n contentLeft,\n contentRight,\n contentPlacing = 'default',\n isLoading,\n loader,\n stretch,\n square,\n pin,\n disabled,\n focused,\n outlined,\n className,\n blur,\n style,\n stretching = 'auto',\n ...rest\n } = props;\n\n const txt = typeof children === 'string' ? children : text;\n const hasRightContentMargin = Boolean(txt || value || contentRight);\n const hasLeftContentMargin = Boolean(contentLeft ? contentLeft && (txt || value) : txt || value);\n\n const stretchingClass = stretch\n ? classes.filledStretching\n : classes[`${stretching}Stretching` as keyof typeof classes];\n const contentRelaxedClass = contentPlacing === 'relaxed' ? classes.contentRelaxed : undefined;\n const squareClass = square ? classes.buttonSquare : undefined;\n const isLoadingClass = isLoading ? classes.buttonLoading : undefined;\n const buttonBorderRadius = pin\n ? convertRoundnessMatrix(pin, `var(${tokens.buttonRadius})`, `var(${tokens.buttonHeight})`)\n : `var(${tokens.buttonRadius}, calc(var(${tokens.buttonHeight}) / 4))`;\n\n const contentPlacingMapper: ContentPlacementMapper = {\n default: 'center',\n relaxed: 'space-between',\n };\n\n const contentPlacementValue = contentPlacing ? contentPlacingMapper[contentPlacing] : 'center';\n\n return (\n <Root\n type=\"button\"\n ref={ref}\n view={view}\n size={size}\n value={value}\n disabled={disabled}\n focused={focused || outlined}\n contentPlacing={contentPlacing}\n className={cx(squareClass, stretchingClass, classes.buttonItem, isLoadingClass, className)}\n style={\n {\n ...style,\n '--plasma_computed-btn-br': buttonBorderRadius,\n '--plasma_private-blur': blur,\n } as CSSProperties\n }\n {...rest}\n >\n <LoadWrap contentPlacing={contentPlacementValue} isLoading={isLoading}>\n {contentLeft && (\n <StyledContentLeft hasContentMargin={hasRightContentMargin}>{contentLeft}</StyledContentLeft>\n )}\n {txt ? <ButtonText className={contentRelaxedClass}>{txt}</ButtonText> : children}\n {value && <ButtonValue>{value}</ButtonValue>}\n {contentRight && (\n <StyledContentRight hasContentMargin={hasLeftContentMargin}>{contentRight}</StyledContentRight>\n )}\n </LoadWrap>\n {isLoading && <Loader>{loader || <StyledSpinner />}</Loader>}\n </Root>\n );\n });\n\nexport const buttonConfig = {\n name: 'Button',\n tag: 'button',\n layout: buttonRoot,\n base,\n variations: {\n view: {\n css: viewCSS,\n },\n size: {\n css: sizeCSS,\n },\n disabled: {\n css: disabledCSS,\n attrs: true,\n },\n focused: {\n css: focusedCSS,\n // TODO: isLoading => disabled\n },\n blurred: {\n css: blurredCSS,\n },\n stretching: {\n css: stretchingCSS,\n },\n },\n defaults: {\n view: 'secondary',\n size: 'm',\n stretching: 'auto',\n },\n};\n"],"names":["buttonRoot","Root","forwardRef","props","ref","children","view","size","text","value","contentLeft","contentRight","_props$contentPlacing","contentPlacing","isLoading","loader","stretch","square","pin","disabled","focused","outlined","className","blur","style","_props$stretching","stretching","rest","_objectWithoutProperties","_excluded","txt","hasRightContentMargin","Boolean","hasLeftContentMargin","stretchingClass","classes","filledStretching","concat","contentRelaxedClass","contentRelaxed","undefined","squareClass","buttonSquare","isLoadingClass","buttonLoading","buttonBorderRadius","convertRoundnessMatrix","tokens","buttonRadius","buttonHeight","contentPlacingMapper","relaxed","contentPlacementValue","React","createElement","_extends","type","cx","buttonItem","_objectSpread","LoadWrap","StyledContentLeft","hasContentMargin","ButtonText","ButtonValue","StyledContentRight","Loader","_StyledSpinner","StyledSpinner","buttonConfig","name","tag","layout","base","variations","css","viewCSS","sizeCSS","disabledCSS","attrs","focusedCSS","blurred","blurredCSS","stretchingCSS","defaults"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;IA0BaA,UAAU,GAAG,SAAbA,UAAUA,CAAIC,IAA+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AE5F,CAAC,EACVG,SAAS,iBAAIuC,sBAAA,CAAAC,aAAA,CAACY,oBAAM,EAAEnD,IAAAA,EAAAA,MAAM,IAAAoD,cAAA,KAAAA,cAAA,gBAAId,sBAAA,CAAAC,aAAA,CAACc,2BAAa,EAAE,IAAA,CAAC,CAAS,CACzD,CAAC,CAAA;AAEf,GAAC,CAAC,CAAA;AAAA,EAAA;AAEC,IAAMC,YAAY,GAAG;AACxBC,EAAAA,IAAI,EAAE,QAAQ;AACdC,EAAAA,GAAG,EAAE,QAAQ;AACbC,EAAAA,MAAM,EAAExE,UAAU;AAClByE,EAAAA,IAAI,EAAJA,kBAAI;AACJC,EAAAA,UAAU,EAAE;AACRpE,IAAAA,IAAI,EAAE;AACFqE,MAAAA,GAAG,EAAEC,SAAAA;KACR;AACDrE,IAAAA,IAAI,EAAE;AACFoE,MAAAA,GAAG,EAAEE,WAAAA;KACR;AACD1D,IAAAA,QAAQ,EAAE;AACNwD,MAAAA,GAAG,EAAEG,WAAW;AAChBC,MAAAA,KAAK,EAAE,IAAA;KACV;AACD3D,IAAAA,OAAO,EAAE;AACLuD,MAAAA,GAAG,EAAEK,WAAAA;AACL;KACH;AACDC,IAAAA,OAAO,EAAE;AACLN,MAAAA,GAAG,EAAEO,WAAAA;KACR;AACDxD,IAAAA,UAAU,EAAE;AACRiD,MAAAA,GAAG,EAAEQ,WAAAA;AACT,KAAA;GACH;AACDC,EAAAA,QAAQ,EAAE;AACN9E,IAAAA,IAAI,EAAE,WAAW;AACjBC,IAAAA,IAAI,EAAE,GAAG;AACTmB,IAAAA,UAAU,EAAE,MAAA;AAChB,GAAA;AACJ;;;;;"}
|
1
|
+
{"version":3,"file":"Button.js","sources":["../../../src/components/Button/Button.tsx"],"sourcesContent":["import React, { forwardRef } from 'react';\nimport type { CSSProperties } from 'react';\n\nimport type { RootProps } from '../../engines';\nimport { convertRoundnessMatrix } from '../../utils/roundness';\nimport { cx } from '../../utils';\n\nimport { base as viewCSS } from './variations/_view/base';\nimport { base as sizeCSS } from './variations/_size/base';\nimport { base as disabledCSS } from './variations/_disabled/base';\nimport { base as focusedCSS } from './variations/_focused/base';\nimport { base as stretchingCSS } from './variations/_stretching/base';\nimport { base as blurredCSS } from './variations/_blurred/base';\nimport type { ButtonProps, ContentPlacementMapper } from './Button.types';\nimport {\n base,\n ButtonText,\n ButtonValue,\n Loader,\n LoadWrap,\n StyledContentLeft,\n StyledContentRight,\n StyledSpinner,\n} from './Button.styles';\nimport { classes, tokens } from './Button.tokens';\n\nexport const buttonRoot = (Root: RootProps<HTMLButtonElement, ButtonProps>) =>\n forwardRef<HTMLButtonElement, ButtonProps>((props, ref) => {\n const {\n children,\n view,\n size,\n text,\n value,\n contentLeft,\n contentRight,\n contentPlacing = 'default',\n isLoading,\n loader,\n stretch,\n square,\n pin,\n disabled,\n focused,\n outlined,\n className,\n blur,\n style,\n stretching = 'auto',\n ...rest\n } = props;\n\n const txt = typeof children === 'string' ? children : text;\n const hasRightContentMargin = Boolean(children || txt || value || contentRight);\n const hasLeftContentMargin = Boolean(contentLeft ? contentLeft && (txt || value) : txt || value);\n\n const stretchingClass = stretch\n ? classes.filledStretching\n : classes[`${stretching}Stretching` as keyof typeof classes];\n const contentRelaxedClass = contentPlacing === 'relaxed' ? classes.contentRelaxed : undefined;\n const squareClass = square ? classes.buttonSquare : undefined;\n const isLoadingClass = isLoading ? classes.buttonLoading : undefined;\n const buttonBorderRadius = pin\n ? convertRoundnessMatrix(pin, `var(${tokens.buttonRadius})`, `var(${tokens.buttonHeight})`)\n : `var(${tokens.buttonRadius}, calc(var(${tokens.buttonHeight}) / 4))`;\n\n const contentPlacingMapper: ContentPlacementMapper = {\n default: 'center',\n relaxed: 'space-between',\n };\n\n const contentPlacementValue = contentPlacing ? contentPlacingMapper[contentPlacing] : 'center';\n\n return (\n <Root\n type=\"button\"\n ref={ref}\n view={view}\n size={size}\n value={value}\n disabled={disabled}\n focused={focused || outlined}\n contentPlacing={contentPlacing}\n className={cx(squareClass, stretchingClass, classes.buttonItem, isLoadingClass, className)}\n style={\n {\n ...style,\n '--plasma_computed-btn-br': buttonBorderRadius,\n '--plasma_private-blur': blur,\n } as CSSProperties\n }\n {...rest}\n >\n <LoadWrap contentPlacing={contentPlacementValue} isLoading={isLoading}>\n {contentLeft && (\n <StyledContentLeft hasContentMargin={hasRightContentMargin}>{contentLeft}</StyledContentLeft>\n )}\n {txt ? <ButtonText className={contentRelaxedClass}>{txt}</ButtonText> : children}\n {value && <ButtonValue>{value}</ButtonValue>}\n {contentRight && (\n <StyledContentRight hasContentMargin={hasLeftContentMargin}>{contentRight}</StyledContentRight>\n )}\n </LoadWrap>\n {isLoading && <Loader>{loader || <StyledSpinner />}</Loader>}\n </Root>\n );\n });\n\nexport const buttonConfig = {\n name: 'Button',\n tag: 'button',\n layout: buttonRoot,\n base,\n variations: {\n view: {\n css: viewCSS,\n },\n size: {\n css: sizeCSS,\n },\n disabled: {\n css: disabledCSS,\n attrs: true,\n },\n focused: {\n css: focusedCSS,\n // TODO: isLoading => disabled\n },\n blurred: {\n css: blurredCSS,\n },\n stretching: {\n css: stretchingCSS,\n },\n },\n defaults: {\n view: 'secondary',\n size: 'm',\n stretching: 'auto',\n },\n};\n"],"names":["buttonRoot","Root","forwardRef","props","ref","children","view","size","text","value","contentLeft","contentRight","_props$contentPlacing","contentPlacing","isLoading","loader","stretch","square","pin","disabled","focused","outlined","className","blur","style","_props$stretching","stretching","rest","_objectWithoutProperties","_excluded","txt","hasRightContentMargin","Boolean","hasLeftContentMargin","stretchingClass","classes","filledStretching","concat","contentRelaxedClass","contentRelaxed","undefined","squareClass","buttonSquare","isLoadingClass","buttonLoading","buttonBorderRadius","convertRoundnessMatrix","tokens","buttonRadius","buttonHeight","contentPlacingMapper","relaxed","contentPlacementValue","React","createElement","_extends","type","cx","buttonItem","_objectSpread","LoadWrap","StyledContentLeft","hasContentMargin","ButtonText","ButtonValue","StyledContentRight","Loader","_StyledSpinner","StyledSpinner","buttonConfig","name","tag","lay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.buttonRoot = function buttonRoot(Root) {
|
|
54
54
|
stretching = _props$stretching === void 0 ? 'auto' : _props$stretching,
|
55
55
|
rest = _objectWithoutProperties(props, _excluded);
|
56
56
|
var txt = typeof children === 'string' ? children : text;
|
57
|
-
var hasRightContentMargin = Boolean(txt || value || contentRight);
|
57
|
+
var hasRightContentMargin = Boolean(children || txt || value || contentRight);
|
58
58
|
var hasLeftContentMargin = Boolean(contentLeft ? contentLeft && (txt || value) : txt || value);
|
59
59
|
var stretchingClass = stretch ? _Button2.classes.filledStretching : _Button2.classes["".concat(stretching, "Stretching")];
|
60
60
|
var contentRelaxedClass = contentPlacing === 'relaxed' ? _Button2.classes.contentRelaxed : undefined;
|
@@ -46,7 +46,7 @@ export var buttonRoot = function buttonRoot(Root) {
|
|
46
46
|
stretching = _props$stretching === void 0 ? 'auto' : _props$stretching,
|
47
47
|
rest = _objectWithoutProperties(props, _excluded);
|
48
48
|
var txt = typeof children === 'string' ? children : text;
|
49
|
-
var hasRightContentMargin = Boolean(txt || value || contentRight);
|
49
|
+
var hasRightContentMargin = Boolean(children || txt || value || contentRight);
|
50
50
|
var hasLeftContentMargin = Boolean(contentLeft ? contentLeft && (txt || value) : txt || value);
|
51
51
|
var stretchingClass = stretch ? classes.filledStretching : classes["".concat(stretching, "Stretching")];
|
52
52
|
var contentRelaxedClass = contentPlacing === 'relaxed' ? classes.contentRelaxed : undefined;
|
@@ -39,7 +39,7 @@ var buttonRoot = function buttonRoot(Root) {
|
|
39
39
|
stretching = _props$stretching === void 0 ? 'auto' : _props$stretching,
|
40
40
|
rest = _objectWithoutProperties(props, _excluded);
|
41
41
|
var txt = typeof children === 'string' ? children : text;
|
42
|
-
var hasRightContentMargin = Boolean(txt || value || contentRight);
|
42
|
+
var hasRightContentMargin = Boolean(children || txt || value || contentRight);
|
43
43
|
var hasLeftContentMargin = Boolean(contentLeft ? contentLeft && (txt || value) : txt || value);
|
44
44
|
var stretchingClass = stretch ? classes.filledStretching : classes["".concat(stretching, "Stretching")];
|
45
45
|
var contentRelaxedClass = contentPlacing === 'relaxed' ? classes.contentRelaxed : undefined;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Button.js","sources":["../../../src/components/Button/Button.tsx"],"sourcesContent":["import React, { forwardRef } from 'react';\nimport type { CSSProperties } from 'react';\n\nimport type { RootProps } from '../../engines';\nimport { convertRoundnessMatrix } from '../../utils/roundness';\nimport { cx } from '../../utils';\n\nimport { base as viewCSS } from './variations/_view/base';\nimport { base as sizeCSS } from './variations/_size/base';\nimport { base as disabledCSS } from './variations/_disabled/base';\nimport { base as focusedCSS } from './variations/_focused/base';\nimport { base as stretchingCSS } from './variations/_stretching/base';\nimport { base as blurredCSS } from './variations/_blurred/base';\nimport type { ButtonProps, ContentPlacementMapper } from './Button.types';\nimport {\n base,\n ButtonText,\n ButtonValue,\n Loader,\n LoadWrap,\n StyledContentLeft,\n StyledContentRight,\n StyledSpinner,\n} from './Button.styles';\nimport { classes, tokens } from './Button.tokens';\n\nexport const buttonRoot = (Root: RootProps<HTMLButtonElement, ButtonProps>) =>\n forwardRef<HTMLButtonElement, ButtonProps>((props, ref) => {\n const {\n children,\n view,\n size,\n text,\n value,\n contentLeft,\n contentRight,\n contentPlacing = 'default',\n isLoading,\n loader,\n stretch,\n square,\n pin,\n disabled,\n focused,\n outlined,\n className,\n blur,\n style,\n stretching = 'auto',\n ...rest\n } = props;\n\n const txt = typeof children === 'string' ? children : text;\n const hasRightContentMargin = Boolean(txt || value || contentRight);\n const hasLeftContentMargin = Boolean(contentLeft ? contentLeft && (txt || value) : txt || value);\n\n const stretchingClass = stretch\n ? classes.filledStretching\n : classes[`${stretching}Stretching` as keyof typeof classes];\n const contentRelaxedClass = contentPlacing === 'relaxed' ? classes.contentRelaxed : undefined;\n const squareClass = square ? classes.buttonSquare : undefined;\n const isLoadingClass = isLoading ? classes.buttonLoading : undefined;\n const buttonBorderRadius = pin\n ? convertRoundnessMatrix(pin, `var(${tokens.buttonRadius})`, `var(${tokens.buttonHeight})`)\n : `var(${tokens.buttonRadius}, calc(var(${tokens.buttonHeight}) / 4))`;\n\n const contentPlacingMapper: ContentPlacementMapper = {\n default: 'center',\n relaxed: 'space-between',\n };\n\n const contentPlacementValue = contentPlacing ? contentPlacingMapper[contentPlacing] : 'center';\n\n return (\n <Root\n type=\"button\"\n ref={ref}\n view={view}\n size={size}\n value={value}\n disabled={disabled}\n focused={focused || outlined}\n contentPlacing={contentPlacing}\n className={cx(squareClass, stretchingClass, classes.buttonItem, isLoadingClass, className)}\n style={\n {\n ...style,\n '--plasma_computed-btn-br': buttonBorderRadius,\n '--plasma_private-blur': blur,\n } as CSSProperties\n }\n {...rest}\n >\n <LoadWrap contentPlacing={contentPlacementValue} isLoading={isLoading}>\n {contentLeft && (\n <StyledContentLeft hasContentMargin={hasRightContentMargin}>{contentLeft}</StyledContentLeft>\n )}\n {txt ? <ButtonText className={contentRelaxedClass}>{txt}</ButtonText> : children}\n {value && <ButtonValue>{value}</ButtonValue>}\n {contentRight && (\n <StyledContentRight hasContentMargin={hasLeftContentMargin}>{contentRight}</StyledContentRight>\n )}\n </LoadWrap>\n {isLoading && <Loader>{loader || <StyledSpinner />}</Loader>}\n </Root>\n );\n });\n\nexport const buttonConfig = {\n name: 'Button',\n tag: 'button',\n layout: buttonRoot,\n base,\n variations: {\n view: {\n css: viewCSS,\n },\n size: {\n css: sizeCSS,\n },\n disabled: {\n css: disabledCSS,\n attrs: true,\n },\n focused: {\n css: focusedCSS,\n // TODO: isLoading => disabled\n },\n blurred: {\n css: blurredCSS,\n },\n stretching: {\n css: stretchingCSS,\n },\n },\n defaults: {\n view: 'secondary',\n size: 'm',\n stretching: 'auto',\n },\n};\n"],"names":["buttonRoot","Root","forwardRef","props","ref","children","view","size","text","value","contentLeft","contentRight","_props$contentPlacing","contentPlacing","isLoading","loader","stretch","square","pin","disabled","focused","outlined","className","blur","style","_props$stretching","stretching","rest","_objectWithoutProperties","_excluded","txt","hasRightContentMargin","Boolean","hasLeftContentMargin","stretchingClass","classes","filledStretching","concat","contentRelaxedClass","contentRelaxed","undefined","squareClass","buttonSquare","isLoadingClass","buttonLoading","buttonBorderRadius","convertRoundnessMatrix","tokens","buttonRadius","buttonHeight","contentPlacingMapper","relaxed","contentPlacementValue","React","createElement","_extends","type","cx","buttonItem","_objectSpread","LoadWrap","StyledContentLeft","hasContentMargin","ButtonText","ButtonValue","StyledContentRight","Loader","_StyledSpinner","StyledSpinner","buttonConfig","name","tag","layout","base","variations","css","viewCSS","sizeCSS","disabledCSS","attrs","focusedCSS","blurred","blurredCSS","stretchingCSS","defaults"],"mappings":";;;;;;;;;;;;;;;IA0BaA,UAAU,GAAG,SAAbA,UAAUA,CAAIC,IAA+C,EAAA;AAAA,EAAA,oBACtEC,UAAU,CAAiC,UAACC,KAAK,EAAEC,GAAG,EAAK;AACvD,IAAA,IACIC,QAAQ,GAqBRF,KAAK,CArBLE,QAAQ;MACRC,IAAI,GAoBJH,KAAK,CApBLG,IAAI;MACJC,IAAI,GAmBJJ,KAAK,CAnBLI,IAAI;MACJC,IAAI,GAkBJL,KAAK,CAlBLK,IAAI;MACJC,KAAK,GAiBLN,KAAK,CAjBLM,KAAK;MACLC,WAAW,GAgBXP,KAAK,CAhBLO,WAAW;MACXC,YAAY,GAeZR,KAAK,CAfLQ,YAAY;MAAAC,qBAAA,GAeZT,KAAK,CAdLU,cAAc;AAAdA,MAAAA,cAAc,GAAAD,qBAAA,KAAG,KAAA,CAAA,GAAA,SAAS,GAAAA,qBAAA;MAC1BE,SAAS,GAaTX,KAAK,CAbLW,SAAS;MACTC,MAAM,GAYNZ,KAAK,CAZLY,MAAM;MACNC,OAAO,GAWPb,KAAK,CAXLa,OAAO;MACPC,MAAM,GAUNd,KAAK,CAVLc,MAAM;MACNC,GAAG,GASHf,KAAK,CATLe,GAAG;MACHC,QAAQ,GAQRhB,KAAK,CARLgB,QAAQ;MACRC,OAAO,GAOPjB,KAAK,CAPLiB,OAAO;MACPC,QAAQ,GAMRl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RiD,MAAAA,GAAG,EAAEQ,MAAAA;AACT,KAAA;GACH;AACDC,EAAAA,QAAQ,EAAE;AACN9E,IAAAA,IAAI,EAAE,WAAW;AACjBC,IAAAA,IAAI,EAAE,GAAG;AACTmB,IAAAA,UAAU,EAAE,MAAA;AAChB,GAAA;AACJ;;;;"}
|
1
|
+
{"version":3,"file":"Button.js","sources":["../../../src/components/Button/Button.tsx"],"sourcesContent":["import React, { forwardRef } from 'react';\nimport type { CSSProperties } from 'react';\n\nimport type { RootProps } from '../../engines';\nimport { convertRoundnessMatrix } from '../../utils/roundness';\nimport { cx } from '../../utils';\n\nimport { base as viewCSS } from './variations/_view/base';\nimport { base as sizeCSS } from './variations/_size/base';\nimport { base as disabledCSS } from './variations/_disabled/base';\nimport { base as focusedCSS } from './variations/_focused/base';\nimport { base as stretchingCSS } from './variations/_stretching/base';\nimport { base as blurredCSS } from './variations/_blurred/base';\nimport type { ButtonProps, ContentPlacementMapper } from './Button.types';\nimport {\n base,\n ButtonText,\n ButtonValue,\n Loader,\n LoadWrap,\n StyledContentLeft,\n StyledContentRight,\n StyledSpinner,\n} from './Button.styles';\nimport { classes, tokens } from './Button.tokens';\n\nexport const buttonRoot = (Root: RootProps<HTMLButtonElement, ButtonProps>) =>\n forwardRef<HTMLButtonElement, ButtonProps>((props, ref) => {\n const {\n children,\n view,\n size,\n text,\n value,\n contentLeft,\n contentRight,\n contentPlacing = 'default',\n isLoading,\n loader,\n stretch,\n square,\n pin,\n disabled,\n focused,\n outlined,\n className,\n blur,\n style,\n stretching = 'auto',\n ...rest\n } = props;\n\n const txt = typeof children === 'string' ? children : text;\n const hasRightContentMargin = Boolean(children || txt || value || contentRight);\n const hasLeftContentMargin = Boolean(contentLeft ? contentLeft && (txt || value) : txt || value);\n\n const stretchingClass = stretch\n ? classes.filledStretching\n : classes[`${stretching}Stretching` as keyof typeof classes];\n const contentRelaxedClass = contentPlacing === 'relaxed' ? classes.contentRelaxed : undefined;\n const squareClass = square ? classes.buttonSquare : undefined;\n const isLoadingClass = isLoading ? classes.buttonLoading : undefined;\n const buttonBorderRadius = pin\n ? convertRoundnessMatrix(pin, `var(${tokens.buttonRadius})`, `var(${tokens.buttonHeight})`)\n : `var(${tokens.buttonRadius}, calc(var(${tokens.buttonHeight}) / 4))`;\n\n const contentPlacingMapper: ContentPlacementMapper = {\n default: 'center',\n relaxed: 'space-between',\n };\n\n const contentPlacementValue = contentPlacing ? contentPlacingMapper[contentPlacing] : 'center';\n\n return (\n <Root\n type=\"button\"\n ref={ref}\n view={view}\n size={size}\n value={value}\n disabled={disabled}\n focused={focused || outlined}\n contentPlacing={contentPlacing}\n className={cx(squareClass, stretchingClass, classes.buttonItem, isLoadingClass, className)}\n style={\n {\n ...style,\n '--plasma_computed-btn-br': buttonBorderRadius,\n '--plasma_private-blur': blur,\n } as CSSProperties\n }\n {...rest}\n >\n <LoadWrap contentPlacing={contentPlacementValue} isLoading={isLoading}>\n {contentLeft && (\n <StyledContentLeft hasContentMargin={hasRightContentMargin}>{contentLeft}</StyledContentLeft>\n )}\n {txt ? <ButtonText className={contentRelaxedClass}>{txt}</ButtonText> : children}\n {value && <ButtonValue>{value}</ButtonValue>}\n {contentRight && (\n <StyledContentRight hasContentMargin={hasLeftContentMargin}>{contentRight}</StyledContentRight>\n )}\n </LoadWrap>\n {isLoading && <Loader>{loader || <StyledSpinner />}</Loader>}\n </Root>\n );\n });\n\nexport const buttonConfig = {\n name: 'Button',\n tag: 'button',\n layout: buttonRoot,\n base,\n variations: {\n view: {\n css: viewCSS,\n },\n size: {\n css: sizeCSS,\n },\n disabled: {\n css: disabledCSS,\n attrs: true,\n },\n focused: {\n css: focusedCSS,\n // TODO: isLoading => disabled\n },\n blurred: {\n css: blurredCSS,\n },\n stretching: {\n css: stretchingCSS,\n },\n },\n defaults: {\n view: 'secondary',\n size: 'm',\n stretching: 'auto',\n },\n};\n"],"names":["buttonRoot","Root","forwardRef","props","ref","children","view","size","text","value","contentLeft","contentRight","_props$contentPlacing","contentPlacing","isLoading","loader","stretch","square","pin","disabled","focused","outlined","className","blur","style","_props$stretching","stretching","rest","_objectWithoutProperties","_excluded","txt","hasRightContentMargin","Boolean","hasLeftContentMargin","stretchingClass","classes","filledStretching","concat","contentRelaxedClass","contentRelaxed","undefined","squareClass","buttonSquare","isLoadingClass","buttonLoading","buttonBorderRadius","convertRoundnessMatrix","tokens","buttonRadius","buttonHeight","contentPlacingMapper","relaxed","contentPlacementValue","React","createElement","_extends","type","cx","buttonItem","_objectSpread","LoadWrap","StyledContentLeft","hasContentMargin","ButtonText","ButtonValue","StyledContentRight","Loader","_StyledSpinner","StyledSpinner","buttonConfig","name","tag","layout","base","variations","css","viewCSS","sizeCSS","disabledCSS","attrs","focusedCSS","blurred","blurredCSS","stretchingCSS","defaults"],"mappings":";;;;;;;;;;;;;;;IA0BaA,UAAU,GAAG,SAAbA,UAAUA,CAAIC,IAA+C,EAAA;AAAA,EAAA,oBACtEC,UAAU,CAAiC,UAACC,KAAK,EAAEC,GAAG,EAAK;AACvD,IAAA,IACIC,QAAQ,GAqBRF,KAAK,CArBLE,QAAQ;MACRC,IAAI,GAoBJH,KAAK,CApBLG,IAAI;MACJC,IAAI,GAmBJJ,KAAK,CAnBLI,IAAI;MACJC,IAAI,GAkBJL,KAAK,CAlBLK,IAAI;MACJC,KAAK,GAiBLN,KAAK,CAjBLM,KAAK;MACLC,WAAW,GAgBXP,KAAK,CAhBLO,WAAW;MACXC,YAAY,GAeZR,KAAK,CAfLQ,YAAY;MAAAC,qBAAA,GAeZT,KAAK,CAdLU,cAAc;AAAdA,MAAAA,cAAc,GAAAD,qBAAA,KAAG,KAAA,CAAA,GAAA,SAAS,GAAAA,qBAAA;MAC1BE,SAAS,GAaTX,KAAK,CAbLW,SAAS;MACTC,MAAM,GAYNZ,KAAK,CAZLY,MAAM;MACNC,OAAO,GAWPb,KAAK,CAXLa,OAAO;MACPC,MAAM,GAUNd,KAAK,CAVLc,MAAM;MACNC,GAAG,GASHf,KAAK,C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D,MAAAA,GAAG,EAAEK,MAAAA;AACL;KACH;AACDC,IAAAA,OAAO,EAAE;AACLN,MAAAA,GAAG,EAAEO,MAAAA;KACR;AACDxD,IAAAA,UAAU,EAAE;AACRiD,MAAAA,GAAG,EAAEQ,MAAAA;AACT,KAAA;GACH;AACDC,EAAAA,QAAQ,EAAE;AACN9E,IAAAA,IAAI,EAAE,WAAW;AACjBC,IAAAA,IAAI,EAAE,GAAG;AACTmB,IAAAA,UAAU,EAAE,MAAA;AAChB,GAAA;AACJ;;;;"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@salutejs/plasma-new-hope",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.315.0-dev.0",
|
4
4
|
"description": "Salute Design System blueprint",
|
5
5
|
"main": "cjs/index.js",
|
6
6
|
"module": "es/index.js",
|
@@ -135,5 +135,5 @@
|
|
135
135
|
"sideEffects": [
|
136
136
|
"*.css"
|
137
137
|
],
|
138
|
-
"gitHead": "
|
138
|
+
"gitHead": "575892386f189ffa7ef7880204680b95f4db4010"
|
139
139
|
}
|
@@ -54,7 +54,7 @@ var buttonRoot = exports.buttonRoot = function buttonRoot(Root) {
|
|
54
54
|
stretching = _props$stretching === void 0 ? 'auto' : _props$stretching,
|
55
55
|
rest = _objectWithoutProperties(props, _excluded);
|
56
56
|
var txt = typeof children === 'string' ? children : text;
|
57
|
-
var hasRightContentMargin = Boolean(txt || value || contentRight);
|
57
|
+
var hasRightContentMargin = Boolean(children || txt || value || contentRight);
|
58
58
|
var hasLeftContentMargin = Boolean(contentLeft ? contentLeft && (txt || value) : txt || value);
|
59
59
|
var stretchingClass = stretch ? _Button2.classes.filledStretching : _Button2.classes["".concat(stretching, "Stretching")];
|
60
60
|
var contentRelaxedClass = contentPlacing === 'relaxed' ? _Button2.classes.contentRelaxed : undefined;
|
@@ -46,7 +46,7 @@ export var buttonRoot = function buttonRoot(Root) {
|
|
46
46
|
stretching = _props$stretching === void 0 ? 'auto' : _props$stretching,
|
47
47
|
rest = _objectWithoutProperties(props, _excluded);
|
48
48
|
var txt = typeof children === 'string' ? children : text;
|
49
|
-
var hasRightContentMargin = Boolean(txt || value || contentRight);
|
49
|
+
var hasRightContentMargin = Boolean(children || txt || value || contentRight);
|
50
50
|
var hasLeftContentMargin = Boolean(contentLeft ? contentLeft && (txt || value) : txt || value);
|
51
51
|
var stretchingClass = stretch ? classes.filledStretching : classes["".concat(stretching, "Stretching")];
|
52
52
|
var contentRelaxedClass = contentPlacing === 'relaxed' ? classes.contentRelaxed : undefined;
|