@semcore/core 1.11.8 → 1.11.11
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/CHANGELOG.md +18 -0
- package/README.md +6 -4
- package/lib/cjs/Component.js.map +1 -1
- package/lib/cjs/enhancement/Children.js.map +1 -1
- package/lib/cjs/enhancement/Root.js +1 -1
- package/lib/cjs/enhancement/Root.js.map +1 -1
- package/lib/cjs/enhancement/bindHandler.js.map +1 -1
- package/lib/cjs/enhancement/dataName.js.map +1 -1
- package/lib/cjs/enhancement/enhance.js.map +1 -1
- package/lib/cjs/enhancement/functionDefaultProps.js.map +1 -1
- package/lib/cjs/enhancement/hoistProps.js.map +1 -1
- package/lib/cjs/enhancement/inheritedName.js.map +1 -1
- package/lib/cjs/enhancement/staticChildren.js.map +1 -1
- package/lib/cjs/enhancement/style.js.map +1 -1
- package/lib/cjs/enhancement/uncontrolledProps.js.map +1 -1
- package/lib/cjs/index.js +4 -4
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/register.js.map +1 -1
- package/lib/cjs/styled/index.js.map +1 -1
- package/lib/cjs/styled/sstyled.js +4 -2
- package/lib/cjs/styled/sstyled.js.map +1 -1
- package/lib/es6/Component.js.map +1 -1
- package/lib/es6/enhancement/Children.js.map +1 -1
- package/lib/es6/enhancement/Root.js +1 -1
- package/lib/es6/enhancement/Root.js.map +1 -1
- package/lib/es6/enhancement/bindHandler.js.map +1 -1
- package/lib/es6/enhancement/dataName.js.map +1 -1
- package/lib/es6/enhancement/enhance.js.map +1 -1
- package/lib/es6/enhancement/functionDefaultProps.js.map +1 -1
- package/lib/es6/enhancement/hoistProps.js.map +1 -1
- package/lib/es6/enhancement/inheritedName.js.map +1 -1
- package/lib/es6/enhancement/staticChildren.js.map +1 -1
- package/lib/es6/enhancement/style.js.map +1 -1
- package/lib/es6/enhancement/uncontrolledProps.js.map +1 -1
- package/lib/es6/index.js +4 -4
- package/lib/es6/index.js.map +1 -1
- package/lib/es6/register.js.map +1 -1
- package/lib/es6/styled/index.js.map +1 -1
- package/lib/es6/styled/sstyled.js +4 -2
- package/lib/es6/styled/sstyled.js.map +1 -1
- package/package.json +2 -2
- package/src/Component.tsx +0 -108
- package/src/enhancement/Children.tsx +0 -104
- package/src/enhancement/Root.tsx +0 -78
- package/src/enhancement/bindHandler.tsx +0 -45
- package/src/enhancement/dataName.tsx +0 -12
- package/src/enhancement/enhance.tsx +0 -12
- package/src/enhancement/functionDefaultProps.tsx +0 -29
- package/src/enhancement/hoistProps.tsx +0 -88
- package/src/enhancement/inheritedName.tsx +0 -18
- package/src/enhancement/staticChildren.tsx +0 -128
- package/src/enhancement/style.tsx +0 -47
- package/src/enhancement/uncontrolledProps.tsx +0 -134
- package/src/index.tsx +0 -381
- package/src/register.tsx +0 -18
- package/src/styled/index.tsx +0 -9
- package/src/styled/sstyled.tsx +0 -150
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"sstyled.js","names":["cn","ReactNode","getStyles","reshadowGetStyles","RESHADOW_ID","isSSR","window","document","createElement","serverMap","map","css","serverStyles","id","insert","code","hash","concat","container","getElementById","head","appendChild","addEventListener","type","innerHTML","merge","s1","s2","Object","entries","reduce","acc","key","value","startsWith","assign","getClassAndVars","styles","name","props","getPropValue","substring","split","mod","modValue","propValue","undefined","Boolean","reshadowToShadow","obj","style","n","replace","sstyled","classes","extraProps","keys","length","className","Error","SHADOW_STYLES","Symbol"],"sources":["../../../src/styled/sstyled.tsx"],"sourcesContent":["/* eslint-disable */\nimport cn from 'classnames';\nimport { ReactNode } from 'react';\nimport { getStyles as reshadowGetStyles } from '@reshadow/core';\n\nconst RESHADOW_ID = '__reshadow__';\n\nconst isSSR = !(typeof window !== 'undefined' && window.document && window.document.createElement);\n\nconst serverMap = reshadowGetStyles().map;\n\nconst getStyles = () => ({\n map: serverMap,\n get css() {\n let serverStyles = '';\n for (const id in serverMap) {\n serverStyles += `<style type='text/css' id='${id}'>${serverMap[id]}</style>`;\n }\n return serverStyles;\n },\n});\n\nfunction insert(code, hash) {\n const id = 'reshadow-'.concat(hash);\n\n if (isSSR) {\n serverMap[id] = code;\n return;\n }\n\n let container = document.getElementById(RESHADOW_ID);\n\n if (!container) {\n container = document.createElement('object');\n container.id = RESHADOW_ID;\n\n if (document.head) {\n document.head.appendChild(container);\n } else {\n document.addEventListener('DOMContentLoaded', function () {\n document.head.appendChild(container);\n });\n }\n }\n\n let css = document.getElementById(id);\n\n if (!css) {\n css = document.createElement('style');\n css.id = id;\n // @ts-ignore\n css.type = 'text/css';\n container.appendChild(css);\n }\n\n css.innerHTML = code;\n}\n\nfunction merge(s1 = {}, s2 = {}) {\n return Object.entries(s2).reduce((acc, [key, value]) => {\n if (key.startsWith('@') || key.startsWith('--')) {\n acc[key] = value;\n } else {\n acc[key] = cn(acc[key], value);\n }\n return acc;\n }, Object.assign({}, s1));\n}\n\nfunction getClassAndVars(styles, name, props) {\n function getPropValue(key, props) {\n return props[`use:${key}`] ?? props[key];\n }\n\n return Object.entries(styles).reduce(\n (acc, [key, value]) => {\n if (key.startsWith('--')) {\n // @ts-ignore\n acc[1][value] = getPropValue(key.substring(2), props);\n } else if (name === key) {\n // @ts-ignore\n acc[0][value] = true;\n } else {\n const [mod, modValue] = key.split('=');\n const propValue = getPropValue(mod, props);\n if (modValue === undefined) {\n // @ts-ignore\n acc[0][value] = Boolean(propValue ?? false);\n } else {\n // @ts-ignore\n acc[0][value] = propValue == modValue;\n }\n }\n return acc;\n },\n [{}, {}],\n );\n}\n\nfunction reshadowToShadow(obj) {\n return Object.entries(obj).reduce((style, [name, value]) => {\n let n = name;\n if (name.startsWith('__')) {\n n = name.replace(/^__/, '');\n } else if (name.startsWith('_')) {\n n = name.replace(/^_/, '').replace('_', '=');\n }\n style[n] = value;\n return style;\n }, {});\n}\n\nfunction sstyled(\n styles = {},\n): ((ReactNode) => ReactNode) & {\n cn(name: string, props: any): any;\n} {\n // @ts-ignore\n return {\n cn(name, props) {\n const [classes, style] = getClassAndVars(reshadowToShadow(styles), name, props);\n const extraProps = {};\n\n if (Object.keys(classes).length) {\n // @ts-ignore\n extraProps.className = cn(props.className, classes);\n }\n\n if (Object.keys(style).length) {\n // @ts-ignore\n extraProps.style = Object.assign(style, props.style);\n }\n return {\n ...props,\n ...extraProps,\n };\n },\n };\n}\n\nsstyled.css = function (css): { [key: string]: string } {\n throw new Error('Enable babel plugin');\n};\nsstyled.insert = insert;\nsstyled.merge = merge;\nsstyled.getStyles = getStyles;\nsstyled.SHADOW_STYLES = Symbol('SHADOW_STYLES');\n\nexport { sstyled };\n/* eslint-enable */\n"],"mappings":";;;;;;;AAAA;AACA,OAAOA,GAAP,MAAe,YAAf;AACA,SAASC,SAAT,QAA0B,OAA1B;AACA,SAASC,SAAS,IAAIC,iBAAtB,QAA+C,gBAA/C;AAEA,IAAMC,WAAW,GAAG,cAApB;AAEA,IAAMC,KAAK,GAAG,EAAE,OAAOC,MAAP,KAAkB,WAAlB,IAAiCA,MAAM,CAACC,QAAxC,IAAoDD,MAAM,CAACC,QAAP,CAAgBC,aAAtE,CAAd;AAEA,IAAMC,SAAS,GAAGN,iBAAiB,GAAGO,GAAtC;;AAEA,IAAMR,SAAS,GAAG,SAAZA,SAAY;EAAA,OAAO;IACvBQ,GAAG,EAAED,SADkB;;IAEvB,IAAIE,GAAJ,GAAU;MACR,IAAIC,YAAY,GAAG,EAAnB;;MACA,KAAK,IAAMC,EAAX,IAAiBJ,SAAjB,EAA4B;QAC1BG,YAAY,yCAAkCC,EAAlC,eAAyCJ,SAAS,CAACI,EAAD,CAAlD,aAAZ;MACD;;MACD,OAAOD,YAAP;IACD;;EARsB,CAAP;AAAA,CAAlB;;AAWA,SAASE,MAAT,CAAgBC,IAAhB,EAAsBC,IAAtB,EAA4B;EAC1B,IAAMH,EAAE,GAAG,YAAYI,MAAZ,CAAmBD,IAAnB,CAAX;;EAEA,IAAIX,KAAJ,EAAW;IACTI,SAAS,CAACI,EAA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D;;MAED,IAAI1B,MAAM,CAAC4B,IAAP,CAAYN,KAAZ,EAAmBO,MAAvB,EAA+B;QAC7B;QACAF,UAAU,CAACL,KAAX,GAAmBtB,MAAM,CAACO,MAAP,CAAce,KAAd,EAAqBX,KAAK,CAACW,KAA3B,CAAnB;MACD;;MACD,uCACKX,KADL,GAEKgB,UAFL;IAID;EAlBI,CAAP;AAoBD;;AAEDF,OAAO,CAAC1C,GAAR,GAAc,UAAUA,GAAV,EAA0C;EACtD,MAAM,IAAIgD,KAAJ,CAAU,qBAAV,CAAN;AACD,CAFD;;AAGAN,OAAO,CAACvC,MAAR,GAAiBA,MAAjB;AACAuC,OAAO,CAAC5B,KAAR,GAAgBA,KAAhB;AACA4B,OAAO,CAACnD,SAAR,GAAoBA,SAApB;AACAmD,OAAO,CAACO,aAAR,GAAwBC,MAAM,CAAC,eAAD,CAA9B;AAEA,SAASR,OAAT;AACA"}
|
package/package.json
CHANGED
package/src/Component.tsx
DELETED
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
AllHTMLAttributes,
|
|
3
|
-
ForwardRefExoticComponent,
|
|
4
|
-
PureComponent,
|
|
5
|
-
ReactNode,
|
|
6
|
-
RefObject,
|
|
7
|
-
} from 'react';
|
|
8
|
-
import { IStyledProps } from './styled';
|
|
9
|
-
|
|
10
|
-
type KnownKeys<T> = {
|
|
11
|
-
[K in keyof T]: string extends K ? never : number extends K ? never : K;
|
|
12
|
-
} extends { [_ in keyof T]: infer U }
|
|
13
|
-
? U
|
|
14
|
-
: never;
|
|
15
|
-
|
|
16
|
-
export type HandlersType<UCProps> = { [K in keyof UCProps]?: <T = unknown>(arg: T) => void };
|
|
17
|
-
export type ChildrenType<Props = {}, Ctx = {}, UCProps = {}> =
|
|
18
|
-
| ((props: Props & Ctx, handlers: HandlersType<UCProps>) => ReactNode)
|
|
19
|
-
| ReactNode;
|
|
20
|
-
|
|
21
|
-
export type RootComponentHandler = (...args: any[]) => void | false;
|
|
22
|
-
|
|
23
|
-
export interface IRootComponentHandlers {
|
|
24
|
-
[key: string]: RootComponentHandler;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export interface IRootComponentProps<Props = {}, Ctx = {}> {
|
|
28
|
-
forwardRef?: RefObject<any>;
|
|
29
|
-
Children?: any;
|
|
30
|
-
children?: ChildrenType<Props, Ctx>;
|
|
31
|
-
styles?: IStyledProps['styles'];
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export type IComponentProps<Props = {}, Ctx = {}> = Props & IRootComponentProps<Props, Ctx>;
|
|
35
|
-
|
|
36
|
-
export type IFunctionProps<Props = {}, Ctx = {}> = IComponentProps<Props, Ctx> &
|
|
37
|
-
Omit<AllHTMLAttributes<any>, keyof IComponentProps<Props, Ctx>> & { Root?: Root };
|
|
38
|
-
|
|
39
|
-
export type PropsWithRenderFnChildren<Props = {}, Ctx = {}, UCProps = {}> = Omit<
|
|
40
|
-
Pick<Props, KnownKeys<Props>>,
|
|
41
|
-
'children'
|
|
42
|
-
> & {
|
|
43
|
-
children?: ChildrenType<Props, Ctx, UCProps>;
|
|
44
|
-
[key: string]: unknown;
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
export type CProps<Props, Ctx = {}, UCProps = {}> = Props & {
|
|
48
|
-
children?: ((props: Props & Ctx, handlers: UCProps) => React.ReactNode) | React.ReactNode;
|
|
49
|
-
};
|
|
50
|
-
export type ReturnEl = React.ReactElement | null;
|
|
51
|
-
|
|
52
|
-
export interface IRootNodeProps {
|
|
53
|
-
render: React.ElementType | string;
|
|
54
|
-
tag?: React.ElementType | string;
|
|
55
|
-
|
|
56
|
-
[key: string]: any;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
type Root = ForwardRefExoticComponent<IRootNodeProps>;
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* @deprecated since version ^1.8.0
|
|
63
|
-
*/
|
|
64
|
-
export type PropGetter<T extends (...args: any) => any> = <P>(props?: P) => ReturnType<T> & P;
|
|
65
|
-
/**
|
|
66
|
-
* @deprecated since version ^1.8.0
|
|
67
|
-
*/
|
|
68
|
-
export type PropGetterReturn<T extends (...args: any) => any> = Partial<ReturnType<T>>;
|
|
69
|
-
export type PropGetterFn = <T extends {}>(props?: T) => T & { [key: string]: unknown };
|
|
70
|
-
export type Merge<Props, HTMLProps> = Props & Omit<HTMLProps, keyof Props>;
|
|
71
|
-
export type MergeGetters<G1 extends (...args: any) => any, G2 extends (...args: any) => any> = <P>(
|
|
72
|
-
props?: P,
|
|
73
|
-
) => Merge<ReturnType<G1>, ReturnType<G2>> & P;
|
|
74
|
-
|
|
75
|
-
declare const Root: Root;
|
|
76
|
-
|
|
77
|
-
export { Root };
|
|
78
|
-
|
|
79
|
-
abstract class RootComponent<Props = {}, Context = {}, State = {}> extends PureComponent<
|
|
80
|
-
Props & IRootComponentProps<Props, Context>,
|
|
81
|
-
State
|
|
82
|
-
> {
|
|
83
|
-
get handlers(): Readonly<IRootComponentHandlers> {
|
|
84
|
-
return {};
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
get asProps() {
|
|
88
|
-
return {} as Readonly<
|
|
89
|
-
Merge<Props & IRootComponentProps<Props, Context>, AllHTMLAttributes<any>>
|
|
90
|
-
>;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
Root: Root;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
export const Component = RootComponent;
|
|
97
|
-
export type Component<
|
|
98
|
-
Props = {},
|
|
99
|
-
Context = {},
|
|
100
|
-
State = {},
|
|
101
|
-
Handlers extends IRootComponentHandlers = IRootComponentHandlers,
|
|
102
|
-
> = React.ComponentClass<Props, State> & {
|
|
103
|
-
handlers: Readonly<Handlers>;
|
|
104
|
-
|
|
105
|
-
asProps: Readonly<Merge<Props & IRootComponentProps<Props, Context>, AllHTMLAttributes<any>>>;
|
|
106
|
-
|
|
107
|
-
Root: Root;
|
|
108
|
-
};
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import { useContext } from 'react';
|
|
2
|
-
import { CONTEXT_COMPONENT } from '../index';
|
|
3
|
-
|
|
4
|
-
export const CHILDREN_COMPONENT = Symbol('CHILDREN_COMPONENT');
|
|
5
|
-
const CHILDREN_SELF = Symbol('CHILDREN_SELF');
|
|
6
|
-
|
|
7
|
-
const GETTER_REG = /^get[\w]+Props$/;
|
|
8
|
-
|
|
9
|
-
function splitPropsAndGetters(props) {
|
|
10
|
-
return Object.entries(props).reduce(
|
|
11
|
-
(acc, [key, value]) => {
|
|
12
|
-
if (GETTER_REG.exec(key) === null) {
|
|
13
|
-
acc.props[key] = value;
|
|
14
|
-
} else {
|
|
15
|
-
acc.getters[key] = value;
|
|
16
|
-
}
|
|
17
|
-
return acc;
|
|
18
|
-
},
|
|
19
|
-
{ props: {}, getters: {} },
|
|
20
|
-
);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
function getterToArray(getter) {
|
|
24
|
-
if (!Array.isArray(getter)) {
|
|
25
|
-
return typeof getter === 'function' ? [getter] : [];
|
|
26
|
-
}
|
|
27
|
-
return getter;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function mergeObjects(a = {}, b = {}) {
|
|
31
|
-
const core = { ...a, ...b };
|
|
32
|
-
return Object.keys(core).reduce((acc, key) => {
|
|
33
|
-
a[key] = getterToArray(a[key]);
|
|
34
|
-
b[key] = getterToArray(b[key]);
|
|
35
|
-
acc[key] = [...a[key], ...b[key]];
|
|
36
|
-
return acc;
|
|
37
|
-
}, {});
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function assignGettersChain(getters: Array<Function>) {
|
|
41
|
-
return function (props = {}) {
|
|
42
|
-
return getters.reduce((acc, getter) => {
|
|
43
|
-
return getter(acc);
|
|
44
|
-
}, props);
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function createChildren(Context, contexts) {
|
|
49
|
-
const Children = function () {
|
|
50
|
-
const children = Children.origin;
|
|
51
|
-
if (typeof children === 'function') {
|
|
52
|
-
const {
|
|
53
|
-
handlers = {},
|
|
54
|
-
getters = {},
|
|
55
|
-
...props
|
|
56
|
-
} = [...contexts, Context].reduce((acc, ctx) => {
|
|
57
|
-
const { handlers, ...propsAndGetters } = useContext(ctx);
|
|
58
|
-
const { props, getters } = splitPropsAndGetters(propsAndGetters);
|
|
59
|
-
return Object.assign({}, acc, {
|
|
60
|
-
handlers: Object.assign({}, acc.handlers, handlers),
|
|
61
|
-
getters: mergeObjects(acc.getters, getters),
|
|
62
|
-
...props,
|
|
63
|
-
});
|
|
64
|
-
}, Children.props);
|
|
65
|
-
|
|
66
|
-
const mergedGetters = Object.entries(getters).reduce((acc, [key, value]) => {
|
|
67
|
-
acc[key] = assignGettersChain(value as []);
|
|
68
|
-
return acc;
|
|
69
|
-
}, {});
|
|
70
|
-
|
|
71
|
-
return children({ ...props, ...mergedGetters }, handlers);
|
|
72
|
-
} else if (children === undefined) {
|
|
73
|
-
return null;
|
|
74
|
-
}
|
|
75
|
-
return children;
|
|
76
|
-
};
|
|
77
|
-
Children.origin = null;
|
|
78
|
-
Children.props = {};
|
|
79
|
-
Children[CHILDREN_COMPONENT] = true;
|
|
80
|
-
return Children;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
function Enhancement(Context, parent) {
|
|
84
|
-
return {
|
|
85
|
-
init: function () {
|
|
86
|
-
const contexts = (Array.isArray(parent) ? parent : [parent])
|
|
87
|
-
.map((component) => component[CONTEXT_COMPONENT])
|
|
88
|
-
.filter(Boolean);
|
|
89
|
-
this[CHILDREN_SELF] = createChildren(Context, contexts);
|
|
90
|
-
},
|
|
91
|
-
asProps: function (props) {
|
|
92
|
-
// TODO: learn the reason what it was used for (by lsroman)
|
|
93
|
-
// this[CHILDREN_SELF].origin = _Children ? _Children.origin : children;
|
|
94
|
-
this[CHILDREN_SELF].origin = props.children;
|
|
95
|
-
this[CHILDREN_SELF].props = props;
|
|
96
|
-
return {
|
|
97
|
-
...props,
|
|
98
|
-
Children: this[CHILDREN_SELF],
|
|
99
|
-
};
|
|
100
|
-
},
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
export default Enhancement;
|
package/src/enhancement/Root.tsx
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
// @ts-ignore
|
|
3
|
-
import assignProps from '@semcore/utils/lib/assignProps';
|
|
4
|
-
// @ts-ignore
|
|
5
|
-
import { useForkRef } from '@semcore/utils/lib/ref';
|
|
6
|
-
|
|
7
|
-
function createRootRender() {
|
|
8
|
-
// @ts-ignore
|
|
9
|
-
const Root = React.forwardRef(function ({ render: Tag, ...source }, ref) {
|
|
10
|
-
const {
|
|
11
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
12
|
-
Root: _Root,
|
|
13
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
14
|
-
styles,
|
|
15
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
16
|
-
children,
|
|
17
|
-
Children,
|
|
18
|
-
forwardRef = null,
|
|
19
|
-
...props
|
|
20
|
-
// @ts-ignore
|
|
21
|
-
} = Root.props;
|
|
22
|
-
|
|
23
|
-
const clearProps = Object.entries(props).reduce((props, [name, value]) => {
|
|
24
|
-
if (value !== undefined) {
|
|
25
|
-
props[name] = value;
|
|
26
|
-
}
|
|
27
|
-
return props;
|
|
28
|
-
}, {});
|
|
29
|
-
|
|
30
|
-
const child = {};
|
|
31
|
-
// TODO: need to find better check solution (by lsroman)
|
|
32
|
-
if (typeof Children.origin !== 'undefined') {
|
|
33
|
-
// @ts-ignore
|
|
34
|
-
child.children = <Children />;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const other = assignProps(
|
|
38
|
-
{
|
|
39
|
-
...clearProps,
|
|
40
|
-
ref: useForkRef(forwardRef, ref),
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
...child,
|
|
44
|
-
...source,
|
|
45
|
-
},
|
|
46
|
-
);
|
|
47
|
-
if (!Tag) {
|
|
48
|
-
throw new Error('`render` prop of Root is not provided');
|
|
49
|
-
}
|
|
50
|
-
return <Tag {...other} />;
|
|
51
|
-
});
|
|
52
|
-
// @ts-ignore
|
|
53
|
-
Root.props = {};
|
|
54
|
-
return Root;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
function Enhancement() {
|
|
58
|
-
return {
|
|
59
|
-
init: function () {
|
|
60
|
-
this.Root = createRootRender();
|
|
61
|
-
},
|
|
62
|
-
asProps: function (props, WrapperComponent, isFunction) {
|
|
63
|
-
if (isFunction) {
|
|
64
|
-
return {
|
|
65
|
-
...props,
|
|
66
|
-
Root: this.Root,
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
return props;
|
|
70
|
-
},
|
|
71
|
-
render: function (render, props) {
|
|
72
|
-
this.Root.props = props;
|
|
73
|
-
return render;
|
|
74
|
-
},
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
export default Enhancement;
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
function arraysEqual(a, b) {
|
|
2
|
-
if (a.length !== b.length) return false;
|
|
3
|
-
for (let i = 0; i < a.length; i++) {
|
|
4
|
-
if (a[i] !== b[i]) return false;
|
|
5
|
-
}
|
|
6
|
-
return true;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
function handlerBinder(fn) {
|
|
10
|
-
return function (...depsArgs) {
|
|
11
|
-
let memoizeds = [];
|
|
12
|
-
if (handlerBinder.hasher.has(fn)) {
|
|
13
|
-
memoizeds = handlerBinder.hasher.get(fn);
|
|
14
|
-
const memoized = memoizeds.find((memoized) => arraysEqual(memoized.deps, depsArgs));
|
|
15
|
-
if (memoized) return memoized.fn;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const bindFn = fn(...depsArgs).bind(fn);
|
|
19
|
-
memoizeds.push({
|
|
20
|
-
deps: depsArgs,
|
|
21
|
-
fn: bindFn,
|
|
22
|
-
});
|
|
23
|
-
handlerBinder.hasher.set(fn, memoizeds);
|
|
24
|
-
return bindFn;
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
handlerBinder.hasher = new WeakMap();
|
|
29
|
-
|
|
30
|
-
function Enhancement() {
|
|
31
|
-
return {
|
|
32
|
-
condition: function (Component, isFunction) {
|
|
33
|
-
return !isFunction;
|
|
34
|
-
},
|
|
35
|
-
init: function () {
|
|
36
|
-
Object.keys(this)
|
|
37
|
-
.filter((field) => field.startsWith('bindHandler'))
|
|
38
|
-
.forEach((name) => {
|
|
39
|
-
this[name] = handlerBinder(this[name].bind(this));
|
|
40
|
-
});
|
|
41
|
-
},
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export default Enhancement;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
function Enhancement() {
|
|
2
|
-
return {
|
|
3
|
-
condition: function (Component) {
|
|
4
|
-
return Boolean(Component.enhance && Component.enhance.length);
|
|
5
|
-
},
|
|
6
|
-
wrapperProps: function (props, WrapperComponent) {
|
|
7
|
-
return WrapperComponent.enhance.reduce((acc, enhance) => enhance(acc), props);
|
|
8
|
-
},
|
|
9
|
-
};
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export default Enhancement;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
function Enhancement() {
|
|
2
|
-
let defaultProps = {};
|
|
3
|
-
return {
|
|
4
|
-
condition: function (Component) {
|
|
5
|
-
if (!Component.defaultProps) {
|
|
6
|
-
return false;
|
|
7
|
-
}
|
|
8
|
-
if (typeof Component.defaultProps === 'function') {
|
|
9
|
-
return true;
|
|
10
|
-
}
|
|
11
|
-
return Boolean(Object.keys(Component.defaultProps).length);
|
|
12
|
-
},
|
|
13
|
-
static: function (WrapperComponent) {
|
|
14
|
-
defaultProps = WrapperComponent.defaultProps;
|
|
15
|
-
return {
|
|
16
|
-
defaultProps: {},
|
|
17
|
-
};
|
|
18
|
-
},
|
|
19
|
-
wrapperProps: function (props) {
|
|
20
|
-
if (typeof defaultProps === 'function') {
|
|
21
|
-
// TODO: optimization
|
|
22
|
-
return Object.assign({}, defaultProps(props), props);
|
|
23
|
-
}
|
|
24
|
-
return Object.assign({}, defaultProps, props);
|
|
25
|
-
},
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export default Enhancement;
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import { useContext, useState } from 'react';
|
|
2
|
-
// @ts-ignore
|
|
3
|
-
import assignProps from '@semcore/utils/lib/assignProps';
|
|
4
|
-
// @ts-ignore
|
|
5
|
-
import useEnhancedEffect from '@semcore/utils/lib/use/useEnhancedEffect';
|
|
6
|
-
// @ts-ignore
|
|
7
|
-
import pick from '@semcore/utils/lib/pick';
|
|
8
|
-
|
|
9
|
-
export const HOIST_CONTEXT = Symbol('HOIST_CONTEXT');
|
|
10
|
-
const HOIST_SELF = Symbol('HOIST_SELF');
|
|
11
|
-
const HOIST_SET = Symbol('HOIST_SET');
|
|
12
|
-
|
|
13
|
-
function flatChildComponent(childComponents) {
|
|
14
|
-
return Object.values(childComponents).reduce<unknown[]>((acc, Component) => {
|
|
15
|
-
if (Array.isArray(Component)) {
|
|
16
|
-
acc = [...acc, Component[0], ...flatChildComponent(Component[1])];
|
|
17
|
-
} else {
|
|
18
|
-
acc.push(Component);
|
|
19
|
-
}
|
|
20
|
-
return acc;
|
|
21
|
-
}, []);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
function Enhancement(childComponents, Context) {
|
|
25
|
-
return {
|
|
26
|
-
condition: function (Component) {
|
|
27
|
-
return [Component, ...flatChildComponent(childComponents)].some((Component) =>
|
|
28
|
-
Boolean(Component.hoistProps && Component.hoistProps.length),
|
|
29
|
-
);
|
|
30
|
-
},
|
|
31
|
-
init: function (props, WrapperComponent, isFunction) {
|
|
32
|
-
if (isFunction) {
|
|
33
|
-
// TODO: might breake rules of hooks (by lsroman)
|
|
34
|
-
this[HOIST_SELF] = useState({});
|
|
35
|
-
} else {
|
|
36
|
-
this[HOIST_SELF] = [
|
|
37
|
-
{},
|
|
38
|
-
(obj) => {
|
|
39
|
-
this[HOIST_SELF][0] = obj;
|
|
40
|
-
this.forceUpdate();
|
|
41
|
-
},
|
|
42
|
-
];
|
|
43
|
-
}
|
|
44
|
-
// For optimization render
|
|
45
|
-
this[HOIST_SET] = (obj) => {
|
|
46
|
-
this[HOIST_SELF][1](obj);
|
|
47
|
-
};
|
|
48
|
-
},
|
|
49
|
-
context: function (context) {
|
|
50
|
-
// TODO: need to optimizte container initialization (by lsroman)
|
|
51
|
-
// WrapperComponent.hoistProps
|
|
52
|
-
return {
|
|
53
|
-
...context,
|
|
54
|
-
[HOIST_CONTEXT]: this[HOIST_SET],
|
|
55
|
-
};
|
|
56
|
-
},
|
|
57
|
-
asProps: function (props) {
|
|
58
|
-
// TODO: need to check for no props overwriting (by lsroman)
|
|
59
|
-
return assignProps(this[HOIST_SELF][0], props);
|
|
60
|
-
},
|
|
61
|
-
wrapperProps: function (props, WrapperComponent) {
|
|
62
|
-
if (WrapperComponent.hoistProps && WrapperComponent.hoistProps.length) {
|
|
63
|
-
const context = useContext(Context);
|
|
64
|
-
const renameProps = WrapperComponent.hoistProps.reduce((acc, propName) => {
|
|
65
|
-
const [name, rename] = propName.split(':');
|
|
66
|
-
acc[name] = rename || name;
|
|
67
|
-
return acc;
|
|
68
|
-
}, {});
|
|
69
|
-
const hoistProps = Object.entries(pick(props, Object.keys(renameProps))).reduce(
|
|
70
|
-
(acc, [name, value]) => {
|
|
71
|
-
acc[renameProps[name]] = value;
|
|
72
|
-
return acc;
|
|
73
|
-
},
|
|
74
|
-
{},
|
|
75
|
-
);
|
|
76
|
-
|
|
77
|
-
useEnhancedEffect(() => {
|
|
78
|
-
if (context[HOIST_CONTEXT]) {
|
|
79
|
-
context[HOIST_CONTEXT](hoistProps);
|
|
80
|
-
}
|
|
81
|
-
}, Object.values(hoistProps));
|
|
82
|
-
}
|
|
83
|
-
return props;
|
|
84
|
-
},
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
export default Enhancement;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export const INHERITED_NAME = Symbol('INHERITED_NAME');
|
|
2
|
-
|
|
3
|
-
function Enhancement() {
|
|
4
|
-
return {
|
|
5
|
-
condition: function (Component) {
|
|
6
|
-
return Boolean(Component.displayName);
|
|
7
|
-
},
|
|
8
|
-
static: function (WrapperComponent) {
|
|
9
|
-
return {
|
|
10
|
-
[INHERITED_NAME]: [
|
|
11
|
-
...new Set([...(WrapperComponent[INHERITED_NAME] || []), WrapperComponent.displayName]),
|
|
12
|
-
],
|
|
13
|
-
};
|
|
14
|
-
},
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export default Enhancement;
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
import { useContext } from 'react';
|
|
2
|
-
// @ts-ignore
|
|
3
|
-
import assignProps from '@semcore/utils/lib/assignProps';
|
|
4
|
-
// @ts-ignore
|
|
5
|
-
import pick from '@semcore/utils/lib/pick';
|
|
6
|
-
// @ts-ignore
|
|
7
|
-
import logger from '@semcore/utils/lib/logger';
|
|
8
|
-
|
|
9
|
-
function assign(target, source) {
|
|
10
|
-
return Object.defineProperties(
|
|
11
|
-
target,
|
|
12
|
-
Object.keys(source).reduce((descriptors, key) => {
|
|
13
|
-
descriptors[key] = Object.getOwnPropertyDescriptor(source, key);
|
|
14
|
-
return descriptors;
|
|
15
|
-
}, {}),
|
|
16
|
-
);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
function getterMethodName(name) {
|
|
20
|
-
return `get${name}Props`;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
function getterMethodNameByDisplayName(displayName) {
|
|
24
|
-
const displayNames = displayName.split('.');
|
|
25
|
-
const name = displayNames.slice(-(displayNames.length - 1)).join('');
|
|
26
|
-
return getterMethodName(name);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
function flatGetterMethodNames(childComponents, parentName?: string) {
|
|
30
|
-
return Object.entries(childComponents).reduce<string[]>((acc, [name, value]) => {
|
|
31
|
-
if (Array.isArray(value)) {
|
|
32
|
-
acc = [...acc, ...flatGetterMethodNames(value[1], name)];
|
|
33
|
-
}
|
|
34
|
-
name = parentName ? `${parentName}${name}` : name;
|
|
35
|
-
acc.push(getterMethodName(name));
|
|
36
|
-
return acc;
|
|
37
|
-
}, []);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export const STATIC_COMPONENT = Symbol('STATIC_COMPONENT');
|
|
41
|
-
const SELF_GETTER_METHOD = Symbol('SELF_GETTER_METHOD');
|
|
42
|
-
|
|
43
|
-
function Enhancement(childComponents, createComponent, options) {
|
|
44
|
-
const getterMethodNames = flatGetterMethodNames(childComponents);
|
|
45
|
-
return {
|
|
46
|
-
condition: function (Component) {
|
|
47
|
-
return Boolean(Component[STATIC_COMPONENT] || Object.keys(childComponents).length);
|
|
48
|
-
},
|
|
49
|
-
init: function (props, WrapperComponent) {
|
|
50
|
-
const getterMethods = pick(this, getterMethodNames);
|
|
51
|
-
this[SELF_GETTER_METHOD] = () => {
|
|
52
|
-
const selfGetterMethod = getterMethodNameByDisplayName(WrapperComponent.displayName);
|
|
53
|
-
logger.warn(
|
|
54
|
-
true,
|
|
55
|
-
`Getter \`${selfGetterMethod}\` can't be fired as it is a getter of static component`,
|
|
56
|
-
props['data-ui-name'] || WrapperComponent.displayName,
|
|
57
|
-
);
|
|
58
|
-
};
|
|
59
|
-
assign(
|
|
60
|
-
this,
|
|
61
|
-
getterMethodNames.reduce((acc, name) => {
|
|
62
|
-
const getterMethod = getterMethods[name];
|
|
63
|
-
if (!getterMethod) return acc;
|
|
64
|
-
acc[name] = (childrenProps = {}) => {
|
|
65
|
-
const getterProps = getterMethod.call(this, childrenProps, acc[name].index);
|
|
66
|
-
acc[name].index++;
|
|
67
|
-
return assignProps(childrenProps, getterProps);
|
|
68
|
-
};
|
|
69
|
-
acc[name].index = 0;
|
|
70
|
-
return acc;
|
|
71
|
-
}, {}),
|
|
72
|
-
);
|
|
73
|
-
},
|
|
74
|
-
static: function (WrapperComponent) {
|
|
75
|
-
if (Object.keys(childComponents).length && !WrapperComponent.displayName) {
|
|
76
|
-
throw new Error('"displayName" is not defined');
|
|
77
|
-
}
|
|
78
|
-
return Object.entries(childComponents).reduce((acc, [name, value]) => {
|
|
79
|
-
let childComponents = {};
|
|
80
|
-
|
|
81
|
-
if (Array.isArray(value)) {
|
|
82
|
-
childComponents = value[1];
|
|
83
|
-
value = value[0];
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
const prevStaticComponent = value[STATIC_COMPONENT];
|
|
87
|
-
// @ts-ignore
|
|
88
|
-
const prevDisplayName = value.displayName;
|
|
89
|
-
// @ts-ignore
|
|
90
|
-
value.displayName = WrapperComponent.displayName + '.' + name;
|
|
91
|
-
value[STATIC_COMPONENT] = true;
|
|
92
|
-
acc[name] = createComponent(value, childComponents, options);
|
|
93
|
-
// @ts-ignore
|
|
94
|
-
value.displayName = prevDisplayName;
|
|
95
|
-
value[STATIC_COMPONENT] = prevStaticComponent;
|
|
96
|
-
return acc;
|
|
97
|
-
}, {});
|
|
98
|
-
},
|
|
99
|
-
context: function (context /*, WrapperComponent*/) {
|
|
100
|
-
// const getterMethod = getterMethodNameByDisplayName(WrapperComponent.displayName);
|
|
101
|
-
|
|
102
|
-
return {
|
|
103
|
-
...context,
|
|
104
|
-
// [getterMethod]: this[SELF_GETTER_METHOD],
|
|
105
|
-
...pick(this, getterMethodNames),
|
|
106
|
-
};
|
|
107
|
-
},
|
|
108
|
-
wrapperProps: function (props, WrapperComponent) {
|
|
109
|
-
if (!WrapperComponent[STATIC_COMPONENT]) return props;
|
|
110
|
-
|
|
111
|
-
const context = useContext(options.context);
|
|
112
|
-
const getterMethod = context[getterMethodNameByDisplayName(WrapperComponent.displayName)];
|
|
113
|
-
if (getterMethod) {
|
|
114
|
-
return getterMethod(props);
|
|
115
|
-
}
|
|
116
|
-
return props;
|
|
117
|
-
},
|
|
118
|
-
render: function (render) {
|
|
119
|
-
getterMethodNames.forEach((name) => {
|
|
120
|
-
if (this[name] === undefined) return;
|
|
121
|
-
this[name].index = 0;
|
|
122
|
-
});
|
|
123
|
-
return render;
|
|
124
|
-
},
|
|
125
|
-
};
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
export default Enhancement;
|