@jfdevelops/react-layout 0.2.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/create-config/define-layout.cjs +149 -0
- package/dist/create-config/define-layout.cjs.map +1 -0
- package/dist/create-config/define-layout.d.cts +107 -0
- package/dist/create-config/define-layout.d.cts.map +1 -0
- package/dist/create-config/define-layout.d.mts +107 -0
- package/dist/create-config/define-layout.d.mts.map +1 -0
- package/dist/create-config/define-layout.mjs +149 -0
- package/dist/create-config/define-layout.mjs.map +1 -0
- package/dist/create-config/get-component.cjs +52 -0
- package/dist/create-config/get-component.cjs.map +1 -0
- package/dist/create-config/get-component.d.cts +62 -0
- package/dist/create-config/get-component.d.cts.map +1 -0
- package/dist/create-config/get-component.d.mts +62 -0
- package/dist/create-config/get-component.d.mts.map +1 -0
- package/dist/create-config/get-component.mjs +51 -0
- package/dist/create-config/get-component.mjs.map +1 -0
- package/dist/create-config/index.d.cts +3 -0
- package/dist/create-config/index.d.mts +3 -0
- package/dist/create-config/types.d.cts +42 -0
- package/dist/create-config/types.d.cts.map +1 -0
- package/dist/create-config/types.d.mts +42 -0
- package/dist/create-config/types.d.mts.map +1 -0
- package/dist/index.cjs +83 -11
- package/dist/index.d.cts +5 -7
- package/dist/index.d.mts +5 -7
- package/dist/index.mjs +5 -6
- package/dist/props.d.cts +6 -6
- package/dist/props.d.cts.map +1 -1
- package/dist/props.d.mts +6 -6
- package/dist/props.d.mts.map +1 -1
- package/dist/resource.cjs.map +1 -1
- package/dist/resource.d.cts +23 -3
- package/dist/resource.d.cts.map +1 -1
- package/dist/resource.d.mts +23 -3
- package/dist/resource.d.mts.map +1 -1
- package/dist/resource.mjs.map +1 -1
- package/dist/utils.cjs +5 -12
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +2 -1
- package/dist/utils.d.cts.map +1 -1
- package/dist/utils.d.mts +2 -1
- package/dist/utils.d.mts.map +1 -1
- package/dist/utils.mjs +5 -12
- package/dist/utils.mjs.map +1 -1
- package/package.json +5 -1
- package/dist/composable.cjs +0 -72
- package/dist/composable.cjs.map +0 -1
- package/dist/composable.d.cts +0 -44
- package/dist/composable.d.cts.map +0 -1
- package/dist/composable.d.mts +0 -44
- package/dist/composable.d.mts.map +0 -1
- package/dist/composable.mjs +0 -70
- package/dist/composable.mjs.map +0 -1
- package/dist/create-config.cjs +0 -101
- package/dist/create-config.cjs.map +0 -1
- package/dist/create-config.d.cts +0 -67
- package/dist/create-config.d.cts.map +0 -1
- package/dist/create-config.d.mts +0 -67
- package/dist/create-config.d.mts.map +0 -1
- package/dist/create-config.mjs +0 -101
- package/dist/create-config.mjs.map +0 -1
- package/dist/utils/capitalize.d.cts +0 -7
- package/dist/utils/capitalize.d.cts.map +0 -1
- package/dist/utils/capitalize.d.mts +0 -7
- package/dist/utils/capitalize.d.mts.map +0 -1
- package/dist/validators/base.cjs +0 -41
- package/dist/validators/base.cjs.map +0 -1
- package/dist/validators/base.d.cts +0 -18
- package/dist/validators/base.d.cts.map +0 -1
- package/dist/validators/base.d.mts +0 -18
- package/dist/validators/base.d.mts.map +0 -1
- package/dist/validators/base.mjs +0 -39
- package/dist/validators/base.mjs.map +0 -1
- package/dist/validators/builders.cjs +0 -137
- package/dist/validators/builders.cjs.map +0 -1
- package/dist/validators/builders.d.cts +0 -156
- package/dist/validators/builders.d.cts.map +0 -1
- package/dist/validators/builders.d.mts +0 -156
- package/dist/validators/builders.d.mts.map +0 -1
- package/dist/validators/builders.mjs +0 -136
- package/dist/validators/builders.mjs.map +0 -1
- package/dist/validators/component.cjs +0 -73
- package/dist/validators/component.cjs.map +0 -1
- package/dist/validators/component.d.cts +0 -28
- package/dist/validators/component.d.cts.map +0 -1
- package/dist/validators/component.d.mts +0 -28
- package/dist/validators/component.d.mts.map +0 -1
- package/dist/validators/component.mjs +0 -71
- package/dist/validators/component.mjs.map +0 -1
- package/dist/validators/enum.cjs +0 -27
- package/dist/validators/enum.cjs.map +0 -1
- package/dist/validators/enum.d.cts +0 -14
- package/dist/validators/enum.d.cts.map +0 -1
- package/dist/validators/enum.d.mts +0 -14
- package/dist/validators/enum.d.mts.map +0 -1
- package/dist/validators/enum.mjs +0 -27
- package/dist/validators/enum.mjs.map +0 -1
- package/dist/validators/index.d.cts +0 -10
- package/dist/validators/index.d.mts +0 -10
- package/dist/validators/literal.cjs +0 -25
- package/dist/validators/literal.cjs.map +0 -1
- package/dist/validators/literal.d.cts +0 -14
- package/dist/validators/literal.d.cts.map +0 -1
- package/dist/validators/literal.d.mts +0 -14
- package/dist/validators/literal.d.mts.map +0 -1
- package/dist/validators/literal.mjs +0 -25
- package/dist/validators/literal.mjs.map +0 -1
- package/dist/validators/object.cjs +0 -53
- package/dist/validators/object.cjs.map +0 -1
- package/dist/validators/object.d.cts +0 -14
- package/dist/validators/object.d.cts.map +0 -1
- package/dist/validators/object.d.mts +0 -14
- package/dist/validators/object.d.mts.map +0 -1
- package/dist/validators/object.mjs +0 -53
- package/dist/validators/object.mjs.map +0 -1
- package/dist/validators/primitive.cjs +0 -80
- package/dist/validators/primitive.cjs.map +0 -1
- package/dist/validators/primitive.d.cts +0 -33
- package/dist/validators/primitive.d.cts.map +0 -1
- package/dist/validators/primitive.d.mts +0 -33
- package/dist/validators/primitive.d.mts.map +0 -1
- package/dist/validators/primitive.mjs +0 -78
- package/dist/validators/primitive.mjs.map +0 -1
- package/dist/validators/types.d.cts +0 -71
- package/dist/validators/types.d.cts.map +0 -1
- package/dist/validators/types.d.mts +0 -71
- package/dist/validators/types.d.mts.map +0 -1
- package/dist/validators/union.cjs +0 -27
- package/dist/validators/union.cjs.map +0 -1
- package/dist/validators/union.d.cts +0 -14
- package/dist/validators/union.d.cts.map +0 -1
- package/dist/validators/union.d.mts +0 -14
- package/dist/validators/union.d.mts.map +0 -1
- package/dist/validators/union.mjs +0 -27
- package/dist/validators/union.mjs.map +0 -1
- package/dist/validators/validate-props.cjs +0 -20
- package/dist/validators/validate-props.cjs.map +0 -1
- package/dist/validators/validate-props.d.cts +0 -7
- package/dist/validators/validate-props.d.cts.map +0 -1
- package/dist/validators/validate-props.d.mts +0 -7
- package/dist/validators/validate-props.d.mts.map +0 -1
- package/dist/validators/validate-props.mjs +0 -19
- package/dist/validators/validate-props.mjs.map +0 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { AnyBuiltPropDefinition, ResolveLayoutProps, ResolveProps } from "./validators/types.mjs";
|
|
2
|
-
import { createPrimitivePropBuilder, createProp } from "./validators/builders.mjs";
|
|
3
|
-
import { validateProps } from "./validators/validate-props.mjs";
|
|
4
1
|
import { BaseComponent, MergeIntersection, Show, UnionToIntersection, pick } from "./utils.mjs";
|
|
5
2
|
import { LayoutResourceKey, NormalizeResource, NormalizeResources, ResourceDefinition, ResourceEnum, ResourceLayoutComponentProps, ResourceTree, normalizeResource, normalizeResources, toResourceEnum } from "./resource.mjs";
|
|
6
|
-
import { InPropsDefinition, InPropsFunction, InPropsObject, InPropsOptions, IncludedProps, InferredInProps, LayoutRenderProps } from "./props.mjs";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
|
|
3
|
+
import { InPropsDefinition, InPropsFunction, InPropsObject, InPropsOptions, IncludedProps, InferredInProps, LayoutRenderProps, MergedLayoutInProps } from "./props.mjs";
|
|
4
|
+
import { defineResourceLayout } from "./create-config/define-layout.mjs";
|
|
5
|
+
import { AnyComposableComponent, ComposableComponent, ComposableComponentCallable, ComposableComponents, ComposableNameContext, ComposablePresetComponent, ComposablePresetComponentCallProps, ComposablePresetMeta, ComposablePresetProps, ComposableResourceLayout, CreateLayoutComposable, DefinedComposableComponentRecord, LayoutComposablePresetProvider, LayoutComposablesFactory, MakeComposable, MakeComposableOptions, MergePresetProps, PresetPropsFromComposable, RequiredPresetLayoutProps, RequiredPresetRenderProps, ResolveLayoutComposables, collectComposablePresetEntries, createComposableComponent, createLayoutComposableFactory, defineComposableComponent, makeComposable, resolveComposablePresetProps, resolveLayoutComposables } from "@jfdevelops/react-layout-composables";
|
|
6
|
+
import { AnyBuiltPropDefinition, ExtractDefinitionValue, ResolveLayoutProps, ResolveProps, createPrimitivePropBuilder, createProp, isPropDefinitionShape, resolvePropDefinitionValues, validateProps } from "@jfdevelops/react-layout-validator";
|
|
7
|
+
export { type AnyBuiltPropDefinition, type AnyComposableComponent, type BaseComponent, type ComposableComponent, type ComposableComponentCallable, type ComposableComponents, type ComposableNameContext, type ComposablePresetComponent, type ComposablePresetComponentCallProps, type ComposablePresetMeta, type ComposablePresetProps, type ComposableResourceLayout, type CreateLayoutComposable, type DefinedComposableComponentRecord, type ExtractDefinitionValue, type InPropsDefinition, type InPropsFunction, type InPropsObject, type InPropsOptions, type IncludedProps, type InferredInProps, LayoutComposablePresetProvider, type LayoutComposablesFactory, type LayoutRenderProps, type LayoutResourceKey, type MakeComposable, type MakeComposableOptions, type MergeIntersection, type MergePresetProps, type MergedLayoutInProps, type NormalizeResource, type NormalizeResources, type PresetPropsFromComposable, type RequiredPresetLayoutProps, type RequiredPresetRenderProps, type ResolveLayoutComposables, type ResolveLayoutProps, type ResolveProps, type ResourceDefinition, type ResourceEnum, type ResourceLayoutComponentProps, type ResourceTree, type Show, type UnionToIntersection, collectComposablePresetEntries, createComposableComponent, createLayoutComposableFactory, createPrimitivePropBuilder, createProp, defineComposableComponent, defineResourceLayout, isPropDefinitionShape, makeComposable, normalizeResource, normalizeResources, pick, resolveComposablePresetProps, resolveLayoutComposables, resolvePropDefinitionValues, toResourceEnum, validateProps };
|
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { pick } from "./utils.mjs";
|
|
2
|
-
import { createComposableComponent, makeComposable } from "./composable.mjs";
|
|
3
|
-
import { createPrimitivePropBuilder, createProp } from "./validators/builders.mjs";
|
|
4
|
-
import { validateProps } from "./validators/validate-props.mjs";
|
|
5
1
|
import { normalizeResource, normalizeResources, toResourceEnum } from "./resource.mjs";
|
|
6
|
-
import {
|
|
2
|
+
import { pick } from "./utils.mjs";
|
|
3
|
+
import { defineResourceLayout } from "./create-config/define-layout.mjs";
|
|
4
|
+
import { LayoutComposablePresetProvider, collectComposablePresetEntries, createComposableComponent, createLayoutComposableFactory, defineComposableComponent, makeComposable, resolveComposablePresetProps, resolveLayoutComposables } from "@jfdevelops/react-layout-composables";
|
|
5
|
+
import { createPrimitivePropBuilder, createProp, isPropDefinitionShape, resolvePropDefinitionValues, validateProps } from "@jfdevelops/react-layout-validator";
|
|
7
6
|
|
|
8
|
-
export { createComposableComponent, createPrimitivePropBuilder, createProp, defineResourceLayout, makeComposable, normalizeResource, normalizeResources, pick, toResourceEnum, validateProps };
|
|
7
|
+
export { LayoutComposablePresetProvider, collectComposablePresetEntries, createComposableComponent, createLayoutComposableFactory, createPrimitivePropBuilder, createProp, defineComposableComponent, defineResourceLayout, isPropDefinitionShape, makeComposable, normalizeResource, normalizeResources, pick, resolveComposablePresetProps, resolveLayoutComposables, resolvePropDefinitionValues, toResourceEnum, validateProps };
|
package/dist/props.d.cts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { AnyBuiltPropDefinition, ResolveProps } from "./validators/types.cjs";
|
|
2
|
-
import { EnumWrappedProp, LiteralWrappedProp } from "./validators/builders.cjs";
|
|
3
1
|
import { Show } from "./utils.cjs";
|
|
4
2
|
import { ResourceDefinition, ResourceEnum } from "./resource.cjs";
|
|
3
|
+
import { ComposableComponents, InPropsObject, MergePresetProps } from "@jfdevelops/react-layout-composables";
|
|
4
|
+
import { EnumWrappedProp, LiteralWrappedProp, ResolveLayoutProps, ResolveProps } from "@jfdevelops/react-layout-validator";
|
|
5
5
|
|
|
6
6
|
//#region src/props.d.ts
|
|
7
|
-
type InPropsObject = Record<string, AnyBuiltPropDefinition>;
|
|
8
7
|
type InPropsOptions<Resources extends ReadonlyArray<ResourceDefinition>, Name extends string> = {
|
|
9
8
|
name: LiteralWrappedProp<Name, 'string', 'required'>;
|
|
10
9
|
resource: EnumWrappedProp<ResourceEnum<Resources>, 'string', 'required'>;
|
|
@@ -12,11 +11,12 @@ type InPropsOptions<Resources extends ReadonlyArray<ResourceDefinition>, Name ex
|
|
|
12
11
|
type InPropsFunction<Resources extends ReadonlyArray<ResourceDefinition>> = <Name extends string>(props: Show<InPropsOptions<Resources, Name>>) => InPropsObject;
|
|
13
12
|
type InPropsDefinition<Resources extends ReadonlyArray<ResourceDefinition>> = InPropsObject | InPropsFunction<Resources>;
|
|
14
13
|
type InferredInProps<Resources extends ReadonlyArray<ResourceDefinition>, Options extends InPropsDefinition<Resources>> = Options extends InPropsFunction<Resources> ? ReturnType<Options> : Options;
|
|
14
|
+
type MergedLayoutInProps<Resources extends ReadonlyArray<ResourceDefinition>, Options extends InPropsDefinition<Resources>, Composables extends ComposableComponents> = InferredInProps<Resources, Options> extends InPropsObject ? InferredInProps<Resources, Options> & MergePresetProps<Composables> : never;
|
|
15
15
|
/**
|
|
16
16
|
* A map of props to include in the layout.
|
|
17
17
|
*/
|
|
18
|
-
type IncludedProps<T> = { [
|
|
19
|
-
type LayoutRenderProps<Resources extends ReadonlyArray<ResourceDefinition>, Options extends InPropsDefinition<Resources>, IncludeProps extends IncludedProps<
|
|
18
|
+
type IncludedProps<T extends object> = { [K in keyof T & string]?: true };
|
|
19
|
+
type LayoutRenderProps<Resources extends ReadonlyArray<ResourceDefinition>, Options extends InPropsDefinition<Resources>, Composables extends ComposableComponents = {}, IncludeProps extends IncludedProps<MergedLayoutInProps<Resources, Options, Composables>> = {}, CustomProps extends InPropsObject = {}> = Show<ResolveProps<CustomProps> & ResolveLayoutProps<Pick<MergedLayoutInProps<Resources, Options, Composables>, keyof IncludeProps & string>>>;
|
|
20
20
|
//#endregion
|
|
21
|
-
export { InPropsDefinition, InPropsFunction, InPropsObject, InPropsOptions, IncludedProps, InferredInProps, LayoutRenderProps };
|
|
21
|
+
export { InPropsDefinition, InPropsFunction, type InPropsObject, InPropsOptions, IncludedProps, InferredInProps, LayoutRenderProps, MergedLayoutInProps };
|
|
22
22
|
//# sourceMappingURL=props.d.cts.map
|
package/dist/props.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"props.d.cts","names":[],"sources":["../src/props.ts"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"props.d.cts","names":[],"sources":["../src/props.ts"],"mappings":";;;;;;KAYY,cAAA,mBACQ,aAAA,CAAc,kBAAA;EAGhC,IAAA,EAAM,kBAAA,CAAmB,IAAA;EACzB,QAAA,EAAU,eAAA,CAAgB,YAAA,CAAa,SAAA;AAAA;AAAA,KAE7B,eAAA,mBACQ,aAAA,CAAc,kBAAA,2BAEhC,KAAA,EAAO,IAAA,CAAK,cAAA,CAAe,SAAA,EAAW,IAAA,OACnC,aAAA;AAAA,KACO,iBAAA,mBACQ,aAAA,CAAc,kBAAA,KAC9B,aAAA,GAAgB,eAAA,CAAgB,SAAA;AAAA,KACxB,eAAA,mBACQ,aAAA,CAAc,kBAAA,mBAChB,iBAAA,CAAkB,SAAA,KAChC,OAAA,SAAgB,eAAA,CAAgB,SAAA,IAAa,UAAA,CAAW,OAAA,IAAW,OAAA;AAAA,KAC3D,mBAAA,mBACQ,aAAA,CAAc,kBAAA,mBAChB,iBAAA,CAAkB,SAAA,uBACd,oBAAA,IAClB,eAAA,CAAgB,SAAA,EAAW,OAAA,UAAiB,aAAA,GAC5C,eAAA,CAAgB,SAAA,EAAW,OAAA,IAAW,gBAAA,CAAiB,WAAA;;;;KAK/C,aAAA,mCACE,CAAC;AAAA,KAEH,iBAAA,mBACQ,aAAA,CAAc,kBAAA,mBAChB,iBAAA,CAAkB,SAAA,uBACd,oBAAA,4BACC,aAAA,CACnB,mBAAA,CAAoB,SAAA,EAAW,OAAA,EAAS,WAAA,6BAEtB,aAAA,SAClB,IAAA,CACF,YAAA,CAAa,WAAA,IACX,kBAAA,CACE,IAAA,CACE,mBAAA,CAAoB,SAAA,EAAW,OAAA,EAAS,WAAA,SAClC,YAAA"}
|
package/dist/props.d.mts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { AnyBuiltPropDefinition, ResolveProps } from "./validators/types.mjs";
|
|
2
|
-
import { EnumWrappedProp, LiteralWrappedProp } from "./validators/builders.mjs";
|
|
3
1
|
import { Show } from "./utils.mjs";
|
|
4
2
|
import { ResourceDefinition, ResourceEnum } from "./resource.mjs";
|
|
3
|
+
import { ComposableComponents, InPropsObject, MergePresetProps } from "@jfdevelops/react-layout-composables";
|
|
4
|
+
import { EnumWrappedProp, LiteralWrappedProp, ResolveLayoutProps, ResolveProps } from "@jfdevelops/react-layout-validator";
|
|
5
5
|
|
|
6
6
|
//#region src/props.d.ts
|
|
7
|
-
type InPropsObject = Record<string, AnyBuiltPropDefinition>;
|
|
8
7
|
type InPropsOptions<Resources extends ReadonlyArray<ResourceDefinition>, Name extends string> = {
|
|
9
8
|
name: LiteralWrappedProp<Name, 'string', 'required'>;
|
|
10
9
|
resource: EnumWrappedProp<ResourceEnum<Resources>, 'string', 'required'>;
|
|
@@ -12,11 +11,12 @@ type InPropsOptions<Resources extends ReadonlyArray<ResourceDefinition>, Name ex
|
|
|
12
11
|
type InPropsFunction<Resources extends ReadonlyArray<ResourceDefinition>> = <Name extends string>(props: Show<InPropsOptions<Resources, Name>>) => InPropsObject;
|
|
13
12
|
type InPropsDefinition<Resources extends ReadonlyArray<ResourceDefinition>> = InPropsObject | InPropsFunction<Resources>;
|
|
14
13
|
type InferredInProps<Resources extends ReadonlyArray<ResourceDefinition>, Options extends InPropsDefinition<Resources>> = Options extends InPropsFunction<Resources> ? ReturnType<Options> : Options;
|
|
14
|
+
type MergedLayoutInProps<Resources extends ReadonlyArray<ResourceDefinition>, Options extends InPropsDefinition<Resources>, Composables extends ComposableComponents> = InferredInProps<Resources, Options> extends InPropsObject ? InferredInProps<Resources, Options> & MergePresetProps<Composables> : never;
|
|
15
15
|
/**
|
|
16
16
|
* A map of props to include in the layout.
|
|
17
17
|
*/
|
|
18
|
-
type IncludedProps<T> = { [
|
|
19
|
-
type LayoutRenderProps<Resources extends ReadonlyArray<ResourceDefinition>, Options extends InPropsDefinition<Resources>, IncludeProps extends IncludedProps<
|
|
18
|
+
type IncludedProps<T extends object> = { [K in keyof T & string]?: true };
|
|
19
|
+
type LayoutRenderProps<Resources extends ReadonlyArray<ResourceDefinition>, Options extends InPropsDefinition<Resources>, Composables extends ComposableComponents = {}, IncludeProps extends IncludedProps<MergedLayoutInProps<Resources, Options, Composables>> = {}, CustomProps extends InPropsObject = {}> = Show<ResolveProps<CustomProps> & ResolveLayoutProps<Pick<MergedLayoutInProps<Resources, Options, Composables>, keyof IncludeProps & string>>>;
|
|
20
20
|
//#endregion
|
|
21
|
-
export { InPropsDefinition, InPropsFunction, InPropsObject, InPropsOptions, IncludedProps, InferredInProps, LayoutRenderProps };
|
|
21
|
+
export { InPropsDefinition, InPropsFunction, type InPropsObject, InPropsOptions, IncludedProps, InferredInProps, LayoutRenderProps, MergedLayoutInProps };
|
|
22
22
|
//# sourceMappingURL=props.d.mts.map
|
package/dist/props.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"props.d.mts","names":[],"sources":["../src/props.ts"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"props.d.mts","names":[],"sources":["../src/props.ts"],"mappings":";;;;;;KAYY,cAAA,mBACQ,aAAA,CAAc,kBAAA;EAGhC,IAAA,EAAM,kBAAA,CAAmB,IAAA;EACzB,QAAA,EAAU,eAAA,CAAgB,YAAA,CAAa,SAAA;AAAA;AAAA,KAE7B,eAAA,mBACQ,aAAA,CAAc,kBAAA,2BAEhC,KAAA,EAAO,IAAA,CAAK,cAAA,CAAe,SAAA,EAAW,IAAA,OACnC,aAAA;AAAA,KACO,iBAAA,mBACQ,aAAA,CAAc,kBAAA,KAC9B,aAAA,GAAgB,eAAA,CAAgB,SAAA;AAAA,KACxB,eAAA,mBACQ,aAAA,CAAc,kBAAA,mBAChB,iBAAA,CAAkB,SAAA,KAChC,OAAA,SAAgB,eAAA,CAAgB,SAAA,IAAa,UAAA,CAAW,OAAA,IAAW,OAAA;AAAA,KAC3D,mBAAA,mBACQ,aAAA,CAAc,kBAAA,mBAChB,iBAAA,CAAkB,SAAA,uBACd,oBAAA,IAClB,eAAA,CAAgB,SAAA,EAAW,OAAA,UAAiB,aAAA,GAC5C,eAAA,CAAgB,SAAA,EAAW,OAAA,IAAW,gBAAA,CAAiB,WAAA;;;;KAK/C,aAAA,mCACE,CAAC;AAAA,KAEH,iBAAA,mBACQ,aAAA,CAAc,kBAAA,mBAChB,iBAAA,CAAkB,SAAA,uBACd,oBAAA,4BACC,aAAA,CACnB,mBAAA,CAAoB,SAAA,EAAW,OAAA,EAAS,WAAA,6BAEtB,aAAA,SAClB,IAAA,CACF,YAAA,CAAa,WAAA,IACX,kBAAA,CACE,IAAA,CACE,mBAAA,CAAoB,SAAA,EAAW,OAAA,EAAS,WAAA,SAClC,YAAA"}
|
package/dist/resource.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resource.cjs","names":[],"sources":["../src/resource.ts"],"sourcesContent":["import { ReactNode } from 'react';\nimport { NonEmptyReadonlyArray } from '
|
|
1
|
+
{"version":3,"file":"resource.cjs","names":[],"sources":["../src/resource.ts"],"sourcesContent":["import { ReactNode } from 'react';\nimport { NonEmptyReadonlyArray } from '@jfdevelops/react-layout-validator';\nimport { MergeIntersection, UnionToIntersection } from './utils';\n\nexport type ResourceDefinition =\n | string\n | {\n value: string;\n subResources: ReadonlyArray<\n ResourceDefinition & {\n /**\n * Whether to allow any string as a sub resource.\n *\n * @default false\n */\n allowAnyString?: boolean;\n }\n >;\n };\n\nexport type ResourceTree = Record<\n string,\n {\n subResources: ResourceTree;\n }\n>;\n\nexport type NormalizeResource<Resource extends ResourceDefinition> =\n Resource extends string\n ? {\n [Key in Resource]: {\n subResources: {};\n };\n }\n : Resource extends {\n value: infer Value extends string;\n subResources: infer SubResources extends\n ReadonlyArray<ResourceDefinition>;\n }\n ? {\n [Key in Value]: {\n subResources: NormalizeResources<SubResources>;\n };\n }\n : never;\n\nexport type NormalizeResources<\n Resources extends ReadonlyArray<ResourceDefinition>,\n> = MergeIntersection<\n UnionToIntersection<NormalizeResource<Resources[number]>>\n>;\nexport type ResourceLayoutComponentProps = {\n children: ReactNode;\n};\n\nfunction normalizeResourceTree(resource: ResourceDefinition): ResourceTree {\n if (typeof resource === 'string') {\n return {\n [resource]: {\n subResources: {},\n },\n };\n }\n\n const { value, subResources } = resource;\n\n return {\n [value]: {\n subResources: normalizeResourcesTree(subResources),\n },\n };\n}\n\nfunction normalizeResourcesTree(\n resources: ReadonlyArray<ResourceDefinition>,\n): ResourceTree {\n const normalizedResources: ResourceTree = {};\n\n for (const resource of resources) {\n Object.assign(normalizedResources, normalizeResourceTree(resource));\n }\n\n return normalizedResources;\n}\n\nexport function normalizeResource(resource: ResourceDefinition): ResourceTree {\n return normalizeResourceTree(resource);\n}\n\nexport function normalizeResources<\n Resources extends ReadonlyArray<ResourceDefinition>,\n>(resources: Resources): NormalizeResources<Resources> {\n return normalizeResourcesTree(resources) as NormalizeResources<Resources>;\n}\n\ntype ResourceDefinitionValue<Resource extends ResourceDefinition> =\n Resource extends string\n ? Resource\n : Resource extends { value: infer Value extends string }\n ? Value\n : never;\n\n /**\n * Top-level resource names declared in a `resources` array. Preserves string\n * literal unions for const resource definitions (unlike `keyof` on the\n * normalized resource tree, which tends to widen to `string` in hovers).\n */\nexport type LayoutResourceKey<\n Resources extends ReadonlyArray<ResourceDefinition>,\n> = ResourceDefinitionValue<Resources[number]>;\n\nexport type ResourceDefinitionForKey<\n Resources extends ReadonlyArray<ResourceDefinition>,\n Key extends string,\n> = Extract<Resources[number], Key | { value: Key }>;\n\n/** `subResources` array declared on a layout resource. */\nexport type SubResourceDefinitionsFor<\n Resources extends ReadonlyArray<ResourceDefinition>,\n Resource extends LayoutResourceKey<Resources>,\n> = ResourceDefinitionForKey<Resources, Resource> extends {\n subResources: infer SubResources extends ReadonlyArray<ResourceDefinition>;\n}\n ? SubResources\n : readonly [];\n\ntype CanNestSubResourceParam<\n MaxDepth extends number,\n DepthAcc extends readonly unknown[],\n> = [...DepthAcc, unknown]['length'] extends MaxDepth ? false : true;\n\n/**\n * `subResource` route param: a slug at the current depth, or `{ resource, subResource }`\n * when that slug has nested `subResources` in the layout tree and `MaxDepth` allows it.\n */\nexport type RecursiveSubResourceParam<\n Resources extends ReadonlyArray<ResourceDefinition>,\n SubDefs extends ReadonlyArray<ResourceDefinition>,\n MaxDepth extends number = 6,\n DepthAcc extends readonly unknown[] = readonly [],\n> = LayoutResourceKey<SubDefs> extends infer Key\n ? Key extends LayoutResourceKey<SubDefs>\n ? CanNestSubResourceParam<MaxDepth, DepthAcc> extends true\n ? ResourceDefinitionForKey<SubDefs, Key> extends {\n subResources: infer Nested extends ReadonlyArray<ResourceDefinition>;\n }\n ? [LayoutResourceKey<Nested>] extends [never]\n ? Key\n :\n | Key\n | {\n resource: Key;\n subResource: RecursiveSubResourceParam<\n Resources,\n Nested,\n MaxDepth,\n readonly [...DepthAcc, unknown]\n >;\n }\n : Key\n : Key\n : never\n : never;\n\n/** Recursive `subResource` values for a layout resource (full tree depth). */\nexport type SubResourceParamForResource<\n Resources extends ReadonlyArray<ResourceDefinition>,\n Resource extends LayoutResourceKey<Resources>,\n> = [SubResourceDefinitionsFor<Resources, Resource>] extends [readonly []]\n ? never\n : RecursiveSubResourceParam<\n Resources,\n SubResourceDefinitionsFor<Resources, Resource>\n >;\n\nexport type GetSubResourceKeys<\n Resources extends ReadonlyArray<ResourceDefinition>,\n Resource extends LayoutResourceKey<Resources>,\n> = ResourceDefinitionForKey<Resources, Resource> extends {\n subResources: infer SubResources extends ReadonlyArray<ResourceDefinition>;\n}\n ? LayoutResourceKey<SubResources>\n : never;\nexport type ResourceEnum<Resources extends ReadonlyArray<ResourceDefinition>> =\n NonEmptyReadonlyArray<LayoutResourceKey<Resources>>;\nexport function toResourceEnum<\n Resources extends ReadonlyArray<ResourceDefinition>,\n>(resources: NormalizeResources<Resources>) {\n const keys = Object.keys(resources);\n\n if (keys.length === 0) {\n throw new Error('No resources provided');\n }\n\n return keys as unknown as ResourceEnum<Resources>;\n}\n"],"mappings":";;AAuDA,SAAS,sBAAsB,UAA4C;CACzE,IAAI,OAAO,aAAa,UACtB,OAAO,GACJ,WAAW,EACV,cAAc,CAAC,EACjB,EACF;CAGF,MAAM,EAAE,OAAO,iBAAiB;CAEhC,OAAO,GACJ,QAAQ,EACP,cAAc,uBAAuB,YAAY,EACnD,EACF;AACF;AAEA,SAAS,uBACP,WACc;CACd,MAAM,sBAAoC,CAAC;CAE3C,KAAK,MAAM,YAAY,WACrB,OAAO,OAAO,qBAAqB,sBAAsB,QAAQ,CAAC;CAGpE,OAAO;AACT;AAEA,SAAgB,kBAAkB,UAA4C;CAC5E,OAAO,sBAAsB,QAAQ;AACvC;AAEA,SAAgB,mBAEd,WAAqD;CACrD,OAAO,uBAAuB,SAAS;AACzC;AA4FA,SAAgB,eAEd,WAA0C;CAC1C,MAAM,OAAO,OAAO,KAAK,SAAS;CAElC,IAAI,KAAK,WAAW,GAClB,MAAM,IAAI,MAAM,uBAAuB;CAGzC,OAAO;AACT"}
|
package/dist/resource.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { NonEmptyReadonlyArray } from "./validators/types.cjs";
|
|
2
1
|
import { MergeIntersection, UnionToIntersection } from "./utils.cjs";
|
|
3
2
|
import { ReactNode } from "react";
|
|
3
|
+
import { NonEmptyReadonlyArray } from "@jfdevelops/react-layout-validator";
|
|
4
4
|
|
|
5
5
|
//#region src/resource.d.ts
|
|
6
6
|
type ResourceDefinition = string | {
|
|
@@ -38,10 +38,30 @@ type ResourceDefinitionValue<Resource extends ResourceDefinition> = Resource ext
|
|
|
38
38
|
* Top-level resource names declared in a `resources` array. Preserves string
|
|
39
39
|
* literal unions for const resource definitions (unlike `keyof` on the
|
|
40
40
|
* normalized resource tree, which tends to widen to `string` in hovers).
|
|
41
|
-
|
|
41
|
+
*/
|
|
42
42
|
type LayoutResourceKey<Resources extends ReadonlyArray<ResourceDefinition>> = ResourceDefinitionValue<Resources[number]>;
|
|
43
|
+
type ResourceDefinitionForKey<Resources extends ReadonlyArray<ResourceDefinition>, Key extends string> = Extract<Resources[number], Key | {
|
|
44
|
+
value: Key;
|
|
45
|
+
}>;
|
|
46
|
+
/** `subResources` array declared on a layout resource. */
|
|
47
|
+
type SubResourceDefinitionsFor<Resources extends ReadonlyArray<ResourceDefinition>, Resource extends LayoutResourceKey<Resources>> = ResourceDefinitionForKey<Resources, Resource> extends {
|
|
48
|
+
subResources: infer SubResources extends ReadonlyArray<ResourceDefinition>;
|
|
49
|
+
} ? SubResources : readonly [];
|
|
50
|
+
type CanNestSubResourceParam<MaxDepth extends number, DepthAcc extends readonly unknown[]> = [...DepthAcc, unknown]['length'] extends MaxDepth ? false : true;
|
|
51
|
+
/**
|
|
52
|
+
* `subResource` route param: a slug at the current depth, or `{ resource, subResource }`
|
|
53
|
+
* when that slug has nested `subResources` in the layout tree and `MaxDepth` allows it.
|
|
54
|
+
*/
|
|
55
|
+
type RecursiveSubResourceParam<Resources extends ReadonlyArray<ResourceDefinition>, SubDefs extends ReadonlyArray<ResourceDefinition>, MaxDepth extends number = 6, DepthAcc extends readonly unknown[] = readonly []> = LayoutResourceKey<SubDefs> extends infer Key ? Key extends LayoutResourceKey<SubDefs> ? CanNestSubResourceParam<MaxDepth, DepthAcc> extends true ? ResourceDefinitionForKey<SubDefs, Key> extends {
|
|
56
|
+
subResources: infer Nested extends ReadonlyArray<ResourceDefinition>;
|
|
57
|
+
} ? [LayoutResourceKey<Nested>] extends [never] ? Key : Key | {
|
|
58
|
+
resource: Key;
|
|
59
|
+
subResource: RecursiveSubResourceParam<Resources, Nested, MaxDepth, readonly [...DepthAcc, unknown]>;
|
|
60
|
+
} : Key : Key : never : never;
|
|
61
|
+
/** Recursive `subResource` values for a layout resource (full tree depth). */
|
|
62
|
+
type SubResourceParamForResource<Resources extends ReadonlyArray<ResourceDefinition>, Resource extends LayoutResourceKey<Resources>> = [SubResourceDefinitionsFor<Resources, Resource>] extends [readonly []] ? never : RecursiveSubResourceParam<Resources, SubResourceDefinitionsFor<Resources, Resource>>;
|
|
43
63
|
type ResourceEnum<Resources extends ReadonlyArray<ResourceDefinition>> = NonEmptyReadonlyArray<LayoutResourceKey<Resources>>;
|
|
44
64
|
declare function toResourceEnum<Resources extends ReadonlyArray<ResourceDefinition>>(resources: NormalizeResources<Resources>): ResourceEnum<Resources>;
|
|
45
65
|
//#endregion
|
|
46
|
-
export { LayoutResourceKey, NormalizeResource, NormalizeResources, ResourceDefinition, ResourceEnum, ResourceLayoutComponentProps, ResourceTree, normalizeResource, normalizeResources, toResourceEnum };
|
|
66
|
+
export { LayoutResourceKey, NormalizeResource, NormalizeResources, ResourceDefinition, ResourceDefinitionForKey, ResourceEnum, ResourceLayoutComponentProps, ResourceTree, SubResourceDefinitionsFor, SubResourceParamForResource, normalizeResource, normalizeResources, toResourceEnum };
|
|
47
67
|
//# sourceMappingURL=resource.d.cts.map
|
package/dist/resource.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resource.d.cts","names":[],"sources":["../src/resource.ts"],"mappings":";;;;;KAIY,kBAAA;EAGN,KAAA;EACA,YAAA,EAAc,aAAa,CACzB,kBAAA;
|
|
1
|
+
{"version":3,"file":"resource.d.cts","names":[],"sources":["../src/resource.ts"],"mappings":";;;;;KAIY,kBAAA;EAGN,KAAA;EACA,YAAA,EAAc,aAAa,CACzB,kBAAA;IALsB;;;;;IAWpB,cAAA;EAAA;AAAA;AAAA,KAKE,YAAA,GAAe,MAAM;EAG7B,YAAA,EAAc,YAAA;AAAA;AAAA,KAIN,iBAAA,kBAAmC,kBAAA,IAC7C,QAAA,4BAEc,QAAA;EACN,YAAA;AAAA,MAGJ,QAAA;EACI,KAAA;EACA,YAAA,6BACE,aAAA,CAAc,kBAAA;AAAA,cAGR,KAAA;EACN,YAAA,EAAc,kBAAA,CAAmB,YAAA;AAAA;AAAA,KAKjC,kBAAA,mBACQ,aAAA,CAAc,kBAAA,KAC9B,iBAAA,CACF,mBAAA,CAAoB,iBAAA,CAAkB,SAAA;AAAA,KAE5B,4BAAA;EACV,QAAA,EAAU,SAAS;AAAA;AAAA,iBAiCL,iBAAA,CAAkB,QAAA,EAAU,kBAAA,GAAqB,YAAY;AAAA,iBAI7D,kBAAA,mBACI,aAAA,CAAc,kBAAA,GAChC,SAAA,EAAW,SAAA,GAAY,kBAAA,CAAmB,SAAA;AAAA,KAIvC,uBAAA,kBAAyC,kBAAA,IAC5C,QAAA,kBACI,QAAA,GACA,QAAA;EAAmB,KAAA;AAAA,IACjB,KAAA;;;;;;KAQI,iBAAA,mBACQ,aAAA,CAAc,kBAAA,KAC9B,uBAAA,CAAwB,SAAA;AAAA,KAEhB,wBAAA,mBACQ,aAAA,CAAc,kBAAA,yBAE9B,OAAA,CAAQ,SAAA,UAAmB,GAAA;EAAQ,KAAA,EAAO,GAAA;AAAA;;KAGlC,yBAAA,mBACQ,aAAA,CAAc,kBAAA,oBACf,iBAAA,CAAkB,SAAA,KACjC,wBAAA,CAAyB,SAAA,EAAW,QAAA;EACtC,YAAA,6BAAyC,aAAA,CAAc,kBAAA;AAAA,IAErD,YAAA;AAAA,KAGC,uBAAA,qEAGG,QAAA,6BAAqC,QAAQ;;;;;KAMzC,yBAAA,mBACQ,aAAA,CAAc,kBAAA,mBAChB,aAAA,CAAc,kBAAA,qFAG5B,iBAAA,CAAkB,OAAA,sBAClB,GAAA,SAAY,iBAAA,CAAkB,OAAA,IAC5B,uBAAA,CAAwB,QAAA,EAAU,QAAA,iBAChC,wBAAA,CAAyB,OAAA,EAAS,GAAA;EAChC,YAAA,uBAAmC,aAAA,CAAc,kBAAA;AAAA,KAEhD,iBAAA,CAAkB,MAAA,qBACjB,GAAA,GAEI,GAAA;EAEE,QAAA,EAAU,GAAA;EACV,WAAA,EAAa,yBAAA,CACX,SAAA,EACA,MAAA,EACA,QAAA,eACa,QAAA;AAAA,IAGvB,GAAA,GACF,GAAA;;KAKI,2BAAA,mBACQ,aAAA,CAAc,kBAAA,oBACf,iBAAA,CAAkB,SAAA,MAChC,yBAAA,CAA0B,SAAA,EAAW,QAAA,mCAEtC,yBAAA,CACE,SAAA,EACA,yBAAA,CAA0B,SAAA,EAAW,QAAA;AAAA,KAW/B,YAAA,mBAA+B,aAAA,CAAc,kBAAA,KACvD,qBAAA,CAAsB,iBAAA,CAAkB,SAAA;AAAA,iBAC1B,cAAA,mBACI,aAAA,CAAc,kBAAA,GAChC,SAAA,EAAW,kBAAA,CAAmB,SAAA,IAOJ,YAAA,CAAa,SAAA"}
|
package/dist/resource.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { NonEmptyReadonlyArray } from "./validators/types.mjs";
|
|
2
1
|
import { MergeIntersection, UnionToIntersection } from "./utils.mjs";
|
|
2
|
+
import { NonEmptyReadonlyArray } from "@jfdevelops/react-layout-validator";
|
|
3
3
|
import { ReactNode } from "react";
|
|
4
4
|
|
|
5
5
|
//#region src/resource.d.ts
|
|
@@ -38,10 +38,30 @@ type ResourceDefinitionValue<Resource extends ResourceDefinition> = Resource ext
|
|
|
38
38
|
* Top-level resource names declared in a `resources` array. Preserves string
|
|
39
39
|
* literal unions for const resource definitions (unlike `keyof` on the
|
|
40
40
|
* normalized resource tree, which tends to widen to `string` in hovers).
|
|
41
|
-
|
|
41
|
+
*/
|
|
42
42
|
type LayoutResourceKey<Resources extends ReadonlyArray<ResourceDefinition>> = ResourceDefinitionValue<Resources[number]>;
|
|
43
|
+
type ResourceDefinitionForKey<Resources extends ReadonlyArray<ResourceDefinition>, Key extends string> = Extract<Resources[number], Key | {
|
|
44
|
+
value: Key;
|
|
45
|
+
}>;
|
|
46
|
+
/** `subResources` array declared on a layout resource. */
|
|
47
|
+
type SubResourceDefinitionsFor<Resources extends ReadonlyArray<ResourceDefinition>, Resource extends LayoutResourceKey<Resources>> = ResourceDefinitionForKey<Resources, Resource> extends {
|
|
48
|
+
subResources: infer SubResources extends ReadonlyArray<ResourceDefinition>;
|
|
49
|
+
} ? SubResources : readonly [];
|
|
50
|
+
type CanNestSubResourceParam<MaxDepth extends number, DepthAcc extends readonly unknown[]> = [...DepthAcc, unknown]['length'] extends MaxDepth ? false : true;
|
|
51
|
+
/**
|
|
52
|
+
* `subResource` route param: a slug at the current depth, or `{ resource, subResource }`
|
|
53
|
+
* when that slug has nested `subResources` in the layout tree and `MaxDepth` allows it.
|
|
54
|
+
*/
|
|
55
|
+
type RecursiveSubResourceParam<Resources extends ReadonlyArray<ResourceDefinition>, SubDefs extends ReadonlyArray<ResourceDefinition>, MaxDepth extends number = 6, DepthAcc extends readonly unknown[] = readonly []> = LayoutResourceKey<SubDefs> extends infer Key ? Key extends LayoutResourceKey<SubDefs> ? CanNestSubResourceParam<MaxDepth, DepthAcc> extends true ? ResourceDefinitionForKey<SubDefs, Key> extends {
|
|
56
|
+
subResources: infer Nested extends ReadonlyArray<ResourceDefinition>;
|
|
57
|
+
} ? [LayoutResourceKey<Nested>] extends [never] ? Key : Key | {
|
|
58
|
+
resource: Key;
|
|
59
|
+
subResource: RecursiveSubResourceParam<Resources, Nested, MaxDepth, readonly [...DepthAcc, unknown]>;
|
|
60
|
+
} : Key : Key : never : never;
|
|
61
|
+
/** Recursive `subResource` values for a layout resource (full tree depth). */
|
|
62
|
+
type SubResourceParamForResource<Resources extends ReadonlyArray<ResourceDefinition>, Resource extends LayoutResourceKey<Resources>> = [SubResourceDefinitionsFor<Resources, Resource>] extends [readonly []] ? never : RecursiveSubResourceParam<Resources, SubResourceDefinitionsFor<Resources, Resource>>;
|
|
43
63
|
type ResourceEnum<Resources extends ReadonlyArray<ResourceDefinition>> = NonEmptyReadonlyArray<LayoutResourceKey<Resources>>;
|
|
44
64
|
declare function toResourceEnum<Resources extends ReadonlyArray<ResourceDefinition>>(resources: NormalizeResources<Resources>): ResourceEnum<Resources>;
|
|
45
65
|
//#endregion
|
|
46
|
-
export { LayoutResourceKey, NormalizeResource, NormalizeResources, ResourceDefinition, ResourceEnum, ResourceLayoutComponentProps, ResourceTree, normalizeResource, normalizeResources, toResourceEnum };
|
|
66
|
+
export { LayoutResourceKey, NormalizeResource, NormalizeResources, ResourceDefinition, ResourceDefinitionForKey, ResourceEnum, ResourceLayoutComponentProps, ResourceTree, SubResourceDefinitionsFor, SubResourceParamForResource, normalizeResource, normalizeResources, toResourceEnum };
|
|
47
67
|
//# sourceMappingURL=resource.d.mts.map
|
package/dist/resource.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resource.d.mts","names":[],"sources":["../src/resource.ts"],"mappings":";;;;;KAIY,kBAAA;EAGN,KAAA;EACA,YAAA,EAAc,aAAa,CACzB,kBAAA;
|
|
1
|
+
{"version":3,"file":"resource.d.mts","names":[],"sources":["../src/resource.ts"],"mappings":";;;;;KAIY,kBAAA;EAGN,KAAA;EACA,YAAA,EAAc,aAAa,CACzB,kBAAA;IALsB;;;;;IAWpB,cAAA;EAAA;AAAA;AAAA,KAKE,YAAA,GAAe,MAAM;EAG7B,YAAA,EAAc,YAAA;AAAA;AAAA,KAIN,iBAAA,kBAAmC,kBAAA,IAC7C,QAAA,4BAEc,QAAA;EACN,YAAA;AAAA,MAGJ,QAAA;EACI,KAAA;EACA,YAAA,6BACE,aAAA,CAAc,kBAAA;AAAA,cAGR,KAAA;EACN,YAAA,EAAc,kBAAA,CAAmB,YAAA;AAAA;AAAA,KAKjC,kBAAA,mBACQ,aAAA,CAAc,kBAAA,KAC9B,iBAAA,CACF,mBAAA,CAAoB,iBAAA,CAAkB,SAAA;AAAA,KAE5B,4BAAA;EACV,QAAA,EAAU,SAAS;AAAA;AAAA,iBAiCL,iBAAA,CAAkB,QAAA,EAAU,kBAAA,GAAqB,YAAY;AAAA,iBAI7D,kBAAA,mBACI,aAAA,CAAc,kBAAA,GAChC,SAAA,EAAW,SAAA,GAAY,kBAAA,CAAmB,SAAA;AAAA,KAIvC,uBAAA,kBAAyC,kBAAA,IAC5C,QAAA,kBACI,QAAA,GACA,QAAA;EAAmB,KAAA;AAAA,IACjB,KAAA;;;;;;KAQI,iBAAA,mBACQ,aAAA,CAAc,kBAAA,KAC9B,uBAAA,CAAwB,SAAA;AAAA,KAEhB,wBAAA,mBACQ,aAAA,CAAc,kBAAA,yBAE9B,OAAA,CAAQ,SAAA,UAAmB,GAAA;EAAQ,KAAA,EAAO,GAAA;AAAA;;KAGlC,yBAAA,mBACQ,aAAA,CAAc,kBAAA,oBACf,iBAAA,CAAkB,SAAA,KACjC,wBAAA,CAAyB,SAAA,EAAW,QAAA;EACtC,YAAA,6BAAyC,aAAA,CAAc,kBAAA;AAAA,IAErD,YAAA;AAAA,KAGC,uBAAA,qEAGG,QAAA,6BAAqC,QAAQ;;;;;KAMzC,yBAAA,mBACQ,aAAA,CAAc,kBAAA,mBAChB,aAAA,CAAc,kBAAA,qFAG5B,iBAAA,CAAkB,OAAA,sBAClB,GAAA,SAAY,iBAAA,CAAkB,OAAA,IAC5B,uBAAA,CAAwB,QAAA,EAAU,QAAA,iBAChC,wBAAA,CAAyB,OAAA,EAAS,GAAA;EAChC,YAAA,uBAAmC,aAAA,CAAc,kBAAA;AAAA,KAEhD,iBAAA,CAAkB,MAAA,qBACjB,GAAA,GAEI,GAAA;EAEE,QAAA,EAAU,GAAA;EACV,WAAA,EAAa,yBAAA,CACX,SAAA,EACA,MAAA,EACA,QAAA,eACa,QAAA;AAAA,IAGvB,GAAA,GACF,GAAA;;KAKI,2BAAA,mBACQ,aAAA,CAAc,kBAAA,oBACf,iBAAA,CAAkB,SAAA,MAChC,yBAAA,CAA0B,SAAA,EAAW,QAAA,mCAEtC,yBAAA,CACE,SAAA,EACA,yBAAA,CAA0B,SAAA,EAAW,QAAA;AAAA,KAW/B,YAAA,mBAA+B,aAAA,CAAc,kBAAA,KACvD,qBAAA,CAAsB,iBAAA,CAAkB,SAAA;AAAA,iBAC1B,cAAA,mBACI,aAAA,CAAc,kBAAA,GAChC,SAAA,EAAW,kBAAA,CAAmB,SAAA,IAOJ,YAAA,CAAa,SAAA"}
|
package/dist/resource.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resource.mjs","names":[],"sources":["../src/resource.ts"],"sourcesContent":["import { ReactNode } from 'react';\nimport { NonEmptyReadonlyArray } from '
|
|
1
|
+
{"version":3,"file":"resource.mjs","names":[],"sources":["../src/resource.ts"],"sourcesContent":["import { ReactNode } from 'react';\nimport { NonEmptyReadonlyArray } from '@jfdevelops/react-layout-validator';\nimport { MergeIntersection, UnionToIntersection } from './utils';\n\nexport type ResourceDefinition =\n | string\n | {\n value: string;\n subResources: ReadonlyArray<\n ResourceDefinition & {\n /**\n * Whether to allow any string as a sub resource.\n *\n * @default false\n */\n allowAnyString?: boolean;\n }\n >;\n };\n\nexport type ResourceTree = Record<\n string,\n {\n subResources: ResourceTree;\n }\n>;\n\nexport type NormalizeResource<Resource extends ResourceDefinition> =\n Resource extends string\n ? {\n [Key in Resource]: {\n subResources: {};\n };\n }\n : Resource extends {\n value: infer Value extends string;\n subResources: infer SubResources extends\n ReadonlyArray<ResourceDefinition>;\n }\n ? {\n [Key in Value]: {\n subResources: NormalizeResources<SubResources>;\n };\n }\n : never;\n\nexport type NormalizeResources<\n Resources extends ReadonlyArray<ResourceDefinition>,\n> = MergeIntersection<\n UnionToIntersection<NormalizeResource<Resources[number]>>\n>;\nexport type ResourceLayoutComponentProps = {\n children: ReactNode;\n};\n\nfunction normalizeResourceTree(resource: ResourceDefinition): ResourceTree {\n if (typeof resource === 'string') {\n return {\n [resource]: {\n subResources: {},\n },\n };\n }\n\n const { value, subResources } = resource;\n\n return {\n [value]: {\n subResources: normalizeResourcesTree(subResources),\n },\n };\n}\n\nfunction normalizeResourcesTree(\n resources: ReadonlyArray<ResourceDefinition>,\n): ResourceTree {\n const normalizedResources: ResourceTree = {};\n\n for (const resource of resources) {\n Object.assign(normalizedResources, normalizeResourceTree(resource));\n }\n\n return normalizedResources;\n}\n\nexport function normalizeResource(resource: ResourceDefinition): ResourceTree {\n return normalizeResourceTree(resource);\n}\n\nexport function normalizeResources<\n Resources extends ReadonlyArray<ResourceDefinition>,\n>(resources: Resources): NormalizeResources<Resources> {\n return normalizeResourcesTree(resources) as NormalizeResources<Resources>;\n}\n\ntype ResourceDefinitionValue<Resource extends ResourceDefinition> =\n Resource extends string\n ? Resource\n : Resource extends { value: infer Value extends string }\n ? Value\n : never;\n\n /**\n * Top-level resource names declared in a `resources` array. Preserves string\n * literal unions for const resource definitions (unlike `keyof` on the\n * normalized resource tree, which tends to widen to `string` in hovers).\n */\nexport type LayoutResourceKey<\n Resources extends ReadonlyArray<ResourceDefinition>,\n> = ResourceDefinitionValue<Resources[number]>;\n\nexport type ResourceDefinitionForKey<\n Resources extends ReadonlyArray<ResourceDefinition>,\n Key extends string,\n> = Extract<Resources[number], Key | { value: Key }>;\n\n/** `subResources` array declared on a layout resource. */\nexport type SubResourceDefinitionsFor<\n Resources extends ReadonlyArray<ResourceDefinition>,\n Resource extends LayoutResourceKey<Resources>,\n> = ResourceDefinitionForKey<Resources, Resource> extends {\n subResources: infer SubResources extends ReadonlyArray<ResourceDefinition>;\n}\n ? SubResources\n : readonly [];\n\ntype CanNestSubResourceParam<\n MaxDepth extends number,\n DepthAcc extends readonly unknown[],\n> = [...DepthAcc, unknown]['length'] extends MaxDepth ? false : true;\n\n/**\n * `subResource` route param: a slug at the current depth, or `{ resource, subResource }`\n * when that slug has nested `subResources` in the layout tree and `MaxDepth` allows it.\n */\nexport type RecursiveSubResourceParam<\n Resources extends ReadonlyArray<ResourceDefinition>,\n SubDefs extends ReadonlyArray<ResourceDefinition>,\n MaxDepth extends number = 6,\n DepthAcc extends readonly unknown[] = readonly [],\n> = LayoutResourceKey<SubDefs> extends infer Key\n ? Key extends LayoutResourceKey<SubDefs>\n ? CanNestSubResourceParam<MaxDepth, DepthAcc> extends true\n ? ResourceDefinitionForKey<SubDefs, Key> extends {\n subResources: infer Nested extends ReadonlyArray<ResourceDefinition>;\n }\n ? [LayoutResourceKey<Nested>] extends [never]\n ? Key\n :\n | Key\n | {\n resource: Key;\n subResource: RecursiveSubResourceParam<\n Resources,\n Nested,\n MaxDepth,\n readonly [...DepthAcc, unknown]\n >;\n }\n : Key\n : Key\n : never\n : never;\n\n/** Recursive `subResource` values for a layout resource (full tree depth). */\nexport type SubResourceParamForResource<\n Resources extends ReadonlyArray<ResourceDefinition>,\n Resource extends LayoutResourceKey<Resources>,\n> = [SubResourceDefinitionsFor<Resources, Resource>] extends [readonly []]\n ? never\n : RecursiveSubResourceParam<\n Resources,\n SubResourceDefinitionsFor<Resources, Resource>\n >;\n\nexport type GetSubResourceKeys<\n Resources extends ReadonlyArray<ResourceDefinition>,\n Resource extends LayoutResourceKey<Resources>,\n> = ResourceDefinitionForKey<Resources, Resource> extends {\n subResources: infer SubResources extends ReadonlyArray<ResourceDefinition>;\n}\n ? LayoutResourceKey<SubResources>\n : never;\nexport type ResourceEnum<Resources extends ReadonlyArray<ResourceDefinition>> =\n NonEmptyReadonlyArray<LayoutResourceKey<Resources>>;\nexport function toResourceEnum<\n Resources extends ReadonlyArray<ResourceDefinition>,\n>(resources: NormalizeResources<Resources>) {\n const keys = Object.keys(resources);\n\n if (keys.length === 0) {\n throw new Error('No resources provided');\n }\n\n return keys as unknown as ResourceEnum<Resources>;\n}\n"],"mappings":";AAuDA,SAAS,sBAAsB,UAA4C;CACzE,IAAI,OAAO,aAAa,UACtB,OAAO,GACJ,WAAW,EACV,cAAc,CAAC,EACjB,EACF;CAGF,MAAM,EAAE,OAAO,iBAAiB;CAEhC,OAAO,GACJ,QAAQ,EACP,cAAc,uBAAuB,YAAY,EACnD,EACF;AACF;AAEA,SAAS,uBACP,WACc;CACd,MAAM,sBAAoC,CAAC;CAE3C,KAAK,MAAM,YAAY,WACrB,OAAO,OAAO,qBAAqB,sBAAsB,QAAQ,CAAC;CAGpE,OAAO;AACT;AAEA,SAAgB,kBAAkB,UAA4C;CAC5E,OAAO,sBAAsB,QAAQ;AACvC;AAEA,SAAgB,mBAEd,WAAqD;CACrD,OAAO,uBAAuB,SAAS;AACzC;AA4FA,SAAgB,eAEd,WAA0C;CAC1C,MAAM,OAAO,OAAO,KAAK,SAAS;CAElC,IAAI,KAAK,WAAW,GAClB,MAAM,IAAI,MAAM,uBAAuB;CAGzC,OAAO;AACT"}
|
package/dist/utils.cjs
CHANGED
|
@@ -1,16 +1,5 @@
|
|
|
1
1
|
|
|
2
2
|
//#region src/utils.ts
|
|
3
|
-
function isPropDefinitionShape(value) {
|
|
4
|
-
return typeof value === "function" && value !== null && "visibility" in value;
|
|
5
|
-
}
|
|
6
|
-
function resolvePropDefinitionValues(input) {
|
|
7
|
-
const out = {};
|
|
8
|
-
for (const key of Object.keys(input)) {
|
|
9
|
-
const value = input[key];
|
|
10
|
-
out[key] = isPropDefinitionShape(value) ? value._baseProp?.value : value;
|
|
11
|
-
}
|
|
12
|
-
return out;
|
|
13
|
-
}
|
|
14
3
|
function pick(obj, keys) {
|
|
15
4
|
if (keys.length === 0) return {};
|
|
16
5
|
return keys.reduce((acc, key) => {
|
|
@@ -18,8 +7,12 @@ function pick(obj, keys) {
|
|
|
18
7
|
return acc;
|
|
19
8
|
}, {});
|
|
20
9
|
}
|
|
10
|
+
function functionalUpdate(value, updater) {
|
|
11
|
+
if (typeof updater === "function") return updater(value);
|
|
12
|
+
return updater;
|
|
13
|
+
}
|
|
21
14
|
|
|
22
15
|
//#endregion
|
|
16
|
+
exports.functionalUpdate = functionalUpdate;
|
|
23
17
|
exports.pick = pick;
|
|
24
|
-
exports.resolvePropDefinitionValues = resolvePropDefinitionValues;
|
|
25
18
|
//# sourceMappingURL=utils.cjs.map
|
package/dist/utils.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.cjs","names":[],"sources":["../src/utils.ts"],"sourcesContent":["export type Show<T> = T extends (...args: infer A) => infer R\n ? (...args: A) => R\n : { [K in keyof T]: T[K] } & {};\nexport type MergeIntersection<T> = {\n [Key in keyof T]: T[Key];\n};\n\nexport type UnionToIntersection<Union> = (\n Union extends unknown ? (value: Union) => void : never\n) extends (value: infer Intersection) => void\n ? Intersection\n : never;\n\nexport interface BaseComponent<Name extends string, Props = {}> {\n /**\n * The name of the component. Useful for debugging and error messages.\n */\n displayName: Name;\n /**\n * A type only property to get the type of the props. At runtime,\n * this is `undefined`.\n */\n props: Props;\n}\n\
|
|
1
|
+
{"version":3,"file":"utils.cjs","names":[],"sources":["../src/utils.ts"],"sourcesContent":["export type Show<T> = T extends (...args: infer A) => infer R\n ? (...args: A) => R\n : { [K in keyof T]: T[K] } & {};\nexport type MergeIntersection<T> = {\n [Key in keyof T]: T[Key];\n};\nexport type IsUnion<T, U = T> = T extends unknown\n ? [U] extends [T]\n ? false\n : true\n : never;\nexport type UnionToIntersection<Union> = (\n Union extends unknown ? (value: Union) => void : never\n) extends (value: infer Intersection) => void\n ? Intersection\n : never;\nexport type Updater<T> = T | ((prev: T) => T);\n\nexport interface BaseComponent<Name extends string, Props = {}> {\n /**\n * The name of the component. Useful for debugging and error messages.\n */\n displayName: Name;\n /**\n * A type only property to get the type of the props. At runtime,\n * this is `undefined`.\n */\n props: Props;\n}\n\nexport function pick<T extends object, K extends keyof T>(obj: T, keys: K[]) {\n if (keys.length === 0) {\n return {} as Pick<T, K>;\n }\n\n return keys.reduce(\n (acc, key) => {\n if (key in obj) acc[key] = obj[key];\n\n return acc;\n },\n {} as Pick<T, K>,\n );\n}\n\nexport function functionalUpdate<T>(value: T, updater: Updater<T>){\n if (typeof updater === 'function') {\n return (updater as (prev: T) => T)(value);\n }\n\n return updater;\n}\n"],"mappings":";;AA8BA,SAAgB,KAA0C,KAAQ,MAAW;CAC3E,IAAI,KAAK,WAAW,GAClB,OAAO,CAAC;CAGV,OAAO,KAAK,QACT,KAAK,QAAQ;EACZ,IAAI,OAAO,KAAK,IAAI,OAAO,IAAI;EAE/B,OAAO;CACT,GACA,CAAC,CACH;AACF;AAEA,SAAgB,iBAAoB,OAAU,SAAoB;CAChE,IAAI,OAAO,YAAY,YACrB,OAAQ,QAA2B,KAAK;CAG1C,OAAO;AACT"}
|
package/dist/utils.d.cts
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
type Show<T> = T extends ((...args: infer A) => infer R) ? (...args: A) => R : { [K in keyof T]: T[K] } & {};
|
|
3
3
|
type MergeIntersection<T> = { [Key in keyof T]: T[Key] };
|
|
4
4
|
type UnionToIntersection<Union> = (Union extends unknown ? (value: Union) => void : never) extends ((value: infer Intersection) => void) ? Intersection : never;
|
|
5
|
+
type Updater<T> = T | ((prev: T) => T);
|
|
5
6
|
interface BaseComponent<Name extends string, Props = {}> {
|
|
6
7
|
/**
|
|
7
8
|
* The name of the component. Useful for debugging and error messages.
|
|
@@ -15,5 +16,5 @@ interface BaseComponent<Name extends string, Props = {}> {
|
|
|
15
16
|
}
|
|
16
17
|
declare function pick<T extends object, K extends keyof T>(obj: T, keys: K[]): Pick<T, K>;
|
|
17
18
|
//#endregion
|
|
18
|
-
export { BaseComponent, MergeIntersection, Show, UnionToIntersection, pick };
|
|
19
|
+
export { BaseComponent, MergeIntersection, Show, UnionToIntersection, Updater, pick };
|
|
19
20
|
//# sourceMappingURL=utils.d.cts.map
|
package/dist/utils.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.cts","names":[],"sources":["../src/utils.ts"],"mappings":";KAAY,IAAA,MAAU,CAAA,cAAc,IAAA,6BAC5B,IAAA,EAAM,CAAA,KAAM,CAAA,iBACF,CAAA,GAAI,CAAA,CAAE,CAAA;AAAA,KACZ,iBAAA,sBACI,CAAA,GAAI,CAAA,CAAE,GAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"utils.d.cts","names":[],"sources":["../src/utils.ts"],"mappings":";KAAY,IAAA,MAAU,CAAA,cAAc,IAAA,6BAC5B,IAAA,EAAM,CAAA,KAAM,CAAA,iBACF,CAAA,GAAI,CAAA,CAAE,CAAA;AAAA,KACZ,iBAAA,sBACI,CAAA,GAAI,CAAA,CAAE,GAAA;AAAA,KAOV,mBAAA,WACV,KAAA,oBAAyB,KAAA,EAAO,KAAK,6BAC5B,KAAA,iCACP,YAAA;AAAA,KAEQ,OAAA,MAAa,CAAA,KAAM,IAAA,EAAM,CAAA,KAAM,CAAA;AAAA,UAE1B,aAAA;EAhBQ;;;EAoBvB,WAAA,EAAa,IAAA;EAtBqB;;;;EA2BlC,KAAA,EAAO,KAAK;AAAA;AAAA,iBAGE,IAAA,mCAAuC,CAAA,EAAG,GAAA,EAAK,CAAA,EAAG,IAAA,EAAM,CAAA,KAAG,IAAA,CAAA,CAAA,EAAA,CAAA"}
|
package/dist/utils.d.mts
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
type Show<T> = T extends ((...args: infer A) => infer R) ? (...args: A) => R : { [K in keyof T]: T[K] } & {};
|
|
3
3
|
type MergeIntersection<T> = { [Key in keyof T]: T[Key] };
|
|
4
4
|
type UnionToIntersection<Union> = (Union extends unknown ? (value: Union) => void : never) extends ((value: infer Intersection) => void) ? Intersection : never;
|
|
5
|
+
type Updater<T> = T | ((prev: T) => T);
|
|
5
6
|
interface BaseComponent<Name extends string, Props = {}> {
|
|
6
7
|
/**
|
|
7
8
|
* The name of the component. Useful for debugging and error messages.
|
|
@@ -15,5 +16,5 @@ interface BaseComponent<Name extends string, Props = {}> {
|
|
|
15
16
|
}
|
|
16
17
|
declare function pick<T extends object, K extends keyof T>(obj: T, keys: K[]): Pick<T, K>;
|
|
17
18
|
//#endregion
|
|
18
|
-
export { BaseComponent, MergeIntersection, Show, UnionToIntersection, pick };
|
|
19
|
+
export { BaseComponent, MergeIntersection, Show, UnionToIntersection, Updater, pick };
|
|
19
20
|
//# sourceMappingURL=utils.d.mts.map
|
package/dist/utils.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.mts","names":[],"sources":["../src/utils.ts"],"mappings":";KAAY,IAAA,MAAU,CAAA,cAAc,IAAA,6BAC5B,IAAA,EAAM,CAAA,KAAM,CAAA,iBACF,CAAA,GAAI,CAAA,CAAE,CAAA;AAAA,KACZ,iBAAA,sBACI,CAAA,GAAI,CAAA,CAAE,GAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"utils.d.mts","names":[],"sources":["../src/utils.ts"],"mappings":";KAAY,IAAA,MAAU,CAAA,cAAc,IAAA,6BAC5B,IAAA,EAAM,CAAA,KAAM,CAAA,iBACF,CAAA,GAAI,CAAA,CAAE,CAAA;AAAA,KACZ,iBAAA,sBACI,CAAA,GAAI,CAAA,CAAE,GAAA;AAAA,KAOV,mBAAA,WACV,KAAA,oBAAyB,KAAA,EAAO,KAAK,6BAC5B,KAAA,iCACP,YAAA;AAAA,KAEQ,OAAA,MAAa,CAAA,KAAM,IAAA,EAAM,CAAA,KAAM,CAAA;AAAA,UAE1B,aAAA;EAhBQ;;;EAoBvB,WAAA,EAAa,IAAA;EAtBqB;;;;EA2BlC,KAAA,EAAO,KAAK;AAAA;AAAA,iBAGE,IAAA,mCAAuC,CAAA,EAAG,GAAA,EAAK,CAAA,EAAG,IAAA,EAAM,CAAA,KAAG,IAAA,CAAA,CAAA,EAAA,CAAA"}
|
package/dist/utils.mjs
CHANGED
|
@@ -1,15 +1,4 @@
|
|
|
1
1
|
//#region src/utils.ts
|
|
2
|
-
function isPropDefinitionShape(value) {
|
|
3
|
-
return typeof value === "function" && value !== null && "visibility" in value;
|
|
4
|
-
}
|
|
5
|
-
function resolvePropDefinitionValues(input) {
|
|
6
|
-
const out = {};
|
|
7
|
-
for (const key of Object.keys(input)) {
|
|
8
|
-
const value = input[key];
|
|
9
|
-
out[key] = isPropDefinitionShape(value) ? value._baseProp?.value : value;
|
|
10
|
-
}
|
|
11
|
-
return out;
|
|
12
|
-
}
|
|
13
2
|
function pick(obj, keys) {
|
|
14
3
|
if (keys.length === 0) return {};
|
|
15
4
|
return keys.reduce((acc, key) => {
|
|
@@ -17,7 +6,11 @@ function pick(obj, keys) {
|
|
|
17
6
|
return acc;
|
|
18
7
|
}, {});
|
|
19
8
|
}
|
|
9
|
+
function functionalUpdate(value, updater) {
|
|
10
|
+
if (typeof updater === "function") return updater(value);
|
|
11
|
+
return updater;
|
|
12
|
+
}
|
|
20
13
|
|
|
21
14
|
//#endregion
|
|
22
|
-
export {
|
|
15
|
+
export { functionalUpdate, pick };
|
|
23
16
|
//# sourceMappingURL=utils.mjs.map
|
package/dist/utils.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.mjs","names":[],"sources":["../src/utils.ts"],"sourcesContent":["export type Show<T> = T extends (...args: infer A) => infer R\n ? (...args: A) => R\n : { [K in keyof T]: T[K] } & {};\nexport type MergeIntersection<T> = {\n [Key in keyof T]: T[Key];\n};\n\nexport type UnionToIntersection<Union> = (\n Union extends unknown ? (value: Union) => void : never\n) extends (value: infer Intersection) => void\n ? Intersection\n : never;\n\nexport interface BaseComponent<Name extends string, Props = {}> {\n /**\n * The name of the component. Useful for debugging and error messages.\n */\n displayName: Name;\n /**\n * A type only property to get the type of the props. At runtime,\n * this is `undefined`.\n */\n props: Props;\n}\n\
|
|
1
|
+
{"version":3,"file":"utils.mjs","names":[],"sources":["../src/utils.ts"],"sourcesContent":["export type Show<T> = T extends (...args: infer A) => infer R\n ? (...args: A) => R\n : { [K in keyof T]: T[K] } & {};\nexport type MergeIntersection<T> = {\n [Key in keyof T]: T[Key];\n};\nexport type IsUnion<T, U = T> = T extends unknown\n ? [U] extends [T]\n ? false\n : true\n : never;\nexport type UnionToIntersection<Union> = (\n Union extends unknown ? (value: Union) => void : never\n) extends (value: infer Intersection) => void\n ? Intersection\n : never;\nexport type Updater<T> = T | ((prev: T) => T);\n\nexport interface BaseComponent<Name extends string, Props = {}> {\n /**\n * The name of the component. Useful for debugging and error messages.\n */\n displayName: Name;\n /**\n * A type only property to get the type of the props. At runtime,\n * this is `undefined`.\n */\n props: Props;\n}\n\nexport function pick<T extends object, K extends keyof T>(obj: T, keys: K[]) {\n if (keys.length === 0) {\n return {} as Pick<T, K>;\n }\n\n return keys.reduce(\n (acc, key) => {\n if (key in obj) acc[key] = obj[key];\n\n return acc;\n },\n {} as Pick<T, K>,\n );\n}\n\nexport function functionalUpdate<T>(value: T, updater: Updater<T>){\n if (typeof updater === 'function') {\n return (updater as (prev: T) => T)(value);\n }\n\n return updater;\n}\n"],"mappings":";AA8BA,SAAgB,KAA0C,KAAQ,MAAW;CAC3E,IAAI,KAAK,WAAW,GAClB,OAAO,CAAC;CAGV,OAAO,KAAK,QACT,KAAK,QAAQ;EACZ,IAAI,OAAO,KAAK,IAAI,OAAO,IAAI;EAE/B,OAAO;CACT,GACA,CAAC,CACH;AACF;AAEA,SAAgB,iBAAoB,OAAU,SAAoB;CAChE,IAAI,OAAO,YAAY,YACrB,OAAQ,QAA2B,KAAK;CAG1C,OAAO;AACT"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jfdevelops/react-layout",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "A React library for creating layout components.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -24,6 +24,10 @@
|
|
|
24
24
|
"engines": {
|
|
25
25
|
"node": "^20.19.0 || >=22.12.0"
|
|
26
26
|
},
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"@jfdevelops/react-layout-composables": "0.2.0",
|
|
29
|
+
"@jfdevelops/react-layout-validator": "0.2.0"
|
|
30
|
+
},
|
|
27
31
|
"peerDependencies": {
|
|
28
32
|
"react": ">=18",
|
|
29
33
|
"react-dom": ">=18"
|
package/dist/composable.cjs
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
const require_utils = require('./utils.cjs');
|
|
2
|
-
let react_jsx_runtime = require("react/jsx-runtime");
|
|
3
|
-
|
|
4
|
-
//#region src/composable.tsx
|
|
5
|
-
function resolveComponent(component, props) {
|
|
6
|
-
if (Object.keys(props).length > 0) return typeof component === "function" ? component(props) : component;
|
|
7
|
-
return component;
|
|
8
|
-
}
|
|
9
|
-
function reactNodeFromSingleFieldOutProps(resolved) {
|
|
10
|
-
if (resolved === null || typeof resolved !== "object") return null;
|
|
11
|
-
const values = Object.values(resolved);
|
|
12
|
-
if (values.length !== 1) return null;
|
|
13
|
-
return values[0];
|
|
14
|
-
}
|
|
15
|
-
function resolveComposableComponentName(name, ctx) {
|
|
16
|
-
return typeof name === "function" ? name(ctx) : name;
|
|
17
|
-
}
|
|
18
|
-
function createLayoutComposableFactory(ctx) {
|
|
19
|
-
const create = (options) => createComposableComponent({
|
|
20
|
-
...options,
|
|
21
|
-
name: resolveComposableComponentName(options.name, ctx)
|
|
22
|
-
});
|
|
23
|
-
return create;
|
|
24
|
-
}
|
|
25
|
-
function resolveLayoutComposables(factory, ctx) {
|
|
26
|
-
return factory(createLayoutComposableFactory(ctx));
|
|
27
|
-
}
|
|
28
|
-
function createComposableComponent(options) {
|
|
29
|
-
const { name, inProps = {}, outProps, wrapWith } = options;
|
|
30
|
-
function Composable({ children, ...props }) {
|
|
31
|
-
const inPropsKeys = Object.keys(inProps);
|
|
32
|
-
const mergedInProps = { ...inProps };
|
|
33
|
-
const propsRecord = props;
|
|
34
|
-
for (const key of inPropsKeys) if (key in propsRecord) mergedInProps[key] = propsRecord[key];
|
|
35
|
-
const wrapperProps = { ...propsRecord };
|
|
36
|
-
for (const key of inPropsKeys) delete wrapperProps[key];
|
|
37
|
-
const mergedResolved = require_utils.resolvePropDefinitionValues(mergedInProps);
|
|
38
|
-
const resolvedProps = outProps ? outProps(mergedResolved) : {};
|
|
39
|
-
const resolvedChildren = children == null ? reactNodeFromSingleFieldOutProps(resolvedProps) : resolveComponent(children, resolvedProps);
|
|
40
|
-
if (wrapWith) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(wrapWith, {
|
|
41
|
-
...wrapperProps,
|
|
42
|
-
children: resolvedChildren
|
|
43
|
-
});
|
|
44
|
-
return resolvedChildren;
|
|
45
|
-
}
|
|
46
|
-
Composable.displayName = name;
|
|
47
|
-
return Object.assign(Composable, { props: void 0 });
|
|
48
|
-
}
|
|
49
|
-
function makeComposable() {
|
|
50
|
-
return function(options) {
|
|
51
|
-
const { components, name: layoutName } = options;
|
|
52
|
-
if (!components || typeof components !== "object") throw new Error("components must be an object");
|
|
53
|
-
if (Object.keys(components).length === 0) throw new Error("components must have at least one component");
|
|
54
|
-
if (!("Layout" in components)) throw new Error("The Layout composable is required");
|
|
55
|
-
const create = (overrideOptions) => {
|
|
56
|
-
const resolvedName = overrideOptions?.name ?? layoutName;
|
|
57
|
-
const { Layout, ...rest } = components;
|
|
58
|
-
return Object.assign(Layout, {
|
|
59
|
-
displayName: resolvedName,
|
|
60
|
-
props: void 0,
|
|
61
|
-
...rest
|
|
62
|
-
});
|
|
63
|
-
};
|
|
64
|
-
return create;
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
//#endregion
|
|
69
|
-
exports.createComposableComponent = createComposableComponent;
|
|
70
|
-
exports.makeComposable = makeComposable;
|
|
71
|
-
exports.resolveLayoutComposables = resolveLayoutComposables;
|
|
72
|
-
//# sourceMappingURL=composable.cjs.map
|
package/dist/composable.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"composable.cjs","names":["resolvePropDefinitionValues","Comp"],"sources":["../src/composable.tsx"],"sourcesContent":["import { ComponentType, ReactNode } from 'react';\nimport { AnyBuiltPropDefinition, ResolveProps } from './validators';\nimport { InPropsObject } from './props';\nimport { BaseComponent, resolvePropDefinitionValues, Show } from './utils';\nimport { CapitalizeFn } from './utils/capitalize';\n\nexport type ComposableNameContext<\n Resource extends string,\n LayoutName extends string = string,\n> = {\n resource: Resource;\n name: LayoutName;\n capitalize: CapitalizeFn;\n};\n\ntype ComposableComponentName<\n Name extends string,\n Resource extends string,\n LayoutName extends string = string,\n> = Name | ((ctx: ComposableNameContext<Resource, LayoutName>) => Name);\n\ntype CreateComposableComponentOptions<\n Name extends string,\n Wrapper,\n Resource extends string,\n LayoutName extends string = string,\n InProps extends InPropsObject = {},\n OutProps = {},\n> = {\n name: ComposableComponentName<Name, Resource, LayoutName>;\n inProps?: InProps;\n outProps?: (props: Show<ResolveProps<InProps>>) => OutProps;\n wrapWith?: Wrapper;\n};\n\ntype ResolvedCreateComposableComponentOptions<\n Name extends string,\n Wrapper,\n Resource extends string,\n LayoutName extends string = string,\n InProps extends InPropsObject = {},\n OutProps = {},\n> = Omit<\n CreateComposableComponentOptions<\n Name,\n Wrapper,\n Resource,\n LayoutName,\n InProps,\n OutProps\n >,\n 'name'\n> & {\n name: Name;\n};\n\nexport type CreateLayoutComposable<\n Resources extends string,\n LayoutName extends string = string,\n> = <\n const Name extends string,\n Wrapper,\n InProps extends InPropsObject = {},\n OutProps = {},\n>(\n options: CreateComposableComponentOptions<\n Name,\n Wrapper,\n Resources,\n LayoutName,\n InProps,\n OutProps\n >,\n) => ComposableComponent<Name, Wrapper, InProps, OutProps>;\n\nexport type LayoutComposablesFactory<\n Resources extends string,\n LayoutName extends string = string,\n> = (\n create: CreateLayoutComposable<Resources, LayoutName>,\n) => ComposableComponents;\n\nexport type ResolveLayoutComposables<\n Factory extends LayoutComposablesFactory<string> | undefined,\n> = Factory extends LayoutComposablesFactory<string> ? ReturnType<Factory> : {};\ntype ComposableComponentWrapperProps<Wrapper> =\n Wrapper extends ComponentType<infer Props> ? Omit<Props, 'children'> : {};\ntype ComposableComponentProps<\n Wrapper,\n InProps extends InPropsObject = {},\n OutProps = {},\n> = ComposableComponentWrapperProps<Wrapper> &\n (keyof InProps extends never ? {} : ResolveProps<InProps>) & {\n children?: [keyof InProps] extends [never]\n ? ReactNode\n : ((props: OutProps) => JSX.Element) | ReactNode;\n };\nexport type ComposableComponent<\n Name extends string,\n Wrapper,\n InProps extends InPropsObject = {},\n OutProps = {},\n> = BaseComponent<Name, ResolveProps<InProps>> & {\n (props: ComposableComponentProps<Wrapper, InProps, OutProps>): ReactNode;\n};\nexport type ComposableResourceLayout<\n Composables extends ComposableComponents,\n Name extends string,\n Wrapper,\n InProps extends InPropsObject = {},\n OutProps = {},\n> = Composables & ComposableComponent<Name, Wrapper, InProps, OutProps>;\n\nexport type AnyComposableComponent = ComposableComponent<string, any, {}, {}>;\nexport type ComposableComponents = Record<string, AnyComposableComponent>;\nexport type ResolvedComposableComponents<\n Components extends ComposableComponents,\n> = [keyof Components] extends [never]\n ? never\n : Components extends { Layout: infer _ }\n ? Components\n : 'The Layout composable is required';\n\nfunction resolveComponent<Props>(\n component: ((props: Props) => JSX.Element | ReactNode) | ReactNode,\n props: Props,\n) {\n const hasProps = Object.keys(props as object).length > 0;\n\n if (hasProps) {\n return typeof component === 'function' ? component(props) : component;\n }\n\n return component as ReactNode;\n}\n\nfunction reactNodeFromSingleFieldOutProps(resolved: unknown): ReactNode {\n if (resolved === null || typeof resolved !== 'object') {\n return null;\n }\n const values = Object.values(resolved);\n if (values.length !== 1) {\n return null;\n }\n return values[0] as ReactNode;\n}\n\nfunction resolveComposableComponentName<\n Name extends string,\n Resource extends string,\n LayoutName extends string,\n>(\n name: ComposableComponentName<Name, Resource, LayoutName>,\n ctx: ComposableNameContext<Resource, LayoutName>,\n): Name {\n return typeof name === 'function' ? name(ctx) : name;\n}\n\nexport function createLayoutComposableFactory<\n Resources extends string,\n LayoutName extends string,\n>(ctx: ComposableNameContext<Resources, LayoutName>) {\n const create: CreateLayoutComposable<Resources, LayoutName> = <\n const Name extends string,\n Wrapper,\n InProps extends InPropsObject = {},\n OutProps = {},\n >(\n options: CreateComposableComponentOptions<\n Name,\n Wrapper,\n Resources,\n LayoutName,\n InProps,\n OutProps\n >,\n ) =>\n createComposableComponent({\n ...options,\n name: resolveComposableComponentName(options.name, ctx),\n } as ResolvedCreateComposableComponentOptions<\n Name,\n Wrapper,\n Resources,\n LayoutName,\n InProps,\n OutProps\n >);\n\n return create;\n}\n\nexport function resolveLayoutComposables<\n Resources extends string,\n LayoutName extends string,\n Composables extends ComposableComponents,\n>(\n factory: (\n create: CreateLayoutComposable<Resources, LayoutName>,\n ) => Composables,\n ctx: ComposableNameContext<Resources, LayoutName>,\n): Composables {\n return factory(createLayoutComposableFactory(ctx));\n}\n\nexport function createComposableComponent<\n const Name extends string,\n Wrapper,\n InProps extends InPropsObject = {},\n OutProps = {},\n>(\n options: ResolvedCreateComposableComponentOptions<\n Name,\n Wrapper,\n string,\n string,\n InProps,\n OutProps\n >,\n) {\n const { name, inProps = {} as InProps, outProps, wrapWith } = options;\n\n function Composable({\n children,\n ...props\n }: ComposableComponentProps<Wrapper, InProps, OutProps>) {\n const inPropsKeys = Object.keys(inProps as object) as (keyof InProps &\n string)[];\n const mergedInProps = { ...inProps };\n const propsRecord = props as Record<string, unknown>;\n for (const key of inPropsKeys) {\n if (key in propsRecord) {\n (mergedInProps as Record<string, unknown>)[key] = propsRecord[key];\n }\n }\n\n const wrapperProps = {\n ...propsRecord,\n } as ComposableComponentWrapperProps<Wrapper>;\n for (const key of inPropsKeys) {\n delete (wrapperProps as Record<string, unknown>)[key];\n }\n\n const mergedResolved = resolvePropDefinitionValues(\n mergedInProps as Record<string, unknown>,\n ) as Show<ResolveProps<InProps>>;\n\n const resolvedProps = outProps\n ? outProps(mergedResolved)\n : ({} as OutProps);\n const resolvedChildren =\n children == null\n ? reactNodeFromSingleFieldOutProps(resolvedProps)\n : resolveComponent(children, resolvedProps);\n\n if (wrapWith) {\n const Comp = wrapWith as ComponentType<\n ComposableComponentWrapperProps<Wrapper>\n >;\n\n return <Comp {...wrapperProps}>{resolvedChildren}</Comp>;\n }\n\n return resolvedChildren;\n }\n\n Composable.displayName = name;\n\n return Object.assign(Composable, {\n props: undefined as unknown as ResolveProps<InProps>,\n }) as unknown as ComposableComponent<Name, Wrapper, InProps, OutProps>;\n}\n\nexport type MakeComposableOptions<\n Composables extends ComposableComponents,\n Name extends string,\n> = { components: Composables | undefined; name: Name };\nexport type MakeComposable<\n Composables extends ComposableComponents,\n Name extends string,\n> = <OverrideName extends string = Name>(\n options?: Partial<\n Pick<MakeComposableOptions<Composables, OverrideName>, 'name'>\n >,\n) => ComposableResourceLayout<Composables, Name, any, any, any>;\n\nexport function makeComposable<Props>() {\n return function <\n Composables extends ComposableComponents,\n Name extends string,\n >(options: MakeComposableOptions<Composables, Name>) {\n const { components, name: layoutName } = options;\n\n if (!components || typeof components !== 'object') {\n throw new Error('components must be an object');\n }\n\n const componentNames = Object.keys(components);\n\n if (componentNames.length === 0) {\n throw new Error('components must have at least one component');\n }\n\n if (!('Layout' in components)) {\n throw new Error('The Layout composable is required');\n }\n\n const create: MakeComposable<Composables, Name> = (overrideOptions) => {\n const resolvedName = overrideOptions?.name ?? layoutName;\n const { Layout, ...rest } = components;\n\n return Object.assign(Layout, {\n displayName: resolvedName,\n props: undefined as unknown as Props,\n ...rest,\n }) as unknown as ComposableResourceLayout<\n Composables,\n Name,\n any,\n any,\n any\n >;\n };\n\n return create;\n };\n}\n"],"mappings":";;;;AA2HA,SAAS,iBACP,WACA,OACA;CAGA,IAFiB,OAAO,KAAK,KAAe,EAAE,SAAS,GAGrD,OAAO,OAAO,cAAc,aAAa,UAAU,KAAK,IAAI;CAG9D,OAAO;AACT;AAEA,SAAS,iCAAiC,UAA8B;CACtE,IAAI,aAAa,QAAQ,OAAO,aAAa,UAC3C,OAAO;CAET,MAAM,SAAS,OAAO,OAAO,QAAQ;CACrC,IAAI,OAAO,WAAW,GACpB,OAAO;CAET,OAAO,OAAO;AAChB;AAEA,SAAS,+BAKP,MACA,KACM;CACN,OAAO,OAAO,SAAS,aAAa,KAAK,GAAG,IAAI;AAClD;AAEA,SAAgB,8BAGd,KAAmD;CACnD,MAAM,UAMJ,YASA,0BAA0B;EACxB,GAAG;EACH,MAAM,+BAA+B,QAAQ,MAAM,GAAG;CACxD,CAOC;CAEH,OAAO;AACT;AAEA,SAAgB,yBAKd,SAGA,KACa;CACb,OAAO,QAAQ,8BAA8B,GAAG,CAAC;AACnD;AAEA,SAAgB,0BAMd,SAQA;CACA,MAAM,EAAE,MAAM,UAAU,CAAC,GAAc,UAAU,aAAa;CAE9D,SAAS,WAAW,EAClB,UACA,GAAG,SACoD;EACvD,MAAM,cAAc,OAAO,KAAK,OAAiB;EAEjD,MAAM,gBAAgB,EAAE,GAAG,QAAQ;EACnC,MAAM,cAAc;EACpB,KAAK,MAAM,OAAO,aAChB,IAAI,OAAO,aACT,AAAC,cAA0C,OAAO,YAAY;EAIlE,MAAM,eAAe,EACnB,GAAG,YACL;EACA,KAAK,MAAM,OAAO,aAChB,OAAQ,aAAyC;EAGnD,MAAM,iBAAiBA,0CACrB,aACF;EAEA,MAAM,gBAAgB,WAClB,SAAS,cAAc,IACtB,CAAC;EACN,MAAM,mBACJ,YAAY,OACR,iCAAiC,aAAa,IAC9C,iBAAiB,UAAU,aAAa;EAE9C,IAAI,UAKF,OAAO,2CAACC,UAAD;GAAM,GAAI;aAAe;EAAuB;EAGzD,OAAO;CACT;CAEA,WAAW,cAAc;CAEzB,OAAO,OAAO,OAAO,YAAY,EAC/B,OAAO,OACT,CAAC;AACH;AAeA,SAAgB,iBAAwB;CACtC,OAAO,SAGL,SAAmD;EACnD,MAAM,EAAE,YAAY,MAAM,eAAe;EAEzC,IAAI,CAAC,cAAc,OAAO,eAAe,UACvC,MAAM,IAAI,MAAM,8BAA8B;EAKhD,IAFuB,OAAO,KAAK,UAElB,EAAE,WAAW,GAC5B,MAAM,IAAI,MAAM,6CAA6C;EAG/D,IAAI,EAAE,YAAY,aAChB,MAAM,IAAI,MAAM,mCAAmC;EAGrD,MAAM,UAA6C,oBAAoB;GACrE,MAAM,eAAe,iBAAiB,QAAQ;GAC9C,MAAM,EAAE,QAAQ,GAAG,SAAS;GAE5B,OAAO,OAAO,OAAO,QAAQ;IAC3B,aAAa;IACb,OAAO;IACP,GAAG;GACL,CAAC;EAOH;EAEA,OAAO;CACT;AACF"}
|
package/dist/composable.d.cts
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { ResolveProps } from "./validators/types.cjs";
|
|
2
|
-
import { BaseComponent, Show } from "./utils.cjs";
|
|
3
|
-
import { InPropsObject } from "./props.cjs";
|
|
4
|
-
import { CapitalizeFn } from "./utils/capitalize.cjs";
|
|
5
|
-
import { ComponentType, ReactNode } from "react";
|
|
6
|
-
|
|
7
|
-
//#region src/composable.d.ts
|
|
8
|
-
type ComposableNameContext<Resource extends string, LayoutName extends string = string> = {
|
|
9
|
-
resource: Resource;
|
|
10
|
-
name: LayoutName;
|
|
11
|
-
capitalize: CapitalizeFn;
|
|
12
|
-
};
|
|
13
|
-
type ComposableComponentName<Name extends string, Resource extends string, LayoutName extends string = string> = Name | ((ctx: ComposableNameContext<Resource, LayoutName>) => Name);
|
|
14
|
-
type CreateComposableComponentOptions<Name extends string, Wrapper, Resource extends string, LayoutName extends string = string, InProps extends InPropsObject = {}, OutProps = {}> = {
|
|
15
|
-
name: ComposableComponentName<Name, Resource, LayoutName>;
|
|
16
|
-
inProps?: InProps;
|
|
17
|
-
outProps?: (props: Show<ResolveProps<InProps>>) => OutProps;
|
|
18
|
-
wrapWith?: Wrapper;
|
|
19
|
-
};
|
|
20
|
-
type ResolvedCreateComposableComponentOptions<Name extends string, Wrapper, Resource extends string, LayoutName extends string = string, InProps extends InPropsObject = {}, OutProps = {}> = Omit<CreateComposableComponentOptions<Name, Wrapper, Resource, LayoutName, InProps, OutProps>, 'name'> & {
|
|
21
|
-
name: Name;
|
|
22
|
-
};
|
|
23
|
-
type CreateLayoutComposable<Resources extends string, LayoutName extends string = string> = <const Name extends string, Wrapper, InProps extends InPropsObject = {}, OutProps = {}>(options: CreateComposableComponentOptions<Name, Wrapper, Resources, LayoutName, InProps, OutProps>) => ComposableComponent<Name, Wrapper, InProps, OutProps>;
|
|
24
|
-
type LayoutComposablesFactory<Resources extends string, LayoutName extends string = string> = (create: CreateLayoutComposable<Resources, LayoutName>) => ComposableComponents;
|
|
25
|
-
type ComposableComponentWrapperProps<Wrapper> = Wrapper extends ComponentType<infer Props> ? Omit<Props, 'children'> : {};
|
|
26
|
-
type ComposableComponentProps<Wrapper, InProps extends InPropsObject = {}, OutProps = {}> = ComposableComponentWrapperProps<Wrapper> & (keyof InProps extends never ? {} : ResolveProps<InProps>) & {
|
|
27
|
-
children?: [keyof InProps] extends [never] ? ReactNode : ((props: OutProps) => JSX.Element) | ReactNode;
|
|
28
|
-
};
|
|
29
|
-
type ComposableComponent<Name extends string, Wrapper, InProps extends InPropsObject = {}, OutProps = {}> = BaseComponent<Name, ResolveProps<InProps>> & {
|
|
30
|
-
(props: ComposableComponentProps<Wrapper, InProps, OutProps>): ReactNode;
|
|
31
|
-
};
|
|
32
|
-
type ComposableResourceLayout<Composables extends ComposableComponents, Name extends string, Wrapper, InProps extends InPropsObject = {}, OutProps = {}> = Composables & ComposableComponent<Name, Wrapper, InProps, OutProps>;
|
|
33
|
-
type AnyComposableComponent = ComposableComponent<string, any, {}, {}>;
|
|
34
|
-
type ComposableComponents = Record<string, AnyComposableComponent>;
|
|
35
|
-
declare function createComposableComponent<const Name extends string, Wrapper, InProps extends InPropsObject = {}, OutProps = {}>(options: ResolvedCreateComposableComponentOptions<Name, Wrapper, string, string, InProps, OutProps>): ComposableComponent<Name, Wrapper, InProps, OutProps>;
|
|
36
|
-
type MakeComposableOptions<Composables extends ComposableComponents, Name extends string> = {
|
|
37
|
-
components: Composables | undefined;
|
|
38
|
-
name: Name;
|
|
39
|
-
};
|
|
40
|
-
type MakeComposable<Composables extends ComposableComponents, Name extends string> = <OverrideName extends string = Name>(options?: Partial<Pick<MakeComposableOptions<Composables, OverrideName>, 'name'>>) => ComposableResourceLayout<Composables, Name, any, any, any>;
|
|
41
|
-
declare function makeComposable<Props>(): <Composables extends ComposableComponents, Name extends string>(options: MakeComposableOptions<Composables, Name>) => MakeComposable<Composables, Name>;
|
|
42
|
-
//#endregion
|
|
43
|
-
export { ComposableComponent, ComposableComponents, ComposableNameContext, ComposableResourceLayout, CreateLayoutComposable, LayoutComposablesFactory, MakeComposable, MakeComposableOptions, createComposableComponent, makeComposable };
|
|
44
|
-
//# sourceMappingURL=composable.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"composable.d.cts","names":[],"sources":["../src/composable.tsx"],"mappings":";;;;;;;KAMY,qBAAA;EAIV,QAAA,EAAU,QAAA;EACV,IAAA,EAAM,UAAA;EACN,UAAA,EAAY,YAAA;AAAA;AAAA,KAGT,uBAAA,qFAID,IAAA,KAAS,GAAA,EAAK,qBAAA,CAAsB,QAAA,EAAU,UAAA,MAAgB,IAAA;AAAA,KAE7D,gCAAA,4GAKa,aAAA;EAGhB,IAAA,EAAM,uBAAA,CAAwB,IAAA,EAAM,QAAA,EAAU,UAAA;EAC9C,OAAA,GAAU,OAAA;EACV,QAAA,IAAY,KAAA,EAAO,IAAA,CAAK,YAAA,CAAa,OAAA,OAAc,QAAA;EACnD,QAAA,GAAW,OAAA;AAAA;AAAA,KAGR,wCAAA,4GAKa,aAAA,wBAEd,IAAA,CACF,gCAAA,CACE,IAAA,EACA,OAAA,EACA,QAAA,EACA,UAAA,EACA,OAAA,EACA,QAAA;EAIF,IAAA,EAAM,IAAA;AAAA;AAAA,KAGI,sBAAA,sHAMM,aAAA,sBAGhB,OAAA,EAAS,gCAAA,CACP,IAAA,EACA,OAAA,EACA,SAAA,EACA,UAAA,EACA,OAAA,EACA,QAAA,MAEC,mBAAA,CAAoB,IAAA,EAAM,OAAA,EAAS,OAAA,EAAS,QAAA;AAAA,KAErC,wBAAA,kEAIV,MAAA,EAAQ,sBAAA,CAAuB,SAAA,EAAW,UAAA,MACvC,oBAAA;AAAA,KAKA,+BAAA,YACH,OAAA,SAAgB,aAAA,gBAA6B,IAAA,CAAK,KAAA;AAAA,KAC/C,wBAAA,0BAEa,aAAA,wBAEd,+BAAA,CAAgC,OAAA,WAC3B,OAAA,sBAA6B,YAAA,CAAa,OAAA;EAC/C,QAAA,UAAkB,OAAA,oBACd,SAAA,KACE,KAAA,EAAO,QAAA,KAAa,GAAA,CAAI,OAAA,IAAW,SAAA;AAAA;AAAA,KAEjC,mBAAA,+CAGM,aAAA,wBAEd,aAAA,CAAc,IAAA,EAAM,YAAA,CAAa,OAAA;EAAA,CAClC,KAAA,EAAO,wBAAA,CAAyB,OAAA,EAAS,OAAA,EAAS,QAAA,IAAY,SAAA;AAAA;AAAA,KAErD,wBAAA,qBACU,oBAAA,gDAGJ,aAAA,wBAEd,WAAA,GAAc,mBAAA,CAAoB,IAAA,EAAM,OAAA,EAAS,OAAA,EAAS,QAAA;AAAA,KAElD,sBAAA,GAAyB,mBAAmB;AAAA,KAC5C,oBAAA,GAAuB,MAAM,SAAS,sBAAA;AAAA,iBA2FlC,yBAAA,qDAGE,aAAA,sBAGhB,OAAA,EAAS,wCAAA,CACP,IAAA,EACA,OAAA,kBAGA,OAAA,EACA,QAAA,IAqDe,mBAAA,CAAoB,IAAA,EAAM,OAAA,EAAS,OAAA,EAAS,QAAA;AAAA,KAGnD,qBAAA,qBACU,oBAAA;EAEhB,UAAA,EAAY,WAAA;EAAyB,IAAA,EAAM,IAAA;AAAA;AAAA,KACrC,cAAA,qBACU,oBAAA,wDAEa,IAAA,EACjC,OAAA,GAAU,OAAA,CACR,IAAA,CAAK,qBAAA,CAAsB,WAAA,EAAa,YAAA,gBAEvC,wBAAA,CAAyB,WAAA,EAAa,IAAA;AAAA,iBAE3B,cAAA,gCAEQ,oBAAA,uBAEpB,OAAA,EAAS,qBAAA,CAAsB,WAAA,EAAa,IAAA,MAAK,cAAA,CAAA,WAAA,EAAA,IAAA"}
|