@semcore/core 1.11.6 → 1.11.9
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 +69 -0
- package/lib/cjs/Component.js.map +1 -1
- package/lib/cjs/enhancement/Children.js +1 -1
- package/lib/cjs/enhancement/Children.js.map +1 -1
- package/lib/cjs/enhancement/Root.js +2 -2
- 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 +3 -3
- 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 +1 -1
- package/lib/cjs/enhancement/style.js.map +1 -1
- package/lib/cjs/enhancement/uncontrolledProps.js +2 -2
- 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 +1 -1
- package/lib/es6/enhancement/Children.js.map +1 -1
- package/lib/es6/enhancement/Root.js +2 -2
- 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 +3 -3
- 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 +1 -1
- package/lib/es6/enhancement/style.js.map +1 -1
- package/lib/es6/enhancement/uncontrolledProps.js +2 -2
- 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 -103
- 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
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,24 @@
|
|
|
2
2
|
|
|
3
3
|
CHANGELOG.md standards are inspired by [keepachangelog.com](https://keepachangelog.com/en/1.0.0/).
|
|
4
4
|
|
|
5
|
+
## [1.11.9] - 2022-07-22
|
|
6
|
+
|
|
7
|
+
### Changed
|
|
8
|
+
|
|
9
|
+
- Version patch update due to children dependencies update (`@semcore/utils` [3.34.0 ~> 3.35.0]).
|
|
10
|
+
|
|
11
|
+
## [1.11.8] - 2022-07-07
|
|
12
|
+
|
|
13
|
+
### Changed
|
|
14
|
+
|
|
15
|
+
- Version patch update due to children dependencies update (`@semcore/utils` [3.33.0 ~> 3.34.0]).
|
|
16
|
+
|
|
17
|
+
## [1.11.7] - 2022-06-02
|
|
18
|
+
|
|
19
|
+
### Changed
|
|
20
|
+
|
|
21
|
+
- Version patch update due to children dependencies update (`@semcore/utils` [3.32.2 ~> 3.33.0]).
|
|
22
|
+
|
|
5
23
|
## [1.11.6] - 2022-05-31
|
|
6
24
|
|
|
7
25
|
### Changed
|
package/README.md
CHANGED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# @semcore/core
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/@semcore/core)
|
|
4
|
+
[](https://www.npmjs.com/package/@semcore/core)
|
|
5
|
+
[](https://github.com/semrush/intergalactic/blob/master/LICENSE)
|
|
6
|
+
|
|
7
|
+
> This component is part of the Intergalactic design system
|
|
8
|
+
|
|
9
|
+
[//]: # '### 📖 [Component documentation](https://developer.semrush.com/intergalactic/components/core/)'
|
|
10
|
+
|
|
11
|
+
### 🏠 [Design system](https://developer.semrush.com/intergalactic/)
|
|
12
|
+
|
|
13
|
+
## Install
|
|
14
|
+
|
|
15
|
+
```sh
|
|
16
|
+
npm install @semcore/ui
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
```jsx
|
|
22
|
+
import createComponent, { Root, sstyled } from '@semcore/ui/core';
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
<details>
|
|
26
|
+
<summary>Alternative installation and use</summary>
|
|
27
|
+
|
|
28
|
+
**We do not recommend this usage path due to possible dependency and update issues.**
|
|
29
|
+
|
|
30
|
+
### Install
|
|
31
|
+
|
|
32
|
+
You can only install one package from the design system
|
|
33
|
+
|
|
34
|
+
```sh
|
|
35
|
+
npm install @semcore/core @semcore/core
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
`@semcore/core` - _is the basic package by which we create our components, and it contains all of the common logic
|
|
39
|
+
of the components that is discussed below. There should only be one version of the package in the project._
|
|
40
|
+
|
|
41
|
+
### Usage
|
|
42
|
+
|
|
43
|
+
You can use the package the same way but without `/ui/` in the import path.
|
|
44
|
+
|
|
45
|
+
```jsx
|
|
46
|
+
import createComponent, { Root, sstyled } from '@semcore/core';
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
</details>
|
|
50
|
+
|
|
51
|
+
## 👤 Author
|
|
52
|
+
|
|
53
|
+
[UI-kit team](https://github.com/semrush/intergalactic/blob/master/MAINTAINERS)
|
|
54
|
+
and [others ❤️](https://github.com/semrush/intergalactic/graphs/contributors)
|
|
55
|
+
|
|
56
|
+
## 🤝 Contributing
|
|
57
|
+
|
|
58
|
+
Contributions, issues and feature requests are welcome!
|
|
59
|
+
|
|
60
|
+
Feel free to check [issues page](https://github.com/semrush/intergalactic/issues). You can also take a look at
|
|
61
|
+
the [contributing guide](https://github.com/semrush/intergalactic/blob/master/CONTRIBUTING.md).
|
|
62
|
+
|
|
63
|
+
## Show your support
|
|
64
|
+
|
|
65
|
+
Give a ⭐️ if this project helped you!
|
|
66
|
+
|
|
67
|
+
## 📝 License
|
|
68
|
+
|
|
69
|
+
This project is [MIT](https://github.com/semrush/intergalactic/blob/master/LICENSE) licensed.
|
package/lib/cjs/Component.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"Component.js","names":["RootComponent","PureComponent","Component"],"sources":["../../src/Component.tsx"],"sourcesContent":["import React, {\n AllHTMLAttributes,\n ForwardRefExoticComponent,\n PureComponent,\n ReactNode,\n RefObject,\n} from 'react';\nimport { IStyledProps } from './styled';\n\ntype KnownKeys<T> = {\n [K in keyof T]: string extends K ? never : number extends K ? never : K;\n} extends { [_ in keyof T]: infer U }\n ? U\n : never;\n\nexport type HandlersType<UCProps> = { [K in keyof UCProps]?: <T = unknown>(arg: T) => void };\nexport type ChildrenType<Props = {}, Ctx = {}, UCProps = {}> =\n | ((props: Props & Ctx, handlers: HandlersType<UCProps>) => ReactNode)\n | ReactNode;\n\nexport type RootComponentHandler = (...args: any[]) => void | false;\n\nexport interface IRootComponentHandlers {\n [key: string]: RootComponentHandler;\n}\n\nexport interface IRootComponentProps<Props = {}, Ctx = {}> {\n forwardRef?: RefObject<any>;\n Children?: any;\n children?: ChildrenType<Props, Ctx>;\n styles?: IStyledProps['styles'];\n}\n\nexport type IComponentProps<Props = {}, Ctx = {}> = Props & IRootComponentProps<Props, Ctx>;\n\nexport type IFunctionProps<Props = {}, Ctx = {}> = IComponentProps<Props, Ctx> &\n Omit<AllHTMLAttributes<any>, keyof IComponentProps<Props, Ctx>> & { Root?: Root };\n\nexport type PropsWithRenderFnChildren<Props = {}, Ctx = {}, UCProps = {}> = Omit<\n Pick<Props, KnownKeys<Props>>,\n 'children'\n> & {\n children?: ChildrenType<Props, Ctx, UCProps>;\n [key: string]: unknown;\n};\n\nexport type CProps<Props, Ctx = {}, UCProps = {}> = Props & {\n children?: ((props: Props & Ctx, handlers: UCProps) => React.ReactNode) | React.ReactNode;\n};\nexport type ReturnEl = React.ReactElement | null;\n\nexport interface IRootNodeProps {\n render: React.ElementType | string;\n tag?: React.ElementType | string;\n\n [key: string]: any;\n}\n\ntype Root = ForwardRefExoticComponent<IRootNodeProps>;\n\n/**\n * @deprecated since version ^1.8.0\n */\nexport type PropGetter<T extends (...args: any) => any> = <P>(props?: P) => ReturnType<T> & P;\n/**\n * @deprecated since version ^1.8.0\n */\nexport type PropGetterReturn<T extends (...args: any) => any> = Partial<ReturnType<T>>;\nexport type PropGetterFn = <T extends {}>(props?: T) => T & { [key: string]: unknown };\nexport type Merge<Props, HTMLProps> = Props & Omit<HTMLProps, keyof Props>;\nexport type MergeGetters<G1 extends (...args: any) => any, G2 extends (...args: any) => any> = <P>(\n props?: P,\n) => Merge<ReturnType<G1>, ReturnType<G2>> & P;\n\ndeclare const Root: Root;\n\nexport { Root };\n\nabstract class RootComponent<Props = {}, Context = {}, State = {}> extends PureComponent<\n Props & IRootComponentProps<Props, Context>,\n State\n> {\n get handlers(): Readonly<IRootComponentHandlers> {\n return {};\n }\n\n get asProps() {\n return {} as Readonly<\n Merge<Props & IRootComponentProps<Props, Context>, AllHTMLAttributes<any>>\n >;\n }\n\n Root: Root;\n}\n\nexport const Component = RootComponent;\nexport type Component<\n Props = {},\n Context = {},\n State = {},\n Handlers extends IRootComponentHandlers = IRootComponentHandlers,\n> = React.ComponentClass<Props, State> & {\n handlers: Readonly<Handlers>;\n\n asProps: Readonly<Merge<Props & IRootComponentProps<Props, Context>, AllHTMLAttributes<any>>>;\n\n Root: Root;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;IA8EeA,a;;;;;;;;;;;;;;;;;;;;;SAIb,eAAiD;MAC/C,OAAO,EAAP;IACD;;;SAED,eAAc;MACZ,OAAO,EAAP;IAGD;;;EAZwEC,oB;;AAiBpE,IAAMC,SAAS,GAAGF,aAAlB"}
|
|
@@ -137,7 +137,7 @@ function Enhancement(Context, parent) {
|
|
|
137
137
|
this[CHILDREN_SELF] = createChildren(Context, contexts);
|
|
138
138
|
},
|
|
139
139
|
asProps: function asProps(props) {
|
|
140
|
-
// TODO:
|
|
140
|
+
// TODO: learn the reason what it was used for (by lsroman)
|
|
141
141
|
// this[CHILDREN_SELF].origin = _Children ? _Children.origin : children;
|
|
142
142
|
this[CHILDREN_SELF].origin = props.children;
|
|
143
143
|
this[CHILDREN_SELF].props = props;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"Children.js","names":["CHILDREN_COMPONENT","Symbol","CHILDREN_SELF","GETTER_REG","splitPropsAndGetters","props","Object","entries","reduce","acc","key","value","exec","getters","getterToArray","getter","Array","isArray","mergeObjects","a","b","core","keys","assignGettersChain","createChildren","Context","contexts","Children","children","origin","ctx","useContext","handlers","propsAndGetters","assign","mergedGetters","undefined","Enhancement","parent","init","map","component","CONTEXT_COMPONENT","filter","Boolean","asProps"],"sources":["../../../src/enhancement/Children.tsx"],"sourcesContent":["import { useContext } from 'react';\nimport { CONTEXT_COMPONENT } from '../index';\n\nexport const CHILDREN_COMPONENT = Symbol('CHILDREN_COMPONENT');\nconst CHILDREN_SELF = Symbol('CHILDREN_SELF');\n\nconst GETTER_REG = /^get[\\w]+Props$/;\n\nfunction splitPropsAndGetters(props) {\n return Object.entries(props).reduce(\n (acc, [key, value]) => {\n if (GETTER_REG.exec(key) === null) {\n acc.props[key] = value;\n } else {\n acc.getters[key] = value;\n }\n return acc;\n },\n { props: {}, getters: {} },\n );\n}\n\nfunction getterToArray(getter) {\n if (!Array.isArray(getter)) {\n return typeof getter === 'function' ? [getter] : [];\n }\n return getter;\n}\n\nfunction mergeObjects(a = {}, b = {}) {\n const core = { ...a, ...b };\n return Object.keys(core).reduce((acc, key) => {\n a[key] = getterToArray(a[key]);\n b[key] = getterToArray(b[key]);\n acc[key] = [...a[key], ...b[key]];\n return acc;\n }, {});\n}\n\nfunction assignGettersChain(getters: Array<Function>) {\n return function (props = {}) {\n return getters.reduce((acc, getter) => {\n return getter(acc);\n }, props);\n };\n}\n\nfunction createChildren(Context, contexts) {\n const Children = function () {\n const children = Children.origin;\n if (typeof children === 'function') {\n const {\n handlers = {},\n getters = {},\n ...props\n } = [...contexts, Context].reduce((acc, ctx) => {\n const { handlers, ...propsAndGetters } = useContext(ctx);\n const { props, getters } = splitPropsAndGetters(propsAndGetters);\n return Object.assign({}, acc, {\n handlers: Object.assign({}, acc.handlers, handlers),\n getters: mergeObjects(acc.getters, getters),\n ...props,\n });\n }, Children.props);\n\n const mergedGetters = Object.entries(getters).reduce((acc, [key, value]) => {\n acc[key] = assignGettersChain(value as []);\n return acc;\n }, {});\n\n return children({ ...props, ...mergedGetters }, handlers);\n } else if (children === undefined) {\n return null;\n }\n return children;\n };\n Children.origin = null;\n Children.props = {};\n Children[CHILDREN_COMPONENT] = true;\n return Children;\n}\n\nfunction Enhancement(Context, parent) {\n return {\n init: function () {\n const contexts = (Array.isArray(parent) ? parent : [parent])\n .map((component) => component[CONTEXT_COMPONENT])\n .filter(Boolean);\n this[CHILDREN_SELF] = createChildren(Context, contexts);\n },\n asProps: function (props) {\n // TODO: learn the reason what it was used for (by lsroman)\n // this[CHILDREN_SELF].origin = _Children ? _Children.origin : children;\n this[CHILDREN_SELF].origin = props.children;\n this[CHILDREN_SELF].props = props;\n return {\n ...props,\n Children: this[CHILDREN_SELF],\n };\n },\n };\n}\n\nexport default Enhancement;\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA;;AACA;;;;;;;;;AAEO,IAAMA,kBAAkB,GAAGC,MAAM,CAAC,oBAAD,CAAjC;;AACP,IAAMC,aAAa,GAAGD,MAAM,CAAC,eAAD,CAA5B;AAEA,IAAME,UAAU,GAAG,iBAAnB;;AAEA,SAASC,oBAAT,CAA8BC,KAA9B,EAAqC;EACnC,OAAOC,MAAM,CAACC,OAAP,CAAeF,KAAf,EAAsBG,MAAtB,CACL,UAACC,GAAD,QAAuB;IAAA;IAAA,IAAhBC,GAAgB;IAAA,IAAXC,KAAW;;IACrB,IAAIR,UAAU,CAACS,IAAX,CAAgBF,GAAhB,MAAyB,IAA7B,EAAmC;MACjCD,GAAG,CAACJ,KAAJ,CAAUK,GAAV,IAAiBC,KAAjB;IACD,CAFD,MAEO;MACLF,GAAG,CAACI,OAAJ,CAAYH,GAAZ,IAAmBC,KAAnB;IACD;;IACD,OAAOF,GAAP;EACD,CARI,EASL;IAAEJ,KAAK,EAAE,EAAT;IAAaQ,OAAO,EAAE;EAAtB,CATK,CAAP;AAWD;;AAED,SAASC,aAAT,CAAuBC,MAAvB,EAA+B;EAC7B,IAAI,CAACC,KAAK,CAACC,OAAN,CAAcF,MAAd,CAAL,EAA4B;IAC1B,OAAO,OAAOA,MAAP,KAAkB,UAAlB,GAA+B,CAACA,MAAD,CAA/B,GAA0C,EAAjD;EACD;;EACD,OAAOA,MAAP;AACD;;AAED,SAASG,YAAT,GAAsC;EAAA,IAAhBC,CAAgB,uEAAZ,EAAY;EAAA,IAARC,CAAQ,uEAAJ,EAAI;;EACpC,IAAMC,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AlC,EACdE,GADc,CACV,UAACC,SAAD;QAAA,OAAeA,SAAS,CAACC,wBAAD,CAAxB;MAAA,CADU,EAEdC,MAFc,CAEPC,OAFO,CAAjB;MAGA,KAAK1C,aAAL,IAAsBsB,cAAc,CAACC,OAAD,EAAUC,QAAV,CAApC;IACD,CANI;IAOLmB,OAAO,EAAE,iBAAUxC,KAAV,EAAiB;MACxB;MACA;MACA,KAAKH,aAAL,EAAoB2B,MAApB,GAA6BxB,KAAK,CAACuB,QAAnC;MACA,KAAK1B,aAAL,EAAoBG,KAApB,GAA4BA,KAA5B;MACA,uCACKA,KADL;QAEEsB,QAAQ,EAAE,KAAKzB,aAAL;MAFZ;IAID;EAhBI,CAAP;AAkBD;;eAEcmC,W"}
|
|
@@ -28,7 +28,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
28
28
|
|
|
29
29
|
function createRootRender() {
|
|
30
30
|
// @ts-ignore
|
|
31
|
-
var Root = _react["default"].forwardRef(function (_ref, ref) {
|
|
31
|
+
var Root = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
32
32
|
var Tag = _ref.render,
|
|
33
33
|
source = (0, _objectWithoutProperties2["default"])(_ref, _excluded);
|
|
34
34
|
var _Root$props = Root.props,
|
|
@@ -50,7 +50,7 @@ function createRootRender() {
|
|
|
50
50
|
|
|
51
51
|
return props;
|
|
52
52
|
}, {});
|
|
53
|
-
var child = {}; // TODO:
|
|
53
|
+
var child = {}; // TODO: need to find better check solution (by lsroman)
|
|
54
54
|
|
|
55
55
|
if (typeof Children.origin !== 'undefined') {
|
|
56
56
|
// @ts-ignore
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"Root.js","names":["createRootRender","Root","React","forwardRef","ref","Tag","render","source","props","_Root","styles","children","Children","clearProps","Object","entries","reduce","name","value","undefined","child","origin","other","assignProps","useForkRef","Error","Enhancement","init","asProps","WrapperComponent","isFunction"],"sources":["../../../src/enhancement/Root.tsx"],"sourcesContent":["import React from 'react';\n// @ts-ignore\nimport assignProps from '@semcore/utils/lib/assignProps';\n// @ts-ignore\nimport { useForkRef } from '@semcore/utils/lib/ref';\n\nfunction createRootRender() {\n // @ts-ignore\n const Root = React.forwardRef(function ({ render: Tag, ...source }, ref) {\n const {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n Root: _Root,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n styles,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n children,\n Children,\n forwardRef = null,\n ...props\n // @ts-ignore\n } = Root.props;\n\n const clearProps = Object.entries(props).reduce((props, [name, value]) => {\n if (value !== undefined) {\n props[name] = value;\n }\n return props;\n }, {});\n\n const child = {};\n // TODO: need to find better check solution (by lsroman)\n if (typeof Children.origin !== 'undefined') {\n // @ts-ignore\n child.children = <Children />;\n }\n\n const other = assignProps(\n {\n ...clearProps,\n ref: useForkRef(forwardRef, ref),\n },\n {\n ...child,\n ...source,\n },\n );\n if (!Tag) {\n throw new Error('`render` prop of Root is not provided');\n }\n return <Tag {...other} />;\n });\n // @ts-ignore\n Root.props = {};\n return Root;\n}\n\nfunction Enhancement() {\n return {\n init: function () {\n this.Root = createRootRender();\n },\n asProps: function (props, WrapperComponent, isFunction) {\n if (isFunction) {\n return {\n ...props,\n Root: this.Root,\n };\n }\n return props;\n },\n render: function (render, props) {\n this.Root.props = props;\n return render;\n },\n };\n}\n\nexport default Enhancement;\n"],"mappings":";;;;;;;;;;;;;;;AAAA;;AAEA;;AAEA;;;;;;;;;AAEA,SAASA,gBAAT,GAA4B;EAC1B;EACA,IAAMC,IAAI,gBAAGC,iBAAA,CAAMC,UAAN,CAAiB,gBAAsCC,GAAtC,EAA2C;IAAA,IAAvBC,GAAuB,QAA/BC,MAA+B;IAAA,IAAfC,MAAe;IACvE,kBAWIN,IAAI,CAACO,KAXT;IAAA,IAEQC,KAFR,eAEER,IAFF;IAAA,IAIES,MAJF,eAIEA,MAJ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KAAKA;QAFb;MAID;;MACD,OAAOO,KAAP;IACD,CAZI;IAaLF,MAAM,EAAE,gBAAUA,OAAV,EAAkBE,KAAlB,EAAyB;MAC/B,KAAKP,IAAL,CAAUO,KAAV,GAAkBA,KAAlB;MACA,OAAOF,OAAP;IACD;EAhBI,CAAP;AAkBD;;eAEcoB,W"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"bindHandler.js","names":["arraysEqual","a","b","length","i","handlerBinder","fn","depsArgs","memoizeds","hasher","has","get","memoized","find","deps","bindFn","bind","push","set","WeakMap","Enhancement","condition","Component","isFunction","init","Object","keys","filter","field","startsWith","forEach","name"],"sources":["../../../src/enhancement/bindHandler.tsx"],"sourcesContent":["function arraysEqual(a, b) {\n if (a.length !== b.length) return false;\n for (let i = 0; i < a.length; i++) {\n if (a[i] !== b[i]) return false;\n }\n return true;\n}\n\nfunction handlerBinder(fn) {\n return function (...depsArgs) {\n let memoizeds = [];\n if (handlerBinder.hasher.has(fn)) {\n memoizeds = handlerBinder.hasher.get(fn);\n const memoized = memoizeds.find((memoized) => arraysEqual(memoized.deps, depsArgs));\n if (memoized) return memoized.fn;\n }\n\n const bindFn = fn(...depsArgs).bind(fn);\n memoizeds.push({\n deps: depsArgs,\n fn: bindFn,\n });\n handlerBinder.hasher.set(fn, memoizeds);\n return bindFn;\n };\n}\n\nhandlerBinder.hasher = new WeakMap();\n\nfunction Enhancement() {\n return {\n condition: function (Component, isFunction) {\n return !isFunction;\n },\n init: function () {\n Object.keys(this)\n .filter((field) => field.startsWith('bindHandler'))\n .forEach((name) => {\n this[name] = handlerBinder(this[name].bind(this));\n });\n },\n };\n}\n\nexport default Enhancement;\n"],"mappings":";;;;;;;AAAA,SAASA,WAAT,CAAqBC,CAArB,EAAwBC,CAAxB,EAA2B;EACzB,IAAID,CAAC,CAACE,MAAF,KAAaD,CAAC,CAACC,MAAnB,EAA2B,OAAO,KAAP;;EAC3B,KAAK,IAAI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IAAZ,EACGC,MADH,CACU,UAACC,KAAD;QAAA,OAAWA,KAAK,CAACC,UAAN,CAAiB,aAAjB,CAAX;MAAA,CADV,EAEGC,OAFH,CAEW,UAACC,IAAD,EAAU;QACjB,KAAI,CAACA,IAAD,CAAJ,GAAa1B,aAAa,CAAC,KAAI,CAAC0B,IAAD,CAAJ,CAAWf,IAAX,CAAgB,KAAhB,CAAD,CAA1B;MACD,CAJH;IAKD;EAVI,CAAP;AAYD;;eAEcI,W"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"dataName.js","names":["Enhancement","wrapperProps","props","WrapperComponent","displayName"],"sources":["../../../src/enhancement/dataName.tsx"],"sourcesContent":["function Enhancement() {\n return {\n wrapperProps: function (props, WrapperComponent) {\n return {\n 'data-ui-name': WrapperComponent.displayName,\n ...props,\n };\n },\n };\n}\n\nexport default Enhancement;\n"],"mappings":";;;;;;;;;;;;;;;AAAA,SAASA,WAAT,GAAuB;EACrB,OAAO;IACLC,YAAY,EAAE,sBAAUC,KAAV,EAAiBC,gBAAjB,EAAmC;MAC/C;QACE,gBAAgBA,gBAAgB,CAACC;MADnC,GAEKF,KAFL;IAID;EANI,CAAP;AAQD;;eAEcF,W"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"enhance.js","names":["Enhancement","condition","Component","Boolean","enhance","length","wrapperProps","props","WrapperComponent","reduce","acc"],"sources":["../../../src/enhancement/enhance.tsx"],"sourcesContent":["function Enhancement() {\n return {\n condition: function (Component) {\n return Boolean(Component.enhance && Component.enhance.length);\n },\n wrapperProps: function (props, WrapperComponent) {\n return WrapperComponent.enhance.reduce((acc, enhance) => enhance(acc), props);\n },\n };\n}\n\nexport default Enhancement;\n"],"mappings":";;;;;;;AAAA,SAASA,WAAT,GAAuB;EACrB,OAAO;IACLC,SAAS,EAAE,mBAAUC,SAAV,EAAqB;MAC9B,OAAOC,OAAO,CAACD,SAAS,CAACE,OAAV,IAAqBF,SAAS,CAACE,OAAV,CAAkBC,MAAxC,CAAd;IACD,CAHI;IAILC,YAAY,EAAE,sBAAUC,KAAV,EAAiBC,gBAAjB,EAAmC;MAC/C,OAAOA,gBAAgB,CAACJ,OAAjB,CAAyBK,MAAzB,CAAgC,UAACC,GAAD,EAAMN,OAAN;QAAA,OAAkBA,OAAO,CAACM,GAAD,CAAzB;MAAA,CAAhC,EAAgEH,KAAhE,CAAP;IACD;EANI,CAAP;AAQD;;eAEcP,W"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"functionDefaultProps.js","names":["Enhancement","defaultProps","condition","Component","Boolean","Object","keys","length","WrapperComponent","wrapperProps","props","assign"],"sources":["../../../src/enhancement/functionDefaultProps.tsx"],"sourcesContent":["function Enhancement() {\n let defaultProps = {};\n return {\n condition: function (Component) {\n if (!Component.defaultProps) {\n return false;\n }\n if (typeof Component.defaultProps === 'function') {\n return true;\n }\n return Boolean(Object.keys(Component.defaultProps).length);\n },\n static: function (WrapperComponent) {\n defaultProps = WrapperComponent.defaultProps;\n return {\n defaultProps: {},\n };\n },\n wrapperProps: function (props) {\n if (typeof defaultProps === 'function') {\n // TODO: optimization\n return Object.assign({}, defaultProps(props), props);\n }\n return Object.assign({}, defaultProps, props);\n },\n };\n}\n\nexport default Enhancement;\n"],"mappings":";;;;;;;AAAA,SAASA,WAAT,GAAuB;EACrB,IAAIC,YAAY,GAAG,EAAnB;EACA,OAAO;IACLC,SAAS,EAAE,mBAAUC,SAAV,EAAqB;MAC9B,IAAI,CAACA,SAAS,CAACF,YAAf,EAA6B;QAC3B,OAAO,KAAP;MACD;;MACD,IAAI,OAAOE,SAAS,CAACF,YAAjB,KAAkC,UAAtC,EAAkD;QAChD,OAAO,IAAP;MACD;;MACD,OAAOG,OAAO,CAACC,MAAM,CAACC,IAAP,CAAYH,SAAS,CAACF,YAAtB,EAAoCM,MAArC,CAAd;IACD,CATI;IAUL,UAAQ,iBAAUC,gBAAV,EAA4B;MAClCP,YAAY,GAAGO,gBAAgB,CAACP,YAAhC;MACA,OAAO;QACLA,YAAY,EAAE;MADT,CAAP;IAGD,CAfI;IAgBLQ,YAAY,EAAE,sBAAUC,KAAV,EAAiB;MAC7B,IAAI,OAAOT,YAAP,KAAwB,UAA5B,EAAwC;QACtC;QACA,OAAOI,MAAM,CAACM,MAAP,CAAc,EAAd,EAAkBV,YAAY,CAACS,KAAD,CAA9B,EAAuCA,KAAvC,CAAP;MACD;;MACD,OAAOL,MAAM,CAACM,MAAP,CAAc,EAAd,EAAkBV,YAAlB,EAAgCS,KAAhC,CAAP;IACD;EAtBI,CAAP;AAwBD;;eAEcV,W"}
|
|
@@ -53,7 +53,7 @@ function Enhancement(childComponents, Context) {
|
|
|
53
53
|
var _this = this;
|
|
54
54
|
|
|
55
55
|
if (isFunction) {
|
|
56
|
-
// TODO:
|
|
56
|
+
// TODO: might breake rules of hooks (by lsroman)
|
|
57
57
|
this[HOIST_SELF] = (0, _react.useState)({});
|
|
58
58
|
} else {
|
|
59
59
|
this[HOIST_SELF] = [{}, function (obj) {
|
|
@@ -69,12 +69,12 @@ function Enhancement(childComponents, Context) {
|
|
|
69
69
|
};
|
|
70
70
|
},
|
|
71
71
|
context: function context(_context) {
|
|
72
|
-
// TODO:
|
|
72
|
+
// TODO: need to optimizte container initialization (by lsroman)
|
|
73
73
|
// WrapperComponent.hoistProps
|
|
74
74
|
return _objectSpread(_objectSpread({}, _context), {}, (0, _defineProperty2["default"])({}, HOIST_CONTEXT, this[HOIST_SET]));
|
|
75
75
|
},
|
|
76
76
|
asProps: function asProps(props) {
|
|
77
|
-
// TODO
|
|
77
|
+
// TODO: need to check for no props overwriting (by lsroman)
|
|
78
78
|
return (0, _assignProps["default"])(this[HOIST_SELF][0], props);
|
|
79
79
|
},
|
|
80
80
|
wrapperProps: function wrapperProps(props, WrapperComponent) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"hoistProps.js","names":["HOIST_CONTEXT","Symbol","HOIST_SELF","HOIST_SET","flatChildComponent","childComponents","Object","values","reduce","acc","Component","Array","isArray","push","Enhancement","Context","condition","some","Boolean","hoistProps","length","init","props","WrapperComponent","isFunction","useState","obj","forceUpdate","context","asProps","assignProps","wrapperProps","useContext","renameProps","propName","split","name","rename","entries","pick","keys","value","useEnhancedEffect"],"sources":["../../../src/enhancement/hoistProps.tsx"],"sourcesContent":["import { useContext, useState } from 'react';\n// @ts-ignore\nimport assignProps from '@semcore/utils/lib/assignProps';\n// @ts-ignore\nimport useEnhancedEffect from '@semcore/utils/lib/use/useEnhancedEffect';\n// @ts-ignore\nimport pick from '@semcore/utils/lib/pick';\n\nexport const HOIST_CONTEXT = Symbol('HOIST_CONTEXT');\nconst HOIST_SELF = Symbol('HOIST_SELF');\nconst HOIST_SET = Symbol('HOIST_SET');\n\nfunction flatChildComponent(childComponents) {\n return Object.values(childComponents).reduce<unknown[]>((acc, Component) => {\n if (Array.isArray(Component)) {\n acc = [...acc, Component[0], ...flatChildComponent(Component[1])];\n } else {\n acc.push(Component);\n }\n return acc;\n }, []);\n}\n\nfunction Enhancement(childComponents, Context) {\n return {\n condition: function (Component) {\n return [Component, ...flatChildComponent(childComponents)].some((Component) =>\n Boolean(Component.hoistProps && Component.hoistProps.length),\n );\n },\n init: function (props, WrapperComponent, isFunction) {\n if (isFunction) {\n // TODO: might breake rules of hooks (by lsroman)\n this[HOIST_SELF] = useState({});\n } else {\n this[HOIST_SELF] = [\n {},\n (obj) => {\n this[HOIST_SELF][0] = obj;\n this.forceUpdate();\n },\n ];\n }\n // For optimization render\n this[HOIST_SET] = (obj) => {\n this[HOIST_SELF][1](obj);\n };\n },\n context: function (context) {\n // TODO: need to optimizte container initialization (by lsroman)\n // WrapperComponent.hoistProps\n return {\n ...context,\n [HOIST_CONTEXT]: this[HOIST_SET],\n };\n },\n asProps: function (props) {\n // TODO: need to check for no props overwriting (by lsroman)\n return assignProps(this[HOIST_SELF][0], props);\n },\n wrapperProps: function (props, WrapperComponent) {\n if (WrapperComponent.hoistProps && WrapperComponent.hoistProps.length) {\n const context = useContext(Context);\n const renameProps = WrapperComponent.hoistProps.reduce((acc, propName) => {\n const [name, rename] = propName.split(':');\n acc[name] = rename || name;\n return acc;\n }, {});\n const hoistProps = Object.entries(pick(props, Object.keys(renameProps))).reduce(\n (acc, [name, value]) => {\n acc[renameProps[name]] = value;\n return acc;\n },\n {},\n );\n\n useEnhancedEffect(() => {\n if (context[HOIST_CONTEXT]) {\n context[HOIST_CONTEXT](hoistProps);\n }\n }, Object.values(hoistProps));\n }\n return props;\n },\n };\n}\n\nexport default Enhancement;\n"],"mappings":";;;;;;;;;;;;;;;AAAA;;AAEA;;AAEA;;AAEA;;;;;;AAEO,IAAMA,aAAa,GAAGC,MAAM,CAAC,eAAD,CAA5B;;AACP,IAAMC,UAAU,GAAGD,MAAM,CAAC,YAAD,CAAzB;AACA,IAAME,SAAS,GAAGF,MAAM,CAAC,WAAD,CAAxB;;AAEA,SAASG,kBAAT,CAA4BC,eAA5B,EAA6C;EAC3C,OAAOC,MAAM,CAACC,MAAP,CAAcF,eAAd,EAA+BG,MAA/B,CAAiD,UAACC,GAAD,EAAMC,SAAN,EAAoB;IAC1E,IAAIC,KAAK,CAACC,OAAN,CAAcF,SAAd,CAAJ,EAA8B;MAC5BD,GAAG,iDAAOA,GAAP,IAAYC,SAAS,CAAC,CAAD,CAArB,uCAA6BN,kBAAkB,CAACM,SAAS,CAAC,CAAD,CAAV,CAA/C,EAAH;IACD,CAFD,MAEO;MACLD,GAAG,CAACI,IAAJ,CAASH,SAAT;IACD;;IACD,OAAOD,GAAP;EACD,CAPM,EAOJ,EAPI,CAAP;AAQD;;AAED,SAASK,WAAT,CAAqBT,eAArB,EAAsCU,OAAtC,EAA+C;EAC7C,OAAO;IACLC,SAAS,EAAE,mBAAUN,SAAV,EAAqB;MAC9B,OAAO,CAACA,SAAD,6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CAACJ,UAAjB,CAA4BX,MAA5B,CAAmC,UAACC,GAAD,EAAMyB,QAAN,EAAmB;UACxE,sBAAuBA,QAAQ,CAACC,KAAT,CAAe,GAAf,CAAvB;UAAA;UAAA,IAAOC,IAAP;UAAA,IAAaC,MAAb;;UACA5B,GAAG,CAAC2B,IAAD,CAAH,GAAYC,MAAM,IAAID,IAAtB;UACA,OAAO3B,GAAP;QACD,CAJmB,EAIjB,EAJiB,CAApB;QAKA,IAAMU,UAAU,GAAGb,MAAM,CAACgC,OAAP,CAAe,IAAAC,gBAAA,EAAKjB,KAAL,EAAYhB,MAAM,CAACkC,IAAP,CAAYP,WAAZ,CAAZ,CAAf,EAAsDzB,MAAtD,CACjB,UAACC,GAAD,QAAwB;UAAA;UAAA,IAAjB2B,IAAiB;UAAA,IAAXK,KAAW;;UACtBhC,GAAG,CAACwB,WAAW,CAACG,IAAD,CAAZ,CAAH,GAAyBK,KAAzB;UACA,OAAOhC,GAAP;QACD,CAJgB,EAKjB,EALiB,CAAnB;QAQA,IAAAiC,6BAAA,EAAkB,YAAM;UACtB,IAAId,OAAO,CAAC5B,aAAD,CAAX,EAA4B;YAC1B4B,OAAO,CAAC5B,aAAD,CAAP,CAAuBmB,UAAvB;UACD;QACF,CAJD,EAIGb,MAAM,CAACC,MAAP,CAAcY,UAAd,CAJH;MAKD;;MACD,OAAOG,KAAP;IACD;EA3DI,CAAP;AA6DD;;eAEcR,W"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"inheritedName.js","names":["INHERITED_NAME","Symbol","Enhancement","condition","Component","Boolean","displayName","WrapperComponent","Set"],"sources":["../../../src/enhancement/inheritedName.tsx"],"sourcesContent":["export const INHERITED_NAME = Symbol('INHERITED_NAME');\n\nfunction Enhancement() {\n return {\n condition: function (Component) {\n return Boolean(Component.displayName);\n },\n static: function (WrapperComponent) {\n return {\n [INHERITED_NAME]: [\n ...new Set([...(WrapperComponent[INHERITED_NAME] || []), WrapperComponent.displayName]),\n ],\n };\n },\n };\n}\n\nexport default Enhancement;\n"],"mappings":";;;;;;;;;;;;;AAAO,IAAMA,cAAc,GAAGC,MAAM,CAAC,gBAAD,CAA7B;;;AAEP,SAASC,WAAT,GAAuB;EACrB,OAAO;IACLC,SAAS,EAAE,mBAAUC,SAAV,EAAqB;MAC9B,OAAOC,OAAO,CAACD,SAAS,CAACE,WAAX,CAAd;IACD,CAHI;IAIL,UAAQ,iBAAUC,gBAAV,EAA4B;MAClC,4CACGP,cADH,sCAEO,IAAIQ,GAAJ,+CAAaD,gBAAgB,CAACP,cAAD,CAAhB,IAAoC,EAAjD,IAAsDO,gBAAgB,CAACD,WAAvE,GAFP;IAKD;EAVI,CAAP;AAYD;;eAEcJ,W"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"staticChildren.js","names":["assign","target","source","Object","defineProperties","keys","reduce","descriptors","key","getOwnPropertyDescriptor","getterMethodName","name","getterMethodNameByDisplayName","displayName","displayNames","split","slice","length","join","flatGetterMethodNames","childComponents","parentName","entries","acc","value","Array","isArray","push","STATIC_COMPONENT","Symbol","SELF_GETTER_METHOD","Enhancement","createComponent","options","getterMethodNames","condition","Component","Boolean","init","props","WrapperComponent","getterMethods","pick","selfGetterMethod","logger","warn","getterMethod","childrenProps","getterProps","call","index","assignProps","Error","prevStaticComponent","prevDisplayName","context","wrapperProps","useContext","render","forEach","undefined"],"sources":["../../../src/enhancement/staticChildren.tsx"],"sourcesContent":["import { useContext } from 'react';\n// @ts-ignore\nimport assignProps from '@semcore/utils/lib/assignProps';\n// @ts-ignore\nimport pick from '@semcore/utils/lib/pick';\n// @ts-ignore\nimport logger from '@semcore/utils/lib/logger';\n\nfunction assign(target, source) {\n return Object.defineProperties(\n target,\n Object.keys(source).reduce((descriptors, key) => {\n descriptors[key] = Object.getOwnPropertyDescriptor(source, key);\n return descriptors;\n }, {}),\n );\n}\n\nfunction getterMethodName(name) {\n return `get${name}Props`;\n}\n\nfunction getterMethodNameByDisplayName(displayName) {\n const displayNames = displayName.split('.');\n const name = displayNames.slice(-(displayNames.length - 1)).join('');\n return getterMethodName(name);\n}\n\nfunction flatGetterMethodNames(childComponents, parentName?: string) {\n return Object.entries(childComponents).reduce<string[]>((acc, [name, value]) => {\n if (Array.isArray(value)) {\n acc = [...acc, ...flatGetterMethodNames(value[1], name)];\n }\n name = parentName ? `${parentName}${name}` : name;\n acc.push(getterMethodName(name));\n return acc;\n }, []);\n}\n\nexport const STATIC_COMPONENT = Symbol('STATIC_COMPONENT');\nconst SELF_GETTER_METHOD = Symbol('SELF_GETTER_METHOD');\n\nfunction Enhancement(childComponents, createComponent, options) {\n const getterMethodNames = flatGetterMethodNames(childComponents);\n return {\n condition: function (Component) {\n return Boolean(Component[STATIC_COMPONENT] || Object.keys(childComponents).length);\n },\n init: function (props, WrapperComponent) {\n const getterMethods = pick(this, getterMethodNames);\n this[SELF_GETTER_METHOD] = () => {\n const selfGetterMethod = getterMethodNameByDisplayName(WrapperComponent.displayName);\n logger.warn(\n true,\n `Getter \\`${selfGetterMethod}\\` can't be fired as it is a getter of static component`,\n props['data-ui-name'] || WrapperComponent.displayName,\n );\n };\n assign(\n this,\n getterMethodNames.reduce((acc, name) => {\n const getterMethod = getterMethods[name];\n if (!getterMethod) return acc;\n acc[name] = (childrenProps = {}) => {\n const getterProps = getterMethod.call(this, childrenProps, acc[name].index);\n acc[name].index++;\n return assignProps(childrenProps, getterProps);\n };\n acc[name].index = 0;\n return acc;\n }, {}),\n );\n },\n static: function (WrapperComponent) {\n if (Object.keys(childComponents).length && !WrapperComponent.displayName) {\n throw new Error('\"displayName\" is not defined');\n }\n return Object.entries(childComponents).reduce((acc, [name, value]) => {\n let childComponents = {};\n\n if (Array.isArray(value)) {\n childComponents = value[1];\n value = value[0];\n }\n\n const prevStaticComponent = value[STATIC_COMPONENT];\n // @ts-ignore\n const prevDisplayName = value.displayName;\n // @ts-ignore\n value.displayName = WrapperComponent.displayName + '.' + name;\n value[STATIC_COMPONENT] = true;\n acc[name] = createComponent(value, childComponents, options);\n // @ts-ignore\n value.displayName = prevDisplayName;\n value[STATIC_COMPONENT] = prevStaticComponent;\n return acc;\n }, {});\n },\n context: function (context /*, WrapperComponent*/) {\n // const getterMethod = getterMethodNameByDisplayName(WrapperComponent.displayName);\n\n return {\n ...context,\n // [getterMethod]: this[SELF_GETTER_METHOD],\n ...pick(this, getterMethodNames),\n };\n },\n wrapperProps: function (props, WrapperComponent) {\n if (!WrapperComponent[STATIC_COMPONENT]) return props;\n\n const context = useContext(options.context);\n const getterMethod = context[getterMethodNameByDisplayName(WrapperComponent.displayName)];\n if (getterMethod) {\n return getterMethod(props);\n }\n return props;\n },\n render: function (render) {\n getterMethodNames.forEach((name) => {\n if (this[name] === undefined) return;\n this[name].index = 0;\n });\n return render;\n },\n };\n}\n\nexport default Enhancement;\n"],"mappings":";;;;;;;;;;;;;;;AAAA;;AAEA;;AAEA;;AAEA;;;;;;AAEA,SAASA,MAAT,CAAgBC,MAAhB,EAAwBC,MAAxB,EAAgC;EAC9B,OAAOC,MAAM,CAACC,gBAAP,CACLH,MADK,EAELE,MAAM,CAACE,IAAP,CAAYH,MAAZ,EAAoBI,MAApB,CAA2B,UAACC,WAAD,EAAcC,GAAd,EAAsB;IAC/CD,WAAW,CAACC,GAAD,CAAX,GAAmBL,MAAM,CAACM,wBAAP,CAAgCP,MAAhC,EAAwCM,GAAxC,CAAnB;IACA,OAAOD,WAAP;EACD,CAHD,EAGG,EAHH,CAFK,CAAP;AAOD;;AAED,SAASG,gBAAT,CAA0BC,IAA1B,EAAgC;EAC9B,oBAAaA,IAAb;AACD;;AAED,SAASC,6BAAT,CAAuCC,WAAvC,EAAoD;EAClD,IAAMC,YAAY,GAAGD,WAAW,CAACE,KAAZ,CAAkB,GAAlB,CAArB;EACA,IAAMJ,IAAI,GAAGG,YAAY,CAACE,KAAb,CAAmB,EAAEF,YAAY,CAACG,MAAb,GAAsB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AAOA,KAAP;IACD,CAxEI;IAyELmB,MAAM,EAAE,gBAAUA,OAAV,EAAkB;MAAA;;MACxBxB,iBAAiB,CAACyB,OAAlB,CAA0B,UAAChD,IAAD,EAAU;QAClC,IAAI,MAAI,CAACA,IAAD,CAAJ,KAAeiD,SAAnB,EAA8B;QAC9B,MAAI,CAACjD,IAAD,CAAJ,CAAWuC,KAAX,GAAmB,CAAnB;MACD,CAHD;MAIA,OAAOQ,OAAP;IACD;EA/EI,CAAP;AAiFD;;eAEc3B,W"}
|
|
@@ -39,7 +39,7 @@ function Enhancement(childComponents, Context) {
|
|
|
39
39
|
}
|
|
40
40
|
},
|
|
41
41
|
context: function context(_context) {
|
|
42
|
-
//
|
|
42
|
+
// Optimization: if has no children there is no need to create new context (by lsroman)
|
|
43
43
|
if (!this[STYLES_SELF] || !Object.keys(childComponents).length) {
|
|
44
44
|
return _context;
|
|
45
45
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"style.js","names":["STYLES_CONTEXT","Symbol","STYLES_SELF","Enhancement","childComponents","Context","condition","Component","Boolean","style","STATIC_COMPONENT","init","props","WrapperComponent","sstyled","merge","_styles","context","Object","keys","length","asProps","styles","wrapperProps","useContext"],"sources":["../../../src/enhancement/style.tsx"],"sourcesContent":["import { useContext } from 'react';\n// @ts-ignore\nimport { sstyled } from '../styled';\nimport { STATIC_COMPONENT } from './staticChildren';\n\nexport const STYLES_CONTEXT = Symbol('STYLES_CONTEXT');\nconst STYLES_SELF = Symbol('STYLES_SELF');\n\nfunction Enhancement(childComponents, Context) {\n return {\n condition: function (Component) {\n return Boolean(Component.style || Component[STATIC_COMPONENT]);\n },\n init: function (props, WrapperComponent) {\n if (WrapperComponent.style) {\n this[STYLES_SELF] = sstyled.merge(WrapperComponent.style, props._styles);\n }\n },\n context: function (context) {\n // Optimization: if has no children there is no need to create new context (by lsroman)\n if (!this[STYLES_SELF] || !Object.keys(childComponents).length) {\n return context;\n }\n return {\n ...context,\n [STYLES_CONTEXT]: this[STYLES_SELF],\n };\n },\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n asProps: function ({ _styles, styles, ...props }) {\n return {\n ...props,\n styles: styles || this[STYLES_SELF],\n };\n },\n wrapperProps: function ({ styles, ...props }) {\n const context = useContext(Context);\n return {\n ...props,\n _styles: styles,\n styles: context[STYLES_CONTEXT],\n };\n },\n };\n}\n\nexport default Enhancement;\n"],"mappings":";;;;;;;;;;;;;AAAA;;AAEA;;AACA;;;;;;;;;AAEO,IAAMA,cAAc,GAAGC,MAAM,CAAC,gBAAD,CAA7B;;AACP,IAAMC,WAAW,GAAGD,MAAM,CAAC,aAAD,CAA1B;;AAEA,SAASE,WAAT,CAAqBC,eAArB,EAAsCC,OAAtC,EAA+C;EAC7C,OAAO;IACLC,SAAS,EAAE,mBAAUC,SAAV,EAAqB;MAC9B,OAAOC,OAAO,CAACD,SAAS,CAACE,KAAV,IAAmBF,SAAS,CAACG,gCAAD,CAA7B,CAAd;IACD,CAHI;IAILC,IAAI,EAAE,cAAUC,KAAV,EAAiBC,gBAAjB,EAAmC;MACvC,IAAIA,gBAAgB,CAACJ,KAArB,EAA4B;QAC1B,KAAKP,WAAL,IAAoBY,eAAA,CAAQC,KAAR,CAAcF,gBAAgB,CAACJ,KAA/B,EAAsCG,KAAK,CAACI,OAA5C,CAApB;MACD;IACF,CARI;IASLC,OAAO,EAAE,iBAAUA,QAAV,EAAmB;MAC1B;MACA,IAAI,CAAC,KAAKf,WAAL,CAAD,IAAsB,CAACgB,MAAM,CAACC,IAAP,CAAYf,eAAZ,EAA6BgB,MAAxD,EAAgE;QAC9D,OAAOH,QAAP;MACD;;MACD,uCACKA,QADL,4CAEGjB,cAFH,EAEoB,KAAKE,WAAL,CAFpB;IAID,CAlBI;IAmBL;IACAmB,OAAO,EAAE,uBAAyC;MAAA,IAA7BL,OAA6B,QAA7BA,OAA6B;MAAA,IAApBM,MAAoB,QAApBA,MAAoB;MAAA,IAATV,KAAS;MAChD,uCACKA,KADL;QAEEU,MAAM,EAAEA,MAAM,IAAI,KAAKpB,WAAL;MAFpB;IAID,CAzBI;IA0BLqB,YAAY,EAAE,6BAAgC;MAAA,IAApBD,MAAoB,SAApBA,MAAoB;MAAA,IAATV,KAAS;MAC5C,IAAMK,OAAO,GAAG,IAAAO,iBAAA,EAAWnB,OAAX,CAAhB;MACA,uCACKO,KADL;QAEEI,OAAO,EAAEM,MAFX;QAGEA,MAAM,EAAEL,OAAO,CAACjB,cAAD;MAHjB;IAKD;EAjCI,CAAP;AAmCD;;eAEcG,W"}
|
|
@@ -109,7 +109,7 @@ function uncontrolledUniversal(props, config, uncontrolledProp) {
|
|
|
109
109
|
var _uncontrolledProp = uncontrolledProp(propName, propValue, propDefaultValue, propHandler, chainHandler),
|
|
110
110
|
_uncontrolledProp2 = (0, _slicedToArray2["default"])(_uncontrolledProp, 2),
|
|
111
111
|
value = _uncontrolledProp2[0],
|
|
112
|
-
handler = _uncontrolledProp2[1]; // TODO:
|
|
112
|
+
handler = _uncontrolledProp2[1]; // TODO: need to warn about recursion (by lsroman)
|
|
113
113
|
|
|
114
114
|
|
|
115
115
|
handlerProps[propName] = handler;
|
|
@@ -158,7 +158,7 @@ function Enhancement() {
|
|
|
158
158
|
});
|
|
159
159
|
},
|
|
160
160
|
asProps: function asProps(props) {
|
|
161
|
-
// TODO
|
|
161
|
+
// TODO: need to omit unneccessary props (by lsroman)
|
|
162
162
|
var _uncontrolled3 = uncontrolled(this, props, this.uncontrolledProps()),
|
|
163
163
|
_uncontrolled4 = (0, _slicedToArray2["default"])(_uncontrolled3, 1),
|
|
164
164
|
uncontrolledProps = _uncontrolled4[0];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"uncontrolledProps.js","names":["assign","target","source","Object","defineProperties","keys","reduce","descriptors","key","getOwnPropertyDescriptor","defaultProp","prop","capitalizeFirstLetter","handlerProp","isControlled","propValue","undefined","uncontrolledProp","self","propName","propDefaultValue","propHandler","chainHandler","getValue","state","value","oldValue","setState","args","callAllEventHandlers","uncontrolledUniversal","props","config","handlerProps","uncontrolledProps","result","handlerName","defaultPropName","other","console","warn","setter","Array","isArray","v","handler","eventOrValue","push","uncontrolled","bind","Enhancement","condition","Component","Boolean","prototype","init","handlers","uncontrolledHandlers","context","asProps"],"sources":["../../../src/enhancement/uncontrolledProps.tsx"],"sourcesContent":["// @ts-ignore\nimport { callAllEventHandlers } from '@semcore/utils/lib/assignProps';\n// @ts-ignore\nimport capitalizeFirstLetter from '@semcore/utils/lib/capitalizeFirstLetter';\n\nfunction assign(target, source) {\n return Object.defineProperties(\n target,\n Object.keys(source).reduce((descriptors, key) => {\n descriptors[key] = Object.getOwnPropertyDescriptor(source, key);\n return descriptors;\n }, {}),\n );\n}\n\nfunction defaultProp(prop) {\n return 'default' + capitalizeFirstLetter(prop);\n}\n\nfunction handlerProp(prop) {\n if (prop === 'value') prop = '';\n if (prop === 'checked') prop = '';\n return `on${capitalizeFirstLetter(prop)}Change`;\n}\n\nfunction isControlled(propValue) {\n return propValue !== undefined;\n}\n\nfunction uncontrolledProp(self, propName, propValue, propDefaultValue, propHandler, chainHandler) {\n function getValue() {\n return isControlled(propValue)\n ? propValue\n : propName in self.state\n ? self.state[propName]\n : propDefaultValue;\n }\n\n return [\n getValue(),\n (value, ...args) => {\n const oldValue = getValue();\n if (oldValue === value) return false;\n if (!isControlled(propValue)) self.setState({ [propName]: value });\n return callAllEventHandlers(propHandler, ...chainHandler)(value, ...args);\n },\n ];\n}\n\nfunction uncontrolledUniversal(props, config, uncontrolledProp) {\n const handlerProps = {};\n const uncontrolledProps = Object.keys(config).reduce((result, propName) => {\n const handlerName = handlerProp(propName);\n const defaultPropName = defaultProp(propName);\n const {\n [defaultPropName]: propDefaultValue,\n [propName]: propValue,\n [handlerName]: propHandler,\n ...other\n } = result;\n\n if (propDefaultValue === undefined) {\n // eslint-disable-next-line no-console\n console.warn(defaultPropName, 'must be installed in \"defaultProps\"');\n }\n\n // if (typeof propDefaultValue === 'function' && propDefaultValue.defaultInit) {\n // propDefaultValue = propDefaultValue(result);\n // }\n\n let setter = config[propName];\n let chainHandler = [];\n\n if (Array.isArray(setter)) [setter, ...chainHandler] = setter;\n setter = setter || ((v) => v);\n\n const [value, handler] = uncontrolledProp(\n propName,\n propValue,\n propDefaultValue,\n propHandler,\n chainHandler,\n );\n // TODO: need to warn about recursion (by lsroman)\n handlerProps[propName] = handler;\n\n return {\n ...other,\n [propName]: value,\n [handlerName]: (eventOrValue, ...args) => {\n const result = [setter(eventOrValue, ...args), ...args];\n if (eventOrValue && eventOrValue.target) {\n result.push(eventOrValue);\n }\n return handler(...result);\n },\n };\n }, props);\n return [uncontrolledProps, handlerProps];\n}\n\nfunction uncontrolled(self, props, config) {\n return uncontrolledUniversal(props, config, uncontrolledProp.bind(undefined, self));\n}\n\nfunction Enhancement() {\n return {\n condition: function (Component) {\n return Boolean(Component.prototype.uncontrolledProps);\n },\n init: function () {\n this.state = this.state || {};\n assign(this, {\n get handlers() {\n const [, uncontrolledHandlers] = uncontrolled(this, this.props, this.uncontrolledProps());\n return uncontrolledHandlers;\n },\n });\n },\n context: function (context) {\n return {\n ...context,\n handlers: this.handlers,\n };\n },\n asProps: function (props) {\n // TODO: need to omit unneccessary props (by lsroman)\n const [uncontrolledProps] = uncontrolled(this, props, this.uncontrolledProps());\n return uncontrolledProps;\n },\n };\n}\n\nexport default Enhancement;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AACA;;AAEA;;;;;;;;;;AAEA,SAASA,MAAT,CAAgBC,MAAhB,EAAwBC,MAAxB,EAAgC;EAC9B,OAAOC,MAAM,CAACC,gBAAP,CACLH,MADK,EAELE,MAAM,CAACE,IAAP,CAAYH,MAAZ,EAAoBI,MAApB,CAA2B,UAACC,WAAD,EAAcC,GAAd,EAAsB;IAC/CD,WAAW,CAACC,GAAD,CAAX,GAAmBL,MAAM,CAACM,wBAAP,CAAgCP,M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A4BiB,YAAY,CAAC,IAAD,EAAOjB,KAAP,EAAc,KAAKG,iBAAL,EAAd,CAAxC;MAAA;MAAA,IAAOA,iBAAP;;MACA,OAAOA,iBAAP;IACD;EAvBI,CAAP;AAyBD;;eAEcgB,W"}
|
package/lib/cjs/index.js
CHANGED
|
@@ -195,7 +195,7 @@ function createGetField(enhancements, Component, isFunction) {
|
|
|
195
195
|
|
|
196
196
|
function createForwardWrapper(Component, wrapperProps, statics, isFunction) {
|
|
197
197
|
// @ts-ignore
|
|
198
|
-
var WrapperComponent = _react["default"].forwardRef(function (_ref, ref) {
|
|
198
|
+
var WrapperComponent = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
199
199
|
var _ref$forwardRef = _ref.forwardRef,
|
|
200
200
|
forwardRef = _ref$forwardRef === void 0 ? null : _ref$forwardRef,
|
|
201
201
|
other = (0, _objectWithoutProperties2["default"])(_ref, _excluded);
|
|
@@ -328,7 +328,7 @@ function wrapFunction(OriginComponent, enhancements, Context) {
|
|
|
328
328
|
var wrapperProps = getField('wrapperProps');
|
|
329
329
|
var contexts = getField('context');
|
|
330
330
|
|
|
331
|
-
var Component = _react["default"].memo(function FunctionMemoComponent(other) {
|
|
331
|
+
var Component = /*#__PURE__*/_react["default"].memo(function FunctionMemoComponent(other) {
|
|
332
332
|
var selfRef = (0, _react.useRef)({});
|
|
333
333
|
var firstRender = (0, _react.useRef)(true);
|
|
334
334
|
(0, _useEnhancedEffect["default"])(function () {
|
|
@@ -407,7 +407,7 @@ function createComponent(OriginComponent) {
|
|
|
407
407
|
var childComponents = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
408
408
|
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
409
409
|
var _options$context = options.context,
|
|
410
|
-
context = _options$context === void 0 ? _react["default"].createContext({}) : _options$context,
|
|
410
|
+
context = _options$context === void 0 ? /*#__PURE__*/_react["default"].createContext({}) : _options$context,
|
|
411
411
|
_options$parent = options.parent,
|
|
412
412
|
parent = _options$parent === void 0 ? [] : _options$parent,
|
|
413
413
|
_options$enhancements = options.enhancements,
|
|
@@ -463,7 +463,7 @@ function createBaseComponent(OriginComponent) {
|
|
|
463
463
|
var Component = null;
|
|
464
464
|
|
|
465
465
|
if (!_react["default"].PureComponent.isPrototypeOf(OriginComponent) && !_react["default"].Component.isPrototypeOf(OriginComponent) && typeof OriginComponent === 'function') {
|
|
466
|
-
Component = _react["default"].forwardRef(OriginComponent);
|
|
466
|
+
Component = /*#__PURE__*/_react["default"].forwardRef(OriginComponent);
|
|
467
467
|
Component.displayName = OriginComponent.displayName;
|
|
468
468
|
Component.defaultProps = _objectSpread({
|
|
469
469
|
'data-ui-name': OriginComponent.displayName
|