@vitus-labs/attrs 1.2.0 → 1.2.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/index.js.html +1 -1
- package/lib/index.d.ts +7 -7
- package/lib/index.js.map +1 -1
- package/lib/types/init.d.ts +1 -1
- package/lib/types/init.d.ts.map +1 -1
- package/lib/types/types/AttrsComponent.d.ts +6 -6
- package/lib/types/types/AttrsComponent.d.ts.map +1 -1
- package/lib/types/types/InitAttrsComponent.d.ts +1 -1
- package/lib/types/types/InitAttrsComponent.d.ts.map +1 -1
- package/lib/types/types/utils.d.ts +1 -1
- package/lib/types/types/utils.d.ts.map +1 -1
- package/package.json +9 -9
|
@@ -5386,7 +5386,7 @@ var drawChart = (function (exports) {
|
|
|
5386
5386
|
</script>
|
|
5387
5387
|
<script>
|
|
5388
5388
|
/*<!--*/
|
|
5389
|
-
const data = {"version":2,"tree":{"name":"root","children":[{"name":"index.js","children":[{"name":"src","children":[{"name":"hooks/useRef.ts","uid":"
|
|
5389
|
+
const data = {"version":2,"tree":{"name":"root","children":[{"name":"index.js","children":[{"name":"src","children":[{"name":"hooks/useRef.ts","uid":"447c95d7-1"},{"name":"utils","children":[{"uid":"447c95d7-3","name":"attrs.ts"},{"uid":"447c95d7-7","name":"statics.ts"},{"uid":"447c95d7-9","name":"chaining.ts"},{"uid":"447c95d7-11","name":"compose.ts"}]},{"name":"hoc/attrsHoc.tsx","uid":"447c95d7-5"},{"uid":"447c95d7-13","name":"attrs.tsx"},{"uid":"447c95d7-15","name":"init.ts"},{"uid":"447c95d7-17","name":"isAttrsComponent.tsx"},{"uid":"447c95d7-19","name":"index.ts"}]}]}],"isRoot":true},"nodeParts":{"447c95d7-1":{"renderedLength":235,"gzipLength":144,"brotliLength":0,"metaUid":"447c95d7-0"},"447c95d7-3":{"renderedLength":488,"gzipLength":275,"brotliLength":0,"metaUid":"447c95d7-2"},"447c95d7-5":{"renderedLength":1229,"gzipLength":443,"brotliLength":0,"metaUid":"447c95d7-4"},"447c95d7-7":{"renderedLength":138,"gzipLength":124,"brotliLength":0,"metaUid":"447c95d7-6"},"447c95d7-9":{"renderedLength":244,"gzipLength":158,"brotliLength":0,"metaUid":"447c95d7-8"},"447c95d7-11":{"renderedLength":133,"gzipLength":125,"brotliLength":0,"metaUid":"447c95d7-10"},"447c95d7-13":{"renderedLength":4929,"gzipLength":1391,"brotliLength":0,"metaUid":"447c95d7-12"},"447c95d7-15":{"renderedLength":856,"gzipLength":364,"brotliLength":0,"metaUid":"447c95d7-14"},"447c95d7-17":{"renderedLength":252,"gzipLength":172,"brotliLength":0,"metaUid":"447c95d7-16"},"447c95d7-19":{"renderedLength":0,"gzipLength":0,"brotliLength":0,"metaUid":"447c95d7-18"}},"nodeMetas":{"447c95d7-0":{"id":"/src/hooks/useRef.ts","moduleParts":{"index.js":"447c95d7-1"},"imported":[{"uid":"447c95d7-21"}],"importedBy":[{"uid":"447c95d7-23"}]},"447c95d7-2":{"id":"/src/utils/attrs.ts","moduleParts":{"index.js":"447c95d7-3"},"imported":[{"uid":"447c95d7-20"}],"importedBy":[{"uid":"447c95d7-12"},{"uid":"447c95d7-4"}]},"447c95d7-4":{"id":"/src/hoc/attrsHoc.tsx","moduleParts":{"index.js":"447c95d7-5"},"imported":[{"uid":"447c95d7-21"},{"uid":"447c95d7-2"}],"importedBy":[{"uid":"447c95d7-24"}]},"447c95d7-6":{"id":"/src/utils/statics.ts","moduleParts":{"index.js":"447c95d7-7"},"imported":[{"uid":"447c95d7-20"}],"importedBy":[{"uid":"447c95d7-12"}]},"447c95d7-8":{"id":"/src/utils/chaining.ts","moduleParts":{"index.js":"447c95d7-9"},"imported":[],"importedBy":[{"uid":"447c95d7-12"}]},"447c95d7-10":{"id":"/src/utils/compose.ts","moduleParts":{"index.js":"447c95d7-11"},"imported":[],"importedBy":[{"uid":"447c95d7-12"}]},"447c95d7-12":{"id":"/src/attrs.tsx","moduleParts":{"index.js":"447c95d7-13"},"imported":[{"uid":"447c95d7-21"},{"uid":"447c95d7-22"},{"uid":"447c95d7-20"},{"uid":"447c95d7-23"},{"uid":"447c95d7-24"},{"uid":"447c95d7-6"},{"uid":"447c95d7-8"},{"uid":"447c95d7-10"},{"uid":"447c95d7-2"}],"importedBy":[{"uid":"447c95d7-14"}]},"447c95d7-14":{"id":"/src/init.ts","moduleParts":{"index.js":"447c95d7-15"},"imported":[{"uid":"447c95d7-20"},{"uid":"447c95d7-12"}],"importedBy":[{"uid":"447c95d7-18"}]},"447c95d7-16":{"id":"/src/isAttrsComponent.tsx","moduleParts":{"index.js":"447c95d7-17"},"imported":[],"importedBy":[{"uid":"447c95d7-18"}]},"447c95d7-18":{"id":"/src/index.ts","moduleParts":{"index.js":"447c95d7-19"},"imported":[{"uid":"447c95d7-14"},{"uid":"447c95d7-16"}],"importedBy":[],"isEntry":true},"447c95d7-20":{"id":"@vitus-labs/core","moduleParts":{},"imported":[],"importedBy":[{"uid":"447c95d7-14"},{"uid":"447c95d7-12"},{"uid":"447c95d7-6"},{"uid":"447c95d7-2"}],"isExternal":true},"447c95d7-21":{"id":"react","moduleParts":{},"imported":[],"importedBy":[{"uid":"447c95d7-12"},{"uid":"447c95d7-0"},{"uid":"447c95d7-4"}],"isExternal":true},"447c95d7-22":{"id":"hoist-non-react-statics","moduleParts":{},"imported":[],"importedBy":[{"uid":"447c95d7-12"}],"isExternal":true},"447c95d7-23":{"id":"/src/hooks/index.ts","moduleParts":{},"imported":[{"uid":"447c95d7-0"}],"importedBy":[{"uid":"447c95d7-12"}]},"447c95d7-24":{"id":"/src/hoc/index.ts","moduleParts":{},"imported":[{"uid":"447c95d7-4"}],"importedBy":[{"uid":"447c95d7-12"}]}},"env":{"rollup":"4.55.1"},"options":{"gzip":true,"brotli":false,"sourcemap":false}};
|
|
5390
5390
|
|
|
5391
5391
|
const run = () => {
|
|
5392
5392
|
const width = window.innerWidth;
|
package/lib/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import type { MergeTypes } from '@vitus-labs/tools-types';
|
|
|
5
5
|
import type { PropsWithoutRef } from 'react';
|
|
6
6
|
import type { RefAttributes } from 'react';
|
|
7
7
|
|
|
8
|
-
export declare type Attrs = <C extends ElementType
|
|
8
|
+
export declare type Attrs = <C extends ElementType>({ name, component, }: {
|
|
9
9
|
name: string;
|
|
10
10
|
component: C;
|
|
11
11
|
}) => ReturnType<InitAttrsComponent<C>>;
|
|
@@ -23,7 +23,7 @@ export declare type AttrsCb<A> = (props: Partial<A>) => Partial<A>;
|
|
|
23
23
|
* @param HOC High-order components
|
|
24
24
|
* @param DFP Calculated final component props
|
|
25
25
|
*/
|
|
26
|
-
export declare interface AttrsComponent<OA extends TObj = {}, EA extends TObj = {}, S extends TObj = {}, HOC extends TObj = {}, DFP extends Record<string, any> = MergeTypes<[OA, EA]>> extends ExoticComponent<DFP> {
|
|
26
|
+
export declare interface AttrsComponent<C extends ElementType = ElementType, OA extends TObj = {}, EA extends TObj = {}, S extends TObj = {}, HOC extends TObj = {}, DFP extends Record<string, any> = MergeTypes<[OA, EA]>> extends ExoticComponent<DFP> {
|
|
27
27
|
/**
|
|
28
28
|
* A chaining method to define default component theme
|
|
29
29
|
* @param param _object_
|
|
@@ -86,7 +86,7 @@ export declare interface AttrsComponent<OA extends TObj = {}, EA extends TObj =
|
|
|
86
86
|
* })
|
|
87
87
|
* ```
|
|
88
88
|
*/
|
|
89
|
-
config: <NC extends ElementType | unknown = unknown>({ name, component: NC, DEBUG, }: ConfigAttrs<NC>) => NC extends ElementType ? AttrsComponent<ExtractProps<NC>, EA, S, HOC> : AttrsComponent<OA, EA, S, HOC>;
|
|
89
|
+
config: <NC extends ElementType | unknown = unknown>({ name, component: NC, DEBUG, }: ConfigAttrs<NC>) => NC extends ElementType ? AttrsComponent<NC, ExtractProps<NC>, EA, S, HOC> : AttrsComponent<C, OA, EA, S, HOC>;
|
|
90
90
|
/**
|
|
91
91
|
* A chaining method to define default component props
|
|
92
92
|
* @param param Can be either _object_ or a _callback_
|
|
@@ -123,7 +123,7 @@ export declare interface AttrsComponent<OA extends TObj = {}, EA extends TObj =
|
|
|
123
123
|
* filter props will be omitted when passing to final component
|
|
124
124
|
*/
|
|
125
125
|
filter: P extends TObj ? Partial<keyof MergeTypes<[EA, P]>>[] : Partial<keyof EA>[];
|
|
126
|
-
}>) => P extends TObj ? AttrsComponent<OA, MergeTypes<[EA, P]>, S, HOC> : AttrsComponent<OA, EA, S, HOC>;
|
|
126
|
+
}>) => P extends TObj ? AttrsComponent<C, OA, MergeTypes<[EA, P]>, S, HOC> : AttrsComponent<C, OA, EA, S, HOC>;
|
|
127
127
|
/**
|
|
128
128
|
* A chaining method to define high-order components to wrap
|
|
129
129
|
* the defined component
|
|
@@ -155,7 +155,7 @@ export declare interface AttrsComponent<OA extends TObj = {}, EA extends TObj =
|
|
|
155
155
|
* const newElement = base.compose({ hocName: undefined })
|
|
156
156
|
* ```
|
|
157
157
|
*/
|
|
158
|
-
compose: <P extends ComposeParam>(param: P) => P extends TObj ? AttrsComponent<OA, EA, S, MergeTypes<[HOC, P]>> : AttrsComponent<OA, EA, S, HOC>;
|
|
158
|
+
compose: <P extends ComposeParam>(param: P) => P extends TObj ? AttrsComponent<C, OA, EA, S, MergeTypes<[HOC, P]>> : AttrsComponent<C, OA, EA, S, HOC>;
|
|
159
159
|
/**
|
|
160
160
|
* A chaining method to define statics on the attrs component.
|
|
161
161
|
* All statics are accessible via `is` static key on the component.
|
|
@@ -190,7 +190,7 @@ export declare interface AttrsComponent<OA extends TObj = {}, EA extends TObj =
|
|
|
190
190
|
* const newElement = base.statics({ isNewStatic: undefined })
|
|
191
191
|
* ```
|
|
192
192
|
*/
|
|
193
|
-
statics: <P extends TObj | unknown = unknown>(param: P) => P extends TObj ? AttrsComponent<OA, EA, MergeTypes<[S, P]>, HOC> : AttrsComponent<OA, EA, S, HOC>;
|
|
193
|
+
statics: <P extends TObj | unknown = unknown>(param: P) => P extends TObj ? AttrsComponent<C, OA, EA, MergeTypes<[S, P]>, HOC> : AttrsComponent<C, OA, EA, S, HOC>;
|
|
194
194
|
/**
|
|
195
195
|
* An access to all defined statics on the component.
|
|
196
196
|
*
|
|
@@ -304,7 +304,7 @@ declare type ExoticComponent<P extends Record<string, unknown> = {}> = ForwardRe
|
|
|
304
304
|
|
|
305
305
|
export declare type GenericHoc = (component: ElementType) => ElementType;
|
|
306
306
|
|
|
307
|
-
declare type InitAttrsComponent<C extends ElementType = ElementType> = (params: Configuration<C>) => AttrsComponent<ExtractProps<C>, {}, {}, {}>;
|
|
307
|
+
declare type InitAttrsComponent<C extends ElementType = ElementType> = (params: Configuration<C>) => AttrsComponent<C, ExtractProps<C>, {}, {}, {}>;
|
|
308
308
|
|
|
309
309
|
declare type InitConfiguration<C> = {
|
|
310
310
|
name?: string;
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/hooks/useRef.ts","../src/utils/attrs.ts","../src/hoc/attrsHoc.tsx","../src/utils/statics.ts","../src/utils/chaining.ts","../src/utils/compose.ts","../src/attrs.tsx","../src/init.ts","../src/isAttrsComponent.tsx"],"sourcesContent":["import { useRef, useImperativeHandle, type ForwardedRef } from 'react'\n\ntype UseAttrsRef = (props: {\n $attrsRef?: ForwardedRef<unknown>\n ref?: ForwardedRef<unknown>\n}) => ForwardedRef<unknown>\n\nconst useAttrsStyleRef: UseAttrsRef = ({ $attrsRef, ref }) => {\n const internalRef = useRef(null)\n\n useImperativeHandle($attrsRef, () => internalRef.current)\n useImperativeHandle(ref, () => internalRef.current)\n\n return internalRef\n}\n\nexport default useAttrsStyleRef\n","/* eslint-disable no-param-reassign */\nimport { isEmpty } from '@vitus-labs/core'\n\n// --------------------------------------------------------\n// Remove undefined props\n// --------------------------------------------------------\ntype RemoveUndefinedProps = <T extends Record<string, any>>(\n props: T,\n) => { [I in keyof T as T[I] extends undefined ? never : I]: T[I] }\n\nexport const removeUndefinedProps: RemoveUndefinedProps = (props) =>\n Object.keys(props).reduce((acc, key) => {\n const currentValue = props[key]\n if (currentValue !== undefined) return { ...acc, [key]: currentValue }\n return acc\n }, {} as any)\n\n// --------------------------------------------------------\n// combine values\n// --------------------------------------------------------\ntype OptionFunc<A> = (...arg: A[]) => Record<string, unknown>\ntype CalculateChainOptions = <A>(\n options?: OptionFunc<A>[],\n) => (args: A[]) => ReturnType<OptionFunc<A>>\n\nexport const calculateChainOptions: CalculateChainOptions =\n (options) => (args) => {\n const result = {}\n if (!options || isEmpty(options)) return result\n\n return options.reduce((acc, item) => Object.assign(acc, item(...args)), {})\n }\n","import React, {\n forwardRef,\n type ForwardRefExoticComponent,\n type ComponentType,\n} from 'react'\nimport { calculateChainOptions, removeUndefinedProps } from '~/utils/attrs'\nimport type { Configuration } from '~/types/configuration'\n\nexport type AttrsStyleHOC = ({\n attrs,\n priorityAttrs,\n}: Pick<Configuration, 'attrs' | 'priorityAttrs'>) => (\n WrappedComponent: ComponentType<any>,\n) => ForwardRefExoticComponent<any>\n\nconst createAttrsHOC: AttrsStyleHOC = ({ attrs, priorityAttrs }) => {\n // --------------------------------------------------\n // .attrs(...)\n // first we need to calculate final props which are\n // being returned by using `attr` chaining method\n // --------------------------------------------------\n const calculateAttrs = calculateChainOptions(attrs)\n const calculatePriorityAttrs = calculateChainOptions(priorityAttrs)\n\n const attrsHoc = (WrappedComponent: ComponentType<any>) =>\n forwardRef<any, any>((props, ref) => {\n // --------------------------------------------------\n // remove undefined props not to override potential default props\n // only props with value (e.g. `null`) should override default props\n // --------------------------------------------------\n const filteredProps = removeUndefinedProps(props)\n\n const prioritizedAttrs = calculatePriorityAttrs([filteredProps])\n\n const finalAttrs = calculateAttrs([\n {\n ...prioritizedAttrs,\n ...filteredProps,\n },\n ])\n\n return (\n <WrappedComponent\n $attrsRef={ref}\n {...prioritizedAttrs}\n {...finalAttrs}\n {...filteredProps}\n />\n )\n })\n\n return attrsHoc\n}\n\nexport default createAttrsHOC\n","import { isEmpty } from '@vitus-labs/core'\n\n// --------------------------------------------------------\n// helpers for create statics on component\n// --------------------------------------------------------\ntype CreateStaticsEnhancers = (params: {\n context: Record<string, any>\n options: Record<string, any>\n}) => void\n\nexport const createStaticsEnhancers: CreateStaticsEnhancers = ({\n context,\n options,\n}) => {\n if (!isEmpty(options)) {\n Object.assign(context, options)\n }\n}\n","type Func = (...args: any) => Record<string, unknown>\ntype Obj = Record<string, unknown>\n\n// --------------------------------------------------------\n// Chain Options\n// --------------------------------------------------------\ntype ChainOptions = (\n opts: Obj | Func | undefined,\n defaultOpts: Func[],\n) => Func[]\n\nexport const chainOptions: ChainOptions = (opts, defaultOpts = []) => {\n const result = [...defaultOpts]\n\n if (typeof opts === 'function') result.push(opts)\n else if (typeof opts === 'object') result.push(() => opts)\n\n return result\n}\n","/* eslint-disable import/prefer-default-export */\ntype CalculateHocsFuncs = (\n options: Record<string, any>,\n) => ((arg: any) => any)[]\n\nexport const calculateHocsFuncs: CalculateHocsFuncs = (options = {}) =>\n Object.values(options)\n .filter((item) => typeof item === 'function')\n .reverse()\n","/* eslint-disable @typescript-eslint/ban-ts-comment */\n/* eslint-disable no-underscore-dangle */\nimport React, { forwardRef } from 'react'\nimport hoistNonReactStatics from 'hoist-non-react-statics'\nimport { pick, compose, omit } from '@vitus-labs/core'\nimport { useRef } from '~/hooks'\nimport { attrsHoc } from '~/hoc'\nimport { createStaticsEnhancers } from '~/utils/statics'\nimport { chainOptions } from '~/utils/chaining'\nimport { calculateHocsFuncs } from '~/utils/compose'\nimport { calculateChainOptions } from '~/utils/attrs'\nimport type {\n AttrsComponent as AttrsComponentType,\n ExoticComponent,\n InnerComponentProps,\n} from '~/types/AttrsComponent'\nimport type { InitAttrsComponent } from '~/types/InitAttrsComponent'\nimport type {\n Configuration,\n ExtendedConfiguration,\n} from '~/types/configuration'\n\n// --------------------------------------------------------\n// cloneAndEnhance\n// helper function which allows function chaining\n// always returns attrsComponent with static functions\n// assigned\n// --------------------------------------------------------\ntype CloneAndEnhance = (\n defaultOpts: Configuration,\n opts: Partial<ExtendedConfiguration>,\n) => ReturnType<typeof attrsComponent>\n\nconst cloneAndEnhance: CloneAndEnhance = (defaultOpts, opts) =>\n // @ts-ignore\n attrsComponent({\n ...defaultOpts,\n attrs: chainOptions(opts.attrs, defaultOpts.attrs),\n filterAttrs: [\n ...(defaultOpts.filterAttrs ?? []),\n ...(opts.filterAttrs ?? []),\n ],\n priorityAttrs: chainOptions(opts.priorityAttrs, defaultOpts.priorityAttrs),\n statics: { ...defaultOpts.statics, ...opts.statics },\n compose: { ...defaultOpts.compose, ...opts.compose },\n })\n\n// --------------------------------------------------------\n// styleComponent\n// helper function which allows function chaining\n// always returns a valid React component with static functions\n// assigned, so it can be even rendered as a valid component\n// or styles can be extended via its statics\n// --------------------------------------------------------\n// @ts-ignore\nconst attrsComponent: InitAttrsComponent = (options) => {\n const componentName =\n options.name ?? options.component.displayName ?? options.component.name\n\n // --------------------------------------------------------\n // COMPONENT - Final component to be rendered\n // --------------------------------------------------------\n const RenderComponent = options.component\n\n // --------------------------------------------------------\n // COMPOSE - high-order components\n // --------------------------------------------------------\n const hocsFuncs = [attrsHoc(options), ...calculateHocsFuncs(options.compose)]\n\n // --------------------------------------------------------\n // ENHANCED COMPONENT (returned component)\n // --------------------------------------------------------\n // .attrs() chaining option is calculated in HOC and passed as props already\n // eslint-disable-next-line react/display-name\n const EnhancedComponent: ExoticComponent<InnerComponentProps> = forwardRef(\n (\n {\n $attrsRef, // it's forwarded from HOC which is always on top of all hocs\n ...props\n },\n ref,\n ) => {\n // --------------------------------------------------\n // handle refs\n // (1) one is passed from inner HOC - $attrsStyleRef\n // (2) second one is used to be used directly (e.g. inside hocs)\n // --------------------------------------------------\n const internalRef = useRef({ $attrsRef, ref })\n\n // --------------------------------------------------\n // final props\n // final props passed to WrappedComponent\n // excluding: styling props\n // including: $attrsStyle, $attrsState\n // --------------------------------------------------\n const newProps: Record<string, any> = {\n // this removes styling state from props and passes its state\n // under attrsState key only\n ...props,\n ref: ref ?? $attrsRef ? internalRef : undefined,\n }\n\n const finalProps: Record<string, any> = omit(\n newProps,\n options.filterAttrs,\n )\n\n // all the development stuff injected\n if (process.env.NODE_ENV !== 'production') {\n finalProps['data-attrs'] = componentName\n }\n\n return <RenderComponent {...finalProps} />\n },\n )\n\n // ------------------------------------------------------\n // This will hoist and generate dynamically next static methods\n // for all dimensions available in configuration\n // ------------------------------------------------------\n const AttrsComponent: AttrsComponentType = compose(...hocsFuncs)(\n EnhancedComponent,\n )\n\n AttrsComponent.IS_ATTRS = true\n AttrsComponent.displayName = componentName\n\n hoistNonReactStatics(AttrsComponent, options.component)\n\n // ------------------------------------------------------\n AttrsComponent.IS_ATTRS = true\n AttrsComponent.displayName = componentName\n AttrsComponent.meta = {}\n // ------------------------------------------------------\n\n // ------------------------------------------------------\n // enhance for statics\n // ------------------------------------------------------\n createStaticsEnhancers({\n context: AttrsComponent.meta,\n options: options.statics,\n })\n\n // @ts-ignore\n AttrsComponent.attrs = (attrs, { priority, filter } = {}) => {\n const result: Record<string, any> = {}\n\n if (filter) {\n result.filterAttrs = filter\n }\n\n if (priority) {\n result.priorityAttrs = attrs as ExtendedConfiguration['priorityAttrs']\n\n return cloneAndEnhance(options, result)\n }\n\n result.attrs = attrs as ExtendedConfiguration['attrs']\n\n return cloneAndEnhance(options, result)\n }\n\n // @ts-ignore\n AttrsComponent.config = (opts = {}) => {\n const result = pick(opts)\n\n return cloneAndEnhance(options, result)\n }\n\n // @ts-ignore\n AttrsComponent.statics = (opts) =>\n // @ts-ignore\n cloneAndEnhance(options, { statics: opts })\n\n AttrsComponent.getDefaultAttrs = (props) =>\n calculateChainOptions(options.attrs)([props])\n\n return AttrsComponent\n}\n\nexport default attrsComponent\n","import { isEmpty } from '@vitus-labs/core'\nimport attrsComponent from '~/attrs'\nimport type { ElementType } from '~/types/utils'\nimport type { InitAttrsComponent } from '~/types/InitAttrsComponent'\n\nexport type Attrs = <C extends ElementType<any>>({\n name,\n component,\n}: {\n name: string\n component: C\n}) => ReturnType<InitAttrsComponent<C>>\n\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nconst attrs: Attrs = ({ name, component }) => {\n // --------------------------------------------------------\n // handle ERRORS in development mode\n // --------------------------------------------------------\n if (process.env.NODE_ENV !== 'production') {\n type Errors = Partial<{\n component: string\n name: string\n }>\n\n const errors: Errors = {}\n if (!component) {\n errors.component = 'Parameter `component` is missing in params!'\n }\n\n if (!name) {\n errors.name = 'Parameter `name` is missing in params!'\n }\n\n if (!isEmpty(errors)) {\n throw Error(JSON.stringify(errors))\n }\n }\n\n return attrsComponent({\n name,\n component,\n attrs: [],\n priorityAttrs: [],\n filterAttrs: [],\n compose: {},\n statics: {},\n })\n}\n\nexport default attrs\n","export type IsAttrsComponent = <T>(component: T) => boolean\n\nconst isAttrsComponent: IsAttrsComponent = (component) => {\n if (\n component &&\n typeof component === 'object' &&\n component !== null &&\n Object.prototype.hasOwnProperty.call(component, 'IS_ATTRS')\n ) {\n return true\n }\n\n return false\n}\n\nexport default isAttrsComponent\n"],"names":["attrsHoc","useRef"],"mappings":";;;;AAOA,MAAM,gBAAgB,GAAgB,CAAC,EAAE,SAAS,EAAE,GAAG,EAAE,KAAI;AAC3D,IAAA,MAAM,WAAW,GAAG,MAAM,CAAC,IAAI,CAAC;IAEhC,mBAAmB,CAAC,SAAS,EAAE,MAAM,WAAW,CAAC,OAAO,CAAC;IACzD,mBAAmB,CAAC,GAAG,EAAE,MAAM,WAAW,CAAC,OAAO,CAAC;AAEnD,IAAA,OAAO,WAAW;AACpB,CAAC;;ACdD;AAUO,MAAM,oBAAoB,GAAyB,CAAC,KAAK,KAC9D,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,KAAI;AACrC,IAAA,MAAM,YAAY,GAAG,KAAK,CAAC,GAAG,CAAC;IAC/B,IAAI,YAAY,KAAK,SAAS;QAAE,OAAO,EAAE,GAAG,GAAG,E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,KAAI;;;;IAI3C,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,EAAE;QAMzC,MAAM,MAAM,GAAW,EAAE;QACzB,IAAI,CAAC,SAAS,EAAE;AACd,YAAA,MAAM,CAAC,SAAS,GAAG,6CAA6C;;QAGlE,IAAI,CAAC,IAAI,EAAE;AACT,YAAA,MAAM,CAAC,IAAI,GAAG,wCAAwC;;AAGxD,QAAA,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;YACpB,MAAM,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;;;AAIvC,IAAA,OAAO,cAAc,CAAC;QACpB,IAAI;QACJ,SAAS;AACT,QAAA,KAAK,EAAE,EAAE;AACT,QAAA,aAAa,EAAE,EAAE;AACjB,QAAA,WAAW,EAAE,EAAE;AACf,QAAA,OAAO,EAAE,EAAE;AACX,QAAA,OAAO,EAAE,EAAE;AACZ,KAAA,CAAC;AACJ;;AC9CA,MAAM,gBAAgB,GAAqB,CAAC,SAAS,KAAI;AACvD,IAAA,IACE,SAAS;QACT,OAAO,SAAS,KAAK,QAAQ;AAC7B,QAAA,SAAS,KAAK,IAAI;AAClB,QAAA,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,SAAS,EAAE,UAAU,CAAC,EAC3D;AACA,QAAA,OAAO,IAAI;;AAGb,IAAA,OAAO,KAAK;AACd;;;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/hooks/useRef.ts","../src/utils/attrs.ts","../src/hoc/attrsHoc.tsx","../src/utils/statics.ts","../src/utils/chaining.ts","../src/utils/compose.ts","../src/attrs.tsx","../src/init.ts","../src/isAttrsComponent.tsx"],"sourcesContent":["import { useRef, useImperativeHandle, type ForwardedRef } from 'react'\n\ntype UseAttrsRef = (props: {\n $attrsRef?: ForwardedRef<unknown>\n ref?: ForwardedRef<unknown>\n}) => ForwardedRef<unknown>\n\nconst useAttrsStyleRef: UseAttrsRef = ({ $attrsRef, ref }) => {\n const internalRef = useRef(null)\n\n useImperativeHandle($attrsRef, () => internalRef.current)\n useImperativeHandle(ref, () => internalRef.current)\n\n return internalRef\n}\n\nexport default useAttrsStyleRef\n","/* eslint-disable no-param-reassign */\nimport { isEmpty } from '@vitus-labs/core'\n\n// --------------------------------------------------------\n// Remove undefined props\n// --------------------------------------------------------\ntype RemoveUndefinedProps = <T extends Record<string, any>>(\n props: T,\n) => { [I in keyof T as T[I] extends undefined ? never : I]: T[I] }\n\nexport const removeUndefinedProps: RemoveUndefinedProps = (props) =>\n Object.keys(props).reduce((acc, key) => {\n const currentValue = props[key]\n if (currentValue !== undefined) return { ...acc, [key]: currentValue }\n return acc\n }, {} as any)\n\n// --------------------------------------------------------\n// combine values\n// --------------------------------------------------------\ntype OptionFunc<A> = (...arg: A[]) => Record<string, unknown>\ntype CalculateChainOptions = <A>(\n options?: OptionFunc<A>[],\n) => (args: A[]) => ReturnType<OptionFunc<A>>\n\nexport const calculateChainOptions: CalculateChainOptions =\n (options) => (args) => {\n const result = {}\n if (!options || isEmpty(options)) return result\n\n return options.reduce((acc, item) => Object.assign(acc, item(...args)), {})\n }\n","import React, {\n forwardRef,\n type ForwardRefExoticComponent,\n type ComponentType,\n} from 'react'\nimport { calculateChainOptions, removeUndefinedProps } from '~/utils/attrs'\nimport type { Configuration } from '~/types/configuration'\n\nexport type AttrsStyleHOC = ({\n attrs,\n priorityAttrs,\n}: Pick<Configuration, 'attrs' | 'priorityAttrs'>) => (\n WrappedComponent: ComponentType<any>,\n) => ForwardRefExoticComponent<any>\n\nconst createAttrsHOC: AttrsStyleHOC = ({ attrs, priorityAttrs }) => {\n // --------------------------------------------------\n // .attrs(...)\n // first we need to calculate final props which are\n // being returned by using `attr` chaining method\n // --------------------------------------------------\n const calculateAttrs = calculateChainOptions(attrs)\n const calculatePriorityAttrs = calculateChainOptions(priorityAttrs)\n\n const attrsHoc = (WrappedComponent: ComponentType<any>) =>\n forwardRef<any, any>((props, ref) => {\n // --------------------------------------------------\n // remove undefined props not to override potential default props\n // only props with value (e.g. `null`) should override default props\n // --------------------------------------------------\n const filteredProps = removeUndefinedProps(props)\n\n const prioritizedAttrs = calculatePriorityAttrs([filteredProps])\n\n const finalAttrs = calculateAttrs([\n {\n ...prioritizedAttrs,\n ...filteredProps,\n },\n ])\n\n return (\n <WrappedComponent\n $attrsRef={ref}\n {...prioritizedAttrs}\n {...finalAttrs}\n {...filteredProps}\n />\n )\n })\n\n return attrsHoc\n}\n\nexport default createAttrsHOC\n","import { isEmpty } from '@vitus-labs/core'\n\n// --------------------------------------------------------\n// helpers for create statics on component\n// --------------------------------------------------------\ntype CreateStaticsEnhancers = (params: {\n context: Record<string, any>\n options: Record<string, any>\n}) => void\n\nexport const createStaticsEnhancers: CreateStaticsEnhancers = ({\n context,\n options,\n}) => {\n if (!isEmpty(options)) {\n Object.assign(context, options)\n }\n}\n","type Func = (...args: any) => Record<string, unknown>\ntype Obj = Record<string, unknown>\n\n// --------------------------------------------------------\n// Chain Options\n// --------------------------------------------------------\ntype ChainOptions = (\n opts: Obj | Func | undefined,\n defaultOpts: Func[],\n) => Func[]\n\nexport const chainOptions: ChainOptions = (opts, defaultOpts = []) => {\n const result = [...defaultOpts]\n\n if (typeof opts === 'function') result.push(opts)\n else if (typeof opts === 'object') result.push(() => opts)\n\n return result\n}\n","/* eslint-disable import/prefer-default-export */\ntype CalculateHocsFuncs = (\n options: Record<string, any>,\n) => ((arg: any) => any)[]\n\nexport const calculateHocsFuncs: CalculateHocsFuncs = (options = {}) =>\n Object.values(options)\n .filter((item) => typeof item === 'function')\n .reverse()\n","/* eslint-disable @typescript-eslint/ban-ts-comment */\n/* eslint-disable no-underscore-dangle */\nimport React, { forwardRef } from 'react'\nimport hoistNonReactStatics from 'hoist-non-react-statics'\nimport { pick, compose, omit } from '@vitus-labs/core'\nimport { useRef } from '~/hooks'\nimport { attrsHoc } from '~/hoc'\nimport { createStaticsEnhancers } from '~/utils/statics'\nimport { chainOptions } from '~/utils/chaining'\nimport { calculateHocsFuncs } from '~/utils/compose'\nimport { calculateChainOptions } from '~/utils/attrs'\nimport type {\n AttrsComponent as AttrsComponentType,\n ExoticComponent,\n InnerComponentProps,\n} from '~/types/AttrsComponent'\nimport type { InitAttrsComponent } from '~/types/InitAttrsComponent'\nimport type {\n Configuration,\n ExtendedConfiguration,\n} from '~/types/configuration'\n\n// --------------------------------------------------------\n// cloneAndEnhance\n// helper function which allows function chaining\n// always returns attrsComponent with static functions\n// assigned\n// --------------------------------------------------------\ntype CloneAndEnhance = (\n defaultOpts: Configuration,\n opts: Partial<ExtendedConfiguration>,\n) => ReturnType<typeof attrsComponent>\n\nconst cloneAndEnhance: CloneAndEnhance = (defaultOpts, opts) =>\n // @ts-ignore\n attrsComponent({\n ...defaultOpts,\n attrs: chainOptions(opts.attrs, defaultOpts.attrs),\n filterAttrs: [\n ...(defaultOpts.filterAttrs ?? []),\n ...(opts.filterAttrs ?? []),\n ],\n priorityAttrs: chainOptions(opts.priorityAttrs, defaultOpts.priorityAttrs),\n statics: { ...defaultOpts.statics, ...opts.statics },\n compose: { ...defaultOpts.compose, ...opts.compose },\n })\n\n// --------------------------------------------------------\n// styleComponent\n// helper function which allows function chaining\n// always returns a valid React component with static functions\n// assigned, so it can be even rendered as a valid component\n// or styles can be extended via its statics\n// --------------------------------------------------------\n// @ts-ignore\nconst attrsComponent: InitAttrsComponent = (options) => {\n const componentName =\n options.name ?? options.component.displayName ?? options.component.name\n\n // --------------------------------------------------------\n // COMPONENT - Final component to be rendered\n // --------------------------------------------------------\n const RenderComponent = options.component\n\n // --------------------------------------------------------\n // COMPOSE - high-order components\n // --------------------------------------------------------\n const hocsFuncs = [attrsHoc(options), ...calculateHocsFuncs(options.compose)]\n\n // --------------------------------------------------------\n // ENHANCED COMPONENT (returned component)\n // --------------------------------------------------------\n // .attrs() chaining option is calculated in HOC and passed as props already\n // eslint-disable-next-line react/display-name\n const EnhancedComponent: ExoticComponent<InnerComponentProps> = forwardRef(\n (\n {\n $attrsRef, // it's forwarded from HOC which is always on top of all hocs\n ...props\n },\n ref,\n ) => {\n // --------------------------------------------------\n // handle refs\n // (1) one is passed from inner HOC - $attrsStyleRef\n // (2) second one is used to be used directly (e.g. inside hocs)\n // --------------------------------------------------\n const internalRef = useRef({ $attrsRef, ref })\n\n // --------------------------------------------------\n // final props\n // final props passed to WrappedComponent\n // excluding: styling props\n // including: $attrsStyle, $attrsState\n // --------------------------------------------------\n const newProps: Record<string, any> = {\n // this removes styling state from props and passes its state\n // under attrsState key only\n ...props,\n ref: ref ?? $attrsRef ? internalRef : undefined,\n }\n\n const finalProps: Record<string, any> = omit(\n newProps,\n options.filterAttrs,\n )\n\n // all the development stuff injected\n if (process.env.NODE_ENV !== 'production') {\n finalProps['data-attrs'] = componentName\n }\n\n return <RenderComponent {...finalProps} />\n },\n )\n\n // ------------------------------------------------------\n // This will hoist and generate dynamically next static methods\n // for all dimensions available in configuration\n // ------------------------------------------------------\n const AttrsComponent: AttrsComponentType = compose(...hocsFuncs)(\n EnhancedComponent,\n )\n\n AttrsComponent.IS_ATTRS = true\n AttrsComponent.displayName = componentName\n\n hoistNonReactStatics(AttrsComponent, options.component)\n\n // ------------------------------------------------------\n AttrsComponent.IS_ATTRS = true\n AttrsComponent.displayName = componentName\n AttrsComponent.meta = {}\n // ------------------------------------------------------\n\n // ------------------------------------------------------\n // enhance for statics\n // ------------------------------------------------------\n createStaticsEnhancers({\n context: AttrsComponent.meta,\n options: options.statics,\n })\n\n // @ts-ignore\n AttrsComponent.attrs = (attrs, { priority, filter } = {}) => {\n const result: Record<string, any> = {}\n\n if (filter) {\n result.filterAttrs = filter\n }\n\n if (priority) {\n result.priorityAttrs = attrs as ExtendedConfiguration['priorityAttrs']\n\n return cloneAndEnhance(options, result)\n }\n\n result.attrs = attrs as ExtendedConfiguration['attrs']\n\n return cloneAndEnhance(options, result)\n }\n\n // @ts-ignore\n AttrsComponent.config = (opts = {}) => {\n const result = pick(opts)\n\n return cloneAndEnhance(options, result)\n }\n\n // @ts-ignore\n AttrsComponent.statics = (opts) =>\n // @ts-ignore\n cloneAndEnhance(options, { statics: opts })\n\n AttrsComponent.getDefaultAttrs = (props) =>\n calculateChainOptions(options.attrs)([props])\n\n return AttrsComponent\n}\n\nexport default attrsComponent\n","import { isEmpty } from '@vitus-labs/core'\nimport attrsComponent from '~/attrs'\nimport type { ElementType } from '~/types/utils'\nimport type { InitAttrsComponent } from '~/types/InitAttrsComponent'\n\nexport type Attrs = <C extends ElementType>({\n name,\n component,\n}: {\n name: string\n component: C\n}) => ReturnType<InitAttrsComponent<C>>\n\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nconst attrs: Attrs = ({ name, component }) => {\n // --------------------------------------------------------\n // handle ERRORS in development mode\n // --------------------------------------------------------\n if (process.env.NODE_ENV !== 'production') {\n type Errors = Partial<{\n component: string\n name: string\n }>\n\n const errors: Errors = {}\n if (!component) {\n errors.component = 'Parameter `component` is missing in params!'\n }\n\n if (!name) {\n errors.name = 'Parameter `name` is missing in params!'\n }\n\n if (!isEmpty(errors)) {\n throw Error(JSON.stringify(errors))\n }\n }\n\n return attrsComponent({\n name,\n component,\n attrs: [],\n priorityAttrs: [],\n filterAttrs: [],\n compose: {},\n statics: {},\n })\n}\n\nexport default attrs\n","export type IsAttrsComponent = <T>(component: T) => boolean\n\nconst isAttrsComponent: IsAttrsComponent = (component) => {\n if (\n component &&\n typeof component === 'object' &&\n component !== null &&\n Object.prototype.hasOwnProperty.call(component, 'IS_ATTRS')\n ) {\n return true\n }\n\n return false\n}\n\nexport default isAttrsComponent\n"],"names":["attrsHoc","useRef"],"mappings":";;;;AAOA,MAAM,gBAAgB,GAAgB,CAAC,EAAE,SAAS,EAAE,GAAG,EAAE,KAAI;AAC3D,IAAA,MAAM,WAAW,GAAG,MAAM,CAAC,IAAI,CAAC;IAEhC,mBAAmB,CAAC,SAAS,EAAE,MAAM,WAAW,CAAC,OAAO,CAAC;IACzD,mB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,QAAA,OAAO,IAAI;IACb;AAEA,IAAA,OAAO,KAAK;AACd;;;;"}
|
package/lib/types/init.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ElementType } from "./types/utils";
|
|
2
2
|
import type { InitAttrsComponent } from "./types/InitAttrsComponent";
|
|
3
|
-
export type Attrs = <C extends ElementType
|
|
3
|
+
export type Attrs = <C extends ElementType>({ name, component, }: {
|
|
4
4
|
name: string;
|
|
5
5
|
component: C;
|
|
6
6
|
}) => ReturnType<InitAttrsComponent<C>>;
|
package/lib/types/init.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/init.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,sBAAqB;AAChD,OAAO,KAAK,EAAE,kBAAkB,EAAE,mCAAkC;AAEpE,MAAM,MAAM,KAAK,GAAG,CAAC,CAAC,SAAS,WAAW,
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/init.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,sBAAqB;AAChD,OAAO,KAAK,EAAE,kBAAkB,EAAE,mCAAkC;AAEpE,MAAM,MAAM,KAAK,GAAG,CAAC,CAAC,SAAS,WAAW,EAAE,EAC1C,IAAI,EACJ,SAAS,GACV,EAAE;IACD,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,EAAE,CAAC,CAAA;CACb,KAAK,UAAU,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAA;AAIvC,QAAA,MAAM,KAAK,EAAE,KAiCZ,CAAA;AAED,eAAe,KAAK,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ForwardedRef, ForwardRefExoticComponent, PropsWithoutRef, RefAttributes } from 'react';
|
|
2
|
-
import type {
|
|
2
|
+
import type { ExtractProps, MergeTypes } from '@vitus-labs/tools-types';
|
|
3
3
|
import type { TObj, ElementType } from './utils';
|
|
4
4
|
import type { ConfigAttrs } from './config';
|
|
5
5
|
import type { AttrsCb } from './attrs';
|
|
@@ -22,7 +22,7 @@ export type ExoticComponent<P extends Record<string, unknown> = {}> = ForwardRef
|
|
|
22
22
|
* @param HOC High-order components
|
|
23
23
|
* @param DFP Calculated final component props
|
|
24
24
|
*/
|
|
25
|
-
export interface AttrsComponent<OA extends TObj = {}, EA extends TObj = {}, S extends TObj = {}, HOC extends TObj = {}, DFP extends Record<string, any> = MergeTypes<[OA, EA]>> extends ExoticComponent<DFP> {
|
|
25
|
+
export interface AttrsComponent<C extends ElementType = ElementType, OA extends TObj = {}, EA extends TObj = {}, S extends TObj = {}, HOC extends TObj = {}, DFP extends Record<string, any> = MergeTypes<[OA, EA]>> extends ExoticComponent<DFP> {
|
|
26
26
|
/**
|
|
27
27
|
* A chaining method to define default component theme
|
|
28
28
|
* @param param _object_
|
|
@@ -85,7 +85,7 @@ export interface AttrsComponent<OA extends TObj = {}, EA extends TObj = {}, S ex
|
|
|
85
85
|
* })
|
|
86
86
|
* ```
|
|
87
87
|
*/
|
|
88
|
-
config: <NC extends ElementType | unknown = unknown>({ name, component: NC, DEBUG, }: ConfigAttrs<NC>) => NC extends ElementType ? AttrsComponent<ExtractProps<NC>, EA, S, HOC> : AttrsComponent<OA, EA, S, HOC>;
|
|
88
|
+
config: <NC extends ElementType | unknown = unknown>({ name, component: NC, DEBUG, }: ConfigAttrs<NC>) => NC extends ElementType ? AttrsComponent<NC, ExtractProps<NC>, EA, S, HOC> : AttrsComponent<C, OA, EA, S, HOC>;
|
|
89
89
|
/**
|
|
90
90
|
* A chaining method to define default component props
|
|
91
91
|
* @param param Can be either _object_ or a _callback_
|
|
@@ -122,7 +122,7 @@ export interface AttrsComponent<OA extends TObj = {}, EA extends TObj = {}, S ex
|
|
|
122
122
|
* filter props will be omitted when passing to final component
|
|
123
123
|
*/
|
|
124
124
|
filter: P extends TObj ? Partial<keyof MergeTypes<[EA, P]>>[] : Partial<keyof EA>[];
|
|
125
|
-
}>) => P extends TObj ? AttrsComponent<OA, MergeTypes<[EA, P]>, S, HOC> : AttrsComponent<OA, EA, S, HOC>;
|
|
125
|
+
}>) => P extends TObj ? AttrsComponent<C, OA, MergeTypes<[EA, P]>, S, HOC> : AttrsComponent<C, OA, EA, S, HOC>;
|
|
126
126
|
/**
|
|
127
127
|
* A chaining method to define high-order components to wrap
|
|
128
128
|
* the defined component
|
|
@@ -154,7 +154,7 @@ export interface AttrsComponent<OA extends TObj = {}, EA extends TObj = {}, S ex
|
|
|
154
154
|
* const newElement = base.compose({ hocName: undefined })
|
|
155
155
|
* ```
|
|
156
156
|
*/
|
|
157
|
-
compose: <P extends ComposeParam>(param: P) => P extends TObj ? AttrsComponent<OA, EA, S, MergeTypes<[HOC, P]>> : AttrsComponent<OA, EA, S, HOC>;
|
|
157
|
+
compose: <P extends ComposeParam>(param: P) => P extends TObj ? AttrsComponent<C, OA, EA, S, MergeTypes<[HOC, P]>> : AttrsComponent<C, OA, EA, S, HOC>;
|
|
158
158
|
/**
|
|
159
159
|
* A chaining method to define statics on the attrs component.
|
|
160
160
|
* All statics are accessible via `is` static key on the component.
|
|
@@ -189,7 +189,7 @@ export interface AttrsComponent<OA extends TObj = {}, EA extends TObj = {}, S ex
|
|
|
189
189
|
* const newElement = base.statics({ isNewStatic: undefined })
|
|
190
190
|
* ```
|
|
191
191
|
*/
|
|
192
|
-
statics: <P extends TObj | unknown = unknown>(param: P) => P extends TObj ? AttrsComponent<OA, EA, MergeTypes<[S, P]>, HOC> : AttrsComponent<OA, EA, S, HOC>;
|
|
192
|
+
statics: <P extends TObj | unknown = unknown>(param: P) => P extends TObj ? AttrsComponent<C, OA, EA, MergeTypes<[S, P]>, HOC> : AttrsComponent<C, OA, EA, S, HOC>;
|
|
193
193
|
/**
|
|
194
194
|
* An access to all defined statics on the component.
|
|
195
195
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AttrsComponent.d.ts","sourceRoot":"","sources":["../../../src/types/AttrsComponent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,yBAAyB,EACzB,eAAe,EACf,aAAa,EACd,MAAM,OAAO,CAAA;AACd,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"AttrsComponent.d.ts","sourceRoot":"","sources":["../../../src/types/AttrsComponent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,yBAAyB,EACzB,eAAe,EACf,aAAa,EACd,MAAM,OAAO,CAAA;AACd,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AACvE,OAAO,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAChD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAC3C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACtC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAA;AAEzC,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,WAAW,GAAG,WAAW,IAAI,CAAC,MAAM,EAAE;IAC7E,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,EAAE,CAAC,CAAA;CACb,KAAK,cAAc,CAElB,YAAY,CAAC,CAAC,CAAC,EAEf,EAAE,EACF,EAAE,EACF,EAAE,CACH,CAAA;AAED,MAAM,MAAM,mBAAmB,GAAG;IAChC,SAAS,CAAC,EAAE,YAAY,CAAC,OAAO,CAAC,CAAA;IACjC,YAAY,EAAE,MAAM,CAAA;CACrB,CAAA;AAED,MAAM,MAAM,eAAe,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,EAAE,IAChE,yBAAyB,CAAC,eAAe,CAAC,CAAC,CAAC,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC,GAAG;IACnE,QAAQ,CAAC,QAAQ,EAAE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IAEP,eAAe,EAAE,CAAC,KAAK,EAAE,IAAI,KAAK,IAAI,CAAA;IAEtC;;;;;;;;;;;;;OAaG;IACH,QAAQ,CAAC,aAAa,EAAE,EAAE,CAAA;IAC1B;;;;;;;;;;;;;;;OAeG;IACH,QAAQ,CAAC,eAAe,EAAE,EAAE,CAAA;IAC5B;;;;;;;;;;;;;OAaG;IACH,QAAQ,CAAC,OAAO,EAAE,GAAG,CAAA;IACrB;;OAEG;IACH,QAAQ,EAAE,IAAI,CAAA;IACd;;;;;;;;;;OAUG;IACH,WAAW,EAAE,MAAM,CAAA;CACpB"}
|
|
@@ -2,5 +2,5 @@ import type { ExtractProps } from '@vitus-labs/tools-types';
|
|
|
2
2
|
import type { ElementType } from './utils';
|
|
3
3
|
import type { Configuration } from './configuration';
|
|
4
4
|
import type { AttrsComponent } from './AttrsComponent';
|
|
5
|
-
export type InitAttrsComponent<C extends ElementType = ElementType> = (params: Configuration<C>) => AttrsComponent<ExtractProps<C>, {}, {}, {}>;
|
|
5
|
+
export type InitAttrsComponent<C extends ElementType = ElementType> = (params: Configuration<C>) => AttrsComponent<C, ExtractProps<C>, {}, {}, {}>;
|
|
6
6
|
//# sourceMappingURL=InitAttrsComponent.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InitAttrsComponent.d.ts","sourceRoot":"","sources":["../../../src/types/InitAttrsComponent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAC3D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAC1C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AACpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAEtD,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,WAAW,GAAG,WAAW,IAAI,CACpE,MAAM,EAAE,aAAa,CAAC,CAAC,CAAC,KACrB,cAAc,
|
|
1
|
+
{"version":3,"file":"InitAttrsComponent.d.ts","sourceRoot":"","sources":["../../../src/types/InitAttrsComponent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAC3D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAC1C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AACpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAEtD,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,WAAW,GAAG,WAAW,IAAI,CACpE,MAAM,EAAE,aAAa,CAAC,CAAC,CAAC,KACrB,cAAc,CACjB,CAAC,EAED,YAAY,CAAC,CAAC,CAAC,EAEf,EAAE,EACF,EAAE,EACF,EAAE,CACH,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ComponentType, ForwardRefExoticComponent, FC } from 'react';
|
|
2
|
-
import type {
|
|
2
|
+
import type { ExtractProps, MergeTypes } from '@vitus-labs/tools-types';
|
|
3
3
|
export type TObj = Record<string, unknown>;
|
|
4
4
|
export type TFn = (...args: any) => any;
|
|
5
5
|
export type CallBackParam = TObj | TFn;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/types/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,yBAAyB,EAAE,EAAE,EAAE,MAAM,OAAO,CAAA;AACzE,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/types/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,yBAAyB,EAAE,EAAE,EAAE,MAAM,OAAO,CAAA;AACzE,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AAEvE,MAAM,MAAM,I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AC,CAAC;CAAE,CAAA;AAEzE,MAAM,MAAM,aAAa,CAAC,CAAC,SAAS,GAAG,GAAG,IAAI,IAAI,CAAC,SAAS,GAAG,GAC3D,UAAU,CAAC,CAAC,CAAC,GACb,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitus-labs/attrs",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Vit Bokisch <vit@bokisch.cz>",
|
|
6
6
|
"maintainers": [
|
|
@@ -56,13 +56,13 @@
|
|
|
56
56
|
"hoist-non-react-statics": "^3.3.2"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
|
-
"@types/hoist-non-react-statics": "^3.3.
|
|
60
|
-
"@vitus-labs/core": "1.2.
|
|
61
|
-
"@vitus-labs/tools-babel": "^1.5.
|
|
62
|
-
"@vitus-labs/tools-rollup": "^1.5.
|
|
63
|
-
"@vitus-labs/tools-storybook": "^1.5.
|
|
64
|
-
"@vitus-labs/tools-types": "^1.5.
|
|
65
|
-
"@vitus-labs/tools-typescript": "^1.5.
|
|
59
|
+
"@types/hoist-non-react-statics": "^3.3.7",
|
|
60
|
+
"@vitus-labs/core": "1.2.2",
|
|
61
|
+
"@vitus-labs/tools-babel": "^1.5.1",
|
|
62
|
+
"@vitus-labs/tools-rollup": "^1.5.1",
|
|
63
|
+
"@vitus-labs/tools-storybook": "^1.5.1",
|
|
64
|
+
"@vitus-labs/tools-types": "^1.5.1",
|
|
65
|
+
"@vitus-labs/tools-typescript": "^1.5.1"
|
|
66
66
|
},
|
|
67
|
-
"gitHead": "
|
|
67
|
+
"gitHead": "7a4d4d7560941675c866162c77a63218684ff850"
|
|
68
68
|
}
|