@jfdevelops/react-layout 1.2.0 → 1.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/create-defined-resource-layout.cjs +41 -4
- package/dist/create-config/create-defined-resource-layout.cjs.map +1 -1
- package/dist/create-config/create-defined-resource-layout.d.cts +33 -13
- package/dist/create-config/create-defined-resource-layout.d.cts.map +1 -1
- package/dist/create-config/create-defined-resource-layout.d.mts +33 -13
- package/dist/create-config/create-defined-resource-layout.d.mts.map +1 -1
- package/dist/create-config/create-defined-resource-layout.mjs +41 -4
- package/dist/create-config/create-defined-resource-layout.mjs.map +1 -1
- package/dist/create-config/define-layout.cjs +173 -25
- package/dist/create-config/define-layout.cjs.map +1 -1
- package/dist/create-config/define-layout.d.cts +46 -15
- package/dist/create-config/define-layout.d.cts.map +1 -1
- package/dist/create-config/define-layout.d.mts +46 -15
- package/dist/create-config/define-layout.d.mts.map +1 -1
- package/dist/create-config/define-layout.mjs +173 -25
- package/dist/create-config/define-layout.mjs.map +1 -1
- package/dist/create-config/for-resource.cjs.map +1 -1
- package/dist/create-config/for-resource.d.cts +2 -1
- package/dist/create-config/for-resource.d.cts.map +1 -1
- package/dist/create-config/for-resource.d.mts +2 -1
- package/dist/create-config/for-resource.d.mts.map +1 -1
- package/dist/create-config/for-resource.mjs.map +1 -1
- package/dist/create-config/index.d.cts +2 -1
- package/dist/create-config/index.d.mts +2 -1
- package/dist/create-config/inspection.cjs +67 -0
- package/dist/create-config/inspection.cjs.map +1 -0
- package/dist/create-config/inspection.mjs +66 -0
- package/dist/create-config/inspection.mjs.map +1 -0
- package/dist/create-config/layout-name.cjs +21 -0
- package/dist/create-config/layout-name.cjs.map +1 -0
- package/dist/create-config/layout-name.d.cts +49 -0
- package/dist/create-config/layout-name.d.cts.map +1 -0
- package/dist/create-config/layout-name.d.mts +49 -0
- package/dist/create-config/layout-name.d.mts.map +1 -0
- package/dist/create-config/layout-name.mjs +20 -0
- package/dist/create-config/layout-name.mjs.map +1 -0
- package/dist/create-config/lazy-resource-layout.cjs +1 -1
- package/dist/create-config/lazy-resource-layout.mjs +1 -1
- package/dist/create-config/merge-layout-props.cjs +20 -0
- package/dist/create-config/merge-layout-props.cjs.map +1 -0
- package/dist/create-config/merge-layout-props.mjs +19 -0
- package/dist/create-config/merge-layout-props.mjs.map +1 -0
- package/dist/create-config/preview.cjs +62 -0
- package/dist/create-config/preview.cjs.map +1 -0
- package/dist/create-config/preview.d.cts +13 -0
- package/dist/create-config/preview.d.cts.map +1 -0
- package/dist/create-config/preview.d.mts +13 -0
- package/dist/create-config/preview.d.mts.map +1 -0
- package/dist/create-config/preview.mjs +61 -0
- package/dist/create-config/preview.mjs.map +1 -0
- package/dist/create-config/render-state.cjs +19 -3
- package/dist/create-config/render-state.cjs.map +1 -1
- package/dist/create-config/render-state.d.cts +18 -14
- package/dist/create-config/render-state.d.cts.map +1 -1
- package/dist/create-config/render-state.d.mts +18 -14
- package/dist/create-config/render-state.d.mts.map +1 -1
- package/dist/create-config/render-state.mjs +19 -3
- package/dist/create-config/render-state.mjs.map +1 -1
- package/dist/create-config/state-composable.cjs +3 -0
- package/dist/create-config/state-composable.cjs.map +1 -1
- package/dist/create-config/state-composable.mjs +3 -1
- package/dist/create-config/state-composable.mjs.map +1 -1
- package/dist/index.cjs +4 -0
- package/dist/index.d.cts +3 -1
- package/dist/index.d.mts +3 -1
- package/dist/index.mjs +3 -1
- package/dist/utils/capitalize.d.cts +6 -0
- package/dist/utils/capitalize.d.cts.map +1 -0
- package/dist/utils/capitalize.d.mts +6 -0
- package/dist/utils/capitalize.d.mts.map +1 -0
- package/package.json +5 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state-composable.cjs","names":["LayoutConfigurationError","capitalize"],"sources":["../../src/create-config/state-composable.ts"],"sourcesContent":["import {\n createContext,\n createElement,\n useContext,\n type ComponentType,\n type JSX,\n} from 'react';\nimport { LayoutConfigurationError } from '../errors';\nimport type { IncludedProps } from '../props';\nimport { capitalize } from '../utils/capitalize';\n\n/** Props selected here are inherited from the containing state's render props. */\nexport type StateComposableOptions<\n Props extends object,\n Include extends IncludedProps<Props> = {},\n> = {\n props?: {\n include?: Include & { [Key in Exclude<keyof Include, keyof Props>]: never };\n };\n};\n\ntype StateComposableCallProps<Props extends object, Carried extends keyof Props> =\n Omit<Props, Carried> & Partial<Pick<Props, Carried>>;\n\n/** Non-enumerable state helpers; class methods stay out of object-spread types. */\nexport declare class StateComposableHandle<Props extends object> {\n asComposable<const Include extends IncludedProps<Props> = {}>(\n options?: StateComposableOptions<Props, Include>,\n ): StateComposable<Props, keyof Include & keyof Props>;\n}\n\n/** A state component usable in a composables map, optionally inheriting props. */\nexport type StateComposable<\n Props extends object,\n Carried extends keyof Props = never,\n> = {\n (props: StateComposableCallProps<Props, Carried>): JSX.Element;\n displayName: string;\n props: StateComposableCallProps<Props, Carried>;\n asComposable: AsStateComposable<Props>;\n};\n\n/** Converts a state into a composable; unselected required props remain required. */\nexport type AsStateComposable<Props extends object> = <\n const Include extends IncludedProps<Props> = {},\n>(\n options?: StateComposableOptions<Props, Include>,\n) => StateComposable<Props, keyof Include & keyof Props>;\n\n/** @internal The definition is kept by identity so builder references need no registration. */\nexport type StateComposableSource = {\n input: unknown;\n name: string;\n /** Fallback state that must not recursively render this reference. */\n fallbackStateName?: string;\n};\n\n/** @internal Shared by all states in one created resource layout. */\nexport type RenderStateScope = {\n states: Record<string, StateComposable<Record<string, unknown>>>;\n resolve: (source: StateComposableSource) => ComponentType<Record<string, unknown>>;\n};\n\n/** @internal Each rendered state supplies its own resolved values for carry-over. */\nexport const StateComposableContext = createContext<{\n scope: RenderStateScope;\n props: Record<string, unknown>;\n definitions: Record<string, unknown>;\n} | undefined>(undefined);\n\n/** @internal Defers state resolution until render, allowing forward references. */\nexport function createStateComposable(\n source: StateComposableSource,\n options: StateComposableOptions<Record<string, unknown>, IncludedProps<Record<string, unknown>>> & {\n normalizeIncludedKeys?: boolean;\n } = {},\n): StateComposable<Record<string, unknown>> {\n function StateReference(callProps: Record<string, unknown>) {\n const context = useContext(StateComposableContext);\n if (!context) {\n throw new LayoutConfigurationError(\n `Render state \"${source.name}\" must be used inside a resource layout`,\n );\n }\n const inherited = Object.fromEntries(\n Object.keys(options.props?.include ?? {}).map((key) => {\n const definition = context.definitions[key];\n return options.normalizeIncludedKeys && typeof definition === 'function' &&\n 'type' in definition && definition.type === 'JSX.Element' ? capitalize(key) : key;\n }).flatMap((key) =>\n Object.prototype.hasOwnProperty.call(context.props, key) && context.props[key] !== undefined\n ? [[key, context.props[key]]]\n : [],\n ),\n );\n return createElement(context.scope.resolve(source), {\n ...inherited,\n ...callProps,\n });\n }\n return withStateComposable(Object.assign(StateReference, {\n displayName: `State.${source.name}`,\n props: undefined as unknown as Record<string, unknown>,\n }), source) as StateComposable<Record<string, unknown>>;\n}\n\n/** @internal Keeps helper methods out of spreadable state maps. */\nexport function withStateComposable<Value extends object>(\n value: Value,\n source: StateComposableSource,\n): Value & { asComposable: AsStateComposable<Record<string, unknown>> } {\n if (Object.prototype.hasOwnProperty.call(value, 'asComposable')) {\n throw new LayoutConfigurationError(\n 'Render state name \"asComposable\" is reserved',\n );\n }\n Object.defineProperty(value, 'asComposable', {\n enumerable: false,\n value: (options?: StateComposableOptions<Record<string, unknown>, IncludedProps<Record<string, unknown>>>) =>\n createStateComposable(source, options),\n });\n return value as Value & { asComposable: AsStateComposable<Record<string, unknown>> };\n}\n\n/** @internal References are descriptors, so reading them never constructs a layout. */\nexport function createStateReferences(states: Record<string, unknown>) {\n return Object.fromEntries(Object.entries(states).map(([name, input]) => [\n name, createStateComposable({ input, name }),\n ]));\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"state-composable.cjs","names":["LayoutConfigurationError","capitalize"],"sources":["../../src/create-config/state-composable.ts"],"sourcesContent":["import {\n createContext,\n createElement,\n useContext,\n type ComponentType,\n type JSX,\n} from 'react';\nimport { LayoutConfigurationError } from '../errors';\nimport type { IncludedProps } from '../props';\nimport { capitalize } from '../utils/capitalize';\n\n/** Props selected here are inherited from the containing state's render props. */\nexport type StateComposableOptions<\n Props extends object,\n Include extends IncludedProps<Props> = {},\n> = {\n props?: {\n include?: Include & { [Key in Exclude<keyof Include, keyof Props>]: never };\n };\n};\n\ntype StateComposableCallProps<Props extends object, Carried extends keyof Props> =\n Omit<Props, Carried> & Partial<Pick<Props, Carried>>;\n\n/** Non-enumerable state helpers; class methods stay out of object-spread types. */\nexport declare class StateComposableHandle<Props extends object> {\n asComposable<const Include extends IncludedProps<Props> = {}>(\n options?: StateComposableOptions<Props, Include>,\n ): StateComposable<Props, keyof Include & keyof Props>;\n}\n\n/** A state component usable in a composables map, optionally inheriting props. */\nexport type StateComposable<\n Props extends object,\n Carried extends keyof Props = never,\n> = {\n (props: StateComposableCallProps<Props, Carried>): JSX.Element;\n displayName: string;\n props: StateComposableCallProps<Props, Carried>;\n asComposable: AsStateComposable<Props>;\n};\n\n/** Converts a state into a composable; unselected required props remain required. */\nexport type AsStateComposable<Props extends object> = <\n const Include extends IncludedProps<Props> = {},\n>(\n options?: StateComposableOptions<Props, Include>,\n) => StateComposable<Props, keyof Include & keyof Props>;\n\n/** @internal The definition is kept by identity so builder references need no registration. */\nexport type StateComposableSource = {\n input: unknown;\n name: string;\n /** Fallback state that must not recursively render this reference. */\n fallbackStateName?: string;\n};\n\nexport const stateReferenceSource = Symbol.for('@jfdevelops/react-layout/state-reference');\n\n/** @internal Shared by all states in one created resource layout. */\nexport type RenderStateScope = {\n states: Record<string, StateComposable<Record<string, unknown>>>;\n resolve: (source: StateComposableSource) => ComponentType<Record<string, unknown>>;\n};\n\n/** @internal Each rendered state supplies its own resolved values for carry-over. */\nexport const StateComposableContext = createContext<{\n scope: RenderStateScope;\n props: Record<string, unknown>;\n definitions: Record<string, unknown>;\n} | undefined>(undefined);\n\n/** @internal Defers state resolution until render, allowing forward references. */\nexport function createStateComposable(\n source: StateComposableSource,\n options: StateComposableOptions<Record<string, unknown>, IncludedProps<Record<string, unknown>>> & {\n normalizeIncludedKeys?: boolean;\n } = {},\n): StateComposable<Record<string, unknown>> {\n function StateReference(callProps: Record<string, unknown>) {\n const context = useContext(StateComposableContext);\n if (!context) {\n throw new LayoutConfigurationError(\n `Render state \"${source.name}\" must be used inside a resource layout`,\n );\n }\n const inherited = Object.fromEntries(\n Object.keys(options.props?.include ?? {}).map((key) => {\n const definition = context.definitions[key];\n return options.normalizeIncludedKeys && typeof definition === 'function' &&\n 'type' in definition && definition.type === 'JSX.Element' ? capitalize(key) : key;\n }).flatMap((key) =>\n Object.prototype.hasOwnProperty.call(context.props, key) && context.props[key] !== undefined\n ? [[key, context.props[key]]]\n : [],\n ),\n );\n return createElement(context.scope.resolve(source), {\n ...inherited,\n ...callProps,\n });\n }\n Object.defineProperty(StateReference, stateReferenceSource, { value: source });\n return withStateComposable(Object.assign(StateReference, {\n displayName: `State.${source.name}`,\n props: undefined as unknown as Record<string, unknown>,\n }), source) as StateComposable<Record<string, unknown>>;\n}\n\n/** @internal Keeps helper methods out of spreadable state maps. */\nexport function withStateComposable<Value extends object>(\n value: Value,\n source: StateComposableSource,\n): Value & { asComposable: AsStateComposable<Record<string, unknown>> } {\n if (Object.prototype.hasOwnProperty.call(value, 'asComposable')) {\n throw new LayoutConfigurationError(\n 'Render state name \"asComposable\" is reserved',\n );\n }\n Object.defineProperty(value, 'asComposable', {\n enumerable: false,\n value: (options?: StateComposableOptions<Record<string, unknown>, IncludedProps<Record<string, unknown>>>) =>\n createStateComposable(source, options),\n });\n return value as Value & { asComposable: AsStateComposable<Record<string, unknown>> };\n}\n\n/** @internal References are descriptors, so reading them never constructs a layout. */\nexport function createStateReferences(states: Record<string, unknown>) {\n return Object.fromEntries(Object.entries(states).map(([name, input]) => [\n name, createStateComposable({ input, name }),\n ]));\n}\n"],"mappings":";;;;;AAyDA,MAAa,uBAAuB,OAAO,IAAI,0CAA0C;;AASzF,MAAa,kDAIE,MAAS;;AAGxB,SAAgB,sBACd,QACA,UAEI,CAAC,GACqC;CAC1C,SAAS,eAAe,WAAoC;EAC1D,MAAM,gCAAqB,sBAAsB;EACjD,IAAI,CAAC,SACH,MAAM,IAAIA,4DACR,iBAAiB,OAAO,KAAK,wCAC/B;EAEF,MAAM,YAAY,OAAO,YACvB,OAAO,KAAK,QAAQ,OAAO,WAAW,CAAC,CAAC,EAAE,KAAK,QAAQ;GACrD,MAAM,aAAa,QAAQ,YAAY;GACvC,OAAO,QAAQ,yBAAyB,OAAO,eAAe,cAC5D,UAAU,cAAc,WAAW,SAAS,gBAAgBC,8BAAW,GAAG,IAAI;EAClF,CAAC,EAAE,SAAS,QACV,OAAO,UAAU,eAAe,KAAK,QAAQ,OAAO,GAAG,KAAK,QAAQ,MAAM,SAAS,SAC/E,CAAC,CAAC,KAAK,QAAQ,MAAM,IAAI,CAAC,IAC1B,CAAC,CACP,CACF;EACA,gCAAqB,QAAQ,MAAM,QAAQ,MAAM,GAAG;GAClD,GAAG;GACH,GAAG;EACL,CAAC;CACH;CACA,OAAO,eAAe,gBAAgB,sBAAsB,EAAE,OAAO,OAAO,CAAC;CAC7E,OAAO,oBAAoB,OAAO,OAAO,gBAAgB;EACvD,aAAa,SAAS,OAAO;EAC7B,OAAO;CACT,CAAC,GAAG,MAAM;AACZ;;AAGA,SAAgB,oBACd,OACA,QACsE;CACtE,IAAI,OAAO,UAAU,eAAe,KAAK,OAAO,cAAc,GAC5D,MAAM,IAAID,4DACR,gDACF;CAEF,OAAO,eAAe,OAAO,gBAAgB;EAC3C,YAAY;EACZ,QAAQ,YACN,sBAAsB,QAAQ,OAAO;CACzC,CAAC;CACD,OAAO;AACT;;AAGA,SAAgB,sBAAsB,QAAiC;CACrE,OAAO,OAAO,YAAY,OAAO,QAAQ,MAAM,EAAE,KAAK,CAAC,MAAM,WAAW,CACtE,MAAM,sBAAsB;EAAE;EAAO;CAAK,CAAC,CAC7C,CAAC,CAAC;AACJ"}
|
|
@@ -3,6 +3,7 @@ import { capitalize } from "../utils/capitalize.mjs";
|
|
|
3
3
|
import { createContext, createElement, useContext } from "react";
|
|
4
4
|
|
|
5
5
|
//#region src/create-config/state-composable.ts
|
|
6
|
+
const stateReferenceSource = Symbol.for("@jfdevelops/react-layout/state-reference");
|
|
6
7
|
/** @internal Each rendered state supplies its own resolved values for carry-over. */
|
|
7
8
|
const StateComposableContext = createContext(void 0);
|
|
8
9
|
/** @internal Defers state resolution until render, allowing forward references. */
|
|
@@ -19,6 +20,7 @@ function createStateComposable(source, options = {}) {
|
|
|
19
20
|
...callProps
|
|
20
21
|
});
|
|
21
22
|
}
|
|
23
|
+
Object.defineProperty(StateReference, stateReferenceSource, { value: source });
|
|
22
24
|
return withStateComposable(Object.assign(StateReference, {
|
|
23
25
|
displayName: `State.${source.name}`,
|
|
24
26
|
props: void 0
|
|
@@ -42,5 +44,5 @@ function createStateReferences(states) {
|
|
|
42
44
|
}
|
|
43
45
|
|
|
44
46
|
//#endregion
|
|
45
|
-
export { StateComposableContext, createStateComposable, createStateReferences, withStateComposable };
|
|
47
|
+
export { StateComposableContext, createStateComposable, createStateReferences, stateReferenceSource, withStateComposable };
|
|
46
48
|
//# sourceMappingURL=state-composable.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state-composable.mjs","names":[],"sources":["../../src/create-config/state-composable.ts"],"sourcesContent":["import {\n createContext,\n createElement,\n useContext,\n type ComponentType,\n type JSX,\n} from 'react';\nimport { LayoutConfigurationError } from '../errors';\nimport type { IncludedProps } from '../props';\nimport { capitalize } from '../utils/capitalize';\n\n/** Props selected here are inherited from the containing state's render props. */\nexport type StateComposableOptions<\n Props extends object,\n Include extends IncludedProps<Props> = {},\n> = {\n props?: {\n include?: Include & { [Key in Exclude<keyof Include, keyof Props>]: never };\n };\n};\n\ntype StateComposableCallProps<Props extends object, Carried extends keyof Props> =\n Omit<Props, Carried> & Partial<Pick<Props, Carried>>;\n\n/** Non-enumerable state helpers; class methods stay out of object-spread types. */\nexport declare class StateComposableHandle<Props extends object> {\n asComposable<const Include extends IncludedProps<Props> = {}>(\n options?: StateComposableOptions<Props, Include>,\n ): StateComposable<Props, keyof Include & keyof Props>;\n}\n\n/** A state component usable in a composables map, optionally inheriting props. */\nexport type StateComposable<\n Props extends object,\n Carried extends keyof Props = never,\n> = {\n (props: StateComposableCallProps<Props, Carried>): JSX.Element;\n displayName: string;\n props: StateComposableCallProps<Props, Carried>;\n asComposable: AsStateComposable<Props>;\n};\n\n/** Converts a state into a composable; unselected required props remain required. */\nexport type AsStateComposable<Props extends object> = <\n const Include extends IncludedProps<Props> = {},\n>(\n options?: StateComposableOptions<Props, Include>,\n) => StateComposable<Props, keyof Include & keyof Props>;\n\n/** @internal The definition is kept by identity so builder references need no registration. */\nexport type StateComposableSource = {\n input: unknown;\n name: string;\n /** Fallback state that must not recursively render this reference. */\n fallbackStateName?: string;\n};\n\n/** @internal Shared by all states in one created resource layout. */\nexport type RenderStateScope = {\n states: Record<string, StateComposable<Record<string, unknown>>>;\n resolve: (source: StateComposableSource) => ComponentType<Record<string, unknown>>;\n};\n\n/** @internal Each rendered state supplies its own resolved values for carry-over. */\nexport const StateComposableContext = createContext<{\n scope: RenderStateScope;\n props: Record<string, unknown>;\n definitions: Record<string, unknown>;\n} | undefined>(undefined);\n\n/** @internal Defers state resolution until render, allowing forward references. */\nexport function createStateComposable(\n source: StateComposableSource,\n options: StateComposableOptions<Record<string, unknown>, IncludedProps<Record<string, unknown>>> & {\n normalizeIncludedKeys?: boolean;\n } = {},\n): StateComposable<Record<string, unknown>> {\n function StateReference(callProps: Record<string, unknown>) {\n const context = useContext(StateComposableContext);\n if (!context) {\n throw new LayoutConfigurationError(\n `Render state \"${source.name}\" must be used inside a resource layout`,\n );\n }\n const inherited = Object.fromEntries(\n Object.keys(options.props?.include ?? {}).map((key) => {\n const definition = context.definitions[key];\n return options.normalizeIncludedKeys && typeof definition === 'function' &&\n 'type' in definition && definition.type === 'JSX.Element' ? capitalize(key) : key;\n }).flatMap((key) =>\n Object.prototype.hasOwnProperty.call(context.props, key) && context.props[key] !== undefined\n ? [[key, context.props[key]]]\n : [],\n ),\n );\n return createElement(context.scope.resolve(source), {\n ...inherited,\n ...callProps,\n });\n }\n return withStateComposable(Object.assign(StateReference, {\n displayName: `State.${source.name}`,\n props: undefined as unknown as Record<string, unknown>,\n }), source) as StateComposable<Record<string, unknown>>;\n}\n\n/** @internal Keeps helper methods out of spreadable state maps. */\nexport function withStateComposable<Value extends object>(\n value: Value,\n source: StateComposableSource,\n): Value & { asComposable: AsStateComposable<Record<string, unknown>> } {\n if (Object.prototype.hasOwnProperty.call(value, 'asComposable')) {\n throw new LayoutConfigurationError(\n 'Render state name \"asComposable\" is reserved',\n );\n }\n Object.defineProperty(value, 'asComposable', {\n enumerable: false,\n value: (options?: StateComposableOptions<Record<string, unknown>, IncludedProps<Record<string, unknown>>>) =>\n createStateComposable(source, options),\n });\n return value as Value & { asComposable: AsStateComposable<Record<string, unknown>> };\n}\n\n/** @internal References are descriptors, so reading them never constructs a layout. */\nexport function createStateReferences(states: Record<string, unknown>) {\n return Object.fromEntries(Object.entries(states).map(([name, input]) => [\n name, createStateComposable({ input, name }),\n ]));\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"state-composable.mjs","names":[],"sources":["../../src/create-config/state-composable.ts"],"sourcesContent":["import {\n createContext,\n createElement,\n useContext,\n type ComponentType,\n type JSX,\n} from 'react';\nimport { LayoutConfigurationError } from '../errors';\nimport type { IncludedProps } from '../props';\nimport { capitalize } from '../utils/capitalize';\n\n/** Props selected here are inherited from the containing state's render props. */\nexport type StateComposableOptions<\n Props extends object,\n Include extends IncludedProps<Props> = {},\n> = {\n props?: {\n include?: Include & { [Key in Exclude<keyof Include, keyof Props>]: never };\n };\n};\n\ntype StateComposableCallProps<Props extends object, Carried extends keyof Props> =\n Omit<Props, Carried> & Partial<Pick<Props, Carried>>;\n\n/** Non-enumerable state helpers; class methods stay out of object-spread types. */\nexport declare class StateComposableHandle<Props extends object> {\n asComposable<const Include extends IncludedProps<Props> = {}>(\n options?: StateComposableOptions<Props, Include>,\n ): StateComposable<Props, keyof Include & keyof Props>;\n}\n\n/** A state component usable in a composables map, optionally inheriting props. */\nexport type StateComposable<\n Props extends object,\n Carried extends keyof Props = never,\n> = {\n (props: StateComposableCallProps<Props, Carried>): JSX.Element;\n displayName: string;\n props: StateComposableCallProps<Props, Carried>;\n asComposable: AsStateComposable<Props>;\n};\n\n/** Converts a state into a composable; unselected required props remain required. */\nexport type AsStateComposable<Props extends object> = <\n const Include extends IncludedProps<Props> = {},\n>(\n options?: StateComposableOptions<Props, Include>,\n) => StateComposable<Props, keyof Include & keyof Props>;\n\n/** @internal The definition is kept by identity so builder references need no registration. */\nexport type StateComposableSource = {\n input: unknown;\n name: string;\n /** Fallback state that must not recursively render this reference. */\n fallbackStateName?: string;\n};\n\nexport const stateReferenceSource = Symbol.for('@jfdevelops/react-layout/state-reference');\n\n/** @internal Shared by all states in one created resource layout. */\nexport type RenderStateScope = {\n states: Record<string, StateComposable<Record<string, unknown>>>;\n resolve: (source: StateComposableSource) => ComponentType<Record<string, unknown>>;\n};\n\n/** @internal Each rendered state supplies its own resolved values for carry-over. */\nexport const StateComposableContext = createContext<{\n scope: RenderStateScope;\n props: Record<string, unknown>;\n definitions: Record<string, unknown>;\n} | undefined>(undefined);\n\n/** @internal Defers state resolution until render, allowing forward references. */\nexport function createStateComposable(\n source: StateComposableSource,\n options: StateComposableOptions<Record<string, unknown>, IncludedProps<Record<string, unknown>>> & {\n normalizeIncludedKeys?: boolean;\n } = {},\n): StateComposable<Record<string, unknown>> {\n function StateReference(callProps: Record<string, unknown>) {\n const context = useContext(StateComposableContext);\n if (!context) {\n throw new LayoutConfigurationError(\n `Render state \"${source.name}\" must be used inside a resource layout`,\n );\n }\n const inherited = Object.fromEntries(\n Object.keys(options.props?.include ?? {}).map((key) => {\n const definition = context.definitions[key];\n return options.normalizeIncludedKeys && typeof definition === 'function' &&\n 'type' in definition && definition.type === 'JSX.Element' ? capitalize(key) : key;\n }).flatMap((key) =>\n Object.prototype.hasOwnProperty.call(context.props, key) && context.props[key] !== undefined\n ? [[key, context.props[key]]]\n : [],\n ),\n );\n return createElement(context.scope.resolve(source), {\n ...inherited,\n ...callProps,\n });\n }\n Object.defineProperty(StateReference, stateReferenceSource, { value: source });\n return withStateComposable(Object.assign(StateReference, {\n displayName: `State.${source.name}`,\n props: undefined as unknown as Record<string, unknown>,\n }), source) as StateComposable<Record<string, unknown>>;\n}\n\n/** @internal Keeps helper methods out of spreadable state maps. */\nexport function withStateComposable<Value extends object>(\n value: Value,\n source: StateComposableSource,\n): Value & { asComposable: AsStateComposable<Record<string, unknown>> } {\n if (Object.prototype.hasOwnProperty.call(value, 'asComposable')) {\n throw new LayoutConfigurationError(\n 'Render state name \"asComposable\" is reserved',\n );\n }\n Object.defineProperty(value, 'asComposable', {\n enumerable: false,\n value: (options?: StateComposableOptions<Record<string, unknown>, IncludedProps<Record<string, unknown>>>) =>\n createStateComposable(source, options),\n });\n return value as Value & { asComposable: AsStateComposable<Record<string, unknown>> };\n}\n\n/** @internal References are descriptors, so reading them never constructs a layout. */\nexport function createStateReferences(states: Record<string, unknown>) {\n return Object.fromEntries(Object.entries(states).map(([name, input]) => [\n name, createStateComposable({ input, name }),\n ]));\n}\n"],"mappings":";;;;;AAyDA,MAAa,uBAAuB,OAAO,IAAI,0CAA0C;;AASzF,MAAa,yBAAyB,cAIvB,MAAS;;AAGxB,SAAgB,sBACd,QACA,UAEI,CAAC,GACqC;CAC1C,SAAS,eAAe,WAAoC;EAC1D,MAAM,UAAU,WAAW,sBAAsB;EACjD,IAAI,CAAC,SACH,MAAM,IAAI,yBACR,iBAAiB,OAAO,KAAK,wCAC/B;EAEF,MAAM,YAAY,OAAO,YACvB,OAAO,KAAK,QAAQ,OAAO,WAAW,CAAC,CAAC,EAAE,KAAK,QAAQ;GACrD,MAAM,aAAa,QAAQ,YAAY;GACvC,OAAO,QAAQ,yBAAyB,OAAO,eAAe,cAC5D,UAAU,cAAc,WAAW,SAAS,gBAAgB,WAAW,GAAG,IAAI;EAClF,CAAC,EAAE,SAAS,QACV,OAAO,UAAU,eAAe,KAAK,QAAQ,OAAO,GAAG,KAAK,QAAQ,MAAM,SAAS,SAC/E,CAAC,CAAC,KAAK,QAAQ,MAAM,IAAI,CAAC,IAC1B,CAAC,CACP,CACF;EACA,OAAO,cAAc,QAAQ,MAAM,QAAQ,MAAM,GAAG;GAClD,GAAG;GACH,GAAG;EACL,CAAC;CACH;CACA,OAAO,eAAe,gBAAgB,sBAAsB,EAAE,OAAO,OAAO,CAAC;CAC7E,OAAO,oBAAoB,OAAO,OAAO,gBAAgB;EACvD,aAAa,SAAS,OAAO;EAC7B,OAAO;CACT,CAAC,GAAG,MAAM;AACZ;;AAGA,SAAgB,oBACd,OACA,QACsE;CACtE,IAAI,OAAO,UAAU,eAAe,KAAK,OAAO,cAAc,GAC5D,MAAM,IAAI,yBACR,gDACF;CAEF,OAAO,eAAe,OAAO,gBAAgB;EAC3C,YAAY;EACZ,QAAQ,YACN,sBAAsB,QAAQ,OAAO;CACzC,CAAC;CACD,OAAO;AACT;;AAGA,SAAgB,sBAAsB,QAAiC;CACrE,OAAO,OAAO,YAAY,OAAO,QAAQ,MAAM,EAAE,KAAK,CAAC,MAAM,WAAW,CACtE,MAAM,sBAAsB;EAAE;EAAO;CAAK,CAAC,CAC7C,CAAC,CAAC;AACJ"}
|
package/dist/index.cjs
CHANGED
|
@@ -9,10 +9,12 @@ const require_missing_path_variable = require('./errors/missing-path-variable.cj
|
|
|
9
9
|
const require_missing_resource_provider = require('./errors/missing-resource-provider.cjs');
|
|
10
10
|
const require_layout_configuration_error = require('./errors/layout-configuration-error.cjs');
|
|
11
11
|
const require_resource_state_error = require('./errors/resource-state-error.cjs');
|
|
12
|
+
const require_preview = require('./create-config/preview.cjs');
|
|
12
13
|
const require_resource = require('./resource.cjs');
|
|
13
14
|
const require_utils = require('./utils.cjs');
|
|
14
15
|
const require_define_layout = require('./create-config/define-layout.cjs');
|
|
15
16
|
const require_create_defined_resource_layout = require('./create-config/create-defined-resource-layout.cjs');
|
|
17
|
+
const require_layout_name = require('./create-config/layout-name.cjs');
|
|
16
18
|
let _jfdevelops_react_layout_composables = require("@jfdevelops/react-layout-composables");
|
|
17
19
|
let _jfdevelops_react_layout_validator = require("@jfdevelops/react-layout-validator");
|
|
18
20
|
|
|
@@ -76,6 +78,8 @@ Object.defineProperty(exports, 'defineComposableComponent', {
|
|
|
76
78
|
return _jfdevelops_react_layout_composables.defineComposableComponent;
|
|
77
79
|
}
|
|
78
80
|
});
|
|
81
|
+
exports.defineLayoutName = require_layout_name.defineLayoutName;
|
|
82
|
+
exports.defineLayoutPreview = require_preview.defineLayoutPreview;
|
|
79
83
|
exports.defineResourceLayout = require_define_layout.defineResourceLayout;
|
|
80
84
|
Object.defineProperty(exports, 'isPropDefinitionShape', {
|
|
81
85
|
enumerable: true,
|
package/dist/index.d.cts
CHANGED
|
@@ -3,6 +3,7 @@ import { LayoutResourceKey, NormalizeResource, NormalizeResources, NormalizedRes
|
|
|
3
3
|
import { InPropsDefinition, InPropsFunction, InPropsObject, InPropsOptions, IncludedComponentPropDefinitions, IncludedPropBehavior, IncludedProps, InferredInProps, LayoutRenderProps, MergedLayoutInProps, PropsContextRender, PropsRenderDefinition, ResolvedIncludedComponentProps, ResolvedIncludedConfigProps, ResolvedIncludedProps, ResolvedIncludedPropsAsDefined } from "./props.cjs";
|
|
4
4
|
import { AsStateComposable, StateComposable, StateComposableOptions } from "./create-config/state-composable.cjs";
|
|
5
5
|
import { AnyRenderStateDefinition, CreateLayoutBuildingBlocks, CreateLayoutBuildingBlocksArguments, CreateLayoutBuildingBlocksResult, CreateRenderState, CreateRenderStateBuilderArguments, CreateRenderStateBuilderResult, CreateRenderStateFromState, DeferredRenderState, DefineLayoutComposables, LayoutComposablesDefinition, LazyRenderState, RenderStateCallProps, RenderStateCallback, RenderStateComposablesDefinition, RenderStateContext, RenderStateFragment, RenderStateName, RenderStateOverloads, RenderStateProps, RenderStateReferences, TypedRenderStateCallback } from "./create-config/render-state.cjs";
|
|
6
|
+
import { LayoutNameContext, LayoutNameInput, LayoutNameParts, LayoutNameResolver, ResolvedLayoutName, defineLayoutName } from "./create-config/layout-name.cjs";
|
|
6
7
|
import { ParameterizedResourcePath, PathVariables } from "./create-config/paths/types.cjs";
|
|
7
8
|
import { CreateGetComponentForPath, GetComponentForPath, ResolvedPathValue } from "./create-config/for-paths/get-component-for-path.cjs";
|
|
8
9
|
import { ForPaths, ForPathsRenderContext, RenderedPathComponent, RenderedPathComponentHOF, TargetPathBuilder } from "./create-config/for-paths/builder.cjs";
|
|
@@ -13,6 +14,7 @@ import { ContextualInlineRenderState, ContextualInlineRenderStates, CreateResour
|
|
|
13
14
|
import { LazyResourceErrorComponent, LazyResourceLayoutComponent, LazyResourceLayoutOptions, LazyResourceLoadingComponent, LazyResourceStates } from "./create-config/lazy-resource-layout.cjs";
|
|
14
15
|
import { BoundDefineResourceLayout, CreateDefinedResourceLayoutOptions, CreateDefinedResourceLayoutResult, DefineLazyDefaults, DefinedResourceLayoutInput, NonEmptyResources, createDefinedResourceLayout } from "./create-config/create-defined-resource-layout.cjs";
|
|
15
16
|
import { ResourceLayoutShellPublisher } from "./create-config/shell-context.cjs";
|
|
17
|
+
import { LayoutPreviewProps, defineLayoutPreview } from "./create-config/preview.cjs";
|
|
16
18
|
import { ReactLayoutError } from "./errors/react-layout-error.cjs";
|
|
17
19
|
import { InvalidConfigContext, InvalidConfigError } from "./errors/invalid-config.cjs";
|
|
18
20
|
import { InvalidPathContext, InvalidPathError } from "./errors/invalid-path.cjs";
|
|
@@ -25,4 +27,4 @@ import { LayoutConfigurationError, LayoutConfigurationErrorContext } from "./err
|
|
|
25
27
|
import { ResourceModuleLoadError, ResourceRenderError, ResourceStateError } from "./errors/resource-state-error.cjs";
|
|
26
28
|
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";
|
|
27
29
|
import { AnyBuiltPropDefinition, ExtractDefinitionValue, PropError, PropErrorOptions, ResolveLayoutProps, ResolveLayoutPropsAsDefined, ResolveProps, ResolvedBuiltPropShape, createPrimitivePropBuilder, createProp, isPropDefinitionShape, resolvePropDefinitionValues, validateProps } from "@jfdevelops/react-layout-validator";
|
|
28
|
-
export { type AnyBuiltPropDefinition, type AnyComposableComponent, type AnyRenderStateDefinition, type AsStateComposable, type BaseComponent, type BoundDefineResourceLayout, type ComponentTypes, type ComposableComponent, type ComposableComponentCallable, type ComposableComponents, type ComposableNameContext, type ComposablePresetComponent, type ComposablePresetComponentCallProps, type ComposablePresetMeta, type ComposablePresetProps, type ComposableResourceLayout, type ContextualInlineRenderState, type ContextualInlineRenderStates, type CreateDefinedResourceLayoutOptions, type CreateDefinedResourceLayoutResult, type CreateGetComponentForPath, type CreateLayoutBuildingBlocks, type CreateLayoutBuildingBlocksArguments, type CreateLayoutBuildingBlocksResult, type CreateLayoutComposable, type CreateRenderState, type CreateRenderStateBuilderArguments, type CreateRenderStateBuilderResult, type CreateRenderStateFromState, type CreateResourceConfigFn, type CreateResourceConfigForResource, type CreateResourceLayoutWithLayoutOptions, type CreateResourceMap, type CreateResourceMapFn, type CreateViewMapBuiltInRenderStatesOptions, type CreateViewMapFunctionRenderOptions, type CreateViewMapInlineRenderStatesOptions, type CreateViewMapRenderStatesOptions, type CreatedResourceConfig, type DeferredRenderState, type DefineLayoutComposables, type DefineLazyDefaults, type DefineResourceLayoutWithLayoutFn, type DefineResourcesFn, type DefinedComposableComponentRecord, type DefinedResourceLayoutInput, type DefinedResourceLayoutWithShell, type ExtractDefinitionValue, type ForPaths, type ForPathsRenderContext, type GetComponentForPath, type InPropsDefinition, type InPropsFunction, type InPropsObject, type InPropsOptions, type IncludedComponentPropDefinitions, type IncludedPropBehavior, type IncludedProps, type InferredInProps, type InvalidComponentContext, InvalidComponentError, type InvalidConfigContext, InvalidConfigError, type InvalidPathContext, InvalidPathError, type InvalidResourceContext, InvalidResourceError, type InvalidSubResourceContext, InvalidSubResourceError, type IsSubResourceKey, LayoutComposablePresetProvider, type LayoutComposablesDefinition, type LayoutComposablesFactory, LayoutConfigurationError, type LayoutConfigurationErrorContext, type LayoutRenderProps, type LayoutRenderResourcesAccessor, type LayoutResourceKey, type LayoutResourcesAccessor, type LazyRenderState, type LazyResourceErrorComponent, type LazyResourceLayoutComponent, type LazyResourceLayoutOptions, type LazyResourceLoadingComponent, type LazyResourceStates, type MakeComposable, type MakeComposableOptions, type MergeIntersection, type MergePresetProps, type MergedLayoutInProps, type MissingPathVariableContext, MissingPathVariableError, MissingResourceProviderError, type NonEmptyResources, type NormalizeResource, type NormalizeResources, type NormalizedResourceDefinition, type NormalizedResourceDefinitions, type ParameterizedResourcePath, type PathVariables, type PresetPropsFromComposable, PropError, type PropErrorOptions, type PropsContextRender, type PropsRenderDefinition, ReactLayoutError, type RenderStateCallProps, type RenderStateCallback, type RenderStateComposablesDefinition, type RenderStateContext, type RenderStateFragment, type RenderStateName, type RenderStateOverloads, type RenderStateProps, type RenderStateReferences, type RenderedPathComponent, type RenderedPathComponentHOF, type RequiredPresetLayoutProps, type RequiredPresetRenderProps, type ResolveLayoutComposables, type ResolveLayoutProps, type ResolveLayoutPropsAsDefined, type ResolveProps, type ResolvedBuiltPropShape, type ResolvedIncludedComponentProps, type ResolvedIncludedConfigProps, type ResolvedIncludedProps, type ResolvedIncludedPropsAsDefined, type ResolvedPathValue, type ResourceConfigFragment, type ResourceDefinition, type ResourceDefinitionValue, type ResourceEnum, type ResourceLayoutComponentProps, type ResourceLayoutProvider, type ResourceLayoutProviderProps, type ResourceLayoutShellComponent, type ResourceLayoutShellProps, type ResourceLayoutShellPublisher, ResourceModuleLoadError, type ResourcePath, ResourceRenderError, type ResourceSelection, type ResourceStateError, type ResourceTree, type ShellLayoutDefinition, type ShellRenderContext, type Show, type StateComposable, type StateComposableOptions, type TargetPathBuilder, type TypedBuiltInRenderStates, type TypedInlineRenderState, type TypedRenderStateCallback, type UnionToIntersection, collectComposablePresetEntries, createComposableComponent, createDefinedResourceLayout, createLayoutComposableFactory, createPrimitivePropBuilder, createProp, defineComposableComponent, defineResourceLayout, isPropDefinitionShape, makeComposable, normalizeResource, normalizeResourceDefinitions, normalizeResources, pick, resolveComposablePresetProps, resolveLayoutComposables, resolvePropDefinitionValues, toResourceEnum, validateProps };
|
|
30
|
+
export { type AnyBuiltPropDefinition, type AnyComposableComponent, type AnyRenderStateDefinition, type AsStateComposable, type BaseComponent, type BoundDefineResourceLayout, type ComponentTypes, type ComposableComponent, type ComposableComponentCallable, type ComposableComponents, type ComposableNameContext, type ComposablePresetComponent, type ComposablePresetComponentCallProps, type ComposablePresetMeta, type ComposablePresetProps, type ComposableResourceLayout, type ContextualInlineRenderState, type ContextualInlineRenderStates, type CreateDefinedResourceLayoutOptions, type CreateDefinedResourceLayoutResult, type CreateGetComponentForPath, type CreateLayoutBuildingBlocks, type CreateLayoutBuildingBlocksArguments, type CreateLayoutBuildingBlocksResult, type CreateLayoutComposable, type CreateRenderState, type CreateRenderStateBuilderArguments, type CreateRenderStateBuilderResult, type CreateRenderStateFromState, type CreateResourceConfigFn, type CreateResourceConfigForResource, type CreateResourceLayoutWithLayoutOptions, type CreateResourceMap, type CreateResourceMapFn, type CreateViewMapBuiltInRenderStatesOptions, type CreateViewMapFunctionRenderOptions, type CreateViewMapInlineRenderStatesOptions, type CreateViewMapRenderStatesOptions, type CreatedResourceConfig, type DeferredRenderState, type DefineLayoutComposables, type DefineLazyDefaults, type DefineResourceLayoutWithLayoutFn, type DefineResourcesFn, type DefinedComposableComponentRecord, type DefinedResourceLayoutInput, type DefinedResourceLayoutWithShell, type ExtractDefinitionValue, type ForPaths, type ForPathsRenderContext, type GetComponentForPath, type InPropsDefinition, type InPropsFunction, type InPropsObject, type InPropsOptions, type IncludedComponentPropDefinitions, type IncludedPropBehavior, type IncludedProps, type InferredInProps, type InvalidComponentContext, InvalidComponentError, type InvalidConfigContext, InvalidConfigError, type InvalidPathContext, InvalidPathError, type InvalidResourceContext, InvalidResourceError, type InvalidSubResourceContext, InvalidSubResourceError, type IsSubResourceKey, LayoutComposablePresetProvider, type LayoutComposablesDefinition, type LayoutComposablesFactory, LayoutConfigurationError, type LayoutConfigurationErrorContext, type LayoutNameContext, type LayoutNameInput, type LayoutNameParts, type LayoutNameResolver, type LayoutPreviewProps, type LayoutRenderProps, type LayoutRenderResourcesAccessor, type LayoutResourceKey, type LayoutResourcesAccessor, type LazyRenderState, type LazyResourceErrorComponent, type LazyResourceLayoutComponent, type LazyResourceLayoutOptions, type LazyResourceLoadingComponent, type LazyResourceStates, type MakeComposable, type MakeComposableOptions, type MergeIntersection, type MergePresetProps, type MergedLayoutInProps, type MissingPathVariableContext, MissingPathVariableError, MissingResourceProviderError, type NonEmptyResources, type NormalizeResource, type NormalizeResources, type NormalizedResourceDefinition, type NormalizedResourceDefinitions, type ParameterizedResourcePath, type PathVariables, type PresetPropsFromComposable, PropError, type PropErrorOptions, type PropsContextRender, type PropsRenderDefinition, ReactLayoutError, type RenderStateCallProps, type RenderStateCallback, type RenderStateComposablesDefinition, type RenderStateContext, type RenderStateFragment, type RenderStateName, type RenderStateOverloads, type RenderStateProps, type RenderStateReferences, type RenderedPathComponent, type RenderedPathComponentHOF, type RequiredPresetLayoutProps, type RequiredPresetRenderProps, type ResolveLayoutComposables, type ResolveLayoutProps, type ResolveLayoutPropsAsDefined, type ResolveProps, type ResolvedBuiltPropShape, type ResolvedIncludedComponentProps, type ResolvedIncludedConfigProps, type ResolvedIncludedProps, type ResolvedIncludedPropsAsDefined, type ResolvedLayoutName, type ResolvedPathValue, type ResourceConfigFragment, type ResourceDefinition, type ResourceDefinitionValue, type ResourceEnum, type ResourceLayoutComponentProps, type ResourceLayoutProvider, type ResourceLayoutProviderProps, type ResourceLayoutShellComponent, type ResourceLayoutShellProps, type ResourceLayoutShellPublisher, ResourceModuleLoadError, type ResourcePath, ResourceRenderError, type ResourceSelection, type ResourceStateError, type ResourceTree, type ShellLayoutDefinition, type ShellRenderContext, type Show, type StateComposable, type StateComposableOptions, type TargetPathBuilder, type TypedBuiltInRenderStates, type TypedInlineRenderState, type TypedRenderStateCallback, type UnionToIntersection, collectComposablePresetEntries, createComposableComponent, createDefinedResourceLayout, createLayoutComposableFactory, createPrimitivePropBuilder, createProp, defineComposableComponent, defineLayoutName, defineLayoutPreview, defineResourceLayout, isPropDefinitionShape, makeComposable, normalizeResource, normalizeResourceDefinitions, normalizeResources, pick, resolveComposablePresetProps, resolveLayoutComposables, resolvePropDefinitionValues, toResourceEnum, validateProps };
|
package/dist/index.d.mts
CHANGED
|
@@ -3,6 +3,7 @@ import { LayoutResourceKey, NormalizeResource, NormalizeResources, NormalizedRes
|
|
|
3
3
|
import { InPropsDefinition, InPropsFunction, InPropsObject, InPropsOptions, IncludedComponentPropDefinitions, IncludedPropBehavior, IncludedProps, InferredInProps, LayoutRenderProps, MergedLayoutInProps, PropsContextRender, PropsRenderDefinition, ResolvedIncludedComponentProps, ResolvedIncludedConfigProps, ResolvedIncludedProps, ResolvedIncludedPropsAsDefined } from "./props.mjs";
|
|
4
4
|
import { AsStateComposable, StateComposable, StateComposableOptions } from "./create-config/state-composable.mjs";
|
|
5
5
|
import { AnyRenderStateDefinition, CreateLayoutBuildingBlocks, CreateLayoutBuildingBlocksArguments, CreateLayoutBuildingBlocksResult, CreateRenderState, CreateRenderStateBuilderArguments, CreateRenderStateBuilderResult, CreateRenderStateFromState, DeferredRenderState, DefineLayoutComposables, LayoutComposablesDefinition, LazyRenderState, RenderStateCallProps, RenderStateCallback, RenderStateComposablesDefinition, RenderStateContext, RenderStateFragment, RenderStateName, RenderStateOverloads, RenderStateProps, RenderStateReferences, TypedRenderStateCallback } from "./create-config/render-state.mjs";
|
|
6
|
+
import { LayoutNameContext, LayoutNameInput, LayoutNameParts, LayoutNameResolver, ResolvedLayoutName, defineLayoutName } from "./create-config/layout-name.mjs";
|
|
6
7
|
import { ParameterizedResourcePath, PathVariables } from "./create-config/paths/types.mjs";
|
|
7
8
|
import { CreateGetComponentForPath, GetComponentForPath, ResolvedPathValue } from "./create-config/for-paths/get-component-for-path.mjs";
|
|
8
9
|
import { ForPaths, ForPathsRenderContext, RenderedPathComponent, RenderedPathComponentHOF, TargetPathBuilder } from "./create-config/for-paths/builder.mjs";
|
|
@@ -13,6 +14,7 @@ import { ContextualInlineRenderState, ContextualInlineRenderStates, CreateResour
|
|
|
13
14
|
import { LazyResourceErrorComponent, LazyResourceLayoutComponent, LazyResourceLayoutOptions, LazyResourceLoadingComponent, LazyResourceStates } from "./create-config/lazy-resource-layout.mjs";
|
|
14
15
|
import { BoundDefineResourceLayout, CreateDefinedResourceLayoutOptions, CreateDefinedResourceLayoutResult, DefineLazyDefaults, DefinedResourceLayoutInput, NonEmptyResources, createDefinedResourceLayout } from "./create-config/create-defined-resource-layout.mjs";
|
|
15
16
|
import { ResourceLayoutShellPublisher } from "./create-config/shell-context.mjs";
|
|
17
|
+
import { LayoutPreviewProps, defineLayoutPreview } from "./create-config/preview.mjs";
|
|
16
18
|
import { ReactLayoutError } from "./errors/react-layout-error.mjs";
|
|
17
19
|
import { InvalidConfigContext, InvalidConfigError } from "./errors/invalid-config.mjs";
|
|
18
20
|
import { InvalidPathContext, InvalidPathError } from "./errors/invalid-path.mjs";
|
|
@@ -25,4 +27,4 @@ import { LayoutConfigurationError, LayoutConfigurationErrorContext } from "./err
|
|
|
25
27
|
import { ResourceModuleLoadError, ResourceRenderError, ResourceStateError } from "./errors/resource-state-error.mjs";
|
|
26
28
|
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";
|
|
27
29
|
import { AnyBuiltPropDefinition, ExtractDefinitionValue, PropError, PropErrorOptions, ResolveLayoutProps, ResolveLayoutPropsAsDefined, ResolveProps, ResolvedBuiltPropShape, createPrimitivePropBuilder, createProp, isPropDefinitionShape, resolvePropDefinitionValues, validateProps } from "@jfdevelops/react-layout-validator";
|
|
28
|
-
export { type AnyBuiltPropDefinition, type AnyComposableComponent, type AnyRenderStateDefinition, type AsStateComposable, type BaseComponent, type BoundDefineResourceLayout, type ComponentTypes, type ComposableComponent, type ComposableComponentCallable, type ComposableComponents, type ComposableNameContext, type ComposablePresetComponent, type ComposablePresetComponentCallProps, type ComposablePresetMeta, type ComposablePresetProps, type ComposableResourceLayout, type ContextualInlineRenderState, type ContextualInlineRenderStates, type CreateDefinedResourceLayoutOptions, type CreateDefinedResourceLayoutResult, type CreateGetComponentForPath, type CreateLayoutBuildingBlocks, type CreateLayoutBuildingBlocksArguments, type CreateLayoutBuildingBlocksResult, type CreateLayoutComposable, type CreateRenderState, type CreateRenderStateBuilderArguments, type CreateRenderStateBuilderResult, type CreateRenderStateFromState, type CreateResourceConfigFn, type CreateResourceConfigForResource, type CreateResourceLayoutWithLayoutOptions, type CreateResourceMap, type CreateResourceMapFn, type CreateViewMapBuiltInRenderStatesOptions, type CreateViewMapFunctionRenderOptions, type CreateViewMapInlineRenderStatesOptions, type CreateViewMapRenderStatesOptions, type CreatedResourceConfig, type DeferredRenderState, type DefineLayoutComposables, type DefineLazyDefaults, type DefineResourceLayoutWithLayoutFn, type DefineResourcesFn, type DefinedComposableComponentRecord, type DefinedResourceLayoutInput, type DefinedResourceLayoutWithShell, type ExtractDefinitionValue, type ForPaths, type ForPathsRenderContext, type GetComponentForPath, type InPropsDefinition, type InPropsFunction, type InPropsObject, type InPropsOptions, type IncludedComponentPropDefinitions, type IncludedPropBehavior, type IncludedProps, type InferredInProps, type InvalidComponentContext, InvalidComponentError, type InvalidConfigContext, InvalidConfigError, type InvalidPathContext, InvalidPathError, type InvalidResourceContext, InvalidResourceError, type InvalidSubResourceContext, InvalidSubResourceError, type IsSubResourceKey, LayoutComposablePresetProvider, type LayoutComposablesDefinition, type LayoutComposablesFactory, LayoutConfigurationError, type LayoutConfigurationErrorContext, type LayoutRenderProps, type LayoutRenderResourcesAccessor, type LayoutResourceKey, type LayoutResourcesAccessor, type LazyRenderState, type LazyResourceErrorComponent, type LazyResourceLayoutComponent, type LazyResourceLayoutOptions, type LazyResourceLoadingComponent, type LazyResourceStates, type MakeComposable, type MakeComposableOptions, type MergeIntersection, type MergePresetProps, type MergedLayoutInProps, type MissingPathVariableContext, MissingPathVariableError, MissingResourceProviderError, type NonEmptyResources, type NormalizeResource, type NormalizeResources, type NormalizedResourceDefinition, type NormalizedResourceDefinitions, type ParameterizedResourcePath, type PathVariables, type PresetPropsFromComposable, PropError, type PropErrorOptions, type PropsContextRender, type PropsRenderDefinition, ReactLayoutError, type RenderStateCallProps, type RenderStateCallback, type RenderStateComposablesDefinition, type RenderStateContext, type RenderStateFragment, type RenderStateName, type RenderStateOverloads, type RenderStateProps, type RenderStateReferences, type RenderedPathComponent, type RenderedPathComponentHOF, type RequiredPresetLayoutProps, type RequiredPresetRenderProps, type ResolveLayoutComposables, type ResolveLayoutProps, type ResolveLayoutPropsAsDefined, type ResolveProps, type ResolvedBuiltPropShape, type ResolvedIncludedComponentProps, type ResolvedIncludedConfigProps, type ResolvedIncludedProps, type ResolvedIncludedPropsAsDefined, type ResolvedPathValue, type ResourceConfigFragment, type ResourceDefinition, type ResourceDefinitionValue, type ResourceEnum, type ResourceLayoutComponentProps, type ResourceLayoutProvider, type ResourceLayoutProviderProps, type ResourceLayoutShellComponent, type ResourceLayoutShellProps, type ResourceLayoutShellPublisher, ResourceModuleLoadError, type ResourcePath, ResourceRenderError, type ResourceSelection, type ResourceStateError, type ResourceTree, type ShellLayoutDefinition, type ShellRenderContext, type Show, type StateComposable, type StateComposableOptions, type TargetPathBuilder, type TypedBuiltInRenderStates, type TypedInlineRenderState, type TypedRenderStateCallback, type UnionToIntersection, collectComposablePresetEntries, createComposableComponent, createDefinedResourceLayout, createLayoutComposableFactory, createPrimitivePropBuilder, createProp, defineComposableComponent, defineResourceLayout, isPropDefinitionShape, makeComposable, normalizeResource, normalizeResourceDefinitions, normalizeResources, pick, resolveComposablePresetProps, resolveLayoutComposables, resolvePropDefinitionValues, toResourceEnum, validateProps };
|
|
30
|
+
export { type AnyBuiltPropDefinition, type AnyComposableComponent, type AnyRenderStateDefinition, type AsStateComposable, type BaseComponent, type BoundDefineResourceLayout, type ComponentTypes, type ComposableComponent, type ComposableComponentCallable, type ComposableComponents, type ComposableNameContext, type ComposablePresetComponent, type ComposablePresetComponentCallProps, type ComposablePresetMeta, type ComposablePresetProps, type ComposableResourceLayout, type ContextualInlineRenderState, type ContextualInlineRenderStates, type CreateDefinedResourceLayoutOptions, type CreateDefinedResourceLayoutResult, type CreateGetComponentForPath, type CreateLayoutBuildingBlocks, type CreateLayoutBuildingBlocksArguments, type CreateLayoutBuildingBlocksResult, type CreateLayoutComposable, type CreateRenderState, type CreateRenderStateBuilderArguments, type CreateRenderStateBuilderResult, type CreateRenderStateFromState, type CreateResourceConfigFn, type CreateResourceConfigForResource, type CreateResourceLayoutWithLayoutOptions, type CreateResourceMap, type CreateResourceMapFn, type CreateViewMapBuiltInRenderStatesOptions, type CreateViewMapFunctionRenderOptions, type CreateViewMapInlineRenderStatesOptions, type CreateViewMapRenderStatesOptions, type CreatedResourceConfig, type DeferredRenderState, type DefineLayoutComposables, type DefineLazyDefaults, type DefineResourceLayoutWithLayoutFn, type DefineResourcesFn, type DefinedComposableComponentRecord, type DefinedResourceLayoutInput, type DefinedResourceLayoutWithShell, type ExtractDefinitionValue, type ForPaths, type ForPathsRenderContext, type GetComponentForPath, type InPropsDefinition, type InPropsFunction, type InPropsObject, type InPropsOptions, type IncludedComponentPropDefinitions, type IncludedPropBehavior, type IncludedProps, type InferredInProps, type InvalidComponentContext, InvalidComponentError, type InvalidConfigContext, InvalidConfigError, type InvalidPathContext, InvalidPathError, type InvalidResourceContext, InvalidResourceError, type InvalidSubResourceContext, InvalidSubResourceError, type IsSubResourceKey, LayoutComposablePresetProvider, type LayoutComposablesDefinition, type LayoutComposablesFactory, LayoutConfigurationError, type LayoutConfigurationErrorContext, type LayoutNameContext, type LayoutNameInput, type LayoutNameParts, type LayoutNameResolver, type LayoutPreviewProps, type LayoutRenderProps, type LayoutRenderResourcesAccessor, type LayoutResourceKey, type LayoutResourcesAccessor, type LazyRenderState, type LazyResourceErrorComponent, type LazyResourceLayoutComponent, type LazyResourceLayoutOptions, type LazyResourceLoadingComponent, type LazyResourceStates, type MakeComposable, type MakeComposableOptions, type MergeIntersection, type MergePresetProps, type MergedLayoutInProps, type MissingPathVariableContext, MissingPathVariableError, MissingResourceProviderError, type NonEmptyResources, type NormalizeResource, type NormalizeResources, type NormalizedResourceDefinition, type NormalizedResourceDefinitions, type ParameterizedResourcePath, type PathVariables, type PresetPropsFromComposable, PropError, type PropErrorOptions, type PropsContextRender, type PropsRenderDefinition, ReactLayoutError, type RenderStateCallProps, type RenderStateCallback, type RenderStateComposablesDefinition, type RenderStateContext, type RenderStateFragment, type RenderStateName, type RenderStateOverloads, type RenderStateProps, type RenderStateReferences, type RenderedPathComponent, type RenderedPathComponentHOF, type RequiredPresetLayoutProps, type RequiredPresetRenderProps, type ResolveLayoutComposables, type ResolveLayoutProps, type ResolveLayoutPropsAsDefined, type ResolveProps, type ResolvedBuiltPropShape, type ResolvedIncludedComponentProps, type ResolvedIncludedConfigProps, type ResolvedIncludedProps, type ResolvedIncludedPropsAsDefined, type ResolvedLayoutName, type ResolvedPathValue, type ResourceConfigFragment, type ResourceDefinition, type ResourceDefinitionValue, type ResourceEnum, type ResourceLayoutComponentProps, type ResourceLayoutProvider, type ResourceLayoutProviderProps, type ResourceLayoutShellComponent, type ResourceLayoutShellProps, type ResourceLayoutShellPublisher, ResourceModuleLoadError, type ResourcePath, ResourceRenderError, type ResourceSelection, type ResourceStateError, type ResourceTree, type ShellLayoutDefinition, type ShellRenderContext, type Show, type StateComposable, type StateComposableOptions, type TargetPathBuilder, type TypedBuiltInRenderStates, type TypedInlineRenderState, type TypedRenderStateCallback, type UnionToIntersection, collectComposablePresetEntries, createComposableComponent, createDefinedResourceLayout, createLayoutComposableFactory, createPrimitivePropBuilder, createProp, defineComposableComponent, defineLayoutName, defineLayoutPreview, defineResourceLayout, isPropDefinitionShape, makeComposable, normalizeResource, normalizeResourceDefinitions, normalizeResources, pick, resolveComposablePresetProps, resolveLayoutComposables, resolvePropDefinitionValues, toResourceEnum, validateProps };
|
package/dist/index.mjs
CHANGED
|
@@ -8,11 +8,13 @@ import { MissingPathVariableError } from "./errors/missing-path-variable.mjs";
|
|
|
8
8
|
import { MissingResourceProviderError } from "./errors/missing-resource-provider.mjs";
|
|
9
9
|
import { LayoutConfigurationError } from "./errors/layout-configuration-error.mjs";
|
|
10
10
|
import { ResourceModuleLoadError, ResourceRenderError } from "./errors/resource-state-error.mjs";
|
|
11
|
+
import { defineLayoutPreview } from "./create-config/preview.mjs";
|
|
11
12
|
import { normalizeResource, normalizeResourceDefinitions, normalizeResources, toResourceEnum } from "./resource.mjs";
|
|
12
13
|
import { pick } from "./utils.mjs";
|
|
13
14
|
import { defineResourceLayout } from "./create-config/define-layout.mjs";
|
|
14
15
|
import { createDefinedResourceLayout } from "./create-config/create-defined-resource-layout.mjs";
|
|
16
|
+
import { defineLayoutName } from "./create-config/layout-name.mjs";
|
|
15
17
|
import { LayoutComposablePresetProvider, collectComposablePresetEntries, createComposableComponent, createLayoutComposableFactory, defineComposableComponent, makeComposable, resolveComposablePresetProps, resolveLayoutComposables } from "@jfdevelops/react-layout-composables";
|
|
16
18
|
import { PropError, createPrimitivePropBuilder, createProp, isPropDefinitionShape, resolvePropDefinitionValues, validateProps } from "@jfdevelops/react-layout-validator";
|
|
17
19
|
|
|
18
|
-
export { InvalidComponentError, InvalidConfigError, InvalidPathError, InvalidResourceError, InvalidSubResourceError, LayoutComposablePresetProvider, LayoutConfigurationError, MissingPathVariableError, MissingResourceProviderError, PropError, ReactLayoutError, ResourceModuleLoadError, ResourceRenderError, collectComposablePresetEntries, createComposableComponent, createDefinedResourceLayout, createLayoutComposableFactory, createPrimitivePropBuilder, createProp, defineComposableComponent, defineResourceLayout, isPropDefinitionShape, makeComposable, normalizeResource, normalizeResourceDefinitions, normalizeResources, pick, resolveComposablePresetProps, resolveLayoutComposables, resolvePropDefinitionValues, toResourceEnum, validateProps };
|
|
20
|
+
export { InvalidComponentError, InvalidConfigError, InvalidPathError, InvalidResourceError, InvalidSubResourceError, LayoutComposablePresetProvider, LayoutConfigurationError, MissingPathVariableError, MissingResourceProviderError, PropError, ReactLayoutError, ResourceModuleLoadError, ResourceRenderError, collectComposablePresetEntries, createComposableComponent, createDefinedResourceLayout, createLayoutComposableFactory, createPrimitivePropBuilder, createProp, defineComposableComponent, defineLayoutName, defineLayoutPreview, defineResourceLayout, isPropDefinitionShape, makeComposable, normalizeResource, normalizeResourceDefinitions, normalizeResources, pick, resolveComposablePresetProps, resolveLayoutComposables, resolvePropDefinitionValues, toResourceEnum, validateProps };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capitalize.d.cts","names":[],"sources":["../../src/utils/capitalize.ts"],"mappings":";iBAEgB,UAAA,mBAA6B,GAAA,EAAK,CAAA,GAAI,UAAA,CAAW,CAAA;AAAA,iBACjD,UAAA,CAAW,GAAW"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capitalize.d.mts","names":[],"sources":["../../src/utils/capitalize.ts"],"mappings":";iBAEgB,UAAA,mBAA6B,GAAA,EAAK,CAAA,GAAI,UAAA,CAAW,CAAA;AAAA,iBACjD,UAAA,CAAW,GAAW"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jfdevelops/react-layout",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "A React library for creating layout components.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -29,7 +29,8 @@
|
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@jfdevelops/create-error": "0.2.0",
|
|
31
31
|
"arktype": "2.2.8",
|
|
32
|
-
"@jfdevelops/react-layout-composables": "0.
|
|
32
|
+
"@jfdevelops/react-layout-composables": "0.3.0",
|
|
33
|
+
"@jfdevelops/react-layout-devtools-core": "0.2.0",
|
|
33
34
|
"@jfdevelops/react-layout-validator": "0.3.0"
|
|
34
35
|
},
|
|
35
36
|
"peerDependencies": {
|
|
@@ -59,13 +60,13 @@
|
|
|
59
60
|
"vitest": "4.1.5"
|
|
60
61
|
},
|
|
61
62
|
"scripts": {
|
|
62
|
-
"dev": "vite",
|
|
63
|
+
"dev": "portless react-layout vite",
|
|
63
64
|
"build": "tsdown",
|
|
64
65
|
"typecheck": "tsc --noEmit",
|
|
65
66
|
"test": "vitest run",
|
|
66
67
|
"test:watch": "vitest",
|
|
67
68
|
"test:ui": "vitest --ui",
|
|
68
69
|
"test:coverage": "vitest run --coverage",
|
|
69
|
-
"preview": "vite preview"
|
|
70
|
+
"preview": "portless react-layout vite preview"
|
|
70
71
|
}
|
|
71
72
|
}
|