@jfdevelops/react-layout 2.1.0 → 2.3.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.
Files changed (125) hide show
  1. package/dist/create-config/create-defined-resource-layout.cjs +6 -3
  2. package/dist/create-config/create-defined-resource-layout.cjs.map +1 -1
  3. package/dist/create-config/create-defined-resource-layout.d.cts +16 -13
  4. package/dist/create-config/create-defined-resource-layout.d.cts.map +1 -1
  5. package/dist/create-config/create-defined-resource-layout.d.mts +16 -13
  6. package/dist/create-config/create-defined-resource-layout.d.mts.map +1 -1
  7. package/dist/create-config/create-defined-resource-layout.mjs +6 -3
  8. package/dist/create-config/create-defined-resource-layout.mjs.map +1 -1
  9. package/dist/create-config/create-resource-links.cjs.map +1 -1
  10. package/dist/create-config/create-resource-links.d.cts +3 -1
  11. package/dist/create-config/create-resource-links.d.cts.map +1 -1
  12. package/dist/create-config/create-resource-links.d.mts +3 -1
  13. package/dist/create-config/create-resource-links.d.mts.map +1 -1
  14. package/dist/create-config/create-resource-links.mjs.map +1 -1
  15. package/dist/create-config/create-reusable.cjs +49 -0
  16. package/dist/create-config/create-reusable.cjs.map +1 -0
  17. package/dist/create-config/create-reusable.d.cts +41 -0
  18. package/dist/create-config/create-reusable.d.cts.map +1 -0
  19. package/dist/create-config/create-reusable.d.mts +41 -0
  20. package/dist/create-config/create-reusable.d.mts.map +1 -0
  21. package/dist/create-config/create-reusable.mjs +49 -0
  22. package/dist/create-config/create-reusable.mjs.map +1 -0
  23. package/dist/create-config/define-layout.cjs +19 -12
  24. package/dist/create-config/define-layout.cjs.map +1 -1
  25. package/dist/create-config/define-layout.d.cts +43 -42
  26. package/dist/create-config/define-layout.d.cts.map +1 -1
  27. package/dist/create-config/define-layout.d.mts +43 -42
  28. package/dist/create-config/define-layout.d.mts.map +1 -1
  29. package/dist/create-config/define-layout.mjs +22 -15
  30. package/dist/create-config/define-layout.mjs.map +1 -1
  31. package/dist/create-config/for-paths/builder.cjs +1 -0
  32. package/dist/create-config/for-paths/builder.cjs.map +1 -1
  33. package/dist/create-config/for-paths/builder.d.cts +5 -3
  34. package/dist/create-config/for-paths/builder.d.cts.map +1 -1
  35. package/dist/create-config/for-paths/builder.d.mts +5 -3
  36. package/dist/create-config/for-paths/builder.d.mts.map +1 -1
  37. package/dist/create-config/for-paths/builder.mjs +1 -0
  38. package/dist/create-config/for-paths/builder.mjs.map +1 -1
  39. package/dist/create-config/for-resource.cjs.map +1 -1
  40. package/dist/create-config/for-resource.d.cts +7 -6
  41. package/dist/create-config/for-resource.d.cts.map +1 -1
  42. package/dist/create-config/for-resource.d.mts +7 -6
  43. package/dist/create-config/for-resource.d.mts.map +1 -1
  44. package/dist/create-config/for-resource.mjs.map +1 -1
  45. package/dist/create-config/for-resources/create-component.d.cts +34 -33
  46. package/dist/create-config/for-resources/create-component.d.cts.map +1 -1
  47. package/dist/create-config/for-resources/create-component.d.mts +34 -33
  48. package/dist/create-config/for-resources/create-component.d.mts.map +1 -1
  49. package/dist/create-config/for-resources/create-for-resources.cjs +7 -6
  50. package/dist/create-config/for-resources/create-for-resources.cjs.map +1 -1
  51. package/dist/create-config/for-resources/create-for-resources.d.cts +2 -1
  52. package/dist/create-config/for-resources/create-for-resources.d.mts +2 -1
  53. package/dist/create-config/for-resources/create-for-resources.mjs +7 -6
  54. package/dist/create-config/for-resources/create-for-resources.mjs.map +1 -1
  55. package/dist/create-config/for-resources/scoped-layout.d.cts +5 -4
  56. package/dist/create-config/for-resources/scoped-layout.d.cts.map +1 -1
  57. package/dist/create-config/for-resources/scoped-layout.d.mts +5 -4
  58. package/dist/create-config/for-resources/scoped-layout.d.mts.map +1 -1
  59. package/dist/create-config/index.d.cts +1 -0
  60. package/dist/create-config/index.d.mts +1 -0
  61. package/dist/create-config/inspection.cjs +23 -1
  62. package/dist/create-config/inspection.cjs.map +1 -1
  63. package/dist/create-config/inspection.mjs +24 -3
  64. package/dist/create-config/inspection.mjs.map +1 -1
  65. package/dist/create-config/layout-name.cjs +1 -1
  66. package/dist/create-config/layout-name.mjs +1 -1
  67. package/dist/create-config/lazy-resource-layout.cjs +5 -5
  68. package/dist/create-config/lazy-resource-layout.cjs.map +1 -1
  69. package/dist/create-config/lazy-resource-layout.d.cts +2 -2
  70. package/dist/create-config/lazy-resource-layout.d.cts.map +1 -1
  71. package/dist/create-config/lazy-resource-layout.d.mts +2 -2
  72. package/dist/create-config/lazy-resource-layout.d.mts.map +1 -1
  73. package/dist/create-config/lazy-resource-layout.mjs +5 -5
  74. package/dist/create-config/lazy-resource-layout.mjs.map +1 -1
  75. package/dist/create-config/render-state.cjs +3 -2
  76. package/dist/create-config/render-state.cjs.map +1 -1
  77. package/dist/create-config/render-state.d.cts +27 -25
  78. package/dist/create-config/render-state.d.cts.map +1 -1
  79. package/dist/create-config/render-state.d.mts +27 -25
  80. package/dist/create-config/render-state.d.mts.map +1 -1
  81. package/dist/create-config/render-state.mjs +3 -2
  82. package/dist/create-config/render-state.mjs.map +1 -1
  83. package/dist/create-config/state-composable.cjs +1 -1
  84. package/dist/create-config/state-composable.mjs +1 -1
  85. package/dist/custom-props.cjs +15 -0
  86. package/dist/custom-props.cjs.map +1 -0
  87. package/dist/custom-props.d.cts +17 -0
  88. package/dist/custom-props.d.cts.map +1 -0
  89. package/dist/custom-props.d.mts +17 -0
  90. package/dist/custom-props.d.mts.map +1 -0
  91. package/dist/custom-props.mjs +15 -0
  92. package/dist/custom-props.mjs.map +1 -0
  93. package/dist/errors/react-layout-error.cjs +1 -1
  94. package/dist/errors/react-layout-error.mjs +1 -1
  95. package/dist/index.cjs +3 -3
  96. package/dist/index.d.cts +3 -1
  97. package/dist/index.d.mts +3 -1
  98. package/dist/index.mjs +3 -3
  99. package/dist/lazy/create-lazy-loader.cjs +30 -9
  100. package/dist/lazy/create-lazy-loader.cjs.map +1 -1
  101. package/dist/lazy/create-lazy-loader.mjs +31 -10
  102. package/dist/lazy/create-lazy-loader.mjs.map +1 -1
  103. package/dist/lazy/create-render-state.cjs.map +1 -1
  104. package/dist/lazy/create-render-state.d.cts +5 -5
  105. package/dist/lazy/create-render-state.d.cts.map +1 -1
  106. package/dist/lazy/create-render-state.d.mts +5 -5
  107. package/dist/lazy/create-render-state.d.mts.map +1 -1
  108. package/dist/lazy/create-render-state.mjs.map +1 -1
  109. package/dist/lazy/lazy-boundary.cjs +1 -1
  110. package/dist/lazy/lazy-boundary.mjs +1 -1
  111. package/dist/lazy/types.cjs.map +1 -1
  112. package/dist/lazy/types.d.cts +5 -4
  113. package/dist/lazy/types.d.cts.map +1 -1
  114. package/dist/lazy/types.d.mts +5 -4
  115. package/dist/lazy/types.d.mts.map +1 -1
  116. package/dist/lazy/types.mjs.map +1 -1
  117. package/dist/props.cjs.map +1 -1
  118. package/dist/props.d.cts +4 -3
  119. package/dist/props.d.cts.map +1 -1
  120. package/dist/props.d.mts +4 -3
  121. package/dist/props.d.mts.map +1 -1
  122. package/dist/props.mjs.map +1 -1
  123. package/dist/resource.d.cts +1 -1
  124. package/dist/resource.d.mts +1 -1
  125. package/package.json +5 -5
@@ -136,6 +136,7 @@ function createTargetPathBuilder(config, paths) {
136
136
  };
137
137
  validateParams(params, state, validationSets);
