@hh.ru/magritte-ui-chips-input 3.1.0 → 3.1.2
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/index.d.ts +1 -0
- package/index.js +1 -0
- package/index.js.map +1 -1
- package/index.mock.d.ts +5 -0
- package/index.mock.js +39 -0
- package/index.mock.js.map +1 -0
- package/package.json +7 -6
package/index.d.ts
CHANGED
package/index.js
CHANGED
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;"}
|
package/index.mock.d.ts
ADDED
package/index.mock.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { forwardRef } from 'react';
|
|
3
|
+
|
|
4
|
+
function enhance(mockComponent, staticProps) {
|
|
5
|
+
// удаляем внутренний свойства реакта, чтобы не перезаписать ими mockComponent
|
|
6
|
+
delete staticProps.type;
|
|
7
|
+
delete staticProps.$$typeof;
|
|
8
|
+
delete staticProps.render;
|
|
9
|
+
for (const prop in staticProps) {
|
|
10
|
+
mockComponent[prop] = staticProps[prop];
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
const MockComponent = ({ style, ...props }) => (
|
|
14
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
15
|
+
// @ts-ignore
|
|
16
|
+
// eslint-disable-next-line react/jsx-no-undef
|
|
17
|
+
jsx("Magritte-component-mock", { "style-data": style, ...props }));
|
|
18
|
+
/**
|
|
19
|
+
* Возвращает mock React компонента
|
|
20
|
+
*/
|
|
21
|
+
const mockComponent = (componentName, staticProps = {}, { withChildren, innerDependence } = {}) => {
|
|
22
|
+
const mockWrapper = forwardRef(({ children, ...props }, ref) => {
|
|
23
|
+
return (
|
|
24
|
+
// eslint-disable-next-line react/jsx-no-undef
|
|
25
|
+
jsxs(MockComponent, { ...props, _component: componentName, children: [innerDependence ? innerDependence(props, ref) : null, withChildren ? children : null] }));
|
|
26
|
+
});
|
|
27
|
+
staticProps && enhance(mockWrapper, staticProps);
|
|
28
|
+
mockWrapper.displayName = 'magritte-ref';
|
|
29
|
+
return mockWrapper;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
33
|
+
const { ThemeProvider } = jest.requireActual('@hh.ru/magritte-ui-theme-provider/index');
|
|
34
|
+
const Input = mockComponent('ChipsInput', undefined, {
|
|
35
|
+
withChildren: false,
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
export { Input, ThemeProvider };
|
|
39
|
+
//# sourceMappingURL=index.mock.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mock.js","sources":["../../mock-component/lib/setupMockComponent.js","../src/index.mock.ts"],"sourcesContent":["import { jsxs, jsx } from 'react/jsx-runtime';\nimport { forwardRef } from 'react';\n\nfunction enhance(mockComponent, staticProps) {\n // удаляем внутренний свойства реакта, чтобы не перезаписать ими mockComponent\n delete staticProps.type;\n delete staticProps.$$typeof;\n delete staticProps.render;\n for (const prop in staticProps) {\n mockComponent[prop] = staticProps[prop];\n }\n}\nconst MockComponent = ({ style, ...props }) => (\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\n// eslint-disable-next-line react/jsx-no-undef\njsx(\"Magritte-component-mock\", { \"style-data\": style, ...props }));\nconst MockComponentRenderProp = ({ style, ...props }) => (\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\n// eslint-disable-next-line react/jsx-no-undef\njsx(\"Magritte-component-mock-render-prop\", { \"style-data\": style, ...props }));\n/**\n * Возвращает mock React компонента\n */\nconst mockComponent = (componentName, staticProps = {}, { withChildren, innerDependence } = {}) => {\n const mockWrapper = forwardRef(({ children, ...props }, ref) => {\n return (\n // eslint-disable-next-line react/jsx-no-undef\n jsxs(MockComponent, { ...props, _component: componentName, children: [innerDependence ? innerDependence(props, ref) : null, withChildren ? children : null] }));\n });\n staticProps && enhance(mockWrapper, staticProps);\n mockWrapper.displayName = 'magritte-ref';\n return mockWrapper;\n};\n/**\n * Возвращает mock React компонента, который рендерит переданный в него пропс render\n *\n * @param {String} componentName наименование компонента\n * @param {Object} [staticProps] объект со свойствами, которыми необходимо усилить mock\n * @param {Object} [options] параметры мока\n * @param {boolean} [options.withChildren] флаг отвечает за рендеринг children компонента\n * @param {React.Component} [options.innerDependence] Реакт компонент, который рендерится внутри мока.\n * Необходим, когда mock компоненту требуется иметь\n * дополнительные элементы\n */\nconst mockComponentRenderProp = (componentName, staticProps, { withChildren, innerDependence, renderArguments } = { renderArguments: [] }) => {\n const mockWrapper = ({ render, children, ...props }) => (jsxs(MockComponentRenderProp, { ...props, _component: componentName, children: [innerDependence ? innerDependence(props) : null, withChildren ? children : null, render?.(...(renderArguments || []))] }));\n staticProps && enhance(mockWrapper, staticProps);\n mockWrapper.displayName = 'magritte-component-mock-render-prop';\n return mockWrapper;\n};\n\nexport { mockComponent, mockComponentRenderProp };\n//# sourceMappingURL=setupMockComponent.js.map\n","import { ForwardRefExoticComponent } from 'react';\n\nimport { mockComponent } from '@hh.ru/magritte-ui-mock-component';\n\nexport type * from '@hh.ru/magritte-ui-chips-input/types';\n\n// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\nconst { ThemeProvider } = jest.requireActual('@hh.ru/magritte-ui-theme-provider/index');\n\nexport { ThemeProvider };\n\nexport const Input: ForwardRefExoticComponent<Record<string, unknown>> = mockComponent('ChipsInput', undefined, {\n withChildren: false,\n});\n"],"names":[],"mappings":";;;AAGA,SAAS,OAAO,CAAC,aAAa,EAAE,WAAW,EAAE;AAC7C;AACA,IAAI,OAAO,WAAW,CAAC,IAAI,CAAC;AAC5B,IAAI,OAAO,WAAW,CAAC,QAAQ,CAAC;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@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hh.ru/magritte-ui-chips-input",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.2",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"types": "index.d.ts",
|
|
6
6
|
"sideEffects": [
|
|
@@ -27,10 +27,11 @@
|
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@hh.ru/magritte-common-use-multiple-refs": "1.1.4",
|
|
30
|
-
"@hh.ru/magritte-ui-chips-trigger": "3.2.
|
|
31
|
-
"@hh.ru/magritte-ui-input": "7.0.
|
|
32
|
-
"@hh.ru/magritte-ui-select": "8.6.
|
|
33
|
-
"@hh.ru/magritte-ui-suggest": "6.4.
|
|
30
|
+
"@hh.ru/magritte-ui-chips-trigger": "3.2.2",
|
|
31
|
+
"@hh.ru/magritte-ui-input": "7.0.3",
|
|
32
|
+
"@hh.ru/magritte-ui-select": "8.6.1",
|
|
33
|
+
"@hh.ru/magritte-ui-suggest": "6.4.1",
|
|
34
|
+
"@hh.ru/magritte-ui-theme-provider": "1.1.31"
|
|
34
35
|
},
|
|
35
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "fdb80d92b5a45a1f8d9652ba486e2c872504b759"
|
|
36
37
|
}
|