@vitus-labs/core 0.57.0-alpha.0 → 0.57.0-alpha.1
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 +6 -2
- package/lib/types/context.d.ts +2 -1
- package/lib/types/index.d.ts +2 -1
- package/lib/types/types.d.ts +3 -0
- package/lib/vitus-labs-core.js +16 -6
- package/lib/vitus-labs-core.js.map +1 -1
- package/lib/vitus-labs-core.module.js +16 -6
- package/lib/vitus-labs-core.module.js.map +1 -1
- package/package.json +2 -2
|
@@ -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":"2537-1","name":"config.ts"},{"uid":"2537-3","name":"isEmpty.ts"},{"uid":"2537-5","name":"context.tsx"},{"uid":"2537-7","name":"compose.ts"},{"uid":"2537-9","name":"render.ts"},{"name":"html/htmlTags.ts","uid":"2537-11"},{"uid":"2537-13","name":"index.ts"}]}]}],"isRoot":true},"nodeParts":{"2537-1":{"renderedLength":708,"gzipLength":248,"brotliLength":0,"mainUid":"2537-0"},"2537-3":{"renderedLength":349,"gzipLength":177,"brotliLength":0,"mainUid":"2537-2"},"2537-5":{"renderedLength":785,"gzipLength":330,"brotliLength":0,"mainUid":"2537-4"},"2537-7":{"renderedLength":207,"gzipLength":153,"brotliLength":0,"mainUid":"2537-6"},"2537-9":{"renderedLength":837,"gzipLength":301,"brotliLength":0,"mainUid":"2537-8"},"2537-11":{"renderedLength":1715,"gzipLength":502,"brotliLength":0,"mainUid":"2537-10"},"2537-13":{"renderedLength":0,"gzipLength":0,"brotliLength":0,"mainUid":"2537-12"}},"nodeMetas":{"2537-0":{"id":"/src/config.ts","moduleParts":{"vitus-labs-core.js":"2537-1"},"imported":[{"uid":"2537-17"}],"importedBy":[{"uid":"2537-12"},{"uid":"2537-4"}]},"2537-2":{"id":"/src/isEmpty.ts","moduleParts":{"vitus-labs-core.js":"2537-3"},"imported":[],"importedBy":[{"uid":"2537-12"},{"uid":"2537-4"},{"uid":"2537-8"}]},"2537-4":{"id":"/src/context.tsx","moduleParts":{"vitus-labs-core.js":"2537-5"},"imported":[{"uid":"2537-18"},{"uid":"2537-0"},{"uid":"2537-2"}],"importedBy":[{"uid":"2537-12"}]},"2537-6":{"id":"/src/compose.ts","moduleParts":{"vitus-labs-core.js":"2537-7"},"imported":[],"importedBy":[{"uid":"2537-12"}]},"2537-8":{"id":"/src/render.ts","moduleParts":{"vitus-labs-core.js":"2537-9"},"imported":[{"uid":"2537-19"},{"uid":"2537-18"},{"uid":"2537-2"}],"importedBy":[{"uid":"2537-12"}]},"2537-10":{"id":"/src/html/htmlTags.ts","moduleParts":{"vitus-labs-core.js":"2537-11"},"imported":[],"importedBy":[{"uid":"2537-16"}]},"2537-12":{"id":"/src/index.ts","moduleParts":{"vitus-labs-core.js":"2537-13"},"imported":[{"uid":"2537-14"},{"uid":"2537-15"},{"uid":"2537-0"},{"uid":"2537-4"},{"uid":"2537-6"},{"uid":"2537-2"},{"uid":"2537-8"},{"uid":"2537-16"}],"importedBy":[],"isEntry":true},"2537-14":{"id":"lodash","moduleParts":{},"imported":[],"importedBy":[{"uid":"2537-12"}],"isExternal":true},"2537-15":{"id":"moize","moduleParts":{},"imported":[],"importedBy":[{"uid":"2537-12"}],"isExternal":true},"2537-16":{"id":"/src/html/index.ts","moduleParts":{},"imported":[{"uid":"2537-10"}],"importedBy":[{"uid":"2537-12"}]},"2537-17":{"id":"styled-components","moduleParts":{},"imported":[],"importedBy":[{"uid":"2537-0"}],"isExternal":true},"2537-18":{"id":"react","moduleParts":{},"imported":[],"importedBy":[{"uid":"2537-4"},{"uid":"2537-8"}],"isExternal":true},"2537-19":{"id":"react-is","moduleParts":{},"imported":[],"importedBy":[{"uid":"2537-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":"2537-21","name":"config.ts"},{"uid":"2537-23","name":"isEmpty.ts"},{"uid":"2537-25","name":"context.tsx"},{"uid":"2537-27","name":"compose.ts"},{"uid":"2537-29","name":"render.ts"},{"name":"html/htmlTags.ts","uid":"2537-31"},{"uid":"2537-33","name":"index.ts"}]}]}],"isRoot":true},"nodeParts":{"2537-21":{"renderedLength":674,"gzipLength":232,"brotliLength":0,"mainUid":"2537-20"},"2537-23":{"renderedLength":349,"gzipLength":177,"brotliLength":0,"mainUid":"2537-22"},"2537-25":{"renderedLength":673,"gzipLength":312,"brotliLength":0,"mainUid":"2537-24"},"2537-27":{"renderedLength":207,"gzipLength":153,"brotliLength":0,"mainUid":"2537-26"},"2537-29":{"renderedLength":797,"gzipLength":284,"brotliLength":0,"mainUid":"2537-28"},"2537-31":{"renderedLength":1715,"gzipLength":502,"brotliLength":0,"mainUid":"2537-30"},"2537-33":{"renderedLength":0,"gzipLength":0,"brotliLength":0,"mainUid":"2537-32"}},"nodeMetas":{"2537-20":{"id":"/src/config.ts","moduleParts":{"vitus-labs-core.module.js":"2537-21"},"imported":[{"uid":"2537-37"}],"importedBy":[{"uid":"2537-32"},{"uid":"2537-24"}]},"2537-22":{"id":"/src/isEmpty.ts","moduleParts":{"vitus-labs-core.module.js":"2537-23"},"imported":[],"importedBy":[{"uid":"2537-32"},{"uid":"2537-24"},{"uid":"2537-28"}]},"2537-24":{"id":"/src/context.tsx","moduleParts":{"vitus-labs-core.module.js":"2537-25"},"imported":[{"uid":"2537-38"},{"uid":"2537-20"},{"uid":"2537-22"}],"importedBy":[{"uid":"2537-32"}]},"2537-26":{"id":"/src/compose.ts","moduleParts":{"vitus-labs-core.module.js":"2537-27"},"imported":[],"importedBy":[{"uid":"2537-32"}]},"2537-28":{"id":"/src/render.ts","moduleParts":{"vitus-labs-core.module.js":"2537-29"},"imported":[{"uid":"2537-39"},{"uid":"2537-38"},{"uid":"2537-22"}],"importedBy":[{"uid":"2537-32"}]},"2537-30":{"id":"/src/html/htmlTags.ts","moduleParts":{"vitus-labs-core.module.js":"2537-31"},"imported":[],"importedBy":[{"uid":"2537-36"}]},"2537-32":{"id":"/src/index.ts","moduleParts":{"vitus-labs-core.module.js":"2537-33"},"imported":[{"uid":"2537-34"},{"uid":"2537-35"},{"uid":"2537-20"},{"uid":"2537-24"},{"uid":"2537-26"},{"uid":"2537-22"},{"uid":"2537-28"},{"uid":"2537-36"}],"importedBy":[],"isEntry":true},"2537-34":{"id":"lodash","moduleParts":{},"imported":[],"importedBy":[{"uid":"2537-32"}],"isExternal":true},"2537-35":{"id":"moize","moduleParts":{},"imported":[],"importedBy":[{"uid":"2537-32"}],"isExternal":true},"2537-36":{"id":"/src/html/index.ts","moduleParts":{},"imported":[{"uid":"2537-30"}],"importedBy":[{"uid":"2537-32"}]},"2537-37":{"id":"styled-components","moduleParts":{},"imported":[],"importedBy":[{"uid":"2537-20"}],"isExternal":true},"2537-38":{"id":"react","moduleParts":{},"imported":[],"importedBy":[{"uid":"2537-24"},{"uid":"2537-28"}],"isExternal":true},"2537-39":{"id":"react-is","moduleParts":{},"imported":[],"importedBy":[{"uid":"2537-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
|
@@ -135,10 +135,14 @@ declare class Configuration {
|
|
|
135
135
|
declare const config: Configuration;
|
|
136
136
|
declare const init: (props: Internal) => void;
|
|
137
137
|
|
|
138
|
+
interface Breakpoints {
|
|
139
|
+
}
|
|
140
|
+
declare type BreakpointKeys = keyof Breakpoints;
|
|
141
|
+
|
|
138
142
|
declare const context: React__default.Context<any>;
|
|
139
143
|
declare type Theme = Partial<{
|
|
140
144
|
rootSize: number;
|
|
141
|
-
breakpoints:
|
|
145
|
+
breakpoints: Breakpoints;
|
|
142
146
|
} & Record<string, any>>;
|
|
143
147
|
declare type ProviderType = Partial<{
|
|
144
148
|
theme: Theme;
|
|
@@ -163,4 +167,4 @@ declare type RenderProps<T extends Record<string, unknown> | undefined> = (props
|
|
|
163
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;
|
|
164
168
|
declare const render: Render;
|
|
165
169
|
|
|
166
|
-
export { HTMLElementAttrs, HTMLTagAttrsByTag, HTMLTags, HTMLTagsText, IsEmpty, Provider, Render, compose, config, context, TAGS as htmlTags, init, isEmpty, render };
|
|
170
|
+
export { BreakpointKeys, Breakpoints, HTMLElementAttrs, HTMLTagAttrsByTag, HTMLTags, HTMLTagsText, IsEmpty, Provider, Render, compose, config, context, TAGS as htmlTags, init, isEmpty, render };
|
package/lib/types/context.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
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;
|
package/lib/types/index.d.ts
CHANGED
|
@@ -6,5 +6,6 @@ import compose from "./compose";
|
|
|
6
6
|
import isEmpty, { IsEmpty } from "./isEmpty";
|
|
7
7
|
import render, { Render } from "./render";
|
|
8
8
|
import { htmlTags, HTMLTags, HTMLTagsText, HTMLElementAttrs, HTMLTagAttrsByTag } from "./html";
|
|
9
|
-
|
|
9
|
+
import type { Breakpoints, BreakpointKeys } from "./types";
|
|
10
|
+
export type { Breakpoints, BreakpointKeys, IsEmpty, Render, HTMLTags, HTMLTagsText, HTMLElementAttrs, HTMLTagAttrsByTag, };
|
|
10
11
|
export { Provider, context, init, config, compose, isEmpty, render, omit, pick, set, get, throttle, merge, memoize, htmlTags, };
|
package/lib/vitus-labs-core.js
CHANGED
|
@@ -21,11 +21,21 @@ class Configuration {
|
|
|
21
21
|
component = 'div';
|
|
22
22
|
textComponent = 'span';
|
|
23
23
|
init = (props) => {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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
|
+
}
|
|
29
39
|
};
|
|
30
40
|
}
|
|
31
41
|
const config = new Configuration();
|
|
@@ -49,10 +59,10 @@ const isEmpty = (param) => {
|
|
|
49
59
|
const context = React.createContext({});
|
|
50
60
|
const VitusLabsProvider = context.Provider;
|
|
51
61
|
const Provider = ({ theme, children, ...props }) => {
|
|
62
|
+
const ExternalProvider = React.useMemo(() => config.provider, []);
|
|
52
63
|
// eslint-disable-next-line react/jsx-no-useless-fragment
|
|
53
64
|
if (!theme || isEmpty(theme))
|
|
54
65
|
return React__default["default"].createElement(React__default["default"].Fragment, null, children);
|
|
55
|
-
const ExternalProvider = React.useMemo(() => config.provider, []);
|
|
56
66
|
if (ExternalProvider) {
|
|
57
67
|
return (React__default["default"].createElement(VitusLabsProvider, { value: { theme, ...props } },
|
|
58
68
|
React__default["default"].createElement(ExternalProvider, { theme: theme }, children)));
|
|
@@ -1 +1 @@
|
|
|
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 styled = styled\n provider = ThemeProvider\n component: ComponentType | HTMLTags = 'div'\n textComponent: ComponentType | HTMLTags = 'span'\n\n init = (props: Internal) => {\n this.css = props.css\n this.styled = props.styled\n this.provider = props.provider\n this.component = props.component\n this.textComponent = props.textComponent\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'\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 children: ReactNode\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 ExternalProvider = useMemo(() => config.provider, [])\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","React","useMemo","isValidElement","createElement","isFragment","isValidElementType","cloneElement"],"mappings":";;;;;;;;;;;;;;;;AAmBA,MAAM,aAAa,CAAA;IACjB,GAAG,GAAGA,UAAG,CAAA;IACT,MAAM,GAAGC,0BAAM,CAAA;IACf,QAAQ,GAAGC,oBAAa,CAAA;IACxB,SAAS,GAA6B,KAAK,CAAA;IAC3C,aAAa,GAA6B,MAAM,CAAA;AAEhD,IAAA,IAAI,GAAG,CAAC,KAAe,KAAI;AACzB,QAAA,IAAI,CAAC,GAAG,GAAG,KAAK,CAAC,GAAG,CAAA;AACpB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;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.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,UAA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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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -11,11 +11,21 @@ class Configuration {
|
|
|
11
11
|
component = 'div';
|
|
12
12
|
textComponent = 'span';
|
|
13
13
|
init = (props) => {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
+
}
|
|
19
29
|
};
|
|
20
30
|
}
|
|
21
31
|
const config = new Configuration();
|
|
@@ -39,10 +49,10 @@ const isEmpty = (param) => {
|
|
|
39
49
|
const context = createContext({});
|
|
40
50
|
const VitusLabsProvider = context.Provider;
|
|
41
51
|
const Provider = ({ theme, children, ...props }) => {
|
|
52
|
+
const ExternalProvider = useMemo(() => config.provider, []);
|
|
42
53
|
// eslint-disable-next-line react/jsx-no-useless-fragment
|
|
43
54
|
if (!theme || isEmpty(theme))
|
|
44
55
|
return React.createElement(React.Fragment, null, children);
|
|
45
|
-
const ExternalProvider = useMemo(() => config.provider, []);
|
|
46
56
|
if (ExternalProvider) {
|
|
47
57
|
return (React.createElement(VitusLabsProvider, { value: { theme, ...props } },
|
|
48
58
|
React.createElement(ExternalProvider, { theme: theme }, children)));
|
|
@@ -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/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 styled = styled\n provider = ThemeProvider\n component: ComponentType | HTMLTags = 'div'\n textComponent: ComponentType | HTMLTags = 'span'\n\n init = (props: Internal) => {\n this.css = props.css\n this.styled = props.styled\n this.provider = props.provider\n this.component = props.component\n this.textComponent = props.textComponent\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'\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 children: ReactNode\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 ExternalProvider = useMemo(() => config.provider, [])\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":[],"mappings":";;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M;;;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;;;;;"}
|
|
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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ha.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Vit Bokisch <vit@bokisch.cz>",
|
|
6
6
|
"maintainers": [
|
|
@@ -58,5 +58,5 @@
|
|
|
58
58
|
"@vitus-labs/tools-typescript": "^0.33.0",
|
|
59
59
|
"styled-components": "^5.3.5"
|
|
60
60
|
},
|
|
61
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "03d796adb63679864933e0259c7c48613602dc78"
|
|
62
62
|
}
|