138
138
  return {
139
+ children: props.children,
139
140
  params,
140
141
  getComponentForPath: (path) => {
141
142
  if (!state.paths.includes(path)) throw new require_invalid_path.InvalidPathError({
@@ -1 +1 @@
1
- {"version":3,"file":"builder.cjs","names":["collectPathResources","collectPathSubResourceKeys","collectPathComponentKeys","InvalidResourceError","flattenSubResourceParam","InvalidSubResourceError","InvalidComponentError","extractPathVariables","InvalidPathError","createGetComponentForPath","generateResourceConfigPaths"],"sources":["../../../src/create-config/for-paths/builder.ts"],"sourcesContent":["import type { JSX } from 'react';\nimport {\n InvalidComponentError,\n InvalidPathError,\n InvalidResourceError,\n InvalidSubResourceError,\n} from '../../errors';\nimport type { ResourceDefinition } from '../../resource';\nimport type { IsUnion, Show } from '../../utils';\nimport {\n collectPathComponentKeys,\n collectPathResources,\n collectPathSubResourceKeys,\n extractPathVariables,\n flattenSubResourceParam,\n generateResourceConfigPaths,\n} from '../paths';\nimport type {\n PathComponentKeys,\n PathVariables,\n SubResourceParamValue,\n} from '../paths';\nimport {\n createGetComponentForPath,\n type CreateGetComponentForPath,\n} from './get-component-for-path';\n\ntype UnwrapTargetPaths<Paths> = Paths extends readonly [\n infer First,\n ...infer Rest,\n]\n ? (First & string) | UnwrapTargetPaths<Rest>\n : Paths extends readonly (infer Path)[]\n ? Path & string\n : never;\n\ntype PathVariablesForPaths<\n Resources extends ReadonlyArray<ResourceDefinition>,\n Config,\n Paths extends ReadonlyArray<string>,\n> =\n UnwrapTargetPaths<Paths> extends infer Path\n ? Path extends string\n ? PathVariables<Resources, Config, Path>\n : never\n : never;\n\ntype ComponentKeysForPaths<\n Resources extends ReadonlyArray<ResourceDefinition>,\n Config,\n Paths extends ReadonlyArray<string>,\n> =\n UnwrapTargetPaths<Paths> extends infer Path\n ? Path extends string\n ? PathComponentKeys<Resources, Config, Path>\n : never\n : never;\n\ntype ValueOrFunction<Value, Input> = Value | ((input: Input) => Value);\n\n/** Context handed to `render` and to `setDisplayName`. */\nexport type ForPathsRenderContext<\n Resources extends ReadonlyArray<ResourceDefinition>,\n Config,\n Paths extends ReadonlyArray<string>,\n Params,\n> = {\n /** Declared params merged with the props the component was called with. */\n params: Params;\n /** Creates a getter for any of the paths this component was built for. */\n getComponentForPath: CreateGetComponentForPath<\n Resources,\n Config,\n UnwrapTargetPaths<Paths>\n >;\n};\n\ntype HOFArgSelection<Params> = {\n [Key in keyof Params]?: true;\n};\n\n/**\n * Value closed over by `asHOF`. Selecting a single arg closes over that value directly;\n * selecting several closes over an object.\n */\ntype HOFClosureValue<Params, Args> = [keyof Args] extends [never]\n ? {}\n : IsUnion<keyof Args> extends false\n ? Params[keyof Args & keyof Params]\n : Show<Pick<Params, keyof Args & keyof Params>>;\n\nexport interface RenderedPathComponentHOF<Params, Args> {\n (closure: HOFClosureValue<Params, Args>): RenderedPathComponent<\n Show<Omit<Params, keyof Args>>\n >;\n /** Type-only view of the value this HOF closes over. At runtime this is `undefined`. */\n _args: HOFClosureValue<Params, Args>;\n}\n\nexport interface RenderedPathComponent<\n Params,\n DisplayName extends string = string,\n> {\n (props: Params): JSX.Element;\n displayName: DisplayName;\n /** Type-only view of the props this component accepts. */\n _args: Params;\n /**\n * Splits the props into a closure and the remaining props, so shared params can be\n * bound once and the component reused. Chained `asHOF` calls keep prior closures.\n */\n asHOF<Args extends HOFArgSelection<Params> = {}>(options?: {\n /** Params to close over. Anything omitted stays a prop. */\n args: Args;\n }): RenderedPathComponentHOF<Params, Args>;\n}\n\ntype WithComponentKeyParam<\n Resources extends ReadonlyArray<ResourceDefinition>,\n Config,\n Paths extends ReadonlyArray<string>,\n Optional extends boolean,\n> = Optional extends true\n ? { componentKey?: ComponentKeysForPaths<Resources, Config, Paths> }\n : { componentKey: ComponentKeysForPaths<Resources, Config, Paths> };\n\ntype PickedPathParams<\n Variables,\n Picked,\n> = [keyof Picked] extends [never]\n ? Variables\n : Pick<Variables, keyof Picked & keyof Variables>;\n\nexport type TargetPathBuilder<\n Resources extends ReadonlyArray<ResourceDefinition>,\n Config,\n Paths extends ReadonlyArray<string>,\n Params extends Record<string, unknown> = {},\n Used extends\n | 'addComponentKeyParams'\n | 'addPathParams'\n | 'addParams' = never,\n> = {\n render: (\n renderer: (\n context: ForPathsRenderContext<Resources, Config, Paths, Params>,\n ) => JSX.Element,\n ) => RenderedPathComponent<Params> & {\n /** Names the component, either statically or from the render context. */\n setDisplayName<Name extends string>(\n name: ValueOrFunction<\n Name,\n ForPathsRenderContext<Resources, Config, Paths, Params>\n >,\n ): RenderedPathComponent<Params, Name>;\n };\n} & ('addComponentKeyParams' extends Used\n ? {}\n : {\n /**\n * Adds a `componentKey` prop narrowed to the component slots configured for these\n * paths. Call it before `render` when building a reusable component.\n */\n addComponentKeyParams<Optional extends boolean = false>(options?: {\n /** Whether the caller may omit `componentKey`. */\n optional?: Optional;\n }): TargetPathBuilder<\n Resources,\n Config,\n Paths,\n Show<\n Params & WithComponentKeyParam<Resources, Config, Paths, Optional>\n >,\n Used | 'addComponentKeyParams'\n >;\n }) &\n ('addPathParams' extends Used\n ? {}\n : {\n /**\n * Turns the variables these paths leave open into props. Without `pick`, every\n * variable becomes a prop.\n */\n addPathParams<\n Variables extends PathVariablesForPaths<Resources, Config, Paths>,\n Picked extends { [Key in keyof Variables]?: true } = {},\n >(options?: {\n /** Variables to expose as props. Defaults to all of them. */\n pick?: Picked;\n }): TargetPathBuilder<\n Resources,\n Config,\n Paths,\n Show<Params & PickedPathParams<Variables, Picked>>,\n Used | 'addPathParams'\n >;\n }) &\n ('addParams' extends Used\n ? {}\n : {\n /**\n * Adds custom params with the given values as defaults. Defaults are\n * optional at the call site and filled in before `render` runs.\n */\n addParams<NewParams extends Record<string, unknown>>(\n params: NewParams,\n ): TargetPathBuilder<\n Resources,\n Config,\n Paths,\n Show<Params & Partial<NewParams>>,\n Used | 'addParams'\n >;\n });\n\nexport type ForPaths<\n Resources extends ReadonlyArray<ResourceDefinition>,\n Config,\n AllowedPath extends string,\n> = <const Paths extends readonly [AllowedPath, ...AllowedPath[]]>(\n ...paths: Paths\n) => TargetPathBuilder<Resources, Config, Paths>;\n\nconst DEFAULT_DISPLAY_NAME = 'ResourcePathComponent';\n\ntype BuilderState = {\n paths: readonly string[];\n paramDefaults: Record<string, unknown>;\n declaredPathParams: readonly string[];\n componentKeyDeclared: boolean;\n componentKeyOptional: boolean;\n usedComponentKeyParams: boolean;\n usedPathParams: boolean;\n usedParams: boolean;\n};\n\ntype ValidationSets = {\n resources: readonly string[];\n subResources: readonly string[];\n components: readonly string[];\n};\n\nfunction collectValidationSets(\n config: Record<string, unknown>,\n paths: readonly string[],\n): ValidationSets {\n const resources = new Set<string>();\n const subResources = new Set<string>();\n const components = new Set<string>();\n\n for (const path of paths) {\n for (const resource of collectPathResources(config, path)) {\n resources.add(resource);\n }\n\n for (const subResource of collectPathSubResourceKeys(config, path)) {\n subResources.add(subResource);\n }\n\n for (const component of collectPathComponentKeys(config, path)) {\n components.add(component);\n }\n }\n\n return {\n resources: [...resources],\n subResources: [...subResources],\n components: [...components],\n };\n}\n\n/**\n * Validates the params a caller passed before the renderer runs, so a bad resource or\n * slot fails with a typed error naming what is available.\n */\nfunction validateParams(\n params: Record<string, unknown>,\n state: BuilderState,\n sets: ValidationSets,\n): void {\n const { resource, subResource, component, componentKey } = params as {\n resource?: unknown;\n subResource?: unknown;\n component?: unknown;\n componentKey?: unknown;\n };\n\n if (state.declaredPathParams.includes('resource') && resource !== undefined) {\n if (typeof resource !== 'string' || !sets.resources.includes(resource)) {\n throw new InvalidResourceError({\n resource,\n validResources: [...sets.resources],\n });\n }\n }\n\n if (\n state.declaredPathParams.includes('subResource') &&\n subResource !== undefined\n ) {\n const slugs = flattenSubResourceParam(subResource as SubResourceParamValue);\n\n for (const slug of slugs) {\n if (!sets.subResources.includes(slug)) {\n throw new InvalidSubResourceError({\n subResource: slug,\n resource: typeof resource === 'string' ? resource : undefined,\n validSubResources: [...sets.subResources],\n });\n }\n }\n }\n\n if (\n state.declaredPathParams.includes('component') &&\n component !== undefined\n ) {\n if (typeof component !== 'string' || !sets.components.includes(component)) {\n throw new InvalidComponentError({\n component,\n validComponents: [...sets.components],\n });\n }\n }\n\n if (!state.componentKeyDeclared) {\n return;\n }\n\n if (componentKey === undefined) {\n if (!state.componentKeyOptional) {\n throw new InvalidComponentError({\n component: componentKey,\n validComponents: [...sets.components],\n reason: 'A \"componentKey\" prop is required for this component',\n });\n }\n\n return;\n }\n\n if (\n typeof componentKey !== 'string' ||\n !sets.components.includes(componentKey)\n ) {\n throw new InvalidComponentError({\n component: componentKey,\n validComponents: [...sets.components],\n });\n }\n}\n\nfunction readClosureProps(\n selected: string[],\n closure: unknown,\n): Record<string, unknown> {\n if (selected.length === 0) {\n return {};\n }\n\n const [only] = selected;\n\n if (selected.length === 1 && only !== undefined) {\n return { [only]: closure };\n }\n\n if (\n typeof closure === 'object' &&\n closure !== null &&\n !Array.isArray(closure)\n ) {\n return { ...(closure as Record<string, unknown>) };\n }\n\n return {};\n}\n\nfunction createRenderedComponent(\n runRenderer: (props: Record<string, unknown>) => JSX.Element,\n paramTemplate: Record<string, unknown> | undefined,\n resolveDisplayName?: (props: Record<string, unknown>) => string,\n boundProps: Record<string, unknown> = {},\n) {\n function RenderedPathView(props: Record<string, unknown>): JSX.Element {\n const merged = { ...boundProps, ...props };\n\n if (resolveDisplayName) {\n RenderedPathView.displayName = resolveDisplayName(merged);\n }\n\n return runRenderer(merged);\n }\n\n RenderedPathView.displayName = DEFAULT_DISPLAY_NAME;\n\n function asHOF(options?: { args?: Record<string, true> }) {\n const selected = Object.entries(options?.args ?? {})\n .filter(([, enabled]) => enabled === true)\n .map(([key]) => key);\n\n function hof(closure: unknown) {\n const bound = createRenderedComponent(\n runRenderer,\n undefined,\n resolveDisplayName,\n { ...boundProps, ...readClosureProps(selected, closure) },\n );\n\n bound.displayName = RenderedPathView.displayName;\n\n return bound;\n }\n\n return Object.assign(hof, { _args: undefined as never });\n }\n\n return Object.assign(RenderedPathView, {\n _args: paramTemplate as never,\n asHOF,\n });\n}\n\nexport function createTargetPathBuilder<\n Resources extends ReadonlyArray<ResourceDefinition>,\n Config extends Record<string, unknown>,\n Paths extends ReadonlyArray<string>,\n>(config: Config, paths: Paths): TargetPathBuilder<Resources, Config, Paths> {\n const validationSets = collectValidationSets(config, paths);\n\n const makeBuilder = (state: BuilderState): Record<string, unknown> => {\n const builder: Record<string, unknown> = {};\n\n if (!state.usedComponentKeyParams) {\n builder.addComponentKeyParams = (options?: { optional?: boolean }) =>\n makeBuilder({\n ...state,\n usedComponentKeyParams: true,\n componentKeyDeclared: true,\n componentKeyOptional: options?.optional === true,\n });\n }\n\n if (!state.usedPathParams) {\n builder.addPathParams = (options?: { pick?: Record<string, true> }) => {\n const available = new Set<string>();\n\n for (const path of state.paths) {\n for (const name of extractPathVariables(path)) {\n available.add(name);\n }\n }\n\n const picked = Object.entries(options?.pick ?? {})\n .filter(([, enabled]) => enabled === true)\n .map(([key]) => key);\n const declared =\n picked.length === 0\n ? [...available]\n : picked.filter((name) => available.has(name));\n\n return makeBuilder({\n ...state,\n usedPathParams: true,\n declaredPathParams: [...state.declaredPathParams, ...declared],\n });\n };\n }\n\n if (!state.usedParams) {\n builder.addParams = (params: Record<string, unknown>) =>\n makeBuilder({\n ...state,\n usedParams: true,\n paramDefaults: { ...state.paramDefaults, ...params },\n });\n }\n\n builder.render = (\n renderer: (context: {\n params: Record<string, unknown>;\n getComponentForPath: unknown;\n }) => JSX.Element,\n ) => {\n const buildContext = (props: Record<string, unknown>) => {\n const params = { ...state.paramDefaults, ...props };\n\n validateParams(params, state, validationSets);\n\n return {\n params,\n getComponentForPath: (path: string) => {\n if (!state.paths.includes(path)) {\n throw new InvalidPathError({\n path,\n validPaths: [...state.paths],\n reason: 'This component was not built for that path',\n });\n }\n\n return createGetComponentForPath(config, path);\n },\n };\n };\n\n const runRenderer = (props: Record<string, unknown>) =>\n renderer(buildContext(props));\n\n const component = createRenderedComponent(runRenderer, {\n ...state.paramDefaults,\n });\n\n return Object.assign(component, {\n setDisplayName: (\n name:\n | string\n | ((context: {\n params: Record<string, unknown>;\n getComponentForPath: unknown;\n }) => string),\n ) => {\n if (typeof name === 'string') {\n const named = createRenderedComponent(runRenderer, {\n ...state.paramDefaults,\n });\n\n named.displayName = name;\n\n return named;\n }\n\n return createRenderedComponent(\n runRenderer,\n { ...state.paramDefaults },\n (props) => name(buildContext(props)),\n );\n },\n });\n };\n\n return builder;\n };\n\n return makeBuilder({\n paths,\n paramDefaults: {},\n declaredPathParams: [],\n componentKeyDeclared: false,\n componentKeyOptional: false,\n usedComponentKeyParams: false,\n usedPathParams: false,\n usedParams: false,\n }) as unknown as TargetPathBuilder<Resources, Config, Paths>;\n}\n\nexport function createForPaths<\n Resources extends ReadonlyArray<ResourceDefinition>,\n Config extends Record<string, unknown>,\n>(config: Config): ForPaths<Resources, Config, string> {\n const validPaths = generateResourceConfigPaths(config);\n\n return ((...paths: string[]) => {\n if (paths.length === 0) {\n throw new InvalidPathError({\n path: paths,\n validPaths,\n reason: 'At least one path is required',\n });\n }\n\n for (const path of paths) {\n if (!validPaths.includes(path)) {\n throw new InvalidPathError({ path, validPaths });\n }\n }\n\n return createTargetPathBuilder(config, paths);\n }) as unknown as ForPaths<Resources, Config, string>;\n}\n"],"mappings":";;;;;;;;;;;AA+NA,MAAM,uBAAuB;AAmB7B,SAAS,sBACP,QACA,OACgB;CAChB,MAAM,4BAAY,IAAI,IAAY;CAClC,MAAM,+BAAe,IAAI,IAAY;CACrC,MAAM,6BAAa,IAAI,IAAY;CAEnC,KAAK,MAAM,QAAQ,OAAO;EACxB,KAAK,MAAM,YAAYA,wCAAqB,QAAQ,IAAI,GACtD,UAAU,IAAI,QAAQ;EAGxB,KAAK,MAAM,eAAeC,8CAA2B,QAAQ,IAAI,GAC/D,aAAa,IAAI,WAAW;EAG9B,KAAK,MAAM,aAAaC,4CAAyB,QAAQ,IAAI,GAC3D,WAAW,IAAI,SAAS;CAE5B;CAEA,OAAO;EACL,WAAW,CAAC,GAAG,SAAS;EACxB,cAAc,CAAC,GAAG,YAAY;EAC9B,YAAY,CAAC,GAAG,UAAU;CAC5B;AACF;;;;;AAMA,SAAS,eACP,QACA,OACA,MACM;CACN,MAAM,EAAE,UAAU,aAAa,WAAW,iBAAiB;CAO3D,IAAI,MAAM,mBAAmB,SAAS,UAAU,KAAK,aAAa,QAChE;MAAI,OAAO,aAAa,YAAY,CAAC,KAAK,UAAU,SAAS,QAAQ,GACnE,MAAM,IAAIC,8CAAqB;GAC7B;GACA,gBAAgB,CAAC,GAAG,KAAK,SAAS;EACpC,CAAC;CACH;CAGF,IACE,MAAM,mBAAmB,SAAS,aAAa,KAC/C,gBAAgB,QAChB;EACA,MAAM,QAAQC,wCAAwB,WAAoC;EAE1E,KAAK,MAAM,QAAQ,OACjB,IAAI,CAAC,KAAK,a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H,KAAK,MAAM,QAAQ,OACjB,IAAI,CAAC,WAAW,SAAS,IAAI,GAC3B,MAAM,IAAIA,sCAAiB;GAAE;GAAM;EAAW,CAAC;EAInD,OAAO,wBAAwB,QAAQ,KAAK;CAC9C;AACF"}
1
+ {"version":3,"file":"builder.cjs","names":["collectPathResources","collectPathSubResourceKeys","collectPathComponentKeys","InvalidResourceError","flattenSubResourceParam","InvalidSubResourceError","InvalidComponentError","extractPathVariables","InvalidPathError","createGetComponentForPath","generateResourceConfigPaths"],"sources":["../../../src/create-config/for-paths/builder.ts"],"sourcesContent":["import type { JSX, ReactNode } from 'react';\nimport type { WithChildren } from '@jfdevelops/react-layout-composables';\nimport {\n InvalidComponentError,\n InvalidPathError,\n InvalidResourceError,\n InvalidSubResourceError,\n} from '../../errors';\nimport type { ResourceDefinition } from '../../resource';\nimport type { IsUnion, Show } from '../../utils';\nimport {\n collectPathComponentKeys,\n collectPathResources,\n collectPathSubResourceKeys,\n extractPathVariables,\n flattenSubResourceParam,\n generateResourceConfigPaths,\n} from '../paths';\nimport type {\n PathComponentKeys,\n PathVariables,\n SubResourceParamValue,\n} from '../paths';\nimport {\n createGetComponentForPath,\n type CreateGetComponentForPath,\n} from './get-component-for-path';\n\ntype UnwrapTargetPaths<Paths> = Paths extends readonly [\n infer First,\n ...infer Rest,\n]\n ? (First & string) | UnwrapTargetPaths<Rest>\n : Paths extends readonly (infer Path)[]\n ? Path & string\n : never;\n\ntype PathVariablesForPaths<\n Resources extends ReadonlyArray<ResourceDefinition>,\n Config,\n Paths extends ReadonlyArray<string>,\n> =\n UnwrapTargetPaths<Paths> extends infer Path\n ? Path extends string\n ? PathVariables<Resources, Config, Path>\n : never\n : never;\n\ntype ComponentKeysForPaths<\n Resources extends ReadonlyArray<ResourceDefinition>,\n Config,\n Paths extends ReadonlyArray<string>,\n> =\n UnwrapTargetPaths<Paths> extends infer Path\n ? Path extends string\n ? PathComponentKeys<Resources, Config, Path>\n : never\n : never;\n\ntype ValueOrFunction<Value, Input> = Value | ((input: Input) => Value);\n\n/** Context handed to `render` and to `setDisplayName`. */\nexport type ForPathsRenderContext<\n Resources extends ReadonlyArray<ResourceDefinition>,\n Config,\n Paths extends ReadonlyArray<string>,\n Params,\n> = {\n children?: ReactNode;\n /** Declared params merged with the props the component was called with. */\n params: Params;\n /** Creates a getter for any of the paths this component was built for. */\n getComponentForPath: CreateGetComponentForPath<\n Resources,\n Config,\n UnwrapTargetPaths<Paths>\n >;\n};\n\ntype HOFArgSelection<Params> = {\n [Key in keyof Params]?: true;\n};\n\n/**\n * Value closed over by `asHOF`. Selecting a single arg closes over that value directly;\n * selecting several closes over an object.\n */\ntype HOFClosureValue<Params, Args> = [keyof Args] extends [never]\n ? {}\n : IsUnion<keyof Args> extends false\n ? Params[keyof Args & keyof Params]\n : Show<Pick<Params, keyof Args & keyof Params>>;\n\nexport interface RenderedPathComponentHOF<Params, Args> {\n (closure: HOFClosureValue<Params, Args>): RenderedPathComponent<\n Show<Omit<Params, keyof Args>>\n >;\n /** Type-only view of the value this HOF closes over. At runtime this is `undefined`. */\n _args: HOFClosureValue<Params, Args>;\n}\n\nexport interface RenderedPathComponent<\n Params,\n DisplayName extends string = string,\n> {\n (props: WithChildren<Params>): JSX.Element;\n displayName: DisplayName;\n /** Type-only view of the props this component accepts. */\n _args: Params;\n /**\n * Splits the props into a closure and the remaining props, so shared params can be\n * bound once and the component reused. Chained `asHOF` calls keep prior closures.\n */\n asHOF<Args extends HOFArgSelection<Params> = {}>(options?: {\n /** Params to close over. Anything omitted stays a prop. */\n args: Args;\n }): RenderedPathComponentHOF<Params, Args>;\n}\n\ntype WithComponentKeyParam<\n Resources extends ReadonlyArray<ResourceDefinition>,\n Config,\n Paths extends ReadonlyArray<string>,\n Optional extends boolean,\n> = Optional extends true\n ? { componentKey?: ComponentKeysForPaths<Resources, Config, Paths> }\n : { componentKey: ComponentKeysForPaths<Resources, Config, Paths> };\n\ntype PickedPathParams<\n Variables,\n Picked,\n> = [keyof Picked] extends [never]\n ? Variables\n : Pick<Variables, keyof Picked & keyof Variables>;\n\nexport type TargetPathBuilder<\n Resources extends ReadonlyArray<ResourceDefinition>,\n Config,\n Paths extends ReadonlyArray<string>,\n Params extends Record<string, unknown> = {},\n Used extends\n | 'addComponentKeyParams'\n | 'addPathParams'\n | 'addParams' = never,\n> = {\n render: (\n renderer: (\n context: ForPathsRenderContext<Resources, Config, Paths, Params>,\n ) => JSX.Element,\n ) => RenderedPathComponent<Params> & {\n /** Names the component, either statically or from the render context. */\n setDisplayName<Name extends string>(\n name: ValueOrFunction<\n Name,\n ForPathsRenderContext<Resources, Config, Paths, Params>\n >,\n ): RenderedPathComponent<Params, Name>;\n };\n} & ('addComponentKeyParams' extends Used\n ? {}\n : {\n /**\n * Adds a `componentKey` prop narrowed to the component slots configured for these\n * paths. Call it before `render` when building a reusable component.\n */\n addComponentKeyParams<Optional extends boolean = false>(options?: {\n /** Whether the caller may omit `componentKey`. */\n optional?: Optional;\n }): TargetPathBuilder<\n Resources,\n Config,\n Paths,\n Show<\n Params & WithComponentKeyParam<Resources, Config, Paths, Optional>\n >,\n Used | 'addComponentKeyParams'\n >;\n }) &\n ('addPathParams' extends Used\n ? {}\n : {\n /**\n * Turns the variables these paths leave open into props. Without `pick`, every\n * variable becomes a prop.\n */\n addPathParams<\n Variables extends PathVariablesForPaths<Resources, Config, Paths>,\n Picked extends { [Key in keyof Variables]?: true } = {},\n >(options?: {\n /** Variables to expose as props. Defaults to all of them. */\n pick?: Picked;\n }): TargetPathBuilder<\n Resources,\n Config,\n Paths,\n Show<Params & PickedPathParams<Variables, Picked>>,\n Used | 'addPathParams'\n >;\n }) &\n ('addParams' extends Used\n ? {}\n : {\n /**\n * Adds custom params with the given values as defaults. Defaults are\n * optional at the call site and filled in before `render` runs.\n */\n addParams<NewParams extends Record<string, unknown>>(\n params: NewParams,\n ): TargetPathBuilder<\n Resources,\n Config,\n Paths,\n Show<Params & Partial<NewParams>>,\n Used | 'addParams'\n >;\n });\n\nexport type ForPaths<\n Resources extends ReadonlyArray<ResourceDefinition>,\n Config,\n AllowedPath extends string,\n> = <const Paths extends readonly [AllowedPath, ...AllowedPath[]]>(\n ...paths: Paths\n) => TargetPathBuilder<Resources, Config, Paths>;\n\nconst DEFAULT_DISPLAY_NAME = 'ResourcePathComponent';\n\ntype BuilderState = {\n paths: readonly string[];\n paramDefaults: Record<string, unknown>;\n declaredPathParams: readonly string[];\n componentKeyDeclared: boolean;\n componentKeyOptional: boolean;\n usedComponentKeyParams: boolean;\n usedPathParams: boolean;\n usedParams: boolean;\n};\n\ntype ValidationSets = {\n resources: readonly string[];\n subResources: readonly string[];\n components: readonly string[];\n};\n\nfunction collectValidationSets(\n config: Record<string, unknown>,\n paths: readonly string[],\n): ValidationSets {\n const resources = new Set<string>();\n const subResources = new Set<string>();\n const components = new Set<string>();\n\n for (const path of paths) {\n for (const resource of collectPathResources(config, path)) {\n resources.add(resource);\n }\n\n for (const subResource of collectPathSubResourceKeys(config, path)) {\n subResources.add(subResource);\n }\n\n for (const component of collectPathComponentKeys(config, path)) {\n components.add(component);\n }\n }\n\n return {\n resources: [...resources],\n subResources: [...subResources],\n components: [...components],\n };\n}\n\n/**\n * Validates the params a caller passed before the renderer runs, so a bad resource or\n * slot fails with a typed error naming what is available.\n */\nfunction validateParams(\n params: Record<string, unknown>,\n state: BuilderState,\n sets: ValidationSets,\n): void {\n const { resource, subResource, component, componentKey } = params as {\n resource?: unknown;\n subResource?: unknown;\n component?: unknown;\n componentKey?: unknown;\n };\n\n if (state.declaredPathParams.includes('resource') && resource !== undefined) {\n if (typeof resource !== 'string' || !sets.resources.includes(resource)) {\n throw new InvalidResourceError({\n resource,\n validResources: [...sets.resources],\n });\n }\n }\n\n if (\n state.declaredPathParams.includes('subResource') &&\n subResource !== undefined\n ) {\n const slugs = flattenSubResourceParam(subResource as SubResourceParamValue);\n\n for (const slug of slugs) {\n if (!sets.subResources.includes(slug)) {\n throw new InvalidSubResourceError({\n subResource: slug,\n resource: typeof resource === 'string' ? resource : undefined,\n validSubResources: [...sets.subResources],\n });\n }\n }\n }\n\n if (\n state.declaredPathParams.includes('component') &&\n component !== undefined\n ) {\n if (typeof component !== 'string' || !sets.components.includes(component)) {\n throw new InvalidComponentError({\n component,\n validComponents: [...sets.components],\n });\n }\n }\n\n if (!state.componentKeyDeclared) {\n return;\n }\n\n if (componentKey === undefined) {\n if (!state.componentKeyOptional) {\n throw new InvalidComponentError({\n component: componentKey,\n validComponents: [...sets.components],\n reason: 'A \"componentKey\" prop is required for this component',\n });\n }\n\n return;\n }\n\n if (\n typeof componentKey !== 'string' ||\n !sets.components.includes(componentKey)\n ) {\n throw new InvalidComponentError({\n component: componentKey,\n validComponents: [...sets.components],\n });\n }\n}\n\nfunction readClosureProps(\n selected: string[],\n closure: unknown,\n): Record<string, unknown> {\n if (selected.length === 0) {\n return {};\n }\n\n const [only] = selected;\n\n if (selected.length === 1 && only !== undefined) {\n return { [only]: closure };\n }\n\n if (\n typeof closure === 'object' &&\n closure !== null &&\n !Array.isArray(closure)\n ) {\n return { ...(closure as Record<string, unknown>) };\n }\n\n return {};\n}\n\nfunction createRenderedComponent(\n runRenderer: (props: Record<string, unknown>) => JSX.Element,\n paramTemplate: Record<string, unknown> | undefined,\n resolveDisplayName?: (props: Record<string, unknown>) => string,\n boundProps: Record<string, unknown> = {},\n) {\n function RenderedPathView(props: Record<string, unknown>): JSX.Element {\n const merged = { ...boundProps, ...props };\n\n if (resolveDisplayName) {\n RenderedPathView.displayName = resolveDisplayName(merged);\n }\n\n return runRenderer(merged);\n }\n\n RenderedPathView.displayName = DEFAULT_DISPLAY_NAME;\n\n function asHOF(options?: { args?: Record<string, true> }) {\n const selected = Object.entries(options?.args ?? {})\n .filter(([, enabled]) => enabled === true)\n .map(([key]) => key);\n\n function hof(closure: unknown) {\n const bound = createRenderedComponent(\n runRenderer,\n undefined,\n resolveDisplayName,\n { ...boundProps, ...readClosureProps(selected, closure) },\n );\n\n bound.displayName = RenderedPathView.displayName;\n\n return bound;\n }\n\n return Object.assign(hof, { _args: undefined as never });\n }\n\n return Object.assign(RenderedPathView, {\n _args: paramTemplate as never,\n asHOF,\n });\n}\n\nexport function createTargetPathBuilder<\n Resources extends ReadonlyArray<ResourceDefinition>,\n Config extends Record<string, unknown>,\n Paths extends ReadonlyArray<string>,\n>(config: Config, paths: Paths): TargetPathBuilder<Resources, Config, Paths> {\n const validationSets = collectValidationSets(config, paths);\n\n const makeBuilder = (state: BuilderState): Record<string, unknown> => {\n const builder: Record<string, unknown> = {};\n\n if (!state.usedComponentKeyParams) {\n builder.addComponentKeyParams = (options?: { optional?: boolean }) =>\n makeBuilder({\n ...state,\n usedComponentKeyParams: true,\n componentKeyDeclared: true,\n componentKeyOptional: options?.optional === true,\n });\n }\n\n if (!state.usedPathParams) {\n builder.addPathParams = (options?: { pick?: Record<string, true> }) => {\n const available = new Set<string>();\n\n for (const path of state.paths) {\n for (const name of extractPathVariables(path)) {\n available.add(name);\n }\n }\n\n const picked = Object.entries(options?.pick ?? {})\n .filter(([, enabled]) => enabled === true)\n .map(([key]) => key);\n const declared =\n picked.length === 0\n ? [...available]\n : picked.filter((name) => available.has(name));\n\n return makeBuilder({\n ...state,\n usedPathParams: true,\n declaredPathParams: [...state.declaredPathParams, ...declared],\n });\n };\n }\n\n if (!state.usedParams) {\n builder.addParams = (params: Record<string, unknown>) =>\n makeBuilder({\n ...state,\n usedParams: true,\n paramDefaults: { ...state.paramDefaults, ...params },\n });\n }\n\n builder.render = (\n renderer: (context: {\n params: Record<string, unknown>;\n getComponentForPath: unknown;\n }) => JSX.Element,\n ) => {\n const buildContext = (props: Record<string, unknown>) => {\n const params = { ...state.paramDefaults, ...props };\n\n validateParams(params, state, validationSets);\n\n return {\n children: props.children as ReactNode,\n params,\n getComponentForPath: (path: string) => {\n if (!state.paths.includes(path)) {\n throw new InvalidPathError({\n path,\n validPaths: [...state.paths],\n reason: 'This component was not built for that path',\n });\n }\n\n return createGetComponentForPath(config, path);\n },\n };\n };\n\n const runRenderer = (props: Record<string, unknown>) =>\n renderer(buildContext(props));\n\n const component = createRenderedComponent(runRenderer, {\n ...state.paramDefaults,\n });\n\n return Object.assign(component, {\n setDisplayName: (\n name:\n | string\n | ((context: {\n params: Record<string, unknown>;\n getComponentForPath: unknown;\n }) => string),\n ) => {\n if (typeof name === 'string') {\n const named = createRenderedComponent(runRenderer, {\n ...state.paramDefaults,\n });\n\n named.displayName = name;\n\n return named;\n }\n\n return createRenderedComponent(\n runRenderer,\n { ...state.paramDefaults },\n (props) => name(buildContext(props)),\n );\n },\n });\n };\n\n return builder;\n };\n\n return makeBuilder({\n paths,\n paramDefaults: {},\n declaredPathParams: [],\n componentKeyDeclared: false,\n componentKeyOptional: false,\n usedComponentKeyParams: false,\n usedPathParams: false,\n usedParams: false,\n }) as unknown as TargetPathBuilder<Resources, Config, Paths>;\n}\n\nexport function createForPaths<\n Resources extends ReadonlyArray<ResourceDefinition>,\n Config extends Record<string, unknown>,\n>(config: Config): ForPaths<Resources, Config, string> {\n const validPaths = generateResourceConfigPaths(config);\n\n return ((...paths: string[]) => {\n if (paths.length === 0) {\n throw new InvalidPathError({\n path: paths,\n validPaths,\n reason: 'At least one path is required',\n });\n }\n\n for (const path of paths) {\n if (!validPaths.includes(path)) {\n throw new InvalidPathError({ path, validPaths });\n }\n }\n\n return createTargetPathBuilder(config, paths);\n }) as unknown as ForPaths<Resources, Config, string>;\n}\n"],"mappings":";;;;;;;;;;;AAiOA,MAAM,uBAAuB;AAmB7B,SAAS,sBACP,QACA,OACgB;CAChB,MAAM,4BAAY,IAAI,IAAY;CAClC,MAAM,+BAAe,IAAI,IAAY;CACrC,MAAM,6BAAa,IAAI,IAAY;CAEnC,KAAK,MAAM,QAAQ,OAAO;EACxB,KAAK,MAAM,YAAYA,wCAAqB,QAAQ,IAAI,GACtD,UAAU,IAAI,QAAQ;EAGxB,KAAK,MAAM,eAAeC,8CAA2B,QAAQ,IAAI,GAC/D,aAAa,IAAI,WAAW;E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,CAAC;GAED,OAAO,OAAO,OAAO,WAAW,EAC9B,iBACE,SAMG;IACH,IAAI,OAAO,SAAS,UAAU;KAC5B,MAAM,QAAQ,wBAAwB,aAAa,EACjD,GAAG,MAAM,cACX,CAAC;KAED,MAAM,cAAc;KAEpB,OAAO;IACT;IAEA,OAAO,wBACL,aACA,EAAE,GAAG,MAAM,cAAc,IACxB,UAAU,KAAK,aAAa,KAAK,CAAC,CACrC;GACF,EACF,CAAC;EACH;EAEA,OAAO;CACT;CAEA,OAAO,YAAY;EACjB;EACA,eAAe,CAAC;EAChB,oBAAoB,CAAC;EACrB,sBAAsB;EACtB,sBAAsB;EACtB,wBAAwB;EACxB,gBAAgB;EAChB,YAAY;CACd,CAAC;AACH;AAEA,SAAgB,eAGd,QAAqD;CACrD,MAAM,aAAaC,6CAA4B,MAAM;CAErD,SAAS,GAAG,UAAoB;EAC9B,IAAI,MAAM,WAAW,GACnB,MAAM,IAAIF,sCAAiB;GACzB,MAAM;GACN;GACA,QAAQ;EACV,CAAC;EAGH,KAAK,MAAM,QAAQ,OACjB,IAAI,CAAC,WAAW,SAAS,IAAI,GAC3B,MAAM,IAAIA,sCAAiB;GAAE;GAAM;EAAW,CAAC;EAInD,OAAO,wBAAwB,QAAQ,KAAK;CAC9C;AACF"}
@@ -2,7 +2,8 @@ import { IsUnion, Show } from "../../utils.cjs";
2
2
  import { ResourceDefinition } from "../../resource.cjs";
3
3
  import { PathComponentKeys, PathVariables } from "../paths/types.cjs";
4
4
  import { CreateGetComponentForPath } from "./get-component-for-path.cjs";
5
- import { JSX } from "react";
5
+ import { WithChildren } from "@jfdevelops/react-layout-composables";
6
+ import { JSX, ReactNode } from "react";
6
7
 
7
8
  //#region src/create-config/for-paths/builder.d.ts
8
9
  type UnwrapTargetPaths<Paths> = Paths extends readonly [infer First, ...infer Rest] ? (First & string) | UnwrapTargetPaths<Rest> : Paths extends readonly (infer Path)[] ? Path & string : never;
@@ -11,7 +12,8 @@ type ComponentKeysForPaths<Resources extends ReadonlyArray<ResourceDefinition>,
11
12
  type ValueOrFunction<Value, Input> = Value | ((input: Input) => Value);
12
13
  /** Context handed to `render` and to `setDisplayName`. */
13
14
  type ForPathsRenderContext<Resources extends ReadonlyArray<ResourceDefinition>, Config, Paths extends ReadonlyArray<string>, Params> = {
14
- /** Declared params merged with the props the component was called with. */params: Params; /** Creates a getter for any of the paths this component was built for. */
15
+ children?: ReactNode; /** Declared params merged with the props the component was called with. */
16
+ params: Params; /** Creates a getter for any of the paths this component was built for. */
15
17
  getComponentForPath: CreateGetComponentForPath<Resources, Config, UnwrapTargetPaths<Paths>>;
16
18
  };
17
19
  type HOFArgSelection<Params> = { [Key in keyof Params]?: true };
@@ -26,7 +28,7 @@ interface RenderedPathComponentHOF<Params, Args> {
26
28
  _args: HOFClosureValue<Params, Args>;
27
29
  }
28
30
  interface RenderedPathComponent<Params, DisplayName extends string = string> {
29
- (props: Params): JSX.Element;
31
+ (props: WithChildren<Params>): JSX.Element;
30
32
  displayName: DisplayName;
31
33
  /** Type-only view of the props this component accepts. */
32
34
  _args: Params;
@@ -1 +1 @@
1
- {"version":3,"file":"builder.d.cts","names":[],"sources":["../../../src/create-config/for-paths/builder.ts"],"mappings":";;;;;;;KA2BK,iBAAA,UAA2B,KAAA,kDAI3B,KAAA,aAAkB,iBAAA,CAAkB,IAAA,IACrC,KAAA,mCACE,IAAA;AAAA,KAGD,qBAAA,mBACe,aAAA,CAAc,kBAAA,yBAElB,aAAA,YAEd,iBAAA,CAAkB,KAAA,uBACd,IAAA,kBACE,aAAA,CAAc,SAAA,EAAW,MAAA,EAAQ,IAAA;AAAA,KAIpC,qBAAA,mBACe,aAAA,CAAc,kBAAA,yBAElB,aAAA,YAEd,iBAAA,CAAkB,KAAA,uBACd,IAAA,kBACE,iBAAA,CAAkB,SAAA,EAAW,MAAA,EAAQ,IAAA;AAAA,KAIxC,eAAA,iBAAgC,KAAA,KAAU,KAAA,EAAO,KAAA,KAAU,KAAA;;KAGpD,qBAAA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,IAAA,GAAO,MAAA;EAAA,IACL,iBAAA,CACF,SAAA,EACA,MAAA,EACA,KAAA,EACA,IAAA,CAAK,MAAA,GAAS,gBAAA,CAAiB,SAAA,EAAW,MAAA,IAC1C,IAAA;AAAA,0BAGa,IAAA;EApJrB;;;;EA2JM,SAAA,mBAA4B,MAAA,mBAC1B,MAAA,EAAQ,SAAA,GACP,iBAAA,CACD,SAAA,EACA,MAAA,EACA,KAAA,EACA,IAAA,CAAK,MAAA,GAAS,OAAA,CAAQ,SAAA,IACtB,IAAA;AAAA;AAAA,KAIE,QAAA,mBACQ,aAAA,CAAc,kBAAA,wEAGC,WAAA,KAAgB,WAAA,QAC9C,KAAA,EAAO,KAAA,KACP,iBAAA,CAAkB,SAAA,EAAW,MAAA,EAAQ,KAAA"}
@@ -2,7 +2,8 @@ import { IsUnion, Show } from "../../utils.mjs";
2
2
  import { ResourceDefinition } from "../../resource.mjs";
3
3
  import { PathComponentKeys, PathVariables } from "../paths/types.mjs";
4
4
  import { CreateGetComponentForPath } from "./get-component-for-path.mjs";
5
- import { JSX } from "react";
5
+ import { WithChildren } from "@jfdevelops/react-layout-composables";
6
+ import { JSX, ReactNode } from "react";
6
7
 
7
8
  //#region src/create-config/for-paths/builder.d.ts
8
9
  type UnwrapTargetPaths<Paths> = Paths extends readonly [infer First, ...infer Rest] ? (First & string) | UnwrapTargetPaths<Rest> : Paths extends readonly (infer Path)[] ? Path & string : never;
@@ -11,7 +12,8 @@ type ComponentKeysForPaths<Resources extends ReadonlyArray<ResourceDefinition>,
11
12
  type ValueOrFunction<Value, Input> = Value | ((input: Input) => Value);
12
13
  /** Context handed to `render` and to `setDisplayName`. */
13
14
  type ForPathsRenderContext<Resources extends ReadonlyArray<ResourceDefinition>, Config, Paths extends ReadonlyArray<string>, Params> = {
14
- /** Declared params merged with the props the component was called with. */params: Params; /** Creates a getter for any of the paths this component was built for. */
15
+ children?: ReactNode; /** Declared params merged with the props the component was called with. */
16
+ params: Params; /** Creates a getter for any of the paths this component was built for. */
15
17
  getComponentForPath: CreateGetComponentForPath<Resources, Config, UnwrapTargetPaths<Paths>>;
16
18
  };
17
19
  type HOFArgSelection<Params> = { [Key in keyof Params]?: true };
@@ -26,7 +28,7 @@ interface RenderedPathComponentHOF<Params, Args> {
26
28
  _args: HOFClosureValue<Params, Args>;
27
29
  }
28
30
  interface RenderedPathComponent<Params, DisplayName extends string = string> {
29
- (props: Params): JSX.Element;
31
+ (props: WithChildren<Params>): JSX.Element;
30
32
  displayName: DisplayName;
31
33
  /** Type-only view of the props this component accepts. */
32
34
  _args: Params;
@@ -1 +1 @@
1
- {"version":3,"file":"builder.d.mts","names":[],"sources":["../../../src/create-config/for-paths/builder.ts"],"mappings":";;;;;;;KA2BK,iBAAA,UAA2B,KAAA,kDAI3B,KAAA,aAAkB,iBAAA,CAAkB,IAAA,IACrC,KAAA,mCACE,IAAA;AAAA,KAGD,qBAAA,mBACe,aAAA,CAAc,kBAAA,yBAElB,aAAA,YAEd,iBAAA,CAAkB,KAAA,uBACd,IAAA,kBACE,aAAA,CAAc,SAAA,EAAW,MAAA,EAAQ,IAAA;AAAA,KAIpC,qBAAA,mBACe,aAAA,CAAc,kBAAA,yBAElB,aAAA,YAEd,iBAAA,CAAkB,KAAA,uBACd,IAAA,kBACE,iBAAA,CAAkB,SAAA,EAAW,MAAA,EAAQ,IAAA;AAAA,KAIxC,eAAA,iBAAgC,KAAA,KAAU,KAAA,EAAO,KAAA,KAAU,KAAA;;KAGpD,qBAAA,mBACQ,aAAA,CAAc,kBAAA,yBAElB,aAAA;EAjCO,2EAqCrB,MAAA,EAAQ,MAAA,EAnCJ;EAqCJ,mBAAA,EAAqB,yBAAA,CACnB,SAAA,EACA,MAAA,EACA,iBAAA,CAAkB,KAAA;AAAA;AAAA,KAIjB,eAAA,2BACW,MAAM;;;;;KAOjB,eAAA,wBAAuC,IAAA,yBAExC,OAAA,OAAc,IAAA,kBACZ,MAAA,OAAa,IAAA,SAAa,MAAA,IAC1B,IA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AAA,CAAQ,SAAA,IACtB,IAAA;AAAA;AAAA,KAIE,QAAA,mBACQ,aAAA,CAAc,kBAAA,wEAGC,WAAA,KAAgB,WAAA,QAC9C,KAAA,EAAO,KAAA,KACP,iBAAA,CAAkB,SAAA,EAAW,MAAA,EAAQ,KAAA"}
@@ -136,6 +136,7 @@ function createTargetPathBuilder(config, paths) {
136
136
  };
137
137
  validateParams(params, state, validationSets);
138
138
  return {
139
+ children: props.children,
139
140
  params,
140
141
  getComponentForPath: (path) => {
141
142
  if (!state.paths.includes(path)) throw new InvalidPathError({
@@ -1 +1 @@
1
- {"version":3,"file":"builder.mjs","names":[],"sources":["../../../src/create-config/for-paths/builder.ts"],"sourcesContent":["import type { JSX } from 'react';\nimport {\n InvalidComponentError,\n InvalidPathError,\n InvalidResourceError,\n InvalidSubResourceError,\n} from '../../errors';\nimport type { ResourceDefinition } from '../../resource';\nimport type { IsUnion, Show } from '../../utils';\nimport {\n collectPathComponentKeys,\n collectPathResources,\n collectPathSubResourceKeys,\n extractPathVariables,\n flattenSubResourceParam,\n generateResourceConfigPaths,\n} from '../paths';\nimport type {\n PathComponentKeys,\n PathVariables,\n SubResourceParamValue,\n} from '../paths';\nimport {\n createGetComponentForPath,\n type CreateGetComponentForPath,\n} from './get-component-for-path';\n\ntype UnwrapTargetPaths<Paths> = Paths extends readonly [\n infer First,\n ...infer Rest,\n]\n ? (First & string) | UnwrapTargetPaths<Rest>\n : Paths extends readonly (infer Path)[]\n ? Path & string\n : never;\n\ntype PathVariablesForPaths<\n Resources extends ReadonlyArray<ResourceDefinition>,\n Config,\n Paths extends ReadonlyArray<string>,\n> =\n UnwrapTargetPaths<Paths> extends infer Path\n ? Path extends string\n ? PathVariables<Resources, Config, Path>\n : never\n : never;\n\ntype ComponentKeysForPaths<\n Resources extends ReadonlyArray<ResourceDefinition>,\n Config,\n Paths extends ReadonlyArray<string>,\n> =\n UnwrapTargetPaths<Paths> extends infer Path\n ? Path extends string\n ? PathComponentKeys<Resources, Config, Path>\n : never\n : never;\n\ntype ValueOrFunction<Value, Input> = Value | ((input: Input) => Value);\n\n/** Context handed to `render` and to `setDisplayName`. */\nexport type ForPathsRenderContext<\n Resources extends ReadonlyArray<ResourceDefinition>,\n Config,\n Paths extends ReadonlyArray<string>,\n Params,\n> = {\n /** Declared params merged with the props the component was called with. */\n params: Params;\n /** Creates a getter for any of the paths this component was built for. */\n getComponentForPath: CreateGetComponentForPath<\n Resources,\n Config,\n UnwrapTargetPaths<Paths>\n >;\n};\n\ntype HOFArgSelection<Params> = {\n [Key in keyof Params]?: true;\n};\n\n/**\n * Value closed over by `asHOF`. Selecting a single arg closes over that value directly;\n * selecting several closes over an object.\n */\ntype HOFClosureValue<Params, Args> = [keyof Args] extends [never]\n ? {}\n : IsUnion<keyof Args> extends false\n ? Params[keyof Args & keyof Params]\n : Show<Pick<Params, keyof Args & keyof Params>>;\n\nexport interface RenderedPathComponentHOF<Params, Args> {\n (closure: HOFClosureValue<Params, Args>): RenderedPathComponent<\n Show<Omit<Params, keyof Args>>\n >;\n /** Type-only view of the value this HOF closes over. At runtime this is `undefined`. */\n _args: HOFClosureValue<Params, Args>;\n}\n\nexport interface RenderedPathComponent<\n Params,\n DisplayName extends string = string,\n> {\n (props: Params): JSX.Element;\n displayName: DisplayName;\n /** Type-only view of the props this component accepts. */\n _args: Params;\n /**\n * Splits the props into a closure and the remaining props, so shared params can be\n * bound once and the component reused. Chained `asHOF` calls keep prior closures.\n */\n asHOF<Args extends HOFArgSelection<Params> = {}>(options?: {\n /** Params to close over. Anything omitted stays a prop. */\n args: Args;\n }): RenderedPathComponentHOF<Params, Args>;\n}\n\ntype WithComponentKeyParam<\n Resources extends ReadonlyArray<ResourceDefinition>,\n Config,\n Paths extends ReadonlyArray<string>,\n Optional extends boolean,\n> = Optional extends true\n ? { componentKey?: ComponentKeysForPaths<Resources, Config, Paths> }\n : { componentKey: ComponentKeysForPaths<Resources, Config, Paths> };\n\ntype PickedPathParams<\n Variables,\n Picked,\n> = [keyof Picked] extends [never]\n ? Variables\n : Pick<Variables, keyof Picked & keyof Variables>;\n\nexport type TargetPathBuilder<\n Resources extends ReadonlyArray<ResourceDefinition>,\n Config,\n Paths extends ReadonlyArray<string>,\n Params extends Record<string, unknown> = {},\n Used extends\n | 'addComponentKeyParams'\n | 'addPathParams'\n | 'addParams' = never,\n> = {\n render: (\n renderer: (\n context: ForPathsRenderContext<Resources, Config, Paths, Params>,\n ) => JSX.Element,\n ) => RenderedPathComponent<Params> & {\n /** Names the component, either statically or from the render context. */\n setDisplayName<Name extends string>(\n name: ValueOrFunction<\n Name,\n ForPathsRenderContext<Resources, Config, Paths, Params>\n >,\n ): RenderedPathComponent<Params, Name>;\n };\n} & ('addComponentKeyParams' extends Used\n ? {}\n : {\n /**\n * Adds a `componentKey` prop narrowed to the component slots configured for these\n * paths. Call it before `render` when building a reusable component.\n */\n addComponentKeyParams<Optional extends boolean = false>(options?: {\n /** Whether the caller may omit `componentKey`. */\n optional?: Optional;\n }): TargetPathBuilder<\n Resources,\n Config,\n Paths,\n Show<\n Params & WithComponentKeyParam<Resources, Config, Paths, Optional>\n >,\n Used | 'addComponentKeyParams'\n >;\n }) &\n ('addPathParams' extends Used\n ? {}\n : {\n /**\n * Turns the variables these paths leave open into props. Without `pick`, every\n * variable becomes a prop.\n */\n addPathParams<\n Variables extends PathVariablesForPaths<Resources, Config, Paths>,\n Picked extends { [Key in keyof Variables]?: true } = {},\n >(options?: {\n /** Variables to expose as props. Defaults to all of them. */\n pick?: Picked;\n }): TargetPathBuilder<\n Resources,\n Config,\n Paths,\n Show<Params & PickedPathParams<Variables, Picked>>,\n Used | 'addPathParams'\n >;\n }) &\n ('addParams' extends Used\n ? {}\n : {\n /**\n * Adds custom params with the given values as defaults. Defaults are\n * optional at the call site and filled in before `render` runs.\n */\n addParams<NewParams extends Record<string, unknown>>(\n params: NewParams,\n ): TargetPathBuilder<\n Resources,\n Config,\n Paths,\n Show<Params & Partial<NewParams>>,\n Used | 'addParams'\n >;\n });\n\nexport type ForPaths<\n Resources extends ReadonlyArray<ResourceDefinition>,\n Config,\n AllowedPath extends string,\n> = <const Paths extends readonly [AllowedPath, ...AllowedPath[]]>(\n ...paths: Paths\n) => TargetPathBuilder<Resources, Config, Paths>;\n\nconst DEFAULT_DISPLAY_NAME = 'ResourcePathComponent';\n\ntype BuilderState = {\n paths: readonly string[];\n paramDefaults: Record<string, unknown>;\n declaredPathParams: readonly string[];\n componentKeyDeclared: boolean;\n componentKeyOptional: boolean;\n usedComponentKeyParams: boolean;\n usedPathParams: boolean;\n usedParams: boolean;\n};\n\ntype ValidationSets = {\n resources: readonly string[];\n subResources: readonly string[];\n components: readonly string[];\n};\n\nfunction collectValidationSets(\n config: Record<string, unknown>,\n paths: readonly string[],\n): ValidationSets {\n const resources = new Set<string>();\n const subResources = new Set<string>();\n const components = new Set<string>();\n\n for (const path of paths) {\n for (const resource of collectPathResources(config, path)) {\n resources.add(resource);\n }\n\n for (const subResource of collectPathSubResourceKeys(config, path)) {\n subResources.add(subResource);\n }\n\n for (const component of collectPathComponentKeys(config, path)) {\n components.add(component);\n }\n }\n\n return {\n resources: [...resources],\n subResources: [...subResources],\n components: [...components],\n };\n}\n\n/**\n * Validates the params a caller passed before the renderer runs, so a bad resource or\n * slot fails with a typed error naming what is available.\n */\nfunction validateParams(\n params: Record<string, unknown>,\n state: BuilderState,\n sets: ValidationSets,\n): void {\n const { resource, subResource, component, componentKey } = params as {\n resource?: unknown;\n subResource?: unknown;\n component?: unknown;\n componentKey?: unknown;\n };\n\n if (state.declaredPathParams.includes('resource') && resource !== undefined) {\n if (typeof resource !== 'string' || !sets.resources.includes(resource)) {\n throw new InvalidResourceError({\n resource,\n validResources: [...sets.resources],\n });\n }\n }\n\n if (\n state.declaredPathParams.includes('subResource') &&\n subResource !== undefined\n ) {\n const slugs = flattenSubResourceParam(subResource as SubResourceParamValue);\n\n for (const slug of slugs) {\n if (!sets.subResources.includes(slug)) {\n throw new InvalidSubResourceError({\n subResource: slug,\n resource: typeof resource === 'string' ? resource : undefined,\n validSubResources: [...sets.subResources],\n });\n }\n }\n }\n\n if (\n state.declaredPathParams.includes('component') &&\n component !== undefined\n ) {\n if (typeof component !== 'string' || !sets.components.includes(component)) {\n throw new InvalidComponentError({\n component,\n validComponents: [...sets.components],\n });\n }\n }\n\n if (!state.componentKeyDeclared) {\n return;\n }\n\n if (componentKey === undefined) {\n if (!state.componentKeyOptional) {\n throw new InvalidComponentError({\n component: componentKey,\n validComponents: [...sets.components],\n reason: 'A \"componentKey\" prop is required for this component',\n });\n }\n\n return;\n }\n\n if (\n typeof componentKey !== 'string' ||\n !sets.components.includes(componentKey)\n ) {\n throw new InvalidComponentError({\n component: componentKey,\n validComponents: [...sets.components],\n });\n }\n}\n\nfunction readClosureProps(\n selected: string[],\n closure: unknown,\n): Record<string, unknown> {\n if (selected.length === 0) {\n return {};\n }\n\n const [only] = selected;\n\n if (selected.length === 1 && only !== undefined) {\n return { [only]: closure };\n }\n\n if (\n typeof closure === 'object' &&\n closure !== null &&\n !Array.isArray(closure)\n ) {\n return { ...(closure as Record<string, unknown>) };\n }\n\n return {};\n}\n\nfunction createRenderedComponent(\n runRenderer: (props: Record<string, unknown>) => JSX.Element,\n paramTemplate: Record<string, unknown> | undefined,\n resolveDisplayName?: (props: Record<string, unknown>) => string,\n boundProps: Record<string, unknown> = {},\n) {\n function RenderedPathView(props: Record<string, unknown>): JSX.Element {\n const merged = { ...boundProps, ...props };\n\n if (resolveDisplayName) {\n RenderedPathView.displayName = resolveDisplayName(merged);\n }\n\n return runRenderer(merged);\n }\n\n RenderedPathView.displayName = DEFAULT_DISPLAY_NAME;\n\n function asHOF(options?: { args?: Record<string, true> }) {\n const selected = Object.entries(options?.args ?? {})\n .filter(([, enabled]) => enabled === true)\n .map(([key]) => key);\n\n function hof(closure: unknown) {\n const bound = createRenderedComponent(\n runRenderer,\n undefined,\n resolveDisplayName,\n { ...boundProps, ...readClosureProps(selected, closure) },\n );\n\n bound.displayName = RenderedPathView.displayName;\n\n return bound;\n }\n\n return Object.assign(hof, { _args: undefined as never });\n }\n\n return Object.assign(RenderedPathView, {\n _args: paramTemplate as never,\n asHOF,\n });\n}\n\nexport function createTargetPathBuilder<\n Resources extends ReadonlyArray<ResourceDefinition>,\n Config extends Record<string, unknown>,\n Paths extends ReadonlyArray<string>,\n>(config: Config, paths: Paths): TargetPathBuilder<Resources, Config, Paths> {\n const validationSets = collectValidationSets(config, paths);\n\n const makeBuilder = (state: BuilderState): Record<string, unknown> => {\n const builder: Record<string, unknown> = {};\n\n if (!state.usedComponentKeyParams) {\n builder.addComponentKeyParams = (options?: { optional?: boolean }) =>\n makeBuilder({\n ...state,\n usedComponentKeyParams: true,\n componentKeyDeclared: true,\n componentKeyOptional: options?.optional === true,\n });\n }\n\n if (!state.usedPathParams) {\n builder.addPathParams = (options?: { pick?: Record<string, true> }) => {\n const available = new Set<string>();\n\n for (const path of state.paths) {\n for (const name of extractPathVariables(path)) {\n available.add(name);\n }\n }\n\n const picked = Object.entries(options?.pick ?? {})\n .filter(([, enabled]) => enabled === true)\n .map(([key]) => key);\n const declared =\n picked.length === 0\n ? [...available]\n : picked.filter((name) => available.has(name));\n\n return makeBuilder({\n ...state,\n usedPathParams: true,\n declaredPathParams: [...state.declaredPathParams, ...declared],\n });\n };\n }\n\n if (!state.usedParams) {\n builder.addParams = (params: Record<string, unknown>) =>\n makeBuilder({\n ...state,\n usedParams: true,\n paramDefaults: { ...state.paramDefaults, ...params },\n });\n }\n\n builder.render = (\n renderer: (context: {\n params: Record<string, unknown>;\n getComponentForPath: unknown;\n }) => JSX.Element,\n ) => {\n const buildContext = (props: Record<string, unknown>) => {\n const params = { ...state.paramDefaults, ...props };\n\n validateParams(params, state, validationSets);\n\n return {\n params,\n getComponentForPath: (path: string) => {\n if (!state.paths.includes(path)) {\n throw new InvalidPathError({\n path,\n validPaths: [...state.paths],\n reason: 'This component was not built for that path',\n });\n }\n\n return createGetComponentForPath(config, path);\n },\n };\n };\n\n const runRenderer = (props: Record<string, unknown>) =>\n renderer(buildContext(props));\n\n const component = createRenderedComponent(runRenderer, {\n ...state.paramDefaults,\n });\n\n return Object.assign(component, {\n setDisplayName: (\n name:\n | string\n | ((context: {\n params: Record<string, unknown>;\n getComponentForPath: unknown;\n }) => string),\n ) => {\n if (typeof name === 'string') {\n const named = createRenderedComponent(runRenderer, {\n ...state.paramDefaults,\n });\n\n named.displayName = name;\n\n return named;\n }\n\n return createRenderedComponent(\n runRenderer,\n { ...state.paramDefaults },\n (props) => name(buildContext(props)),\n );\n },\n });\n };\n\n return builder;\n };\n\n return makeBuilder({\n paths,\n paramDefaults: {},\n declaredPathParams: [],\n componentKeyDeclared: false,\n componentKeyOptional: false,\n usedComponentKeyParams: false,\n usedPathParams: false,\n usedParams: false,\n }) as unknown as TargetPathBuilder<Resources, Config, Paths>;\n}\n\nexport function createForPaths<\n Resources extends ReadonlyArray<ResourceDefinition>,\n Config extends Record<string, unknown>,\n>(config: Config): ForPaths<Resources, Config, string> {\n const validPaths = generateResourceConfigPaths(config);\n\n return ((...paths: string[]) => {\n if (paths.length === 0) {\n throw new InvalidPathError({\n path: paths,\n validPaths,\n reason: 'At least one path is required',\n });\n }\n\n for (const path of paths) {\n if (!validPaths.includes(path)) {\n throw new InvalidPathError({ path, validPaths });\n }\n }\n\n return createTargetPathBuilder(config, paths);\n }) as unknown as ForPaths<Resources, Config, string>;\n}\n"],"mappings":";;;;;;;;;;;AA+NA,MAAM,uBAAuB;AAmB7B,SAAS,sBACP,QACA,OACgB;CAChB,MAAM,4BAAY,IAAI,IAAY;CAClC,MAAM,+BAAe,IAAI,IAAY;CACrC,MAAM,6BAAa,IAAI,IAAY;CAEnC,KAAK,MAAM,QAAQ,OAAO;EACxB,KAAK,MAAM,YAAY,qBAAqB,QAAQ,IAAI,GACtD,UAAU,IAAI,QAAQ;EAGxB,KAAK,MAAM,eAAe,2BAA2B,QAAQ,IAAI,GAC/D,aAAa,IAAI,WAAW;EAG9B,KA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EAC9B,iBACE,SAMG;IACH,IAAI,OAAO,SAAS,UAAU;KAC5B,MAAM,QAAQ,wBAAwB,aAAa,EACjD,GAAG,MAAM,cACX,CAAC;KAED,MAAM,cAAc;KAEpB,OAAO;IACT;IAEA,OAAO,wBACL,aACA,EAAE,GAAG,MAAM,cAAc,IACxB,UAAU,KAAK,aAAa,KAAK,CAAC,CACrC;GACF,EACF,CAAC;EACH;EAEA,OAAO;CACT;CAEA,OAAO,YAAY;EACjB;EACA,eAAe,CAAC;EAChB,oBAAoB,CAAC;EACrB,sBAAsB;EACtB,sBAAsB;EACtB,wBAAwB;EACxB,gBAAgB;EAChB,YAAY;CACd,CAAC;AACH;AAEA,SAAgB,eAGd,QAAqD;CACrD,MAAM,aAAa,4BAA4B,MAAM;CAErD,SAAS,GAAG,UAAoB;EAC9B,IAAI,MAAM,WAAW,GACnB,MAAM,IAAI,iBAAiB;GACzB,MAAM;GACN;GACA,QAAQ;EACV,CAAC;EAGH,KAAK,MAAM,QAAQ,OACjB,IAAI,CAAC,WAAW,SAAS,IAAI,GAC3B,MAAM,IAAI,iBAAiB;GAAE;GAAM;EAAW,CAAC;EAInD,OAAO,wBAAwB,QAAQ,KAAK;CAC9C;AACF"}
1
+ {"version":3,"file":"builder.mjs","names":[],"sources":["../../../src/create-config/for-paths/builder.ts"],"sourcesContent":["import type { JSX, ReactNode } from 'react';\nimport type { WithChildren } from '@jfdevelops/react-layout-composables';\nimport {\n InvalidComponentError,\n InvalidPathError,\n InvalidResourceError,\n InvalidSubResourceError,\n} from '../../errors';\nimport type { ResourceDefinition } from '../../resource';\nimport type { IsUnion, Show } from '../../utils';\nimport {\n collectPathComponentKeys,\n collectPathResources,\n collectPathSubResourceKeys,\n extractPathVariables,\n flattenSubResourceParam,\n generateResourceConfigPaths,\n} from '../paths';\nimport type {\n PathComponentKeys,\n PathVariables,\n SubResourceParamValue,\n} from '../paths';\nimport {\n createGetComponentForPath,\n type CreateGetComponentForPath,\n} from './get-component-for-path';\n\ntype UnwrapTargetPaths<Paths> = Paths extends readonly [\n infer First,\n ...infer Rest,\n]\n ? (First & string) | UnwrapTargetPaths<Rest>\n : Paths extends readonly (infer Path)[]\n ? Path & string\n : never;\n\ntype PathVariablesForPaths<\n Resources extends ReadonlyArray<ResourceDefinition>,\n Config,\n Paths extends ReadonlyArray<string>,\n> =\n UnwrapTargetPaths<Paths> extends infer Path\n ? Path extends string\n ? PathVariables<Resources, Config, Path>\n : never\n : never;\n\ntype ComponentKeysForPaths<\n Resources extends ReadonlyArray<ResourceDefinition>,\n Config,\n Paths extends ReadonlyArray<string>,\n> =\n UnwrapTargetPaths<Paths> extends infer Path\n ? Path extends string\n ? PathComponentKeys<Resources, Config, Path>\n : never\n : never;\n\ntype ValueOrFunction<Value, Input> = Value | ((input: Input) => Value);\n\n/** Context handed to `render` and to `setDisplayName`. */\nexport type ForPathsRenderContext<\n Resources extends ReadonlyArray<ResourceDefinition>,\n Config,\n Paths extends ReadonlyArray<string>,\n Params,\n> = {\n children?: ReactNode;\n /** Declared params merged with the props the component was called with. */\n params: Params;\n /** Creates a getter for any of the paths this component was built for. */\n getComponentForPath: CreateGetComponentForPath<\n Resources,\n Config,\n UnwrapTargetPaths<Paths>\n >;\n};\n\ntype HOFArgSelection<Params> = {\n [Key in keyof Params]?: true;\n};\n\n/**\n * Value closed over by `asHOF`. Selecting a single arg closes over that value directly;\n * selecting several closes over an object.\n */\ntype HOFClosureValue<Params, Args> = [keyof Args] extends [never]\n ? {}\n : IsUnion<keyof Args> extends false\n ? Params[keyof Args & keyof Params]\n : Show<Pick<Params, keyof Args & keyof Params>>;\n\nexport interface RenderedPathComponentHOF<Params, Args> {\n (closure: HOFClosureValue<Params, Args>): RenderedPathComponent<\n Show<Omit<Params, keyof Args>>\n >;\n /** Type-only view of the value this HOF closes over. At runtime this is `undefined`. */\n _args: HOFClosureValue<Params, Args>;\n}\n\nexport interface RenderedPathComponent<\n Params,\n DisplayName extends string = string,\n> {\n (props: WithChildren<Params>): JSX.Element;\n displayName: DisplayName;\n /** Type-only view of the props this component accepts. */\n _args: Params;\n /**\n * Splits the props into a closure and the remaining props, so shared params can be\n * bound once and the component reused. Chained `asHOF` calls keep prior closures.\n */\n asHOF<Args extends HOFArgSelection<Params> = {}>(options?: {\n /** Params to close over. Anything omitted stays a prop. */\n args: Args;\n }): RenderedPathComponentHOF<Params, Args>;\n}\n\ntype WithComponentKeyParam<\n Resources extends ReadonlyArray<ResourceDefinition>,\n Config,\n Paths extends ReadonlyArray<string>,\n Optional extends boolean,\n> = Optional extends true\n ? { componentKey?: ComponentKeysForPaths<Resources, Config, Paths> }\n : { componentKey: ComponentKeysForPaths<Resources, Config, Paths> };\n\ntype PickedPathParams<\n Variables,\n Picked,\n> = [keyof Picked] extends [never]\n ? Variables\n : Pick<Variables, keyof Picked & keyof Variables>;\n\nexport type TargetPathBuilder<\n Resources extends ReadonlyArray<ResourceDefinition>,\n Config,\n Paths extends ReadonlyArray<string>,\n Params extends Record<string, unknown> = {},\n Used extends\n | 'addComponentKeyParams'\n | 'addPathParams'\n | 'addParams' = never,\n> = {\n render: (\n renderer: (\n context: ForPathsRenderContext<Resources, Config, Paths, Params>,\n ) => JSX.Element,\n ) => RenderedPathComponent<Params> & {\n /** Names the component, either statically or from the render context. */\n setDisplayName<Name extends string>(\n name: ValueOrFunction<\n Name,\n ForPathsRenderContext<Resources, Config, Paths, Params>\n >,\n ): RenderedPathComponent<Params, Name>;\n };\n} & ('addComponentKeyParams' extends Used\n ? {}\n : {\n /**\n * Adds a `componentKey` prop narrowed to the component slots configured for these\n * paths. Call it before `render` when building a reusable component.\n */\n addComponentKeyParams<Optional extends boolean = false>(options?: {\n /** Whether the caller may omit `componentKey`. */\n optional?: Optional;\n }): TargetPathBuilder<\n Resources,\n Config,\n Paths,\n Show<\n Params & WithComponentKeyParam<Resources, Config, Paths, Optional>\n >,\n Used | 'addComponentKeyParams'\n >;\n }) &\n ('addPathParams' extends Used\n ? {}\n : {\n /**\n * Turns the variables these paths leave open into props. Without `pick`, every\n * variable becomes a prop.\n */\n addPathParams<\n Variables extends PathVariablesForPaths<Resources, Config, Paths>,\n Picked extends { [Key in keyof Variables]?: true } = {},\n >(options?: {\n /** Variables to expose as props. Defaults to all of them. */\n pick?: Picked;\n }): TargetPathBuilder<\n Resources,\n Config,\n Paths,\n Show<Params & PickedPathParams<Variables, Picked>>,\n Used | 'addPathParams'\n >;\n }) &\n ('addParams' extends Used\n ? {}\n : {\n /**\n * Adds custom params with the given values as defaults. Defaults are\n * optional at the call site and filled in before `render` runs.\n */\n addParams<NewParams extends Record<string, unknown>>(\n params: NewParams,\n ): TargetPathBuilder<\n Resources,\n Config,\n Paths,\n Show<Params & Partial<NewParams>>,\n Used | 'addParams'\n >;\n });\n\nexport type ForPaths<\n Resources extends ReadonlyArray<ResourceDefinition>,\n Config,\n AllowedPath extends string,\n> = <const Paths extends readonly [AllowedPath, ...AllowedPath[]]>(\n ...paths: Paths\n) => TargetPathBuilder<Resources, Config, Paths>;\n\nconst DEFAULT_DISPLAY_NAME = 'ResourcePathComponent';\n\ntype BuilderState = {\n paths: readonly string[];\n paramDefaults: Record<string, unknown>;\n declaredPathParams: readonly string[];\n componentKeyDeclared: boolean;\n componentKeyOptional: boolean;\n usedComponentKeyParams: boolean;\n usedPathParams: boolean;\n usedParams: boolean;\n};\n\ntype ValidationSets = {\n resources: readonly string[];\n subResources: readonly string[];\n components: readonly string[];\n};\n\nfunction collectValidationSets(\n config: Record<string, unknown>,\n paths: readonly string[],\n): ValidationSets {\n const resources = new Set<string>();\n const subResources = new Set<string>();\n const components = new Set<string>();\n\n for (const path of paths) {\n for (const resource of collectPathResources(config, path)) {\n resources.add(resource);\n }\n\n for (const subResource of collectPathSubResourceKeys(config, path)) {\n subResources.add(subResource);\n }\n\n for (const component of collectPathComponentKeys(config, path)) {\n components.add(component);\n }\n }\n\n return {\n resources: [...resources],\n subResources: [...subResources],\n components: [...components],\n };\n}\n\n/**\n * Validates the params a caller passed before the renderer runs, so a bad resource or\n * slot fails with a typed error naming what is available.\n */\nfunction validateParams(\n params: Record<string, unknown>,\n state: BuilderState,\n sets: ValidationSets,\n): void {\n const { resource, subResource, component, componentKey } = params as {\n resource?: unknown;\n subResource?: unknown;\n component?: unknown;\n componentKey?: unknown;\n };\n\n if (state.declaredPathParams.includes('resource') && resource !== undefined) {\n if (typeof resource !== 'string' || !sets.resources.includes(resource)) {\n throw new InvalidResourceError({\n resource,\n validResources: [...sets.resources],\n });\n }\n }\n\n if (\n state.declaredPathParams.includes('subResource') &&\n subResource !== undefined\n ) {\n const slugs = flattenSubResourceParam(subResource as SubResourceParamValue);\n\n for (const slug of slugs) {\n if (!sets.subResources.includes(slug)) {\n throw new InvalidSubResourceError({\n subResource: slug,\n resource: typeof resource === 'string' ? resource : undefined,\n validSubResources: [...sets.subResources],\n });\n }\n }\n }\n\n if (\n state.declaredPathParams.includes('component') &&\n component !== undefined\n ) {\n if (typeof component !== 'string' || !sets.components.includes(component)) {\n throw new InvalidComponentError({\n component,\n validComponents: [...sets.components],\n });\n }\n }\n\n if (!state.componentKeyDeclared) {\n return;\n }\n\n if (componentKey === undefined) {\n if (!state.componentKeyOptional) {\n throw new InvalidComponentError({\n component: componentKey,\n validComponents: [...sets.components],\n reason: 'A \"componentKey\" prop is required for this component',\n });\n }\n\n return;\n }\n\n if (\n typeof componentKey !== 'string' ||\n !sets.components.includes(componentKey)\n ) {\n throw new InvalidComponentError({\n component: componentKey,\n validComponents: [...sets.components],\n });\n }\n}\n\nfunction readClosureProps(\n selected: string[],\n closure: unknown,\n): Record<string, unknown> {\n if (selected.length === 0) {\n return {};\n }\n\n const [only] = selected;\n\n if (selected.length === 1 && only !== undefined) {\n return { [only]: closure };\n }\n\n if (\n typeof closure === 'object' &&\n closure !== null &&\n !Array.isArray(closure)\n ) {\n return { ...(closure as Record<string, unknown>) };\n }\n\n return {};\n}\n\nfunction createRenderedComponent(\n runRenderer: (props: Record<string, unknown>) => JSX.Element,\n paramTemplate: Record<string, unknown> | undefined,\n resolveDisplayName?: (props: Record<string, unknown>) => string,\n boundProps: Record<string, unknown> = {},\n) {\n function RenderedPathView(props: Record<string, unknown>): JSX.Element {\n const merged = { ...boundProps, ...props };\n\n if (resolveDisplayName) {\n RenderedPathView.displayName = resolveDisplayName(merged);\n }\n\n return runRenderer(merged);\n }\n\n RenderedPathView.displayName = DEFAULT_DISPLAY_NAME;\n\n function asHOF(options?: { args?: Record<string, true> }) {\n const selected = Object.entries(options?.args ?? {})\n .filter(([, enabled]) => enabled === true)\n .map(([key]) => key);\n\n function hof(closure: unknown) {\n const bound = createRenderedComponent(\n runRenderer,\n undefined,\n resolveDisplayName,\n { ...boundProps, ...readClosureProps(selected, closure) },\n );\n\n bound.displayName = RenderedPathView.displayName;\n\n return bound;\n }\n\n return Object.assign(hof, { _args: undefined as never });\n }\n\n return Object.assign(RenderedPathView, {\n _args: paramTemplate as never,\n asHOF,\n });\n}\n\nexport function createTargetPathBuilder<\n Resources extends ReadonlyArray<ResourceDefinition>,\n Config extends Record<string, unknown>,\n Paths extends ReadonlyArray<string>,\n>(config: Config, paths: Paths): TargetPathBuilder<Resources, Config, Paths> {\n const validationSets = collectValidationSets(config, paths);\n\n const makeBuilder = (state: BuilderState): Record<string, unknown> => {\n const builder: Record<string, unknown> = {};\n\n if (!state.usedComponentKeyParams) {\n builder.addComponentKeyParams = (options?: { optional?: boolean }) =>\n makeBuilder({\n ...state,\n usedComponentKeyParams: true,\n componentKeyDeclared: true,\n componentKeyOptional: options?.optional === true,\n });\n }\n\n if (!state.usedPathParams) {\n builder.addPathParams = (options?: { pick?: Record<string, true> }) => {\n const available = new Set<string>();\n\n for (const path of state.paths) {\n for (const name of extractPathVariables(path)) {\n available.add(name);\n }\n }\n\n const picked = Object.entries(options?.pick ?? {})\n .filter(([, enabled]) => enabled === true)\n .map(([key]) => key);\n const declared =\n picked.length === 0\n ? [...available]\n : picked.filter((name) => available.has(name));\n\n return makeBuilder({\n ...state,\n usedPathParams: true,\n declaredPathParams: [...state.declaredPathParams, ...declared],\n });\n };\n }\n\n if (!state.usedParams) {\n builder.addParams = (params: Record<string, unknown>) =>\n makeBuilder({\n ...state,\n usedParams: true,\n paramDefaults: { ...state.paramDefaults, ...params },\n });\n }\n\n builder.render = (\n renderer: (context: {\n params: Record<string, unknown>;\n getComponentForPath: unknown;\n }) => JSX.Element,\n ) => {\n const buildContext = (props: Record<string, unknown>) => {\n const params = { ...state.paramDefaults, ...props };\n\n validateParams(params, state, validationSets);\n\n return {\n children: props.children as ReactNode,\n params,\n getComponentForPath: (path: string) => {\n if (!state.paths.includes(path)) {\n throw new InvalidPathError({\n path,\n validPaths: [...state.paths],\n reason: 'This component was not built for that path',\n });\n }\n\n return createGetComponentForPath(config, path);\n },\n };\n };\n\n const runRenderer = (props: Record<string, unknown>) =>\n renderer(buildContext(props));\n\n const component = createRenderedComponent(runRenderer, {\n ...state.paramDefaults,\n });\n\n return Object.assign(component, {\n setDisplayName: (\n name:\n | string\n | ((context: {\n params: Record<string, unknown>;\n getComponentForPath: unknown;\n }) => string),\n ) => {\n if (typeof name === 'string') {\n const named = createRenderedComponent(runRenderer, {\n ...state.paramDefaults,\n });\n\n named.displayName = name;\n\n return named;\n }\n\n return createRenderedComponent(\n runRenderer,\n { ...state.paramDefaults },\n (props) => name(buildContext(props)),\n );\n },\n });\n };\n\n return builder;\n };\n\n return makeBuilder({\n paths,\n paramDefaults: {},\n declaredPathParams: [],\n componentKeyDeclared: false,\n componentKeyOptional: false,\n usedComponentKeyParams: false,\n usedPathParams: false,\n usedParams: false,\n }) as unknown as TargetPathBuilder<Resources, Config, Paths>;\n}\n\nexport function createForPaths<\n Resources extends ReadonlyArray<ResourceDefinition>,\n Config extends Record<string, unknown>,\n>(config: Config): ForPaths<Resources, Config, string> {\n const validPaths = generateResourceConfigPaths(config);\n\n return ((...paths: string[]) => {\n if (paths.length === 0) {\n throw new InvalidPathError({\n path: paths,\n validPaths,\n reason: 'At least one path is required',\n });\n }\n\n for (const path of paths) {\n if (!validPaths.includes(path)) {\n throw new InvalidPathError({ path, validPaths });\n }\n }\n\n return createTargetPathBuilder(config, paths);\n }) as unknown as ForPaths<Resources, Config, string>;\n}\n"],"mappings":";;;;;;;;;;;AAiOA,MAAM,uBAAuB;AAmB7B,SAAS,sBACP,QACA,OACgB;CAChB,MAAM,4BAAY,IAAI,IAAY;CAClC,MAAM,+BAAe,IAAI,IAAY;CACrC,MAAM,6BAAa,IAAI,IAAY;CAEnC,KAAK,MAAM,QAAQ,OAAO;EACxB,KAAK,MAAM,YAAY,qBAAqB,QAAQ,IAAI,GACtD,UAAU,IAAI,QAAQ;EAGxB,KAAK,MAAM,eAAe,2BAA2B,QAAQ,IAAI,GAC/D,aAAa,IAAI,WAAW;EAG9B,KAAK,MAAM,aAAa,yBAAyB,QAAQ,IAAI,GAC3D,WAAW,IAAI,SAAS;CAE5B;CAEA,OAAO;EACL,WAAW,CAAC,GAAG,SAAS;EACxB,cAAc,CAAC,GAAG,YAAY;EAC9B,YAAY,CAAC,GAAG,UAAU;CAC5B;AACF;;;;;AAMA,SAAS,eACP,QACA,OACA,MACM;CACN,MAAM,EAAE,UAAU,aAAa,WAAW,iBAAiB;CAO3D,IAAI,MAAM,mBAAmB,SAAS,UAAU,KAAK,aAAa,QAChE;MAAI,OAAO,aAAa,YAAY,CAAC,KAAK,UAAU,SAAS,QAAQ,GACnE,MAAM,IAAI,qBAAqB;GAC7B;GACA,gBAAgB,CAAC,GAAG,KAAK,SAAS;EACpC,CAAC;CACH;CAGF,IACE,MAAM,mBAAmB,SAAS,aAAa,KAC/C,gBAAgB,QAChB;EACA,MAAM,QAAQ,wBAAwB,WAAoC;EAE1E,KAAK,MAAM,QAAQ,OACjB,IAAI,CAAC,KAAK,aAAa,SAAS,IAAI,GAClC,MAAM,IAAI,wBAAwB;GAChC,aAAa;GACb,UAAU,OAAO,aAAa,WAAW,WAAW;GACpD,mBAAmB,CAAC,GAAG,KAAK,YAAY;EAC1C,CAAC;CAGP;CA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;CAC9C;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"for-resource.cjs","names":["LayoutConfigurationError","capitalize"],"sources":["../../src/create-config/for-resource.ts"],"sourcesContent":["import type { LayoutNameInput, ResolvedLayoutName } from './layout-name';\nimport type { ComposableComponents } from '@jfdevelops/react-layout-composables';\nimport type {\n InPropsDefinition,\n InPropsObject,\n MergedLayoutInProps,\n ResolvedIncludedComponentProps,\n} from '../props';\nimport type {\n LayoutResourceKey,\n ResourceDefinition,\n} from '../resource';\nimport type { UnionToIntersection, Updater } from '../utils';\nimport { LayoutConfigurationError } from '../errors';\nimport { capitalize } from '../utils/capitalize';\nimport type {\n LayoutIncludeProps,\n LayoutPropsForResource,\n ResourceLayoutComponent,\n ResourceLayoutResult,\n} from './define-layout';\n\ntype LayoutPropDefaults = Record<string, unknown>;\n\ntype CreateTimeLayoutPropWithDefault<\n LayoutProps extends LayoutPropDefaults,\n Key extends keyof LayoutProps,\n> = LayoutProps[Key] extends (...args: unknown[]) => unknown\n ? LayoutProps[Key]\n : Updater<LayoutProps[Key]>;\n\ntype ResolveLayoutPropsWithDefaults<\n LayoutProps extends LayoutPropDefaults,\n Defaults extends LayoutPropDefaults,\n> = Omit<LayoutProps, keyof Defaults> & {\n [Key in keyof Defaults & keyof LayoutProps]?: CreateTimeLayoutPropWithDefault<\n LayoutProps,\n Key\n >;\n};\n\nexport type CreateResourceLayoutOptionsBase<\n Resources extends ReadonlyArray<ResourceDefinition>,\n Name extends string,\n Resource extends LayoutResourceKey<Resources>,\n Props extends InPropsObject = {},\n Naming extends LayoutNameInput<Resource, any, Name> | undefined =\n LayoutNameInput<Resource, string, Name>,\n> = {\n /**\n * Overrides the definition or factory name; otherwise the resource supplies the name.\n */\n name?: Naming;\n resource: Resource;\n props?: Props;\n};\n\nexport type CreateResourceLayoutOptions<\n Resources extends ReadonlyArray<ResourceDefinition>,\n InProps extends InPropsDefinition<Resources>,\n Composables extends ComposableComponents,\n IncludeProps extends LayoutIncludeProps<Resources, InProps, Composables>,\n Name extends string,\n Resource extends LayoutResourceKey<Resources>,\n Props extends InPropsObject = {},\n Namespace extends boolean = false,\n Naming extends LayoutNameInput<Resource, any, Name> | undefined =\n LayoutNameInput<Resource, string, Name>,\n> = LayoutPropsForResource<Resources, InProps, Composables, IncludeProps> &\n CreateResourceLayoutOptionsBase<Resources, Name, Resource, Props, Naming> & {\n /** Return a component namespace with `Root` instead of a callable component. Defaults to false. */\n namespace?: Namespace;\n };\n\nexport type CreateLayoutForResourceOptions<\n Resources extends ReadonlyArray<ResourceDefinition>,\n Name extends string,\n Resource extends LayoutResourceKey<Resources>,\n> = {\n name?: Name;\n resource: Resource;\n};\n\ntype CreatedLayoutForResourceOptions<\n Resources extends ReadonlyArray<ResourceDefinition>,\n InProps extends InPropsDefinition<Resources>,\n Composables extends ComposableComponents,\n IncludeProps extends LayoutIncludeProps<Resources, InProps, Composables>,\n Props extends InPropsObject = {},\n Defaults extends LayoutPropDefaults = {},\n> = ResolveLayoutPropsWithDefaults<\n LayoutPropsForResource<Resources, InProps, Composables, IncludeProps>,\n Defaults\n> & {\n props?: Props;\n};\n\ntype CreatedLayoutForResourceCallOptions<\n Resources extends ReadonlyArray<ResourceDefinition>,\n InProps extends InPropsDefinition<Resources>,\n Composables extends ComposableComponents,\n IncludeProps extends LayoutIncludeProps<Resources, InProps, Composables>,\n OverrideName extends string,\n Props extends InPropsObject,\n Defaults extends LayoutPropDefaults,\n> = CreatedLayoutForResourceOptions<\n Resources,\n InProps,\n Composables,\n IncludeProps,\n Props,\n Defaults\n> & {\n name?: OverrideName;\n};\n\nexport type CreatedLayoutForResource<\n Resources extends ReadonlyArray<ResourceDefinition>,\n InProps extends InPropsDefinition<Resources>,\n Composables extends ComposableComponents,\n IncludeProps extends LayoutIncludeProps<Resources, InProps, Composables>,\n Name extends string,\n Resource extends LayoutResourceKey<Resources>,\n CustomProps extends InPropsObject = {},\n Defaults extends LayoutPropDefaults = {},\n DefaultNamespace extends boolean = false,\n States = {},\n> = <OverrideName extends string = Name, Props extends InPropsObject = {}, Namespace extends boolean = DefaultNamespace>(\n ...args: {} extends CreatedLayoutForResourceCallOptions<\n Resources,\n InProps,\n Composables,\n IncludeProps,\n OverrideName,\n Props,\n Defaults\n > & { namespace?: Namespace }\n ? [options?: CreatedLayoutForResourceCallOptions<\n Resources,\n InProps,\n Composables,\n IncludeProps,\n OverrideName,\n Props,\n Defaults\n > & { namespace?: Namespace }]\n : [options: CreatedLayoutForResourceCallOptions<\n Resources,\n InProps,\n Composables,\n IncludeProps,\n OverrideName,\n Props,\n Defaults\n > & { namespace?: Namespace }]\n) => ResourceLayoutResult<ResourceLayoutComponent<\n OverrideName,\n CustomProps,\n Composables,\n Resource,\n ResolvedIncludedComponentProps<\n MergedLayoutInProps<Resources, InProps, Composables>,\n IncludeProps\n >\n,\n States,\n Resources,\n InProps\n>, Namespace>;\n\ntype SetDefaultPropsForResource<\n Resources extends ReadonlyArray<ResourceDefinition>,\n InProps extends InPropsDefinition<Resources>,\n Composables extends ComposableComponents = {},\n IncludeProps extends LayoutIncludeProps<Resources, InProps, Composables> = {},\n> = Partial<\n LayoutPropsForResource<Resources, InProps, Composables, IncludeProps>\n>;\n\ntype ResolvedSetDefaultProps<\n Resources extends ReadonlyArray<ResourceDefinition>,\n InProps extends InPropsDefinition<Resources>,\n Composables extends ComposableComponents,\n IncludeProps extends LayoutIncludeProps<Resources, InProps, Composables>,\n Defaults extends SetDefaultPropsForResource<\n Resources,\n InProps,\n Composables,\n IncludeProps\n >,\n> = {\n [Key in keyof Defaults &\n keyof LayoutPropsForResource<\n Resources,\n InProps,\n Composables,\n IncludeProps\n >]: LayoutPropsForResource<\n Resources,\n InProps,\n Composables,\n IncludeProps\n >[Key];\n};\n\nexport type SetDefaultPropForResourceFn<\n Resources extends ReadonlyArray<ResourceDefinition>,\n InProps extends InPropsDefinition<Resources>,\n Composables extends ComposableComponents,\n IncludeProps extends LayoutIncludeProps<Resources, InProps, Composables>,\n Name extends string,\n Resource extends LayoutResourceKey<Resources>,\n CustomProps extends InPropsObject = {},\n DefaultNamespace extends boolean = false,\n States = {},\n> = <\n const Defaults extends SetDefaultPropsForResource<\n Resources,\n InProps,\n Composables,\n IncludeProps\n >,\n>(\n /** Default values for layout props. Each prop can only be set once. */\n defaults: Defaults,\n) => CreatedLayoutForResource<\n Resources,\n InProps,\n Composables,\n IncludeProps,\n Name,\n Resource,\n CustomProps,\n ResolvedSetDefaultProps<\n Resources,\n InProps,\n Composables,\n IncludeProps,\n Defaults\n >,\n DefaultNamespace,\n States\n>;\n\ntype CapitalizedResource<Resource extends string> =\n Resource extends Resource\n ? {\n toLowerCase: () => Lowercase<Capitalize<Resource>>;\n } & Capitalize<Resource>\n : never;\n\ntype ResourceLayoutNames<\n Resource extends string,\n CallbackName extends string,\n> = {\n [TargetResource in Resource]?:\n | string\n | ((resource: CapitalizedResource<TargetResource>) => CallbackName);\n};\n\ntype AtLeastOneResourceLayoutNameKey<Resource extends string> = {\n [TargetResource in Resource]: Record<TargetResource, unknown> &\n Partial<Record<Exclude<Resource, TargetResource>, unknown>>;\n}[Resource];\n\ntype SelectedResourceLayoutNames<\n Resource extends string,\n SelectedResource extends Resource,\n CallbackName extends string,\n> = {\n [TargetResource in Resource as TargetResource extends SelectedResource\n ? TargetResource\n : never]?:\n | string\n | ((resource: CapitalizedResource<TargetResource>) => CallbackName);\n};\n\ntype NormalizeCapitalizedResourceName<\n Name extends string,\n Resource extends string,\n> = Name extends Name\n ? NormalizeCapitalizedResourceNameMatch<\n Name,\n Resource\n > extends infer Match extends string\n ? [Match] extends [never]\n ? Name\n : Match\n : never\n : never;\n\ntype NormalizeCapitalizedResourceNameMatch<\n Name extends string,\n Resource extends string,\n> = Resource extends Resource\n ? Name extends `${CapitalizedResource<Resource>}${infer Suffix}`\n ? `${Capitalize<Resource>}${Suffix}`\n : never\n : never;\n\ntype ResourceLayoutBuilder<\n Resources extends ReadonlyArray<ResourceDefinition>,\n InProps extends InPropsDefinition<Resources>,\n Composables extends ComposableComponents,\n IncludeProps extends LayoutIncludeProps<Resources, InProps, Composables>,\n Name extends string,\n Resource extends LayoutResourceKey<Resources>,\n CustomProps extends InPropsObject,\n DefaultNamespace extends boolean = false,\n States = {},\n> = CreatedLayoutForResource<\n Resources,\n InProps,\n Composables,\n IncludeProps,\n Name,\n Resource,\n CustomProps,\n {},\n DefaultNamespace,\n States\n> & {\n /** Set default values for layout props in a single call. */\n setDefaults: SetDefaultPropForResourceFn<\n Resources,\n InProps,\n Composables,\n IncludeProps,\n Name,\n Resource,\n CustomProps,\n DefaultNamespace,\n States\n >;\n};\n\ntype SingleResourceLayoutSelection<\n Resources extends ReadonlyArray<ResourceDefinition>,\n CallbackName extends string,\n> = {\n [Resource in LayoutResourceKey<Resources>]: Record<\n Resource,\n {\n name?:\n | string\n | ((resource: CapitalizedResource<Resource>) => CallbackName);\n }\n > &\n Partial<\n Record<\n Exclude<LayoutResourceKey<Resources>, Resource>,\n never\n >\n >;\n}[LayoutResourceKey<Resources>];\n\ntype SelectedResourceName<Selection, Resource extends string> =\n Selection extends Record<Resource, { name?: infer Name }>\n ? Name extends (...args: never[]) => infer CallbackName\n ? NormalizeCapitalizedResourceName<CallbackName & string, Resource>\n : Name extends string\n ? Name\n : string\n : string;\n\ntype MappedResourceName<\n Names,\n CallbackName extends string,\n Resource extends string,\n> = Names extends Record<Resource, infer Name>\n ? Name extends (...args: never[]) => unknown\n ? NormalizeCapitalizedResourceName<CallbackName, Resource>\n : Name & string\n : string;\n\n/**\n * Creates a layout builder with a resource-keyed default-name map.\n *\n * @example\n * createResourceLayout.forResource({\n * resource: 'users',\n * name: {\n * users: resource => `${resource}Page`,\n * },\n * })\n *\n * @param options The resource and its resource-keyed default name.\n * @returns A layout builder bound to the selected resource.\n */\ntype ResourceLayoutNameMapFn<\n Resources extends ReadonlyArray<ResourceDefinition>,\n InProps extends InPropsDefinition<Resources>,\n Composables extends ComposableComponents,\n IncludeProps extends LayoutIncludeProps<Resources, InProps, Composables>,\n CustomProps extends InPropsObject,\n Resource extends LayoutResourceKey<Resources>,\n DefaultNamespace extends boolean = false,\n States = {},\n> = <const CallbackName extends string, const Names>(\n options: {\n resource: Resource;\n name: SelectedResourceLayoutNames<\n LayoutResourceKey<Resources>,\n Resource,\n CallbackName\n > &\n AtLeastOneResourceLayoutNameKey<Resource> &\n Record<\n string,\n NonNullable<\n ResourceLayoutNames<\n LayoutResourceKey<Resources>,\n CallbackName\n >[LayoutResourceKey<Resources>]\n >\n >;\n } & {\n name: Names & Record<Exclude<keyof Names, Resource>, never>;\n },\n) => ResourceLayoutBuilder<\n Resources,\n InProps,\n Composables,\n IncludeProps,\n MappedResourceName<Names, CallbackName, Resource>,\n Resource,\n CustomProps,\n DefaultNamespace,\n States\n>;\n\ntype ResourceLayoutNameMapFns<\n Resources extends ReadonlyArray<ResourceDefinition>,\n InProps extends InPropsDefinition<Resources>,\n Composables extends ComposableComponents,\n IncludeProps extends LayoutIncludeProps<Resources, InProps, Composables>,\n CustomProps extends InPropsObject,\n DefaultNamespace extends boolean = false,\n States = {},\n> = UnionToIntersection<\n {\n [Resource in LayoutResourceKey<Resources>]: ResourceLayoutNameMapFn<\n Resources,\n InProps,\n Composables,\n IncludeProps,\n CustomProps,\n Resource,\n DefaultNamespace,\n States\n >;\n }[LayoutResourceKey<Resources>]\n>;\n\nexport type CreateLayoutForResource<\n Resources extends ReadonlyArray<ResourceDefinition>,\n InProps extends InPropsDefinition<Resources>,\n Composables extends ComposableComponents = {},\n IncludeProps extends LayoutIncludeProps<Resources, InProps, Composables> = {},\n CustomProps extends InPropsObject = {},\n DefaultNamespace extends boolean = false,\n States = {},\n DefaultNaming extends LayoutNameInput<any, any> | undefined = undefined,\n> = {\n /**\n * Creates a layout builder for one resource without a default name.\n *\n * @example\n * createResourceLayout.forResource('users')\n *\n * @param resource The resource to bind to the returned layout builder.\n * @returns A layout builder bound to the selected resource.\n */\n <const Resource extends LayoutResourceKey<Resources>>(\n resource: Resource,\n ): ResourceLayoutBuilder<\n Resources,\n InProps,\n Composables,\n IncludeProps,\n ResolvedLayoutName<DefaultNaming, Resource>,\n Resource,\n CustomProps,\n DefaultNamespace,\n States\n >;\n\n /**\n * Creates a layout builder with a capitalized-resource naming callback.\n *\n * @example\n * createResourceLayout.forResource({\n * resource: 'users',\n * name: resource => `${resource}Page`,\n * })\n *\n * @param options The resource and its default-name callback.\n * @returns A layout builder bound to the selected resource.\n */\n <\n const Resource extends LayoutResourceKey<Resources>,\n const Name extends string,\n >(\n options: {\n name: (resource: CapitalizedResource<Resource>) => Name;\n resource: Resource;\n },\n ): ResourceLayoutBuilder<\n Resources,\n InProps,\n Composables,\n IncludeProps,\n NormalizeCapitalizedResourceName<Name, Resource>,\n Resource,\n CustomProps,\n DefaultNamespace,\n States\n >;\n\n /**\n * Creates a layout builder from the existing resource-options notation.\n *\n * @example\n * createResourceLayout.forResource({\n * resource: 'users',\n * name: 'UsersPage',\n * })\n *\n * @param options The resource and its optional default name.\n * @returns A layout builder bound to the selected resource.\n */\n <\n const Resource extends LayoutResourceKey<Resources>,\n const Name extends string = ResolvedLayoutName<DefaultNaming, Resource>,\n >(\n options: CreateLayoutForResourceOptions<Resources, Name, Resource>,\n ): ResourceLayoutBuilder<\n Resources,\n InProps,\n Composables,\n IncludeProps,\n Name,\n Resource,\n CustomProps,\n DefaultNamespace,\n States\n >;\n\n /**\n * Creates a layout builder from a single resource-keyed configuration.\n *\n * @example\n * createResourceLayout.forResource({\n * users: { name: resource => `${resource}Page` },\n * })\n *\n * @param options A single resource-keyed layout configuration.\n * @returns A layout builder bound to the configured resource.\n */\n <\n const CallbackName extends string,\n const Selection extends SingleResourceLayoutSelection<\n Resources,\n CallbackName\n >,\n >(\n options: Selection,\n ): ResourceLayoutBuilder<\n Resources,\n InProps,\n Composables,\n IncludeProps,\n SelectedResourceName<\n Selection,\n keyof Selection & LayoutResourceKey<Resources>\n >,\n keyof Selection & LayoutResourceKey<Resources>,\n CustomProps,\n DefaultNamespace,\n States\n >;\n} & ResourceLayoutNameMapFns<\n Resources,\n InProps,\n Composables,\n IncludeProps,\n CustomProps,\n DefaultNamespace,\n States\n>;\n\ntype CreateForResourceOptions = {\n createResourceLayout: (options: Record<string, unknown>) => unknown;\n resolveLayoutOptionDefaults: (\n defaults: Record<string, unknown>,\n options: Record<string, unknown>,\n ) => Record<string, unknown>;\n};\n\nexport function createForResource<\n Resources extends ReadonlyArray<ResourceDefinition>,\n InProps extends InPropsDefinition<Resources>,\n Composables extends ComposableComponents,\n IncludeProps extends LayoutIncludeProps<Resources, InProps, Composables>,\n CustomProps extends InPropsObject,\n>({\n createResourceLayout,\n resolveLayoutOptionDefaults,\n}: CreateForResourceOptions) {\n function createLayoutForResource<\n Name extends string,\n Resource extends LayoutResourceKey<Resources>,\n Defaults extends LayoutPropDefaults,\n >(\n defaultName: Name | undefined,\n resource: Resource,\n defaults: Record<string, unknown>,\n ) {\n return ((\n layoutOptions: { name?: string } & Record<string, unknown> = {},\n ) => {\n const { name, ...options } = layoutOptions;\n\n return createResourceLayout({\n ...defaults,\n name: name ?? defaultName,\n resource,\n ...resolveLayoutOptionDefaults(defaults, options),\n });\n }) as CreatedLayoutForResource<\n Resources,\n InProps,\n Composables,\n IncludeProps,\n Name,\n Resource,\n CustomProps,\n Defaults\n >;\n }\n\n function createLayoutForResourceBuilder<\n Name extends string,\n Resource extends LayoutResourceKey<Resources>,\n >(defaultName: Name | undefined, resource: Resource) {\n const createLayout = createLayoutForResource(defaultName, resource, {});\n const setDefaults = ((defaults) =>\n createLayoutForResource(\n defaultName,\n resource,\n defaults,\n )) as SetDefaultPropForResourceFn<\n Resources,\n InProps,\n Composables,\n IncludeProps,\n Name,\n Resource,\n CustomProps\n >;\n\n return Object.assign(createLayout, { setDefaults });\n }\n\n const forResource = ((resourceOrOptions: unknown) => {\n type ResourceName =\n | string\n | ((resource: CapitalizedResource<LayoutResourceKey<Resources>>) => string);\n let name:\n | ResourceName\n | Partial<Record<LayoutResourceKey<Resources>, ResourceName>>\n | undefined;\n let resource: LayoutResourceKey<Resources> | undefined;\n\n if (typeof resourceOrOptions === 'string') {\n resource = resourceOrOptions as LayoutResourceKey<Resources>;\n } else if (\n resourceOrOptions !== null &&\n typeof resourceOrOptions === 'object' &&\n ('resource' in resourceOrOptions || 'name' in resourceOrOptions)\n ) {\n ({ name, resource } = resourceOrOptions as {\n name?: typeof name;\n resource?: LayoutResourceKey<Resources>;\n });\n } else {\n const [selection] = Object.entries(resourceOrOptions ?? {});\n\n if (selection) {\n const [selectedResource, options] = selection;\n resource = selectedResource as LayoutResourceKey<Resources>;\n name = (options as { name?: typeof name }).name;\n }\n }\n\n if (!resource) {\n throw new LayoutConfigurationError('\"resource\" is required when calling \"forResource\"');\n }\n\n const selectedName =\n name !== null && typeof name === 'object' ? name[resource] : name;\n let defaultName: string | undefined;\n\n if (typeof selectedName === 'function') {\n defaultName = selectedName(\n capitalize(resource) as CapitalizedResource<\n LayoutResourceKey<Resources>\n >,\n );\n } else if (typeof selectedName === 'string') {\n defaultName = selectedName;\n }\n\n return createLayoutForResourceBuilder(defaultName, resource);\n }) as CreateLayoutForResource<\n Resources,\n InProps,\n Composables,\n IncludeProps,\n CustomProps\n >;\n\n return { createLayoutForResourceBuilder, forResource };\n}\n"],"mappings":";;;;AAulBA,SAAgB,kBAMd,EACA,sBACA,+BAC2B;CAC3B,SAAS,wBAKP,aACA,UACA,UACA;EACA,SACE,gBAA6D,CAAC,MAC3D;GACH,MAAM,EAAE,MAAM,GAAG,YAAY;GAE7B,OAAO,qBAAqB;IAC1B,GAAG;IACH,MAAM,QAAQ;IACd;IACA,GAAG,4BAA4B,UAAU,OAAO;GAClD,CAAC;EACH;CAUF;CAEA,SAAS,+BAGP,aAA+B,UAAoB;EACnD,MAAM,eAAe,wBAAwB,aAAa,UAAU,CAAC,CAAC;EACtE,MAAM,gBAAgB,aACpB,wBACE,aACA,UACA,QACF;EAUF,OAAO,OAAO,OAAO,cAAc,EAAE,YAAY,CAAC;CACpD;CAEA,MAAM,gBAAgB,sBAA+B;EAInD,IAAI;EAIJ,IAAI;EAEJ,IAAI,OAAO,sBAAsB,UAC/B,WAAW;OACN,IACL,sBAAsB,QACtB,OAAO,sBAAsB,aAC5B,cAAc,qBAAqB,UAAU,oBAE9C,CAAC,CAAE,MAAM,YAAa;OAIjB;GACL,MAAM,CAAC,aAAa,OAAO,QAAQ,qBAAqB,CAAC,CAAC;GAE1D,IAAI,WAAW;IACb,MAAM,CAAC,kBAAkB,WAAW;IACpC,WAAW;IACX,OAAQ,QAAmC;GAC7C;EACF;EAEA,IAAI,CAAC,UACH,MAAM,IAAIA,4DAAyB,uDAAmD;EAGxF,MAAM,eACJ,SAAS,QAAQ,OAAO,SAAS,WAAW,KAAK,YAAY;EAC/D,IAAI;EAEJ,IAAI,OAAO,iBAAiB,YAC1B,cAAc,aACZC,8BAAW,QAAQ,CAGrB;OACK,IAAI,OAAO,iBAAiB,UACjC,cAAc;EAGhB,OAAO,+BAA+B,aAAa,QAAQ;CAC7D;CAQA,OAAO;EAAE;EAAgC;CAAY;AACvD"}
1
+ {"version":3,"file":"for-resource.cjs","names":["LayoutConfigurationError","capitalize"],"sources":["../../src/create-config/for-resource.ts"],"sourcesContent":["import type { CustomPropsObject } from '../custom-props';\nimport type { LayoutNameInput, ResolvedLayoutName } from './layout-name';\nimport type { ComposableComponents } from '@jfdevelops/react-layout-composables';\nimport type {\n InPropsDefinition,\n InPropsObject,\n MergedLayoutInProps,\n ResolvedIncludedComponentProps,\n} from '../props';\nimport type {\n LayoutResourceKey,\n ResourceDefinition,\n} from '../resource';\nimport type { UnionToIntersection, Updater } from '../utils';\nimport { LayoutConfigurationError } from '../errors';\nimport { capitalize } from '../utils/capitalize';\nimport type {\n LayoutIncludeProps,\n LayoutPropsForResource,\n ResourceLayoutComponent,\n ResourceLayoutResult,\n} from './define-layout';\n\ntype LayoutPropDefaults = Record<string, unknown>;\n\ntype CreateTimeLayoutPropWithDefault<\n LayoutProps extends LayoutPropDefaults,\n Key extends keyof LayoutProps,\n> = LayoutProps[Key] extends (...args: unknown[]) => unknown\n ? LayoutProps[Key]\n : Updater<LayoutProps[Key]>;\n\ntype ResolveLayoutPropsWithDefaults<\n LayoutProps extends LayoutPropDefaults,\n Defaults extends LayoutPropDefaults,\n> = Omit<LayoutProps, keyof Defaults> & {\n [Key in keyof Defaults & keyof LayoutProps]?: CreateTimeLayoutPropWithDefault<\n LayoutProps,\n Key\n >;\n};\n\nexport type CreateResourceLayoutOptionsBase<\n Resources extends ReadonlyArray<ResourceDefinition>,\n Name extends string,\n Resource extends LayoutResourceKey<Resources>,\n Props extends InPropsObject = {},\n Naming extends LayoutNameInput<Resource, any, Name> | undefined =\n LayoutNameInput<Resource, string, Name>,\n> = {\n /**\n * Overrides the definition or factory name; otherwise the resource supplies the name.\n */\n name?: Naming;\n resource: Resource;\n props?: Props;\n};\n\nexport type CreateResourceLayoutOptions<\n Resources extends ReadonlyArray<ResourceDefinition>,\n InProps extends InPropsDefinition<Resources>,\n Composables extends ComposableComponents,\n IncludeProps extends LayoutIncludeProps<Resources, InProps, Composables>,\n Name extends string,\n Resource extends LayoutResourceKey<Resources>,\n Props extends InPropsObject = {},\n Namespace extends boolean = false,\n Naming extends LayoutNameInput<Resource, any, Name> | undefined =\n LayoutNameInput<Resource, string, Name>,\n> = LayoutPropsForResource<Resources, InProps, Composables, IncludeProps> &\n CreateResourceLayoutOptionsBase<Resources, Name, Resource, Props, Naming> & {\n /** Return a component namespace with `Root` instead of a callable component. Defaults to false. */\n namespace?: Namespace;\n };\n\nexport type CreateLayoutForResourceOptions<\n Resources extends ReadonlyArray<ResourceDefinition>,\n Name extends string,\n Resource extends LayoutResourceKey<Resources>,\n> = {\n name?: Name;\n resource: Resource;\n};\n\ntype CreatedLayoutForResourceOptions<\n Resources extends ReadonlyArray<ResourceDefinition>,\n InProps extends InPropsDefinition<Resources>,\n Composables extends ComposableComponents,\n IncludeProps extends LayoutIncludeProps<Resources, InProps, Composables>,\n Props extends InPropsObject = {},\n Defaults extends LayoutPropDefaults = {},\n> = ResolveLayoutPropsWithDefaults<\n LayoutPropsForResource<Resources, InProps, Composables, IncludeProps>,\n Defaults\n> & {\n props?: Props;\n};\n\ntype CreatedLayoutForResourceCallOptions<\n Resources extends ReadonlyArray<ResourceDefinition>,\n InProps extends InPropsDefinition<Resources>,\n Composables extends ComposableComponents,\n IncludeProps extends LayoutIncludeProps<Resources, InProps, Composables>,\n OverrideName extends string,\n Props extends InPropsObject,\n Defaults extends LayoutPropDefaults,\n> = CreatedLayoutForResourceOptions<\n Resources,\n InProps,\n Composables,\n IncludeProps,\n Props,\n Defaults\n> & {\n name?: OverrideName;\n};\n\nexport type CreatedLayoutForResource<\n Resources extends ReadonlyArray<ResourceDefinition>,\n InProps extends InPropsDefinition<Resources>,\n Composables extends ComposableComponents,\n IncludeProps extends LayoutIncludeProps<Resources, InProps, Composables>,\n Name extends string,\n Resource extends LayoutResourceKey<Resources>,\n CustomProps extends CustomPropsObject = {},\n Defaults extends LayoutPropDefaults = {},\n DefaultNamespace extends boolean = false,\n States = {},\n> = <OverrideName extends string = Name, Props extends InPropsObject = {}, Namespace extends boolean = DefaultNamespace>(\n ...args: {} extends CreatedLayoutForResourceCallOptions<\n Resources,\n InProps,\n Composables,\n IncludeProps,\n OverrideName,\n Props,\n Defaults\n > & { namespace?: Namespace }\n ? [options?: CreatedLayoutForResourceCallOptions<\n Resources,\n InProps,\n Composables,\n IncludeProps,\n OverrideName,\n Props,\n Defaults\n > & { namespace?: Namespace }]\n : [options: CreatedLayoutForResourceCallOptions<\n Resources,\n InProps,\n Composables,\n IncludeProps,\n OverrideName,\n Props,\n Defaults\n > & { namespace?: Namespace }]\n) => ResourceLayoutResult<ResourceLayoutComponent<\n OverrideName,\n CustomProps,\n Composables,\n Resource,\n ResolvedIncludedComponentProps<\n MergedLayoutInProps<Resources, InProps, Composables>,\n IncludeProps\n >\n,\n States,\n Resources,\n InProps\n>, Namespace>;\n\ntype SetDefaultPropsForResource<\n Resources extends ReadonlyArray<ResourceDefinition>,\n InProps extends InPropsDefinition<Resources>,\n Composables extends ComposableComponents = {},\n IncludeProps extends LayoutIncludeProps<Resources, InProps, Composables> = {},\n> = Partial<\n LayoutPropsForResource<Resources, InProps, Composables, IncludeProps>\n>;\n\ntype ResolvedSetDefaultProps<\n Resources extends ReadonlyArray<ResourceDefinition>,\n InProps extends InPropsDefinition<Resources>,\n Composables extends ComposableComponents,\n IncludeProps extends LayoutIncludeProps<Resources, InProps, Composables>,\n Defaults extends SetDefaultPropsForResource<\n Resources,\n InProps,\n Composables,\n IncludeProps\n >,\n> = {\n [Key in keyof Defaults &\n keyof LayoutPropsForResource<\n Resources,\n InProps,\n Composables,\n IncludeProps\n >]: LayoutPropsForResource<\n Resources,\n InProps,\n Composables,\n IncludeProps\n >[Key];\n};\n\nexport type SetDefaultPropForResourceFn<\n Resources extends ReadonlyArray<ResourceDefinition>,\n InProps extends InPropsDefinition<Resources>,\n Composables extends ComposableComponents,\n IncludeProps extends LayoutIncludeProps<Resources, InProps, Composables>,\n Name extends string,\n Resource extends LayoutResourceKey<Resources>,\n CustomProps extends CustomPropsObject = {},\n DefaultNamespace extends boolean = false,\n States = {},\n> = <\n const Defaults extends SetDefaultPropsForResource<\n Resources,\n InProps,\n Composables,\n IncludeProps\n >,\n>(\n /** Default values for layout props. Each prop can only be set once. */\n defaults: Defaults,\n) => CreatedLayoutForResource<\n Resources,\n InProps,\n Composables,\n IncludeProps,\n Name,\n Resource,\n CustomProps,\n ResolvedSetDefaultProps<\n Resources,\n InProps,\n Composables,\n IncludeProps,\n Defaults\n >,\n DefaultNamespace,\n States\n>;\n\ntype CapitalizedResource<Resource extends string> =\n Resource extends Resource\n ? {\n toLowerCase: () => Lowercase<Capitalize<Resource>>;\n } & Capitalize<Resource>\n : never;\n\ntype ResourceLayoutNames<\n Resource extends string,\n CallbackName extends string,\n> = {\n [TargetResource in Resource]?:\n | string\n | ((resource: CapitalizedResource<TargetResource>) => CallbackName);\n};\n\ntype AtLeastOneResourceLayoutNameKey<Resource extends string> = {\n [TargetResource in Resource]: Record<TargetResource, unknown> &\n Partial<Record<Exclude<Resource, TargetResource>, unknown>>;\n}[Resource];\n\ntype SelectedResourceLayoutNames<\n Resource extends string,\n SelectedResource extends Resource,\n CallbackName extends string,\n> = {\n [TargetResource in Resource as TargetResource extends SelectedResource\n ? TargetResource\n : never]?:\n | string\n | ((resource: CapitalizedResource<TargetResource>) => CallbackName);\n};\n\ntype NormalizeCapitalizedResourceName<\n Name extends string,\n Resource extends string,\n> = Name extends Name\n ? NormalizeCapitalizedResourceNameMatch<\n Name,\n Resource\n > extends infer Match extends string\n ? [Match] extends [never]\n ? Name\n : Match\n : never\n : never;\n\ntype NormalizeCapitalizedResourceNameMatch<\n Name extends string,\n Resource extends string,\n> = Resource extends Resource\n ? Name extends `${CapitalizedResource<Resource>}${infer Suffix}`\n ? `${Capitalize<Resource>}${Suffix}`\n : never\n : never;\n\ntype ResourceLayoutBuilder<\n Resources extends ReadonlyArray<ResourceDefinition>,\n InProps extends InPropsDefinition<Resources>,\n Composables extends ComposableComponents,\n IncludeProps extends LayoutIncludeProps<Resources, InProps, Composables>,\n Name extends string,\n Resource extends LayoutResourceKey<Resources>,\n CustomProps extends CustomPropsObject,\n DefaultNamespace extends boolean = false,\n States = {},\n> = CreatedLayoutForResource<\n Resources,\n InProps,\n Composables,\n IncludeProps,\n Name,\n Resource,\n CustomProps,\n {},\n DefaultNamespace,\n States\n> & {\n /** Set default values for layout props in a single call. */\n setDefaults: SetDefaultPropForResourceFn<\n Resources,\n InProps,\n Composables,\n IncludeProps,\n Name,\n Resource,\n CustomProps,\n DefaultNamespace,\n States\n >;\n};\n\ntype SingleResourceLayoutSelection<\n Resources extends ReadonlyArray<ResourceDefinition>,\n CallbackName extends string,\n> = {\n [Resource in LayoutResourceKey<Resources>]: Record<\n Resource,\n {\n name?:\n | string\n | ((resource: CapitalizedResource<Resource>) => CallbackName);\n }\n > &\n Partial<\n Record<\n Exclude<LayoutResourceKey<Resources>, Resource>,\n never\n >\n >;\n}[LayoutResourceKey<Resources>];\n\ntype SelectedResourceName<Selection, Resource extends string> =\n Selection extends Record<Resource, { name?: infer Name }>\n ? Name extends (...args: never[]) => infer CallbackName\n ? NormalizeCapitalizedResourceName<CallbackName & string, Resource>\n : Name extends string\n ? Name\n : string\n : string;\n\ntype MappedResourceName<\n Names,\n CallbackName extends string,\n Resource extends string,\n> = Names extends Record<Resource, infer Name>\n ? Name extends (...args: never[]) => unknown\n ? NormalizeCapitalizedResourceName<CallbackName, Resource>\n : Name & string\n : string;\n\n/**\n * Creates a layout builder with a resource-keyed default-name map.\n *\n * @example\n * createResourceLayout.forResource({\n * resource: 'users',\n * name: {\n * users: resource => `${resource}Page`,\n * },\n * })\n *\n * @param options The resource and its resource-keyed default name.\n * @returns A layout builder bound to the selected resource.\n */\ntype ResourceLayoutNameMapFn<\n Resources extends ReadonlyArray<ResourceDefinition>,\n InProps extends InPropsDefinition<Resources>,\n Composables extends ComposableComponents,\n IncludeProps extends LayoutIncludeProps<Resources, InProps, Composables>,\n CustomProps extends CustomPropsObject,\n Resource extends LayoutResourceKey<Resources>,\n DefaultNamespace extends boolean = false,\n States = {},\n> = <const CallbackName extends string, const Names>(\n options: {\n resource: Resource;\n name: SelectedResourceLayoutNames<\n LayoutResourceKey<Resources>,\n Resource,\n CallbackName\n > &\n AtLeastOneResourceLayoutNameKey<Resource> &\n Record<\n string,\n NonNullable<\n ResourceLayoutNames<\n LayoutResourceKey<Resources>,\n CallbackName\n >[LayoutResourceKey<Resources>]\n >\n >;\n } & {\n name: Names & Record<Exclude<keyof Names, Resource>, never>;\n },\n) => ResourceLayoutBuilder<\n Resources,\n InProps,\n Composables,\n IncludeProps,\n MappedResourceName<Names, CallbackName, Resource>,\n Resource,\n CustomProps,\n DefaultNamespace,\n States\n>;\n\ntype ResourceLayoutNameMapFns<\n Resources extends ReadonlyArray<ResourceDefinition>,\n InProps extends InPropsDefinition<Resources>,\n Composables extends ComposableComponents,\n IncludeProps extends LayoutIncludeProps<Resources, InProps, Composables>,\n CustomProps extends CustomPropsObject,\n DefaultNamespace extends boolean = false,\n States = {},\n> = UnionToIntersection<\n {\n [Resource in LayoutResourceKey<Resources>]: ResourceLayoutNameMapFn<\n Resources,\n InProps,\n Composables,\n IncludeProps,\n CustomProps,\n Resource,\n DefaultNamespace,\n States\n >;\n }[LayoutResourceKey<Resources>]\n>;\n\nexport type CreateLayoutForResource<\n Resources extends ReadonlyArray<ResourceDefinition>,\n InProps extends InPropsDefinition<Resources>,\n Composables extends ComposableComponents = {},\n IncludeProps extends LayoutIncludeProps<Resources, InProps, Composables> = {},\n CustomProps extends CustomPropsObject = {},\n DefaultNamespace extends boolean = false,\n States = {},\n DefaultNaming extends LayoutNameInput<any, any> | undefined = undefined,\n> = {\n /**\n * Creates a layout builder for one resource without a default name.\n *\n * @example\n * createResourceLayout.forResource('users')\n *\n * @param resource The resource to bind to the returned layout builder.\n * @returns A layout builder bound to the selected resource.\n */\n <const Resource extends LayoutResourceKey<Resources>>(\n resource: Resource,\n ): ResourceLayoutBuilder<\n Resources,\n InProps,\n Composables,\n IncludeProps,\n ResolvedLayoutName<DefaultNaming, Resource>,\n Resource,\n CustomProps,\n DefaultNamespace,\n States\n >;\n\n /**\n * Creates a layout builder with a capitalized-resource naming callback.\n *\n * @example\n * createResourceLayout.forResource({\n * resource: 'users',\n * name: resource => `${resource}Page`,\n * })\n *\n * @param options The resource and its default-name callback.\n * @returns A layout builder bound to the selected resource.\n */\n <\n const Resource extends LayoutResourceKey<Resources>,\n const Name extends string,\n >(\n options: {\n name: (resource: CapitalizedResource<Resource>) => Name;\n resource: Resource;\n },\n ): ResourceLayoutBuilder<\n Resources,\n InProps,\n Composables,\n IncludeProps,\n NormalizeCapitalizedResourceName<Name, Resource>,\n Resource,\n CustomProps,\n DefaultNamespace,\n States\n >;\n\n /**\n * Creates a layout builder from the existing resource-options notation.\n *\n * @example\n * createResourceLayout.forResource({\n * resource: 'users',\n * name: 'UsersPage',\n * })\n *\n * @param options The resource and its optional default name.\n * @returns A layout builder bound to the selected resource.\n */\n <\n const Resource extends LayoutResourceKey<Resources>,\n const Name extends string = ResolvedLayoutName<DefaultNaming, Resource>,\n >(\n options: CreateLayoutForResourceOptions<Resources, Name, Resource>,\n ): ResourceLayoutBuilder<\n Resources,\n InProps,\n Composables,\n IncludeProps,\n Name,\n Resource,\n CustomProps,\n DefaultNamespace,\n States\n >;\n\n /**\n * Creates a layout builder from a single resource-keyed configuration.\n *\n * @example\n * createResourceLayout.forResource({\n * users: { name: resource => `${resource}Page` },\n * })\n *\n * @param options A single resource-keyed layout configuration.\n * @returns A layout builder bound to the configured resource.\n */\n <\n const CallbackName extends string,\n const Selection extends SingleResourceLayoutSelection<\n Resources,\n CallbackName\n >,\n >(\n options: Selection,\n ): ResourceLayoutBuilder<\n Resources,\n InProps,\n Composables,\n IncludeProps,\n SelectedResourceName<\n Selection,\n keyof Selection & LayoutResourceKey<Resources>\n >,\n keyof Selection & LayoutResourceKey<Resources>,\n CustomProps,\n DefaultNamespace,\n States\n >;\n} & ResourceLayoutNameMapFns<\n Resources,\n InProps,\n Composables,\n IncludeProps,\n CustomProps,\n DefaultNamespace,\n States\n>;\n\ntype CreateForResourceOptions = {\n createResourceLayout: (options: Record<string, unknown>) => unknown;\n resolveLayoutOptionDefaults: (\n defaults: Record<string, unknown>,\n options: Record<string, unknown>,\n ) => Record<string, unknown>;\n};\n\nexport function createForResource<\n Resources extends ReadonlyArray<ResourceDefinition>,\n InProps extends InPropsDefinition<Resources>,\n Composables extends ComposableComponents,\n IncludeProps extends LayoutIncludeProps<Resources, InProps, Composables>,\n CustomProps extends CustomPropsObject,\n>({\n createResourceLayout,\n resolveLayoutOptionDefaults,\n}: CreateForResourceOptions) {\n function createLayoutForResource<\n Name extends string,\n Resource extends LayoutResourceKey<Resources>,\n Defaults extends LayoutPropDefaults,\n >(\n defaultName: Name | undefined,\n resource: Resource,\n defaults: Record<string, unknown>,\n ) {\n return ((\n layoutOptions: { name?: string } & Record<string, unknown> = {},\n ) => {\n const { name, ...options } = layoutOptions;\n\n return createResourceLayout({\n ...defaults,\n name: name ?? defaultName,\n resource,\n ...resolveLayoutOptionDefaults(defaults, options),\n });\n }) as CreatedLayoutForResource<\n Resources,\n InProps,\n Composables,\n IncludeProps,\n Name,\n Resource,\n CustomProps,\n Defaults\n >;\n }\n\n function createLayoutForResourceBuilder<\n Name extends string,\n Resource extends LayoutResourceKey<Resources>,\n >(defaultName: Name | undefined, resource: Resource) {\n const createLayout = createLayoutForResource(defaultName, resource, {});\n const setDefaults = ((defaults) =>\n createLayoutForResource(\n defaultName,\n resource,\n defaults,\n )) as SetDefaultPropForResourceFn<\n Resources,\n InProps,\n Composables,\n IncludeProps,\n Name,\n Resource,\n CustomProps\n >;\n\n return Object.assign(createLayout, { setDefaults });\n }\n\n const forResource = ((resourceOrOptions: unknown) => {\n type ResourceName =\n | string\n | ((resource: CapitalizedResource<LayoutResourceKey<Resources>>) => string);\n let name:\n | ResourceName\n | Partial<Record<LayoutResourceKey<Resources>, ResourceName>>\n | undefined;\n let resource: LayoutResourceKey<Resources> | undefined;\n\n if (typeof resourceOrOptions === 'string') {\n resource = resourceOrOptions as LayoutResourceKey<Resources>;\n } else if (\n resourceOrOptions !== null &&\n typeof resourceOrOptions === 'object' &&\n ('resource' in resourceOrOptions || 'name' in resourceOrOptions)\n ) {\n ({ name, resource } = resourceOrOptions as {\n name?: typeof name;\n resource?: LayoutResourceKey<Resources>;\n });\n } else {\n const [selection] = Object.entries(resourceOrOptions ?? {});\n\n if (selection) {\n const [selectedResource, options] = selection;\n resource = selectedResource as LayoutResourceKey<Resources>;\n name = (options as { name?: typeof name }).name;\n }\n }\n\n if (!resource) {\n throw new LayoutConfigurationError('\"resource\" is required when calling \"forResource\"');\n }\n\n const selectedName =\n name !== null && typeof name === 'object' ? name[resource] : name;\n let defaultName: string | undefined;\n\n if (typeof selectedName === 'function') {\n defaultName = selectedName(\n capitalize(resource) as CapitalizedResource<\n LayoutResourceKey<Resources>\n >,\n );\n } else if (typeof selectedName === 'string') {\n defaultName = selectedName;\n }\n\n return createLayoutForResourceBuilder(defaultName, resource);\n }) as CreateLayoutForResource<\n Resources,\n InProps,\n Composables,\n IncludeProps,\n CustomProps\n >;\n\n return { createLayoutForResourceBuilder, forResource };\n}\n"],"mappings":";;;;AAwlBA,SAAgB,kBAMd,EACA,sBACA,+BAC2B;CAC3B,SAAS,wBAKP,aACA,UACA,UACA;EACA,SACE,gBAA6D,CAAC,MAC3D;GACH,MAAM,EAAE,MAAM,GAAG,YAAY;GAE7B,OAAO,qBAAqB;IAC1B,GAAG;IACH,MAAM,QAAQ;IACd;IACA,GAAG,4BAA4B,UAAU,OAAO;GAClD,CAAC;EACH;CAUF;CAEA,SAAS,+BAGP,aAA+B,UAAoB;EACnD,MAAM,eAAe,wBAAwB,aAAa,UAAU,CAAC,CAAC;EACtE,MAAM,gBAAgB,aACpB,wBACE,aACA,UACA,QACF;EAUF,OAAO,OAAO,OAAO,cAAc,EAAE,YAAY,CAAC;CACpD;CAEA,MAAM,gBAAgB,sBAA+B;EAInD,IAAI;EAIJ,IAAI;EAEJ,IAAI,OAAO,sBAAsB,UAC/B,WAAW;OACN,IACL,sBAAsB,QACtB,OAAO,sBAAsB,aAC5B,cAAc,qBAAqB,UAAU,oBAE9C,CAAC,CAAE,MAAM,YAAa;OAIjB;GACL,MAAM,CAAC,aAAa,OAAO,QAAQ,qBAAqB,CAAC,CAAC;GAE1D,IAAI,WAAW;IACb,MAAM,CAAC,kBAAkB,WAAW;IACpC,WAAW;IACX,OAAQ,QAAmC;GAC7C;EACF;EAEA,IAAI,CAAC,UACH,MAAM,IAAIA,4DAAyB,uDAAmD;EAGxF,MAAM,eACJ,SAAS,QAAQ,OAAO,SAAS,WAAW,KAAK,YAAY;EAC/D,IAAI;EAEJ,IAAI,OAAO,iBAAiB,YAC1B,cAAc,aACZC,8BAAW,QAAQ,CAGrB;OACK,IAAI,OAAO,iBAAiB,UACjC,cAAc;EAGhB,OAAO,+BAA+B,aAAa,QAAQ;CAC7D;CAQA,OAAO;EAAE;EAAgC;CAAY;AACvD"}
@@ -1,3 +1,4 @@
1
+ import { CustomPropsObject } from "../custom-props.cjs";
1
2
  import { UnionToIntersection, Updater } from "../utils.cjs";
2
3
  import { LayoutResourceKey, ResourceDefinition } from "../resource.cjs";
3
4
  import { InPropsDefinition, InPropsObject, MergedLayoutInProps, ResolvedIncludedComponentProps } from "../props.cjs";
@@ -30,7 +31,7 @@ type CreatedLayoutForResourceOptions<Resources extends ReadonlyArray<ResourceDef
30
31
  type CreatedLayoutForResourceCallOptions<Resources extends ReadonlyArray<ResourceDefinition>, InProps extends InPropsDefinition<Resources>, Composables extends ComposableComponents, IncludeProps extends LayoutIncludeProps<Resources, InProps, Composables>, OverrideName extends string, Props extends InPropsObject, Defaults extends LayoutPropDefaults> = CreatedLayoutForResourceOptions<Resources, InProps, Composables, IncludeProps, Props, Defaults> & {
31
32
  name?: OverrideName;
32
33
  };
33
- type CreatedLayoutForResource<Resources extends ReadonlyArray<ResourceDefinition>, InProps extends InPropsDefinition<Resources>, Composables extends ComposableComponents, IncludeProps extends LayoutIncludeProps<Resources, InProps, Composables>, Name extends string, Resource extends LayoutResourceKey<Resources>, CustomProps extends InPropsObject = {}, Defaults extends LayoutPropDefaults = {}, DefaultNamespace extends boolean = false, States = {}> = <OverrideName extends string = Name, Props extends InPropsObject = {}, Namespace extends boolean = DefaultNamespace>(...args: {} extends CreatedLayoutForResourceCallOptions<Resources, InProps, Composables, IncludeProps, OverrideName, Props, Defaults> & {
34
+ type CreatedLayoutForResource<Resources extends ReadonlyArray<ResourceDefinition>, InProps extends InPropsDefinition<Resources>, Composables extends ComposableComponents, IncludeProps extends LayoutIncludeProps<Resources, InProps, Composables>, Name extends string, Resource extends LayoutResourceKey<Resources>, CustomProps extends CustomPropsObject = {}, Defaults extends LayoutPropDefaults = {}, DefaultNamespace extends boolean = false, States = {}> = <OverrideName extends string = Name, Props extends InPropsObject = {}, Namespace extends boolean = DefaultNamespace>(...args: {} extends CreatedLayoutForResourceCallOptions<Resources, InProps, Composables, IncludeProps, OverrideName, Props, Defaults> & {
34
35
  namespace?: Namespace;
35
36
  } ? [options?: CreatedLayoutForResourceCallOptions<Resources, InProps, Composables, IncludeProps, OverrideName, Props, Defaults> & {
36
37
  namespace?: Namespace;
@@ -39,7 +40,7 @@ type CreatedLayoutForResource<Resources extends ReadonlyArray<ResourceDefinition
39
40
  }]) => ResourceLayoutResult<ResourceLayoutComponent<OverrideName, CustomProps, Composables, Resource, ResolvedIncludedComponentProps<MergedLayoutInProps<Resources, InProps, Composables>, IncludeProps>, States, Resources, InProps>, Namespace>;
40
41
  type SetDefaultPropsForResource<Resources extends ReadonlyArray<ResourceDefinition>, InProps extends InPropsDefinition<Resources>, Composables extends ComposableComponents = {}, IncludeProps extends LayoutIncludeProps<Resources, InProps, Composables> = {}> = Partial<LayoutPropsForResource<Resources, InProps, Composables, IncludeProps>>;
41
42
  type ResolvedSetDefaultProps<Resources extends ReadonlyArray<ResourceDefinition>, InProps extends InPropsDefinition<Resources>, Composables extends ComposableComponents, IncludeProps extends LayoutIncludeProps<Resources, InProps, Composables>, Defaults extends SetDefaultPropsForResource<Resources, InProps, Composables, IncludeProps>> = { [Key in keyof Defaults & keyof LayoutPropsForResource<Resources, InProps, Composables, IncludeProps>]: LayoutPropsForResource<Resources, InProps, Composables, IncludeProps>[Key] };
42
- type SetDefaultPropForResourceFn<Resources extends ReadonlyArray<ResourceDefinition>, InProps extends InPropsDefinition<Resources>, Composables extends ComposableComponents, IncludeProps extends LayoutIncludeProps<Resources, InProps, Composables>, Name extends string, Resource extends LayoutResourceKey<Resources>, CustomProps extends InPropsObject = {}, DefaultNamespace extends boolean = false, States = {}> = <const Defaults extends SetDefaultPropsForResource<Resources, InProps, Composables, IncludeProps>>(/** Default values for layout props. Each prop can only be set once. */
43
+ type SetDefaultPropForResourceFn<Resources extends ReadonlyArray<ResourceDefinition>, InProps extends InPropsDefinition<Resources>, Composables extends ComposableComponents, IncludeProps extends LayoutIncludeProps<Resources, InProps, Composables>, Name extends string, Resource extends LayoutResourceKey<Resources>, CustomProps extends CustomPropsObject = {}, DefaultNamespace extends boolean = false, States = {}> = <const Defaults extends SetDefaultPropsForResource<Resources, InProps, Composables, IncludeProps>>(/** Default values for layout props. Each prop can only be set once. */
43
44
 
44
45
  defaults: Defaults) => CreatedLayoutForResource<Resources, InProps, Composables, IncludeProps, Name, Resource, CustomProps, ResolvedSetDefaultProps<Resources, InProps, Composables, IncludeProps, Defaults>, DefaultNamespace, States>;
45
46
  type CapitalizedResource<Resource extends string> = Resource extends Resource ? {
@@ -50,7 +51,7 @@ type AtLeastOneResourceLayoutNameKey<Resource extends string> = { [TargetResourc
50
51
  type SelectedResourceLayoutNames<Resource extends string, SelectedResource extends Resource, CallbackName extends string> = { [TargetResource in Resource as TargetResource extends SelectedResource ? TargetResource : never]?: string | ((resource: CapitalizedResource<TargetResource>) => CallbackName) };
51
52
  type NormalizeCapitalizedResourceName<Name extends string, Resource extends string> = Name extends Name ? NormalizeCapitalizedResourceNameMatch<Name, Resource> extends infer Match extends string ? [Match] extends [never] ? Name : Match : never : never;
52
53
  type NormalizeCapitalizedResourceNameMatch<Name extends string, Resource extends string> = Resource extends Resource ? Name extends `${CapitalizedResource<Resource>}${infer Suffix}` ? `${Capitalize<Resource>}${Suffix}` : never : never;
53
- type ResourceLayoutBuilder<Resources extends ReadonlyArray<ResourceDefinition>, InProps extends InPropsDefinition<Resources>, Composables extends ComposableComponents, IncludeProps extends LayoutIncludeProps<Resources, InProps, Composables>, Name extends string, Resource extends LayoutResourceKey<Resources>, CustomProps extends InPropsObject, DefaultNamespace extends boolean = false, States = {}> = CreatedLayoutForResource<Resources, InProps, Composables, IncludeProps, Name, Resource, CustomProps, {}, DefaultNamespace, States> & {
54
+ type ResourceLayoutBuilder<Resources extends ReadonlyArray<ResourceDefinition>, InProps extends InPropsDefinition<Resources>, Composables extends ComposableComponents, IncludeProps extends LayoutIncludeProps<Resources, InProps, Composables>, Name extends string, Resource extends LayoutResourceKey<Resources>, CustomProps extends CustomPropsObject, DefaultNamespace extends boolean = false, States = {}> = CreatedLayoutForResource<Resources, InProps, Composables, IncludeProps, Name, Resource, CustomProps, {}, DefaultNamespace, States> & {
54
55
  /** Set default values for layout props in a single call. */setDefaults: SetDefaultPropForResourceFn<Resources, InProps, Composables, IncludeProps, Name, Resource, CustomProps, DefaultNamespace, States>;
55
56
  };
56
57
  type SingleResourceLayoutSelection<Resources extends ReadonlyArray<ResourceDefinition>, CallbackName extends string> = { [Resource in LayoutResourceKey<Resources>]: Record<Resource, {
@@ -74,14 +75,14 @@ type MappedResourceName<Names, CallbackName extends string, Resource extends str
74
75
  * @param options The resource and its resource-keyed default name.
75
76
  * @returns A layout builder bound to the selected resource.
76
77
  */
77
- type ResourceLayoutNameMapFn<Resources extends ReadonlyArray<ResourceDefinition>, InProps extends InPropsDefinition<Resources>, Composables extends ComposableComponents, IncludeProps extends LayoutIncludeProps<Resources, InProps, Composables>, CustomProps extends InPropsObject, Resource extends LayoutResourceKey<Resources>, DefaultNamespace extends boolean = false, States = {}> = <const CallbackName extends string, const Names>(options: {
78
+ type ResourceLayoutNameMapFn<Resources extends ReadonlyArray<ResourceDefinition>, InProps extends InPropsDefinition<Resources>, Composables extends ComposableComponents, IncludeProps extends LayoutIncludeProps<Resources, InProps, Composables>, CustomProps extends CustomPropsObject, Resource extends LayoutResourceKey<Resources>, DefaultNamespace extends boolean = false, States = {}> = <const CallbackName extends string, const Names>(options: {
78
79
  resource: Resource;
79
80
  name: SelectedResourceLayoutNames<LayoutResourceKey<Resources>, Resource, CallbackName> & AtLeastOneResourceLayoutNameKey<Resource> & Record<string, NonNullable<ResourceLayoutNames<LayoutResourceKey<Resources>, CallbackName>[LayoutResourceKey<Resources>]>>;
80
81
  } & {
81
82
  name: Names & Record<Exclude<keyof Names, Resource>, never>;
82
83
  }) => ResourceLayoutBuilder<Resources, InProps, Composables, IncludeProps, MappedResourceName<Names, CallbackName, Resource>, Resource, CustomProps, DefaultNamespace, States>;
83
- type ResourceLayoutNameMapFns<Resources extends ReadonlyArray<ResourceDefinition>, InProps extends InPropsDefinition<Resources>, Composables extends ComposableComponents, IncludeProps extends LayoutIncludeProps<Resources, InProps, Composables>, CustomProps extends InPropsObject, DefaultNamespace extends boolean = false, States = {}> = UnionToIntersection<{ [Resource in LayoutResourceKey<Resources>]: ResourceLayoutNameMapFn<Resources, InProps, Composables, IncludeProps, CustomProps, Resource, DefaultNamespace, States> }[LayoutResourceKey<Resources>]>;
84
- type CreateLayoutForResource<Resources extends ReadonlyArray<ResourceDefinition>, InProps extends InPropsDefinition<Resources>, Composables extends ComposableComponents = {}, IncludeProps extends LayoutIncludeProps<Resources, InProps, Composables> = {}, CustomProps extends InPropsObject = {}, DefaultNamespace extends boolean = false, States = {}, DefaultNaming extends LayoutNameInput<any, any> | undefined = undefined> = {
84
+ type ResourceLayoutNameMapFns<Resources extends ReadonlyArray<ResourceDefinition>, InProps extends InPropsDefinition<Resources>, Composables extends ComposableComponents, IncludeProps extends LayoutIncludeProps<Resources, InProps, Composables>, CustomProps extends CustomPropsObject, DefaultNamespace extends boolean = false, States = {}> = UnionToIntersection<{ [Resource in LayoutResourceKey<Resources>]: ResourceLayoutNameMapFn<Resources, InProps, Composables, IncludeProps, CustomProps, Resource, DefaultNamespace, States> }[LayoutResourceKey<Resources>]>;
85
+ type CreateLayoutForResource<Resources extends ReadonlyArray<ResourceDefinition>, InProps extends InPropsDefinition<Resources>, Composables extends ComposableComponents = {}, IncludeProps extends LayoutIncludeProps<Resources, InProps, Composables> = {}, CustomProps extends CustomPropsObject = {}, DefaultNamespace extends boolean = false, States = {}, DefaultNaming extends LayoutNameInput<any, any> | undefined = undefined> = {
85
86
  /**
86
87
  * Creates a layout builder for one resource without a default name.
87
88
  *
@@ -1 +1 @@
1
- {"version":3,"file":"for-resource.d.cts","names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