@salutejs/plasma-new-hope 0.335.1-canary.2209.17603494170.0 → 0.335.1-canary.2209.17629577358.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/engines/common.js +11 -1
- package/cjs/engines/common.js.map +1 -1
- package/emotion/cjs/engines/common.js +14 -1
- package/emotion/cjs/examples/components/Avatar/Avatar.config.js +23 -23
- package/emotion/cjs/examples/components/Combobox/Combobox.js +15 -0
- package/emotion/es/engines/common.js +14 -1
- package/emotion/es/examples/components/Avatar/Avatar.config.js +23 -23
- package/es/engines/common.js +12 -2
- package/es/engines/common.js.map +1 -1
- package/package.json +2 -2
- package/styled-components/cjs/engines/common.js +14 -1
- package/styled-components/cjs/examples/components/Avatar/Avatar.config.js +2 -2
- package/styled-components/es/engines/common.js +14 -1
- package/styled-components/es/examples/components/Avatar/Avatar.config.js +2 -2
- package/types/components/NumberFormat/NumberFormat.d.ts.map +1 -1
- package/types/components/NumberFormat/NumberFormat.types.d.ts +1 -1
- package/types/components/TextField/TextField.types.d.ts +2 -2
- package/types/engines/common.d.ts.map +1 -1
- package/types/examples/components/NumberFormat/NumberFormat.d.ts.map +1 -1
package/cjs/engines/common.js
CHANGED
@@ -37,10 +37,20 @@ var mergeConfig = function mergeConfig(baseConfig, userConfig) {
|
|
37
37
|
}
|
38
38
|
return res;
|
39
39
|
};
|
40
|
+
|
41
|
+
// INFO: Метод, который проводит слияние двух объектов
|
42
|
+
// INFO: если значение явно указанно как undefined/null/пустая строка, то будет взято значение указанное в default
|
43
|
+
function mergeWithoutNullable(defaults, componentProps) {
|
44
|
+
var props = Object.keys(defaults).reduce(function (acc, key) {
|
45
|
+
return _rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2({}, acc), {}, _rollupPluginBabelHelpers.defineProperty({}, key, [null, undefined, ''].includes(componentProps[key]) ? defaults[key] : componentProps[key]));
|
46
|
+
}, {});
|
47
|
+
return _rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2({}, componentProps), props);
|
48
|
+
}
|
40
49
|
function component(config) {
|
41
50
|
var Comp = config.layout(linaria._component(config));
|
42
51
|
return /*#__PURE__*/React__default.default.forwardRef(function (props, ref) {
|
43
|
-
|
52
|
+
var mergedProps = mergeWithoutNullable(config === null || config === void 0 ? void 0 : config.defaults, props);
|
53
|
+
return /*#__PURE__*/React__default.default.createElement(Comp, _rollupPluginBabelHelpers.extends({}, mergedProps, {
|
44
54
|
ref: ref
|
45
55
|
}));
|
46
56
|
});
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"common.js","sources":["../../src/engines/common.tsx"],"sourcesContent":["import React from 'react';\n\nimport { _component } from './linaria';\nimport type {\n ComponentConfig,\n HTMLTagList,\n PropsType,\n Variants,\n HTMLAttributesWithoutOnChange,\n HTMLAttributesWithoutOnChangeAndDefaultValue,\n} from './types';\n\nexport const mergeConfig = <\n Tag extends HTMLTagList,\n VariantList extends Variants,\n VariantsProps extends PropsType<VariantList>,\n LayoutPropsBase extends\n | React.HTMLAttributes<HTMLElement>\n | HTMLAttributesWithoutOnChange<HTMLElement>\n | HTMLAttributesWithoutOnChangeAndDefaultValue<HTMLElement>,\n LayoutPropsUser extends\n | React.HTMLAttributes<HTMLElement>\n | HTMLAttributesWithoutOnChange<HTMLElement>\n | HTMLAttributesWithoutOnChangeAndDefaultValue<HTMLElement>\n | undefined = undefined\n>(\n baseConfig: ComponentConfig<Tag, Variants, PropsType & LayoutPropsBase, LayoutPropsBase>,\n userConfig?: Partial<ComponentConfig<Tag, VariantList, VariantsProps, LayoutPropsUser>>,\n) => {\n const res = { ...baseConfig, ...userConfig };\n\n if (res.variations) {\n // copy variations base css\n // eslint-disable-next-line guard-for-in\n for (const key in res.variations) {\n const variant = baseConfig.variations[key];\n\n res.variations[key].css = variant?.css;\n /* start of bad decision */\n if (!res.variations[key].true && variant?.true) {\n res.variations[key].true = variant.true;\n }\n /* end of bad decision */\n if (variant?.attrs) {\n res.variations[key].attrs = variant.attrs;\n }\n }\n }\n\n // eslint-disable-next-line guard-for-in\n for (const key in baseConfig.defaults || {}) {\n if (!(key in res.defaults)) {\n res.defaults[key] = baseConfig.defaults[key];\n }\n }\n\n return res as ComponentConfig<\n Tag,\n VariantList,\n PropsType<VariantList>,\n LayoutPropsUser extends undefined ? LayoutPropsBase : LayoutPropsUser\n >;\n};\n\nexport function component<\n Tag extends HTMLTagList,\n VariantList extends Variants,\n VariantsProps extends PropsType<VariantList>,\n LayoutProps extends\n | React.HTMLAttributes<HTMLElement>\n | HTMLAttributesWithoutOnChange<HTMLElement>\n | HTMLAttributesWithoutOnChangeAndDefaultValue<HTMLElement>\n>(\n config: ComponentConfig<Tag, VariantList, VariantsProps, LayoutProps>,\n): React.FunctionComponent<VariantsProps & LayoutProps> {\n const Comp = config.layout(_component((config as unknown) as ComponentConfig));\n\n return React.forwardRef<VariantsProps & LayoutProps, any>((props, ref) =>
|
1
|
+
{"version":3,"file":"common.js","sources":["../../src/engines/common.tsx"],"sourcesContent":["import React from 'react';\n\nimport { _component } from './linaria';\nimport type {\n ComponentConfig,\n HTMLTagList,\n PropsType,\n Variants,\n HTMLAttributesWithoutOnChange,\n HTMLAttributesWithoutOnChangeAndDefaultValue,\n} from './types';\n\nexport const mergeConfig = <\n Tag extends HTMLTagList,\n VariantList extends Variants,\n VariantsProps extends PropsType<VariantList>,\n LayoutPropsBase extends\n | React.HTMLAttributes<HTMLElement>\n | HTMLAttributesWithoutOnChange<HTMLElement>\n | HTMLAttributesWithoutOnChangeAndDefaultValue<HTMLElement>,\n LayoutPropsUser extends\n | React.HTMLAttributes<HTMLElement>\n | HTMLAttributesWithoutOnChange<HTMLElement>\n | HTMLAttributesWithoutOnChangeAndDefaultValue<HTMLElement>\n | undefined = undefined\n>(\n baseConfig: ComponentConfig<Tag, Variants, PropsType & LayoutPropsBase, LayoutPropsBase>,\n userConfig?: Partial<ComponentConfig<Tag, VariantList, VariantsProps, LayoutPropsUser>>,\n) => {\n const res = { ...baseConfig, ...userConfig };\n\n if (res.variations) {\n // copy variations base css\n // eslint-disable-next-line guard-for-in\n for (const key in res.variations) {\n const variant = baseConfig.variations[key];\n\n res.variations[key].css = variant?.css;\n /* start of bad decision */\n if (!res.variations[key].true && variant?.true) {\n res.variations[key].true = variant.true;\n }\n /* end of bad decision */\n if (variant?.attrs) {\n res.variations[key].attrs = variant.attrs;\n }\n }\n }\n\n // eslint-disable-next-line guard-for-in\n for (const key in baseConfig.defaults || {}) {\n if (!(key in res.defaults)) {\n res.defaults[key] = baseConfig.defaults[key];\n }\n }\n\n return res as ComponentConfig<\n Tag,\n VariantList,\n PropsType<VariantList>,\n LayoutPropsUser extends undefined ? LayoutPropsBase : LayoutPropsUser\n >;\n};\n\n// INFO: Метод, который проводит слияние двух объектов\n// INFO: если значение явно указанно как undefined/null/пустая строка, то будет взято значение указанное в default\nfunction mergeWithoutNullable(defaults: any, componentProps: any) {\n const props = Object.keys(defaults).reduce((acc, key) => {\n return {\n ...acc,\n [key]: [null, undefined, ''].includes(componentProps[key]) ? defaults[key] : componentProps[key],\n };\n }, {});\n\n return { ...componentProps, ...props };\n}\n\nexport function component<\n Tag extends HTMLTagList,\n VariantList extends Variants,\n VariantsProps extends PropsType<VariantList>,\n LayoutProps extends\n | React.HTMLAttributes<HTMLElement>\n | HTMLAttributesWithoutOnChange<HTMLElement>\n | HTMLAttributesWithoutOnChangeAndDefaultValue<HTMLElement>\n>(\n config: ComponentConfig<Tag, VariantList, VariantsProps, LayoutProps>,\n): React.FunctionComponent<VariantsProps & LayoutProps> {\n const Comp = config.layout(_component((config as unknown) as ComponentConfig));\n\n return React.forwardRef<VariantsProps & LayoutProps, any>((props, ref) => {\n const mergedProps = mergeWithoutNullable(config?.defaults, props);\n\n return <Comp {...mergedProps} ref={ref} />;\n });\n}\n"],"names":["mergeConfig","baseConfig","userConfig","res","_objectSpread","variations","key","variant","css","attrs","defaults","mergeWithoutNullable","componentProps","props","Object","keys","reduce","acc","_defineProperty","undefined","includes","component","config","Comp","layout","_component","React","forwardRef","ref","mergedProps","createElement","_extends"],"mappings":";;;;;;;;;;;;AAYO,IAAMA,WAAW,GAAG,SAAdA,WAAWA,CAcpBC,UAAwF,EACxFC,UAAuF,EACtF;EACD,IAAMC,GAAG,GAAAC,uCAAA,CAAAA,uCAAA,CAAQH,EAAAA,EAAAA,UAAU,CAAKC,EAAAA,UAAU,CAAE,CAAA;EAE5C,IAAIC,GAAG,CAACE,UAAU,EAAE;AAChB;AACA;AACA,IAAA,KAAK,IAAMC,GAAG,IAAIH,GAAG,CAACE,UAAU,EAAE;AAC9B,MAAA,IAAME,OAAO,GAAGN,UAAU,CAACI,UAAU,CAACC,GAAG,CAAC,CAAA;AAE1CH,MAAAA,GAAG,CAACE,UAAU,CAACC,GAAG,CAAC,CAACE,GAAG,GAAGD,OAAO,KAAPA,IAAAA,IAAAA,OAAO,KAAPA,KAAAA,CAAAA,GAAAA,KAAAA,CAAAA,GAAAA,OAAO,CAAEC,GAAG,CAAA;AACtC;AACA,MAAA,IAAI,CAACL,GAAG,CAACE,UAAU,CAACC,GAAG,CAAC,CAAK,MAAA,CAAA,IAAIC,OAAO,KAAPA,IAAAA,IAAAA,OAAO,KAAPA,KAAAA,CAAAA,IAAAA,OAAO,QAAM,EAAE;QAC5CJ,GAAG,CAACE,UAAU,CAACC,GAAG,CAAC,CAAK,MAAA,CAAA,GAAGC,OAAO,CAAK,MAAA,CAAA,CAAA;AAC3C,OAAA;AACA;AACA,MAAA,IAAIA,OAAO,KAAPA,IAAAA,IAAAA,OAAO,eAAPA,OAAO,CAAEE,KAAK,EAAE;QAChBN,GAAG,CAACE,UAAU,CAACC,GAAG,CAAC,CAACG,KAAK,GAAGF,OAAO,CAACE,KAAK,CAAA;AAC7C,OAAA;AACJ,KAAA;AACJ,GAAA;;AAEA;EACA,KAAK,IAAMH,IAAG,IAAIL,UAAU,CAACS,QAAQ,IAAI,EAAE,EAAE;AACzC,I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;IAEjE,oBAAOa,sBAAA,CAAAI,aAAA,CAACP,IAAI,EAAAQ,iCAAA,KAAKF,WAAW,EAAA;AAAED,MAAAA,GAAG,EAAEA,GAAAA;AAAI,KAAA,CAAE,CAAC,CAAA;AAC9C,GAAC,CAAC,CAAA;AACN;;;;;"}
|
@@ -99,10 +99,23 @@ var mergeConfig = function(baseConfig, userConfig) {
|
|
99
99
|
}
|
100
100
|
return res;
|
101
101
|
};
|
102
|
+
// INFO: Метод, который проводит слияние двух объектов
|
103
|
+
// INFO: если значение явно указанно как undefined/null/пустая строка, то будет взято значение указанное в default
|
104
|
+
function mergeWithoutNullable(defaults, componentProps) {
|
105
|
+
var props = Object.keys(defaults).reduce(function(acc, key) {
|
106
|
+
return _object_spread_props(_object_spread({}, acc), _define_property({}, key, [
|
107
|
+
null,
|
108
|
+
undefined,
|
109
|
+
''
|
110
|
+
].includes(componentProps[key]) ? defaults[key] : componentProps[key]));
|
111
|
+
}, {});
|
112
|
+
return _object_spread({}, componentProps, props);
|
113
|
+
}
|
102
114
|
function component(config) {
|
103
115
|
var Comp = config.layout((0, _emotion._component)(config));
|
104
116
|
return /*#__PURE__*/ _react.default.forwardRef(function(props, ref) {
|
105
|
-
|
117
|
+
var mergedProps = mergeWithoutNullable(config === null || config === void 0 ? void 0 : config.defaults, props);
|
118
|
+
return /*#__PURE__*/ _react.default.createElement(Comp, _object_spread_props(_object_spread({}, mergedProps), {
|
106
119
|
ref: ref
|
107
120
|
}));
|
108
121
|
});
|