@jfdevelops/react-layout-composables 0.6.0 → 1.0.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.
@@ -1,6 +1,6 @@
1
1
  const require_errors = require('./errors.cjs');
2
- let _jfdevelops_react_layout_validator = require("@jfdevelops/react-layout-validator");
3
2
  let react = require("react");
3
+ let _jfdevelops_react_layout_validator = require("@jfdevelops/react-layout-validator");
4
4
  let react_jsx_runtime = require("react/jsx-runtime");
5
5
 
6
6
  //#region src/composable.tsx
@@ -67,7 +67,8 @@ function createComposableComponent(options) {
67
67
  const wrapperProps = { ...propsRecord };
68
68
  for (const key of inPropsKeys) delete wrapperProps[key];
69
69
  const mergedValues = (0, _jfdevelops_react_layout_validator.resolvePropDefinitionValues)(mergedInProps);
70
- const mergedResolved = (0, _jfdevelops_react_layout_validator.validateProps)(options[validatedComposableProps] ? {} : Object.fromEntries(Object.entries(inProps ?? {}).filter(([, definition]) => (0, _jfdevelops_react_layout_validator.isStandardSchema)(definition))), mergedValues);
70
+ const alreadyValidated = options[validatedComposableProps];
71
+ const mergedResolved = (0, _jfdevelops_react_layout_validator.validateProps)(alreadyValidated ? {} : inProps, mergedValues);
71
72
  const resolvedProps = outProps ? outProps(mergedResolved) : {};
72
73
  const resolvedChildren = children == null ? reactNodeFromSingleFieldOutProps(resolvedProps) : resolveComponent(children, resolvedProps);
73
74
  if (wrapWith) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(wrapWith, {
@@ -92,8 +93,8 @@ function createComposableComponent(options) {
92
93
  function resolvePresetComposableCallProps(presetKey, propDefinitions, callProps) {
93
94
  const presetKeys = Object.keys(propDefinitions);
94
95
  const contextValues = useComposablePresetProps(presetKey) ?? {};
95
- const presetValues = Object.fromEntries(presetKeys.map((key) => [key, (0, _jfdevelops_react_layout_validator.isStandardSchema)(propDefinitions[key]) && Object.hasOwn(callProps, key) ? callProps[key] : callProps[key] ?? contextValues[key]]));
96
- return (0, _jfdevelops_react_layout_validator.validateProps)(Object.fromEntries(Object.entries(propDefinitions).filter(([key, definition]) => !(0, _jfdevelops_react_layout_validator.isStandardSchema)(definition) || Object.hasOwn(callProps, key) || !Object.hasOwn(contextValues, key))), presetValues);
96
+ const presetValues = Object.fromEntries(presetKeys.map((key) => [key, Object.hasOwn(callProps, key) ? callProps[key] : contextValues[key]]));
97
+ return (0, _jfdevelops_react_layout_validator.validateProps)(Object.fromEntries(Object.entries(propDefinitions).filter(([key]) => Object.hasOwn(callProps, key) || !Object.hasOwn(contextValues, key))), presetValues);
97
98
  }
98
99
  function defineComposableComponent(options) {
99
100
  const { name, props = {}, wrapWith } = options;
@@ -1 +1 @@
1
- {"version":3,"file":"composable.cjs","names":["Comp","InvalidComponentsError","EmptyComponentsError"],"sources":["../src/composable.tsx"],"sourcesContent":["import { ComponentType, createContext, ReactNode, useContext, cloneElement, isValidElement } from 'react';\nimport { EmptyComponentsError, InvalidComponentsError } from './errors';\nimport {\n AnyBuiltPropDefinition,\n type PropValidationContext,\n ResolveLayoutProps,\n ResolveProps,\n ResolveInputProps,\n ResolveLayoutInputProps,\n type StandardSchemaV1,\n isStandardSchema,\n resolvePropDefinitionValues,\n validateProps,\n} from '@jfdevelops/react-layout-validator';\nimport { InPropsObject, type WithChildren } from './types';\nimport { BaseComponent, Show, UnionToIntersection } from './utils';\nimport { CapitalizeFn } from './utils/capitalize';\n\nexport const composablePresetMetaKey = Symbol.for(\n 'view-map.composable-preset-meta'\n);\n\nconst validatedComposableProps = Symbol('validatedComposableProps');\n\nexport type ComposablePresetMeta<Props extends InPropsObject = InPropsObject> =\n {\n key: string;\n props: Props;\n };\n\nexport type ComposablePresetProps = Record<string, Record<string, unknown>>;\n\nconst composablePresetPropsContext = createContext<\n ComposablePresetProps | undefined\n>(undefined);\n\nexport function LayoutComposablePresetProvider({\n value,\n children,\n}: {\n value: ComposablePresetProps;\n children: ReactNode;\n}) {\n return (\n <composablePresetPropsContext.Provider value={value}>\n {children}\n </composablePresetPropsContext.Provider>\n );\n}\n\nfunction useComposablePresetProps(key: string) {\n return useContext(composablePresetPropsContext)?.[key];\n}\n\nexport function collectComposablePresetEntries(\n composables: ComposableComponents | undefined\n) {\n if (!composables) {\n return [] as Array<{\n key: string;\n props: InPropsObject;\n }>;\n }\n\n return Object.entries(composables).flatMap(([objectKey, component]) => {\n const meta = (component as ComposablePresetComponent)[\n composablePresetMetaKey\n ];\n\n if (!meta) {\n return [];\n }\n\n return [\n {\n key: meta.key ?? objectKey,\n props: meta.props,\n },\n ];\n });\n}\n\nexport function resolveComposablePresetProps(\n composables: ComposableComponents | undefined,\n layoutOptions: Record<string, unknown>,\n context?: PropValidationContext\n) {\n const resolved: ComposablePresetProps = {};\n\n for (const { key, props } of collectComposablePresetEntries(composables)) {\n const propKeys = Object.keys(props);\n const values = Object.fromEntries(\n propKeys.flatMap((propKey) => {\n if (!(propKey in layoutOptions)) {\n return [];\n }\n\n return [[propKey, layoutOptions[propKey]]];\n })\n );\n\n resolved[key] = validateProps(\n props as Record<string, AnyBuiltPropDefinition>,\n values,\n context\n );\n }\n\n return resolved;\n}\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> : {};\n\ntype ComposableComponentWrapperProps<Wrapper> = Wrapper extends ComponentType<\n infer Props\n>\n ? Omit<Props, 'children'>\n : {};\n\ntype ComposableComponentProps<\n Wrapper,\n InProps extends InPropsObject = {},\n OutProps = {}\n> = ComposableComponentWrapperProps<Wrapper> &\n (keyof InProps extends never ? {} : ResolveInputProps<InProps>) & {\n children?: [keyof InProps] extends [never]\n ? ReactNode\n : ((props: OutProps) => JSX.Element) | ReactNode;\n };\n\nexport type ComposableComponent<\n Name extends string,\n Wrapper,\n InProps extends InPropsObject = {},\n OutProps = {}\n> = BaseComponent<Name, ResolveInputProps<InProps>> & {\n (props: ComposableComponentProps<Wrapper, InProps, OutProps>): ReactNode;\n};\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<\n string,\n any,\n InPropsObject,\n any\n>;\n\n/**\n * Minimal callable shape shared by layout and preset composables.\n * Used as the record value so preset components keep their own prop types.\n */\nexport type ComposableComponentCallable = {\n displayName: string;\n props: unknown;\n (...args: any[]): ReactNode;\n};\n\n// Separate installed versions declare distinct unique symbols for the same\n// Symbol.for key. Read the metadata structurally so their presets interoperate.\ntype PresetPropsFromMetadata<Component> = {\n [Key in keyof Component]-?: Key extends symbol\n ? Component[Key] extends ComposablePresetMeta<infer Props>\n ? Props\n : never\n : never;\n}[keyof Component];\n\nexport type PresetPropsFromComposable<Component> = Component extends {\n [composablePresetMetaKey]: ComposablePresetMeta<infer Props>;\n}\n ? Props\n : [PresetPropsFromMetadata<Component>] extends [never]\n ? {}\n : PresetPropsFromMetadata<Component>;\n\nexport type MergePresetProps<Composables extends ComposableComponents> = Show<\n UnionToIntersection<PresetPropsFromComposable<Composables[keyof Composables]>>\n>;\n\nexport type RequiredPresetRenderProps<Props extends InPropsObject> = {\n [K in keyof ResolveProps<Props> & string]-?: ResolveProps<Props>[K];\n};\n\ntype SchemaDefinitions<Props extends InPropsObject> = {\n [Key in keyof Props as Props[Key] extends StandardSchemaV1 ? Key : never]: Props[Key];\n};\n\ntype PresetInputProps<Props extends InPropsObject> =\n ResolveInputProps<SchemaDefinitions<Props>> &\n RequiredPresetRenderProps<Omit<Props, keyof SchemaDefinitions<Props>>>;\n\nexport type ComposablePresetComponentCallProps<\n Props extends InPropsObject,\n Wrapper = undefined\n> = WithChildren<PresetInputProps<Props>> &\n (Wrapper extends undefined ? {} : ComposableComponentWrapperProps<Wrapper>);\n\nexport type ComposablePresetComponent<\n Name extends string = string,\n Props extends InPropsObject = InPropsObject,\n Wrapper = undefined\n> = BaseComponent<Name, Show<WithChildren<ResolveInputProps<Props>>>> & {\n [composablePresetMetaKey]: ComposablePresetMeta<Props>;\n} & ((props: ComposablePresetComponentCallProps<Props, Wrapper>) => ReactNode);\n\ntype PresetPropDefinitions<Composables extends ComposableComponents> =\n MergePresetProps<Composables> extends InPropsObject\n ? MergePresetProps<Composables>\n : {};\n\ntype PresetLayoutInputProps<Props extends InPropsObject> =\n ResolveLayoutInputProps<SchemaDefinitions<Props>> & {\n [Key in keyof ResolveLayoutProps<Omit<Props, keyof SchemaDefinitions<Props>>>]-?:\n ResolveLayoutProps<Omit<Props, keyof SchemaDefinitions<Props>>>[Key];\n };\n\nexport type RequiredPresetLayoutProps<Composables extends ComposableComponents> =\n PresetLayoutInputProps<PresetPropDefinitions<Composables>>;\n\nexport type ComposableComponents = Record<string, ComposableComponentCallable>;\n\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 return typeof component === 'function' ? component(props) : component;\n}\n\nfunction reactNodeFromSingleFieldOutProps(resolved: unknown): ReactNode {\n if (resolved === null || typeof resolved !== 'object') {\n return null;\n }\n\n const values = Object.values(resolved);\n\n if (values.length !== 1) {\n return null;\n }\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<Name, Wrapper, Resources, LayoutName, InProps, OutProps>);\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\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\n for (const key of inPropsKeys) {\n delete (wrapperProps as Record<string, unknown>)[key];\n }\n\n const mergedValues = resolvePropDefinitionValues(mergedInProps as Record<string, unknown>);\n const alreadyValidated = (options as unknown as Record<symbol, unknown>)[validatedComposableProps];\n const schemaDefinitions = alreadyValidated ? {} : Object.fromEntries(\n Object.entries(inProps ?? {}).filter(([, definition]) => isStandardSchema(definition)),\n );\n const mergedResolved = validateProps(schemaDefinitions, mergedValues) 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 // A single intrinsic child is the composable's root without adding a wrapper.\n if (propsRecord['data-rl-node'] && isValidElement(resolvedChildren) && typeof resolvedChildren.type === 'string') {\n return cloneElement(resolvedChildren, {\n 'data-rl-node': propsRecord['data-rl-node'],\n 'data-rl-composable': propsRecord['data-rl-composable'],\n 'data-rl-owners': propsRecord['data-rl-owners'],\n } as Record<string, unknown>);\n }\n return resolvedChildren;\n }\n\n Composable.displayName = name;\n\n const debugKey = Symbol.for('@jfdevelops/react-layout/debug');\n const debug = (options as unknown as Record<symbol, unknown>)[debugKey];\n\n return Object.assign(Composable, {\n ...(debug ? { [debugKey]: debug } : {}),\n props: undefined as unknown as ResolveProps<InProps>,\n }) as unknown as ComposableComponent<Name, Wrapper, InProps, OutProps>;\n}\n\ntype DefineComposableComponentOptions<\n Name extends string,\n Props extends InPropsObject,\n Wrapper = undefined\n> = {\n name: Name;\n props?: Props;\n wrapWith?: Wrapper;\n};\n\nexport type DefinedComposableComponentRecord<\n Name extends string,\n Props extends InPropsObject = {},\n Wrapper = undefined\n> = {\n [K in Name]: ComposablePresetComponent<Name, Props, Wrapper>;\n};\n\ntype DefinedComposableComponentFactory<\n Name extends string,\n Props extends InPropsObject,\n Wrapper = undefined,\n> = {\n props: Props;\n (\n render: (props: Show<WithChildren<ResolveProps<Props>>>) => ReactNode,\n ): DefinedComposableComponentRecord<Name, Props, Wrapper>;\n /** Customize this instance without changing the factory's defaults. */\n <\n const Overrides extends InPropsObject = {},\n const CustomName extends string = Name,\n CustomWrapper = Wrapper,\n >(options: {\n name?: CustomName;\n props?: Overrides | ((defaults: Props) => Overrides);\n wrapWith?: CustomWrapper;\n render: (\n props: Show<\n WithChildren<ResolveProps<Omit<Props, keyof Overrides> & Overrides>>\n >,\n ) => ReactNode;\n }): DefinedComposableComponentRecord<\n CustomName,\n Omit<Props, keyof Overrides> & Overrides,\n CustomWrapper\n >;\n};\n\nfunction resolvePresetComposableCallProps<Props extends InPropsObject>(\n presetKey: string,\n propDefinitions: Props,\n callProps: Record<string, unknown>\n) {\n const presetKeys = Object.keys(propDefinitions) as (keyof Props & string)[];\n const contextValues = useComposablePresetProps(presetKey) ?? {};\n const presetValues = Object.fromEntries(\n presetKeys.map((key) => [key,\n isStandardSchema(propDefinitions[key]) && Object.hasOwn(callProps, key)\n ? callProps[key]\n : callProps[key] ?? contextValues[key],\n ])\n );\n // Context values have already been validated by the owning layout.\n const definitions = Object.fromEntries(\n Object.entries(propDefinitions).filter(([key, definition]) =>\n !isStandardSchema(definition) || Object.hasOwn(callProps, key) || !Object.hasOwn(contextValues, key),\n ),\n );\n\n return validateProps(\n definitions,\n presetValues\n ) as Show<WithChildren<ResolveProps<Props>>>;\n}\n\nexport function defineComposableComponent<\n const Name extends string,\n Props extends InPropsObject = {},\n Wrapper = undefined\n>(\n options: DefineComposableComponentOptions<Name, Props, Wrapper>\n): DefinedComposableComponentFactory<Name, Props, Wrapper> {\n const { name, props = {} as Props, wrapWith } = options;\n\n const factory = (\n definition:\n | ((props: Show<WithChildren<ResolveProps<Props>>>) => ReactNode)\n | {\n name?: string;\n props?: InPropsObject | ((defaults: Props) => InPropsObject);\n wrapWith?: unknown;\n render: (props: any) => ReactNode;\n }\n ): DefinedComposableComponentRecord<Name, Props, Wrapper> => {\n if (typeof definition !== 'function') {\n const overrides =\n typeof definition.props === 'function'\n ? definition.props(props)\n : definition.props;\n\n return defineComposableComponent({\n ...options,\n name: definition.name ?? name,\n props: { ...props, ...overrides },\n wrapWith: 'wrapWith' in definition ? definition.wrapWith : wrapWith,\n })(definition.render) as unknown as DefinedComposableComponentRecord<\n Name,\n Props,\n Wrapper\n >;\n }\n\n const render = definition;\n const component = createComposableComponent<\n Name,\n Wrapper,\n Props,\n Show<WithChildren<ResolveProps<Props>>>\n >({\n name,\n wrapWith,\n inProps: props,\n outProps: (resolved) => resolved,\n ...{ [validatedComposableProps]: true },\n });\n\n function PresetComposable(\n callProps: ComposablePresetComponentCallProps<Props, Wrapper>\n ) {\n const callPropsRecord = callProps as Record<string, unknown>;\n const presetKeys = Object.keys(props) as (keyof Props & string)[];\n const validatedPresetProps = resolvePresetComposableCallProps(\n name,\n props,\n callPropsRecord\n );\n const wrapperProps = { ...callPropsRecord };\n\n for (const key of presetKeys) {\n delete wrapperProps[key];\n }\n\n return component({\n ...(wrapperProps as ComposableComponentWrapperProps<Wrapper>),\n ...validatedPresetProps,\n children: (resolved: Show<WithChildren<ResolveProps<Props>>>) => render({\n ...resolved,\n children: 'children' in props\n ? (validatedPresetProps as Record<string, unknown>).children\n : callPropsRecord.children,\n } as Show<WithChildren<ResolveProps<Props>>>),\n } as unknown as ComposableComponentProps<Wrapper, Props, Show<WithChildren<ResolveProps<Props>>>>);\n }\n\n PresetComposable.displayName = name;\n\n const debugKey = Symbol.for('@jfdevelops/react-layout/debug');\n const debug = (options as unknown as Record<symbol, unknown>)[debugKey];\n const presetComponent = Object.assign(PresetComposable, {\n ...(debug ? { [debugKey]: debug } : {}),\n props: undefined as unknown as Show<WithChildren<ResolveProps<Props>>>,\n [composablePresetMetaKey]: {\n key: name,\n props,\n } satisfies ComposablePresetMeta<Props>,\n }) as unknown as DefinedComposableComponentRecord<\n Name,\n Props,\n Wrapper\n >[Name];\n\n return {\n [name]: presetComponent,\n } as DefinedComposableComponentRecord<Name, Props, Wrapper>;\n };\n\n Object.defineProperty(factory, 'props', {\n enumerable: true,\n value: props,\n });\n\n return factory as DefinedComposableComponentFactory<Name, Props, Wrapper>;\n}\n\nexport type MakeComposableOptions<\n Composables extends ComposableComponents,\n Name extends string\n> = { components: Composables | undefined; name: Name };\n\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 InvalidComponentsError('components must be an object');\n }\n\n const componentNames = Object.keys(components);\n\n if (componentNames.length === 0) {\n throw new EmptyComponentsError(\n 'components must have at least one component'\n );\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":";;;;;;AAkBA,MAAa,0BAA0B,OAAO,IAC5C,iCACF;AAEA,MAAM,2BAA2B,OAAO,0BAA0B;AAUlE,MAAM,wDAEJ,MAAS;AAEX,SAAgB,+BAA+B,EAC7C,OACA,YAIC;CACD,OACE,2CAAC,6BAA6B,UAA9B;EAA8C;EAC3C;CACoC;AAE3C;AAEA,SAAS,yBAAyB,KAAa;CAC7C,6BAAkB,4BAA4B,IAAI;AACpD;AAEA,SAAgB,+BACd,aACA;CACA,IAAI,CAAC,aACH,OAAO,CAAC;CAMV,OAAO,OAAO,QAAQ,WAAW,EAAE,SAAS,CAAC,WAAW,eAAe;EACrE,MAAM,OAAQ,UACZ;EAGF,IAAI,CAAC,MACH,OAAO,CAAC;EAGV,OAAO,CACL;GACE,KAAK,KAAK,OAAO;GACjB,OAAO,KAAK;EACd,CACF;CACF,CAAC;AACH;AAEA,SAAgB,6BACd,aACA,eACA,SACA;CACA,MAAM,WAAkC,CAAC;CAEzC,KAAK,MAAM,EAAE,KAAK,WAAW,+BAA+B,WAAW,GAYrE,SAAS,6DACP,OAXa,OAAO,YADL,OAAO,KAAK,KAEpB,EAAE,SAAS,YAAY;EAC5B,IAAI,EAAE,WAAW,gBACf,OAAO,CAAC;EAGV,OAAO,CAAC,CAAC,SAAS,cAAc,QAAQ,CAAC;CAC3C,CAAC,CAKI,GACL,OACF;CAGF,OAAO;AACT;AA6MA,SAAS,iBACP,WACA,OACA;CACA,OAAO,OAAO,cAAc,aAAa,UAAU,KAAK,IAAI;AAC9D;AAEA,SAAS,iCAAiC,UAA8B;CACtE,IAAI,aAAa,QAAQ,OAAO,aAAa,UAC3C,OAAO;CAGT,MAAM,SAAS,OAAO,OA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M,kBAAkB;GACxB,MAAM,aAAa,OAAO,KAAK,KAAK;GACpC,MAAM,uBAAuB,iCAC3B,MACA,OACA,eACF;GACA,MAAM,eAAe,EAAE,GAAG,gBAAgB;GAE1C,KAAK,MAAM,OAAO,YAChB,OAAO,aAAa;GAGtB,OAAO,UAAU;IACf,GAAI;IACJ,GAAG;IACH,WAAW,aAAsD,OAAO;KACtE,GAAG;KACH,UAAU,cAAc,QACnB,qBAAiD,WAClD,gBAAgB;IACtB,CAA4C;GAC9C,CAAiG;EACnG;EAEA,iBAAiB,cAAc;EAE/B,MAAM,WAAW,OAAO,IAAI,gCAAgC;EAC5D,MAAM,QAAS,QAA+C;EAC9D,MAAM,kBAAkB,OAAO,OAAO,kBAAkB;GACtD,GAAI,QAAQ,GAAG,WAAW,MAAM,IAAI,CAAC;GACrC,OAAO;IACN,0BAA0B;IACzB,KAAK;IACL;GACF;EACF,CAAC;EAMD,OAAO,GACJ,OAAO,gBACV;CACF;CAEA,OAAO,eAAe,SAAS,SAAS;EACtC,YAAY;EACZ,OAAO;CACT,CAAC;CAED,OAAO;AACT;AAgBA,SAAgB,iBAAwB;CACtC,OAAO,SAGL,SAAmD;EACnD,MAAM,EAAE,YAAY,MAAM,eAAe;EAEzC,IAAI,CAAC,cAAc,OAAO,eAAe,UACvC,MAAM,IAAIC,sCAAuB,8BAA8B;EAKjE,IAFuB,OAAO,KAAK,UAElB,EAAE,WAAW,GAC5B,MAAM,IAAIC,oCACR,6CACF;EAGF,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"}
1
+ {"version":3,"file":"composable.cjs","names":["Comp","InvalidComponentsError","EmptyComponentsError"],"sources":["../src/composable.tsx"],"sourcesContent":["import {\n ComponentType,\n createContext,\n ReactNode,\n useContext,\n cloneElement,\n isValidElement,\n} from 'react';\nimport { EmptyComponentsError, InvalidComponentsError } from './errors';\nimport {\n PropDefinition,\n type PropValidationContext,\n ResolveProps,\n ResolveInputProps,\n type StandardSchemaV1,\n resolvePropDefinitionValues,\n validateProps,\n} from '@jfdevelops/react-layout-validator';\nimport { InPropsObject, type WithChildren } from './types';\nimport type {\n BaseComponent,\n CapitalizeFn,\n Show,\n UnionToIntersection,\n} from '@jfdevelops/react-layout-internals';\n\nexport const composablePresetMetaKey = Symbol.for(\n 'view-map.composable-preset-meta',\n);\n\nconst validatedComposableProps = Symbol('validatedComposableProps');\n\nexport type ComposablePresetMeta<Props extends InPropsObject = InPropsObject> =\n {\n key: string;\n props: Props;\n };\n\nexport type ComposablePresetProps = Record<string, Record<string, unknown>>;\n\nconst composablePresetPropsContext = createContext<\n ComposablePresetProps | undefined\n>(undefined);\n\nexport function LayoutComposablePresetProvider({\n value,\n children,\n}: {\n value: ComposablePresetProps;\n children: ReactNode;\n}) {\n return (\n <composablePresetPropsContext.Provider value={value}>\n {children}\n </composablePresetPropsContext.Provider>\n );\n}\n\nfunction useComposablePresetProps(key: string) {\n return useContext(composablePresetPropsContext)?.[key];\n}\n\nexport function collectComposablePresetEntries(\n composables: ComposableComponents | undefined,\n) {\n if (!composables) {\n return [] as Array<{\n key: string;\n props: InPropsObject;\n }>;\n }\n\n return Object.entries(composables).flatMap(([objectKey, component]) => {\n const meta = (component as ComposablePresetComponent)[\n composablePresetMetaKey\n ];\n\n if (!meta) {\n return [];\n }\n\n return [\n {\n key: meta.key ?? objectKey,\n props: meta.props,\n },\n ];\n });\n}\n\nexport function resolveComposablePresetProps(\n composables: ComposableComponents | undefined,\n layoutOptions: Record<string, unknown>,\n context?: PropValidationContext,\n) {\n const resolved: ComposablePresetProps = {};\n\n for (const { key, props } of collectComposablePresetEntries(composables)) {\n const propKeys = Object.keys(props);\n const values = Object.fromEntries(\n propKeys.flatMap((propKey) => {\n if (!(propKey in layoutOptions)) {\n return [];\n }\n\n return [[propKey, layoutOptions[propKey]]];\n }),\n );\n\n resolved[key] = validateProps(\n props as Record<string, PropDefinition>,\n values,\n context,\n );\n }\n\n return resolved;\n}\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> : {};\n\ntype ComposableComponentWrapperProps<Wrapper> =\n Wrapper extends ComponentType<infer Props> ? Omit<Props, 'children'> : {};\n\ntype ComposableComponentProps<\n Wrapper,\n InProps extends InPropsObject = {},\n OutProps = {},\n> = ComposableComponentWrapperProps<Wrapper> &\n (keyof InProps extends never ? {} : ResolveInputProps<InProps>) & {\n children?: [keyof InProps] extends [never]\n ? ReactNode\n : ((props: OutProps) => JSX.Element) | ReactNode;\n };\n\nexport type ComposableComponent<\n Name extends string,\n Wrapper,\n InProps extends InPropsObject = {},\n OutProps = {},\n> = BaseComponent<Name, ResolveInputProps<InProps>> & {\n (props: ComposableComponentProps<Wrapper, InProps, OutProps>): ReactNode;\n};\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<\n string,\n any,\n InPropsObject,\n any\n>;\n\n/**\n * Minimal callable shape shared by layout and preset composables.\n * Used as the record value so preset components keep their own prop types.\n */\nexport type ComposableComponentCallable = {\n displayName: string;\n props: unknown;\n (...args: any[]): ReactNode;\n};\n\n// Separate installed versions declare distinct unique symbols for the same\n// Symbol.for key. Read the metadata structurally so their presets interoperate.\ntype PresetPropsFromMetadata<Component> = {\n [Key in keyof Component]-?: Key extends symbol\n ? Component[Key] extends ComposablePresetMeta<infer Props>\n ? Props\n : never\n : never;\n}[keyof Component];\n\nexport type PresetPropsFromComposable<Component> = Component extends {\n [composablePresetMetaKey]: ComposablePresetMeta<infer Props>;\n}\n ? Props\n : [PresetPropsFromMetadata<Component>] extends [never]\n ? {}\n : PresetPropsFromMetadata<Component>;\n\nexport type MergePresetProps<Composables extends ComposableComponents> = Show<\n UnionToIntersection<PresetPropsFromComposable<Composables[keyof Composables]>>\n>;\n\nexport type RequiredPresetRenderProps<Props extends InPropsObject> = {\n [K in keyof ResolveProps<Props> & string]-?: ResolveProps<Props>[K];\n};\n\ntype SchemaDefinitions<Props extends InPropsObject> = {\n [\n Key in keyof Props as Props[Key] extends StandardSchemaV1 ? Key : never\n ]: Props[Key];\n};\n\ntype PresetInputProps<Props extends InPropsObject> = ResolveInputProps<\n SchemaDefinitions<Props>\n> &\n RequiredPresetRenderProps<Omit<Props, keyof SchemaDefinitions<Props>>>;\n\nexport type ComposablePresetComponentCallProps<\n Props extends InPropsObject,\n Wrapper = undefined,\n> = WithChildren<PresetInputProps<Props>> &\n (Wrapper extends undefined ? {} : ComposableComponentWrapperProps<Wrapper>);\n\nexport type ComposablePresetComponent<\n Name extends string = string,\n Props extends InPropsObject = InPropsObject,\n Wrapper = undefined,\n> = BaseComponent<Name, Show<WithChildren<ResolveInputProps<Props>>>> & {\n [composablePresetMetaKey]: ComposablePresetMeta<Props>;\n} & ((props: ComposablePresetComponentCallProps<Props, Wrapper>) => ReactNode);\n\ntype PresetPropDefinitions<Composables extends ComposableComponents> =\n MergePresetProps<Composables> extends InPropsObject\n ? MergePresetProps<Composables>\n : {};\n\ntype PresetLayoutInputProps<Props extends InPropsObject> = ResolveInputProps<\n SchemaDefinitions<Props>\n> & {\n [\n Key in keyof ResolveProps<Omit<Props, keyof SchemaDefinitions<Props>>>\n ]-?: ResolveProps<Omit<Props, keyof SchemaDefinitions<Props>>>[Key];\n};\n\nexport type RequiredPresetLayoutProps<\n Composables extends ComposableComponents,\n> = PresetLayoutInputProps<PresetPropDefinitions<Composables>>;\n\nexport type ComposableComponents = Record<string, ComposableComponentCallable>;\n\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 return typeof component === 'function' ? component(props) : component;\n}\n\nfunction reactNodeFromSingleFieldOutProps(resolved: unknown): ReactNode {\n if (resolved === null || typeof resolved !== 'object') {\n return null;\n }\n\n const values = Object.values(resolved);\n\n if (values.length !== 1) {\n return null;\n }\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 = {\n ...inProps,\n };\n const propsRecord = props as Record<string, unknown>;\n\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\n for (const key of inPropsKeys) {\n delete (wrapperProps as Record<string, unknown>)[key];\n }\n\n const mergedValues = resolvePropDefinitionValues(\n mergedInProps as Record<string, unknown>,\n );\n const alreadyValidated = (options as unknown as Record<symbol, unknown>)[\n validatedComposableProps\n ];\n const mergedResolved = validateProps(\n alreadyValidated ? {} : inProps,\n mergedValues,\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 // A single intrinsic child is the composable's root without adding a wrapper.\n if (\n propsRecord['data-rl-node'] &&\n isValidElement(resolvedChildren) &&\n typeof resolvedChildren.type === 'string'\n ) {\n return cloneElement(resolvedChildren, {\n 'data-rl-node': propsRecord['data-rl-node'],\n 'data-rl-composable': propsRecord['data-rl-composable'],\n 'data-rl-owners': propsRecord['data-rl-owners'],\n } as Record<string, unknown>);\n }\n\n return resolvedChildren;\n }\n\n Composable.displayName = name;\n\n const debugKey = Symbol.for('@jfdevelops/react-layout/debug');\n const debug = (options as unknown as Record<symbol, unknown>)[debugKey];\n\n return Object.assign(Composable, {\n ...(debug\n ? {\n [debugKey]: debug,\n }\n : {}),\n props: undefined as unknown as ResolveProps<InProps>,\n }) as unknown as ComposableComponent<Name, Wrapper, InProps, OutProps>;\n}\n\ntype DefineComposableComponentOptions<\n Name extends string,\n Props extends InPropsObject,\n Wrapper = undefined,\n> = {\n name: Name;\n props?: Props;\n wrapWith?: Wrapper;\n};\n\nexport type DefinedComposableComponentRecord<\n Name extends string,\n Props extends InPropsObject = {},\n Wrapper = undefined,\n> = {\n [K in Name]: ComposablePresetComponent<Name, Props, Wrapper>;\n};\n\ntype DefinedComposableComponentFactory<\n Name extends string,\n Props extends InPropsObject,\n Wrapper = undefined,\n> = {\n props: Props;\n (\n render: (props: Show<WithChildren<ResolveProps<Props>>>) => ReactNode,\n ): DefinedComposableComponentRecord<Name, Props, Wrapper>;\n /**\n * Customize this instance without changing the factory's defaults.\n */\n <\n const Overrides extends InPropsObject = {},\n const CustomName extends string = Name,\n CustomWrapper = Wrapper,\n >(options: {\n name?: CustomName;\n props?: Overrides | ((defaults: Props) => Overrides);\n wrapWith?: CustomWrapper;\n render: (\n props: Show<\n WithChildren<ResolveProps<Omit<Props, keyof Overrides> & Overrides>>\n >,\n ) => ReactNode;\n }): DefinedComposableComponentRecord<\n CustomName,\n Omit<Props, keyof Overrides> & Overrides,\n CustomWrapper\n >;\n};\n\nfunction resolvePresetComposableCallProps<Props extends InPropsObject>(\n presetKey: string,\n propDefinitions: Props,\n callProps: Record<string, unknown>,\n) {\n const presetKeys = Object.keys(propDefinitions) as (keyof Props & string)[];\n const contextValues = useComposablePresetProps(presetKey) ?? {};\n const presetValues = Object.fromEntries(\n presetKeys.map((key) => [\n key,\n Object.hasOwn(callProps, key) ? callProps[key] : contextValues[key],\n ]),\n );\n // Context values have already been validated by the owning layout.\n const definitions = Object.fromEntries(\n Object.entries(propDefinitions).filter(\n ([key]) =>\n Object.hasOwn(callProps, key) || !Object.hasOwn(contextValues, key),\n ),\n );\n\n return validateProps(definitions, presetValues) as Show<\n WithChildren<ResolveProps<Props>>\n >;\n}\n\nexport function defineComposableComponent<\n const Name extends string,\n Props extends InPropsObject = {},\n Wrapper = undefined,\n>(\n options: DefineComposableComponentOptions<Name, Props, Wrapper>,\n): DefinedComposableComponentFactory<Name, Props, Wrapper> {\n const { name, props = {} as Props, wrapWith } = options;\n\n const factory = (\n definition:\n | ((props: Show<WithChildren<ResolveProps<Props>>>) => ReactNode)\n | {\n name?: string;\n props?: InPropsObject | ((defaults: Props) => InPropsObject);\n wrapWith?: unknown;\n render: (props: any) => ReactNode;\n },\n ): DefinedComposableComponentRecord<Name, Props, Wrapper> => {\n if (typeof definition !== 'function') {\n const overrides =\n typeof definition.props === 'function'\n ? definition.props(props)\n : definition.props;\n\n return defineComposableComponent({\n ...options,\n name: definition.name ?? name,\n props: {\n ...props,\n ...overrides,\n },\n wrapWith: 'wrapWith' in definition ? definition.wrapWith : wrapWith,\n })(definition.render) as unknown as DefinedComposableComponentRecord<\n Name,\n Props,\n Wrapper\n >;\n }\n\n const render = definition;\n const component = createComposableComponent<\n Name,\n Wrapper,\n Props,\n Show<WithChildren<ResolveProps<Props>>>\n >({\n name,\n wrapWith,\n inProps: props,\n outProps: (resolved) => resolved as never,\n ...{\n [validatedComposableProps]: true,\n },\n });\n\n function PresetComposable(\n callProps: ComposablePresetComponentCallProps<Props, Wrapper>,\n ) {\n const callPropsRecord = callProps as Record<string, unknown>;\n const presetKeys = Object.keys(props) as (keyof Props & string)[];\n const validatedPresetProps = resolvePresetComposableCallProps(\n name,\n props,\n callPropsRecord,\n );\n const wrapperProps = {\n ...callPropsRecord,\n };\n\n for (const key of presetKeys) {\n delete wrapperProps[key];\n }\n\n return component({\n ...(wrapperProps as ComposableComponentWrapperProps<Wrapper>),\n ...validatedPresetProps,\n children: (resolved: Show<WithChildren<ResolveProps<Props>>>) =>\n render({\n ...resolved,\n children:\n 'children' in props\n ? (validatedPresetProps as Record<string, unknown>).children\n : callPropsRecord.children,\n } as Show<WithChildren<ResolveProps<Props>>>),\n } as unknown as ComposableComponentProps<\n Wrapper,\n Props,\n Show<WithChildren<ResolveProps<Props>>>\n >);\n }\n\n PresetComposable.displayName = name;\n\n const debugKey = Symbol.for('@jfdevelops/react-layout/debug');\n const debug = (options as unknown as Record<symbol, unknown>)[debugKey];\n const presetComponent = Object.assign(PresetComposable, {\n ...(debug\n ? {\n [debugKey]: debug,\n }\n : {}),\n props: undefined as unknown as Show<WithChildren<ResolveProps<Props>>>,\n [composablePresetMetaKey]: {\n key: name,\n props,\n } satisfies ComposablePresetMeta<Props>,\n }) as unknown as DefinedComposableComponentRecord<\n Name,\n Props,\n Wrapper\n >[Name];\n\n return {\n [name]: presetComponent,\n } as DefinedComposableComponentRecord<Name, Props, Wrapper>;\n };\n\n Object.defineProperty(factory, 'props', {\n enumerable: true,\n value: props,\n });\n\n return factory as DefinedComposableComponentFactory<Name, Props, Wrapper>;\n}\n\nexport type MakeComposableOptions<\n Composables extends ComposableComponents,\n Name extends string,\n> = {\n components: Composables | undefined;\n name: Name;\n};\n\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 InvalidComponentsError('components must be an object');\n }\n\n const componentNames = Object.keys(components);\n\n if (componentNames.length === 0) {\n throw new EmptyComponentsError(\n 'components must have at least one component',\n );\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":";;;;;;AA0BA,MAAa,0BAA0B,OAAO,IAC5C,iCACF;AAEA,MAAM,2BAA2B,OAAO,0BAA0B;AAUlE,MAAM,wDAEJ,MAAS;AAEX,SAAgB,+BAA+B,EAC7C,OACA,YAIC;CACD,OACE,2CAAC,6BAA6B,UAA9B;EAA8C;EAC3C;CACoC;AAE3C;AAEA,SAAS,yBAAyB,KAAa;CAC7C,6BAAkB,4BAA4B,IAAI;AACpD;AAEA,SAAgB,+BACd,aACA;CACA,IAAI,CAAC,aACH,OAAO,CAAC;CAMV,OA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;CACtC,OAAO,SAGL,SAAmD;EACnD,MAAM,EAAE,YAAY,MAAM,eAAe;EAEzC,IAAI,CAAC,cAAc,OAAO,eAAe,UACvC,MAAM,IAAIC,sCAAuB,8BAA8B;EAKjE,IAFuB,OAAO,KAAK,UAElB,EAAE,WAAW,GAC5B,MAAM,IAAIC,oCACR,6CACF;EAGF,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"}
@@ -1,8 +1,8 @@
1
1
  import { InPropsObject, WithChildren } from "./types.cjs";
2
- import { BaseComponent, Show, UnionToIntersection } from "./utils.cjs";
3
- import { CapitalizeFn } from "./utils/capitalize.cjs";
4
- import { PropValidationContext, ResolveInputProps, ResolveLayoutInputProps, ResolveLayoutProps, ResolveProps, StandardSchemaV1 } from "@jfdevelops/react-layout-validator";
2
+ import { CapitalizeFn } from "./packages/internals/src/capitalize.cjs";
3
+ import { BaseComponent, Show, UnionToIntersection } from "./packages/internals/src/types.cjs";
5
4
  import { ComponentType, ReactNode } from "react";
5
+ import { PropValidationContext, ResolveInputProps, ResolveProps, StandardSchemaV1 } from "@jfdevelops/react-layout-validator";
6
6
 
7
7
  //#region src/composable.d.ts
8
8
  declare const composablePresetMetaKey: unique symbol;
@@ -72,7 +72,7 @@ type ComposablePresetComponent<Name extends string = string, Props extends InPro
72
72
  [composablePresetMetaKey]: ComposablePresetMeta<Props>;
73
73
  } & ((props: ComposablePresetComponentCallProps<Props, Wrapper>) => ReactNode);
74
74
  type PresetPropDefinitions<Composables extends ComposableComponents> = MergePresetProps<Composables> extends InPropsObject ? MergePresetProps<Composables> : {};
75
- type PresetLayoutInputProps<Props extends InPropsObject> = ResolveLayoutInputProps<SchemaDefinitions<Props>> & { [Key in keyof ResolveLayoutProps<Omit<Props, keyof SchemaDefinitions<Props>>>]-?: ResolveLayoutProps<Omit<Props, keyof SchemaDefinitions<Props>>>[Key] };
75
+ type PresetLayoutInputProps<Props extends InPropsObject> = ResolveInputProps<SchemaDefinitions<Props>> & { [Key in keyof ResolveProps<Omit<Props, keyof SchemaDefinitions<Props>>>]-?: ResolveProps<Omit<Props, keyof SchemaDefinitions<Props>>>[Key] };
76
76
  type RequiredPresetLayoutProps<Composables extends ComposableComponents> = PresetLayoutInputProps<PresetPropDefinitions<Composables>>;
77
77
  type ComposableComponents = Record<string, ComposableComponentCallable>;
78
78
  declare function createLayoutComposableFactory<Resources extends string, LayoutName extends string>(ctx: ComposableNameContext<Resources, LayoutName>): CreateLayoutComposable<Resources, LayoutName>;
@@ -86,7 +86,10 @@ type DefineComposableComponentOptions<Name extends string, Props extends InProps
86
86
  type DefinedComposableComponentRecord<Name extends string, Props extends InPropsObject = {}, Wrapper = undefined> = { [K in Name]: ComposablePresetComponent<Name, Props, Wrapper> };
87
87
  type DefinedComposableComponentFactory<Name extends string, Props extends InPropsObject, Wrapper = undefined> = {
88
88
  props: Props;
89
- (render: (props: Show<WithChildren<ResolveProps<Props>>>) => ReactNode): DefinedComposableComponentRecord<Name, Props, Wrapper>; /** Customize this instance without changing the factory's defaults. */
89
+ (render: (props: Show<WithChildren<ResolveProps<Props>>>) => ReactNode): DefinedComposableComponentRecord<Name, Props, Wrapper>;
90
+ /**
91
+ * Customize this instance without changing the factory's defaults.
92
+ */
90
93
  <const Overrides extends InPropsObject = {}, const CustomName extends string = Name, CustomWrapper = Wrapper>(options: {
91
94
  name?: CustomName;
92
95
  props?: Overrides | ((defaults: Props) => Overrides);
@@ -1 +1 @@
1
- {"version":3,"file":"composable.d.cts","names":[],"sources":["../src/composable.tsx"],"mappings":";;;;;;;cAkBa,uBAAA;AAAA,KAMD,oBAAA,eAAmC,aAAA,GAAgB,aAAA;EAE3D,GAAA;EACA,KAAA,EAAO,KAAA;AAAA;AAAA,KAGC,qBAA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,EAAU,KAAA,KAAU,SAAA;IAC1C,QAAA,GAAW,aAAA;IACX,MAAA,GACE,KAAA,EAAO,IAAA,CACL,YAAA,CAAa,YAAA,CAAa,IAAA,CAAK,KAAA,QAAa,SAAA,IAAa,SAAA,QAExD,SAAA;EAAA,IACH,gCAAA,CACF,UAAA,EACA,IAAA,CAAK,KAAA,QAAa,SAAA,IAAa,SAAA,EAC/B,aAAA;AAAA;AAAA,iBA8BY,yBAAA,0CAEA,aAAA,4BAGd,OAAA,EAAS,gCAAA,CAAiC,IAAA,EAAM,KAAA,EAAO,OAAA,IACtD,iCAAA,CAAkC,IAAA,EAAM,KAAA,EAAO,OAAA;AAAA,KAwHtC,qBAAA,qBACU,oBAAA;EAGpB,UAAA,EAAY,WAAA;EACZ,IAAA,EAAM,IAAA;AAAA;AAAA,KAGI,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"}
@@ -1,8 +1,8 @@
1
1
  import { InPropsObject, WithChildren } from "./types.mjs";
2
- import { BaseComponent, Show, UnionToIntersection } from "./utils.mjs";
3
- import { CapitalizeFn } from "./utils/capitalize.mjs";
4
- import { PropValidationContext, ResolveInputProps, ResolveLayoutInputProps, ResolveLayoutProps, ResolveProps, StandardSchemaV1 } from "@jfdevelops/react-layout-validator";
2
+ import { CapitalizeFn } from "./packages/internals/src/capitalize.mjs";
3
+ import { BaseComponent, Show, UnionToIntersection } from "./packages/internals/src/types.mjs";
5
4
  import { ComponentType, ReactNode } from "react";
5
+ import { PropValidationContext, ResolveInputProps, ResolveProps, StandardSchemaV1 } from "@jfdevelops/react-layout-validator";
6
6
 
7
7
  //#region src/composable.d.ts
8
8
  declare const composablePresetMetaKey: unique symbol;
@@ -72,7 +72,7 @@ type ComposablePresetComponent<Name extends string = string, Props extends InPro
72
72
  [composablePresetMetaKey]: ComposablePresetMeta<Props>;
73
73
  } & ((props: ComposablePresetComponentCallProps<Props, Wrapper>) => ReactNode);
74
74
  type PresetPropDefinitions<Composables extends ComposableComponents> = MergePresetProps<Composables> extends InPropsObject ? MergePresetProps<Composables> : {};
75
- type PresetLayoutInputProps<Props extends InPropsObject> = ResolveLayoutInputProps<SchemaDefinitions<Props>> & { [Key in keyof ResolveLayoutProps<Omit<Props, keyof SchemaDefinitions<Props>>>]-?: ResolveLayoutProps<Omit<Props, keyof SchemaDefinitions<Props>>>[Key] };
75
+ type PresetLayoutInputProps<Props extends InPropsObject> = ResolveInputProps<SchemaDefinitions<Props>> & { [Key in keyof ResolveProps<Omit<Props, keyof SchemaDefinitions<Props>>>]-?: ResolveProps<Omit<Props, keyof SchemaDefinitions<Props>>>[Key] };
76
76
  type RequiredPresetLayoutProps<Composables extends ComposableComponents> = PresetLayoutInputProps<PresetPropDefinitions<Composables>>;
77
77
  type ComposableComponents = Record<string, ComposableComponentCallable>;
78
78
  declare function createLayoutComposableFactory<Resources extends string, LayoutName extends string>(ctx: ComposableNameContext<Resources, LayoutName>): CreateLayoutComposable<Resources, LayoutName>;
@@ -86,7 +86,10 @@ type DefineComposableComponentOptions<Name extends string, Props extends InProps
86
86
  type DefinedComposableComponentRecord<Name extends string, Props extends InPropsObject = {}, Wrapper = undefined> = { [K in Name]: ComposablePresetComponent<Name, Props, Wrapper> };
87
87
  type DefinedComposableComponentFactory<Name extends string, Props extends InPropsObject, Wrapper = undefined> = {
88
88
  props: Props;
89
- (render: (props: Show<WithChildren<ResolveProps<Props>>>) => ReactNode): DefinedComposableComponentRecord<Name, Props, Wrapper>; /** Customize this instance without changing the factory's defaults. */
89
+ (render: (props: Show<WithChildren<ResolveProps<Props>>>) => ReactNode): DefinedComposableComponentRecord<Name, Props, Wrapper>;
90
+ /**
91
+ * Customize this instance without changing the factory's defaults.
92
+ */
90
93
  <const Overrides extends InPropsObject = {}, const CustomName extends string = Name, CustomWrapper = Wrapper>(options: {
91
94
  name?: CustomName;
92
95
  props?: Overrides | ((defaults: Props) => Overrides);
@@ -1 +1 @@
1
- {"version":3,"file":"composable.d.mts","names":[],"sources":["../src/composable.tsx"],"mappings":";;;;;;;cAkBa,uBAAA;AAAA,KAMD,oBAAA,eAAmC,aAAA,GAAgB,aAAA;EAE3D,GAAA;EACA,KAAA,EAAO,KAAA;AAAA;AAAA,KAGC,qBAAA,GAAwB,MAAM,SAAS,MAAA;AAAA,iBAMnC,8BAAA;EACd,KAAA;EACA;AAAA;EAEA,KAAA,EAAO,qBAAA;EACP,QAAA,EAAU,SAAA;AAAA,gCACX,GAAA,CAAA,OAAA;AAAA,iBAYe,8BAAA,CACd,WAAA,EAAa,oBAAA;;SAKF,aAAa;AAAA;AAAA,iBAsBV,4BAAA,CACd,WAAA,EAAa,oBAAA,cACb,aAAA,EAAe,MAAA,mBACf,OAAA,GAAU,qBAAA,GAAqB,qBAAA;AAAA,KA0BrB,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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chema, resolvePropDefinitionValues, validateProps } from "@jfdevelops/react-layout-validator";
3
2
  import { cloneElement, createContext, isValidElement, useContext } from "react";
3
+ import { resolvePropDefinitionValues, validateProps } from "@jfdevelops/react-layout-validator";
4
4
  import { jsx } from "react/jsx-runtime";
5
5
 
6
6
  //#region src/composable.tsx
@@ -67,7 +67,8 @@ function createComposableComponent(options) {
67
67
  const wrapperProps = { ...propsRecord };
68
68
  for (const key of inPropsKeys) delete wrapperProps[key];
69
69
  const mergedValues = resolvePropDefinitionValues(mergedInProps);
70
- const mergedResolved = validateProps(options[validatedComposableProps] ? {} : Object.fromEntries(Object.entries(inProps ?? {}).filter(([, definition]) => isStandardSchema(definition))), mergedValues);
70
+ const alreadyValidated = options[validatedComposableProps];
71
+ const mergedResolved = validateProps(alreadyValidated ? {} : inProps, mergedValues);
71
72
  const resolvedProps = outProps ? outProps(mergedResolved) : {};
72
73
  const resolvedChildren = children == null ? reactNodeFromSingleFieldOutProps(resolvedProps) : resolveComponent(children, resolvedProps);
73
74
  if (wrapWith) return /* @__PURE__ */ jsx(wrapWith, {
@@ -92,8 +93,8 @@ function createComposableComponent(options) {
92
93
  function resolvePresetComposableCallProps(presetKey, propDefinitions, callProps) {
93
94
  const presetKeys = Object.keys(propDefinitions);
94
95
  const contextValues = useComposablePresetProps(presetKey) ?? {};
95
- const presetValues = Object.fromEntries(presetKeys.map((key) => [key, isStandardSchema(propDefinitions[key]) && Object.hasOwn(callProps, key) ? callProps[key] : callProps[key] ?? contextValues[key]]));
96
- return validateProps(Object.fromEntries(Object.entries(propDefinitions).filter(([key, definition]) => !isStandardSchema(definition) || Object.hasOwn(callProps, key) || !Object.hasOwn(contextValues, key))), presetValues);
96
+ const presetValues = Object.fromEntries(presetKeys.map((key) => [key, Object.hasOwn(callProps, key) ? callProps[key] : contextValues[key]]));
97
+ return validateProps(Object.fromEntries(Object.entries(propDefinitions).filter(([key]) => Object.hasOwn(callProps, key) || !Object.hasOwn(contextValues, key))), presetValues);
97
98
  }
98
99
  function defineComposableComponent(options) {
99
100
  const { name, props = {}, wrapWith } = options;
@@ -1 +1 @@
1
- {"version":3,"file":"composable.mjs","names":["Comp"],"sources":["../src/composable.tsx"],"sourcesContent":["import { ComponentType, createContext, ReactNode, useContext, cloneElement, isValidElement } from 'react';\nimport { EmptyComponentsError, InvalidComponentsError } from './errors';\nimport {\n AnyBuiltPropDefinition,\n type PropValidationContext,\n ResolveLayoutProps,\n ResolveProps,\n ResolveInputProps,\n ResolveLayoutInputProps,\n type StandardSchemaV1,\n isStandardSchema,\n resolvePropDefinitionValues,\n validateProps,\n} from '@jfdevelops/react-layout-validator';\nimport { InPropsObject, type WithChildren } from './types';\nimport { BaseComponent, Show, UnionToIntersection } from './utils';\nimport { CapitalizeFn } from './utils/capitalize';\n\nexport const composablePresetMetaKey = Symbol.for(\n 'view-map.composable-preset-meta'\n);\n\nconst validatedComposableProps = Symbol('validatedComposableProps');\n\nexport type ComposablePresetMeta<Props extends InPropsObject = InPropsObject> =\n {\n key: string;\n props: Props;\n };\n\nexport type ComposablePresetProps = Record<string, Record<string, unknown>>;\n\nconst composablePresetPropsContext = createContext<\n ComposablePresetProps | undefined\n>(undefined);\n\nexport function LayoutComposablePresetProvider({\n value,\n children,\n}: {\n value: ComposablePresetProps;\n children: ReactNode;\n}) {\n return (\n <composablePresetPropsContext.Provider value={value}>\n {children}\n </composablePresetPropsContext.Provider>\n );\n}\n\nfunction useComposablePresetProps(key: string) {\n return useContext(composablePresetPropsContext)?.[key];\n}\n\nexport function collectComposablePresetEntries(\n composables: ComposableComponents | undefined\n) {\n if (!composables) {\n return [] as Array<{\n key: string;\n props: InPropsObject;\n }>;\n }\n\n return Object.entries(composables).flatMap(([objectKey, component]) => {\n const meta = (component as ComposablePresetComponent)[\n composablePresetMetaKey\n ];\n\n if (!meta) {\n return [];\n }\n\n return [\n {\n key: meta.key ?? objectKey,\n props: meta.props,\n },\n ];\n });\n}\n\nexport function resolveComposablePresetProps(\n composables: ComposableComponents | undefined,\n layoutOptions: Record<string, unknown>,\n context?: PropValidationContext\n) {\n const resolved: ComposablePresetProps = {};\n\n for (const { key, props } of collectComposablePresetEntries(composables)) {\n const propKeys = Object.keys(props);\n const values = Object.fromEntries(\n propKeys.flatMap((propKey) => {\n if (!(propKey in layoutOptions)) {\n return [];\n }\n\n return [[propKey, layoutOptions[propKey]]];\n })\n );\n\n resolved[key] = validateProps(\n props as Record<string, AnyBuiltPropDefinition>,\n values,\n context\n );\n }\n\n return resolved;\n}\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> : {};\n\ntype ComposableComponentWrapperProps<Wrapper> = Wrapper extends ComponentType<\n infer Props\n>\n ? Omit<Props, 'children'>\n : {};\n\ntype ComposableComponentProps<\n Wrapper,\n InProps extends InPropsObject = {},\n OutProps = {}\n> = ComposableComponentWrapperProps<Wrapper> &\n (keyof InProps extends never ? {} : ResolveInputProps<InProps>) & {\n children?: [keyof InProps] extends [never]\n ? ReactNode\n : ((props: OutProps) => JSX.Element) | ReactNode;\n };\n\nexport type ComposableComponent<\n Name extends string,\n Wrapper,\n InProps extends InPropsObject = {},\n OutProps = {}\n> = BaseComponent<Name, ResolveInputProps<InProps>> & {\n (props: ComposableComponentProps<Wrapper, InProps, OutProps>): ReactNode;\n};\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<\n string,\n any,\n InPropsObject,\n any\n>;\n\n/**\n * Minimal callable shape shared by layout and preset composables.\n * Used as the record value so preset components keep their own prop types.\n */\nexport type ComposableComponentCallable = {\n displayName: string;\n props: unknown;\n (...args: any[]): ReactNode;\n};\n\n// Separate installed versions declare distinct unique symbols for the same\n// Symbol.for key. Read the metadata structurally so their presets interoperate.\ntype PresetPropsFromMetadata<Component> = {\n [Key in keyof Component]-?: Key extends symbol\n ? Component[Key] extends ComposablePresetMeta<infer Props>\n ? Props\n : never\n : never;\n}[keyof Component];\n\nexport type PresetPropsFromComposable<Component> = Component extends {\n [composablePresetMetaKey]: ComposablePresetMeta<infer Props>;\n}\n ? Props\n : [PresetPropsFromMetadata<Component>] extends [never]\n ? {}\n : PresetPropsFromMetadata<Component>;\n\nexport type MergePresetProps<Composables extends ComposableComponents> = Show<\n UnionToIntersection<PresetPropsFromComposable<Composables[keyof Composables]>>\n>;\n\nexport type RequiredPresetRenderProps<Props extends InPropsObject> = {\n [K in keyof ResolveProps<Props> & string]-?: ResolveProps<Props>[K];\n};\n\ntype SchemaDefinitions<Props extends InPropsObject> = {\n [Key in keyof Props as Props[Key] extends StandardSchemaV1 ? Key : never]: Props[Key];\n};\n\ntype PresetInputProps<Props extends InPropsObject> =\n ResolveInputProps<SchemaDefinitions<Props>> &\n RequiredPresetRenderProps<Omit<Props, keyof SchemaDefinitions<Props>>>;\n\nexport type ComposablePresetComponentCallProps<\n Props extends InPropsObject,\n Wrapper = undefined\n> = WithChildren<PresetInputProps<Props>> &\n (Wrapper extends undefined ? {} : ComposableComponentWrapperProps<Wrapper>);\n\nexport type ComposablePresetComponent<\n Name extends string = string,\n Props extends InPropsObject = InPropsObject,\n Wrapper = undefined\n> = BaseComponent<Name, Show<WithChildren<ResolveInputProps<Props>>>> & {\n [composablePresetMetaKey]: ComposablePresetMeta<Props>;\n} & ((props: ComposablePresetComponentCallProps<Props, Wrapper>) => ReactNode);\n\ntype PresetPropDefinitions<Composables extends ComposableComponents> =\n MergePresetProps<Composables> extends InPropsObject\n ? MergePresetProps<Composables>\n : {};\n\ntype PresetLayoutInputProps<Props extends InPropsObject> =\n ResolveLayoutInputProps<SchemaDefinitions<Props>> & {\n [Key in keyof ResolveLayoutProps<Omit<Props, keyof SchemaDefinitions<Props>>>]-?:\n ResolveLayoutProps<Omit<Props, keyof SchemaDefinitions<Props>>>[Key];\n };\n\nexport type RequiredPresetLayoutProps<Composables extends ComposableComponents> =\n PresetLayoutInputProps<PresetPropDefinitions<Composables>>;\n\nexport type ComposableComponents = Record<string, ComposableComponentCallable>;\n\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 return typeof component === 'function' ? component(props) : component;\n}\n\nfunction reactNodeFromSingleFieldOutProps(resolved: unknown): ReactNode {\n if (resolved === null || typeof resolved !== 'object') {\n return null;\n }\n\n const values = Object.values(resolved);\n\n if (values.length !== 1) {\n return null;\n }\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<Name, Wrapper, Resources, LayoutName, InProps, OutProps>);\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\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\n for (const key of inPropsKeys) {\n delete (wrapperProps as Record<string, unknown>)[key];\n }\n\n const mergedValues = resolvePropDefinitionValues(mergedInProps as Record<string, unknown>);\n const alreadyValidated = (options as unknown as Record<symbol, unknown>)[validatedComposableProps];\n const schemaDefinitions = alreadyValidated ? {} : Object.fromEntries(\n Object.entries(inProps ?? {}).filter(([, definition]) => isStandardSchema(definition)),\n );\n const mergedResolved = validateProps(schemaDefinitions, mergedValues) 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 // A single intrinsic child is the composable's root without adding a wrapper.\n if (propsRecord['data-rl-node'] && isValidElement(resolvedChildren) && typeof resolvedChildren.type === 'string') {\n return cloneElement(resolvedChildren, {\n 'data-rl-node': propsRecord['data-rl-node'],\n 'data-rl-composable': propsRecord['data-rl-composable'],\n 'data-rl-owners': propsRecord['data-rl-owners'],\n } as Record<string, unknown>);\n }\n return resolvedChildren;\n }\n\n Composable.displayName = name;\n\n const debugKey = Symbol.for('@jfdevelops/react-layout/debug');\n const debug = (options as unknown as Record<symbol, unknown>)[debugKey];\n\n return Object.assign(Composable, {\n ...(debug ? { [debugKey]: debug } : {}),\n props: undefined as unknown as ResolveProps<InProps>,\n }) as unknown as ComposableComponent<Name, Wrapper, InProps, OutProps>;\n}\n\ntype DefineComposableComponentOptions<\n Name extends string,\n Props extends InPropsObject,\n Wrapper = undefined\n> = {\n name: Name;\n props?: Props;\n wrapWith?: Wrapper;\n};\n\nexport type DefinedComposableComponentRecord<\n Name extends string,\n Props extends InPropsObject = {},\n Wrapper = undefined\n> = {\n [K in Name]: ComposablePresetComponent<Name, Props, Wrapper>;\n};\n\ntype DefinedComposableComponentFactory<\n Name extends string,\n Props extends InPropsObject,\n Wrapper = undefined,\n> = {\n props: Props;\n (\n render: (props: Show<WithChildren<ResolveProps<Props>>>) => ReactNode,\n ): DefinedComposableComponentRecord<Name, Props, Wrapper>;\n /** Customize this instance without changing the factory's defaults. */\n <\n const Overrides extends InPropsObject = {},\n const CustomName extends string = Name,\n CustomWrapper = Wrapper,\n >(options: {\n name?: CustomName;\n props?: Overrides | ((defaults: Props) => Overrides);\n wrapWith?: CustomWrapper;\n render: (\n props: Show<\n WithChildren<ResolveProps<Omit<Props, keyof Overrides> & Overrides>>\n >,\n ) => ReactNode;\n }): DefinedComposableComponentRecord<\n CustomName,\n Omit<Props, keyof Overrides> & Overrides,\n CustomWrapper\n >;\n};\n\nfunction resolvePresetComposableCallProps<Props extends InPropsObject>(\n presetKey: string,\n propDefinitions: Props,\n callProps: Record<string, unknown>\n) {\n const presetKeys = Object.keys(propDefinitions) as (keyof Props & string)[];\n const contextValues = useComposablePresetProps(presetKey) ?? {};\n const presetValues = Object.fromEntries(\n presetKeys.map((key) => [key,\n isStandardSchema(propDefinitions[key]) && Object.hasOwn(callProps, key)\n ? callProps[key]\n : callProps[key] ?? contextValues[key],\n ])\n );\n // Context values have already been validated by the owning layout.\n const definitions = Object.fromEntries(\n Object.entries(propDefinitions).filter(([key, definition]) =>\n !isStandardSchema(definition) || Object.hasOwn(callProps, key) || !Object.hasOwn(contextValues, key),\n ),\n );\n\n return validateProps(\n definitions,\n presetValues\n ) as Show<WithChildren<ResolveProps<Props>>>;\n}\n\nexport function defineComposableComponent<\n const Name extends string,\n Props extends InPropsObject = {},\n Wrapper = undefined\n>(\n options: DefineComposableComponentOptions<Name, Props, Wrapper>\n): DefinedComposableComponentFactory<Name, Props, Wrapper> {\n const { name, props = {} as Props, wrapWith } = options;\n\n const factory = (\n definition:\n | ((props: Show<WithChildren<ResolveProps<Props>>>) => ReactNode)\n | {\n name?: string;\n props?: InPropsObject | ((defaults: Props) => InPropsObject);\n wrapWith?: unknown;\n render: (props: any) => ReactNode;\n }\n ): DefinedComposableComponentRecord<Name, Props, Wrapper> => {\n if (typeof definition !== 'function') {\n const overrides =\n typeof definition.props === 'function'\n ? definition.props(props)\n : definition.props;\n\n return defineComposableComponent({\n ...options,\n name: definition.name ?? name,\n props: { ...props, ...overrides },\n wrapWith: 'wrapWith' in definition ? definition.wrapWith : wrapWith,\n })(definition.render) as unknown as DefinedComposableComponentRecord<\n Name,\n Props,\n Wrapper\n >;\n }\n\n const render = definition;\n const component = createComposableComponent<\n Name,\n Wrapper,\n Props,\n Show<WithChildren<ResolveProps<Props>>>\n >({\n name,\n wrapWith,\n inProps: props,\n outProps: (resolved) => resolved,\n ...{ [validatedComposableProps]: true },\n });\n\n function PresetComposable(\n callProps: ComposablePresetComponentCallProps<Props, Wrapper>\n ) {\n const callPropsRecord = callProps as Record<string, unknown>;\n const presetKeys = Object.keys(props) as (keyof Props & string)[];\n const validatedPresetProps = resolvePresetComposableCallProps(\n name,\n props,\n callPropsRecord\n );\n const wrapperProps = { ...callPropsRecord };\n\n for (const key of presetKeys) {\n delete wrapperProps[key];\n }\n\n return component({\n ...(wrapperProps as ComposableComponentWrapperProps<Wrapper>),\n ...validatedPresetProps,\n children: (resolved: Show<WithChildren<ResolveProps<Props>>>) => render({\n ...resolved,\n children: 'children' in props\n ? (validatedPresetProps as Record<string, unknown>).children\n : callPropsRecord.children,\n } as Show<WithChildren<ResolveProps<Props>>>),\n } as unknown as ComposableComponentProps<Wrapper, Props, Show<WithChildren<ResolveProps<Props>>>>);\n }\n\n PresetComposable.displayName = name;\n\n const debugKey = Symbol.for('@jfdevelops/react-layout/debug');\n const debug = (options as unknown as Record<symbol, unknown>)[debugKey];\n const presetComponent = Object.assign(PresetComposable, {\n ...(debug ? { [debugKey]: debug } : {}),\n props: undefined as unknown as Show<WithChildren<ResolveProps<Props>>>,\n [composablePresetMetaKey]: {\n key: name,\n props,\n } satisfies ComposablePresetMeta<Props>,\n }) as unknown as DefinedComposableComponentRecord<\n Name,\n Props,\n Wrapper\n >[Name];\n\n return {\n [name]: presetComponent,\n } as DefinedComposableComponentRecord<Name, Props, Wrapper>;\n };\n\n Object.defineProperty(factory, 'props', {\n enumerable: true,\n value: props,\n });\n\n return factory as DefinedComposableComponentFactory<Name, Props, Wrapper>;\n}\n\nexport type MakeComposableOptions<\n Composables extends ComposableComponents,\n Name extends string\n> = { components: Composables | undefined; name: Name };\n\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 InvalidComponentsError('components must be an object');\n }\n\n const componentNames = Object.keys(components);\n\n if (componentNames.length === 0) {\n throw new EmptyComponentsError(\n 'components must have at least one component'\n );\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":";;;;;;AAkBA,MAAa,0BAA0B,OAAO,IAC5C,iCACF;AAEA,MAAM,2BAA2B,OAAO,0BAA0B;AAUlE,MAAM,+BAA+B,cAEnC,MAAS;AAEX,SAAgB,+BAA+B,EAC7C,OACA,YAIC;CACD,OACE,oBAAC,6BAA6B,UAA9B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C,CAAiG;EACnG;EAEA,iBAAiB,cAAc;EAE/B,MAAM,WAAW,OAAO,IAAI,gCAAgC;EAC5D,MAAM,QAAS,QAA+C;EAC9D,MAAM,kBAAkB,OAAO,OAAO,kBAAkB;GACtD,GAAI,QAAQ,GAAG,WAAW,MAAM,IAAI,CAAC;GACrC,OAAO;IACN,0BAA0B;IACzB,KAAK;IACL;GACF;EACF,CAAC;EAMD,OAAO,GACJ,OAAO,gBACV;CACF;CAEA,OAAO,eAAe,SAAS,SAAS;EACtC,YAAY;EACZ,OAAO;CACT,CAAC;CAED,OAAO;AACT;AAgBA,SAAgB,iBAAwB;CACtC,OAAO,SAGL,SAAmD;EACnD,MAAM,EAAE,YAAY,MAAM,eAAe;EAEzC,IAAI,CAAC,cAAc,OAAO,eAAe,UACvC,MAAM,IAAI,uBAAuB,8BAA8B;EAKjE,IAFuB,OAAO,KAAK,UAElB,EAAE,WAAW,GAC5B,MAAM,IAAI,qBACR,6CACF;EAGF,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"}
1
+ {"version":3,"file":"composable.mjs","names":["Comp"],"sources":["../src/composable.tsx"],"sourcesContent":["import {\n ComponentType,\n createContext,\n ReactNode,\n useContext,\n cloneElement,\n isValidElement,\n} from 'react';\nimport { EmptyComponentsError, InvalidComponentsError } from './errors';\nimport {\n PropDefinition,\n type PropValidationContext,\n ResolveProps,\n ResolveInputProps,\n type StandardSchemaV1,\n resolvePropDefinitionValues,\n validateProps,\n} from '@jfdevelops/react-layout-validator';\nimport { InPropsObject, type WithChildren } from './types';\nimport type {\n BaseComponent,\n CapitalizeFn,\n Show,\n UnionToIntersection,\n} from '@jfdevelops/react-layout-internals';\n\nexport const composablePresetMetaKey = Symbol.for(\n 'view-map.composable-preset-meta',\n);\n\nconst validatedComposableProps = Symbol('validatedComposableProps');\n\nexport type ComposablePresetMeta<Props extends InPropsObject = InPropsObject> =\n {\n key: string;\n props: Props;\n };\n\nexport type ComposablePresetProps = Record<string, Record<string, unknown>>;\n\nconst composablePresetPropsContext = createContext<\n ComposablePresetProps | undefined\n>(undefined);\n\nexport function LayoutComposablePresetProvider({\n value,\n children,\n}: {\n value: ComposablePresetProps;\n children: ReactNode;\n}) {\n return (\n <composablePresetPropsContext.Provider value={value}>\n {children}\n </composablePresetPropsContext.Provider>\n );\n}\n\nfunction useComposablePresetProps(key: string) {\n return useContext(composablePresetPropsContext)?.[key];\n}\n\nexport function collectComposablePresetEntries(\n composables: ComposableComponents | undefined,\n) {\n if (!composables) {\n return [] as Array<{\n key: string;\n props: InPropsObject;\n }>;\n }\n\n return Object.entries(composables).flatMap(([objectKey, component]) => {\n const meta = (component as ComposablePresetComponent)[\n composablePresetMetaKey\n ];\n\n if (!meta) {\n return [];\n }\n\n return [\n {\n key: meta.key ?? objectKey,\n props: meta.props,\n },\n ];\n });\n}\n\nexport function resolveComposablePresetProps(\n composables: ComposableComponents | undefined,\n layoutOptions: Record<string, unknown>,\n context?: PropValidationContext,\n) {\n const resolved: ComposablePresetProps = {};\n\n for (const { key, props } of collectComposablePresetEntries(composables)) {\n const propKeys = Object.keys(props);\n const values = Object.fromEntries(\n propKeys.flatMap((propKey) => {\n if (!(propKey in layoutOptions)) {\n return [];\n }\n\n return [[propKey, layoutOptions[propKey]]];\n }),\n );\n\n resolved[key] = validateProps(\n props as Record<string, PropDefinition>,\n values,\n context,\n );\n }\n\n return resolved;\n}\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> : {};\n\ntype ComposableComponentWrapperProps<Wrapper> =\n Wrapper extends ComponentType<infer Props> ? Omit<Props, 'children'> : {};\n\ntype ComposableComponentProps<\n Wrapper,\n InProps extends InPropsObject = {},\n OutProps = {},\n> = ComposableComponentWrapperProps<Wrapper> &\n (keyof InProps extends never ? {} : ResolveInputProps<InProps>) & {\n children?: [keyof InProps] extends [never]\n ? ReactNode\n : ((props: OutProps) => JSX.Element) | ReactNode;\n };\n\nexport type ComposableComponent<\n Name extends string,\n Wrapper,\n InProps extends InPropsObject = {},\n OutProps = {},\n> = BaseComponent<Name, ResolveInputProps<InProps>> & {\n (props: ComposableComponentProps<Wrapper, InProps, OutProps>): ReactNode;\n};\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<\n string,\n any,\n InPropsObject,\n any\n>;\n\n/**\n * Minimal callable shape shared by layout and preset composables.\n * Used as the record value so preset components keep their own prop types.\n */\nexport type ComposableComponentCallable = {\n displayName: string;\n props: unknown;\n (...args: any[]): ReactNode;\n};\n\n// Separate installed versions declare distinct unique symbols for the same\n// Symbol.for key. Read the metadata structurally so their presets interoperate.\ntype PresetPropsFromMetadata<Component> = {\n [Key in keyof Component]-?: Key extends symbol\n ? Component[Key] extends ComposablePresetMeta<infer Props>\n ? Props\n : never\n : never;\n}[keyof Component];\n\nexport type PresetPropsFromComposable<Component> = Component extends {\n [composablePresetMetaKey]: ComposablePresetMeta<infer Props>;\n}\n ? Props\n : [PresetPropsFromMetadata<Component>] extends [never]\n ? {}\n : PresetPropsFromMetadata<Component>;\n\nexport type MergePresetProps<Composables extends ComposableComponents> = Show<\n UnionToIntersection<PresetPropsFromComposable<Composables[keyof Composables]>>\n>;\n\nexport type RequiredPresetRenderProps<Props extends InPropsObject> = {\n [K in keyof ResolveProps<Props> & string]-?: ResolveProps<Props>[K];\n};\n\ntype SchemaDefinitions<Props extends InPropsObject> = {\n [\n Key in keyof Props as Props[Key] extends StandardSchemaV1 ? Key : never\n ]: Props[Key];\n};\n\ntype PresetInputProps<Props extends InPropsObject> = ResolveInputProps<\n SchemaDefinitions<Props>\n> &\n RequiredPresetRenderProps<Omit<Props, keyof SchemaDefinitions<Props>>>;\n\nexport type ComposablePresetComponentCallProps<\n Props extends InPropsObject,\n Wrapper = undefined,\n> = WithChildren<PresetInputProps<Props>> &\n (Wrapper extends undefined ? {} : ComposableComponentWrapperProps<Wrapper>);\n\nexport type ComposablePresetComponent<\n Name extends string = string,\n Props extends InPropsObject = InPropsObject,\n Wrapper = undefined,\n> = BaseComponent<Name, Show<WithChildren<ResolveInputProps<Props>>>> & {\n [composablePresetMetaKey]: ComposablePresetMeta<Props>;\n} & ((props: ComposablePresetComponentCallProps<Props, Wrapper>) => ReactNode);\n\ntype PresetPropDefinitions<Composables extends ComposableComponents> =\n MergePresetProps<Composables> extends InPropsObject\n ? MergePresetProps<Composables>\n : {};\n\ntype PresetLayoutInputProps<Props extends InPropsObject> = ResolveInputProps<\n SchemaDefinitions<Props>\n> & {\n [\n Key in keyof ResolveProps<Omit<Props, keyof SchemaDefinitions<Props>>>\n ]-?: ResolveProps<Omit<Props, keyof SchemaDefinitions<Props>>>[Key];\n};\n\nexport type RequiredPresetLayoutProps<\n Composables extends ComposableComponents,\n> = PresetLayoutInputProps<PresetPropDefinitions<Composables>>;\n\nexport type ComposableComponents = Record<string, ComposableComponentCallable>;\n\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 return typeof component === 'function' ? component(props) : component;\n}\n\nfunction reactNodeFromSingleFieldOutProps(resolved: unknown): ReactNode {\n if (resolved === null || typeof resolved !== 'object') {\n return null;\n }\n\n const values = Object.values(resolved);\n\n if (values.length !== 1) {\n return null;\n }\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 = {\n ...inProps,\n };\n const propsRecord = props as Record<string, unknown>;\n\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\n for (const key of inPropsKeys) {\n delete (wrapperProps as Record<string, unknown>)[key];\n }\n\n const mergedValues = resolvePropDefinitionValues(\n mergedInProps as Record<string, unknown>,\n );\n const alreadyValidated = (options as unknown as Record<symbol, unknown>)[\n validatedComposableProps\n ];\n const mergedResolved = validateProps(\n alreadyValidated ? {} : inProps,\n mergedValues,\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 // A single intrinsic child is the composable's root without adding a wrapper.\n if (\n propsRecord['data-rl-node'] &&\n isValidElement(resolvedChildren) &&\n typeof resolvedChildren.type === 'string'\n ) {\n return cloneElement(resolvedChildren, {\n 'data-rl-node': propsRecord['data-rl-node'],\n 'data-rl-composable': propsRecord['data-rl-composable'],\n 'data-rl-owners': propsRecord['data-rl-owners'],\n } as Record<string, unknown>);\n }\n\n return resolvedChildren;\n }\n\n Composable.displayName = name;\n\n const debugKey = Symbol.for('@jfdevelops/react-layout/debug');\n const debug = (options as unknown as Record<symbol, unknown>)[debugKey];\n\n return Object.assign(Composable, {\n ...(debug\n ? {\n [debugKey]: debug,\n }\n : {}),\n props: undefined as unknown as ResolveProps<InProps>,\n }) as unknown as ComposableComponent<Name, Wrapper, InProps, OutProps>;\n}\n\ntype DefineComposableComponentOptions<\n Name extends string,\n Props extends InPropsObject,\n Wrapper = undefined,\n> = {\n name: Name;\n props?: Props;\n wrapWith?: Wrapper;\n};\n\nexport type DefinedComposableComponentRecord<\n Name extends string,\n Props extends InPropsObject = {},\n Wrapper = undefined,\n> = {\n [K in Name]: ComposablePresetComponent<Name, Props, Wrapper>;\n};\n\ntype DefinedComposableComponentFactory<\n Name extends string,\n Props extends InPropsObject,\n Wrapper = undefined,\n> = {\n props: Props;\n (\n render: (props: Show<WithChildren<ResolveProps<Props>>>) => ReactNode,\n ): DefinedComposableComponentRecord<Name, Props, Wrapper>;\n /**\n * Customize this instance without changing the factory's defaults.\n */\n <\n const Overrides extends InPropsObject = {},\n const CustomName extends string = Name,\n CustomWrapper = Wrapper,\n >(options: {\n name?: CustomName;\n props?: Overrides | ((defaults: Props) => Overrides);\n wrapWith?: CustomWrapper;\n render: (\n props: Show<\n WithChildren<ResolveProps<Omit<Props, keyof Overrides> & Overrides>>\n >,\n ) => ReactNode;\n }): DefinedComposableComponentRecord<\n CustomName,\n Omit<Props, keyof Overrides> & Overrides,\n CustomWrapper\n >;\n};\n\nfunction resolvePresetComposableCallProps<Props extends InPropsObject>(\n presetKey: string,\n propDefinitions: Props,\n callProps: Record<string, unknown>,\n) {\n const presetKeys = Object.keys(propDefinitions) as (keyof Props & string)[];\n const contextValues = useComposablePresetProps(presetKey) ?? {};\n const presetValues = Object.fromEntries(\n presetKeys.map((key) => [\n key,\n Object.hasOwn(callProps, key) ? callProps[key] : contextValues[key],\n ]),\n );\n // Context values have already been validated by the owning layout.\n const definitions = Object.fromEntries(\n Object.entries(propDefinitions).filter(\n ([key]) =>\n Object.hasOwn(callProps, key) || !Object.hasOwn(contextValues, key),\n ),\n );\n\n return validateProps(definitions, presetValues) as Show<\n WithChildren<ResolveProps<Props>>\n >;\n}\n\nexport function defineComposableComponent<\n const Name extends string,\n Props extends InPropsObject = {},\n Wrapper = undefined,\n>(\n options: DefineComposableComponentOptions<Name, Props, Wrapper>,\n): DefinedComposableComponentFactory<Name, Props, Wrapper> {\n const { name, props = {} as Props, wrapWith } = options;\n\n const factory = (\n definition:\n | ((props: Show<WithChildren<ResolveProps<Props>>>) => ReactNode)\n | {\n name?: string;\n props?: InPropsObject | ((defaults: Props) => InPropsObject);\n wrapWith?: unknown;\n render: (props: any) => ReactNode;\n },\n ): DefinedComposableComponentRecord<Name, Props, Wrapper> => {\n if (typeof definition !== 'function') {\n const overrides =\n typeof definition.props === 'function'\n ? definition.props(props)\n : definition.props;\n\n return defineComposableComponent({\n ...options,\n name: definition.name ?? name,\n props: {\n ...props,\n ...overrides,\n },\n wrapWith: 'wrapWith' in definition ? definition.wrapWith : wrapWith,\n })(definition.render) as unknown as DefinedComposableComponentRecord<\n Name,\n Props,\n Wrapper\n >;\n }\n\n const render = definition;\n const component = createComposableComponent<\n Name,\n Wrapper,\n Props,\n Show<WithChildren<ResolveProps<Props>>>\n >({\n name,\n wrapWith,\n inProps: props,\n outProps: (resolved) => resolved as never,\n ...{\n [validatedComposableProps]: true,\n },\n });\n\n function PresetComposable(\n callProps: ComposablePresetComponentCallProps<Props, Wrapper>,\n ) {\n const callPropsRecord = callProps as Record<string, unknown>;\n const presetKeys = Object.keys(props) as (keyof Props & string)[];\n const validatedPresetProps = resolvePresetComposableCallProps(\n name,\n props,\n callPropsRecord,\n );\n const wrapperProps = {\n ...callPropsRecord,\n };\n\n for (const key of presetKeys) {\n delete wrapperProps[key];\n }\n\n return component({\n ...(wrapperProps as ComposableComponentWrapperProps<Wrapper>),\n ...validatedPresetProps,\n children: (resolved: Show<WithChildren<ResolveProps<Props>>>) =>\n render({\n ...resolved,\n children:\n 'children' in props\n ? (validatedPresetProps as Record<string, unknown>).children\n : callPropsRecord.children,\n } as Show<WithChildren<ResolveProps<Props>>>),\n } as unknown as ComposableComponentProps<\n Wrapper,\n Props,\n Show<WithChildren<ResolveProps<Props>>>\n >);\n }\n\n PresetComposable.displayName = name;\n\n const debugKey = Symbol.for('@jfdevelops/react-layout/debug');\n const debug = (options as unknown as Record<symbol, unknown>)[debugKey];\n const presetComponent = Object.assign(PresetComposable, {\n ...(debug\n ? {\n [debugKey]: debug,\n }\n : {}),\n props: undefined as unknown as Show<WithChildren<ResolveProps<Props>>>,\n [composablePresetMetaKey]: {\n key: name,\n props,\n } satisfies ComposablePresetMeta<Props>,\n }) as unknown as DefinedComposableComponentRecord<\n Name,\n Props,\n Wrapper\n >[Name];\n\n return {\n [name]: presetComponent,\n } as DefinedComposableComponentRecord<Name, Props, Wrapper>;\n };\n\n Object.defineProperty(factory, 'props', {\n enumerable: true,\n value: props,\n });\n\n return factory as DefinedComposableComponentFactory<Name, Props, Wrapper>;\n}\n\nexport type MakeComposableOptions<\n Composables extends ComposableComponents,\n Name extends string,\n> = {\n components: Composables | undefined;\n name: Name;\n};\n\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 InvalidComponentsError('components must be an object');\n }\n\n const componentNames = Object.keys(components);\n\n if (componentNames.length === 0) {\n throw new EmptyComponentsError(\n 'components must have at least one component',\n );\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":";;;;;;AA0BA,MAAa,0BAA0B,OAAO,IAC5C,iCACF;AAEA,MAAM,2BAA2B,OAAO,0BAA0B;AAUlE,MAAM,+BAA+B,cAEnC,MAAS;AAEX,SAAgB,+BAA+B,EAC7C,OACA,YAIC;CACD,OACE,oBAAC,6BAA6B,UAA9B;EAA8C;EAC3C;CACoC;AAE3C;AAEA,SAAS,yBAAyB,KAAa;CAC7C,OAAO,WAAW,4BAA4B,IAAI;AACpD;AAEA,SAAgB,+BACd,aACA;CACA,IAAI,CAAC,aACH,OAAO,CAAC;CAMV,OAAO,OAAO,QAAQ,WAAW,EAAE,SAAS,CAAC,WAAW,eAAe;EACrE,MAAM,OAAQ,UACZ;EAGF,IAAI,CAAC,MACH,OAAO,CAAC;EAGV,OAAO,CACL;GACE,KAAK,KAAK,OAAO;GACjB,OAAO,KAAK;EACd,CACF;CACF,CAAC;AACH;AAEA,SAAgB,6BACd,aACA,eACA,SACA;CACA,MAAM,WAAkC,CAAC;CAEzC,KAAK,MAAM,EAAE,KAAK,WAAW,+BAA+B,WAAW,GAYrE,SAAS,OAAO,cACd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,GAAG,SAAS;GAE5B,OAAO,OAAO,OAAO,QAAQ;IAC3B,aAAa;IACb,OAAO;IACP,GAAG;GACL,CAAC;EAOH;EAEA,OAAO;CACT;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"errors.cjs","names":[],"sources":["../src/errors.ts"],"sourcesContent":["import { createError } from '@jfdevelops/create-error';\nimport { type } from 'arktype';\n\nconst composableErrorFactory = createError({\n definition: type({ code: 'string' }),\n data: {\n property: 'context',\n resolve: ({ input }) => input,\n },\n message: ({ data, implementation }) => implementation(data),\n properties: ({ definition }) => ({ code: definition.code }),\n});\n\n/** Thrown when the composable component map is not an object. */\nexport class InvalidComponentsError extends composableErrorFactory({\n code: 'invalidComponents',\n})\n .defineContext(type('string'))\n .implement((message) => message) {}\n\n/** Thrown when no composable components were provided. */\nexport class EmptyComponentsError extends composableErrorFactory({\n code: 'emptyComponents',\n})\n .defineContext(type('string'))\n .implement((message) => message) {}\n"],"mappings":";;;;AAGA,MAAM,mEAAqC;CACzC,8BAAiB,EAAE,MAAM,SAAS,CAAC;CACnC,MAAM;EACJ,UAAU;EACV,UAAU,EAAE,YAAY;CAC1B;CACA,UAAU,EAAE,MAAM,qBAAqB,eAAe,IAAI;CAC1D,aAAa,EAAE,kBAAkB,EAAE,MAAM,WAAW,KAAK;AAC3D,CAAC;;AAGD,IAAa,yBAAb,cAA4C,uBAAuB,EACjE,MAAM,oBACR,CAAC,EACE,gCAAmB,QAAQ,CAAC,EAC5B,WAAW,YAAY,OAAO,EAAE,CAAC;;AAGpC,IAAa,uBAAb,cAA0C,uBAAuB,EAC/D,MAAM,kBACR,CAAC,EACE,gCAAmB,QAAQ,CAAC,EAC5B,WAAW,YAAY,OAAO,EAAE,CAAC"}
1
+ {"version":3,"file":"errors.cjs","names":[],"sources":["../src/errors.ts"],"sourcesContent":["import { createError } from '@jfdevelops/create-error';\nimport { type } from 'arktype';\n\nconst composableErrorFactory = createError({\n definition: type({\n code: 'string',\n }),\n data: {\n property: 'context',\n resolve: ({ input }) => input,\n },\n message: ({ data, implementation }) => implementation(data),\n properties: ({ definition }) => ({\n code: definition.code,\n }),\n});\n\n/** Thrown when the composable component map is not an object. */\nexport class InvalidComponentsError extends composableErrorFactory({\n code: 'invalidComponents',\n})\n .defineContext(type('string'))\n .implement((message) => message) {}\n\n/** Thrown when no composable components were provided. */\nexport class EmptyComponentsError extends composableErrorFactory({\n code: 'emptyComponents',\n})\n .defineContext(type('string'))\n .implement((message) => message) {}\n"],"mappings":";;;;AAGA,MAAM,mEAAqC;CACzC,8BAAiB,EACf,MAAM,SACR,CAAC;CACD,MAAM;EACJ,UAAU;EACV,UAAU,EAAE,YAAY;CAC1B;CACA,UAAU,EAAE,MAAM,qBAAqB,eAAe,IAAI;CAC1D,aAAa,EAAE,kBAAkB,EAC/B,MAAM,WAAW,KACnB;AACF,CAAC;;AAGD,IAAa,yBAAb,cAA4C,uBAAuB,EACjE,MAAM,oBACR,CAAC,EACE,gCAAmB,QAAQ,CAAC,EAC5B,WAAW,YAAY,OAAO,EAAE,CAAC;;AAGpC,IAAa,uBAAb,cAA0C,uBAAuB,EAC/D,MAAM,kBACR,CAAC,EACE,gCAAmB,QAAQ,CAAC,EAC5B,WAAW,YAAY,OAAO,EAAE,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.cts","names":[],"sources":["../src/errors.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAca,sBAAA,SAA+B,2BAIV;AAAA,cAAG,yBAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAGxB,oBAAA,SAA6B,yBAIR"}
1
+ {"version":3,"file":"errors.d.cts","names":[],"sources":["../src/errors.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAkBa,sBAAA,SAA+B,2BAIV;AAAA,cAAG,yBAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAGxB,oBAAA,SAA6B,yBAIR"}
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.mts","names":[],"sources":["../src/errors.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAca,sBAAA,SAA+B,2BAIV;AAAA,cAAG,yBAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAGxB,oBAAA,SAA6B,yBAIR"}
1
+ {"version":3,"file":"errors.d.mts","names":[],"sources":["../src/errors.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAkBa,sBAAA,SAA+B,2BAIV;AAAA,cAAG,yBAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAGxB,oBAAA,SAA6B,yBAIR"}
@@ -1 +1 @@
1
- {"version":3,"file":"errors.mjs","names":[],"sources":["../src/errors.ts"],"sourcesContent":["import { createError } from '@jfdevelops/create-error';\nimport { type } from 'arktype';\n\nconst composableErrorFactory = createError({\n definition: type({ code: 'string' }),\n data: {\n property: 'context',\n resolve: ({ input }) => input,\n },\n message: ({ data, implementation }) => implementation(data),\n properties: ({ definition }) => ({ code: definition.code }),\n});\n\n/** Thrown when the composable component map is not an object. */\nexport class InvalidComponentsError extends composableErrorFactory({\n code: 'invalidComponents',\n})\n .defineContext(type('string'))\n .implement((message) => message) {}\n\n/** Thrown when no composable components were provided. */\nexport class EmptyComponentsError extends composableErrorFactory({\n code: 'emptyComponents',\n})\n .defineContext(type('string'))\n .implement((message) => message) {}\n"],"mappings":";;;;AAGA,MAAM,yBAAyB,YAAY;CACzC,YAAY,KAAK,EAAE,MAAM,SAAS,CAAC;CACnC,MAAM;EACJ,UAAU;EACV,UAAU,EAAE,YAAY;CAC1B;CACA,UAAU,EAAE,MAAM,qBAAqB,eAAe,IAAI;CAC1D,aAAa,EAAE,kBAAkB,EAAE,MAAM,WAAW,KAAK;AAC3D,CAAC;;AAGD,IAAa,yBAAb,cAA4C,uBAAuB,EACjE,MAAM,oBACR,CAAC,EACE,cAAc,KAAK,QAAQ,CAAC,EAC5B,WAAW,YAAY,OAAO,EAAE,CAAC;;AAGpC,IAAa,uBAAb,cAA0C,uBAAuB,EAC/D,MAAM,kBACR,CAAC,EACE,cAAc,KAAK,QAAQ,CAAC,EAC5B,WAAW,YAAY,OAAO,EAAE,CAAC"}
1
+ {"version":3,"file":"errors.mjs","names":[],"sources":["../src/errors.ts"],"sourcesContent":["import { createError } from '@jfdevelops/create-error';\nimport { type } from 'arktype';\n\nconst composableErrorFactory = createError({\n definition: type({\n code: 'string',\n }),\n data: {\n property: 'context',\n resolve: ({ input }) => input,\n },\n message: ({ data, implementation }) => implementation(data),\n properties: ({ definition }) => ({\n code: definition.code,\n }),\n});\n\n/** Thrown when the composable component map is not an object. */\nexport class InvalidComponentsError extends composableErrorFactory({\n code: 'invalidComponents',\n})\n .defineContext(type('string'))\n .implement((message) => message) {}\n\n/** Thrown when no composable components were provided. */\nexport class EmptyComponentsError extends composableErrorFactory({\n code: 'emptyComponents',\n})\n .defineContext(type('string'))\n .implement((message) => message) {}\n"],"mappings":";;;;AAGA,MAAM,yBAAyB,YAAY;CACzC,YAAY,KAAK,EACf,MAAM,SACR,CAAC;CACD,MAAM;EACJ,UAAU;EACV,UAAU,EAAE,YAAY;CAC1B;CACA,UAAU,EAAE,MAAM,qBAAqB,eAAe,IAAI;CAC1D,aAAa,EAAE,kBAAkB,EAC/B,MAAM,WAAW,KACnB;AACF,CAAC;;AAGD,IAAa,yBAAb,cAA4C,uBAAuB,EACjE,MAAM,oBACR,CAAC,EACE,cAAc,KAAK,QAAQ,CAAC,EAC5B,WAAW,YAAY,OAAO,EAAE,CAAC;;AAGpC,IAAa,uBAAb,cAA0C,uBAAuB,EAC/D,MAAM,kBACR,CAAC,EACE,cAAc,KAAK,QAAQ,CAAC,EAC5B,WAAW,YAAY,OAAO,EAAE,CAAC"}
package/dist/index.cjs CHANGED
@@ -1,7 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
  const require_errors = require('./errors.cjs');
3
3
  const require_composable = require('./composable.cjs');
4
- let _jfdevelops_react_layout_validator = require("@jfdevelops/react-layout-validator");
5
4
 
6
5
  exports.EmptyComponentsError = require_errors.EmptyComponentsError;
7
6
  exports.InvalidComponentsError = require_errors.InvalidComponentsError;
@@ -10,12 +9,6 @@ exports.collectComposablePresetEntries = require_composable.collectComposablePre
10
9
  exports.composablePresetMetaKey = require_composable.composablePresetMetaKey;
11
10
  exports.createComposableComponent = require_composable.createComposableComponent;
12
11
  exports.createLayoutComposableFactory = require_composable.createLayoutComposableFactory;
13
- Object.defineProperty(exports, 'createProp', {
14
- enumerable: true,
15
- get: function () {
16
- return _jfdevelops_react_layout_validator.createProp;
17
- }
18
- });
19
12
  exports.defineComposableComponent = require_composable.defineComposableComponent;
20
13
  exports.makeComposable = require_composable.makeComposable;
21
14
  exports.resolveComposablePresetProps = require_composable.resolveComposablePresetProps;
package/dist/index.d.cts CHANGED
@@ -1,6 +1,5 @@
1
1
  import { InPropsObject, WithChildren } from "./types.cjs";
2
- import { BaseComponent, Show, UnionToIntersection } from "./utils.cjs";
2
+ import { BaseComponent, Show, ShowCallable, UnionToIntersection } from "./packages/internals/src/types.cjs";
3
3
  import { AnyComposableComponent, ComposableComponent, ComposableComponentCallable, ComposableComponents, ComposableNameContext, ComposablePresetComponent, ComposablePresetComponentCallProps, ComposablePresetMeta, ComposablePresetProps, ComposableResourceLayout, CreateLayoutComposable, DefinedComposableComponentRecord, LayoutComposablePresetProvider, LayoutComposablesFactory, MakeComposable, MakeComposableOptions, MergePresetProps, PresetPropsFromComposable, RequiredPresetLayoutProps, RequiredPresetRenderProps, ResolveLayoutComposables, collectComposablePresetEntries, composablePresetMetaKey, createComposableComponent, createLayoutComposableFactory, defineComposableComponent, makeComposable, resolveComposablePresetProps, resolveLayoutComposables } from "./composable.cjs";
4
4
  import { EmptyComponentsError, InvalidComponentsError } from "./errors.cjs";
5
- import { createProp } from "@jfdevelops/react-layout-validator";
6
- export { 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, EmptyComponentsError, type InPropsObject, InvalidComponentsError, LayoutComposablePresetProvider, type LayoutComposablesFactory, type MakeComposable, type MakeComposableOptions, type MergePresetProps, type PresetPropsFromComposable, type RequiredPresetLayoutProps, type RequiredPresetRenderProps, type ResolveLayoutComposables, type Show, type UnionToIntersection, type WithChildren, collectComposablePresetEntries, composablePresetMetaKey, createComposableComponent, createLayoutComposableFactory, createProp, defineComposableComponent, makeComposable, resolveComposablePresetProps, resolveLayoutComposables };
5
+ export { 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, EmptyComponentsError, type InPropsObject, InvalidComponentsError, LayoutComposablePresetProvider, type LayoutComposablesFactory, type MakeComposable, type MakeComposableOptions, type MergePresetProps, type PresetPropsFromComposable, type RequiredPresetLayoutProps, type RequiredPresetRenderProps, type ResolveLayoutComposables, type Show, type ShowCallable, type UnionToIntersection, type WithChildren, collectComposablePresetEntries, composablePresetMetaKey, createComposableComponent, createLayoutComposableFactory, defineComposableComponent, makeComposable, resolveComposablePresetProps, resolveLayoutComposables };
package/dist/index.d.mts CHANGED
@@ -1,6 +1,5 @@
1
1
  import { InPropsObject, WithChildren } from "./types.mjs";
2
- import { BaseComponent, Show, UnionToIntersection } from "./utils.mjs";
2
+ import { BaseComponent, Show, ShowCallable, UnionToIntersection } from "./packages/internals/src/types.mjs";
3
3
  import { AnyComposableComponent, ComposableComponent, ComposableComponentCallable, ComposableComponents, ComposableNameContext, ComposablePresetComponent, ComposablePresetComponentCallProps, ComposablePresetMeta, ComposablePresetProps, ComposableResourceLayout, CreateLayoutComposable, DefinedComposableComponentRecord, LayoutComposablePresetProvider, LayoutComposablesFactory, MakeComposable, MakeComposableOptions, MergePresetProps, PresetPropsFromComposable, RequiredPresetLayoutProps, RequiredPresetRenderProps, ResolveLayoutComposables, collectComposablePresetEntries, composablePresetMetaKey, createComposableComponent, createLayoutComposableFactory, defineComposableComponent, makeComposable, resolveComposablePresetProps, resolveLayoutComposables } from "./composable.mjs";
4
4
  import { EmptyComponentsError, InvalidComponentsError } from "./errors.mjs";
5
- import { createProp } from "@jfdevelops/react-layout-validator";
6
- export { 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, EmptyComponentsError, type InPropsObject, InvalidComponentsError, LayoutComposablePresetProvider, type LayoutComposablesFactory, type MakeComposable, type MakeComposableOptions, type MergePresetProps, type PresetPropsFromComposable, type RequiredPresetLayoutProps, type RequiredPresetRenderProps, type ResolveLayoutComposables, type Show, type UnionToIntersection, type WithChildren, collectComposablePresetEntries, composablePresetMetaKey, createComposableComponent, createLayoutComposableFactory, createProp, defineComposableComponent, makeComposable, resolveComposablePresetProps, resolveLayoutComposables };
5
+ export { 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, EmptyComponentsError, type InPropsObject, InvalidComponentsError, LayoutComposablePresetProvider, type LayoutComposablesFactory, type MakeComposable, type MakeComposableOptions, type MergePresetProps, type PresetPropsFromComposable, type RequiredPresetLayoutProps, type RequiredPresetRenderProps, type ResolveLayoutComposables, type Show, type ShowCallable, type UnionToIntersection, type WithChildren, collectComposablePresetEntries, composablePresetMetaKey, createComposableComponent, createLayoutComposableFactory, defineComposableComponent, makeComposable, resolveComposablePresetProps, resolveLayoutComposables };
package/dist/index.mjs CHANGED
@@ -1,5 +1,4 @@
1
1
  import { EmptyComponentsError, InvalidComponentsError } from "./errors.mjs";
2
2
  import { LayoutComposablePresetProvider, collectComposablePresetEntries, composablePresetMetaKey, createComposableComponent, createLayoutComposableFactory, defineComposableComponent, makeComposable, resolveComposablePresetProps, resolveLayoutComposables } from "./composable.mjs";
3
- import { createProp } from "@jfdevelops/react-layout-validator";
4
3
 
5
- export { EmptyComponentsError, InvalidComponentsError, LayoutComposablePresetProvider, collectComposablePresetEntries, composablePresetMetaKey, createComposableComponent, createLayoutComposableFactory, createProp, defineComposableComponent, makeComposable, resolveComposablePresetProps, resolveLayoutComposables };
4
+ export { EmptyComponentsError, InvalidComponentsError, LayoutComposablePresetProvider, collectComposablePresetEntries, composablePresetMetaKey, createComposableComponent, createLayoutComposableFactory, defineComposableComponent, makeComposable, resolveComposablePresetProps, resolveLayoutComposables };
@@ -1,4 +1,4 @@
1
- //#region src/utils/capitalize.d.ts
1
+ //#region ../internals/src/capitalize.d.ts
2
2
  type CapitalizeFn = typeof capitalize;
3
3
  declare function capitalize<T extends string>(str: T): Capitalize<T>;
4
4
  declare function capitalize(str: string): string;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"capitalize.d.cts","names":[],"sources":["../../../../../internals/src/capitalize.ts"],"mappings":";KAAY,YAAA,UAAsB,UAAU;AAAA,iBAE5B,UAAA,mBAA6B,GAAA,EAAK,CAAA,GAAI,UAAA,CAAW,CAAA;AAAA,iBACjD,UAAA,CAAW,GAAW"}
@@ -1,4 +1,4 @@
1
- //#region src/utils/capitalize.d.ts
1
+ //#region ../internals/src/capitalize.d.ts
2
2
  type CapitalizeFn = typeof capitalize;
3
3
  declare function capitalize<T extends string>(str: T): Capitalize<T>;
4
4
  declare function capitalize(str: string): string;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"capitalize.d.mts","names":[],"sources":["../../../../../internals/src/capitalize.ts"],"mappings":";KAAY,YAAA,UAAsB,UAAU;AAAA,iBAE5B,UAAA,mBAA6B,GAAA,EAAK,CAAA,GAAI,UAAA,CAAW,CAAA;AAAA,iBACjD,UAAA,CAAW,GAAW"}
@@ -0,0 +1,25 @@
1
+ //#region ../internals/src/types.d.ts
2
+ /**
3
+ * Flattens an object type for display. Use {@link ShowCallable} when the type
4
+ * may carry call signatures, which a mapped type does not preserve.
5
+ */
6
+ type Show<T> = { [K in keyof T]: T[K] } & {};
7
+ /**
8
+ * Like {@link Show}, but keeps the call signature of callable types.
9
+ */
10
+ type ShowCallable<T> = T extends ((...args: infer Arguments) => infer Result) ? ((...args: Arguments) => Result) & { [Key in keyof T]: T[Key] } : Show<T>;
11
+ type UnionToIntersection<Union> = (Union extends unknown ? (value: Union) => void : never) extends ((value: infer Intersection) => void) ? Intersection : never;
12
+ interface BaseComponent<Name extends string, Props = {}> {
13
+ /**
14
+ * The name of the component. Useful for debugging and error messages.
15
+ */
16
+ displayName: Name;
17
+ /**
18
+ * A type only property to get the type of the props. At runtime,
19
+ * this is `undefined`.
20
+ */
21
+ props: Props;
22
+ }
23
+ //#endregion
24
+ export { BaseComponent, Show, ShowCallable, UnionToIntersection };
25
+ //# sourceMappingURL=types.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.cts","names":[],"sources":["../../../../../internals/src/types.ts"],"mappings":";;AAIA;;;KAAY,IAAA,oBAAwB,CAAA,GAAI,CAAA,CAAE,CAAA;;;;KAK9B,YAAA,MAAkB,CAAA,cACzB,IAAA,2CAEI,IAAA,EAAM,SAAA,KAAc,MAAA,oBAA0B,CAAA,GAAI,CAAA,CAAE,GAAA,MACzD,IAAA,CAAK,CAAA;AAAA,KAIG,mBAAA,WACV,KAAA,oBAAyB,KAAA,EAAO,KAAK,6BAC5B,KAAA,iCACP,YAAA;AAAA,UAGa,aAAA;EAdL;;;EAkBV,WAAA,EAAa,IAAA;EAfA;;;;EAoBb,KAAA,EAAO,KAAK;AAAA"}
@@ -0,0 +1,25 @@
1
+ //#region ../internals/src/types.d.ts
2
+ /**
3
+ * Flattens an object type for display. Use {@link ShowCallable} when the type
4
+ * may carry call signatures, which a mapped type does not preserve.
5
+ */
6
+ type Show<T> = { [K in keyof T]: T[K] } & {};
7
+ /**
8
+ * Like {@link Show}, but keeps the call signature of callable types.
9
+ */
10
+ type ShowCallable<T> = T extends ((...args: infer Arguments) => infer Result) ? ((...args: Arguments) => Result) & { [Key in keyof T]: T[Key] } : Show<T>;
11
+ type UnionToIntersection<Union> = (Union extends unknown ? (value: Union) => void : never) extends ((value: infer Intersection) => void) ? Intersection : never;
12
+ interface BaseComponent<Name extends string, Props = {}> {
13
+ /**
14
+ * The name of the component. Useful for debugging and error messages.
15
+ */
16
+ displayName: Name;
17
+ /**
18
+ * A type only property to get the type of the props. At runtime,
19
+ * this is `undefined`.
20
+ */
21
+ props: Props;
22
+ }
23
+ //#endregion
24
+ export { BaseComponent, Show, ShowCallable, UnionToIntersection };
25
+ //# sourceMappingURL=types.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.mts","names":[],"sources":["../../../../../internals/src/types.ts"],"mappings":";;AAIA;;;KAAY,IAAA,oBAAwB,CAAA,GAAI,CAAA,CAAE,CAAA;;;;KAK9B,YAAA,MAAkB,CAAA,cACzB,IAAA,2CAEI,IAAA,EAAM,SAAA,KAAc,MAAA,oBAA0B,CAAA,GAAI,CAAA,CAAE,GAAA,MACzD,IAAA,CAAK,CAAA;AAAA,KAIG,mBAAA,WACV,KAAA,oBAAyB,KAAA,EAAO,KAAK,6BAC5B,KAAA,iCACP,YAAA;AAAA,UAGa,aAAA;EAdL;;;EAkBV,WAAA,EAAa,IAAA;EAfA;;;;EAoBb,KAAA,EAAO,KAAK;AAAA"}
package/dist/types.d.cts CHANGED
@@ -1,8 +1,8 @@
1
- import { AnyBuiltPropDefinition } from "@jfdevelops/react-layout-validator";
2
1
  import { ReactNode } from "react";
2
+ import { PropDefinition } from "@jfdevelops/react-layout-validator";
3
3
 
4
4
  //#region src/types.d.ts
5
- type InPropsObject = Record<string, AnyBuiltPropDefinition>;
5
+ type InPropsObject = Record<string, PropDefinition>;
6
6
  /** Adds the default content slot without weakening an explicit declaration. */
7
7
  type WithChildren<Props> = Props & ('children' extends keyof Props ? {} : {
8
8
  children?: ReactNode;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.cts","names":[],"sources":["../src/types.ts"],"mappings":";;;;KAGY,aAAA,GAAgB,MAAM,SAAS,sBAAA;;KAG/B,YAAA,UAAsB,KAAA,6BACN,KAAA;EAAe,QAAA,GAAW,SAAA;AAAA"}
1
+ {"version":3,"file":"types.d.cts","names":[],"sources":["../src/types.ts"],"mappings":";;;;KAGY,aAAA,GAAgB,MAAM,SAAS,cAAA;;KAG/B,YAAA,UAAsB,KAAA,6BACN,KAAA;EAAe,QAAA,GAAW,SAAA;AAAA"}
package/dist/types.d.mts CHANGED
@@ -1,8 +1,8 @@
1
- import { AnyBuiltPropDefinition } from "@jfdevelops/react-layout-validator";
2
1
  import { ReactNode } from "react";
2
+ import { PropDefinition } from "@jfdevelops/react-layout-validator";
3
3
 
4
4
  //#region src/types.d.ts
5
- type InPropsObject = Record<string, AnyBuiltPropDefinition>;
5
+ type InPropsObject = Record<string, PropDefinition>;
6
6
  /** Adds the default content slot without weakening an explicit declaration. */
7
7
  type WithChildren<Props> = Props & ('children' extends keyof Props ? {} : {
8
8
  children?: ReactNode;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.mts","names":[],"sources":["../src/types.ts"],"mappings":";;;;KAGY,aAAA,GAAgB,MAAM,SAAS,sBAAA;;KAG/B,YAAA,UAAsB,KAAA,6BACN,KAAA;EAAe,QAAA,GAAW,SAAA;AAAA"}
1
+ {"version":3,"file":"types.d.mts","names":[],"sources":["../src/types.ts"],"mappings":";;;;KAGY,aAAA,GAAgB,MAAM,SAAS,cAAA;;KAG/B,YAAA,UAAsB,KAAA,6BACN,KAAA;EAAe,QAAA,GAAW,SAAA;AAAA"}
package/package.json CHANGED
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "@jfdevelops/react-layout-composables",
3
- "version": "0.6.0",
3
+ "version": "1.0.0",
4
4
  "description": "Composable components for react-layout.",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/jfdevelops/react-layout.git",
8
8
  "directory": "packages/composables"
9
9
  },
10
- "type": "module",
11
10
  "files": [
12
11
  "dist"
13
12
  ],
13
+ "type": "module",
14
14
  "sideEffects": false,
15
15
  "main": "./dist/index.cjs",
16
16
  "module": "./dist/index.mjs",
@@ -23,21 +23,14 @@
23
23
  },
24
24
  "./package.json": "./package.json"
25
25
  },
26
- "engines": {
27
- "node": "^20.19.0 || >=22.12.0"
26
+ "publishConfig": {
27
+ "access": "public",
28
+ "provenance": true
28
29
  },
29
30
  "dependencies": {
30
31
  "@jfdevelops/create-error": "0.2.1",
31
32
  "arktype": "2.2.8",
32
- "@jfdevelops/react-layout-validator": "0.5.0"
33
- },
34
- "peerDependencies": {
35
- "react": ">=18",
36
- "react-dom": ">=18"
37
- },
38
- "publishConfig": {
39
- "access": "public",
40
- "provenance": true
33
+ "@jfdevelops/react-layout-validator": "1.0.0"
41
34
  },
42
35
  "devDependencies": {
43
36
  "@testing-library/jest-dom": "6.9.1",
@@ -50,10 +43,19 @@
50
43
  "react": "18.3.1",
51
44
  "react-dom": "18.3.1",
52
45
  "tsdown": "0.22.1",
53
- "typescript": "6.0.3",
54
46
  "unrun": "0.3.0",
55
47
  "vite": "8.0.10",
56
- "vitest": "4.1.5"
48
+ "vitest": "4.1.5",
49
+ "zod": "^4.6.7",
50
+ "@jfdevelops/react-layout-adapter-zod": "1.0.0",
51
+ "@jfdevelops/react-layout-internals": "0.0.0"
52
+ },
53
+ "peerDependencies": {
54
+ "react": ">=18",
55
+ "react-dom": ">=18"
56
+ },
57
+ "engines": {
58
+ "node": "^20.19.0 || >=22.12.0"
57
59
  },
58
60
  "scripts": {
59
61
  "build": "tsdown",
@@ -1 +0,0 @@
1
- {"version":3,"file":"capitalize.d.cts","names":[],"sources":["../../src/utils/capitalize.ts"],"mappings":";KAAY,YAAA,UAAsB,UAAU;AAAA,iBAE5B,UAAA,mBAA6B,GAAA,EAAK,CAAA,GAAI,UAAA,CAAW,CAAA;AAAA,iBACjD,UAAA,CAAW,GAAW"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"capitalize.d.mts","names":[],"sources":["../../src/utils/capitalize.ts"],"mappings":";KAAY,YAAA,UAAsB,UAAU;AAAA,iBAE5B,UAAA,mBAA6B,GAAA,EAAK,CAAA,GAAI,UAAA,CAAW,CAAA;AAAA,iBACjD,UAAA,CAAW,GAAW"}
package/dist/utils.d.cts DELETED
@@ -1,10 +0,0 @@
1
- //#region src/utils.d.ts
2
- type Show<T> = T extends ((...args: infer A) => infer R) ? (...args: A) => R : { [K in keyof T]: T[K] } & {};
3
- type UnionToIntersection<Union> = (Union extends unknown ? (value: Union) => void : never) extends ((value: infer Intersection) => void) ? Intersection : never;
4
- interface BaseComponent<Name extends string, Props = {}> {
5
- displayName: Name;
6
- props: Props;
7
- }
8
- //#endregion
9
- export { BaseComponent, Show, UnionToIntersection };
10
- //# sourceMappingURL=utils.d.cts.map
@@ -1 +0,0 @@
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,KAEZ,mBAAA,WACV,KAAA,oBAAyB,KAAA,EAAO,KAAK,6BAC5B,KAAA,iCACP,YAAA;AAAA,UAGa,aAAA;EACf,WAAA,EAAa,IAAA;EACb,KAAA,EAAO,KAAK;AAAA"}
package/dist/utils.d.mts DELETED
@@ -1,10 +0,0 @@
1
- //#region src/utils.d.ts
2
- type Show<T> = T extends ((...args: infer A) => infer R) ? (...args: A) => R : { [K in keyof T]: T[K] } & {};
3
- type UnionToIntersection<Union> = (Union extends unknown ? (value: Union) => void : never) extends ((value: infer Intersection) => void) ? Intersection : never;
4
- interface BaseComponent<Name extends string, Props = {}> {
5
- displayName: Name;
6
- props: Props;
7
- }
8
- //#endregion
9
- export { BaseComponent, Show, UnionToIntersection };
10
- //# sourceMappingURL=utils.d.mts.map
@@ -1 +0,0 @@
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,KAEZ,mBAAA,WACV,KAAA,oBAAyB,KAAA,EAAO,KAAK,6BAC5B,KAAA,iCACP,YAAA;AAAA,UAGa,aAAA;EACf,WAAA,EAAa,IAAA;EACb,KAAA,EAAO,KAAK;AAAA"}