@vitus-labs/core 0.55.0 → 0.57.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/analysis/vitus-labs-core.js.html +1 -1
- package/lib/analysis/vitus-labs-core.module.js.html +1 -1
- package/lib/index.d.ts +23 -16
- package/lib/types/config.d.ts +15 -14
- package/lib/types/context.d.ts +4 -2
- package/lib/types/index.d.ts +4 -3
- package/lib/types/render.d.ts +7 -0
- package/lib/types/types.d.ts +3 -0
- package/lib/vitus-labs-core.js +40 -48
- package/lib/vitus-labs-core.js.map +1 -1
- package/lib/vitus-labs-core.module.js +40 -48
- package/lib/vitus-labs-core.module.js.map +1 -1
- package/package.json +10 -12
- package/lib/types/renderContent.d.ts +0 -6
|
@@ -6424,7 +6424,7 @@ var drawChart = (function (exports) {
|
|
|
6424
6424
|
</script>
|
|
6425
6425
|
<script>
|
|
6426
6426
|
/*<!--*/
|
|
6427
|
-
const data = {"version":2,"tree":{"name":"root","children":[{"name":"vitus-labs-core.js","children":[{"name":"src","children":[{"uid":"
|
|
6427
|
+
const data = {"version":2,"tree":{"name":"root","children":[{"name":"vitus-labs-core.js","children":[{"name":"src","children":[{"uid":"9eb5-1","name":"config.ts"},{"uid":"9eb5-3","name":"isEmpty.ts"},{"uid":"9eb5-5","name":"context.tsx"},{"uid":"9eb5-7","name":"compose.ts"},{"uid":"9eb5-9","name":"render.ts"},{"name":"html/htmlTags.ts","uid":"9eb5-11"},{"uid":"9eb5-13","name":"index.ts"}]}]}],"isRoot":true},"nodeParts":{"9eb5-1":{"renderedLength":708,"gzipLength":248,"brotliLength":0,"mainUid":"9eb5-0"},"9eb5-3":{"renderedLength":349,"gzipLength":177,"brotliLength":0,"mainUid":"9eb5-2"},"9eb5-5":{"renderedLength":785,"gzipLength":330,"brotliLength":0,"mainUid":"9eb5-4"},"9eb5-7":{"renderedLength":207,"gzipLength":153,"brotliLength":0,"mainUid":"9eb5-6"},"9eb5-9":{"renderedLength":837,"gzipLength":301,"brotliLength":0,"mainUid":"9eb5-8"},"9eb5-11":{"renderedLength":1715,"gzipLength":502,"brotliLength":0,"mainUid":"9eb5-10"},"9eb5-13":{"renderedLength":0,"gzipLength":0,"brotliLength":0,"mainUid":"9eb5-12"}},"nodeMetas":{"9eb5-0":{"id":"/src/config.ts","moduleParts":{"vitus-labs-core.js":"9eb5-1"},"imported":[{"uid":"9eb5-17"}],"importedBy":[{"uid":"9eb5-12"},{"uid":"9eb5-4"}]},"9eb5-2":{"id":"/src/isEmpty.ts","moduleParts":{"vitus-labs-core.js":"9eb5-3"},"imported":[],"importedBy":[{"uid":"9eb5-12"},{"uid":"9eb5-4"},{"uid":"9eb5-8"}]},"9eb5-4":{"id":"/src/context.tsx","moduleParts":{"vitus-labs-core.js":"9eb5-5"},"imported":[{"uid":"9eb5-18"},{"uid":"9eb5-0"},{"uid":"9eb5-2"}],"importedBy":[{"uid":"9eb5-12"}]},"9eb5-6":{"id":"/src/compose.ts","moduleParts":{"vitus-labs-core.js":"9eb5-7"},"imported":[],"importedBy":[{"uid":"9eb5-12"}]},"9eb5-8":{"id":"/src/render.ts","moduleParts":{"vitus-labs-core.js":"9eb5-9"},"imported":[{"uid":"9eb5-19"},{"uid":"9eb5-18"},{"uid":"9eb5-2"}],"importedBy":[{"uid":"9eb5-12"}]},"9eb5-10":{"id":"/src/html/htmlTags.ts","moduleParts":{"vitus-labs-core.js":"9eb5-11"},"imported":[],"importedBy":[{"uid":"9eb5-16"}]},"9eb5-12":{"id":"/src/index.ts","moduleParts":{"vitus-labs-core.js":"9eb5-13"},"imported":[{"uid":"9eb5-14"},{"uid":"9eb5-15"},{"uid":"9eb5-0"},{"uid":"9eb5-4"},{"uid":"9eb5-6"},{"uid":"9eb5-2"},{"uid":"9eb5-8"},{"uid":"9eb5-16"}],"importedBy":[],"isEntry":true},"9eb5-14":{"id":"lodash","moduleParts":{},"imported":[],"importedBy":[{"uid":"9eb5-12"}],"isExternal":true},"9eb5-15":{"id":"moize","moduleParts":{},"imported":[],"importedBy":[{"uid":"9eb5-12"}],"isExternal":true},"9eb5-16":{"id":"/src/html/index.ts","moduleParts":{},"imported":[{"uid":"9eb5-10"}],"importedBy":[{"uid":"9eb5-12"}]},"9eb5-17":{"id":"styled-components","moduleParts":{},"imported":[],"importedBy":[{"uid":"9eb5-0"}],"isExternal":true},"9eb5-18":{"id":"react","moduleParts":{},"imported":[],"importedBy":[{"uid":"9eb5-4"},{"uid":"9eb5-8"}],"isExternal":true},"9eb5-19":{"id":"react-is","moduleParts":{},"imported":[],"importedBy":[{"uid":"9eb5-8"}],"isExternal":true}},"env":{"rollup":"2.72.0"},"options":{"gzip":true,"brotli":false,"sourcemap":false}};
|
|
6428
6428
|
|
|
6429
6429
|
const run = () => {
|
|
6430
6430
|
const width = window.innerWidth;
|
|
@@ -6424,7 +6424,7 @@ var drawChart = (function (exports) {
|
|
|
6424
6424
|
</script>
|
|
6425
6425
|
<script>
|
|
6426
6426
|
/*<!--*/
|
|
6427
|
-
const data = {"version":2,"tree":{"name":"root","children":[{"name":"vitus-labs-core.module.js","children":[{"name":"src","children":[{"uid":"
|
|
6427
|
+
const data = {"version":2,"tree":{"name":"root","children":[{"name":"vitus-labs-core.module.js","children":[{"name":"src","children":[{"uid":"9eb5-21","name":"config.ts"},{"uid":"9eb5-23","name":"isEmpty.ts"},{"uid":"9eb5-25","name":"context.tsx"},{"uid":"9eb5-27","name":"compose.ts"},{"uid":"9eb5-29","name":"render.ts"},{"name":"html/htmlTags.ts","uid":"9eb5-31"},{"uid":"9eb5-33","name":"index.ts"}]}]}],"isRoot":true},"nodeParts":{"9eb5-21":{"renderedLength":674,"gzipLength":232,"brotliLength":0,"mainUid":"9eb5-20"},"9eb5-23":{"renderedLength":349,"gzipLength":177,"brotliLength":0,"mainUid":"9eb5-22"},"9eb5-25":{"renderedLength":673,"gzipLength":312,"brotliLength":0,"mainUid":"9eb5-24"},"9eb5-27":{"renderedLength":207,"gzipLength":153,"brotliLength":0,"mainUid":"9eb5-26"},"9eb5-29":{"renderedLength":797,"gzipLength":284,"brotliLength":0,"mainUid":"9eb5-28"},"9eb5-31":{"renderedLength":1715,"gzipLength":502,"brotliLength":0,"mainUid":"9eb5-30"},"9eb5-33":{"renderedLength":0,"gzipLength":0,"brotliLength":0,"mainUid":"9eb5-32"}},"nodeMetas":{"9eb5-20":{"id":"/src/config.ts","moduleParts":{"vitus-labs-core.module.js":"9eb5-21"},"imported":[{"uid":"9eb5-37"}],"importedBy":[{"uid":"9eb5-32"},{"uid":"9eb5-24"}]},"9eb5-22":{"id":"/src/isEmpty.ts","moduleParts":{"vitus-labs-core.module.js":"9eb5-23"},"imported":[],"importedBy":[{"uid":"9eb5-32"},{"uid":"9eb5-24"},{"uid":"9eb5-28"}]},"9eb5-24":{"id":"/src/context.tsx","moduleParts":{"vitus-labs-core.module.js":"9eb5-25"},"imported":[{"uid":"9eb5-38"},{"uid":"9eb5-20"},{"uid":"9eb5-22"}],"importedBy":[{"uid":"9eb5-32"}]},"9eb5-26":{"id":"/src/compose.ts","moduleParts":{"vitus-labs-core.module.js":"9eb5-27"},"imported":[],"importedBy":[{"uid":"9eb5-32"}]},"9eb5-28":{"id":"/src/render.ts","moduleParts":{"vitus-labs-core.module.js":"9eb5-29"},"imported":[{"uid":"9eb5-39"},{"uid":"9eb5-38"},{"uid":"9eb5-22"}],"importedBy":[{"uid":"9eb5-32"}]},"9eb5-30":{"id":"/src/html/htmlTags.ts","moduleParts":{"vitus-labs-core.module.js":"9eb5-31"},"imported":[],"importedBy":[{"uid":"9eb5-36"}]},"9eb5-32":{"id":"/src/index.ts","moduleParts":{"vitus-labs-core.module.js":"9eb5-33"},"imported":[{"uid":"9eb5-34"},{"uid":"9eb5-35"},{"uid":"9eb5-20"},{"uid":"9eb5-24"},{"uid":"9eb5-26"},{"uid":"9eb5-22"},{"uid":"9eb5-28"},{"uid":"9eb5-36"}],"importedBy":[],"isEntry":true},"9eb5-34":{"id":"lodash","moduleParts":{},"imported":[],"importedBy":[{"uid":"9eb5-32"}],"isExternal":true},"9eb5-35":{"id":"moize","moduleParts":{},"imported":[],"importedBy":[{"uid":"9eb5-32"}],"isExternal":true},"9eb5-36":{"id":"/src/html/index.ts","moduleParts":{},"imported":[{"uid":"9eb5-30"}],"importedBy":[{"uid":"9eb5-32"}]},"9eb5-37":{"id":"styled-components","moduleParts":{},"imported":[],"importedBy":[{"uid":"9eb5-20"}],"isExternal":true},"9eb5-38":{"id":"react","moduleParts":{},"imported":[],"importedBy":[{"uid":"9eb5-24"},{"uid":"9eb5-28"}],"isExternal":true},"9eb5-39":{"id":"react-is","moduleParts":{},"imported":[],"importedBy":[{"uid":"9eb5-28"}],"isExternal":true}},"env":{"rollup":"2.72.0"},"options":{"gzip":true,"brotli":false,"sourcemap":false}};
|
|
6428
6428
|
|
|
6429
6429
|
const run = () => {
|
|
6430
6430
|
const width = window.innerWidth;
|
package/lib/index.d.ts
CHANGED
|
@@ -117,30 +117,36 @@ declare type HTMLElementAttrs = {
|
|
|
117
117
|
|
|
118
118
|
declare type HTMLTagAttrsByTag<T extends HTMLTags> = T extends unknown ? {} : HTMLElementAttrs[T];
|
|
119
119
|
|
|
120
|
-
declare type Init = ({ styled, css, context, component, textComponent, }: {
|
|
121
|
-
styled: any;
|
|
122
|
-
css: any;
|
|
123
|
-
context: any;
|
|
124
|
-
component?: ComponentType | HTMLTags;
|
|
125
|
-
textComponent?: ComponentType | HTMLTags;
|
|
126
|
-
}) => void;
|
|
127
|
-
declare const init: Init;
|
|
128
120
|
interface Internal {
|
|
129
121
|
css: ThemedCssFunction<DefaultTheme>;
|
|
130
122
|
styled: StyledInterface;
|
|
131
|
-
|
|
132
|
-
component:
|
|
133
|
-
textComponent:
|
|
123
|
+
provider: ThemeProviderComponent<any, any>;
|
|
124
|
+
component: ComponentType | HTMLTags;
|
|
125
|
+
textComponent: ComponentType | HTMLTags;
|
|
134
126
|
}
|
|
135
|
-
declare
|
|
127
|
+
declare class Configuration {
|
|
128
|
+
css: ThemedCssFunction<DefaultTheme>;
|
|
129
|
+
styled: StyledInterface;
|
|
130
|
+
provider: ThemeProviderComponent<any, any>;
|
|
131
|
+
component: ComponentType | HTMLTags;
|
|
132
|
+
textComponent: ComponentType | HTMLTags;
|
|
133
|
+
init: (props: Internal) => void;
|
|
134
|
+
}
|
|
135
|
+
declare const config: Configuration;
|
|
136
|
+
declare const init: (props: Internal) => void;
|
|
137
|
+
|
|
138
|
+
interface Breakpoints {
|
|
139
|
+
}
|
|
140
|
+
declare type BreakpointKeys = keyof Breakpoints;
|
|
136
141
|
|
|
137
142
|
declare const context: React__default.Context<any>;
|
|
138
143
|
declare type Theme = Partial<{
|
|
139
144
|
rootSize: number;
|
|
140
|
-
breakpoints:
|
|
145
|
+
breakpoints: Breakpoints;
|
|
141
146
|
} & Record<string, any>>;
|
|
142
147
|
declare type ProviderType = Partial<{
|
|
143
148
|
theme: Theme;
|
|
149
|
+
children: ReactNode;
|
|
144
150
|
} & Record<string, any>>;
|
|
145
151
|
declare const Provider: FC<ProviderType>;
|
|
146
152
|
|
|
@@ -157,7 +163,8 @@ declare const isEmpty: IsEmpty;
|
|
|
157
163
|
|
|
158
164
|
declare type CreateTypes = Parameters<typeof createElement>[0];
|
|
159
165
|
declare type CloneTypes = Parameters<typeof cloneElement>[0];
|
|
160
|
-
declare type
|
|
161
|
-
declare
|
|
166
|
+
declare type RenderProps<T extends Record<string, unknown> | undefined> = (props: Partial<T>) => ReactNode;
|
|
167
|
+
declare type Render = <T extends Record<string, any> | undefined>(content?: CreateTypes | CloneTypes | ReactNode | ReactNode[] | RenderProps<T>, attachProps?: T) => ReturnType<typeof createElement> | ReturnType<typeof cloneElement> | null;
|
|
168
|
+
declare const render: Render;
|
|
162
169
|
|
|
163
|
-
export { HTMLElementAttrs, HTMLTagAttrsByTag, HTMLTags, HTMLTagsText, IsEmpty, Provider,
|
|
170
|
+
export { BreakpointKeys, Breakpoints, HTMLElementAttrs, HTMLTagAttrsByTag, HTMLTags, HTMLTagsText, IsEmpty, Provider, Render, compose, config, context, TAGS as htmlTags, init, isEmpty, render };
|
package/lib/types/config.d.ts
CHANGED
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
import { ComponentType } from 'react';
|
|
2
|
-
import { ThemedCssFunction, StyledInterface, DefaultTheme, ThemeProviderComponent } from 'styled-components';
|
|
3
2
|
import type { HTMLTags } from "./html";
|
|
4
|
-
|
|
5
|
-
styled: any;
|
|
6
|
-
css: any;
|
|
7
|
-
context: any;
|
|
8
|
-
component?: ComponentType | HTMLTags;
|
|
9
|
-
textComponent?: ComponentType | HTMLTags;
|
|
10
|
-
}) => void;
|
|
11
|
-
declare const init: Init;
|
|
3
|
+
import { ThemedCssFunction, StyledInterface, DefaultTheme, ThemeProviderComponent } from 'styled-components';
|
|
12
4
|
interface Internal {
|
|
13
5
|
css: ThemedCssFunction<DefaultTheme>;
|
|
14
6
|
styled: StyledInterface;
|
|
15
|
-
|
|
16
|
-
component:
|
|
17
|
-
textComponent:
|
|
7
|
+
provider: ThemeProviderComponent<any, any>;
|
|
8
|
+
component: ComponentType | HTMLTags;
|
|
9
|
+
textComponent: ComponentType | HTMLTags;
|
|
10
|
+
}
|
|
11
|
+
declare class Configuration {
|
|
12
|
+
css: ThemedCssFunction<DefaultTheme>;
|
|
13
|
+
styled: StyledInterface;
|
|
14
|
+
provider: ThemeProviderComponent<any, any>;
|
|
15
|
+
component: ComponentType | HTMLTags;
|
|
16
|
+
textComponent: ComponentType | HTMLTags;
|
|
17
|
+
init: (props: Internal) => void;
|
|
18
18
|
}
|
|
19
|
-
declare const
|
|
19
|
+
declare const config: Configuration;
|
|
20
|
+
declare const init: (props: Internal) => void;
|
|
21
|
+
export default config;
|
|
20
22
|
export { init };
|
|
21
|
-
export default internal;
|
package/lib/types/context.d.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import React, { FC } from 'react';
|
|
1
|
+
import React, { FC, ReactNode } from 'react';
|
|
2
|
+
import type { Breakpoints } from "./types";
|
|
2
3
|
declare const context: React.Context<any>;
|
|
3
4
|
declare type Theme = Partial<{
|
|
4
5
|
rootSize: number;
|
|
5
|
-
breakpoints:
|
|
6
|
+
breakpoints: Breakpoints;
|
|
6
7
|
} & Record<string, any>>;
|
|
7
8
|
declare type ProviderType = Partial<{
|
|
8
9
|
theme: Theme;
|
|
10
|
+
children: ReactNode;
|
|
9
11
|
} & Record<string, any>>;
|
|
10
12
|
declare const Provider: FC<ProviderType>;
|
|
11
13
|
export { context };
|
package/lib/types/index.d.ts
CHANGED
|
@@ -4,7 +4,8 @@ import config, { init } from "./config";
|
|
|
4
4
|
import Provider, { context } from "./context";
|
|
5
5
|
import compose from "./compose";
|
|
6
6
|
import isEmpty, { IsEmpty } from "./isEmpty";
|
|
7
|
-
import
|
|
7
|
+
import render, { Render } from "./render";
|
|
8
8
|
import { htmlTags, HTMLTags, HTMLTagsText, HTMLElementAttrs, HTMLTagAttrsByTag } from "./html";
|
|
9
|
-
|
|
10
|
-
export {
|
|
9
|
+
import type { Breakpoints, BreakpointKeys } from "./types";
|
|
10
|
+
export type { Breakpoints, BreakpointKeys, IsEmpty, Render, HTMLTags, HTMLTagsText, HTMLElementAttrs, HTMLTagAttrsByTag, };
|
|
11
|
+
export { Provider, context, init, config, compose, isEmpty, render, omit, pick, set, get, throttle, merge, memoize, htmlTags, };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { createElement, cloneElement, ReactNode } from 'react';
|
|
2
|
+
declare type CreateTypes = Parameters<typeof createElement>[0];
|
|
3
|
+
declare type CloneTypes = Parameters<typeof cloneElement>[0];
|
|
4
|
+
declare type RenderProps<T extends Record<string, unknown> | undefined> = (props: Partial<T>) => ReactNode;
|
|
5
|
+
export declare type Render = <T extends Record<string, any> | undefined>(content?: CreateTypes | CloneTypes | ReactNode | ReactNode[] | RenderProps<T>, attachProps?: T) => ReturnType<typeof createElement> | ReturnType<typeof cloneElement> | null;
|
|
6
|
+
declare const render: Render;
|
|
7
|
+
export default render;
|
package/lib/vitus-labs-core.js
CHANGED
|
@@ -14,37 +14,32 @@ var moize__default = /*#__PURE__*/_interopDefaultLegacy(moize);
|
|
|
14
14
|
var styled__default = /*#__PURE__*/_interopDefaultLegacy(styled);
|
|
15
15
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
styled
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
component
|
|
22
|
-
textComponent
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
},
|
|
44
|
-
get textComponent() {
|
|
45
|
-
return OPTIONS.textComponent;
|
|
46
|
-
},
|
|
47
|
-
});
|
|
17
|
+
class Configuration {
|
|
18
|
+
css = styled.css;
|
|
19
|
+
styled = styled__default["default"];
|
|
20
|
+
provider = styled.ThemeProvider;
|
|
21
|
+
component = 'div';
|
|
22
|
+
textComponent = 'span';
|
|
23
|
+
init = (props) => {
|
|
24
|
+
if (props.css) {
|
|
25
|
+
this.css = props.css;
|
|
26
|
+
}
|
|
27
|
+
if (props.styled) {
|
|
28
|
+
this.styled = props.styled;
|
|
29
|
+
}
|
|
30
|
+
if (props.provider) {
|
|
31
|
+
this.provider = props.provider;
|
|
32
|
+
}
|
|
33
|
+
if (props.component) {
|
|
34
|
+
this.component = props.component;
|
|
35
|
+
}
|
|
36
|
+
if (props.textComponent) {
|
|
37
|
+
this.textComponent = props.textComponent;
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
const config = new Configuration();
|
|
42
|
+
const { init } = config;
|
|
48
43
|
|
|
49
44
|
const isEmpty = (param) => {
|
|
50
45
|
if (!param)
|
|
@@ -55,8 +50,7 @@ const isEmpty = (param) => {
|
|
|
55
50
|
if (Array.isArray(param) && param.length === 0) {
|
|
56
51
|
return true;
|
|
57
52
|
}
|
|
58
|
-
if (Object.entries(param).length === 0 &&
|
|
59
|
-
param.constructor === Object) {
|
|
53
|
+
if (Object.entries(param).length === 0 && param.constructor === Object) {
|
|
60
54
|
return true;
|
|
61
55
|
}
|
|
62
56
|
return false;
|
|
@@ -65,13 +59,13 @@ const isEmpty = (param) => {
|
|
|
65
59
|
const context = React.createContext({});
|
|
66
60
|
const VitusLabsProvider = context.Provider;
|
|
67
61
|
const Provider = ({ theme, children, ...props }) => {
|
|
62
|
+
const ExternalProvider = React.useMemo(() => config.provider, []);
|
|
68
63
|
// eslint-disable-next-line react/jsx-no-useless-fragment
|
|
69
64
|
if (!theme || isEmpty(theme))
|
|
70
65
|
return React__default["default"].createElement(React__default["default"].Fragment, null, children);
|
|
71
|
-
|
|
72
|
-
if (StyledContext) {
|
|
66
|
+
if (ExternalProvider) {
|
|
73
67
|
return (React__default["default"].createElement(VitusLabsProvider, { value: { theme, ...props } },
|
|
74
|
-
React__default["default"].createElement(
|
|
68
|
+
React__default["default"].createElement(ExternalProvider, { theme: theme }, children)));
|
|
75
69
|
}
|
|
76
70
|
return (React__default["default"].createElement(VitusLabsProvider, { value: { theme, ...props } }, children));
|
|
77
71
|
};
|
|
@@ -80,26 +74,24 @@ const Provider = ({ theme, children, ...props }) => {
|
|
|
80
74
|
// fns.reduce((a, b) => (value) => a(b(value)), fn1)
|
|
81
75
|
const compose = (...fns) => (p) => fns.reduceRight((acc, cur) => cur(acc), p);
|
|
82
76
|
|
|
83
|
-
const
|
|
77
|
+
const render = (content, attachProps) => {
|
|
84
78
|
if (!content)
|
|
85
79
|
return null;
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
80
|
+
const isValidEl = React.isValidElement(content);
|
|
81
|
+
const render = (content) => attachProps ? React.createElement(content, attachProps) : React.createElement(content);
|
|
82
|
+
if (typeof content === 'string' && isValidEl) {
|
|
83
|
+
return render(content);
|
|
90
84
|
}
|
|
91
|
-
if (['number', 'boolean', 'string'].includes(typeof content)) {
|
|
85
|
+
if (['number', 'boolean', 'bigint', 'string'].includes(typeof content)) {
|
|
92
86
|
return content;
|
|
93
87
|
}
|
|
94
88
|
if (Array.isArray(content) || reactIs.isFragment(content)) {
|
|
95
89
|
return content;
|
|
96
90
|
}
|
|
97
91
|
if (reactIs.isValidElementType(content)) {
|
|
98
|
-
return
|
|
99
|
-
? React.createElement(content, attachProps)
|
|
100
|
-
: React.createElement(content);
|
|
92
|
+
return render(content);
|
|
101
93
|
}
|
|
102
|
-
if (
|
|
94
|
+
if (isValidEl) {
|
|
103
95
|
if (isEmpty(attachProps)) {
|
|
104
96
|
return content;
|
|
105
97
|
}
|
|
@@ -263,10 +255,10 @@ Object.defineProperty(exports, 'memoize', {
|
|
|
263
255
|
});
|
|
264
256
|
exports.Provider = Provider;
|
|
265
257
|
exports.compose = compose;
|
|
266
|
-
exports.config =
|
|
258
|
+
exports.config = config;
|
|
267
259
|
exports.context = context;
|
|
268
260
|
exports.htmlTags = TAGS;
|
|
269
261
|
exports.init = init;
|
|
270
262
|
exports.isEmpty = isEmpty;
|
|
271
|
-
exports.
|
|
263
|
+
exports.render = render;
|
|
272
264
|
//# sourceMappingURL=vitus-labs-core.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vitus-labs-core.js","sources":["../src/config.ts","../src/isEmpty.ts","../src/context.tsx","../src/compose.ts","../src/renderContent.ts","../src/html/htmlTags.ts"],"sourcesContent":["import { ComponentType } from 'react'\nimport styled, {\n css,\n ThemeProvider,\n ThemedCssFunction,\n StyledInterface,\n DefaultTheme,\n ThemeProviderComponent,\n} from 'styled-components'\nimport type { HTMLTags } from '~/html'\n\nconst OPTIONS: Internal = {\n styled,\n css,\n styledContext: ThemeProvider,\n component: 'div',\n textComponent: 'span',\n} as Internal\n\ntype Init = ({\n styled,\n css,\n context,\n component,\n textComponent,\n}: {\n styled: any\n css: any\n context: any\n component?: ComponentType | HTMLTags\n textComponent?: ComponentType | HTMLTags\n}) => void\n\nconst init: Init = ({\n styled,\n css,\n context,\n component = 'div',\n textComponent = 'span',\n}) => {\n OPTIONS.css = css\n OPTIONS.styled = styled\n OPTIONS.styledContext = context\n OPTIONS.component = component\n OPTIONS.textComponent = textComponent\n}\n\ninterface Internal {\n css: ThemedCssFunction<DefaultTheme>\n styled: StyledInterface\n styledContext: ThemeProviderComponent<any, any>\n component: any\n textComponent: any\n}\n\nconst internal: Internal = Object.freeze({\n get css() {\n return OPTIONS.css\n },\n get styled() {\n return OPTIONS.styled\n },\n get styledContext() {\n return OPTIONS.styledContext\n },\n get component() {\n return OPTIONS.component\n },\n get textComponent() {\n return OPTIONS.textComponent\n },\n})\n\nexport { init }\nexport default internal\n","export type IsEmpty = <T extends Record<string, unknown> | unknown[] | null>(\n param?: T\n) => null | undefined extends T ? true : keyof T extends never ? true : false\n\nconst isEmpty: IsEmpty = (param) => {\n if (!param) return true\n\n if (typeof param !== 'object') {\n return true as any\n }\n\n if (Array.isArray(param) && param.length === 0) {\n return true\n }\n\n if (\n Object.entries(param as any).length === 0 &&\n param.constructor === Object\n ) {\n return true\n }\n\n return false\n}\n\nexport default isEmpty\n","import React, { createContext, FC, useMemo } from 'react'\nimport config from '~/config'\nimport isEmpty from '~/isEmpty'\n\nconst context = createContext<any>({})\nconst VitusLabsProvider = context.Provider\n\ntype Theme = Partial<\n {\n rootSize: number\n breakpoints: Record<string, number | string>\n } & Record<string, any>\n>\n\ntype ProviderType = Partial<\n {\n theme: Theme\n } & Record<string, any>\n>\n\nconst Provider: FC<ProviderType> = ({ theme, children, ...props }) => {\n // eslint-disable-next-line react/jsx-no-useless-fragment\n if (!theme || isEmpty(theme)) return <>{children}</>\n\n const StyledContext = useMemo(() => config.styledContext, [])\n\n if (StyledContext) {\n return (\n <VitusLabsProvider value={{ theme, ...props }}>\n <StyledContext theme={theme}>{children}</StyledContext>\n </VitusLabsProvider>\n )\n }\n\n return (\n <VitusLabsProvider value={{ theme, ...props }}>\n {children}\n </VitusLabsProvider>\n )\n}\n\nexport { context }\n\nexport default Provider\n","// const compose = <R>(fn1: (a: R) => R, ...fns: Array<(a: R) => R>) =>\n// fns.reduce((a, b) => (value) => a(b(value)), fn1)\n\n// const compose = (funcs) =>\n// funcs.reduce(\n// (a, b) => (...args) => a(b(...args)),\n// (arg) => arg\n// )\n\ntype ArityOneFn = (arg: any) => any\ntype PickLastInTuple<T extends any[]> = T extends [\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n ...rest: infer U,\n argn: infer L\n]\n ? L\n : any\ntype FirstFnParameterType<T extends any[]> = Parameters<PickLastInTuple<T>>[any]\ntype LastFnReturnType<T extends any[]> = ReturnType<T[0]>\n\nconst compose =\n <T extends ArityOneFn[]>(...fns: T) =>\n (p: FirstFnParameterType<T>): LastFnReturnType<T> =>\n fns.reduceRight((acc: any, cur: any) => cur(acc), p)\n\nexport default compose\n","import { isValidElementType, isFragment } from 'react-is'\nimport { createElement, isValidElement, cloneElement, ReactNode } from 'react'\nimport isEmpty from './isEmpty'\n\ntype CreateTypes = Parameters<typeof createElement>[0]\ntype CloneTypes = Parameters<typeof cloneElement>[0]\n\nexport type RenderContent = (\n content?: CreateTypes | CloneTypes | ReactNode | ReactNode[],\n attachProps?: Record<string, any>\n) => ReturnType<typeof createElement> | ReturnType<typeof cloneElement> | null\n\nconst renderContent: RenderContent = (content, attachProps) => {\n if (!content) return null as any\n\n if (typeof content === 'string' && isValidElement(content)) {\n return attachProps\n ? createElement(content, attachProps)\n : createElement(content)\n }\n\n if (['number', 'boolean', 'string'].includes(typeof content)) {\n return content\n }\n\n if (Array.isArray(content) || isFragment(content)) {\n return content\n }\n\n if (isValidElementType(content)) {\n return attachProps\n ? createElement(content, attachProps)\n : createElement(content)\n }\n\n if (isValidElement(content)) {\n if (isEmpty(attachProps)) {\n return content\n }\n\n return cloneElement(content, attachProps)\n }\n\n return content\n}\n\nexport default renderContent\n","const TAGS = [\n 'a',\n 'abbr',\n // 'acronym',\n 'address',\n // 'applet',\n 'area',\n 'article',\n 'aside',\n 'audio',\n 'b',\n // 'base',\n // 'basefont',\n 'bdi',\n 'bdo',\n 'big',\n 'blockquote',\n 'body',\n 'br',\n 'button',\n 'canvas',\n 'caption',\n // 'center',\n 'cite',\n 'code',\n 'col',\n 'colgroup',\n 'data',\n 'datalist',\n 'dd',\n 'del',\n 'details',\n 'dfn',\n 'dialog',\n // 'dir',\n 'div',\n 'dl',\n 'dt',\n 'em',\n 'embed',\n 'fieldset',\n 'figcaption',\n 'figure',\n // 'font',\n 'footer',\n 'form',\n // 'frame',\n // 'frameset',\n 'h1',\n 'h2',\n 'h3',\n 'h4',\n 'h5',\n 'h6',\n // 'head',\n 'header',\n 'hr',\n 'html',\n 'i',\n 'iframe',\n 'img',\n 'input',\n 'ins',\n 'kbd',\n 'label',\n 'legend',\n 'li',\n // 'link',\n 'main',\n 'map',\n 'mark',\n // 'meta',\n 'meter',\n 'nav',\n // 'noframes',\n // 'noscript',\n 'object',\n 'ol',\n 'optgroup',\n 'option',\n 'output',\n 'p',\n // 'param',\n 'picture',\n 'pre',\n 'progress',\n 'q',\n 'rp',\n 'rt',\n 'ruby',\n 's',\n 'samp',\n // 'script',\n 'section',\n 'select',\n 'small',\n 'source',\n 'span',\n // 'strike',\n 'strong',\n // 'style',\n 'sub',\n 'summary',\n 'sup',\n 'svg',\n 'table',\n 'tbody',\n 'td',\n 'template',\n 'textarea',\n 'tfoot',\n 'th',\n 'thead',\n 'time',\n // 'title',\n 'tr',\n 'track',\n // 'tt',\n 'u',\n 'ul',\n 'var',\n 'video',\n 'wbr',\n] as const\n\nconst TEXT_TAGS = [\n 'abbr',\n 'b',\n 'bdi',\n 'bdo',\n 'big',\n 'blockquote',\n 'cite',\n 'code',\n 'dl',\n 'dt',\n 'em',\n 'figcaption',\n 'h1',\n 'h2',\n 'h3',\n 'h4',\n 'h5',\n 'h6',\n 'i',\n 'ins',\n 'kbd',\n 'label',\n 'legend',\n 'li',\n 'p',\n 'pre',\n 'q',\n 'rp',\n 'rt',\n 's',\n 'small',\n 'span',\n 'strong',\n 'sub',\n 'summary',\n 'sup',\n 'time',\n 'u',\n] as const\n\nexport type HTMLTags = typeof TAGS[number]\n\nexport type HTMLTagsText = typeof TEXT_TAGS[number]\n\nexport default TAGS\n"],"names":["styled","css","ThemeProvider","createContext","React","useMemo","config","isValidElement","createElement","isFragment","isValidElementType","cloneElement"],"mappings":";;;;;;;;;;;;;;;;AAWA,MAAM,OAAO,GAAa;YACxBA,0BAAM;SACNC,UAAG;AACH,IAAA,aAAa,EAAEC,oBAAa;AAC5B,IAAA,SAAS,EAAE,KAAK;AAChB,IAAA,aAAa,EAAE,MAAM;CACV,CAAA;AAgBb,MAAM,IAAI,GAAS,CAAC,EAClB,MAAM,EACN,GAAG,EACH,OAAO,EACP,SAAS,GAAG,KAAK,EACjB,aAAa,GAAG,MAAM,GACvB,KAAI;AACH,IAAA,OAAO,CAAC,GAAG,GAAG,GAAG,CAAA;AACjB,IAAA,OAAO,CAAC,MAAM,GAAG,MAAM,CAAA;AACvB,IAAA,OAAO,CAAC,aAAa,GAAG,OAAO,CAAA;AAC/B,IAAA,OAAO,CAAC,SAAS,GAAG,SAAS,CAAA;AAC7B,IAAA,OAAO,CAAC,aAAa,GAAG,aAAa,CAAA;AACvC,EAAC;AAUD,MAAM,QAAQ,GAAa,MAAM,CAAC,MAAM,CAAC;AACvC,IAAA,IAAI,GAAG,GAAA;QACL,OAAO,OAAO,CAAC,GAAG,CAAA;KACnB;AACD,IAAA,IAAI,MAAM,GAAA;QACR,OAAO,OAAO,CAAC,MAAM,CAAA;KACtB;AACD,IAAA,IAAI,aAAa,GAAA;QACf,OAAO,OAAO,CAAC,aAAa,CAAA;KAC7B;AACD,IAAA,IAAI,SAAS,GAAA;QACX,OAAO,OAAO,CAAC,SA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T,KAAK;IACL,KAAK;IACL,OAAO;IACP,OAAO;IACP,IAAI;IACJ,UAAU;IACV,UAAU;IACV,OAAO;IACP,IAAI;IACJ,OAAO;IACP,MAAM;;IAEN,IAAI;IACJ,OAAO;;IAEP,GAAG;IACH,IAAI;IACJ,KAAK;IACL,OAAO;IACP,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"vitus-labs-core.js","sources":["../src/config.ts","../src/isEmpty.ts","../src/context.tsx","../src/compose.ts","../src/render.ts","../src/html/htmlTags.ts"],"sourcesContent":["import { ComponentType } from 'react'\nimport type { HTMLTags } from '~/html'\nimport styled, {\n css,\n ThemeProvider,\n ThemedCssFunction,\n StyledInterface,\n DefaultTheme,\n ThemeProviderComponent,\n} from 'styled-components'\n\ninterface Internal {\n css: ThemedCssFunction<DefaultTheme>\n styled: StyledInterface\n provider: ThemeProviderComponent<any, any>\n component: ComponentType | HTMLTags\n textComponent: ComponentType | HTMLTags\n}\n\nclass Configuration {\n css = css\n\n styled = styled\n\n provider = ThemeProvider\n\n component: ComponentType | HTMLTags = 'div'\n\n textComponent: ComponentType | HTMLTags = 'span'\n\n init = (props: Internal) => {\n if (props.css) {\n this.css = props.css\n }\n\n if (props.styled) {\n this.styled = props.styled\n }\n\n if (props.provider) {\n this.provider = props.provider\n }\n\n if (props.component) {\n this.component = props.component\n }\n\n if (props.textComponent) {\n this.textComponent = props.textComponent\n }\n }\n}\n\nconst config = new Configuration()\n\nconst { init } = config\n\nexport default config\nexport { init }\n","export type IsEmpty = <T extends Record<string, unknown> | unknown[] | null>(\n param?: T\n) => null | undefined extends T ? true : keyof T extends never ? true : false\n\nconst isEmpty: IsEmpty = (param) => {\n if (!param) return true\n\n if (typeof param !== 'object') {\n return true as any\n }\n\n if (Array.isArray(param) && param.length === 0) {\n return true\n }\n\n if (Object.entries(param).length === 0 && param.constructor === Object) {\n return true\n }\n\n return false\n}\n\nexport default isEmpty\n","import React, { createContext, FC, useMemo, ReactNode } from 'react'\nimport config from '~/config'\nimport isEmpty from '~/isEmpty'\nimport type { Breakpoints } from '~/types'\n\nconst context = createContext<any>({})\nconst VitusLabsProvider = context.Provider\n\ntype Theme = Partial<\n {\n rootSize: number\n breakpoints: Breakpoints\n } & Record<string, any>\n>\n\ntype ProviderType = Partial<\n {\n theme: Theme\n children: ReactNode\n } & Record<string, any>\n>\n\nconst Provider: FC<ProviderType> = ({ theme, children, ...props }) => {\n const ExternalProvider = useMemo(() => config.provider, [])\n\n // eslint-disable-next-line react/jsx-no-useless-fragment\n if (!theme || isEmpty(theme)) return <>{children}</>\n\n if (ExternalProvider) {\n return (\n <VitusLabsProvider value={{ theme, ...props }}>\n <ExternalProvider theme={theme}>{children}</ExternalProvider>\n </VitusLabsProvider>\n )\n }\n\n return (\n <VitusLabsProvider value={{ theme, ...props }}>\n {children}\n </VitusLabsProvider>\n )\n}\n\nexport { context }\n\nexport default Provider\n","// const compose = <R>(fn1: (a: R) => R, ...fns: Array<(a: R) => R>) =>\n// fns.reduce((a, b) => (value) => a(b(value)), fn1)\n\n// const compose = (funcs) =>\n// funcs.reduce(\n// (a, b) => (...args) => a(b(...args)),\n// (arg) => arg\n// )\n\ntype ArityOneFn = (arg: any) => any\ntype PickLastInTuple<T extends any[]> = T extends [\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n ...rest: infer U,\n argn: infer L\n]\n ? L\n : any\ntype FirstFnParameterType<T extends any[]> = Parameters<PickLastInTuple<T>>[any]\ntype LastFnReturnType<T extends any[]> = ReturnType<T[0]>\n\nconst compose =\n <T extends ArityOneFn[]>(...fns: T) =>\n (p: FirstFnParameterType<T>): LastFnReturnType<T> =>\n fns.reduceRight((acc: any, cur: any) => cur(acc), p)\n\nexport default compose\n","import { isValidElementType, isFragment } from 'react-is'\nimport { createElement, isValidElement, cloneElement, ReactNode } from 'react'\nimport isEmpty from './isEmpty'\n\ntype CreateTypes = Parameters<typeof createElement>[0]\ntype CloneTypes = Parameters<typeof cloneElement>[0]\ntype RenderProps<T extends Record<string, unknown> | undefined> = (\n props: Partial<T>\n) => ReactNode\n\nexport type Render = <T extends Record<string, any> | undefined>(\n content?: CreateTypes | CloneTypes | ReactNode | ReactNode[] | RenderProps<T>,\n attachProps?: T\n) => ReturnType<typeof createElement> | ReturnType<typeof cloneElement> | null\n\nconst render: Render = (content, attachProps) => {\n if (!content) return null as any\n\n const isValidEl = isValidElement(content)\n const render = (content) =>\n attachProps ? createElement(content, attachProps) : createElement(content)\n\n if (typeof content === 'string' && isValidEl) {\n return render(content)\n }\n\n if (['number', 'boolean', 'bigint', 'string'].includes(typeof content)) {\n return content\n }\n\n if (Array.isArray(content) || isFragment(content)) {\n return content\n }\n\n if (isValidElementType(content)) {\n return render(content)\n }\n\n if (isValidEl) {\n if (isEmpty(attachProps)) {\n return content\n }\n\n return cloneElement(content, attachProps)\n }\n\n return content\n}\n\nexport default render\n","const TAGS = [\n 'a',\n 'abbr',\n // 'acronym',\n 'address',\n // 'applet',\n 'area',\n 'article',\n 'aside',\n 'audio',\n 'b',\n // 'base',\n // 'basefont',\n 'bdi',\n 'bdo',\n 'big',\n 'blockquote',\n 'body',\n 'br',\n 'button',\n 'canvas',\n 'caption',\n // 'center',\n 'cite',\n 'code',\n 'col',\n 'colgroup',\n 'data',\n 'datalist',\n 'dd',\n 'del',\n 'details',\n 'dfn',\n 'dialog',\n // 'dir',\n 'div',\n 'dl',\n 'dt',\n 'em',\n 'embed',\n 'fieldset',\n 'figcaption',\n 'figure',\n // 'font',\n 'footer',\n 'form',\n // 'frame',\n // 'frameset',\n 'h1',\n 'h2',\n 'h3',\n 'h4',\n 'h5',\n 'h6',\n // 'head',\n 'header',\n 'hr',\n 'html',\n 'i',\n 'iframe',\n 'img',\n 'input',\n 'ins',\n 'kbd',\n 'label',\n 'legend',\n 'li',\n // 'link',\n 'main',\n 'map',\n 'mark',\n // 'meta',\n 'meter',\n 'nav',\n // 'noframes',\n // 'noscript',\n 'object',\n 'ol',\n 'optgroup',\n 'option',\n 'output',\n 'p',\n // 'param',\n 'picture',\n 'pre',\n 'progress',\n 'q',\n 'rp',\n 'rt',\n 'ruby',\n 's',\n 'samp',\n // 'script',\n 'section',\n 'select',\n 'small',\n 'source',\n 'span',\n // 'strike',\n 'strong',\n // 'style',\n 'sub',\n 'summary',\n 'sup',\n 'svg',\n 'table',\n 'tbody',\n 'td',\n 'template',\n 'textarea',\n 'tfoot',\n 'th',\n 'thead',\n 'time',\n // 'title',\n 'tr',\n 'track',\n // 'tt',\n 'u',\n 'ul',\n 'var',\n 'video',\n 'wbr',\n] as const\n\nconst TEXT_TAGS = [\n 'abbr',\n 'b',\n 'bdi',\n 'bdo',\n 'big',\n 'blockquote',\n 'cite',\n 'code',\n 'dl',\n 'dt',\n 'em',\n 'figcaption',\n 'h1',\n 'h2',\n 'h3',\n 'h4',\n 'h5',\n 'h6',\n 'i',\n 'ins',\n 'kbd',\n 'label',\n 'legend',\n 'li',\n 'p',\n 'pre',\n 'q',\n 'rp',\n 'rt',\n 's',\n 'small',\n 'span',\n 'strong',\n 'sub',\n 'summary',\n 'sup',\n 'time',\n 'u',\n] as const\n\nexport type HTMLTags = typeof TAGS[number]\n\nexport type HTMLTagsText = typeof TEXT_TAGS[number]\n\nexport default TAGS\n"],"names":["css","styled","ThemeProvider","createContext","useMemo","React","isValidElement","createElement","isFragment","isValidElementType","cloneElement"],"mappings":";;;;;;;;;;;;;;;;AAmBA,MAAM,aAAa,CAAA;IACjB,GAAG,GAAGA,UAAG,CAAA;IAET,MAAM,GAAGC,0BAAM,CAAA;IAEf,QAAQ,GAAGC,oBAAa,CAAA;IAExB,SAAS,GAA6B,KAAK,CAAA;IAE3C,aAAa,GAA6B,MAAM,CAAA;AAEhD,IAAA,IAAI,GAAG,CAAC,KAAe,KAAI;QACzB,IAAI,KAAK,CAAC,GAAG,EAAE;AACb,YAAA,IAAI,CAAC,GAAG,GAAG,KAAK,CAAC,GAAG,CAAA;AACrB,SAAA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IAAI;;IAEJ,QAAQ;IACR,IAAI;IACJ,MAAM;IACN,GAAG;IACH,QAAQ;IACR,KAAK;IACL,OAAO;IACP,KAAK;IACL,KAAK;IACL,OAAO;IACP,QAAQ;IACR,IAAI;;IAEJ,MAAM;IACN,KAAK;IACL,MAAM;;IAEN,OAAO;IACP,KAAK;;;IAGL,QAAQ;IACR,IAAI;IACJ,UAAU;IACV,QAAQ;IACR,QAAQ;IACR,GAAG;;IAEH,SAAS;IACT,KAAK;IACL,UAAU;IACV,GAAG;IACH,IAAI;IACJ,IAAI;IACJ,MAAM;IACN,GAAG;IACH,MAAM;;IAEN,SAAS;IACT,QAAQ;IACR,OAAO;IACP,QAAQ;IACR,MAAM;;IAEN,QAAQ;;IAER,KAAK;IACL,SAAS;IACT,KAAK;IACL,KAAK;IACL,OAAO;IACP,OAAO;IACP,IAAI;IACJ,UAAU;IACV,UAAU;IACV,OAAO;IACP,IAAI;IACJ,OAAO;IACP,MAAM;;IAEN,IAAI;IACJ,OAAO;;IAEP,GAAG;IACH,IAAI;IACJ,KAAK;IACL,OAAO;IACP,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,40 +1,35 @@
|
|
|
1
1
|
export { get, merge, omit, pick, set, throttle } from 'lodash';
|
|
2
2
|
export { default as memoize } from 'moize';
|
|
3
3
|
import styled, { css, ThemeProvider } from 'styled-components';
|
|
4
|
-
import React, { createContext, useMemo, isValidElement,
|
|
4
|
+
import React, { createContext, useMemo, isValidElement, cloneElement, createElement } from 'react';
|
|
5
5
|
import { isFragment, isValidElementType } from 'react-is';
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
component
|
|
12
|
-
textComponent
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
},
|
|
34
|
-
get textComponent() {
|
|
35
|
-
return OPTIONS.textComponent;
|
|
36
|
-
},
|
|
37
|
-
});
|
|
7
|
+
class Configuration {
|
|
8
|
+
css = css;
|
|
9
|
+
styled = styled;
|
|
10
|
+
provider = ThemeProvider;
|
|
11
|
+
component = 'div';
|
|
12
|
+
textComponent = 'span';
|
|
13
|
+
init = (props) => {
|
|
14
|
+
if (props.css) {
|
|
15
|
+
this.css = props.css;
|
|
16
|
+
}
|
|
17
|
+
if (props.styled) {
|
|
18
|
+
this.styled = props.styled;
|
|
19
|
+
}
|
|
20
|
+
if (props.provider) {
|
|
21
|
+
this.provider = props.provider;
|
|
22
|
+
}
|
|
23
|
+
if (props.component) {
|
|
24
|
+
this.component = props.component;
|
|
25
|
+
}
|
|
26
|
+
if (props.textComponent) {
|
|
27
|
+
this.textComponent = props.textComponent;
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
const config = new Configuration();
|
|
32
|
+
const { init } = config;
|
|
38
33
|
|
|
39
34
|
const isEmpty = (param) => {
|
|
40
35
|
if (!param)
|
|
@@ -45,8 +40,7 @@ const isEmpty = (param) => {
|
|
|
45
40
|
if (Array.isArray(param) && param.length === 0) {
|
|
46
41
|
return true;
|
|
47
42
|
}
|
|
48
|
-
if (Object.entries(param).length === 0 &&
|
|
49
|
-
param.constructor === Object) {
|
|
43
|
+
if (Object.entries(param).length === 0 && param.constructor === Object) {
|
|
50
44
|
return true;
|
|
51
45
|
}
|
|
52
46
|
return false;
|
|
@@ -55,13 +49,13 @@ const isEmpty = (param) => {
|
|
|
55
49
|
const context = createContext({});
|
|
56
50
|
const VitusLabsProvider = context.Provider;
|
|
57
51
|
const Provider = ({ theme, children, ...props }) => {
|
|
52
|
+
const ExternalProvider = useMemo(() => config.provider, []);
|
|
58
53
|
// eslint-disable-next-line react/jsx-no-useless-fragment
|
|
59
54
|
if (!theme || isEmpty(theme))
|
|
60
55
|
return React.createElement(React.Fragment, null, children);
|
|
61
|
-
|
|
62
|
-
if (StyledContext) {
|
|
56
|
+
if (ExternalProvider) {
|
|
63
57
|
return (React.createElement(VitusLabsProvider, { value: { theme, ...props } },
|
|
64
|
-
React.createElement(
|
|
58
|
+
React.createElement(ExternalProvider, { theme: theme }, children)));
|
|
65
59
|
}
|
|
66
60
|
return (React.createElement(VitusLabsProvider, { value: { theme, ...props } }, children));
|
|
67
61
|
};
|
|
@@ -70,26 +64,24 @@ const Provider = ({ theme, children, ...props }) => {
|
|
|
70
64
|
// fns.reduce((a, b) => (value) => a(b(value)), fn1)
|
|
71
65
|
const compose = (...fns) => (p) => fns.reduceRight((acc, cur) => cur(acc), p);
|
|
72
66
|
|
|
73
|
-
const
|
|
67
|
+
const render = (content, attachProps) => {
|
|
74
68
|
if (!content)
|
|
75
69
|
return null;
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
70
|
+
const isValidEl = isValidElement(content);
|
|
71
|
+
const render = (content) => attachProps ? createElement(content, attachProps) : createElement(content);
|
|
72
|
+
if (typeof content === 'string' && isValidEl) {
|
|
73
|
+
return render(content);
|
|
80
74
|
}
|
|
81
|
-
if (['number', 'boolean', 'string'].includes(typeof content)) {
|
|
75
|
+
if (['number', 'boolean', 'bigint', 'string'].includes(typeof content)) {
|
|
82
76
|
return content;
|
|
83
77
|
}
|
|
84
78
|
if (Array.isArray(content) || isFragment(content)) {
|
|
85
79
|
return content;
|
|
86
80
|
}
|
|
87
81
|
if (isValidElementType(content)) {
|
|
88
|
-
return
|
|
89
|
-
? createElement(content, attachProps)
|
|
90
|
-
: createElement(content);
|
|
82
|
+
return render(content);
|
|
91
83
|
}
|
|
92
|
-
if (
|
|
84
|
+
if (isValidEl) {
|
|
93
85
|
if (isEmpty(attachProps)) {
|
|
94
86
|
return content;
|
|
95
87
|
}
|
|
@@ -223,5 +215,5 @@ const TAGS = [
|
|
|
223
215
|
'wbr',
|
|
224
216
|
];
|
|
225
217
|
|
|
226
|
-
export { Provider, compose,
|
|
218
|
+
export { Provider, compose, config, context, TAGS as htmlTags, init, isEmpty, render };
|
|
227
219
|
//# sourceMappingURL=vitus-labs-core.module.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vitus-labs-core.module.js","sources":["../src/config.ts","../src/isEmpty.ts","../src/context.tsx","../src/compose.ts","../src/renderContent.ts","../src/html/htmlTags.ts"],"sourcesContent":["import { ComponentType } from 'react'\nimport styled, {\n css,\n ThemeProvider,\n ThemedCssFunction,\n StyledInterface,\n DefaultTheme,\n ThemeProviderComponent,\n} from 'styled-components'\nimport type { HTMLTags } from '~/html'\n\nconst OPTIONS: Internal = {\n styled,\n css,\n styledContext: ThemeProvider,\n component: 'div',\n textComponent: 'span',\n} as Internal\n\ntype Init = ({\n styled,\n css,\n context,\n component,\n textComponent,\n}: {\n styled: any\n css: any\n context: any\n component?: ComponentType | HTMLTags\n textComponent?: ComponentType | HTMLTags\n}) => void\n\nconst init: Init = ({\n styled,\n css,\n context,\n component = 'div',\n textComponent = 'span',\n}) => {\n OPTIONS.css = css\n OPTIONS.styled = styled\n OPTIONS.styledContext = context\n OPTIONS.component = component\n OPTIONS.textComponent = textComponent\n}\n\ninterface Internal {\n css: ThemedCssFunction<DefaultTheme>\n styled: StyledInterface\n styledContext: ThemeProviderComponent<any, any>\n component: any\n textComponent: any\n}\n\nconst internal: Internal = Object.freeze({\n get css() {\n return OPTIONS.css\n },\n get styled() {\n return OPTIONS.styled\n },\n get styledContext() {\n return OPTIONS.styledContext\n },\n get component() {\n return OPTIONS.component\n },\n get textComponent() {\n return OPTIONS.textComponent\n },\n})\n\nexport { init }\nexport default internal\n","export type IsEmpty = <T extends Record<string, unknown> | unknown[] | null>(\n param?: T\n) => null | undefined extends T ? true : keyof T extends never ? true : false\n\nconst isEmpty: IsEmpty = (param) => {\n if (!param) return true\n\n if (typeof param !== 'object') {\n return true as any\n }\n\n if (Array.isArray(param) && param.length === 0) {\n return true\n }\n\n if (\n Object.entries(param as any).length === 0 &&\n param.constructor === Object\n ) {\n return true\n }\n\n return false\n}\n\nexport default isEmpty\n","import React, { createContext, FC, useMemo } from 'react'\nimport config from '~/config'\nimport isEmpty from '~/isEmpty'\n\nconst context = createContext<any>({})\nconst VitusLabsProvider = context.Provider\n\ntype Theme = Partial<\n {\n rootSize: number\n breakpoints: Record<string, number | string>\n } & Record<string, any>\n>\n\ntype ProviderType = Partial<\n {\n theme: Theme\n } & Record<string, any>\n>\n\nconst Provider: FC<ProviderType> = ({ theme, children, ...props }) => {\n // eslint-disable-next-line react/jsx-no-useless-fragment\n if (!theme || isEmpty(theme)) return <>{children}</>\n\n const StyledContext = useMemo(() => config.styledContext, [])\n\n if (StyledContext) {\n return (\n <VitusLabsProvider value={{ theme, ...props }}>\n <StyledContext theme={theme}>{children}</StyledContext>\n </VitusLabsProvider>\n )\n }\n\n return (\n <VitusLabsProvider value={{ theme, ...props }}>\n {children}\n </VitusLabsProvider>\n )\n}\n\nexport { context }\n\nexport default Provider\n","// const compose = <R>(fn1: (a: R) => R, ...fns: Array<(a: R) => R>) =>\n// fns.reduce((a, b) => (value) => a(b(value)), fn1)\n\n// const compose = (funcs) =>\n// funcs.reduce(\n// (a, b) => (...args) => a(b(...args)),\n// (arg) => arg\n// )\n\ntype ArityOneFn = (arg: any) => any\ntype PickLastInTuple<T extends any[]> = T extends [\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n ...rest: infer U,\n argn: infer L\n]\n ? L\n : any\ntype FirstFnParameterType<T extends any[]> = Parameters<PickLastInTuple<T>>[any]\ntype LastFnReturnType<T extends any[]> = ReturnType<T[0]>\n\nconst compose =\n <T extends ArityOneFn[]>(...fns: T) =>\n (p: FirstFnParameterType<T>): LastFnReturnType<T> =>\n fns.reduceRight((acc: any, cur: any) => cur(acc), p)\n\nexport default compose\n","import { isValidElementType, isFragment } from 'react-is'\nimport { createElement, isValidElement, cloneElement, ReactNode } from 'react'\nimport isEmpty from './isEmpty'\n\ntype CreateTypes = Parameters<typeof createElement>[0]\ntype CloneTypes = Parameters<typeof cloneElement>[0]\n\nexport type RenderContent = (\n content?: CreateTypes | CloneTypes | ReactNode | ReactNode[],\n attachProps?: Record<string, any>\n) => ReturnType<typeof createElement> | ReturnType<typeof cloneElement> | null\n\nconst renderContent: RenderContent = (content, attachProps) => {\n if (!content) return null as any\n\n if (typeof content === 'string' && isValidElement(content)) {\n return attachProps\n ? createElement(content, attachProps)\n : createElement(content)\n }\n\n if (['number', 'boolean', 'string'].includes(typeof content)) {\n return content\n }\n\n if (Array.isArray(content) || isFragment(content)) {\n return content\n }\n\n if (isValidElementType(content)) {\n return attachProps\n ? createElement(content, attachProps)\n : createElement(content)\n }\n\n if (isValidElement(content)) {\n if (isEmpty(attachProps)) {\n return content\n }\n\n return cloneElement(content, attachProps)\n }\n\n return content\n}\n\nexport default renderContent\n","const TAGS = [\n 'a',\n 'abbr',\n // 'acronym',\n 'address',\n // 'applet',\n 'area',\n 'article',\n 'aside',\n 'audio',\n 'b',\n // 'base',\n // 'basefont',\n 'bdi',\n 'bdo',\n 'big',\n 'blockquote',\n 'body',\n 'br',\n 'button',\n 'canvas',\n 'caption',\n // 'center',\n 'cite',\n 'code',\n 'col',\n 'colgroup',\n 'data',\n 'datalist',\n 'dd',\n 'del',\n 'details',\n 'dfn',\n 'dialog',\n // 'dir',\n 'div',\n 'dl',\n 'dt',\n 'em',\n 'embed',\n 'fieldset',\n 'figcaption',\n 'figure',\n // 'font',\n 'footer',\n 'form',\n // 'frame',\n // 'frameset',\n 'h1',\n 'h2',\n 'h3',\n 'h4',\n 'h5',\n 'h6',\n // 'head',\n 'header',\n 'hr',\n 'html',\n 'i',\n 'iframe',\n 'img',\n 'input',\n 'ins',\n 'kbd',\n 'label',\n 'legend',\n 'li',\n // 'link',\n 'main',\n 'map',\n 'mark',\n // 'meta',\n 'meter',\n 'nav',\n // 'noframes',\n // 'noscript',\n 'object',\n 'ol',\n 'optgroup',\n 'option',\n 'output',\n 'p',\n // 'param',\n 'picture',\n 'pre',\n 'progress',\n 'q',\n 'rp',\n 'rt',\n 'ruby',\n 's',\n 'samp',\n // 'script',\n 'section',\n 'select',\n 'small',\n 'source',\n 'span',\n // 'strike',\n 'strong',\n // 'style',\n 'sub',\n 'summary',\n 'sup',\n 'svg',\n 'table',\n 'tbody',\n 'td',\n 'template',\n 'textarea',\n 'tfoot',\n 'th',\n 'thead',\n 'time',\n // 'title',\n 'tr',\n 'track',\n // 'tt',\n 'u',\n 'ul',\n 'var',\n 'video',\n 'wbr',\n] as const\n\nconst TEXT_TAGS = [\n 'abbr',\n 'b',\n 'bdi',\n 'bdo',\n 'big',\n 'blockquote',\n 'cite',\n 'code',\n 'dl',\n 'dt',\n 'em',\n 'figcaption',\n 'h1',\n 'h2',\n 'h3',\n 'h4',\n 'h5',\n 'h6',\n 'i',\n 'ins',\n 'kbd',\n 'label',\n 'legend',\n 'li',\n 'p',\n 'pre',\n 'q',\n 'rp',\n 'rt',\n 's',\n 'small',\n 'span',\n 'strong',\n 'sub',\n 'summary',\n 'sup',\n 'time',\n 'u',\n] as const\n\nexport type HTMLTags = typeof TAGS[number]\n\nexport type HTMLTagsText = typeof TEXT_TAGS[number]\n\nexport default TAGS\n"],"names":["config"],"mappings":";;;;;;AAWA,MAAM,OAAO,GAAa;IACxB,MAAM;IACN,GAAG;AACH,IAAA,aAAa,EAAE,aAAa;AAC5B,IAAA,SAAS,EAAE,KAAK;AAChB,IAAA,aAAa,EAAE,MAAM;CACV,CAAA;AAgBb,MAAM,IAAI,GAAS,CAAC,EAClB,MAAM,EACN,GAAG,EACH,OAAO,EACP,SAAS,GAAG,KAAK,EACjB,aAAa,GAAG,MAAM,GACvB,KAAI;AACH,IAAA,OAAO,CAAC,GAAG,GAAG,GAAG,CAAA;AACjB,IAAA,OAAO,CAAC,MAA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;IACR,IAAI;IACJ,MAAM;IACN,GAAG;IACH,QAAQ;IACR,KAAK;IACL,OAAO;IACP,KAAK;IACL,KAAK;IACL,OAAO;IACP,QAAQ;IACR,IAAI;;IAEJ,MAAM;IACN,KAAK;IACL,MAAM;;IAEN,OAAO;IACP,KAAK;;;IAGL,QAAQ;IACR,IAAI;IACJ,UAAU;IACV,QAAQ;IACR,QAAQ;IACR,GAAG;;IAEH,SAAS;IACT,KAAK;IACL,UAAU;IACV,GAAG;IACH,IAAI;IACJ,IAAI;IACJ,MAAM;IACN,GAAG;IACH,MAAM;;IAEN,SAAS;IACT,QAAQ;IACR,OAAO;IACP,QAAQ;IACR,MAAM;;IAEN,QAAQ;;IAER,KAAK;IACL,SAAS;IACT,KAAK;IACL,KAAK;IACL,OAAO;IACP,OAAO;IACP,IAAI;IACJ,UAAU;IACV,UAAU;IACV,OAAO;IACP,IAAI;IACJ,OAAO;IACP,MAAM;;IAEN,IAAI;IACJ,OAAO;;IAEP,GAAG;IACH,IAAI;IACJ,KAAK;IACL,OAAO;IACP,KAAK;;;;;"}
|
|
1
|
+
{"version":3,"file":"vitus-labs-core.module.js","sources":["../src/config.ts","../src/isEmpty.ts","../src/context.tsx","../src/compose.ts","../src/render.ts","../src/html/htmlTags.ts"],"sourcesContent":["import { ComponentType } from 'react'\nimport type { HTMLTags } from '~/html'\nimport styled, {\n css,\n ThemeProvider,\n ThemedCssFunction,\n StyledInterface,\n DefaultTheme,\n ThemeProviderComponent,\n} from 'styled-components'\n\ninterface Internal {\n css: ThemedCssFunction<DefaultTheme>\n styled: StyledInterface\n provider: ThemeProviderComponent<any, any>\n component: ComponentType | HTMLTags\n textComponent: ComponentType | HTMLTags\n}\n\nclass Configuration {\n css = css\n\n styled = styled\n\n provider = ThemeProvider\n\n component: ComponentType | HTMLTags = 'div'\n\n textComponent: ComponentType | HTMLTags = 'span'\n\n init = (props: Internal) => {\n if (props.css) {\n this.css = props.css\n }\n\n if (props.styled) {\n this.styled = props.styled\n }\n\n if (props.provider) {\n this.provider = props.provider\n }\n\n if (props.component) {\n this.component = props.component\n }\n\n if (props.textComponent) {\n this.textComponent = props.textComponent\n }\n }\n}\n\nconst config = new Configuration()\n\nconst { init } = config\n\nexport default config\nexport { init }\n","export type IsEmpty = <T extends Record<string, unknown> | unknown[] | null>(\n param?: T\n) => null | undefined extends T ? true : keyof T extends never ? true : false\n\nconst isEmpty: IsEmpty = (param) => {\n if (!param) return true\n\n if (typeof param !== 'object') {\n return true as any\n }\n\n if (Array.isArray(param) && param.length === 0) {\n return true\n }\n\n if (Object.entries(param).length === 0 && param.constructor === Object) {\n return true\n }\n\n return false\n}\n\nexport default isEmpty\n","import React, { createContext, FC, useMemo, ReactNode } from 'react'\nimport config from '~/config'\nimport isEmpty from '~/isEmpty'\nimport type { Breakpoints } from '~/types'\n\nconst context = createContext<any>({})\nconst VitusLabsProvider = context.Provider\n\ntype Theme = Partial<\n {\n rootSize: number\n breakpoints: Breakpoints\n } & Record<string, any>\n>\n\ntype ProviderType = Partial<\n {\n theme: Theme\n children: ReactNode\n } & Record<string, any>\n>\n\nconst Provider: FC<ProviderType> = ({ theme, children, ...props }) => {\n const ExternalProvider = useMemo(() => config.provider, [])\n\n // eslint-disable-next-line react/jsx-no-useless-fragment\n if (!theme || isEmpty(theme)) return <>{children}</>\n\n if (ExternalProvider) {\n return (\n <VitusLabsProvider value={{ theme, ...props }}>\n <ExternalProvider theme={theme}>{children}</ExternalProvider>\n </VitusLabsProvider>\n )\n }\n\n return (\n <VitusLabsProvider value={{ theme, ...props }}>\n {children}\n </VitusLabsProvider>\n )\n}\n\nexport { context }\n\nexport default Provider\n","// const compose = <R>(fn1: (a: R) => R, ...fns: Array<(a: R) => R>) =>\n// fns.reduce((a, b) => (value) => a(b(value)), fn1)\n\n// const compose = (funcs) =>\n// funcs.reduce(\n// (a, b) => (...args) => a(b(...args)),\n// (arg) => arg\n// )\n\ntype ArityOneFn = (arg: any) => any\ntype PickLastInTuple<T extends any[]> = T extends [\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n ...rest: infer U,\n argn: infer L\n]\n ? L\n : any\ntype FirstFnParameterType<T extends any[]> = Parameters<PickLastInTuple<T>>[any]\ntype LastFnReturnType<T extends any[]> = ReturnType<T[0]>\n\nconst compose =\n <T extends ArityOneFn[]>(...fns: T) =>\n (p: FirstFnParameterType<T>): LastFnReturnType<T> =>\n fns.reduceRight((acc: any, cur: any) => cur(acc), p)\n\nexport default compose\n","import { isValidElementType, isFragment } from 'react-is'\nimport { createElement, isValidElement, cloneElement, ReactNode } from 'react'\nimport isEmpty from './isEmpty'\n\ntype CreateTypes = Parameters<typeof createElement>[0]\ntype CloneTypes = Parameters<typeof cloneElement>[0]\ntype RenderProps<T extends Record<string, unknown> | undefined> = (\n props: Partial<T>\n) => ReactNode\n\nexport type Render = <T extends Record<string, any> | undefined>(\n content?: CreateTypes | CloneTypes | ReactNode | ReactNode[] | RenderProps<T>,\n attachProps?: T\n) => ReturnType<typeof createElement> | ReturnType<typeof cloneElement> | null\n\nconst render: Render = (content, attachProps) => {\n if (!content) return null as any\n\n const isValidEl = isValidElement(content)\n const render = (content) =>\n attachProps ? createElement(content, attachProps) : createElement(content)\n\n if (typeof content === 'string' && isValidEl) {\n return render(content)\n }\n\n if (['number', 'boolean', 'bigint', 'string'].includes(typeof content)) {\n return content\n }\n\n if (Array.isArray(content) || isFragment(content)) {\n return content\n }\n\n if (isValidElementType(content)) {\n return render(content)\n }\n\n if (isValidEl) {\n if (isEmpty(attachProps)) {\n return content\n }\n\n return cloneElement(content, attachProps)\n }\n\n return content\n}\n\nexport default render\n","const TAGS = [\n 'a',\n 'abbr',\n // 'acronym',\n 'address',\n // 'applet',\n 'area',\n 'article',\n 'aside',\n 'audio',\n 'b',\n // 'base',\n // 'basefont',\n 'bdi',\n 'bdo',\n 'big',\n 'blockquote',\n 'body',\n 'br',\n 'button',\n 'canvas',\n 'caption',\n // 'center',\n 'cite',\n 'code',\n 'col',\n 'colgroup',\n 'data',\n 'datalist',\n 'dd',\n 'del',\n 'details',\n 'dfn',\n 'dialog',\n // 'dir',\n 'div',\n 'dl',\n 'dt',\n 'em',\n 'embed',\n 'fieldset',\n 'figcaption',\n 'figure',\n // 'font',\n 'footer',\n 'form',\n // 'frame',\n // 'frameset',\n 'h1',\n 'h2',\n 'h3',\n 'h4',\n 'h5',\n 'h6',\n // 'head',\n 'header',\n 'hr',\n 'html',\n 'i',\n 'iframe',\n 'img',\n 'input',\n 'ins',\n 'kbd',\n 'label',\n 'legend',\n 'li',\n // 'link',\n 'main',\n 'map',\n 'mark',\n // 'meta',\n 'meter',\n 'nav',\n // 'noframes',\n // 'noscript',\n 'object',\n 'ol',\n 'optgroup',\n 'option',\n 'output',\n 'p',\n // 'param',\n 'picture',\n 'pre',\n 'progress',\n 'q',\n 'rp',\n 'rt',\n 'ruby',\n 's',\n 'samp',\n // 'script',\n 'section',\n 'select',\n 'small',\n 'source',\n 'span',\n // 'strike',\n 'strong',\n // 'style',\n 'sub',\n 'summary',\n 'sup',\n 'svg',\n 'table',\n 'tbody',\n 'td',\n 'template',\n 'textarea',\n 'tfoot',\n 'th',\n 'thead',\n 'time',\n // 'title',\n 'tr',\n 'track',\n // 'tt',\n 'u',\n 'ul',\n 'var',\n 'video',\n 'wbr',\n] as const\n\nconst TEXT_TAGS = [\n 'abbr',\n 'b',\n 'bdi',\n 'bdo',\n 'big',\n 'blockquote',\n 'cite',\n 'code',\n 'dl',\n 'dt',\n 'em',\n 'figcaption',\n 'h1',\n 'h2',\n 'h3',\n 'h4',\n 'h5',\n 'h6',\n 'i',\n 'ins',\n 'kbd',\n 'label',\n 'legend',\n 'li',\n 'p',\n 'pre',\n 'q',\n 'rp',\n 'rt',\n 's',\n 'small',\n 'span',\n 'strong',\n 'sub',\n 'summary',\n 'sup',\n 'time',\n 'u',\n] as const\n\nexport type HTMLTags = typeof TAGS[number]\n\nexport type HTMLTagsText = typeof TEXT_TAGS[number]\n\nexport default TAGS\n"],"names":[],"m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;;IAET,MAAM;IACN,MAAM;IACN,KAAK;IACL,UAAU;IACV,MAAM;IACN,UAAU;IACV,IAAI;IACJ,KAAK;IACL,SAAS;IACT,KAAK;IACL,QAAQ;;IAER,KAAK;IACL,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,OAAO;IACP,UAAU;IACV,YAAY;IACZ,QAAQ;;IAER,QAAQ;IACR,MAAM;;;IAGN,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;;IAEJ,QAAQ;IACR,IAAI;IACJ,MAAM;IACN,GAAG;IACH,QAAQ;IACR,KAAK;IACL,OAAO;IACP,KAAK;IACL,KAAK;IACL,OAAO;IACP,QAAQ;IACR,IAAI;;IAEJ,MAAM;IACN,KAAK;IACL,MAAM;;IAEN,OAAO;IACP,KAAK;;;IAGL,QAAQ;IACR,IAAI;IACJ,UAAU;IACV,QAAQ;IACR,QAAQ;IACR,GAAG;;IAEH,SAAS;IACT,KAAK;IACL,UAAU;IACV,GAAG;IACH,IAAI;IACJ,IAAI;IACJ,MAAM;IACN,GAAG;IACH,MAAM;;IAEN,SAAS;IACT,QAAQ;IACR,OAAO;IACP,QAAQ;IACR,MAAM;;IAEN,QAAQ;;IAER,KAAK;IACL,SAAS;IACT,KAAK;IACL,KAAK;IACL,OAAO;IACP,OAAO;IACP,IAAI;IACJ,UAAU;IACV,UAAU;IACV,OAAO;IACP,IAAI;IACJ,OAAO;IACP,MAAM;;IAEN,IAAI;IACJ,OAAO;;IAEP,GAAG;IACH,IAAI;IACJ,KAAK;IACL,OAAO;IACP,KAAK;;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitus-labs/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.57.0-alpha.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Vit Bokisch <vit@bokisch.cz>",
|
|
6
6
|
"maintainers": [
|
|
@@ -47,18 +47,16 @@
|
|
|
47
47
|
"styled-components": "<= 5"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"lodash": "^4.17.
|
|
51
|
-
"moize": "^6.1.
|
|
52
|
-
"react-is": "^
|
|
50
|
+
"lodash": "^4.17.21",
|
|
51
|
+
"moize": "^6.1.1",
|
|
52
|
+
"react-is": "^18.1.0"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
|
-
"@
|
|
56
|
-
"@
|
|
57
|
-
"@
|
|
58
|
-
"@vitus-labs/tools-
|
|
59
|
-
"
|
|
60
|
-
"@vitus-labs/tools-typescript": "^0.30.0",
|
|
61
|
-
"styled-components": "^5.3.3"
|
|
55
|
+
"@types/lodash": "^4.14.182",
|
|
56
|
+
"@vitus-labs/tools-babel": "^0.33.0",
|
|
57
|
+
"@vitus-labs/tools-rollup": "^0.33.0",
|
|
58
|
+
"@vitus-labs/tools-typescript": "^0.33.0",
|
|
59
|
+
"styled-components": "^5.3.5"
|
|
62
60
|
},
|
|
63
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "2c794cd421ff685d1edb1ef12341d050fc7b6409"
|
|
64
62
|
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { createElement, cloneElement, ReactNode } from 'react';
|
|
2
|
-
declare type CreateTypes = Parameters<typeof createElement>[0];
|
|
3
|
-
declare type CloneTypes = Parameters<typeof cloneElement>[0];
|
|
4
|
-
export declare type RenderContent = (content?: CreateTypes | CloneTypes | ReactNode | ReactNode[], attachProps?: Record<string, any>) => ReturnType<typeof createElement> | ReturnType<typeof cloneElement> | null;
|
|
5
|
-
declare const renderContent: RenderContent;
|
|
6
|
-
export default renderContent;
|