@semcore/core 16.6.0-prerelease.1 → 16.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/core-types/Component.d.ts +33 -79
- package/lib/core-types/Component.js +14 -46
- package/lib/core-types/Component.js.map +1 -1
- package/lib/core-types/Component.mjs +11 -7
- package/lib/core-types/Component.mjs.map +1 -1
- package/lib/core-types/symbols.mjs +9 -9
- package/lib/coreFactory.d.ts +6 -23
- package/lib/coreFactory.js +53 -22
- package/lib/coreFactory.js.map +1 -1
- package/lib/coreFactory.mjs +54 -35
- package/lib/coreFactory.mjs.map +1 -1
- package/lib/decorators/propsObserver.d.ts +11 -0
- package/lib/decorators/propsObserver.js +77 -0
- package/lib/decorators/propsObserver.js.map +1 -0
- package/lib/decorators/propsObserver.mjs +70 -0
- package/lib/decorators/propsObserver.mjs.map +1 -0
- package/lib/decorators/reactive.d.ts +11 -0
- package/lib/decorators/reactive.js +51 -0
- package/lib/decorators/reactive.js.map +1 -0
- package/lib/decorators/reactive.mjs +45 -0
- package/lib/decorators/reactive.mjs.map +1 -0
- package/lib/enhancement/Children.mjs +1 -1
- package/lib/enhancement/staticChildren.mjs +3 -3
- package/lib/enhancement/style.mjs +2 -2
- package/lib/enhancement/uncontrolledProps.js +2 -1
- package/lib/enhancement/uncontrolledProps.js.map +1 -1
- package/lib/enhancement/uncontrolledProps.mjs +2 -1
- package/lib/enhancement/uncontrolledProps.mjs.map +1 -1
- package/lib/esm/core-types/Component.mjs +11 -7
- package/lib/esm/core-types/symbols.mjs +9 -9
- package/lib/esm/coreFactory.mjs +54 -35
- package/lib/esm/enhancement/Children.mjs +1 -1
- package/lib/esm/enhancement/staticChildren.mjs +3 -3
- package/lib/esm/enhancement/style.mjs +2 -2
- package/lib/esm/enhancement/uncontrolledProps.mjs +2 -1
- package/lib/esm/styled/sstyled.mjs +1 -1
- package/lib/esm/utils/enhances/WithI18n.mjs +1 -46
- package/lib/esm/utils/ref.mjs +0 -14
- package/lib/index.d.ts +3 -3
- package/lib/index.js.map +1 -1
- package/lib/index.mjs.map +1 -1
- package/lib/styled/index.d.ts +1 -5
- package/lib/styled/index.js.map +1 -1
- package/lib/styled/index.mjs.map +1 -1
- package/lib/styled/sstyled.mjs +1 -1
- package/lib/utils/enhances/WithCSS.d.ts +2 -30
- package/lib/utils/enhances/WithCSS.js +4 -57
- package/lib/utils/enhances/WithCSS.js.map +1 -1
- package/lib/utils/enhances/WithCSS.mjs +2 -53
- package/lib/utils/enhances/WithCSS.mjs.map +1 -1
- package/lib/utils/enhances/WithI18n.d.ts +1 -30
- package/lib/utils/enhances/WithI18n.js +1 -57
- package/lib/utils/enhances/WithI18n.js.map +1 -1
- package/lib/utils/enhances/WithI18n.mjs +1 -46
- package/lib/utils/enhances/WithI18n.mjs.map +1 -1
- package/lib/utils/enhances/animatedSizeEnhance.d.ts +0 -4
- package/lib/utils/enhances/animatedSizeEnhance.js +0 -2
- package/lib/utils/enhances/animatedSizeEnhance.js.map +1 -1
- package/lib/utils/enhances/animatedSizeEnhance.mjs +0 -3
- package/lib/utils/enhances/animatedSizeEnhance.mjs.map +1 -1
- package/lib/utils/enhances/i18nEnhance.d.ts +0 -4
- package/lib/utils/enhances/i18nEnhance.js +0 -2
- package/lib/utils/enhances/i18nEnhance.js.map +1 -1
- package/lib/utils/enhances/i18nEnhance.mjs.map +1 -1
- package/lib/utils/eventEmitter.d.ts +10 -6
- package/lib/utils/eventEmitter.js +55 -27
- package/lib/utils/eventEmitter.js.map +1 -1
- package/lib/utils/eventEmitter.mjs +55 -27
- package/lib/utils/eventEmitter.mjs.map +1 -1
- package/lib/utils/getDisplayName.mjs +3 -5
- package/lib/utils/indentStyles.d.ts +3 -0
- package/lib/utils/indentStyles.js +45 -0
- package/lib/utils/indentStyles.js.map +1 -0
- package/lib/utils/indentStyles.mjs +36 -0
- package/lib/utils/indentStyles.mjs.map +1 -0
- package/lib/utils/injectStyle.js +1 -1
- package/lib/utils/injectStyle.js.map +1 -1
- package/lib/utils/injectStyle.mjs +1 -1
- package/lib/utils/injectStyle.mjs.map +1 -1
- package/lib/utils/ref.d.ts +1 -3
- package/lib/utils/ref.js +0 -14
- package/lib/utils/ref.js.map +1 -1
- package/lib/utils/ref.mjs +0 -14
- package/lib/utils/ref.mjs.map +1 -1
- package/lib/utils/uniqueID.d.ts +0 -4
- package/lib/utils/uniqueID.js +1 -3
- package/lib/utils/uniqueID.js.map +1 -1
- package/lib/utils/uniqueID.mjs +1 -4
- package/lib/utils/uniqueID.mjs.map +1 -1
- package/lib/utils/use/useColorResolver.js +1 -1
- package/lib/utils/use/useColorResolver.js.map +1 -1
- package/lib/utils/use/useColorResolver.mjs +1 -1
- package/lib/utils/use/useColorResolver.mjs.map +1 -1
- package/lib/utils/use/useEnhancedEffect.d.ts +1 -1
- package/lib/utils/zIndexStacking.d.ts +3 -1
- package/lib/utils/zIndexStacking.js.map +1 -1
- package/lib/utils/zIndexStacking.mjs.map +1 -1
- package/package.json +2 -2
- package/lib/enhancement/bindHandler.d.ts +0 -5
- package/lib/enhancement/bindHandler.js +0 -53
- package/lib/enhancement/bindHandler.js.map +0 -1
- package/lib/enhancement/bindHandler.mjs +0 -48
- package/lib/enhancement/bindHandler.mjs.map +0 -1
- package/lib/enhancement/hoistProps.d.ts +0 -10
- package/lib/enhancement/hoistProps.js +0 -95
- package/lib/enhancement/hoistProps.js.map +0 -1
- package/lib/enhancement/hoistProps.mjs +0 -78
- package/lib/enhancement/hoistProps.mjs.map +0 -1
- package/lib/esm/enhancement/bindHandler.mjs +0 -48
- package/lib/esm/enhancement/hoistProps.mjs +0 -78
- package/lib/esm/utils/createHoc.mjs +0 -42
- package/lib/esm/utils/getDisplayName.mjs +0 -6
- package/lib/utils/ScreenReaderOnly.d.ts +0 -8
- package/lib/utils/ScreenReaderOnly.js +0 -30
- package/lib/utils/ScreenReaderOnly.js.map +0 -1
- package/lib/utils/ScreenReaderOnly.mjs +0 -24
- package/lib/utils/ScreenReaderOnly.mjs.map +0 -1
- package/lib/utils/createHoc.d.ts +0 -3
- package/lib/utils/createHoc.js +0 -52
- package/lib/utils/createHoc.js.map +0 -1
- package/lib/utils/createHoc.mjs +0 -42
- package/lib/utils/createHoc.mjs.map +0 -1
- package/lib/utils/enhances/WithAutoFocus.d.ts +0 -14
- package/lib/utils/enhances/WithAutoFocus.js +0 -72
- package/lib/utils/enhances/WithAutoFocus.js.map +0 -1
- package/lib/utils/enhances/WithAutoFocus.mjs +0 -66
- package/lib/utils/enhances/WithAutoFocus.mjs.map +0 -1
- package/lib/utils/enhances/WithKeyboardFocus.d.ts +0 -46
- package/lib/utils/enhances/WithKeyboardFocus.js +0 -94
- package/lib/utils/enhances/WithKeyboardFocus.js.map +0 -1
- package/lib/utils/enhances/WithKeyboardFocus.mjs +0 -88
- package/lib/utils/enhances/WithKeyboardFocus.mjs.map +0 -1
- package/lib/utils/enhances/WithRef.d.ts +0 -3
- package/lib/utils/enhances/WithRef.js +0 -25
- package/lib/utils/enhances/WithRef.js.map +0 -1
- package/lib/utils/enhances/WithRef.mjs +0 -18
- package/lib/utils/enhances/WithRef.mjs.map +0 -1
- package/lib/utils/enhances/autoFocusEnhance.d.ts +0 -10
- package/lib/utils/enhances/autoFocusEnhance.js +0 -45
- package/lib/utils/enhances/autoFocusEnhance.js.map +0 -1
- package/lib/utils/enhances/autoFocusEnhance.mjs +0 -38
- package/lib/utils/enhances/autoFocusEnhance.mjs.map +0 -1
- package/lib/utils/enhances/keyboardFocusEnhance.d.ts +0 -27
- package/lib/utils/enhances/keyboardFocusEnhance.js +0 -63
- package/lib/utils/enhances/keyboardFocusEnhance.js.map +0 -1
- package/lib/utils/enhances/keyboardFocusEnhance.mjs +0 -57
- package/lib/utils/enhances/keyboardFocusEnhance.mjs.map +0 -1
- package/lib/utils/if.d.ts +0 -11
- package/lib/utils/if.js +0 -15
- package/lib/utils/if.js.map +0 -1
- package/lib/utils/if.mjs +0 -9
- package/lib/utils/if.mjs.map +0 -1
- package/lib/utils/use/useCss.d.ts +0 -4
- package/lib/utils/use/useCss.js +0 -19
- package/lib/utils/use/useCss.js.map +0 -1
- package/lib/utils/use/useCss.mjs +0 -12
- package/lib/utils/use/useCss.mjs.map +0 -1
package/lib/esm/coreFactory.mjs
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
2
2
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
3
|
+
import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
|
|
4
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
5
|
import _superPropGet from "@babel/runtime/helpers/esm/superPropGet";
|
|
4
6
|
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
5
7
|
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
@@ -12,18 +14,16 @@ import hoistNonReactStatics from "hoist-non-react-statics";
|
|
|
12
14
|
import React from "react";
|
|
13
15
|
import { Component } from "./core-types/Component.mjs";
|
|
14
16
|
import { CORE_AS_PROPS, CORE_INSTANCE, CORE_INIT, CORE_COMPONENT, PARENT_COMPONENTS, CONTEXT_COMPONENT, CREATE_COMPONENT } from "./core-types/symbols.mjs";
|
|
15
|
-
import Enhancement from "./enhancement/
|
|
16
|
-
import Enhancement$
|
|
17
|
-
import Enhancement$7 from "./enhancement/
|
|
18
|
-
import Enhancement$
|
|
19
|
-
import Enhancement$5 from "./enhancement/functionDefaultProps.mjs";
|
|
20
|
-
import Enhancement$a from "./enhancement/hoistProps.mjs";
|
|
17
|
+
import Enhancement from "./enhancement/Children.mjs";
|
|
18
|
+
import Enhancement$6 from "./enhancement/dataName.mjs";
|
|
19
|
+
import Enhancement$7 from "./enhancement/enhance.mjs";
|
|
20
|
+
import Enhancement$4 from "./enhancement/functionDefaultProps.mjs";
|
|
21
21
|
import i18nAppLocaleEnhance from "./enhancement/i18n.mjs";
|
|
22
|
-
import Enhancement$
|
|
23
|
-
import Enhancement$
|
|
24
|
-
import Enhancement$
|
|
25
|
-
import Enhancement$
|
|
26
|
-
import Enhancement$
|
|
22
|
+
import Enhancement$5 from "./enhancement/inheritedName.mjs";
|
|
23
|
+
import Enhancement$1 from "./enhancement/Root.mjs";
|
|
24
|
+
import Enhancement$3, { ROOT_COMPONENT, getterMethodNameByDisplayName, STATIC_COMPONENT } from "./enhancement/staticChildren.mjs";
|
|
25
|
+
import Enhancement$8 from "./enhancement/style.mjs";
|
|
26
|
+
import Enhancement$2 from "./enhancement/uncontrolledProps.mjs";
|
|
27
27
|
import assignProps$1 from "./utils/assignProps.mjs";
|
|
28
28
|
import { useForkRef } from "./utils/ref.mjs";
|
|
29
29
|
import useEnhancedEffect from "./utils/use/useEnhancedEffect.mjs";
|
|
@@ -134,6 +134,32 @@ function wrapClass(OriginComponent, enhancements, Context) {
|
|
|
134
134
|
this[CORE_AS_PROPS] = props.reduce(function(acc, enhancement) {
|
|
135
135
|
return enhancement.call(_this4, acc, WrapperComponent, false);
|
|
136
136
|
}, this.props);
|
|
137
|
+
if (this[CORE_AS_PROPS] !== null) {
|
|
138
|
+
var prefixesMap = /* @__PURE__ */ new Map();
|
|
139
|
+
Object.entries(this[CORE_AS_PROPS]).forEach(function(_ref3) {
|
|
140
|
+
var _ref4 = _slicedToArray(_ref3, 2), key2 = _ref4[0], value2 = _ref4[1];
|
|
141
|
+
var _key$split = key2.split(":"), _key$split2 = _slicedToArray(_key$split, 2), prefix = _key$split2[0], propertyKey = _key$split2[1];
|
|
142
|
+
if (prefix !== "use" && propertyKey) {
|
|
143
|
+
var _prefixesMap$get;
|
|
144
|
+
var obj = (_prefixesMap$get = prefixesMap.get(prefix)) !== null && _prefixesMap$get !== void 0 ? _prefixesMap$get : {};
|
|
145
|
+
obj[propertyKey] = value2;
|
|
146
|
+
prefixesMap.set(prefix, obj);
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
var _iterator = _createForOfIteratorHelper(prefixesMap.entries()), _step;
|
|
150
|
+
try {
|
|
151
|
+
for (_iterator.s(); !(_step = _iterator.n()).done; ) {
|
|
152
|
+
var _step$value = _slicedToArray(_step.value, 2), key = _step$value[0], value = _step$value[1];
|
|
153
|
+
Object.defineProperty(this[CORE_AS_PROPS], "".concat(key, "Props"), {
|
|
154
|
+
value
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
} catch (err) {
|
|
158
|
+
_iterator.e(err);
|
|
159
|
+
} finally {
|
|
160
|
+
_iterator.f();
|
|
161
|
+
}
|
|
162
|
+
}
|
|
137
163
|
}
|
|
138
164
|
return this[CORE_AS_PROPS];
|
|
139
165
|
}
|
|
@@ -213,8 +239,8 @@ function wrapFunction(OriginComponent, enhancements, Context) {
|
|
|
213
239
|
return WrapperComponent;
|
|
214
240
|
}
|
|
215
241
|
function wrapCore(OriginComponent, enhancements, Context) {
|
|
216
|
-
var Component2 = function Component3(
|
|
217
|
-
var Root =
|
|
242
|
+
var Component2 = function Component3(_ref5) {
|
|
243
|
+
var Root = _ref5.Root;
|
|
218
244
|
var defaultProps = OriginComponent.defaultProps || {};
|
|
219
245
|
return /* @__PURE__ */ React.createElement(Root, _extends({}, defaultProps, {
|
|
220
246
|
render: OriginComponent
|
|
@@ -264,27 +290,24 @@ function createComponent(OriginComponent) {
|
|
|
264
290
|
return f(context, parents, createComponent, childComponents);
|
|
265
291
|
})), [
|
|
266
292
|
i18nAppLocaleEnhance(),
|
|
267
|
-
Enhancement(),
|
|
268
|
-
Enhancement$1(context, parents),
|
|
293
|
+
Enhancement(context, parents),
|
|
269
294
|
// root must be under the children
|
|
295
|
+
Enhancement$1(),
|
|
270
296
|
Enhancement$2(),
|
|
271
|
-
Enhancement$3(
|
|
272
|
-
Enhancement$4(childComponents, createComponent, {
|
|
297
|
+
Enhancement$3(childComponents, createComponent, {
|
|
273
298
|
context,
|
|
274
299
|
parent,
|
|
275
300
|
enhancements
|
|
276
301
|
}),
|
|
277
302
|
// functionDefaultProps must be under the staticChild
|
|
278
|
-
Enhancement$
|
|
303
|
+
Enhancement$4(),
|
|
279
304
|
// inheritedName must be under the staticChild
|
|
280
|
-
Enhancement$
|
|
305
|
+
Enhancement$5(),
|
|
281
306
|
// dataName must be under the staticChild
|
|
282
|
-
Enhancement$
|
|
307
|
+
Enhancement$6(),
|
|
283
308
|
// enhanceEnhancement must be under the functionDefaultPropsEnhancement
|
|
284
|
-
Enhancement$
|
|
285
|
-
Enhancement$
|
|
286
|
-
// must be the last one so any properties can be raised
|
|
287
|
-
Enhancement$a(childComponents, context)
|
|
309
|
+
Enhancement$7(),
|
|
310
|
+
Enhancement$8(childComponents, context)
|
|
288
311
|
]));
|
|
289
312
|
Component2[CONTEXT_COMPONENT] = context;
|
|
290
313
|
Component2._______childrenComponents = childComponents;
|
|
@@ -304,17 +327,13 @@ function createComponent(OriginComponent) {
|
|
|
304
327
|
return Component2;
|
|
305
328
|
}
|
|
306
329
|
function createBaseComponent(OriginComponent) {
|
|
307
|
-
var
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
Component2[CORE_COMPONENT] = true;
|
|
315
|
-
} else {
|
|
316
|
-
throw new Error("createBaseComponent accepts only functional component");
|
|
317
|
-
}
|
|
330
|
+
var _OriginComponent$disp;
|
|
331
|
+
var Component2 = /* @__PURE__ */ React.forwardRef(OriginComponent);
|
|
332
|
+
Component2.displayName = (_OriginComponent$disp = OriginComponent.displayName) !== null && _OriginComponent$disp !== void 0 ? _OriginComponent$disp : "";
|
|
333
|
+
Component2.defaultProps = {
|
|
334
|
+
"data-ui-name": OriginComponent.displayName
|
|
335
|
+
};
|
|
336
|
+
Component2[CORE_COMPONENT] = true;
|
|
318
337
|
return Component2;
|
|
319
338
|
}
|
|
320
339
|
export {
|
|
@@ -5,7 +5,7 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
|
5
5
|
import React from "react";
|
|
6
6
|
import { CHILDREN_COMPONENT, CONTEXT_COMPONENT } from "../core-types/symbols.mjs";
|
|
7
7
|
var _excluded = ["handlers", "getters"], _excluded2 = ["handlers"];
|
|
8
|
-
var CHILDREN_SELF = Symbol("CHILDREN_SELF");
|
|
8
|
+
var CHILDREN_SELF = /* @__PURE__ */ Symbol("CHILDREN_SELF");
|
|
9
9
|
var GETTER_REG = /^get[\w]+Props$/;
|
|
10
10
|
function splitPropsAndGetters(props) {
|
|
11
11
|
return Object.entries(props).reduce(function(acc, _ref) {
|
|
@@ -31,9 +31,9 @@ function flatGetterMethodNames(childComponents, parentName) {
|
|
|
31
31
|
return acc;
|
|
32
32
|
}, []);
|
|
33
33
|
}
|
|
34
|
-
var STATIC_COMPONENT = Symbol("STATIC_COMPONENT");
|
|
35
|
-
var ROOT_COMPONENT = Symbol("ROOT_COMPONENT");
|
|
36
|
-
var SELF_GETTER_METHOD = Symbol("SELF_GETTER_METHOD");
|
|
34
|
+
var STATIC_COMPONENT = /* @__PURE__ */ Symbol("STATIC_COMPONENT");
|
|
35
|
+
var ROOT_COMPONENT = /* @__PURE__ */ Symbol("ROOT_COMPONENT");
|
|
36
|
+
var SELF_GETTER_METHOD = /* @__PURE__ */ Symbol("SELF_GETTER_METHOD");
|
|
37
37
|
function Enhancement(childComponents, createComponent, options) {
|
|
38
38
|
var getterMethodNames = flatGetterMethodNames(childComponents);
|
|
39
39
|
return {
|
|
@@ -6,8 +6,8 @@ import { STATIC_COMPONENT } from "./staticChildren.mjs";
|
|
|
6
6
|
import "../styled/index.mjs";
|
|
7
7
|
import { sstyled } from "../styled/sstyled.mjs";
|
|
8
8
|
var _excluded = ["_styles", "styles"], _excluded2 = ["styles"];
|
|
9
|
-
var STYLES_CONTEXT = Symbol("STYLES_CONTEXT");
|
|
10
|
-
var STYLES_SELF = Symbol("STYLES_SELF");
|
|
9
|
+
var STYLES_CONTEXT = /* @__PURE__ */ Symbol("STYLES_CONTEXT");
|
|
10
|
+
var STYLES_SELF = /* @__PURE__ */ Symbol("STYLES_SELF");
|
|
11
11
|
function Enhancement(childComponents, Context) {
|
|
12
12
|
return {
|
|
13
13
|
condition: function condition(Component) {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
2
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
|
+
import _arrayLikeToArray from "@babel/runtime/helpers/esm/arrayLikeToArray";
|
|
3
4
|
import _toArray from "@babel/runtime/helpers/esm/toArray";
|
|
4
5
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
5
6
|
import _toPropertyKey from "@babel/runtime/helpers/esm/toPropertyKey";
|
|
@@ -53,7 +54,7 @@ function uncontrolledUniversal(props, config, uncontrolledProp2) {
|
|
|
53
54
|
var _setter = setter;
|
|
54
55
|
var _setter2 = _toArray(_setter);
|
|
55
56
|
setter = _setter2[0];
|
|
56
|
-
chainHandler = _setter2.slice(1);
|
|
57
|
+
chainHandler = _arrayLikeToArray(_setter2).slice(1);
|
|
57
58
|
}
|
|
58
59
|
setter = setter || function(v) {
|
|
59
60
|
return v;
|
|
@@ -119,7 +119,7 @@ sstyled.css = function(_css) {
|
|
|
119
119
|
sstyled.insert = insert;
|
|
120
120
|
sstyled.merge = merge;
|
|
121
121
|
sstyled.getStyles = getStyles;
|
|
122
|
-
sstyled.SHADOW_STYLES = Symbol("SHADOW_STYLES");
|
|
122
|
+
sstyled.SHADOW_STYLES = /* @__PURE__ */ Symbol("SHADOW_STYLES");
|
|
123
123
|
export {
|
|
124
124
|
sstyled
|
|
125
125
|
};
|
|
@@ -1,52 +1,9 @@
|
|
|
1
|
-
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
2
|
-
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
|
-
import _callSuper from "@babel/runtime/helpers/esm/callSuper";
|
|
4
|
-
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
5
|
-
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
6
1
|
import { createIntlCache, createIntl } from "@formatjs/intl";
|
|
7
|
-
import React, { createContext
|
|
8
|
-
import createHoc from "../createHoc.mjs";
|
|
2
|
+
import React, { createContext } from "react";
|
|
9
3
|
import { useAsyncI18nMessages } from "./i18nEnhance.mjs";
|
|
10
4
|
var Context = /* @__PURE__ */ createContext(void 0);
|
|
11
5
|
var I18nProvider = Context.Provider, I18nConsumer = Context.Consumer;
|
|
12
6
|
var messagesCache = createIntlCache();
|
|
13
|
-
function getText(dictionaries, locale) {
|
|
14
|
-
return function(key) {
|
|
15
|
-
var dictionary = dictionaries[locale];
|
|
16
|
-
return dictionary ? dictionary[key] : dictionaries["en"][key];
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
var WithI18n = /* @__PURE__ */ (function(_Component) {
|
|
20
|
-
function WithI18n2() {
|
|
21
|
-
var _this;
|
|
22
|
-
_classCallCheck(this, WithI18n2);
|
|
23
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
24
|
-
args[_key] = arguments[_key];
|
|
25
|
-
}
|
|
26
|
-
_this = _callSuper(this, WithI18n2, [].concat(args));
|
|
27
|
-
_defineProperty(_this, "context", void 0);
|
|
28
|
-
_defineProperty(_this, "getText", function(dictionary, selfLocale) {
|
|
29
|
-
var _this$props = _this.props, locale = _this$props.locale, getText2 = _this$props.getText;
|
|
30
|
-
var contextLocale = _this.context;
|
|
31
|
-
return getText2(dictionary, selfLocale || locale || contextLocale);
|
|
32
|
-
});
|
|
33
|
-
return _this;
|
|
34
|
-
}
|
|
35
|
-
_inherits(WithI18n2, _Component);
|
|
36
|
-
return _createClass(WithI18n2, [{
|
|
37
|
-
key: "render",
|
|
38
|
-
value: function render() {
|
|
39
|
-
var _ref = this.props, children = _ref.children;
|
|
40
|
-
return children({
|
|
41
|
-
getText: this.getText
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
}]);
|
|
45
|
-
})(Component);
|
|
46
|
-
_defineProperty(WithI18n, "contextType", Context);
|
|
47
|
-
_defineProperty(WithI18n, "defaultProps", {
|
|
48
|
-
getText
|
|
49
|
-
});
|
|
50
7
|
var useI18n = function useI18n2(dictionary) {
|
|
51
8
|
var _React$useContext;
|
|
52
9
|
var locale = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "en";
|
|
@@ -65,11 +22,9 @@ var useI18n = function useI18n2(dictionary) {
|
|
|
65
22
|
}, variables);
|
|
66
23
|
}, [intl]);
|
|
67
24
|
};
|
|
68
|
-
const WithI18n$1 = createHoc(WithI18n);
|
|
69
25
|
export {
|
|
70
26
|
Context,
|
|
71
27
|
I18nConsumer,
|
|
72
28
|
I18nProvider,
|
|
73
|
-
WithI18n$1 as default,
|
|
74
29
|
useI18n
|
|
75
30
|
};
|
package/lib/esm/utils/ref.mjs
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
2
2
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
3
|
import React from "react";
|
|
4
|
-
import { findDOMNode } from "react-dom";
|
|
5
4
|
function setRef(ref, value) {
|
|
6
5
|
if (typeof ref === "function") {
|
|
7
6
|
ref(value);
|
|
@@ -65,21 +64,8 @@ function forkRef() {
|
|
|
65
64
|
});
|
|
66
65
|
};
|
|
67
66
|
}
|
|
68
|
-
function getNodeByRef(ref) {
|
|
69
|
-
if (typeof ref === "function") {
|
|
70
|
-
ref = ref();
|
|
71
|
-
}
|
|
72
|
-
if (!ref) return null;
|
|
73
|
-
var node = getRef(ref);
|
|
74
|
-
if (!node) return null;
|
|
75
|
-
if ("nodeType" in node && node.nodeType === 1) return node;
|
|
76
|
-
if (Object.keys(node).length === 1 && "getBoundingClientRect" in node) return null;
|
|
77
|
-
if (!/* @__PURE__ */ React.isValidElement(node) && !(node instanceof React.Component)) return null;
|
|
78
|
-
return findDOMNode(node);
|
|
79
|
-
}
|
|
80
67
|
export {
|
|
81
68
|
forkRef,
|
|
82
|
-
getNodeByRef,
|
|
83
69
|
getRef,
|
|
84
70
|
setRef,
|
|
85
71
|
useCallbackRef,
|
package/lib/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/** ============================== core ============================== */
|
|
2
2
|
import { Root, Component, Intergalactic, wrapIntergalacticComponent } from './core-types/Component';
|
|
3
|
-
import type { PropGetterFn, IRootComponentProps,
|
|
3
|
+
import type { PropGetterFn, IRootComponentProps, IRootNodeProps } from './core-types/Component';
|
|
4
4
|
import { CORE_INSTANCE, CREATE_COMPONENT, CONTEXT_COMPONENT, CHILDREN_COMPONENT, INHERITED_NAME } from './core-types/symbols';
|
|
5
5
|
import type { UnknownProperties } from './core-types/UnknownProperties';
|
|
6
6
|
import { createComponent, createBaseComponent, assignProps } from './coreFactory';
|
|
7
7
|
import { lastInteraction } from './LastInteractionType';
|
|
8
8
|
import register from './register';
|
|
9
|
-
import type {
|
|
9
|
+
import type { IStyledProps } from './styled';
|
|
10
10
|
import { sstyled } from './styled';
|
|
11
|
-
export { sstyled, createComponent, createBaseComponent, Root, Component, type UnknownProperties, Intergalactic, type PropGetterFn, type IRootComponentProps, type
|
|
11
|
+
export { sstyled, createComponent, createBaseComponent, Root, Component, type UnknownProperties, Intergalactic, type PropGetterFn, type IRootComponentProps, type IRootNodeProps, CORE_INSTANCE, CREATE_COMPONENT, CONTEXT_COMPONENT, CHILDREN_COMPONENT, INHERITED_NAME, type IStyledProps, wrapIntergalacticComponent, assignProps, register, lastInteraction, };
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_Component","require","_symbols","_coreFactory","_LastInteractionType","_register","_interopRequireDefault","_styled"],"sources":["../src/index.ts"],"sourcesContent":["/** ============================== core ============================== */\nimport { Root, Component, Intergalactic, wrapIntergalacticComponent } from './core-types/Component';\nimport type {\n PropGetterFn,\n IRootComponentProps,\n
|
|
1
|
+
{"version":3,"file":"index.js","names":["_Component","require","_symbols","_coreFactory","_LastInteractionType","_register","_interopRequireDefault","_styled"],"sources":["../src/index.ts"],"sourcesContent":["/** ============================== core ============================== */\nimport { Root, Component, Intergalactic, wrapIntergalacticComponent } from './core-types/Component';\nimport type {\n PropGetterFn,\n IRootComponentProps,\n IRootNodeProps,\n} from './core-types/Component';\nimport {\n CORE_INSTANCE,\n CREATE_COMPONENT,\n CONTEXT_COMPONENT,\n CHILDREN_COMPONENT,\n INHERITED_NAME,\n} from './core-types/symbols';\nimport type { UnknownProperties } from './core-types/UnknownProperties';\nimport { createComponent, createBaseComponent, assignProps } from './coreFactory';\nimport { lastInteraction } from './LastInteractionType';\nimport register from './register';\nimport type { IStyledProps } from './styled';\nimport { sstyled } from './styled';\n\nexport {\n sstyled,\n createComponent,\n createBaseComponent,\n Root,\n Component,\n type UnknownProperties,\n Intergalactic,\n type PropGetterFn,\n type IRootComponentProps,\n type IRootNodeProps,\n CORE_INSTANCE,\n CREATE_COMPONENT,\n CONTEXT_COMPONENT,\n CHILDREN_COMPONENT,\n INHERITED_NAME,\n type IStyledProps,\n wrapIntergalacticComponent,\n assignProps,\n register,\n lastInteraction,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,IAAAA,UAAA,GAAAC,OAAA;AAMA,IAAAC,QAAA,GAAAD,OAAA;AAQA,IAAAE,YAAA,GAAAF,OAAA;AACA,IAAAG,oBAAA,GAAAH,OAAA;AACA,IAAAI,SAAA,GAAAC,sBAAA,CAAAL,OAAA;AAEA,IAAAM,OAAA,GAAAN,OAAA","ignoreList":[]}
|
package/lib/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["Root","Component","Intergalactic","wrapIntergalacticComponent","CORE_INSTANCE","CREATE_COMPONENT","CONTEXT_COMPONENT","CHILDREN_COMPONENT","INHERITED_NAME","createComponent","createBaseComponent","assignProps","lastInteraction","register","sstyled"],"sources":["../src/index.ts"],"sourcesContent":["/** ============================== core ============================== */\nimport { Root, Component, Intergalactic, wrapIntergalacticComponent } from './core-types/Component';\nimport type {\n PropGetterFn,\n IRootComponentProps,\n
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["Root","Component","Intergalactic","wrapIntergalacticComponent","CORE_INSTANCE","CREATE_COMPONENT","CONTEXT_COMPONENT","CHILDREN_COMPONENT","INHERITED_NAME","createComponent","createBaseComponent","assignProps","lastInteraction","register","sstyled"],"sources":["../src/index.ts"],"sourcesContent":["/** ============================== core ============================== */\nimport { Root, Component, Intergalactic, wrapIntergalacticComponent } from './core-types/Component';\nimport type {\n PropGetterFn,\n IRootComponentProps,\n IRootNodeProps,\n} from './core-types/Component';\nimport {\n CORE_INSTANCE,\n CREATE_COMPONENT,\n CONTEXT_COMPONENT,\n CHILDREN_COMPONENT,\n INHERITED_NAME,\n} from './core-types/symbols';\nimport type { UnknownProperties } from './core-types/UnknownProperties';\nimport { createComponent, createBaseComponent, assignProps } from './coreFactory';\nimport { lastInteraction } from './LastInteractionType';\nimport register from './register';\nimport type { IStyledProps } from './styled';\nimport { sstyled } from './styled';\n\nexport {\n sstyled,\n createComponent,\n createBaseComponent,\n Root,\n Component,\n type UnknownProperties,\n Intergalactic,\n type PropGetterFn,\n type IRootComponentProps,\n type IRootNodeProps,\n CORE_INSTANCE,\n CREATE_COMPONENT,\n CONTEXT_COMPONENT,\n CHILDREN_COMPONENT,\n INHERITED_NAME,\n type IStyledProps,\n wrapIntergalacticComponent,\n assignProps,\n register,\n lastInteraction,\n};\n"],"mappings":"AAAA;AACA,SAASA,IAAI,EAAEC,SAAS,EAAEC,aAAa,EAAEC,0BAA0B,QAAQ,4BAAwB;AAMnG,SACEC,aAAa,EACbC,gBAAgB,EAChBC,iBAAiB,EACjBC,kBAAkB,EAClBC,cAAc,QACT,0BAAsB;AAE7B,SAASC,eAAe,EAAEC,mBAAmB,EAAEC,WAAW,QAAQ,mBAAe;AACjF,SAASC,eAAe,QAAQ,2BAAuB;AACvD,OAAOC,QAAQ,MAAM,gBAAY;AAEjC,SAASC,OAAO,QAAQ,cAAU;AAElC,SACEA,OAAO,EACPL,eAAe,EACfC,mBAAmB,EACnBV,IAAI,EACJC,SAAS,EAETC,aAAa,EAIbE,aAAa,EACbC,gBAAgB,EAChBC,iBAAiB,EACjBC,kBAAkB,EAClBC,cAAc,EAEdL,0BAA0B,EAC1BQ,WAAW,EACXE,QAAQ,EACRD,eAAe","ignoreList":[]}
|
package/lib/styled/index.d.ts
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
export type StyledProps = {
|
|
1
|
+
export interface IStyledProps {
|
|
3
2
|
styles?: React.DetailedHTMLProps<React.StyleHTMLAttributes<HTMLStyleElement>, HTMLStyleElement>;
|
|
4
|
-
};
|
|
5
|
-
/** @deprecated */
|
|
6
|
-
export interface IStyledProps extends StyledProps, UnknownProperties {
|
|
7
3
|
}
|
|
8
4
|
/** @ts-ignore */
|
|
9
5
|
export { styled, use, css } from './reshadow-core';
|
package/lib/styled/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_reshadowCore","require","_sstyled"],"sources":["../../src/styled/index.tsx"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"index.js","names":["_reshadowCore","require","_sstyled"],"sources":["../../src/styled/index.tsx"],"sourcesContent":["export interface IStyledProps {\n styles?: React.DetailedHTMLProps<React.StyleHTMLAttributes<HTMLStyleElement>, HTMLStyleElement>;\n}\n\n/** @ts-ignore */\nexport { styled, use, css } from './reshadow-core';\n\nexport { sstyled } from './sstyled';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,IAAAA,aAAA,GAAAC,OAAA;AAEA,IAAAC,QAAA,GAAAD,OAAA","ignoreList":[]}
|
package/lib/styled/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["styled","use","css","sstyled"],"sources":["../../src/styled/index.tsx"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["styled","use","css","sstyled"],"sources":["../../src/styled/index.tsx"],"sourcesContent":["export interface IStyledProps {\n styles?: React.DetailedHTMLProps<React.StyleHTMLAttributes<HTMLStyleElement>, HTMLStyleElement>;\n}\n\n/** @ts-ignore */\nexport { styled, use, css } from './reshadow-core';\n\nexport { sstyled } from './sstyled';\n"],"mappings":"AAIA;AACA,SAASA,MAAM,EAAEC,GAAG,EAAEC,GAAG,QAAQ,qBAAiB;AAElD,SAASC,OAAO,QAAQ,eAAW","ignoreList":[]}
|
package/lib/styled/sstyled.mjs
CHANGED
|
@@ -119,7 +119,7 @@ sstyled.css = function(_css) {
|
|
|
119
119
|
sstyled.insert = insert;
|
|
120
120
|
sstyled.merge = merge;
|
|
121
121
|
sstyled.getStyles = getStyles;
|
|
122
|
-
sstyled.SHADOW_STYLES = Symbol("SHADOW_STYLES");
|
|
122
|
+
sstyled.SHADOW_STYLES = /* @__PURE__ */ Symbol("SHADOW_STYLES");
|
|
123
123
|
export {
|
|
124
124
|
sstyled
|
|
125
125
|
};
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import type { NanoOptions } from '@phytonmk/nano-css';
|
|
2
2
|
import type { CssLikeObject } from '@phytonmk/nano-css/types/common';
|
|
3
|
-
import React
|
|
4
|
-
import type { UnknownProperties } from '../../core-types/UnknownProperties';
|
|
5
|
-
declare const getStylesheet: () => string;
|
|
3
|
+
import React from 'react';
|
|
6
4
|
/**
|
|
7
5
|
* Function to clear the nano CSS styles object from keys with undefined value
|
|
8
6
|
* @param {Object} obj - nano CSS styles object
|
|
@@ -12,30 +10,4 @@ declare function normaliseCss(obj: CssLikeObject): any;
|
|
|
12
10
|
declare const WithCssContext: React.Context<NanoOptions>;
|
|
13
11
|
declare const Provider: React.Provider<NanoOptions>;
|
|
14
12
|
declare function initNanoCss(options?: NanoOptions): import("@phytonmk/nano-css").NanoRenderer;
|
|
15
|
-
|
|
16
|
-
export interface IEnhancedWithCSSProps extends EnhancedWithCSSProps, UnknownProperties {
|
|
17
|
-
}
|
|
18
|
-
export type EnhancedWithCSSProps = {
|
|
19
|
-
className?: string;
|
|
20
|
-
css?: {};
|
|
21
|
-
children(props: {
|
|
22
|
-
className: string | undefined;
|
|
23
|
-
}): React.ReactNode;
|
|
24
|
-
};
|
|
25
|
-
declare class EnhancedWithCSS extends PureComponent<IEnhancedWithCSSProps> {
|
|
26
|
-
static contextType: React.Context<NanoOptions>;
|
|
27
|
-
static defaultProps: {
|
|
28
|
-
css: {};
|
|
29
|
-
};
|
|
30
|
-
state: {
|
|
31
|
-
dynamicClassName: string;
|
|
32
|
-
};
|
|
33
|
-
static getDerivedStateFromProps(props: any): {
|
|
34
|
-
dynamicClassName: string | undefined;
|
|
35
|
-
};
|
|
36
|
-
constructor(props: any, context: any);
|
|
37
|
-
render(): React.ReactNode;
|
|
38
|
-
}
|
|
39
|
-
export { getStylesheet, EnhancedWithCSS, Provider, WithCssContext, initNanoCss, normaliseCss };
|
|
40
|
-
declare const _default: (options?: {}) => (WrappedComponent: React.ComponentType) => React.ComponentClass;
|
|
41
|
-
export default _default;
|
|
13
|
+
export { Provider, WithCssContext, initNanoCss, normaliseCss };
|
|
@@ -1,25 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard")["default"];
|
|
4
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
|
-
exports.
|
|
7
|
+
exports.WithCssContext = exports.Provider = void 0;
|
|
9
8
|
exports.initNanoCss = initNanoCss;
|
|
10
9
|
exports.normaliseCss = normaliseCss;
|
|
11
|
-
var
|
|
12
|
-
var
|
|
13
|
-
var _callSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/callSuper"));
|
|
14
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
15
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
16
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
17
|
-
var _createHoc = _interopRequireDefault(require("../createHoc"));
|
|
18
|
-
var _CSSinJS2 = _interopRequireDefault(require("../CSSinJS"));
|
|
19
|
-
var getStylesheet = exports.getStylesheet = function getStylesheet() {
|
|
20
|
-
return (0, _CSSinJS2["default"])().raw;
|
|
21
|
-
};
|
|
22
|
-
|
|
10
|
+
var _react = _interopRequireDefault(require("react"));
|
|
11
|
+
var _CSSinJS = _interopRequireDefault(require("../CSSinJS"));
|
|
23
12
|
/**
|
|
24
13
|
* Function to clear the nano CSS styles object from keys with undefined value
|
|
25
14
|
* @param {Object} obj - nano CSS styles object
|
|
@@ -38,48 +27,6 @@ var WithCssContext = exports.WithCssContext = /*#__PURE__*/_react["default"].cre
|
|
|
38
27
|
var Provider = exports.Provider = WithCssContext.Provider;
|
|
39
28
|
function initNanoCss() {
|
|
40
29
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
41
|
-
return (0,
|
|
30
|
+
return (0, _CSSinJS["default"])(options);
|
|
42
31
|
}
|
|
43
|
-
|
|
44
|
-
/** @deprecated */
|
|
45
|
-
var EnhancedWithCSS = exports.EnhancedWithCSS = /*#__PURE__*/function (_PureComponent) {
|
|
46
|
-
function EnhancedWithCSS(props, context) {
|
|
47
|
-
var _this;
|
|
48
|
-
(0, _classCallCheck2["default"])(this, EnhancedWithCSS);
|
|
49
|
-
_this = (0, _callSuper2["default"])(this, EnhancedWithCSS, [props, context]);
|
|
50
|
-
(0, _defineProperty2["default"])(_this, "state", {
|
|
51
|
-
dynamicClassName: ''
|
|
52
|
-
});
|
|
53
|
-
initNanoCss(context);
|
|
54
|
-
return _this;
|
|
55
|
-
}
|
|
56
|
-
(0, _inherits2["default"])(EnhancedWithCSS, _PureComponent);
|
|
57
|
-
return (0, _createClass2["default"])(EnhancedWithCSS, [{
|
|
58
|
-
key: "render",
|
|
59
|
-
value: function render() {
|
|
60
|
-
var _this$props = this.props,
|
|
61
|
-
children = _this$props.children,
|
|
62
|
-
_this$props$className = _this$props.className,
|
|
63
|
-
className = _this$props$className === void 0 ? '' : _this$props$className;
|
|
64
|
-
var dynamicClassName = this.state.dynamicClassName;
|
|
65
|
-
return children({
|
|
66
|
-
className: className + dynamicClassName || undefined
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
}], [{
|
|
70
|
-
key: "getDerivedStateFromProps",
|
|
71
|
-
value: function getDerivedStateFromProps(props) {
|
|
72
|
-
var _CSSinJS$cache, _CSSinJS;
|
|
73
|
-
var cleanCss = normaliseCss(props.css);
|
|
74
|
-
return {
|
|
75
|
-
dynamicClassName: Object.keys(cleanCss).length ? (_CSSinJS$cache = (_CSSinJS = (0, _CSSinJS2["default"])()).cache) === null || _CSSinJS$cache === void 0 ? void 0 : _CSSinJS$cache.call(_CSSinJS, cleanCss) : ''
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
}]);
|
|
79
|
-
}(_react.PureComponent);
|
|
80
|
-
(0, _defineProperty2["default"])(EnhancedWithCSS, "contextType", WithCssContext);
|
|
81
|
-
(0, _defineProperty2["default"])(EnhancedWithCSS, "defaultProps", {
|
|
82
|
-
css: {}
|
|
83
|
-
});
|
|
84
|
-
var _default = exports["default"] = (0, _createHoc["default"])(EnhancedWithCSS);
|
|
85
32
|
//# sourceMappingURL=WithCSS.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WithCSS.js","names":["_react","
|
|
1
|
+
{"version":3,"file":"WithCSS.js","names":["_react","_interopRequireDefault","require","_CSSinJS","normaliseCss","obj","Object","keys","reduce","acc","key","result","undefined","WithCssContext","exports","React","createContext","Provider","initNanoCss","options","arguments","length","CSSinJS"],"sources":["../../../src/utils/enhances/WithCSS.tsx"],"sourcesContent":["import type { NanoOptions } from '@phytonmk/nano-css';\nimport type { CssLikeObject } from '@phytonmk/nano-css/types/common';\nimport React from 'react';\n\nimport CSSinJS from '../CSSinJS';\n\n/**\n * Function to clear the nano CSS styles object from keys with undefined value\n * @param {Object} obj - nano CSS styles object\n * @returns {Object}\n */\nfunction normaliseCss(obj: CssLikeObject) {\n return Object.keys(obj).reduce((acc: any, key) => {\n const result = acc;\n if (obj[key] !== undefined) {\n result[key] = obj[key];\n }\n return result;\n }, {});\n}\n\nconst WithCssContext = React.createContext<NanoOptions>({});\nconst { Provider } = WithCssContext;\n\nfunction initNanoCss(options: NanoOptions = {}) {\n return CSSinJS(options);\n}\n\nexport { Provider, WithCssContext, initNanoCss, normaliseCss };\n"],"mappings":";;;;;;;;;AAEA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,QAAA,GAAAF,sBAAA,CAAAC,OAAA;AAEA;AACA;AACA;AACA;AACA;AACA,SAASE,YAAYA,CAACC,GAAkB,EAAE;EACxC,OAAOC,MAAM,CAACC,IAAI,CAACF,GAAG,CAAC,CAACG,MAAM,CAAC,UAACC,GAAQ,EAAEC,GAAG,EAAK;IAChD,IAAMC,MAAM,GAAGF,GAAG;IAClB,IAAIJ,GAAG,CAACK,GAAG,CAAC,KAAKE,SAAS,EAAE;MAC1BD,MAAM,CAACD,GAAG,CAAC,GAAGL,GAAG,CAACK,GAAG,CAAC;IACxB;IACA,OAAOC,MAAM;EACf,CAAC,EAAE,CAAC,CAAC,CAAC;AACR;AAEA,IAAME,cAAc,GAAAC,OAAA,CAAAD,cAAA,gBAAGE,iBAAK,CAACC,aAAa,CAAc,CAAC,CAAC,CAAC;AAC3D,IAAQC,QAAQ,GAAAH,OAAA,CAAAG,QAAA,GAAKJ,cAAc,CAA3BI,QAAQ;AAEhB,SAASC,WAAWA,CAAA,EAA4B;EAAA,IAA3BC,OAAoB,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAR,SAAA,GAAAQ,SAAA,MAAG,CAAC,CAAC;EAC5C,OAAO,IAAAE,mBAAO,EAACH,OAAO,CAAC;AACzB","ignoreList":[]}
|
|
@@ -1,14 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
|
-
import _callSuper from "@babel/runtime/helpers/esm/callSuper";
|
|
4
|
-
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
5
|
-
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
6
|
-
import React, { PureComponent } from 'react';
|
|
7
|
-
import createHoc from "../createHoc.mjs";
|
|
1
|
+
import React from 'react';
|
|
8
2
|
import CSSinJS from "../CSSinJS.mjs";
|
|
9
|
-
var getStylesheet = function getStylesheet() {
|
|
10
|
-
return CSSinJS().raw;
|
|
11
|
-
};
|
|
12
3
|
|
|
13
4
|
/**
|
|
14
5
|
* Function to clear the nano CSS styles object from keys with undefined value
|
|
@@ -30,47 +21,5 @@ function initNanoCss() {
|
|
|
30
21
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
31
22
|
return CSSinJS(options);
|
|
32
23
|
}
|
|
33
|
-
|
|
34
|
-
/** @deprecated */
|
|
35
|
-
var EnhancedWithCSS = /*#__PURE__*/function (_PureComponent) {
|
|
36
|
-
function EnhancedWithCSS(props, context) {
|
|
37
|
-
var _this;
|
|
38
|
-
_classCallCheck(this, EnhancedWithCSS);
|
|
39
|
-
_this = _callSuper(this, EnhancedWithCSS, [props, context]);
|
|
40
|
-
_defineProperty(_this, "state", {
|
|
41
|
-
dynamicClassName: ''
|
|
42
|
-
});
|
|
43
|
-
initNanoCss(context);
|
|
44
|
-
return _this;
|
|
45
|
-
}
|
|
46
|
-
_inherits(EnhancedWithCSS, _PureComponent);
|
|
47
|
-
return _createClass(EnhancedWithCSS, [{
|
|
48
|
-
key: "render",
|
|
49
|
-
value: function render() {
|
|
50
|
-
var _this$props = this.props,
|
|
51
|
-
children = _this$props.children,
|
|
52
|
-
_this$props$className = _this$props.className,
|
|
53
|
-
className = _this$props$className === void 0 ? '' : _this$props$className;
|
|
54
|
-
var dynamicClassName = this.state.dynamicClassName;
|
|
55
|
-
return children({
|
|
56
|
-
className: className + dynamicClassName || undefined
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
}], [{
|
|
60
|
-
key: "getDerivedStateFromProps",
|
|
61
|
-
value: function getDerivedStateFromProps(props) {
|
|
62
|
-
var _CSSinJS$cache, _CSSinJS;
|
|
63
|
-
var cleanCss = normaliseCss(props.css);
|
|
64
|
-
return {
|
|
65
|
-
dynamicClassName: Object.keys(cleanCss).length ? (_CSSinJS$cache = (_CSSinJS = CSSinJS()).cache) === null || _CSSinJS$cache === void 0 ? void 0 : _CSSinJS$cache.call(_CSSinJS, cleanCss) : ''
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
}]);
|
|
69
|
-
}(PureComponent);
|
|
70
|
-
_defineProperty(EnhancedWithCSS, "contextType", WithCssContext);
|
|
71
|
-
_defineProperty(EnhancedWithCSS, "defaultProps", {
|
|
72
|
-
css: {}
|
|
73
|
-
});
|
|
74
|
-
export { getStylesheet, EnhancedWithCSS, Provider, WithCssContext, initNanoCss, normaliseCss };
|
|
75
|
-
export default createHoc(EnhancedWithCSS);
|
|
24
|
+
export { Provider, WithCssContext, initNanoCss, normaliseCss };
|
|
76
25
|
//# sourceMappingURL=WithCSS.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WithCSS.mjs","names":["React","
|
|
1
|
+
{"version":3,"file":"WithCSS.mjs","names":["React","CSSinJS","normaliseCss","obj","Object","keys","reduce","acc","key","result","undefined","WithCssContext","createContext","Provider","initNanoCss","options","arguments","length"],"sources":["../../../src/utils/enhances/WithCSS.tsx"],"sourcesContent":["import type { NanoOptions } from '@phytonmk/nano-css';\nimport type { CssLikeObject } from '@phytonmk/nano-css/types/common';\nimport React from 'react';\n\nimport CSSinJS from '../CSSinJS';\n\n/**\n * Function to clear the nano CSS styles object from keys with undefined value\n * @param {Object} obj - nano CSS styles object\n * @returns {Object}\n */\nfunction normaliseCss(obj: CssLikeObject) {\n return Object.keys(obj).reduce((acc: any, key) => {\n const result = acc;\n if (obj[key] !== undefined) {\n result[key] = obj[key];\n }\n return result;\n }, {});\n}\n\nconst WithCssContext = React.createContext<NanoOptions>({});\nconst { Provider } = WithCssContext;\n\nfunction initNanoCss(options: NanoOptions = {}) {\n return CSSinJS(options);\n}\n\nexport { Provider, WithCssContext, initNanoCss, normaliseCss };\n"],"mappings":"AAEA,OAAOA,KAAK,MAAM,OAAO;AAEzB,OAAOC,OAAO,MAAM,gBAAY;;AAEhC;AACA;AACA;AACA;AACA;AACA,SAASC,YAAYA,CAACC,GAAkB,EAAE;EACxC,OAAOC,MAAM,CAACC,IAAI,CAACF,GAAG,CAAC,CAACG,MAAM,CAAC,UAACC,GAAQ,EAAEC,GAAG,EAAK;IAChD,IAAMC,MAAM,GAAGF,GAAG;IAClB,IAAIJ,GAAG,CAACK,GAAG,CAAC,KAAKE,SAAS,EAAE;MAC1BD,MAAM,CAACD,GAAG,CAAC,GAAGL,GAAG,CAACK,GAAG,CAAC;IACxB;IACA,OAAOC,MAAM;EACf,CAAC,EAAE,CAAC,CAAC,CAAC;AACR;AAEA,IAAME,cAAc,gBAAGX,KAAK,CAACY,aAAa,CAAc,CAAC,CAAC,CAAC;AAC3D,IAAQC,QAAQ,GAAKF,cAAc,CAA3BE,QAAQ;AAEhB,SAASC,WAAWA,CAAA,EAA4B;EAAA,IAA3BC,OAAoB,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAN,SAAA,GAAAM,SAAA,MAAG,CAAC,CAAC;EAC5C,OAAOf,OAAO,CAACc,OAAO,CAAC;AACzB;AAEA,SAASF,QAAQ,EAAEF,cAAc,EAAEG,WAAW,EAAEZ,YAAY","ignoreList":[]}
|