@semcore/core 1.13.16 → 1.13.18

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.
Files changed (43) hide show
  1. package/CHANGELOG.md +2 -2
  2. package/lib/cjs/Component.js +2 -8
  3. package/lib/cjs/Component.js.map +1 -1
  4. package/lib/cjs/enhancement/Children.js +5 -12
  5. package/lib/cjs/enhancement/Children.js.map +1 -1
  6. package/lib/cjs/enhancement/Root.js +4 -8
  7. package/lib/cjs/enhancement/Root.js.map +1 -1
  8. package/lib/cjs/enhancement/dataName.js +2 -6
  9. package/lib/cjs/enhancement/dataName.js.map +1 -1
  10. package/lib/cjs/enhancement/hoistProps.js +6 -5
  11. package/lib/cjs/enhancement/hoistProps.js.map +1 -1
  12. package/lib/cjs/enhancement/staticChildren.js +5 -6
  13. package/lib/cjs/enhancement/staticChildren.js.map +1 -1
  14. package/lib/cjs/enhancement/style.js +5 -8
  15. package/lib/cjs/enhancement/style.js.map +1 -1
  16. package/lib/cjs/enhancement/uncontrolledProps.js +9 -13
  17. package/lib/cjs/enhancement/uncontrolledProps.js.map +1 -1
  18. package/lib/cjs/index.js +11 -22
  19. package/lib/cjs/index.js.map +1 -1
  20. package/lib/cjs/styled/index.js +1 -5
  21. package/lib/cjs/styled/sstyled.js +3 -6
  22. package/lib/cjs/styled/sstyled.js.map +1 -1
  23. package/lib/es6/Component.js +1 -7
  24. package/lib/es6/Component.js.map +1 -1
  25. package/lib/es6/enhancement/Children.js +1 -6
  26. package/lib/es6/enhancement/Children.js.map +1 -1
  27. package/lib/es6/enhancement/Root.js +1 -6
  28. package/lib/es6/enhancement/Root.js.map +1 -1
  29. package/lib/es6/enhancement/dataName.js +1 -5
  30. package/lib/es6/enhancement/dataName.js.map +1 -1
  31. package/lib/es6/enhancement/hoistProps.js +1 -5
  32. package/lib/es6/enhancement/hoistProps.js.map +1 -1
  33. package/lib/es6/enhancement/staticChildren.js +1 -6
  34. package/lib/es6/enhancement/staticChildren.js.map +1 -1
  35. package/lib/es6/enhancement/style.js +1 -5
  36. package/lib/es6/enhancement/style.js.map +1 -1
  37. package/lib/es6/enhancement/uncontrolledProps.js +2 -10
  38. package/lib/es6/enhancement/uncontrolledProps.js.map +1 -1
  39. package/lib/es6/index.js +3 -11
  40. package/lib/es6/index.js.map +1 -1
  41. package/lib/es6/styled/sstyled.js +1 -5
  42. package/lib/es6/styled/sstyled.js.map +1 -1
  43. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  CHANGELOG.md standards are inspired by [keepachangelog.com](https://keepachangelog.com/en/1.0.0/).
4
4
 
5
- ## [1.13.16] - 2023-02-20
5
+ ## [1.13.18] - 2023-03-13
6
6
 
7
7
  ### Changed
8
8
 
9
- - Version patch update due to children dependencies update (`@semcore/utils` [3.46.1 ~> 3.47.0]).
9
+ - Version patch update due to children dependencies update (`@semcore/utils` [3.47.1 ~> 3.47.2]).
10
10
 
11
11
  ## [1.13.15] - 2023-02-09
12
12
 
@@ -15,22 +15,16 @@ var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/hel
15
15
 
16
16
  var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
17
17
 
18
- var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
19
-
20
- var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
18
+ var _createSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/createSuper"));
21
19
 
22
20
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
23
21
 
24
22
  var _react = require("react");
25
23
 
26
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
27
-
28
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
29
-
30
24
  var RootComponent = /*#__PURE__*/function (_PureComponent) {
31
25
  (0, _inherits2["default"])(RootComponent, _PureComponent);
32
26
 
33
- var _super = _createSuper(RootComponent);
27
+ var _super = (0, _createSuper2["default"])(RootComponent);
34
28
 
35
29
  function RootComponent() {
36
30
  var _this;
@@ -1 +1 @@
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"}
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"}
@@ -11,7 +11,7 @@ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/h
11
11
 
12
12
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
13
13
 
14
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
14
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
15
15
 
16
16
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
17
17
 
@@ -21,11 +21,6 @@ var _index = require("../index");
21
21
 
22
22
  var _excluded = ["handlers", "getters"],
23
23
  _excluded2 = ["handlers"];
24
-
25
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
26
-
27
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
28
-
29
24
  var CHILDREN_COMPONENT = Symbol('CHILDREN_COMPONENT');
30
25
  exports.CHILDREN_COMPONENT = CHILDREN_COMPONENT;
31
26
  var CHILDREN_SELF = Symbol('CHILDREN_SELF');
@@ -61,9 +56,7 @@ function getterToArray(getter) {
61
56
  function mergeObjects() {
62
57
  var a = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
63
58
  var b = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
64
-
65
- var core = _objectSpread(_objectSpread({}, a), b);
66
-
59
+ var core = (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, a), b);
67
60
  return Object.keys(core).reduce(function (acc, key) {
68
61
  a[key] = getterToArray(a[key]);
69
62
  b[key] = getterToArray(b[key]);
@@ -95,7 +88,7 @@ function createChildren(Context, contexts) {
95
88
  props = _splitPropsAndGetters.props,
96
89
  getters = _splitPropsAndGetters.getters;
97
90
 
98
- return Object.assign({}, acc, _objectSpread({
91
+ return Object.assign({}, acc, (0, _objectSpread2["default"])({
99
92
  handlers: Object.assign({}, acc.handlers, handlers),
100
93
  getters: mergeObjects(acc.getters, getters)
101
94
  }, props));
@@ -114,7 +107,7 @@ function createChildren(Context, contexts) {
114
107
  acc[key] = assignGettersChain(value);
115
108
  return acc;
116
109
  }, {});
117
- return children(_objectSpread(_objectSpread({}, props), mergedGetters), handlers);
110
+ return children((0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, props), mergedGetters), handlers);
118
111
  } else if (children === undefined) {
119
112
  return null;
120
113
  }
@@ -141,7 +134,7 @@ function Enhancement(Context, parent) {
141
134
  // this[CHILDREN_SELF].origin = _Children ? _Children.origin : children;
142
135
  this[CHILDREN_SELF].origin = props.children;
143
136
  this[CHILDREN_SELF].props = props;
144
- return _objectSpread(_objectSpread({}, props), {}, {
137
+ return (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, props), {}, {
145
138
  Children: this[CHILDREN_SELF]
146
139
  });
147
140
  }
@@ -1 +1 @@
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,IAAI,mCAAQF,CAAR,GAAcC,CAAd,CAAV;;EACA,OAAOd,MAAM,CAACgB,IAAP,CAAYD,IAAZ,EAAkBb,MAAlB,CAAyB,U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AAjB;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"}
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,G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- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
10
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
11
11
 
12
12
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
13
13
 
@@ -22,10 +22,6 @@ var _ref4 = require("@semcore/utils/lib/ref");
22
22
  var _excluded = ["render"],
23
23
  _excluded2 = ["Root", "styles", "children", "Children", "forwardRef"];
24
24
 
25
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
26
-
27
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
28
-
29
25
  function createRootRender() {
30
26
  // @ts-ignore
31
27
  var Root = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
@@ -57,9 +53,9 @@ function createRootRender() {
57
53
  child.children = /*#__PURE__*/_react["default"].createElement(Children, null);
58
54
  }
59
55
 
60
- var other = (0, _assignProps["default"])(_objectSpread(_objectSpread({}, clearProps), {}, {
56
+ var other = (0, _assignProps["default"])((0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, clearProps), {}, {
61
57
  ref: (0, _ref4.useForkRef)(forwardRef, ref)
62
- }), _objectSpread(_objectSpread({}, child), source));
58
+ }), (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, child), source));
63
59
 
64
60
  if (!Tag) {
65
61
  throw new Error('`render` prop of Root is not provided');
@@ -80,7 +76,7 @@ function Enhancement() {
80
76
  },
81
77
  asProps: function asProps(props, WrapperComponent, isFunction) {
82
78
  if (isFunction) {
83
- return _objectSpread(_objectSpread({}, props), {}, {
79
+ return (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, props), {}, {
84
80
  Root: this.Root
85
81
  });
86
82
  }
@@ -1 +1 @@
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,MAJF;IAAA,IAMEC,QANF,eAMEA,QANF;IAAA,IAOEC,QAPF,eAOEA,QAPF;IAAA,wCAQET,UARF;IAAA,IAQEA,UARF,sCAQe,IARf;IAAA,IASKK,KATL;IAaA,IAAMK,UAAU,GAAGC,MAAM,CAACC,OAAP,CAAeP,KAAf,EAAsBQ,MAAtB,CAA6B,UAACR,KAAD,SAA0B;MAAA;MAAA,IAAjBS,IAAiB;MAAA,IAAXC,KAAW;;MACxE,IAAIA,KAAK,KAAKC,SAAd,EAAyB;QACvBX,KAAK,CAACS,IAAD,CAAL,GAAcC,KAAd;MACD;;MACD,OAAOV,KAAP;IACD,CALkB,EAKhB,EALgB,CAAnB;IAOA,IAAMY,KAAK,GAAG,EAAd,CArBuE,CAsBvE;;IACA,IAAI,OAAOR,QAAQ,CAACS,MAAhB,KAA2B,WAA/B,EAA4C;MAC1C;MACAD,KAAK,CAACT,QAAN,gBAAiB,gCAAC,QAAD,OAAjB;IACD;;IAED,IAAMW,KAAK,GAAG,IAAAC,uBAAA,kCAEPV,UAFO;MAGVT,GAAG,EAAE,IAAAoB,gBAAA,EAAWrB,UAAX,EAAuBC,GAAvB;IAHK,oCAMPgB,KANO,GAOPb,MAPO,EAAd;;IAUA,IAAI,CAACF,GAAL,EAAU;MACR,MAAM,IAAIoB,KAAJ,CAAU,uCAAV,CAAN;IACD;;IACD,oBAAO,gCAAC,GAAD,EAASH,KAAT,CAAP;EACD,CA1CY,CAAb,CAF0B,CA6C1B;;;EACArB,IAAI,CAACO,KAAL,GAAa,EAAb;EACA,OAAOP,IAAP;AACD;;AAED,SAASyB,WAAT,GAAuB;EACrB,OAAO;IACLC,IAAI,EAAE,gBAAY;MAChB,KAAK1B,IAAL,GAAYD,gBAAgB,EAA5B;IACD,CAHI;IAIL4B,OAAO,EAAE,iBAAUpB,KAAV,EAAiBqB,gBAAjB,EAAmCC,UAAnC,EAA+C;MACtD,IAAIA,UAAJ,EAAgB;QACd,uCACKtB,KADL;UAEEP,IAAI,EAAE,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
+ {"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,MAJF;IAAA,IAMEC,QANF,eAMEA,QANF;IAAA,IAOEC,QAPF,eAOEA,QAPF;IAAA,wCAQET,UARF;IAAA,IAQEA,UARF,sCAQe,IARf;IAAA,IASKK,KATL;IAaA,IAAMK,UAAU,GAAGC,MAAM,CAACC,OAAP,CAAeP,KAAf,EAAsBQ,MAAtB,CAA6B,UAACR,KAAD,SAA0B;MAAA;MAAA,IAAjBS,IAAiB;MAAA,IAAXC,KAAW;;MACxE,IAAIA,KAAK,KAAKC,SAAd,EAAyB;QACvBX,KAAK,CAACS,IAAD,CAAL,GAAcC,KAAd;MACD;;MACD,OAAOV,KAAP;IACD,CALkB,EAKhB,EALgB,CAAnB;IAOA,IAAMY,KAAK,GAAG,EAAd,CArBuE,CAsBvE;;IACA,IAAI,OAAOR,QAAQ,CAACS,MAAhB,KAA2B,WAA/B,EAA4C;MAC1C;MACAD,KAAK,CAACT,QAAN,gBAAiB,gCAAC,QAAD,OAAjB;IACD;;IAED,IAAMW,KAAK,GAAG,IAAAC,uBAAA,oEAEPV,UAFO;MAGVT,GAAG,EAAE,IAAAoB,gBAAA,EAAWrB,UAAX,EAAuBC,GAAvB;IAHK,sEAMPgB,KANO,GAOPb,MAPO,EAAd;;IAUA,IAAI,CAACF,GAAL,EAAU;MACR,MAAM,IAAIoB,KAAJ,CAAU,uCAAV,CAAN;IACD;;IACD,oBAAO,gCAAC,GAAD,EAASH,KAAT,CAAP;EACD,CA1CY,CAAb,CAF0B,CA6C1B;;;EACArB,IAAI,CAACO,KAAL,GAAa,EAAb;EACA,OAAOP,IAAP;AACD;;AAED,SAASyB,WAAT,GAAuB;EACrB,OAAO;IACLC,IAAI,EAAE,gBAAY;MAChB,KAAK1B,IAAL,GAAYD,gBAAgB,EAA5B;IACD,CAHI;IAIL4B,OAAO,EAAE,iBAAUpB,KAAV,EAAiBqB,gBAAjB,EAAmCC,UAAnC,EAA+C;MACtD,IAAIA,UAAJ,EAAgB;QACd,yEACKtB,KADL;UAEEP,IAAI,EAAE,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"}
@@ -7,16 +7,12 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports["default"] = void 0;
9
9
 
10
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
-
12
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
13
-
14
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
10
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
15
11
 
16
12
  function Enhancement() {
17
13
  return {
18
14
  wrapperProps: function wrapperProps(props, WrapperComponent) {
19
- return _objectSpread({
15
+ return (0, _objectSpread2["default"])({
20
16
  'data-ui-name': WrapperComponent.displayName
21
17
  }, props);
22
18
  }
@@ -1 +1 @@
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
+ {"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"}
@@ -11,6 +11,8 @@ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/sli
11
11
 
12
12
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
13
13
 
14
+ var _objectSpread3 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
15
+
14
16
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
15
17
 
16
18
  var _react = require("react");
@@ -21,10 +23,9 @@ var _useEnhancedEffect = _interopRequireDefault(require("@semcore/utils/lib/use/
21
23
 
22
24
  var _pick = _interopRequireDefault(require("@semcore/utils/lib/pick"));
23
25
 
24
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
25
-
26
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
27
-
26
+ // @ts-ignore
27
+ // @ts-ignore
28
+ // @ts-ignore
28
29
  var HOIST_CONTEXT = Symbol('HOIST_CONTEXT');
29
30
  exports.HOIST_CONTEXT = HOIST_CONTEXT;
30
31
  var HOIST_SELF = Symbol('HOIST_SELF');
@@ -71,7 +72,7 @@ function Enhancement(childComponents, Context) {
71
72
  context: function context(_context) {
72
73
  // TODO: need to optimizte container initialization (by lsroman)
73
74
  // WrapperComponent.hoistProps
74
- return _objectSpread(_objectSpread({}, _context), {}, (0, _defineProperty2["default"])({}, HOIST_CONTEXT, this[HOIST_SET]));
75
+ return (0, _objectSpread3["default"])((0, _objectSpread3["default"])({}, _context), {}, (0, _defineProperty2["default"])({}, HOIST_CONTEXT, this[HOIST_SET]));
75
76
  },
76
77
  asProps: function asProps(props) {
77
78
  // TODO: need to check for no props overwriting (by lsroman)
@@ -1 +1 @@
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;MAC5B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AA6DD;;eAEcR,W"}
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;;AALA;AAEA;AAEA;AAGO,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;MAC9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WAAW,GAAGV,gBAAgB,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"}
@@ -9,7 +9,7 @@ exports["default"] = exports.STATIC_COMPONENT = exports.ROOT_COMPONENT = void 0;
9
9
  exports.getterMethodName = getterMethodName;
10
10
  exports.getterMethodNameByDisplayName = getterMethodNameByDisplayName;
11
11
 
12
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
12
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
13
13
 
14
14
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
15
15
 
@@ -23,10 +23,9 @@ var _pick = _interopRequireDefault(require("@semcore/utils/lib/pick"));
23
23
 
24
24
  var _logger = _interopRequireDefault(require("@semcore/utils/lib/logger"));
25
25
 
26
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
27
-
28
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
29
-
26
+ // @ts-ignore
27
+ // @ts-ignore
28
+ // @ts-ignore
30
29
  function assign(target, source) {
31
30
  return Object.defineProperties(target, Object.keys(source).reduce(function (descriptors, key) {
32
31
  descriptors[key] = Object.getOwnPropertyDescriptor(source, key);
@@ -134,7 +133,7 @@ function Enhancement(childComponents, createComponent, options) {
134
133
  /*, WrapperComponent*/
135
134
  ) {
136
135
  // const getterMethod = getterMethodNameByDisplayName(WrapperComponent.displayName);
137
- return _objectSpread(_objectSpread({}, _context), (0, _pick["default"])(this, getterMethodNames));
136
+ return (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, _context), (0, _pick["default"])(this, getterMethodNames));
138
137
  },
139
138
  wrapperProps: function wrapperProps(props, WrapperComponent) {
140
139
  if (!WrapperComponent[STATIC_COMPONENT]) return props;
@@ -1 +1 @@
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","ROOT_COMPONENT","SELF_GETTER_METHOD","Enhancement","createComponent","options","getterMethodNames","condition","Component","Boolean","init","props","WrapperComponent","getterMethods","pick","selfGetterMethod","logger","warn","getterMethod","childrenProps","getterProps","call","index","assignProps","cache","Set","Error","prevStaticComponent","prevDisplayName","context","wrapperProps","useContext","has","add","render","forEach","undefined","clear"],"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\nexport function getterMethodName(name) {\n return `get${name}Props`;\n}\n\nexport function 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');\nexport const ROOT_COMPONENT = Symbol('ROOT_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 return assignProps(childrenProps, getterProps);\n };\n acc[name].index = -1;\n acc[name].cache = new Set();\n return acc;\n }, {}),\n );\n },\n static: function (WrapperComponent, Component) {\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 value[ROOT_COMPONENT] = Component[ROOT_COMPONENT] || Component;\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 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 const context = useContext(options.context);\n const getterMethod = context[getterMethodNameByDisplayName(WrapperComponent.displayName)];\n if (getterMethod) {\n if (!getterMethod.cache.has(this)) {\n getterMethod.cache.add(this);\n getterMethod.index++;\n if (this) this.index = getterMethod.index;\n }\n if (this) getterMethod.index = this.index;\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 = -1;\n this[name].cache.clear();\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;;AAEM,SAASG,gBAAT,CAA0BC,IAA1B,EAAgC;EACrC,oBAAaA,IAAb;AACD;;AAEM,SAASC,6BAAT,GAAyD;EAAA,IAAlBC,WAAkB,uEAAJ,EAAI;EAC9D,IAAMC,YAAY,GAAGD,WAAW,CAACE,KAAZ,CAAkB,GAAlB,CAArB;EACA,IAAMJ,IAAI,GAAGG,YAAY,CAACE,KAAb,CAAmB,EAAEF,YAAY,CAACG,MAAb,GAAsB,CAAxB,CAAnB,EAA+CC,IAA/C,CAAoD,EAApD,CAAb;EACA,OAAOR,gBAAgB,CAACC,IAAD,CAAvB;AACD;;AAED,SAASQ,qBAAT,CAA+BC,eAA/B,EAAgDC,UAAhD,EAAqE;EACnE,OAAOlB,MAAM,CAACmB,OAAP,CAAeF,eAAf,EAAgCd,MAAhC,CAAiD,UAACiB,GAAD,QAAwB;IAAA;IAAA,IAAjBZ,IAAiB;IAAA,IAAXa,KAAW;;IAC9E,IAAIC,KAAK,CAACC,OAAN,CAAcF,KAAd,CAAJ,EAA0B;MACxBD,GAAG,iDAAOA,GAAP,uCAAeJ,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,YAAY,CAACI,KAAb,GAAqB,KAAKA,KAA1B;QACV,OAAOJ,YAAY,CAACP,KAAD,CAAnB;MACD;;MACD,OAAOA,KAAP;IACD,CA7EI;IA8ELuB,MAAM,EAAE,gBAAUA,OAAV,EAAkB;MAAA;;MACxB5B,iBAAiB,CAAC6B,OAAlB,CAA0B,UAACrD,IAAD,EAAU;QAClC,IAAI,MAAI,CAACA,IAAD,CAAJ,KAAesD,SAAnB,EAA8B;QAC9B,MAAI,CAACtD,IAAD,CAAJ,CAAWwC,KAAX,GAAmB,CAAC,CAApB;;QACA,MAAI,CAACxC,IAAD,CAAJ,CAAW0C,KAAX,CAAiBa,KAAjB;MACD,CAJD;MAKA,OAAOH,OAAP;IACD;EArFI,CAAP;AAuFD;;eAEc/B,W"}
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","ROOT_COMPONENT","SELF_GETTER_METHOD","Enhancement","createComponent","options","getterMethodNames","condition","Component","Boolean","init","props","WrapperComponent","getterMethods","pick","selfGetterMethod","logger","warn","getterMethod","childrenProps","getterProps","call","index","assignProps","cache","Set","Error","prevStaticComponent","prevDisplayName","context","wrapperProps","useContext","has","add","render","forEach","undefined","clear"],"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\nexport function getterMethodName(name) {\n return `get${name}Props`;\n}\n\nexport function 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');\nexport const ROOT_COMPONENT = Symbol('ROOT_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 return assignProps(childrenProps, getterProps);\n };\n acc[name].index = -1;\n acc[name].cache = new Set();\n return acc;\n }, {}),\n );\n },\n static: function (WrapperComponent, Component) {\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 value[ROOT_COMPONENT] = Component[ROOT_COMPONENT] || Component;\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 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 const context = useContext(options.context);\n const getterMethod = context[getterMethodNameByDisplayName(WrapperComponent.displayName)];\n if (getterMethod) {\n if (!getterMethod.cache.has(this)) {\n getterMethod.cache.add(this);\n getterMethod.index++;\n if (this) this.index = getterMethod.index;\n }\n if (this) getterMethod.index = this.index;\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 = -1;\n this[name].cache.clear();\n });\n return render;\n },\n };\n}\n\nexport default Enhancement;\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA;;AAEA;;AAEA;;AAEA;;AALA;AAEA;AAEA;AAGA,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;;AAEM,SAASG,gBAAT,CAA0BC,IAA1B,EAAgC;EACrC,oBA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,EAAWR,iBAAX,CAHL;IAKD,CA9DI;IA+DLwB,YAAY,EAAE,sBAAUnB,KAAV,EAAiBC,gBAAjB,EAAmC;MAC/C,IAAI,CAACA,gBAAgB,CAACb,gBAAD,CAArB,EAAyC,OAAOY,KAAP;MACzC,IAAMkB,OAAO,GAAG,IAAAE,iBAAA,EAAW1B,OAAO,CAACwB,OAAnB,CAAhB;MACA,IAAMX,YAAY,GAAGW,OAAO,CAAC9C,6BAA6B,CAAC6B,gBAAgB,CAAC5B,WAAlB,CAA9B,CAA5B;;MACA,IAAIkC,YAAJ,EAAkB;QAChB,IAAI,CAACA,YAAY,CAACM,KAAb,CAAmBQ,GAAnB,CAAuB,IAAvB,CAAL,EAAmC;UACjCd,YAAY,CAACM,KAAb,CAAmBS,GAAnB,CAAuB,IAAvB;UACAf,YAAY,CAACI,KAAb;UACA,IAAI,IAAJ,EAAU,KAAKA,KAAL,GAAaJ,YAAY,CAACI,KAA1B;QACX;;QACD,IAAI,IAAJ,EAAUJ,YAAY,CAACI,KAAb,GAAqB,KAAKA,KAA1B;QACV,OAAOJ,YAAY,CAACP,KAAD,CAAnB;MACD;;MACD,OAAOA,KAAP;IACD,CA7EI;IA8ELuB,MAAM,EAAE,gBAAUA,OAAV,EAAkB;MAAA;;MACxB5B,iBAAiB,CAAC6B,OAAlB,CAA0B,UAACrD,IAAD,EAAU;QAClC,IAAI,MAAI,CAACA,IAAD,CAAJ,KAAesD,SAAnB,EAA8B;QAC9B,MAAI,CAACtD,IAAD,CAAJ,CAAWwC,KAAX,GAAmB,CAAC,CAApB;;QACA,MAAI,CAACxC,IAAD,CAAJ,CAAW0C,KAAX,CAAiBa,KAAjB;MACD,CAJD;MAKA,OAAOH,OAAP;IACD;EArFI,CAAP;AAuFD;;eAEc/B,W"}
@@ -11,6 +11,8 @@ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/h
11
11
 
12
12
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
13
13
 
14
+ var _objectSpread3 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
15
+
14
16
  var _react = require("react");
15
17
 
16
18
  var _styled = require("../styled");
@@ -19,11 +21,6 @@ var _staticChildren = require("./staticChildren");
19
21
 
20
22
  var _excluded = ["_styles", "styles"],
21
23
  _excluded2 = ["styles"];
22
-
23
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
24
-
25
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
26
-
27
24
  var STYLES_CONTEXT = Symbol('STYLES_CONTEXT');
28
25
  exports.STYLES_CONTEXT = STYLES_CONTEXT;
29
26
  var STYLES_SELF = Symbol('STYLES_SELF');
@@ -44,14 +41,14 @@ function Enhancement(childComponents, Context) {
44
41
  return _context;
45
42
  }
46
43
 
47
- return _objectSpread(_objectSpread({}, _context), {}, (0, _defineProperty2["default"])({}, STYLES_CONTEXT, this[STYLES_SELF]));
44
+ return (0, _objectSpread3["default"])((0, _objectSpread3["default"])({}, _context), {}, (0, _defineProperty2["default"])({}, STYLES_CONTEXT, this[STYLES_SELF]));
48
45
  },
49
46
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
50
47
  asProps: function asProps(_ref) {
51
48
  var _styles = _ref._styles,
52
49
  styles = _ref.styles,
53
50
  props = (0, _objectWithoutProperties2["default"])(_ref, _excluded);
54
- return _objectSpread(_objectSpread({}, props), {}, {
51
+ return (0, _objectSpread3["default"])((0, _objectSpread3["default"])({}, props), {}, {
55
52
  styles: styles || this[STYLES_SELF]
56
53
  });
57
54
  },
@@ -59,7 +56,7 @@ function Enhancement(childComponents, Context) {
59
56
  var styles = _ref2.styles,
60
57
  props = (0, _objectWithoutProperties2["default"])(_ref2, _excluded2);
61
58
  var context = (0, _react.useContext)(Context);
62
- return _objectSpread(_objectSpread({}, props), {}, {
59
+ return (0, _objectSpread3["default"])((0, _objectSpread3["default"])({}, props), {}, {
63
60
  _styles: styles,
64
61
  styles: context[STYLES_CONTEXT]
65
62
  });
@@ -1 +1 @@
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: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AAX,CAAhB;MACA,uCACKO,KADL;QAEEI,OAAO,EAAEM,MAFX;QAGEA,MAAM,EAAEL,OAAO,CAACjB,cAAD;MAHjB;IAKD;EAjCI,CAAP;AAmCD;;eAEcG,W"}
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,yEACKA,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,yEACKA,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,yEACKO,KADL;QAEEI,OAAO,EAAEM,MAFX;QAGEA,MAAM,EAAEL,OAAO,CAACjB,cAAD;MAHjB;IAKD;EAjCI,CAAP;AAmCD;;eAEcG,W"}
@@ -2,19 +2,21 @@
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
4
 
5
- var _typeof = require("@babel/runtime/helpers/typeof");
6
-
7
5
  Object.defineProperty(exports, "__esModule", {
8
6
  value: true
9
7
  });
10
8
  exports["default"] = void 0;
11
9
 
10
+ var _objectSpread3 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
11
+
12
12
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
13
13
 
14
14
  var _toArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toArray"));
15
15
 
16
16
  var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
17
17
 
18
+ var _toPropertyKey2 = _interopRequireDefault(require("@babel/runtime/helpers/toPropertyKey"));
19
+
18
20
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
19
21
 
20
22
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
@@ -23,14 +25,8 @@ var _assignProps = require("@semcore/utils/lib/assignProps");
23
25
 
24
26
  var _capitalizeFirstLetter = _interopRequireDefault(require("@semcore/utils/lib/capitalizeFirstLetter"));
25
27
 
26
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
27
-
28
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
29
-
30
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
31
-
32
- function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
33
-
28
+ // @ts-ignore
29
+ // @ts-ignore
34
30
  function assign(target, source) {
35
31
  return Object.defineProperties(target, Object.keys(source).reduce(function (descriptors, key) {
36
32
  descriptors[key] = Object.getOwnPropertyDescriptor(source, key);
@@ -80,7 +76,7 @@ function uncontrolledUniversal(props, config, uncontrolledProp) {
80
76
  var propDefaultValue = result[defaultPropName],
81
77
  propValue = result[propName],
82
78
  propHandler = result[handlerName],
83
- other = (0, _objectWithoutProperties2["default"])(result, [defaultPropName, propName, handlerName].map(_toPropertyKey));
79
+ other = (0, _objectWithoutProperties2["default"])(result, [defaultPropName, propName, handlerName].map(_toPropertyKey2["default"]));
84
80
 
85
81
  if (propDefaultValue === undefined) {
86
82
  // eslint-disable-next-line no-console
@@ -113,7 +109,7 @@ function uncontrolledUniversal(props, config, uncontrolledProp) {
113
109
 
114
110
 
115
111
  handlerProps[propName] = handler;
116
- return _objectSpread(_objectSpread({}, other), {}, (_objectSpread2 = {}, (0, _defineProperty2["default"])(_objectSpread2, propName, value), (0, _defineProperty2["default"])(_objectSpread2, handlerName, function (eventOrValue) {
112
+ return (0, _objectSpread3["default"])((0, _objectSpread3["default"])({}, other), {}, (_objectSpread2 = {}, (0, _defineProperty2["default"])(_objectSpread2, propName, value), (0, _defineProperty2["default"])(_objectSpread2, handlerName, function (eventOrValue) {
117
113
  for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
118
114
  args[_key2 - 1] = arguments[_key2];
119
115
  }
@@ -153,7 +149,7 @@ function Enhancement() {
153
149
  });
154
150
  },
155
151
  context: function context(_context) {
156
- return _objectSpread(_objectSpread({}, _context), {}, {
152
+ return (0, _objectSpread3["default"])((0, _objectSpread3["default"])({}, _context), {}, {
157
153
  handlers: this.handlers
158
154
  });
159
155
  },
@@ -1 +1 @@
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,EA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OA,oBAAP;QACD;;MAJU,CAAP,CAAN;IAMD,CAZI;IAaLC,OAAO,EAAE,iBAAUA,QAAV,EAAmB;MAC1B,uCACKA,QADL;QAEEF,QAAQ,EAAE,KAAKA;MAFjB;IAID,CAlBI;IAmBLG,OAAO,EAAE,iBAAU5B,KAAV,EAAiB;MACxB;MACA,qBAA4BiB,YAAY,CAAC,IAAD,EAAOjB,KAAP,EAAc,KAAKG,iBAAL,EAAd,CAAxC;MAAA;MAAA,IAAOA,iBAAP;;MACA,OAAOA,iBAAP;IACD;EAvBI,CAAP;AAyBD;;eAEcgB,W"}
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;;AAHA;AAEA;AAGA,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,WAAT,CAAqBC,IAArB,EAA2B;EACzB,OAAO,YAAY,IAAAC,iCAAA,EAAsBD,IAAtB,CAAnB;AACD;;AAED,SAASE,WAAT,CAAqBF,IAArB,EAA2B;EACzB,IAAIA,IAAI,KAAK,OAAb,EAAsBA,IAAI,GAAG,EAAP;EACtB,IAAIA,IAAI,KAAK,SAAb,EAAwBA,IAAI,GAAG,EAAP;EACxB,mBAAY,IAAAC,iCAAA,EAAsBD,IAAtB,CAAZ;AACD;;AAED,SAASG,YAAT,CAAsBC,SAAtB,EAAiC;EAC/B,OAAOA,SAAS,KAAKC,SAArB;AACD;;AAED,SAASC,gBAAT,CAA0BC,IAA1B,EAAgCC,QAAhC,EAA0CJ,SAA1C,EAAqDK,gBAArD,EAAuEC,WAAvE,EAAoFC,YAApF,EAAkG;EAChG,SAASC,QAAT,GAAoB;IAClB,OAAOT,YAAY,CAACC,SAAD,CAAZ,GACHA,SADG,GAEHI,QAAQ,IAAID,IAAI,CAACM,KAAjB,GACAN,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