@jfdevelops/react-layout-composables 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/composable.cjs +7 -3
- package/dist/composable.cjs.map +1 -1
- package/dist/composable.d.cts +9 -6
- package/dist/composable.d.cts.map +1 -1
- package/dist/composable.d.mts +9 -6
- package/dist/composable.d.mts.map +1 -1
- package/dist/composable.mjs +8 -4
- package/dist/composable.mjs.map +1 -1
- package/dist/errors.d.cts +11 -11
- package/dist/errors.d.cts.map +1 -1
- package/dist/errors.d.mts +11 -11
- package/dist/errors.d.mts.map +1 -1
- package/dist/node_modules/.pnpm/{@jfdevelops_create-error@0.2.0_patch_hash_afc71b16c3f866f54416d30f467784ddc31736feb04f281a5fc4772ea422f4a9 → @jfdevelops_create-error@0.2.1}/node_modules/@jfdevelops/create-error/dist/types.d.cts +46 -2
- package/dist/node_modules/.pnpm/{@jfdevelops_create-error@0.2.0_patch_hash_afc71b16c3f866f54416d30f467784ddc31736feb04f281a5fc4772ea422f4a9 → @jfdevelops_create-error@0.2.1}/node_modules/@jfdevelops/create-error/dist/types.d.cts.map +1 -1
- package/dist/node_modules/.pnpm/{@jfdevelops_create-error@0.2.0_patch_hash_afc71b16c3f866f54416d30f467784ddc31736feb04f281a5fc4772ea422f4a9 → @jfdevelops_create-error@0.2.1}/node_modules/@jfdevelops/create-error/dist/types.d.mts +46 -2
- package/dist/node_modules/.pnpm/{@jfdevelops_create-error@0.2.0_patch_hash_afc71b16c3f866f54416d30f467784ddc31736feb04f281a5fc4772ea422f4a9 → @jfdevelops_create-error@0.2.1}/node_modules/@jfdevelops/create-error/dist/types.d.mts.map +1 -1
- package/dist/node_modules/.pnpm/@standard-schema_spec@1.1.0/node_modules/@standard-schema/spec/dist/index.d.cts +80 -0
- package/dist/node_modules/.pnpm/@standard-schema_spec@1.1.0/node_modules/@standard-schema/spec/dist/index.d.cts.map +1 -0
- package/dist/node_modules/.pnpm/@standard-schema_spec@1.1.0/node_modules/@standard-schema/spec/dist/index.d.mts +80 -0
- package/dist/node_modules/.pnpm/@standard-schema_spec@1.1.0/node_modules/@standard-schema/spec/dist/index.d.mts.map +1 -0
- package/package.json +3 -3
package/dist/composable.cjs
CHANGED
|
@@ -5,6 +5,7 @@ let react_jsx_runtime = require("react/jsx-runtime");
|
|
|
5
5
|
|
|
6
6
|
//#region src/composable.tsx
|
|
7
7
|
const composablePresetMetaKey = Symbol.for("view-map.composable-preset-meta");
|
|
8
|
+
const validatedComposableProps = Symbol("validatedComposableProps");
|
|
8
9
|
const composablePresetPropsContext = (0, react.createContext)(void 0);
|
|
9
10
|
function LayoutComposablePresetProvider({ value, children }) {
|
|
10
11
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(composablePresetPropsContext.Provider, {
|
|
@@ -65,7 +66,8 @@ function createComposableComponent(options) {
|
|
|
65
66
|
for (const key of inPropsKeys) if (key in propsRecord) mergedInProps[key] = propsRecord[key];
|
|
66
67
|
const wrapperProps = { ...propsRecord };
|
|
67
68
|
for (const key of inPropsKeys) delete wrapperProps[key];
|
|
68
|
-
const
|
|
69
|
+
const mergedValues = (0, _jfdevelops_react_layout_validator.resolvePropDefinitionValues)(mergedInProps);
|
|
70
|
+
const mergedResolved = (0, _jfdevelops_react_layout_validator.validateProps)(options[validatedComposableProps] ? {} : Object.fromEntries(Object.entries(inProps ?? {}).filter(([, definition]) => (0, _jfdevelops_react_layout_validator.isStandardSchema)(definition))), mergedValues);
|
|
69
71
|
const resolvedProps = outProps ? outProps(mergedResolved) : {};
|
|
70
72
|
const resolvedChildren = children == null ? reactNodeFromSingleFieldOutProps(resolvedProps) : resolveComponent(children, resolvedProps);
|
|
71
73
|
if (wrapWith) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(wrapWith, {
|
|
@@ -90,7 +92,8 @@ function createComposableComponent(options) {
|
|
|
90
92
|
function resolvePresetComposableCallProps(presetKey, propDefinitions, callProps) {
|
|
91
93
|
const presetKeys = Object.keys(propDefinitions);
|
|
92
94
|
const contextValues = useComposablePresetProps(presetKey) ?? {};
|
|
93
|
-
|
|
95
|
+
const presetValues = Object.fromEntries(presetKeys.map((key) => [key, (0, _jfdevelops_react_layout_validator.isStandardSchema)(propDefinitions[key]) && Object.hasOwn(callProps, key) ? callProps[key] : callProps[key] ?? contextValues[key]]));
|
|
96
|
+
return (0, _jfdevelops_react_layout_validator.validateProps)(Object.fromEntries(Object.entries(propDefinitions).filter(([key, definition]) => !(0, _jfdevelops_react_layout_validator.isStandardSchema)(definition) || Object.hasOwn(callProps, key) || !Object.hasOwn(contextValues, key))), presetValues);
|
|
94
97
|
}
|
|
95
98
|
function defineComposableComponent(options) {
|
|
96
99
|
const { name, props = {}, wrapWith } = options;
|
|
@@ -112,7 +115,8 @@ function defineComposableComponent(options) {
|
|
|
112
115
|
name,
|
|
113
116
|
wrapWith,
|
|
114
117
|
inProps: props,
|
|
115
|
-
outProps: (resolved) => resolved
|
|
118
|
+
outProps: (resolved) => resolved,
|
|
119
|
+
[validatedComposableProps]: true
|
|
116
120
|
});
|
|
117
121
|
function PresetComposable(callProps) {
|
|
118
122
|
const callPropsRecord = callProps;
|
package/dist/composable.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"composable.cjs","names":["Comp","InvalidComponentsError","EmptyComponentsError"],"sources":["../src/composable.tsx"],"sourcesContent":["import { ComponentType, createContext, ReactNode, useContext, cloneElement, isValidElement } from 'react';\nimport { EmptyComponentsError, InvalidComponentsError } from './errors';\nimport {\n AnyBuiltPropDefinition,\n type PropValidationContext,\n ResolveLayoutProps,\n ResolveProps,\n resolvePropDefinitionValues,\n validateProps,\n} from '@jfdevelops/react-layout-validator';\nimport { InPropsObject, type WithChildren } from './types';\nimport { BaseComponent, Show, UnionToIntersection } from './utils';\nimport { CapitalizeFn } from './utils/capitalize';\n\nexport const composablePresetMetaKey = Symbol.for(\n 'view-map.composable-preset-meta'\n);\n\nexport type ComposablePresetMeta<Props extends InPropsObject = InPropsObject> =\n {\n key: string;\n props: Props;\n };\n\nexport type ComposablePresetProps = Record<string, Record<string, unknown>>;\n\nconst composablePresetPropsContext = createContext<\n ComposablePresetProps | undefined\n>(undefined);\n\nexport function LayoutComposablePresetProvider({\n value,\n children,\n}: {\n value: ComposablePresetProps;\n children: ReactNode;\n}) {\n return (\n <composablePresetPropsContext.Provider value={value}>\n {children}\n </composablePresetPropsContext.Provider>\n );\n}\n\nfunction useComposablePresetProps(key: string) {\n return useContext(composablePresetPropsContext)?.[key];\n}\n\nexport function collectComposablePresetEntries(\n composables: ComposableComponents | undefined\n) {\n if (!composables) {\n return [] as Array<{\n key: string;\n props: InPropsObject;\n }>;\n }\n\n return Object.entries(composables).flatMap(([objectKey, component]) => {\n const meta = (component as ComposablePresetComponent)[\n composablePresetMetaKey\n ];\n\n if (!meta) {\n return [];\n }\n\n return [\n {\n key: meta.key ?? objectKey,\n props: meta.props,\n },\n ];\n });\n}\n\nexport function resolveComposablePresetProps(\n composables: ComposableComponents | undefined,\n layoutOptions: Record<string, unknown>,\n context?: PropValidationContext\n) {\n const resolved: ComposablePresetProps = {};\n\n for (const { key, props } of collectComposablePresetEntries(composables)) {\n const propKeys = Object.keys(props);\n const values = Object.fromEntries(\n propKeys.flatMap((propKey) => {\n if (!(propKey in layoutOptions)) {\n return [];\n }\n\n return [[propKey, layoutOptions[propKey]]];\n })\n );\n\n resolved[key] = validateProps(\n props as Record<string, AnyBuiltPropDefinition>,\n values,\n context\n );\n }\n\n return resolved;\n}\n\nexport type ComposableNameContext<\n Resource extends string,\n LayoutName extends string = string\n> = {\n resource: Resource;\n name: LayoutName;\n capitalize: CapitalizeFn;\n};\n\ntype ComposableComponentName<\n Name extends string,\n Resource extends string,\n LayoutName extends string = string\n> = Name | ((ctx: ComposableNameContext<Resource, LayoutName>) => Name);\n\ntype CreateComposableComponentOptions<\n Name extends string,\n Wrapper,\n Resource extends string,\n LayoutName extends string = string,\n InProps extends InPropsObject = {},\n OutProps = {}\n> = {\n name: ComposableComponentName<Name, Resource, LayoutName>;\n inProps?: InProps;\n outProps?: (props: Show<ResolveProps<InProps>>) => OutProps;\n wrapWith?: Wrapper;\n};\n\ntype ResolvedCreateComposableComponentOptions<\n Name extends string,\n Wrapper,\n Resource extends string,\n LayoutName extends string = string,\n InProps extends InPropsObject = {},\n OutProps = {}\n> = Omit<\n CreateComposableComponentOptions<\n Name,\n Wrapper,\n Resource,\n LayoutName,\n InProps,\n OutProps\n >,\n 'name'\n> & {\n name: Name;\n};\n\nexport type CreateLayoutComposable<\n Resources extends string,\n LayoutName extends string = string\n> = <\n const Name extends string,\n Wrapper,\n InProps extends InPropsObject = {},\n OutProps = {}\n>(\n options: CreateComposableComponentOptions<\n Name,\n Wrapper,\n Resources,\n LayoutName,\n InProps,\n OutProps\n >\n) => ComposableComponent<Name, Wrapper, InProps, OutProps>;\n\nexport type LayoutComposablesFactory<\n Resources extends string,\n LayoutName extends string = string\n> = (\n create: CreateLayoutComposable<Resources, LayoutName>\n) => ComposableComponents;\n\nexport type ResolveLayoutComposables<\n Factory extends LayoutComposablesFactory<string> | undefined\n> = Factory extends LayoutComposablesFactory<string> ? ReturnType<Factory> : {};\n\ntype ComposableComponentWrapperProps<Wrapper> = Wrapper extends ComponentType<\n infer Props\n>\n ? Omit<Props, 'children'>\n : {};\n\ntype ComposableComponentProps<\n Wrapper,\n InProps extends InPropsObject = {},\n OutProps = {}\n> = ComposableComponentWrapperProps<Wrapper> &\n (keyof InProps extends never ? {} : ResolveProps<InProps>) & {\n children?: [keyof InProps] extends [never]\n ? ReactNode\n : ((props: OutProps) => JSX.Element) | ReactNode;\n };\n\nexport type ComposableComponent<\n Name extends string,\n Wrapper,\n InProps extends InPropsObject = {},\n OutProps = {}\n> = BaseComponent<Name, ResolveProps<InProps>> & {\n (props: ComposableComponentProps<Wrapper, InProps, OutProps>): ReactNode;\n};\n\nexport type ComposableResourceLayout<\n Composables extends ComposableComponents,\n Name extends string,\n Wrapper,\n InProps extends InPropsObject = {},\n OutProps = {}\n> = Composables & ComposableComponent<Name, Wrapper, InProps, OutProps>;\n\nexport type AnyComposableComponent = ComposableComponent<\n string,\n any,\n InPropsObject,\n any\n>;\n\n/**\n * Minimal callable shape shared by layout and preset composables.\n * Used as the record value so preset components keep their own prop types.\n */\nexport type ComposableComponentCallable = {\n displayName: string;\n props: unknown;\n (...args: any[]): ReactNode;\n};\n\n// Separate installed versions declare distinct unique symbols for the same\n// Symbol.for key. Read the metadata structurally so their presets interoperate.\ntype PresetPropsFromMetadata<Component> = {\n [Key in keyof Component]-?: Key extends symbol\n ? Component[Key] extends ComposablePresetMeta<infer Props>\n ? Props\n : never\n : never;\n}[keyof Component];\n\nexport type PresetPropsFromComposable<Component> = Component extends {\n [composablePresetMetaKey]: ComposablePresetMeta<infer Props>;\n}\n ? Props\n : [PresetPropsFromMetadata<Component>] extends [never]\n ? {}\n : PresetPropsFromMetadata<Component>;\n\nexport type MergePresetProps<Composables extends ComposableComponents> = Show<\n UnionToIntersection<PresetPropsFromComposable<Composables[keyof Composables]>>\n>;\n\nexport type RequiredPresetRenderProps<Props extends InPropsObject> = {\n [K in keyof ResolveProps<Props> & string]-?: ResolveProps<Props>[K];\n};\n\nexport type ComposablePresetComponentCallProps<\n Props extends InPropsObject,\n Wrapper = undefined\n> = WithChildren<RequiredPresetRenderProps<Props>> &\n (Wrapper extends undefined ? {} : ComposableComponentWrapperProps<Wrapper>);\n\nexport type ComposablePresetComponent<\n Name extends string = string,\n Props extends InPropsObject = InPropsObject,\n Wrapper = undefined\n> = BaseComponent<Name, Show<WithChildren<ResolveProps<Props>>>> & {\n [composablePresetMetaKey]: ComposablePresetMeta<Props>;\n} & ((props: ComposablePresetComponentCallProps<Props, Wrapper>) => ReactNode);\n\ntype PresetPropDefinitions<Composables extends ComposableComponents> =\n MergePresetProps<Composables> extends InPropsObject\n ? MergePresetProps<Composables>\n : {};\n\nexport type RequiredPresetLayoutProps<\n Composables extends ComposableComponents\n> = {\n [K in keyof ResolveLayoutProps<PresetPropDefinitions<Composables>> &\n string]-?: ResolveLayoutProps<PresetPropDefinitions<Composables>>[K];\n};\n\nexport type ComposableComponents = Record<string, ComposableComponentCallable>;\n\nexport type ResolvedComposableComponents<\n Components extends ComposableComponents\n> = [keyof Components] extends [never]\n ? never\n : Components extends { Layout: infer _ }\n ? Components\n : 'The Layout composable is required';\n\nfunction resolveComponent<Props>(\n component: ((props: Props) => JSX.Element | ReactNode) | ReactNode,\n props: Props\n) {\n return typeof component === 'function' ? component(props) : component;\n}\n\nfunction reactNodeFromSingleFieldOutProps(resolved: unknown): ReactNode {\n if (resolved === null || typeof resolved !== 'object') {\n return null;\n }\n\n const values = Object.values(resolved);\n\n if (values.length !== 1) {\n return null;\n }\n\n return values[0] as ReactNode;\n}\n\nfunction resolveComposableComponentName<\n Name extends string,\n Resource extends string,\n LayoutName extends string\n>(\n name: ComposableComponentName<Name, Resource, LayoutName>,\n ctx: ComposableNameContext<Resource, LayoutName>\n): Name {\n return typeof name === 'function' ? name(ctx) : name;\n}\n\nexport function createLayoutComposableFactory<\n Resources extends string,\n LayoutName extends string\n>(ctx: ComposableNameContext<Resources, LayoutName>) {\n const create: CreateLayoutComposable<Resources, LayoutName> = <\n const Name extends string,\n Wrapper,\n InProps extends InPropsObject = {},\n OutProps = {}\n >(\n options: CreateComposableComponentOptions<\n Name,\n Wrapper,\n Resources,\n LayoutName,\n InProps,\n OutProps\n >\n ) =>\n createComposableComponent({\n ...options,\n name: resolveComposableComponentName(options.name, ctx),\n } as ResolvedCreateComposableComponentOptions<Name, Wrapper, Resources, LayoutName, InProps, OutProps>);\n\n return create;\n}\n\nexport function resolveLayoutComposables<\n Resources extends string,\n LayoutName extends string,\n Composables extends ComposableComponents\n>(\n factory: (\n create: CreateLayoutComposable<Resources, LayoutName>\n ) => Composables,\n ctx: ComposableNameContext<Resources, LayoutName>\n): Composables {\n return factory(createLayoutComposableFactory(ctx));\n}\n\nexport function createComposableComponent<\n const Name extends string,\n Wrapper,\n InProps extends InPropsObject = {},\n OutProps = {}\n>(\n options: ResolvedCreateComposableComponentOptions<\n Name,\n Wrapper,\n string,\n string,\n InProps,\n OutProps\n >\n) {\n const { name, inProps = {} as InProps, outProps, wrapWith } = options;\n\n function Composable({\n children,\n ...props\n }: ComposableComponentProps<Wrapper, InProps, OutProps>) {\n const inPropsKeys = Object.keys(inProps as object) as (keyof InProps &\n string)[];\n const mergedInProps = { ...inProps };\n const propsRecord = props as Record<string, unknown>;\n\n for (const key of inPropsKeys) {\n if (key in propsRecord) {\n (mergedInProps as Record<string, unknown>)[key] = propsRecord[key];\n }\n }\n\n const wrapperProps = {\n ...propsRecord,\n } as ComposableComponentWrapperProps<Wrapper>;\n\n for (const key of inPropsKeys) {\n delete (wrapperProps as Record<string, unknown>)[key];\n }\n\n const mergedResolved = resolvePropDefinitionValues(\n mergedInProps as Record<string, unknown>\n ) as Show<ResolveProps<InProps>>;\n\n const resolvedProps = outProps\n ? outProps(mergedResolved)\n : ({} as OutProps);\n const resolvedChildren =\n children == null\n ? reactNodeFromSingleFieldOutProps(resolvedProps)\n : resolveComponent(children, resolvedProps);\n\n if (wrapWith) {\n const Comp = wrapWith as ComponentType<\n ComposableComponentWrapperProps<Wrapper>\n >;\n\n return <Comp {...wrapperProps}>{resolvedChildren}</Comp>;\n }\n\n // A single intrinsic child is the composable's root without adding a wrapper.\n if (propsRecord['data-rl-node'] && isValidElement(resolvedChildren) && typeof resolvedChildren.type === 'string') {\n return cloneElement(resolvedChildren, {\n 'data-rl-node': propsRecord['data-rl-node'],\n 'data-rl-composable': propsRecord['data-rl-composable'],\n 'data-rl-owners': propsRecord['data-rl-owners'],\n } as Record<string, unknown>);\n }\n return resolvedChildren;\n }\n\n Composable.displayName = name;\n\n const debugKey = Symbol.for('@jfdevelops/react-layout/debug');\n const debug = (options as unknown as Record<symbol, unknown>)[debugKey];\n\n return Object.assign(Composable, {\n ...(debug ? { [debugKey]: debug } : {}),\n props: undefined as unknown as ResolveProps<InProps>,\n }) as unknown as ComposableComponent<Name, Wrapper, InProps, OutProps>;\n}\n\ntype DefineComposableComponentOptions<\n Name extends string,\n Props extends InPropsObject,\n Wrapper = undefined\n> = {\n name: Name;\n props?: Props;\n wrapWith?: Wrapper;\n};\n\nexport type DefinedComposableComponentRecord<\n Name extends string,\n Props extends InPropsObject = {},\n Wrapper = undefined\n> = {\n [K in Name]: ComposablePresetComponent<Name, Props, Wrapper>;\n};\n\ntype DefinedComposableComponentFactory<\n Name extends string,\n Props extends InPropsObject,\n Wrapper = undefined,\n> = {\n props: Props;\n (\n render: (props: Show<WithChildren<ResolveProps<Props>>>) => ReactNode,\n ): DefinedComposableComponentRecord<Name, Props, Wrapper>;\n /** Customize this instance without changing the factory's defaults. */\n <\n const Overrides extends InPropsObject = {},\n const CustomName extends string = Name,\n CustomWrapper = Wrapper,\n >(options: {\n name?: CustomName;\n props?: Overrides | ((defaults: Props) => Overrides);\n wrapWith?: CustomWrapper;\n render: (\n props: Show<\n WithChildren<ResolveProps<Omit<Props, keyof Overrides> & Overrides>>\n >,\n ) => ReactNode;\n }): DefinedComposableComponentRecord<\n CustomName,\n Omit<Props, keyof Overrides> & Overrides,\n CustomWrapper\n >;\n};\n\nfunction resolvePresetComposableCallProps<Props extends InPropsObject>(\n presetKey: string,\n propDefinitions: Props,\n callProps: Record<string, unknown>\n) {\n const presetKeys = Object.keys(propDefinitions) as (keyof Props & string)[];\n const contextValues = useComposablePresetProps(presetKey) ?? {};\n const presetValues = Object.fromEntries(\n presetKeys.map((key) => [key, callProps[key] ?? contextValues[key]])\n );\n\n return validateProps(\n propDefinitions as Record<string, AnyBuiltPropDefinition>,\n presetValues\n ) as Show<WithChildren<ResolveProps<Props>>>;\n}\n\nexport function defineComposableComponent<\n const Name extends string,\n Props extends InPropsObject = {},\n Wrapper = undefined\n>(\n options: DefineComposableComponentOptions<Name, Props, Wrapper>\n): DefinedComposableComponentFactory<Name, Props, Wrapper> {\n const { name, props = {} as Props, wrapWith } = options;\n\n const factory = (\n definition:\n | ((props: Show<WithChildren<ResolveProps<Props>>>) => ReactNode)\n | {\n name?: string;\n props?: InPropsObject | ((defaults: Props) => InPropsObject);\n wrapWith?: unknown;\n render: (props: any) => ReactNode;\n }\n ): DefinedComposableComponentRecord<Name, Props, Wrapper> => {\n if (typeof definition !== 'function') {\n const overrides =\n typeof definition.props === 'function'\n ? definition.props(props)\n : definition.props;\n\n return defineComposableComponent({\n ...options,\n name: definition.name ?? name,\n props: { ...props, ...overrides },\n wrapWith: 'wrapWith' in definition ? definition.wrapWith : wrapWith,\n })(definition.render) as unknown as DefinedComposableComponentRecord<\n Name,\n Props,\n Wrapper\n >;\n }\n\n const render = definition;\n const component = createComposableComponent<\n Name,\n Wrapper,\n Props,\n Show<WithChildren<ResolveProps<Props>>>\n >({\n name,\n wrapWith,\n inProps: props,\n outProps: (resolved) => resolved,\n });\n\n function PresetComposable(\n callProps: ComposablePresetComponentCallProps<Props, Wrapper>\n ) {\n const callPropsRecord = callProps as Record<string, unknown>;\n const presetKeys = Object.keys(props) as (keyof Props & string)[];\n const validatedPresetProps = resolvePresetComposableCallProps(\n name,\n props,\n callPropsRecord\n );\n const wrapperProps = { ...callPropsRecord };\n\n for (const key of presetKeys) {\n delete wrapperProps[key];\n }\n\n return component({\n ...(wrapperProps as ComposableComponentWrapperProps<Wrapper>),\n ...validatedPresetProps,\n children: (resolved: Show<WithChildren<ResolveProps<Props>>>) => render({\n ...resolved,\n children: 'children' in props\n ? (validatedPresetProps as Record<string, unknown>).children\n : callPropsRecord.children,\n } as Show<WithChildren<ResolveProps<Props>>>),\n } as unknown as ComposableComponentProps<Wrapper, Props, Show<WithChildren<ResolveProps<Props>>>>);\n }\n\n PresetComposable.displayName = name;\n\n const debugKey = Symbol.for('@jfdevelops/react-layout/debug');\n const debug = (options as unknown as Record<symbol, unknown>)[debugKey];\n const presetComponent = Object.assign(PresetComposable, {\n ...(debug ? { [debugKey]: debug } : {}),\n props: undefined as unknown as Show<WithChildren<ResolveProps<Props>>>,\n [composablePresetMetaKey]: {\n key: name,\n props,\n } satisfies ComposablePresetMeta<Props>,\n }) as unknown as DefinedComposableComponentRecord<\n Name,\n Props,\n Wrapper\n >[Name];\n\n return {\n [name]: presetComponent,\n } as DefinedComposableComponentRecord<Name, Props, Wrapper>;\n };\n\n Object.defineProperty(factory, 'props', {\n enumerable: true,\n value: props,\n });\n\n return factory as DefinedComposableComponentFactory<Name, Props, Wrapper>;\n}\n\nexport type MakeComposableOptions<\n Composables extends ComposableComponents,\n Name extends string\n> = { components: Composables | undefined; name: Name };\n\nexport type MakeComposable<\n Composables extends ComposableComponents,\n Name extends string\n> = <OverrideName extends string = Name>(\n options?: Partial<\n Pick<MakeComposableOptions<Composables, OverrideName>, 'name'>\n >\n) => ComposableResourceLayout<Composables, Name, any, any, any>;\n\nexport function makeComposable<Props>() {\n return function <\n Composables extends ComposableComponents,\n Name extends string\n >(options: MakeComposableOptions<Composables, Name>) {\n const { components, name: layoutName } = options;\n\n if (!components || typeof components !== 'object') {\n throw new InvalidComponentsError('components must be an object');\n }\n\n const componentNames = Object.keys(components);\n\n if (componentNames.length === 0) {\n throw new EmptyComponentsError(\n 'components must have at least one component'\n );\n }\n\n const create: MakeComposable<Composables, Name> = (overrideOptions) => {\n const resolvedName = overrideOptions?.name ?? layoutName;\n const { Layout, ...rest } = components;\n\n return Object.assign(Layout, {\n displayName: resolvedName,\n props: undefined as unknown as Props,\n ...rest,\n }) as unknown as ComposableResourceLayout<\n Composables,\n Name,\n any,\n any,\n any\n >;\n };\n\n return create;\n };\n}\n"],"mappings":";;;;;;AAcA,MAAa,0BAA0B,OAAO,IAC5C,iCACF;AAUA,MAAM,wDAEJ,MAAS;AAEX,SAAgB,+BAA+B,EAC7C,OACA,YAIC;CACD,OACE,2CAAC,6BAA6B,UAA9B;EAA8C;EAC3C;CACoC;AAE3C;AAEA,SAAS,yBAAyB,KAAa;CAC7C,6BAAkB,4BAA4B,IAAI;AACpD;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,UAElB,EAAE,WAAW,GAC5B,MAAM,IAAIC,oCACR,6CACF;EAGF,MAAM,UAA6C,oBAAoB;GACrE,MAAM,eAAe,iBAAiB,QAAQ;GAC9C,MAAM,EAAE,QAAQ,GAAG,SAAS;GAE5B,OAAO,OAAO,OAAO,QAAQ;IAC3B,aAAa;IACb,OAAO;IACP,GAAG;GACL,CAAC;EAOH;EAEA,OAAO;CACT;AACF"}
|
|
1
|
+
{"version":3,"file":"composable.cjs","names":["Comp","InvalidComponentsError","EmptyComponentsError"],"sources":["../src/composable.tsx"],"sourcesContent":["import { ComponentType, createContext, ReactNode, useContext, cloneElement, isValidElement } from 'react';\nimport { EmptyComponentsError, InvalidComponentsError } from './errors';\nimport {\n AnyBuiltPropDefinition,\n type PropValidationContext,\n ResolveLayoutProps,\n ResolveProps,\n ResolveInputProps,\n ResolveLayoutInputProps,\n type StandardSchemaV1,\n isStandardSchema,\n resolvePropDefinitionValues,\n validateProps,\n} from '@jfdevelops/react-layout-validator';\nimport { InPropsObject, type WithChildren } from './types';\nimport { BaseComponent, Show, UnionToIntersection } from './utils';\nimport { CapitalizeFn } from './utils/capitalize';\n\nexport const composablePresetMetaKey = Symbol.for(\n 'view-map.composable-preset-meta'\n);\n\nconst validatedComposableProps = Symbol('validatedComposableProps');\n\nexport type ComposablePresetMeta<Props extends InPropsObject = InPropsObject> =\n {\n key: string;\n props: Props;\n };\n\nexport type ComposablePresetProps = Record<string, Record<string, unknown>>;\n\nconst composablePresetPropsContext = createContext<\n ComposablePresetProps | undefined\n>(undefined);\n\nexport function LayoutComposablePresetProvider({\n value,\n children,\n}: {\n value: ComposablePresetProps;\n children: ReactNode;\n}) {\n return (\n <composablePresetPropsContext.Provider value={value}>\n {children}\n </composablePresetPropsContext.Provider>\n );\n}\n\nfunction useComposablePresetProps(key: string) {\n return useContext(composablePresetPropsContext)?.[key];\n}\n\nexport function collectComposablePresetEntries(\n composables: ComposableComponents | undefined\n) {\n if (!composables) {\n return [] as Array<{\n key: string;\n props: InPropsObject;\n }>;\n }\n\n return Object.entries(composables).flatMap(([objectKey, component]) => {\n const meta = (component as ComposablePresetComponent)[\n composablePresetMetaKey\n ];\n\n if (!meta) {\n return [];\n }\n\n return [\n {\n key: meta.key ?? objectKey,\n props: meta.props,\n },\n ];\n });\n}\n\nexport function resolveComposablePresetProps(\n composables: ComposableComponents | undefined,\n layoutOptions: Record<string, unknown>,\n context?: PropValidationContext\n) {\n const resolved: ComposablePresetProps = {};\n\n for (const { key, props } of collectComposablePresetEntries(composables)) {\n const propKeys = Object.keys(props);\n const values = Object.fromEntries(\n propKeys.flatMap((propKey) => {\n if (!(propKey in layoutOptions)) {\n return [];\n }\n\n return [[propKey, layoutOptions[propKey]]];\n })\n );\n\n resolved[key] = validateProps(\n props as Record<string, AnyBuiltPropDefinition>,\n values,\n context\n );\n }\n\n return resolved;\n}\n\nexport type ComposableNameContext<\n Resource extends string,\n LayoutName extends string = string\n> = {\n resource: Resource;\n name: LayoutName;\n capitalize: CapitalizeFn;\n};\n\ntype ComposableComponentName<\n Name extends string,\n Resource extends string,\n LayoutName extends string = string\n> = Name | ((ctx: ComposableNameContext<Resource, LayoutName>) => Name);\n\ntype CreateComposableComponentOptions<\n Name extends string,\n Wrapper,\n Resource extends string,\n LayoutName extends string = string,\n InProps extends InPropsObject = {},\n OutProps = {}\n> = {\n name: ComposableComponentName<Name, Resource, LayoutName>;\n inProps?: InProps;\n outProps?: (props: Show<ResolveProps<InProps>>) => OutProps;\n wrapWith?: Wrapper;\n};\n\ntype ResolvedCreateComposableComponentOptions<\n Name extends string,\n Wrapper,\n Resource extends string,\n LayoutName extends string = string,\n InProps extends InPropsObject = {},\n OutProps = {}\n> = Omit<\n CreateComposableComponentOptions<\n Name,\n Wrapper,\n Resource,\n LayoutName,\n InProps,\n OutProps\n >,\n 'name'\n> & {\n name: Name;\n};\n\nexport type CreateLayoutComposable<\n Resources extends string,\n LayoutName extends string = string\n> = <\n const Name extends string,\n Wrapper,\n InProps extends InPropsObject = {},\n OutProps = {}\n>(\n options: CreateComposableComponentOptions<\n Name,\n Wrapper,\n Resources,\n LayoutName,\n InProps,\n OutProps\n >\n) => ComposableComponent<Name, Wrapper, InProps, OutProps>;\n\nexport type LayoutComposablesFactory<\n Resources extends string,\n LayoutName extends string = string\n> = (\n create: CreateLayoutComposable<Resources, LayoutName>\n) => ComposableComponents;\n\nexport type ResolveLayoutComposables<\n Factory extends LayoutComposablesFactory<string> | undefined\n> = Factory extends LayoutComposablesFactory<string> ? ReturnType<Factory> : {};\n\ntype ComposableComponentWrapperProps<Wrapper> = Wrapper extends ComponentType<\n infer Props\n>\n ? Omit<Props, 'children'>\n : {};\n\ntype ComposableComponentProps<\n Wrapper,\n InProps extends InPropsObject = {},\n OutProps = {}\n> = ComposableComponentWrapperProps<Wrapper> &\n (keyof InProps extends never ? {} : ResolveInputProps<InProps>) & {\n children?: [keyof InProps] extends [never]\n ? ReactNode\n : ((props: OutProps) => JSX.Element) | ReactNode;\n };\n\nexport type ComposableComponent<\n Name extends string,\n Wrapper,\n InProps extends InPropsObject = {},\n OutProps = {}\n> = BaseComponent<Name, ResolveInputProps<InProps>> & {\n (props: ComposableComponentProps<Wrapper, InProps, OutProps>): ReactNode;\n};\n\nexport type ComposableResourceLayout<\n Composables extends ComposableComponents,\n Name extends string,\n Wrapper,\n InProps extends InPropsObject = {},\n OutProps = {}\n> = Composables & ComposableComponent<Name, Wrapper, InProps, OutProps>;\n\nexport type AnyComposableComponent = ComposableComponent<\n string,\n any,\n InPropsObject,\n any\n>;\n\n/**\n * Minimal callable shape shared by layout and preset composables.\n * Used as the record value so preset components keep their own prop types.\n */\nexport type ComposableComponentCallable = {\n displayName: string;\n props: unknown;\n (...args: any[]): ReactNode;\n};\n\n// Separate installed versions declare distinct unique symbols for the same\n// Symbol.for key. Read the metadata structurally so their presets interoperate.\ntype PresetPropsFromMetadata<Component> = {\n [Key in keyof Component]-?: Key extends symbol\n ? Component[Key] extends ComposablePresetMeta<infer Props>\n ? Props\n : never\n : never;\n}[keyof Component];\n\nexport type PresetPropsFromComposable<Component> = Component extends {\n [composablePresetMetaKey]: ComposablePresetMeta<infer Props>;\n}\n ? Props\n : [PresetPropsFromMetadata<Component>] extends [never]\n ? {}\n : PresetPropsFromMetadata<Component>;\n\nexport type MergePresetProps<Composables extends ComposableComponents> = Show<\n UnionToIntersection<PresetPropsFromComposable<Composables[keyof Composables]>>\n>;\n\nexport type RequiredPresetRenderProps<Props extends InPropsObject> = {\n [K in keyof ResolveProps<Props> & string]-?: ResolveProps<Props>[K];\n};\n\ntype SchemaDefinitions<Props extends InPropsObject> = {\n [Key in keyof Props as Props[Key] extends StandardSchemaV1 ? Key : never]: Props[Key];\n};\n\ntype PresetInputProps<Props extends InPropsObject> =\n ResolveInputProps<SchemaDefinitions<Props>> &\n RequiredPresetRenderProps<Omit<Props, keyof SchemaDefinitions<Props>>>;\n\nexport type ComposablePresetComponentCallProps<\n Props extends InPropsObject,\n Wrapper = undefined\n> = WithChildren<PresetInputProps<Props>> &\n (Wrapper extends undefined ? {} : ComposableComponentWrapperProps<Wrapper>);\n\nexport type ComposablePresetComponent<\n Name extends string = string,\n Props extends InPropsObject = InPropsObject,\n Wrapper = undefined\n> = BaseComponent<Name, Show<WithChildren<ResolveInputProps<Props>>>> & {\n [composablePresetMetaKey]: ComposablePresetMeta<Props>;\n} & ((props: ComposablePresetComponentCallProps<Props, Wrapper>) => ReactNode);\n\ntype PresetPropDefinitions<Composables extends ComposableComponents> =\n MergePresetProps<Composables> extends InPropsObject\n ? MergePresetProps<Composables>\n : {};\n\ntype PresetLayoutInputProps<Props extends InPropsObject> =\n ResolveLayoutInputProps<SchemaDefinitions<Props>> & {\n [Key in keyof ResolveLayoutProps<Omit<Props, keyof SchemaDefinitions<Props>>>]-?:\n ResolveLayoutProps<Omit<Props, keyof SchemaDefinitions<Props>>>[Key];\n };\n\nexport type RequiredPresetLayoutProps<Composables extends ComposableComponents> =\n PresetLayoutInputProps<PresetPropDefinitions<Composables>>;\n\nexport type ComposableComponents = Record<string, ComposableComponentCallable>;\n\nexport type ResolvedComposableComponents<\n Components extends ComposableComponents\n> = [keyof Components] extends [never]\n ? never\n : Components extends { Layout: infer _ }\n ? Components\n : 'The Layout composable is required';\n\nfunction resolveComponent<Props>(\n component: ((props: Props) => JSX.Element | ReactNode) | ReactNode,\n props: Props\n) {\n return typeof component === 'function' ? component(props) : component;\n}\n\nfunction reactNodeFromSingleFieldOutProps(resolved: unknown): ReactNode {\n if (resolved === null || typeof resolved !== 'object') {\n return null;\n }\n\n const values = Object.values(resolved);\n\n if (values.length !== 1) {\n return null;\n }\n\n return values[0] as ReactNode;\n}\n\nfunction resolveComposableComponentName<\n Name extends string,\n Resource extends string,\n LayoutName extends string\n>(\n name: ComposableComponentName<Name, Resource, LayoutName>,\n ctx: ComposableNameContext<Resource, LayoutName>\n): Name {\n return typeof name === 'function' ? name(ctx) : name;\n}\n\nexport function createLayoutComposableFactory<\n Resources extends string,\n LayoutName extends string\n>(ctx: ComposableNameContext<Resources, LayoutName>) {\n const create: CreateLayoutComposable<Resources, LayoutName> = <\n const Name extends string,\n Wrapper,\n InProps extends InPropsObject = {},\n OutProps = {}\n >(\n options: CreateComposableComponentOptions<\n Name,\n Wrapper,\n Resources,\n LayoutName,\n InProps,\n OutProps\n >\n ) =>\n createComposableComponent({\n ...options,\n name: resolveComposableComponentName(options.name, ctx),\n } as ResolvedCreateComposableComponentOptions<Name, Wrapper, Resources, LayoutName, InProps, OutProps>);\n\n return create;\n}\n\nexport function resolveLayoutComposables<\n Resources extends string,\n LayoutName extends string,\n Composables extends ComposableComponents\n>(\n factory: (\n create: CreateLayoutComposable<Resources, LayoutName>\n ) => Composables,\n ctx: ComposableNameContext<Resources, LayoutName>\n): Composables {\n return factory(createLayoutComposableFactory(ctx));\n}\n\nexport function createComposableComponent<\n const Name extends string,\n Wrapper,\n InProps extends InPropsObject = {},\n OutProps = {}\n>(\n options: ResolvedCreateComposableComponentOptions<\n Name,\n Wrapper,\n string,\n string,\n InProps,\n OutProps\n >\n) {\n const { name, inProps = {} as InProps, outProps, wrapWith } = options;\n\n function Composable({\n children,\n ...props\n }: ComposableComponentProps<Wrapper, InProps, OutProps>) {\n const inPropsKeys = Object.keys(inProps as object) as (keyof InProps &\n string)[];\n const mergedInProps = { ...inProps };\n const propsRecord = props as Record<string, unknown>;\n\n for (const key of inPropsKeys) {\n if (key in propsRecord) {\n (mergedInProps as Record<string, unknown>)[key] = propsRecord[key];\n }\n }\n\n const wrapperProps = {\n ...propsRecord,\n } as ComposableComponentWrapperProps<Wrapper>;\n\n for (const key of inPropsKeys) {\n delete (wrapperProps as Record<string, unknown>)[key];\n }\n\n const mergedValues = resolvePropDefinitionValues(mergedInProps as Record<string, unknown>);\n const alreadyValidated = (options as unknown as Record<symbol, unknown>)[validatedComposableProps];\n const schemaDefinitions = alreadyValidated ? {} : Object.fromEntries(\n Object.entries(inProps ?? {}).filter(([, definition]) => isStandardSchema(definition)),\n );\n const mergedResolved = validateProps(schemaDefinitions, mergedValues) as Show<ResolveProps<InProps>>;\n\n const resolvedProps = outProps\n ? outProps(mergedResolved)\n : ({} as OutProps);\n const resolvedChildren =\n children == null\n ? reactNodeFromSingleFieldOutProps(resolvedProps)\n : resolveComponent(children, resolvedProps);\n\n if (wrapWith) {\n const Comp = wrapWith as ComponentType<\n ComposableComponentWrapperProps<Wrapper>\n >;\n\n return <Comp {...wrapperProps}>{resolvedChildren}</Comp>;\n }\n\n // A single intrinsic child is the composable's root without adding a wrapper.\n if (propsRecord['data-rl-node'] && isValidElement(resolvedChildren) && typeof resolvedChildren.type === 'string') {\n return cloneElement(resolvedChildren, {\n 'data-rl-node': propsRecord['data-rl-node'],\n 'data-rl-composable': propsRecord['data-rl-composable'],\n 'data-rl-owners': propsRecord['data-rl-owners'],\n } as Record<string, unknown>);\n }\n return resolvedChildren;\n }\n\n Composable.displayName = name;\n\n const debugKey = Symbol.for('@jfdevelops/react-layout/debug');\n const debug = (options as unknown as Record<symbol, unknown>)[debugKey];\n\n return Object.assign(Composable, {\n ...(debug ? { [debugKey]: debug } : {}),\n props: undefined as unknown as ResolveProps<InProps>,\n }) as unknown as ComposableComponent<Name, Wrapper, InProps, OutProps>;\n}\n\ntype DefineComposableComponentOptions<\n Name extends string,\n Props extends InPropsObject,\n Wrapper = undefined\n> = {\n name: Name;\n props?: Props;\n wrapWith?: Wrapper;\n};\n\nexport type DefinedComposableComponentRecord<\n Name extends string,\n Props extends InPropsObject = {},\n Wrapper = undefined\n> = {\n [K in Name]: ComposablePresetComponent<Name, Props, Wrapper>;\n};\n\ntype DefinedComposableComponentFactory<\n Name extends string,\n Props extends InPropsObject,\n Wrapper = undefined,\n> = {\n props: Props;\n (\n render: (props: Show<WithChildren<ResolveProps<Props>>>) => ReactNode,\n ): DefinedComposableComponentRecord<Name, Props, Wrapper>;\n /** Customize this instance without changing the factory's defaults. */\n <\n const Overrides extends InPropsObject = {},\n const CustomName extends string = Name,\n CustomWrapper = Wrapper,\n >(options: {\n name?: CustomName;\n props?: Overrides | ((defaults: Props) => Overrides);\n wrapWith?: CustomWrapper;\n render: (\n props: Show<\n WithChildren<ResolveProps<Omit<Props, keyof Overrides> & Overrides>>\n >,\n ) => ReactNode;\n }): DefinedComposableComponentRecord<\n CustomName,\n Omit<Props, keyof Overrides> & Overrides,\n CustomWrapper\n >;\n};\n\nfunction resolvePresetComposableCallProps<Props extends InPropsObject>(\n presetKey: string,\n propDefinitions: Props,\n callProps: Record<string, unknown>\n) {\n const presetKeys = Object.keys(propDefinitions) as (keyof Props & string)[];\n const contextValues = useComposablePresetProps(presetKey) ?? {};\n const presetValues = Object.fromEntries(\n presetKeys.map((key) => [key,\n isStandardSchema(propDefinitions[key]) && Object.hasOwn(callProps, key)\n ? callProps[key]\n : callProps[key] ?? contextValues[key],\n ])\n );\n // Context values have already been validated by the owning layout.\n const definitions = Object.fromEntries(\n Object.entries(propDefinitions).filter(([key, definition]) =>\n !isStandardSchema(definition) || Object.hasOwn(callProps, key) || !Object.hasOwn(contextValues, key),\n ),\n );\n\n return validateProps(\n definitions,\n presetValues\n ) as Show<WithChildren<ResolveProps<Props>>>;\n}\n\nexport function defineComposableComponent<\n const Name extends string,\n Props extends InPropsObject = {},\n Wrapper = undefined\n>(\n options: DefineComposableComponentOptions<Name, Props, Wrapper>\n): DefinedComposableComponentFactory<Name, Props, Wrapper> {\n const { name, props = {} as Props, wrapWith } = options;\n\n const factory = (\n definition:\n | ((props: Show<WithChildren<ResolveProps<Props>>>) => ReactNode)\n | {\n name?: string;\n props?: InPropsObject | ((defaults: Props) => InPropsObject);\n wrapWith?: unknown;\n render: (props: any) => ReactNode;\n }\n ): DefinedComposableComponentRecord<Name, Props, Wrapper> => {\n if (typeof definition !== 'function') {\n const overrides =\n typeof definition.props === 'function'\n ? definition.props(props)\n : definition.props;\n\n return defineComposableComponent({\n ...options,\n name: definition.name ?? name,\n props: { ...props, ...overrides },\n wrapWith: 'wrapWith' in definition ? definition.wrapWith : wrapWith,\n })(definition.render) as unknown as DefinedComposableComponentRecord<\n Name,\n Props,\n Wrapper\n >;\n }\n\n const render = definition;\n const component = createComposableComponent<\n Name,\n Wrapper,\n Props,\n Show<WithChildren<ResolveProps<Props>>>\n >({\n name,\n wrapWith,\n inProps: props,\n outProps: (resolved) => resolved,\n ...{ [validatedComposableProps]: true },\n });\n\n function PresetComposable(\n callProps: ComposablePresetComponentCallProps<Props, Wrapper>\n ) {\n const callPropsRecord = callProps as Record<string, unknown>;\n const presetKeys = Object.keys(props) as (keyof Props & string)[];\n const validatedPresetProps = resolvePresetComposableCallProps(\n name,\n props,\n callPropsRecord\n );\n const wrapperProps = { ...callPropsRecord };\n\n for (const key of presetKeys) {\n delete wrapperProps[key];\n }\n\n return component({\n ...(wrapperProps as ComposableComponentWrapperProps<Wrapper>),\n ...validatedPresetProps,\n children: (resolved: Show<WithChildren<ResolveProps<Props>>>) => render({\n ...resolved,\n children: 'children' in props\n ? (validatedPresetProps as Record<string, unknown>).children\n : callPropsRecord.children,\n } as Show<WithChildren<ResolveProps<Props>>>),\n } as unknown as ComposableComponentProps<Wrapper, Props, Show<WithChildren<ResolveProps<Props>>>>);\n }\n\n PresetComposable.displayName = name;\n\n const debugKey = Symbol.for('@jfdevelops/react-layout/debug');\n const debug = (options as unknown as Record<symbol, unknown>)[debugKey];\n const presetComponent = Object.assign(PresetComposable, {\n ...(debug ? { [debugKey]: debug } : {}),\n props: undefined as unknown as Show<WithChildren<ResolveProps<Props>>>,\n [composablePresetMetaKey]: {\n key: name,\n props,\n } satisfies ComposablePresetMeta<Props>,\n }) as unknown as DefinedComposableComponentRecord<\n Name,\n Props,\n Wrapper\n >[Name];\n\n return {\n [name]: presetComponent,\n } as DefinedComposableComponentRecord<Name, Props, Wrapper>;\n };\n\n Object.defineProperty(factory, 'props', {\n enumerable: true,\n value: props,\n });\n\n return factory as DefinedComposableComponentFactory<Name, Props, Wrapper>;\n}\n\nexport type MakeComposableOptions<\n Composables extends ComposableComponents,\n Name extends string\n> = { components: Composables | undefined; name: Name };\n\nexport type MakeComposable<\n Composables extends ComposableComponents,\n Name extends string\n> = <OverrideName extends string = Name>(\n options?: Partial<\n Pick<MakeComposableOptions<Composables, OverrideName>, 'name'>\n >\n) => ComposableResourceLayout<Composables, Name, any, any, any>;\n\nexport function makeComposable<Props>() {\n return function <\n Composables extends ComposableComponents,\n Name extends string\n >(options: MakeComposableOptions<Composables, Name>) {\n const { components, name: layoutName } = options;\n\n if (!components || typeof components !== 'object') {\n throw new InvalidComponentsError('components must be an object');\n }\n\n const componentNames = Object.keys(components);\n\n if (componentNames.length === 0) {\n throw new EmptyComponentsError(\n 'components must have at least one component'\n );\n }\n\n const create: MakeComposable<Composables, Name> = (overrideOptions) => {\n const resolvedName = overrideOptions?.name ?? layoutName;\n const { Layout, ...rest } = components;\n\n return Object.assign(Layout, {\n displayName: resolvedName,\n props: undefined as unknown as Props,\n ...rest,\n }) as unknown as ComposableResourceLayout<\n Composables,\n Name,\n any,\n any,\n any\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AChB,OAAO,aAAa;GAGtB,OAAO,UAAU;IACf,GAAI;IACJ,GAAG;IACH,WAAW,aAAsD,OAAO;KACtE,GAAG;KACH,UAAU,cAAc,QACnB,qBAAiD,WAClD,gBAAgB;IACtB,CAA4C;GAC9C,CAAiG;EACnG;EAEA,iBAAiB,cAAc;EAE/B,MAAM,WAAW,OAAO,IAAI,gCAAgC;EAC5D,MAAM,QAAS,QAA+C;EAC9D,MAAM,kBAAkB,OAAO,OAAO,kBAAkB;GACtD,GAAI,QAAQ,GAAG,WAAW,MAAM,IAAI,CAAC;GACrC,OAAO;IACN,0BAA0B;IACzB,KAAK;IACL;GACF;EACF,CAAC;EAMD,OAAO,GACJ,OAAO,gBACV;CACF;CAEA,OAAO,eAAe,SAAS,SAAS;EACtC,YAAY;EACZ,OAAO;CACT,CAAC;CAED,OAAO;AACT;AAgBA,SAAgB,iBAAwB;CACtC,OAAO,SAGL,SAAmD;EACnD,MAAM,EAAE,YAAY,MAAM,eAAe;EAEzC,IAAI,CAAC,cAAc,OAAO,eAAe,UACvC,MAAM,IAAIC,sCAAuB,8BAA8B;EAKjE,IAFuB,OAAO,KAAK,UAElB,EAAE,WAAW,GAC5B,MAAM,IAAIC,oCACR,6CACF;EAGF,MAAM,UAA6C,oBAAoB;GACrE,MAAM,eAAe,iBAAiB,QAAQ;GAC9C,MAAM,EAAE,QAAQ,GAAG,SAAS;GAE5B,OAAO,OAAO,OAAO,QAAQ;IAC3B,aAAa;IACb,OAAO;IACP,GAAG;GACL,CAAC;EAOH;EAEA,OAAO;CACT;AACF"}
|
package/dist/composable.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { InPropsObject, WithChildren } from "./types.cjs";
|
|
2
2
|
import { BaseComponent, Show, UnionToIntersection } from "./utils.cjs";
|
|
3
3
|
import { CapitalizeFn } from "./utils/capitalize.cjs";
|
|
4
|
-
import { PropValidationContext, ResolveLayoutProps, ResolveProps } from "@jfdevelops/react-layout-validator";
|
|
4
|
+
import { PropValidationContext, ResolveInputProps, ResolveLayoutInputProps, ResolveLayoutProps, ResolveProps, StandardSchemaV1 } from "@jfdevelops/react-layout-validator";
|
|
5
5
|
import { ComponentType, ReactNode } from "react";
|
|
6
6
|
|
|
7
7
|
//#region src/composable.d.ts
|
|
@@ -42,10 +42,10 @@ type CreateLayoutComposable<Resources extends string, LayoutName extends string
|
|
|
42
42
|
type LayoutComposablesFactory<Resources extends string, LayoutName extends string = string> = (create: CreateLayoutComposable<Resources, LayoutName>) => ComposableComponents;
|
|
43
43
|
type ResolveLayoutComposables<Factory extends LayoutComposablesFactory<string> | undefined> = Factory extends LayoutComposablesFactory<string> ? ReturnType<Factory> : {};
|
|
44
44
|
type ComposableComponentWrapperProps<Wrapper> = Wrapper extends ComponentType<infer Props> ? Omit<Props, 'children'> : {};
|
|
45
|
-
type ComposableComponentProps<Wrapper, InProps extends InPropsObject = {}, OutProps = {}> = ComposableComponentWrapperProps<Wrapper> & (keyof InProps extends never ? {} :
|
|
45
|
+
type ComposableComponentProps<Wrapper, InProps extends InPropsObject = {}, OutProps = {}> = ComposableComponentWrapperProps<Wrapper> & (keyof InProps extends never ? {} : ResolveInputProps<InProps>) & {
|
|
46
46
|
children?: [keyof InProps] extends [never] ? ReactNode : ((props: OutProps) => JSX.Element) | ReactNode;
|
|
47
47
|
};
|
|
48
|
-
type ComposableComponent<Name extends string, Wrapper, InProps extends InPropsObject = {}, OutProps = {}> = BaseComponent<Name,
|
|
48
|
+
type ComposableComponent<Name extends string, Wrapper, InProps extends InPropsObject = {}, OutProps = {}> = BaseComponent<Name, ResolveInputProps<InProps>> & {
|
|
49
49
|
(props: ComposableComponentProps<Wrapper, InProps, OutProps>): ReactNode;
|
|
50
50
|
};
|
|
51
51
|
type ComposableResourceLayout<Composables extends ComposableComponents, Name extends string, Wrapper, InProps extends InPropsObject = {}, OutProps = {}> = Composables & ComposableComponent<Name, Wrapper, InProps, OutProps>;
|
|
@@ -65,12 +65,15 @@ type PresetPropsFromComposable<Component> = Component extends {
|
|
|
65
65
|
} ? Props : [PresetPropsFromMetadata<Component>] extends [never] ? {} : PresetPropsFromMetadata<Component>;
|
|
66
66
|
type MergePresetProps<Composables extends ComposableComponents> = Show<UnionToIntersection<PresetPropsFromComposable<Composables[keyof Composables]>>>;
|
|
67
67
|
type RequiredPresetRenderProps<Props extends InPropsObject> = { [K in keyof ResolveProps<Props> & string]-?: ResolveProps<Props>[K] };
|
|
68
|
-
type
|
|
69
|
-
type
|
|
68
|
+
type SchemaDefinitions<Props extends InPropsObject> = { [Key in keyof Props as Props[Key] extends StandardSchemaV1 ? Key : never]: Props[Key] };
|
|
69
|
+
type PresetInputProps<Props extends InPropsObject> = ResolveInputProps<SchemaDefinitions<Props>> & RequiredPresetRenderProps<Omit<Props, keyof SchemaDefinitions<Props>>>;
|
|
70
|
+
type ComposablePresetComponentCallProps<Props extends InPropsObject, Wrapper = undefined> = WithChildren<PresetInputProps<Props>> & (Wrapper extends undefined ? {} : ComposableComponentWrapperProps<Wrapper>);
|
|
71
|
+
type ComposablePresetComponent<Name extends string = string, Props extends InPropsObject = InPropsObject, Wrapper = undefined> = BaseComponent<Name, Show<WithChildren<ResolveInputProps<Props>>>> & {
|
|
70
72
|
[composablePresetMetaKey]: ComposablePresetMeta<Props>;
|
|
71
73
|
} & ((props: ComposablePresetComponentCallProps<Props, Wrapper>) => ReactNode);
|
|
72
74
|
type PresetPropDefinitions<Composables extends ComposableComponents> = MergePresetProps<Composables> extends InPropsObject ? MergePresetProps<Composables> : {};
|
|
73
|
-
type
|
|
75
|
+
type PresetLayoutInputProps<Props extends InPropsObject> = ResolveLayoutInputProps<SchemaDefinitions<Props>> & { [Key in keyof ResolveLayoutProps<Omit<Props, keyof SchemaDefinitions<Props>>>]-?: ResolveLayoutProps<Omit<Props, keyof SchemaDefinitions<Props>>>[Key] };
|
|
76
|
+
type RequiredPresetLayoutProps<Composables extends ComposableComponents> = PresetLayoutInputProps<PresetPropDefinitions<Composables>>;
|
|
74
77
|
type ComposableComponents = Record<string, ComposableComponentCallable>;
|
|
75
78
|
declare function createLayoutComposableFactory<Resources extends string, LayoutName extends string>(ctx: ComposableNameContext<Resources, LayoutName>): CreateLayoutComposable<Resources, LayoutName>;
|
|
76
79
|
declare function resolveLayoutComposables<Resources extends string, LayoutName extends string, Composables extends ComposableComponents>(factory: (create: CreateLayoutComposable<Resources, LayoutName>) => Composables, ctx: ComposableNameContext<Resources, LayoutName>): Composables;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"composable.d.cts","names":[],"sources":["../src/composable.tsx"],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"composable.d.cts","names":[],"sources":["../src/composable.tsx"],"mappings":";;;;;;;cAkBa,uBAAA;AAAA,KAMD,oBAAA,eAAmC,aAAA,GAAgB,aAAA;EAE3D,GAAA;EACA,KAAA,EAAO,KAAA;AAAA;AAAA,KAGC,qBAAA,GAAwB,MAAM,SAAS,MAAA;AAAA,iBAMnC,8BAAA;EACd,KAAA;EACA;AAAA;EAEA,KAAA,EAAO,qBAAA;EACP,QAAA,EAAU,SAAA;AAAA,gCACX,GAAA,CAAA,OAAA;AAAA,iBAYe,8BAAA,CACd,WAAA,EAAa,oBAAA;;SAKF,aAAa;AAAA;AAAA,iBAsBV,4BAAA,CACd,WAAA,EAAa,oBAAA,cACb,aAAA,EAAe,MAAA,mBACf,OAAA,GAAU,qBAAA,GAAqB,qBAAA;AAAA,KA0BrB,qBAAA;EAIV,QAAA,EAAU,QAAA;EACV,IAAA,EAAM,UAAA;EACN,UAAA,EAAY,YAAA;AAAA;AAAA,KAGT,uBAAA,qFAID,IAAA,KAAS,GAAA,EAAK,qBAAA,CAAsB,QAAA,EAAU,UAAA,MAAgB,IAAA;AAAA,KAE7D,gCAAA,4GAKa,aAAA;EAGhB,IAAA,EAAM,uBAAA,CAAwB,IAAA,EAAM,QAAA,EAAU,UAAA;EAC9C,OAAA,GAAU,OAAA;EACV,QAAA,IAAY,KAAA,E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AA,kBAClB,OAAA,EAChB,OAAA;IACA,IAAA,GAAO,UAAA;IACP,KAAA,GAAQ,SAAA,KAAc,QAAA,EAAU,KAAA,KAAU,SAAA;IAC1C,QAAA,GAAW,aAAA;IACX,MAAA,GACE,KAAA,EAAO,IAAA,CACL,YAAA,CAAa,YAAA,CAAa,IAAA,CAAK,KAAA,QAAa,SAAA,IAAa,SAAA,QAExD,SAAA;EAAA,IACH,gCAAA,CACF,UAAA,EACA,IAAA,CAAK,KAAA,QAAa,SAAA,IAAa,SAAA,EAC/B,aAAA;AAAA;AAAA,iBA+BY,yBAAA,0CAEA,aAAA,4BAGd,OAAA,EAAS,gCAAA,CAAiC,IAAA,EAAM,KAAA,EAAO,OAAA,IACtD,iCAAA,CAAkC,IAAA,EAAM,KAAA,EAAO,OAAA;AAAA,KAuGtC,qBAAA,qBACU,oBAAA;EAEhB,UAAA,EAAY,WAAA;EAAyB,IAAA,EAAM,IAAA;AAAA;AAAA,KAErC,cAAA,qBACU,oBAAA,wDAEa,IAAA,EACjC,OAAA,GAAU,OAAA,CACR,IAAA,CAAK,qBAAA,CAAsB,WAAA,EAAa,YAAA,gBAEvC,wBAAA,CAAyB,WAAA,EAAa,IAAA;AAAA,iBAE3B,cAAA,gCAEQ,oBAAA,uBAEpB,OAAA,EAAS,qBAAA,CAAsB,WAAA,EAAa,IAAA,MAAK,cAAA,CAAA,WAAA,EAAA,IAAA"}
|
package/dist/composable.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { InPropsObject, WithChildren } from "./types.mjs";
|
|
2
2
|
import { BaseComponent, Show, UnionToIntersection } from "./utils.mjs";
|
|
3
3
|
import { CapitalizeFn } from "./utils/capitalize.mjs";
|
|
4
|
-
import { PropValidationContext, ResolveLayoutProps, ResolveProps } from "@jfdevelops/react-layout-validator";
|
|
4
|
+
import { PropValidationContext, ResolveInputProps, ResolveLayoutInputProps, ResolveLayoutProps, ResolveProps, StandardSchemaV1 } from "@jfdevelops/react-layout-validator";
|
|
5
5
|
import { ComponentType, ReactNode } from "react";
|
|
6
6
|
|
|
7
7
|
//#region src/composable.d.ts
|
|
@@ -42,10 +42,10 @@ type CreateLayoutComposable<Resources extends string, LayoutName extends string
|
|
|
42
42
|
type LayoutComposablesFactory<Resources extends string, LayoutName extends string = string> = (create: CreateLayoutComposable<Resources, LayoutName>) => ComposableComponents;
|
|
43
43
|
type ResolveLayoutComposables<Factory extends LayoutComposablesFactory<string> | undefined> = Factory extends LayoutComposablesFactory<string> ? ReturnType<Factory> : {};
|
|
44
44
|
type ComposableComponentWrapperProps<Wrapper> = Wrapper extends ComponentType<infer Props> ? Omit<Props, 'children'> : {};
|
|
45
|
-
type ComposableComponentProps<Wrapper, InProps extends InPropsObject = {}, OutProps = {}> = ComposableComponentWrapperProps<Wrapper> & (keyof InProps extends never ? {} :
|
|
45
|
+
type ComposableComponentProps<Wrapper, InProps extends InPropsObject = {}, OutProps = {}> = ComposableComponentWrapperProps<Wrapper> & (keyof InProps extends never ? {} : ResolveInputProps<InProps>) & {
|
|
46
46
|
children?: [keyof InProps] extends [never] ? ReactNode : ((props: OutProps) => JSX.Element) | ReactNode;
|
|
47
47
|
};
|
|
48
|
-
type ComposableComponent<Name extends string, Wrapper, InProps extends InPropsObject = {}, OutProps = {}> = BaseComponent<Name,
|
|
48
|
+
type ComposableComponent<Name extends string, Wrapper, InProps extends InPropsObject = {}, OutProps = {}> = BaseComponent<Name, ResolveInputProps<InProps>> & {
|
|
49
49
|
(props: ComposableComponentProps<Wrapper, InProps, OutProps>): ReactNode;
|
|
50
50
|
};
|
|
51
51
|
type ComposableResourceLayout<Composables extends ComposableComponents, Name extends string, Wrapper, InProps extends InPropsObject = {}, OutProps = {}> = Composables & ComposableComponent<Name, Wrapper, InProps, OutProps>;
|
|
@@ -65,12 +65,15 @@ type PresetPropsFromComposable<Component> = Component extends {
|
|
|
65
65
|
} ? Props : [PresetPropsFromMetadata<Component>] extends [never] ? {} : PresetPropsFromMetadata<Component>;
|
|
66
66
|
type MergePresetProps<Composables extends ComposableComponents> = Show<UnionToIntersection<PresetPropsFromComposable<Composables[keyof Composables]>>>;
|
|
67
67
|
type RequiredPresetRenderProps<Props extends InPropsObject> = { [K in keyof ResolveProps<Props> & string]-?: ResolveProps<Props>[K] };
|
|
68
|
-
type
|
|
69
|
-
type
|
|
68
|
+
type SchemaDefinitions<Props extends InPropsObject> = { [Key in keyof Props as Props[Key] extends StandardSchemaV1 ? Key : never]: Props[Key] };
|
|
69
|
+
type PresetInputProps<Props extends InPropsObject> = ResolveInputProps<SchemaDefinitions<Props>> & RequiredPresetRenderProps<Omit<Props, keyof SchemaDefinitions<Props>>>;
|
|
70
|
+
type ComposablePresetComponentCallProps<Props extends InPropsObject, Wrapper = undefined> = WithChildren<PresetInputProps<Props>> & (Wrapper extends undefined ? {} : ComposableComponentWrapperProps<Wrapper>);
|
|
71
|
+
type ComposablePresetComponent<Name extends string = string, Props extends InPropsObject = InPropsObject, Wrapper = undefined> = BaseComponent<Name, Show<WithChildren<ResolveInputProps<Props>>>> & {
|
|
70
72
|
[composablePresetMetaKey]: ComposablePresetMeta<Props>;
|
|
71
73
|
} & ((props: ComposablePresetComponentCallProps<Props, Wrapper>) => ReactNode);
|
|
72
74
|
type PresetPropDefinitions<Composables extends ComposableComponents> = MergePresetProps<Composables> extends InPropsObject ? MergePresetProps<Composables> : {};
|
|
73
|
-
type
|
|
75
|
+
type PresetLayoutInputProps<Props extends InPropsObject> = ResolveLayoutInputProps<SchemaDefinitions<Props>> & { [Key in keyof ResolveLayoutProps<Omit<Props, keyof SchemaDefinitions<Props>>>]-?: ResolveLayoutProps<Omit<Props, keyof SchemaDefinitions<Props>>>[Key] };
|
|
76
|
+
type RequiredPresetLayoutProps<Composables extends ComposableComponents> = PresetLayoutInputProps<PresetPropDefinitions<Composables>>;
|
|
74
77
|
type ComposableComponents = Record<string, ComposableComponentCallable>;
|
|
75
78
|
declare function createLayoutComposableFactory<Resources extends string, LayoutName extends string>(ctx: ComposableNameContext<Resources, LayoutName>): CreateLayoutComposable<Resources, LayoutName>;
|
|
76
79
|
declare function resolveLayoutComposables<Resources extends string, LayoutName extends string, Composables extends ComposableComponents>(factory: (create: CreateLayoutComposable<Resources, LayoutName>) => Composables, ctx: ComposableNameContext<Resources, LayoutName>): Composables;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"composable.d.mts","names":[],"sources":["../src/composable.tsx"],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"composable.d.mts","names":[],"sources":["../src/composable.tsx"],"mappings":";;;;;;;cAkBa,uBAAA;AAAA,KAMD,oBAAA,eAAmC,aAAA,GAAgB,aAAA;EAE3D,GAAA;EACA,KAAA,EAAO,KAAA;AAAA;AAAA,KAGC,qBAAA,GAAwB,MAAM,SAAS,MAAA;AAAA,iBAMnC,8BAAA;EACd,KAAA;EACA;AAAA;EAEA,KAAA,EAAO,qBAAA;EACP,QAAA,EAAU,SAAA;AAAA,gCACX,GAAA,CAAA,OAAA;AAAA,iBAYe,8BAAA,CACd,WAAA,EAAa,oBAAA;;SAKF,aAAa;AAAA;AAAA,iBAsBV,4BAAA,CACd,WAAA,EAAa,oBAAA,cACb,aAAA,EAAe,MAAA,mBACf,OAAA,GAAU,qBAAA,GAAqB,qBAAA;AAAA,KA0BrB,qBAAA;EAIV,QAAA,EAAU,QAAA;EACV,IAAA,EAAM,UAAA;EACN,UAAA,EAAY,YAAA;AAAA;AAAA,KAGT,uBAAA,qFAID,IAAA,KAAS,GAAA,EAAK,qBAAA,CAAsB,QAAA,EAAU,UAAA,MAAgB,IAAA;AAAA,KAE7D,gCAAA,4GAKa,aAAA;EAGhB,IAAA,EAAM,uBAAA,CAAwB,IAAA,EAAM,QAAA,EAAU,UAAA;EAC9C,OAAA,GAAU,OAAA;EACV,QAAA,IAAY,KAAA,EAAO,IAAA,CAAK,YAAA,CAAa,OAAA,OAAc,QAAA;EACnD,QAAA,GAAW,OAAA;AAAA;AAAA,KAGR,wCA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,KAAA,KAAU,SAAA;IAC1C,QAAA,GAAW,aAAA;IACX,MAAA,GACE,KAAA,EAAO,IAAA,CACL,YAAA,CAAa,YAAA,CAAa,IAAA,CAAK,KAAA,QAAa,SAAA,IAAa,SAAA,QAExD,SAAA;EAAA,IACH,gCAAA,CACF,UAAA,EACA,IAAA,CAAK,KAAA,QAAa,SAAA,IAAa,SAAA,EAC/B,aAAA;AAAA;AAAA,iBA+BY,yBAAA,0CAEA,aAAA,4BAGd,OAAA,EAAS,gCAAA,CAAiC,IAAA,EAAM,KAAA,EAAO,OAAA,IACtD,iCAAA,CAAkC,IAAA,EAAM,KAAA,EAAO,OAAA;AAAA,KAuGtC,qBAAA,qBACU,oBAAA;EAEhB,UAAA,EAAY,WAAA;EAAyB,IAAA,EAAM,IAAA;AAAA;AAAA,KAErC,cAAA,qBACU,oBAAA,wDAEa,IAAA,EACjC,OAAA,GAAU,OAAA,CACR,IAAA,CAAK,qBAAA,CAAsB,WAAA,EAAa,YAAA,gBAEvC,wBAAA,CAAyB,WAAA,EAAa,IAAA;AAAA,iBAE3B,cAAA,gCAEQ,oBAAA,uBAEpB,OAAA,EAAS,qBAAA,CAAsB,WAAA,EAAa,IAAA,MAAK,cAAA,CAAA,WAAA,EAAA,IAAA"}
|
package/dist/composable.mjs
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { EmptyComponentsError, InvalidComponentsError } from "./errors.mjs";
|
|
2
|
-
import { resolvePropDefinitionValues, validateProps } from "@jfdevelops/react-layout-validator";
|
|
2
|
+
import { isStandardSchema, resolvePropDefinitionValues, validateProps } from "@jfdevelops/react-layout-validator";
|
|
3
3
|
import { cloneElement, createContext, isValidElement, useContext } from "react";
|
|
4
4
|
import { jsx } from "react/jsx-runtime";
|
|
5
5
|
|
|
6
6
|
//#region src/composable.tsx
|
|
7
7
|
const composablePresetMetaKey = Symbol.for("view-map.composable-preset-meta");
|
|
8
|
+
const validatedComposableProps = Symbol("validatedComposableProps");
|
|
8
9
|
const composablePresetPropsContext = createContext(void 0);
|
|
9
10
|
function LayoutComposablePresetProvider({ value, children }) {
|
|
10
11
|
return /* @__PURE__ */ jsx(composablePresetPropsContext.Provider, {
|
|
@@ -65,7 +66,8 @@ function createComposableComponent(options) {
|
|
|
65
66
|
for (const key of inPropsKeys) if (key in propsRecord) mergedInProps[key] = propsRecord[key];
|
|
66
67
|
const wrapperProps = { ...propsRecord };
|
|
67
68
|
for (const key of inPropsKeys) delete wrapperProps[key];
|
|
68
|
-
const
|
|
69
|
+
const mergedValues = resolvePropDefinitionValues(mergedInProps);
|
|
70
|
+
const mergedResolved = validateProps(options[validatedComposableProps] ? {} : Object.fromEntries(Object.entries(inProps ?? {}).filter(([, definition]) => isStandardSchema(definition))), mergedValues);
|
|
69
71
|
const resolvedProps = outProps ? outProps(mergedResolved) : {};
|
|
70
72
|
const resolvedChildren = children == null ? reactNodeFromSingleFieldOutProps(resolvedProps) : resolveComponent(children, resolvedProps);
|
|
71
73
|
if (wrapWith) return /* @__PURE__ */ jsx(wrapWith, {
|
|
@@ -90,7 +92,8 @@ function createComposableComponent(options) {
|
|
|
90
92
|
function resolvePresetComposableCallProps(presetKey, propDefinitions, callProps) {
|
|
91
93
|
const presetKeys = Object.keys(propDefinitions);
|
|
92
94
|
const contextValues = useComposablePresetProps(presetKey) ?? {};
|
|
93
|
-
|
|
95
|
+
const presetValues = Object.fromEntries(presetKeys.map((key) => [key, isStandardSchema(propDefinitions[key]) && Object.hasOwn(callProps, key) ? callProps[key] : callProps[key] ?? contextValues[key]]));
|
|
96
|
+
return validateProps(Object.fromEntries(Object.entries(propDefinitions).filter(([key, definition]) => !isStandardSchema(definition) || Object.hasOwn(callProps, key) || !Object.hasOwn(contextValues, key))), presetValues);
|
|
94
97
|
}
|
|
95
98
|
function defineComposableComponent(options) {
|
|
96
99
|
const { name, props = {}, wrapWith } = options;
|
|
@@ -112,7 +115,8 @@ function defineComposableComponent(options) {
|
|
|
112
115
|
name,
|
|
113
116
|
wrapWith,
|
|
114
117
|
inProps: props,
|
|
115
|
-
outProps: (resolved) => resolved
|
|
118
|
+
outProps: (resolved) => resolved,
|
|
119
|
+
[validatedComposableProps]: true
|
|
116
120
|
});
|
|
117
121
|
function PresetComposable(callProps) {
|
|
118
122
|
const callPropsRecord = callProps;
|
package/dist/composable.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"composable.mjs","names":["Comp"],"sources":["../src/composable.tsx"],"sourcesContent":["import { ComponentType, createContext, ReactNode, useContext, cloneElement, isValidElement } from 'react';\nimport { EmptyComponentsError, InvalidComponentsError } from './errors';\nimport {\n AnyBuiltPropDefinition,\n type PropValidationContext,\n ResolveLayoutProps,\n ResolveProps,\n resolvePropDefinitionValues,\n validateProps,\n} from '@jfdevelops/react-layout-validator';\nimport { InPropsObject, type WithChildren } from './types';\nimport { BaseComponent, Show, UnionToIntersection } from './utils';\nimport { CapitalizeFn } from './utils/capitalize';\n\nexport const composablePresetMetaKey = Symbol.for(\n 'view-map.composable-preset-meta'\n);\n\nexport type ComposablePresetMeta<Props extends InPropsObject = InPropsObject> =\n {\n key: string;\n props: Props;\n };\n\nexport type ComposablePresetProps = Record<string, Record<string, unknown>>;\n\nconst composablePresetPropsContext = createContext<\n ComposablePresetProps | undefined\n>(undefined);\n\nexport function LayoutComposablePresetProvider({\n value,\n children,\n}: {\n value: ComposablePresetProps;\n children: ReactNode;\n}) {\n return (\n <composablePresetPropsContext.Provider value={value}>\n {children}\n </composablePresetPropsContext.Provider>\n );\n}\n\nfunction useComposablePresetProps(key: string) {\n return useContext(composablePresetPropsContext)?.[key];\n}\n\nexport function collectComposablePresetEntries(\n composables: ComposableComponents | undefined\n) {\n if (!composables) {\n return [] as Array<{\n key: string;\n props: InPropsObject;\n }>;\n }\n\n return Object.entries(composables).flatMap(([objectKey, component]) => {\n const meta = (component as ComposablePresetComponent)[\n composablePresetMetaKey\n ];\n\n if (!meta) {\n return [];\n }\n\n return [\n {\n key: meta.key ?? objectKey,\n props: meta.props,\n },\n ];\n });\n}\n\nexport function resolveComposablePresetProps(\n composables: ComposableComponents | undefined,\n layoutOptions: Record<string, unknown>,\n context?: PropValidationContext\n) {\n const resolved: ComposablePresetProps = {};\n\n for (const { key, props } of collectComposablePresetEntries(composables)) {\n const propKeys = Object.keys(props);\n const values = Object.fromEntries(\n propKeys.flatMap((propKey) => {\n if (!(propKey in layoutOptions)) {\n return [];\n }\n\n return [[propKey, layoutOptions[propKey]]];\n })\n );\n\n resolved[key] = validateProps(\n props as Record<string, AnyBuiltPropDefinition>,\n values,\n context\n );\n }\n\n return resolved;\n}\n\nexport type ComposableNameContext<\n Resource extends string,\n LayoutName extends string = string\n> = {\n resource: Resource;\n name: LayoutName;\n capitalize: CapitalizeFn;\n};\n\ntype ComposableComponentName<\n Name extends string,\n Resource extends string,\n LayoutName extends string = string\n> = Name | ((ctx: ComposableNameContext<Resource, LayoutName>) => Name);\n\ntype CreateComposableComponentOptions<\n Name extends string,\n Wrapper,\n Resource extends string,\n LayoutName extends string = string,\n InProps extends InPropsObject = {},\n OutProps = {}\n> = {\n name: ComposableComponentName<Name, Resource, LayoutName>;\n inProps?: InProps;\n outProps?: (props: Show<ResolveProps<InProps>>) => OutProps;\n wrapWith?: Wrapper;\n};\n\ntype ResolvedCreateComposableComponentOptions<\n Name extends string,\n Wrapper,\n Resource extends string,\n LayoutName extends string = string,\n InProps extends InPropsObject = {},\n OutProps = {}\n> = Omit<\n CreateComposableComponentOptions<\n Name,\n Wrapper,\n Resource,\n LayoutName,\n InProps,\n OutProps\n >,\n 'name'\n> & {\n name: Name;\n};\n\nexport type CreateLayoutComposable<\n Resources extends string,\n LayoutName extends string = string\n> = <\n const Name extends string,\n Wrapper,\n InProps extends InPropsObject = {},\n OutProps = {}\n>(\n options: CreateComposableComponentOptions<\n Name,\n Wrapper,\n Resources,\n LayoutName,\n InProps,\n OutProps\n >\n) => ComposableComponent<Name, Wrapper, InProps, OutProps>;\n\nexport type LayoutComposablesFactory<\n Resources extends string,\n LayoutName extends string = string\n> = (\n create: CreateLayoutComposable<Resources, LayoutName>\n) => ComposableComponents;\n\nexport type ResolveLayoutComposables<\n Factory extends LayoutComposablesFactory<string> | undefined\n> = Factory extends LayoutComposablesFactory<string> ? ReturnType<Factory> : {};\n\ntype ComposableComponentWrapperProps<Wrapper> = Wrapper extends ComponentType<\n infer Props\n>\n ? Omit<Props, 'children'>\n : {};\n\ntype ComposableComponentProps<\n Wrapper,\n InProps extends InPropsObject = {},\n OutProps = {}\n> = ComposableComponentWrapperProps<Wrapper> &\n (keyof InProps extends never ? {} : ResolveProps<InProps>) & {\n children?: [keyof InProps] extends [never]\n ? ReactNode\n : ((props: OutProps) => JSX.Element) | ReactNode;\n };\n\nexport type ComposableComponent<\n Name extends string,\n Wrapper,\n InProps extends InPropsObject = {},\n OutProps = {}\n> = BaseComponent<Name, ResolveProps<InProps>> & {\n (props: ComposableComponentProps<Wrapper, InProps, OutProps>): ReactNode;\n};\n\nexport type ComposableResourceLayout<\n Composables extends ComposableComponents,\n Name extends string,\n Wrapper,\n InProps extends InPropsObject = {},\n OutProps = {}\n> = Composables & ComposableComponent<Name, Wrapper, InProps, OutProps>;\n\nexport type AnyComposableComponent = ComposableComponent<\n string,\n any,\n InPropsObject,\n any\n>;\n\n/**\n * Minimal callable shape shared by layout and preset composables.\n * Used as the record value so preset components keep their own prop types.\n */\nexport type ComposableComponentCallable = {\n displayName: string;\n props: unknown;\n (...args: any[]): ReactNode;\n};\n\n// Separate installed versions declare distinct unique symbols for the same\n// Symbol.for key. Read the metadata structurally so their presets interoperate.\ntype PresetPropsFromMetadata<Component> = {\n [Key in keyof Component]-?: Key extends symbol\n ? Component[Key] extends ComposablePresetMeta<infer Props>\n ? Props\n : never\n : never;\n}[keyof Component];\n\nexport type PresetPropsFromComposable<Component> = Component extends {\n [composablePresetMetaKey]: ComposablePresetMeta<infer Props>;\n}\n ? Props\n : [PresetPropsFromMetadata<Component>] extends [never]\n ? {}\n : PresetPropsFromMetadata<Component>;\n\nexport type MergePresetProps<Composables extends ComposableComponents> = Show<\n UnionToIntersection<PresetPropsFromComposable<Composables[keyof Composables]>>\n>;\n\nexport type RequiredPresetRenderProps<Props extends InPropsObject> = {\n [K in keyof ResolveProps<Props> & string]-?: ResolveProps<Props>[K];\n};\n\nexport type ComposablePresetComponentCallProps<\n Props extends InPropsObject,\n Wrapper = undefined\n> = WithChildren<RequiredPresetRenderProps<Props>> &\n (Wrapper extends undefined ? {} : ComposableComponentWrapperProps<Wrapper>);\n\nexport type ComposablePresetComponent<\n Name extends string = string,\n Props extends InPropsObject = InPropsObject,\n Wrapper = undefined\n> = BaseComponent<Name, Show<WithChildren<ResolveProps<Props>>>> & {\n [composablePresetMetaKey]: ComposablePresetMeta<Props>;\n} & ((props: ComposablePresetComponentCallProps<Props, Wrapper>) => ReactNode);\n\ntype PresetPropDefinitions<Composables extends ComposableComponents> =\n MergePresetProps<Composables> extends InPropsObject\n ? MergePresetProps<Composables>\n : {};\n\nexport type RequiredPresetLayoutProps<\n Composables extends ComposableComponents\n> = {\n [K in keyof ResolveLayoutProps<PresetPropDefinitions<Composables>> &\n string]-?: ResolveLayoutProps<PresetPropDefinitions<Composables>>[K];\n};\n\nexport type ComposableComponents = Record<string, ComposableComponentCallable>;\n\nexport type ResolvedComposableComponents<\n Components extends ComposableComponents\n> = [keyof Components] extends [never]\n ? never\n : Components extends { Layout: infer _ }\n ? Components\n : 'The Layout composable is required';\n\nfunction resolveComponent<Props>(\n component: ((props: Props) => JSX.Element | ReactNode) | ReactNode,\n props: Props\n) {\n return typeof component === 'function' ? component(props) : component;\n}\n\nfunction reactNodeFromSingleFieldOutProps(resolved: unknown): ReactNode {\n if (resolved === null || typeof resolved !== 'object') {\n return null;\n }\n\n const values = Object.values(resolved);\n\n if (values.length !== 1) {\n return null;\n }\n\n return values[0] as ReactNode;\n}\n\nfunction resolveComposableComponentName<\n Name extends string,\n Resource extends string,\n LayoutName extends string\n>(\n name: ComposableComponentName<Name, Resource, LayoutName>,\n ctx: ComposableNameContext<Resource, LayoutName>\n): Name {\n return typeof name === 'function' ? name(ctx) : name;\n}\n\nexport function createLayoutComposableFactory<\n Resources extends string,\n LayoutName extends string\n>(ctx: ComposableNameContext<Resources, LayoutName>) {\n const create: CreateLayoutComposable<Resources, LayoutName> = <\n const Name extends string,\n Wrapper,\n InProps extends InPropsObject = {},\n OutProps = {}\n >(\n options: CreateComposableComponentOptions<\n Name,\n Wrapper,\n Resources,\n LayoutName,\n InProps,\n OutProps\n >\n ) =>\n createComposableComponent({\n ...options,\n name: resolveComposableComponentName(options.name, ctx),\n } as ResolvedCreateComposableComponentOptions<Name, Wrapper, Resources, LayoutName, InProps, OutProps>);\n\n return create;\n}\n\nexport function resolveLayoutComposables<\n Resources extends string,\n LayoutName extends string,\n Composables extends ComposableComponents\n>(\n factory: (\n create: CreateLayoutComposable<Resources, LayoutName>\n ) => Composables,\n ctx: ComposableNameContext<Resources, LayoutName>\n): Composables {\n return factory(createLayoutComposableFactory(ctx));\n}\n\nexport function createComposableComponent<\n const Name extends string,\n Wrapper,\n InProps extends InPropsObject = {},\n OutProps = {}\n>(\n options: ResolvedCreateComposableComponentOptions<\n Name,\n Wrapper,\n string,\n string,\n InProps,\n OutProps\n >\n) {\n const { name, inProps = {} as InProps, outProps, wrapWith } = options;\n\n function Composable({\n children,\n ...props\n }: ComposableComponentProps<Wrapper, InProps, OutProps>) {\n const inPropsKeys = Object.keys(inProps as object) as (keyof InProps &\n string)[];\n const mergedInProps = { ...inProps };\n const propsRecord = props as Record<string, unknown>;\n\n for (const key of inPropsKeys) {\n if (key in propsRecord) {\n (mergedInProps as Record<string, unknown>)[key] = propsRecord[key];\n }\n }\n\n const wrapperProps = {\n ...propsRecord,\n } as ComposableComponentWrapperProps<Wrapper>;\n\n for (const key of inPropsKeys) {\n delete (wrapperProps as Record<string, unknown>)[key];\n }\n\n const mergedResolved = resolvePropDefinitionValues(\n mergedInProps as Record<string, unknown>\n ) as Show<ResolveProps<InProps>>;\n\n const resolvedProps = outProps\n ? outProps(mergedResolved)\n : ({} as OutProps);\n const resolvedChildren =\n children == null\n ? reactNodeFromSingleFieldOutProps(resolvedProps)\n : resolveComponent(children, resolvedProps);\n\n if (wrapWith) {\n const Comp = wrapWith as ComponentType<\n ComposableComponentWrapperProps<Wrapper>\n >;\n\n return <Comp {...wrapperProps}>{resolvedChildren}</Comp>;\n }\n\n // A single intrinsic child is the composable's root without adding a wrapper.\n if (propsRecord['data-rl-node'] && isValidElement(resolvedChildren) && typeof resolvedChildren.type === 'string') {\n return cloneElement(resolvedChildren, {\n 'data-rl-node': propsRecord['data-rl-node'],\n 'data-rl-composable': propsRecord['data-rl-composable'],\n 'data-rl-owners': propsRecord['data-rl-owners'],\n } as Record<string, unknown>);\n }\n return resolvedChildren;\n }\n\n Composable.displayName = name;\n\n const debugKey = Symbol.for('@jfdevelops/react-layout/debug');\n const debug = (options as unknown as Record<symbol, unknown>)[debugKey];\n\n return Object.assign(Composable, {\n ...(debug ? { [debugKey]: debug } : {}),\n props: undefined as unknown as ResolveProps<InProps>,\n }) as unknown as ComposableComponent<Name, Wrapper, InProps, OutProps>;\n}\n\ntype DefineComposableComponentOptions<\n Name extends string,\n Props extends InPropsObject,\n Wrapper = undefined\n> = {\n name: Name;\n props?: Props;\n wrapWith?: Wrapper;\n};\n\nexport type DefinedComposableComponentRecord<\n Name extends string,\n Props extends InPropsObject = {},\n Wrapper = undefined\n> = {\n [K in Name]: ComposablePresetComponent<Name, Props, Wrapper>;\n};\n\ntype DefinedComposableComponentFactory<\n Name extends string,\n Props extends InPropsObject,\n Wrapper = undefined,\n> = {\n props: Props;\n (\n render: (props: Show<WithChildren<ResolveProps<Props>>>) => ReactNode,\n ): DefinedComposableComponentRecord<Name, Props, Wrapper>;\n /** Customize this instance without changing the factory's defaults. */\n <\n const Overrides extends InPropsObject = {},\n const CustomName extends string = Name,\n CustomWrapper = Wrapper,\n >(options: {\n name?: CustomName;\n props?: Overrides | ((defaults: Props) => Overrides);\n wrapWith?: CustomWrapper;\n render: (\n props: Show<\n WithChildren<ResolveProps<Omit<Props, keyof Overrides> & Overrides>>\n >,\n ) => ReactNode;\n }): DefinedComposableComponentRecord<\n CustomName,\n Omit<Props, keyof Overrides> & Overrides,\n CustomWrapper\n >;\n};\n\nfunction resolvePresetComposableCallProps<Props extends InPropsObject>(\n presetKey: string,\n propDefinitions: Props,\n callProps: Record<string, unknown>\n) {\n const presetKeys = Object.keys(propDefinitions) as (keyof Props & string)[];\n const contextValues = useComposablePresetProps(presetKey) ?? {};\n const presetValues = Object.fromEntries(\n presetKeys.map((key) => [key, callProps[key] ?? contextValues[key]])\n );\n\n return validateProps(\n propDefinitions as Record<string, AnyBuiltPropDefinition>,\n presetValues\n ) as Show<WithChildren<ResolveProps<Props>>>;\n}\n\nexport function defineComposableComponent<\n const Name extends string,\n Props extends InPropsObject = {},\n Wrapper = undefined\n>(\n options: DefineComposableComponentOptions<Name, Props, Wrapper>\n): DefinedComposableComponentFactory<Name, Props, Wrapper> {\n const { name, props = {} as Props, wrapWith } = options;\n\n const factory = (\n definition:\n | ((props: Show<WithChildren<ResolveProps<Props>>>) => ReactNode)\n | {\n name?: string;\n props?: InPropsObject | ((defaults: Props) => InPropsObject);\n wrapWith?: unknown;\n render: (props: any) => ReactNode;\n }\n ): DefinedComposableComponentRecord<Name, Props, Wrapper> => {\n if (typeof definition !== 'function') {\n const overrides =\n typeof definition.props === 'function'\n ? definition.props(props)\n : definition.props;\n\n return defineComposableComponent({\n ...options,\n name: definition.name ?? name,\n props: { ...props, ...overrides },\n wrapWith: 'wrapWith' in definition ? definition.wrapWith : wrapWith,\n })(definition.render) as unknown as DefinedComposableComponentRecord<\n Name,\n Props,\n Wrapper\n >;\n }\n\n const render = definition;\n const component = createComposableComponent<\n Name,\n Wrapper,\n Props,\n Show<WithChildren<ResolveProps<Props>>>\n >({\n name,\n wrapWith,\n inProps: props,\n outProps: (resolved) => resolved,\n });\n\n function PresetComposable(\n callProps: ComposablePresetComponentCallProps<Props, Wrapper>\n ) {\n const callPropsRecord = callProps as Record<string, unknown>;\n const presetKeys = Object.keys(props) as (keyof Props & string)[];\n const validatedPresetProps = resolvePresetComposableCallProps(\n name,\n props,\n callPropsRecord\n );\n const wrapperProps = { ...callPropsRecord };\n\n for (const key of presetKeys) {\n delete wrapperProps[key];\n }\n\n return component({\n ...(wrapperProps as ComposableComponentWrapperProps<Wrapper>),\n ...validatedPresetProps,\n children: (resolved: Show<WithChildren<ResolveProps<Props>>>) => render({\n ...resolved,\n children: 'children' in props\n ? (validatedPresetProps as Record<string, unknown>).children\n : callPropsRecord.children,\n } as Show<WithChildren<ResolveProps<Props>>>),\n } as unknown as ComposableComponentProps<Wrapper, Props, Show<WithChildren<ResolveProps<Props>>>>);\n }\n\n PresetComposable.displayName = name;\n\n const debugKey = Symbol.for('@jfdevelops/react-layout/debug');\n const debug = (options as unknown as Record<symbol, unknown>)[debugKey];\n const presetComponent = Object.assign(PresetComposable, {\n ...(debug ? { [debugKey]: debug } : {}),\n props: undefined as unknown as Show<WithChildren<ResolveProps<Props>>>,\n [composablePresetMetaKey]: {\n key: name,\n props,\n } satisfies ComposablePresetMeta<Props>,\n }) as unknown as DefinedComposableComponentRecord<\n Name,\n Props,\n Wrapper\n >[Name];\n\n return {\n [name]: presetComponent,\n } as DefinedComposableComponentRecord<Name, Props, Wrapper>;\n };\n\n Object.defineProperty(factory, 'props', {\n enumerable: true,\n value: props,\n });\n\n return factory as DefinedComposableComponentFactory<Name, Props, Wrapper>;\n}\n\nexport type MakeComposableOptions<\n Composables extends ComposableComponents,\n Name extends string\n> = { components: Composables | undefined; name: Name };\n\nexport type MakeComposable<\n Composables extends ComposableComponents,\n Name extends string\n> = <OverrideName extends string = Name>(\n options?: Partial<\n Pick<MakeComposableOptions<Composables, OverrideName>, 'name'>\n >\n) => ComposableResourceLayout<Composables, Name, any, any, any>;\n\nexport function makeComposable<Props>() {\n return function <\n Composables extends ComposableComponents,\n Name extends string\n >(options: MakeComposableOptions<Composables, Name>) {\n const { components, name: layoutName } = options;\n\n if (!components || typeof components !== 'object') {\n throw new InvalidComponentsError('components must be an object');\n }\n\n const componentNames = Object.keys(components);\n\n if (componentNames.length === 0) {\n throw new EmptyComponentsError(\n 'components must have at least one component'\n );\n }\n\n const create: MakeComposable<Composables, Name> = (overrideOptions) => {\n const resolvedName = overrideOptions?.name ?? layoutName;\n const { Layout, ...rest } = components;\n\n return Object.assign(Layout, {\n displayName: resolvedName,\n props: undefined as unknown as Props,\n ...rest,\n }) as unknown as ComposableResourceLayout<\n Composables,\n Name,\n any,\n any,\n any\n >;\n };\n\n return create;\n };\n}\n"],"mappings":";;;;;;AAcA,MAAa,0BAA0B,OAAO,IAC5C,iCACF;AAUA,MAAM,+BAA+B,cAEnC,MAAS;AAEX,SAAgB,+BAA+B,EAC7C,OACA,YAIC;CACD,OACE,oBAAC,6BAA6B,UAA9B;EAA8C;EAC3C;CACoC;AAE3C;AAEA,SAAS,yBAAyB,KAAa;CAC7C,OAAO,WAAW,4BAA4B,IAAI;AACpD;AAEA,SAAgB,+BACd,aACA;CACA,IAAI,CAAC,aACH,OAAO,CAAC;CAMV,OAAO,OAAO,QAAQ,WAAW,EAAE,SAAS,CAAC,WAAW,eAAe;EACrE,MAAM,OAAQ,UACZ;EAGF,IAAI,CAAC,MACH,OAAO,CAAC;EAGV,OAAO,CACL;GACE,KAAK,KAAK,OAAO;GACjB,OAAO,KAAK;EACd,CACF;CACF,CAAC;AACH;AAEA,SAAgB,6BACd,aACA,eACA,SACA;CACA,MAAM,WAAkC,CAAC;CAEzC,KAAK,MAAM,EAAE,KAAK,WAAW,+BAA+B,WAAW,GAYrE,SAAS,OAAO,cACd,OAXa,OAAO,YADL,OAAO,KAAK,KAEpB,EAAE,SAAS,YAAY;EAC5B,IAAI,EAAE,WAAW,gBACf,OAAO,CAAC;EAGV,OAAO,CAAC,CAAC,SAAS,cAAc,QAAQ,CAAC;CAC3C,CAAC,CAKI,G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AAa;GAGtB,OAAO,UAAU;IACf,GAAI;IACJ,GAAG;IACH,WAAW,aAAsD,OAAO;KACtE,GAAG;KACH,UAAU,cAAc,QACnB,qBAAiD,WAClD,gBAAgB;IACtB,CAA4C;GAC9C,CAAiG;EACnG;EAEA,iBAAiB,cAAc;EAE/B,MAAM,WAAW,OAAO,IAAI,gCAAgC;EAC5D,MAAM,QAAS,QAA+C;EAC9D,MAAM,kBAAkB,OAAO,OAAO,kBAAkB;GACtD,GAAI,QAAQ,GAAG,WAAW,MAAM,IAAI,CAAC;GACrC,OAAO;IACN,0BAA0B;IACzB,KAAK;IACL;GACF;EACF,CAAC;EAMD,OAAO,GACJ,OAAO,gBACV;CACF;CAEA,OAAO,eAAe,SAAS,SAAS;EACtC,YAAY;EACZ,OAAO;CACT,CAAC;CAED,OAAO;AACT;AAgBA,SAAgB,iBAAwB;CACtC,OAAO,SAGL,SAAmD;EACnD,MAAM,EAAE,YAAY,MAAM,eAAe;EAEzC,IAAI,CAAC,cAAc,OAAO,eAAe,UACvC,MAAM,IAAI,uBAAuB,8BAA8B;EAKjE,IAFuB,OAAO,KAAK,UAElB,EAAE,WAAW,GAC5B,MAAM,IAAI,qBACR,6CACF;EAGF,MAAM,UAA6C,oBAAoB;GACrE,MAAM,eAAe,iBAAiB,QAAQ;GAC9C,MAAM,EAAE,QAAQ,GAAG,SAAS;GAE5B,OAAO,OAAO,OAAO,QAAQ;IAC3B,aAAa;IACb,OAAO;IACP,GAAG;GACL,CAAC;EAOH;EAEA,OAAO;CACT;AACF"}
|
|
1
|
+
{"version":3,"file":"composable.mjs","names":["Comp"],"sources":["../src/composable.tsx"],"sourcesContent":["import { ComponentType, createContext, ReactNode, useContext, cloneElement, isValidElement } from 'react';\nimport { EmptyComponentsError, InvalidComponentsError } from './errors';\nimport {\n AnyBuiltPropDefinition,\n type PropValidationContext,\n ResolveLayoutProps,\n ResolveProps,\n ResolveInputProps,\n ResolveLayoutInputProps,\n type StandardSchemaV1,\n isStandardSchema,\n resolvePropDefinitionValues,\n validateProps,\n} from '@jfdevelops/react-layout-validator';\nimport { InPropsObject, type WithChildren } from './types';\nimport { BaseComponent, Show, UnionToIntersection } from './utils';\nimport { CapitalizeFn } from './utils/capitalize';\n\nexport const composablePresetMetaKey = Symbol.for(\n 'view-map.composable-preset-meta'\n);\n\nconst validatedComposableProps = Symbol('validatedComposableProps');\n\nexport type ComposablePresetMeta<Props extends InPropsObject = InPropsObject> =\n {\n key: string;\n props: Props;\n };\n\nexport type ComposablePresetProps = Record<string, Record<string, unknown>>;\n\nconst composablePresetPropsContext = createContext<\n ComposablePresetProps | undefined\n>(undefined);\n\nexport function LayoutComposablePresetProvider({\n value,\n children,\n}: {\n value: ComposablePresetProps;\n children: ReactNode;\n}) {\n return (\n <composablePresetPropsContext.Provider value={value}>\n {children}\n </composablePresetPropsContext.Provider>\n );\n}\n\nfunction useComposablePresetProps(key: string) {\n return useContext(composablePresetPropsContext)?.[key];\n}\n\nexport function collectComposablePresetEntries(\n composables: ComposableComponents | undefined\n) {\n if (!composables) {\n return [] as Array<{\n key: string;\n props: InPropsObject;\n }>;\n }\n\n return Object.entries(composables).flatMap(([objectKey, component]) => {\n const meta = (component as ComposablePresetComponent)[\n composablePresetMetaKey\n ];\n\n if (!meta) {\n return [];\n }\n\n return [\n {\n key: meta.key ?? objectKey,\n props: meta.props,\n },\n ];\n });\n}\n\nexport function resolveComposablePresetProps(\n composables: ComposableComponents | undefined,\n layoutOptions: Record<string, unknown>,\n context?: PropValidationContext\n) {\n const resolved: ComposablePresetProps = {};\n\n for (const { key, props } of collectComposablePresetEntries(composables)) {\n const propKeys = Object.keys(props);\n const values = Object.fromEntries(\n propKeys.flatMap((propKey) => {\n if (!(propKey in layoutOptions)) {\n return [];\n }\n\n return [[propKey, layoutOptions[propKey]]];\n })\n );\n\n resolved[key] = validateProps(\n props as Record<string, AnyBuiltPropDefinition>,\n values,\n context\n );\n }\n\n return resolved;\n}\n\nexport type ComposableNameContext<\n Resource extends string,\n LayoutName extends string = string\n> = {\n resource: Resource;\n name: LayoutName;\n capitalize: CapitalizeFn;\n};\n\ntype ComposableComponentName<\n Name extends string,\n Resource extends string,\n LayoutName extends string = string\n> = Name | ((ctx: ComposableNameContext<Resource, LayoutName>) => Name);\n\ntype CreateComposableComponentOptions<\n Name extends string,\n Wrapper,\n Resource extends string,\n LayoutName extends string = string,\n InProps extends InPropsObject = {},\n OutProps = {}\n> = {\n name: ComposableComponentName<Name, Resource, LayoutName>;\n inProps?: InProps;\n outProps?: (props: Show<ResolveProps<InProps>>) => OutProps;\n wrapWith?: Wrapper;\n};\n\ntype ResolvedCreateComposableComponentOptions<\n Name extends string,\n Wrapper,\n Resource extends string,\n LayoutName extends string = string,\n InProps extends InPropsObject = {},\n OutProps = {}\n> = Omit<\n CreateComposableComponentOptions<\n Name,\n Wrapper,\n Resource,\n LayoutName,\n InProps,\n OutProps\n >,\n 'name'\n> & {\n name: Name;\n};\n\nexport type CreateLayoutComposable<\n Resources extends string,\n LayoutName extends string = string\n> = <\n const Name extends string,\n Wrapper,\n InProps extends InPropsObject = {},\n OutProps = {}\n>(\n options: CreateComposableComponentOptions<\n Name,\n Wrapper,\n Resources,\n LayoutName,\n InProps,\n OutProps\n >\n) => ComposableComponent<Name, Wrapper, InProps, OutProps>;\n\nexport type LayoutComposablesFactory<\n Resources extends string,\n LayoutName extends string = string\n> = (\n create: CreateLayoutComposable<Resources, LayoutName>\n) => ComposableComponents;\n\nexport type ResolveLayoutComposables<\n Factory extends LayoutComposablesFactory<string> | undefined\n> = Factory extends LayoutComposablesFactory<string> ? ReturnType<Factory> : {};\n\ntype ComposableComponentWrapperProps<Wrapper> = Wrapper extends ComponentType<\n infer Props\n>\n ? Omit<Props, 'children'>\n : {};\n\ntype ComposableComponentProps<\n Wrapper,\n InProps extends InPropsObject = {},\n OutProps = {}\n> = ComposableComponentWrapperProps<Wrapper> &\n (keyof InProps extends never ? {} : ResolveInputProps<InProps>) & {\n children?: [keyof InProps] extends [never]\n ? ReactNode\n : ((props: OutProps) => JSX.Element) | ReactNode;\n };\n\nexport type ComposableComponent<\n Name extends string,\n Wrapper,\n InProps extends InPropsObject = {},\n OutProps = {}\n> = BaseComponent<Name, ResolveInputProps<InProps>> & {\n (props: ComposableComponentProps<Wrapper, InProps, OutProps>): ReactNode;\n};\n\nexport type ComposableResourceLayout<\n Composables extends ComposableComponents,\n Name extends string,\n Wrapper,\n InProps extends InPropsObject = {},\n OutProps = {}\n> = Composables & ComposableComponent<Name, Wrapper, InProps, OutProps>;\n\nexport type AnyComposableComponent = ComposableComponent<\n string,\n any,\n InPropsObject,\n any\n>;\n\n/**\n * Minimal callable shape shared by layout and preset composables.\n * Used as the record value so preset components keep their own prop types.\n */\nexport type ComposableComponentCallable = {\n displayName: string;\n props: unknown;\n (...args: any[]): ReactNode;\n};\n\n// Separate installed versions declare distinct unique symbols for the same\n// Symbol.for key. Read the metadata structurally so their presets interoperate.\ntype PresetPropsFromMetadata<Component> = {\n [Key in keyof Component]-?: Key extends symbol\n ? Component[Key] extends ComposablePresetMeta<infer Props>\n ? Props\n : never\n : never;\n}[keyof Component];\n\nexport type PresetPropsFromComposable<Component> = Component extends {\n [composablePresetMetaKey]: ComposablePresetMeta<infer Props>;\n}\n ? Props\n : [PresetPropsFromMetadata<Component>] extends [never]\n ? {}\n : PresetPropsFromMetadata<Component>;\n\nexport type MergePresetProps<Composables extends ComposableComponents> = Show<\n UnionToIntersection<PresetPropsFromComposable<Composables[keyof Composables]>>\n>;\n\nexport type RequiredPresetRenderProps<Props extends InPropsObject> = {\n [K in keyof ResolveProps<Props> & string]-?: ResolveProps<Props>[K];\n};\n\ntype SchemaDefinitions<Props extends InPropsObject> = {\n [Key in keyof Props as Props[Key] extends StandardSchemaV1 ? Key : never]: Props[Key];\n};\n\ntype PresetInputProps<Props extends InPropsObject> =\n ResolveInputProps<SchemaDefinitions<Props>> &\n RequiredPresetRenderProps<Omit<Props, keyof SchemaDefinitions<Props>>>;\n\nexport type ComposablePresetComponentCallProps<\n Props extends InPropsObject,\n Wrapper = undefined\n> = WithChildren<PresetInputProps<Props>> &\n (Wrapper extends undefined ? {} : ComposableComponentWrapperProps<Wrapper>);\n\nexport type ComposablePresetComponent<\n Name extends string = string,\n Props extends InPropsObject = InPropsObject,\n Wrapper = undefined\n> = BaseComponent<Name, Show<WithChildren<ResolveInputProps<Props>>>> & {\n [composablePresetMetaKey]: ComposablePresetMeta<Props>;\n} & ((props: ComposablePresetComponentCallProps<Props, Wrapper>) => ReactNode);\n\ntype PresetPropDefinitions<Composables extends ComposableComponents> =\n MergePresetProps<Composables> extends InPropsObject\n ? MergePresetProps<Composables>\n : {};\n\ntype PresetLayoutInputProps<Props extends InPropsObject> =\n ResolveLayoutInputProps<SchemaDefinitions<Props>> & {\n [Key in keyof ResolveLayoutProps<Omit<Props, keyof SchemaDefinitions<Props>>>]-?:\n ResolveLayoutProps<Omit<Props, keyof SchemaDefinitions<Props>>>[Key];\n };\n\nexport type RequiredPresetLayoutProps<Composables extends ComposableComponents> =\n PresetLayoutInputProps<PresetPropDefinitions<Composables>>;\n\nexport type ComposableComponents = Record<string, ComposableComponentCallable>;\n\nexport type ResolvedComposableComponents<\n Components extends ComposableComponents\n> = [keyof Components] extends [never]\n ? never\n : Components extends { Layout: infer _ }\n ? Components\n : 'The Layout composable is required';\n\nfunction resolveComponent<Props>(\n component: ((props: Props) => JSX.Element | ReactNode) | ReactNode,\n props: Props\n) {\n return typeof component === 'function' ? component(props) : component;\n}\n\nfunction reactNodeFromSingleFieldOutProps(resolved: unknown): ReactNode {\n if (resolved === null || typeof resolved !== 'object') {\n return null;\n }\n\n const values = Object.values(resolved);\n\n if (values.length !== 1) {\n return null;\n }\n\n return values[0] as ReactNode;\n}\n\nfunction resolveComposableComponentName<\n Name extends string,\n Resource extends string,\n LayoutName extends string\n>(\n name: ComposableComponentName<Name, Resource, LayoutName>,\n ctx: ComposableNameContext<Resource, LayoutName>\n): Name {\n return typeof name === 'function' ? name(ctx) : name;\n}\n\nexport function createLayoutComposableFactory<\n Resources extends string,\n LayoutName extends string\n>(ctx: ComposableNameContext<Resources, LayoutName>) {\n const create: CreateLayoutComposable<Resources, LayoutName> = <\n const Name extends string,\n Wrapper,\n InProps extends InPropsObject = {},\n OutProps = {}\n >(\n options: CreateComposableComponentOptions<\n Name,\n Wrapper,\n Resources,\n LayoutName,\n InProps,\n OutProps\n >\n ) =>\n createComposableComponent({\n ...options,\n name: resolveComposableComponentName(options.name, ctx),\n } as ResolvedCreateComposableComponentOptions<Name, Wrapper, Resources, LayoutName, InProps, OutProps>);\n\n return create;\n}\n\nexport function resolveLayoutComposables<\n Resources extends string,\n LayoutName extends string,\n Composables extends ComposableComponents\n>(\n factory: (\n create: CreateLayoutComposable<Resources, LayoutName>\n ) => Composables,\n ctx: ComposableNameContext<Resources, LayoutName>\n): Composables {\n return factory(createLayoutComposableFactory(ctx));\n}\n\nexport function createComposableComponent<\n const Name extends string,\n Wrapper,\n InProps extends InPropsObject = {},\n OutProps = {}\n>(\n options: ResolvedCreateComposableComponentOptions<\n Name,\n Wrapper,\n string,\n string,\n InProps,\n OutProps\n >\n) {\n const { name, inProps = {} as InProps, outProps, wrapWith } = options;\n\n function Composable({\n children,\n ...props\n }: ComposableComponentProps<Wrapper, InProps, OutProps>) {\n const inPropsKeys = Object.keys(inProps as object) as (keyof InProps &\n string)[];\n const mergedInProps = { ...inProps };\n const propsRecord = props as Record<string, unknown>;\n\n for (const key of inPropsKeys) {\n if (key in propsRecord) {\n (mergedInProps as Record<string, unknown>)[key] = propsRecord[key];\n }\n }\n\n const wrapperProps = {\n ...propsRecord,\n } as ComposableComponentWrapperProps<Wrapper>;\n\n for (const key of inPropsKeys) {\n delete (wrapperProps as Record<string, unknown>)[key];\n }\n\n const mergedValues = resolvePropDefinitionValues(mergedInProps as Record<string, unknown>);\n const alreadyValidated = (options as unknown as Record<symbol, unknown>)[validatedComposableProps];\n const schemaDefinitions = alreadyValidated ? {} : Object.fromEntries(\n Object.entries(inProps ?? {}).filter(([, definition]) => isStandardSchema(definition)),\n );\n const mergedResolved = validateProps(schemaDefinitions, mergedValues) as Show<ResolveProps<InProps>>;\n\n const resolvedProps = outProps\n ? outProps(mergedResolved)\n : ({} as OutProps);\n const resolvedChildren =\n children == null\n ? reactNodeFromSingleFieldOutProps(resolvedProps)\n : resolveComponent(children, resolvedProps);\n\n if (wrapWith) {\n const Comp = wrapWith as ComponentType<\n ComposableComponentWrapperProps<Wrapper>\n >;\n\n return <Comp {...wrapperProps}>{resolvedChildren}</Comp>;\n }\n\n // A single intrinsic child is the composable's root without adding a wrapper.\n if (propsRecord['data-rl-node'] && isValidElement(resolvedChildren) && typeof resolvedChildren.type === 'string') {\n return cloneElement(resolvedChildren, {\n 'data-rl-node': propsRecord['data-rl-node'],\n 'data-rl-composable': propsRecord['data-rl-composable'],\n 'data-rl-owners': propsRecord['data-rl-owners'],\n } as Record<string, unknown>);\n }\n return resolvedChildren;\n }\n\n Composable.displayName = name;\n\n const debugKey = Symbol.for('@jfdevelops/react-layout/debug');\n const debug = (options as unknown as Record<symbol, unknown>)[debugKey];\n\n return Object.assign(Composable, {\n ...(debug ? { [debugKey]: debug } : {}),\n props: undefined as unknown as ResolveProps<InProps>,\n }) as unknown as ComposableComponent<Name, Wrapper, InProps, OutProps>;\n}\n\ntype DefineComposableComponentOptions<\n Name extends string,\n Props extends InPropsObject,\n Wrapper = undefined\n> = {\n name: Name;\n props?: Props;\n wrapWith?: Wrapper;\n};\n\nexport type DefinedComposableComponentRecord<\n Name extends string,\n Props extends InPropsObject = {},\n Wrapper = undefined\n> = {\n [K in Name]: ComposablePresetComponent<Name, Props, Wrapper>;\n};\n\ntype DefinedComposableComponentFactory<\n Name extends string,\n Props extends InPropsObject,\n Wrapper = undefined,\n> = {\n props: Props;\n (\n render: (props: Show<WithChildren<ResolveProps<Props>>>) => ReactNode,\n ): DefinedComposableComponentRecord<Name, Props, Wrapper>;\n /** Customize this instance without changing the factory's defaults. */\n <\n const Overrides extends InPropsObject = {},\n const CustomName extends string = Name,\n CustomWrapper = Wrapper,\n >(options: {\n name?: CustomName;\n props?: Overrides | ((defaults: Props) => Overrides);\n wrapWith?: CustomWrapper;\n render: (\n props: Show<\n WithChildren<ResolveProps<Omit<Props, keyof Overrides> & Overrides>>\n >,\n ) => ReactNode;\n }): DefinedComposableComponentRecord<\n CustomName,\n Omit<Props, keyof Overrides> & Overrides,\n CustomWrapper\n >;\n};\n\nfunction resolvePresetComposableCallProps<Props extends InPropsObject>(\n presetKey: string,\n propDefinitions: Props,\n callProps: Record<string, unknown>\n) {\n const presetKeys = Object.keys(propDefinitions) as (keyof Props & string)[];\n const contextValues = useComposablePresetProps(presetKey) ?? {};\n const presetValues = Object.fromEntries(\n presetKeys.map((key) => [key,\n isStandardSchema(propDefinitions[key]) && Object.hasOwn(callProps, key)\n ? callProps[key]\n : callProps[key] ?? contextValues[key],\n ])\n );\n // Context values have already been validated by the owning layout.\n const definitions = Object.fromEntries(\n Object.entries(propDefinitions).filter(([key, definition]) =>\n !isStandardSchema(definition) || Object.hasOwn(callProps, key) || !Object.hasOwn(contextValues, key),\n ),\n );\n\n return validateProps(\n definitions,\n presetValues\n ) as Show<WithChildren<ResolveProps<Props>>>;\n}\n\nexport function defineComposableComponent<\n const Name extends string,\n Props extends InPropsObject = {},\n Wrapper = undefined\n>(\n options: DefineComposableComponentOptions<Name, Props, Wrapper>\n): DefinedComposableComponentFactory<Name, Props, Wrapper> {\n const { name, props = {} as Props, wrapWith } = options;\n\n const factory = (\n definition:\n | ((props: Show<WithChildren<ResolveProps<Props>>>) => ReactNode)\n | {\n name?: string;\n props?: InPropsObject | ((defaults: Props) => InPropsObject);\n wrapWith?: unknown;\n render: (props: any) => ReactNode;\n }\n ): DefinedComposableComponentRecord<Name, Props, Wrapper> => {\n if (typeof definition !== 'function') {\n const overrides =\n typeof definition.props === 'function'\n ? definition.props(props)\n : definition.props;\n\n return defineComposableComponent({\n ...options,\n name: definition.name ?? name,\n props: { ...props, ...overrides },\n wrapWith: 'wrapWith' in definition ? definition.wrapWith : wrapWith,\n })(definition.render) as unknown as DefinedComposableComponentRecord<\n Name,\n Props,\n Wrapper\n >;\n }\n\n const render = definition;\n const component = createComposableComponent<\n Name,\n Wrapper,\n Props,\n Show<WithChildren<ResolveProps<Props>>>\n >({\n name,\n wrapWith,\n inProps: props,\n outProps: (resolved) => resolved,\n ...{ [validatedComposableProps]: true },\n });\n\n function PresetComposable(\n callProps: ComposablePresetComponentCallProps<Props, Wrapper>\n ) {\n const callPropsRecord = callProps as Record<string, unknown>;\n const presetKeys = Object.keys(props) as (keyof Props & string)[];\n const validatedPresetProps = resolvePresetComposableCallProps(\n name,\n props,\n callPropsRecord\n );\n const wrapperProps = { ...callPropsRecord };\n\n for (const key of presetKeys) {\n delete wrapperProps[key];\n }\n\n return component({\n ...(wrapperProps as ComposableComponentWrapperProps<Wrapper>),\n ...validatedPresetProps,\n children: (resolved: Show<WithChildren<ResolveProps<Props>>>) => render({\n ...resolved,\n children: 'children' in props\n ? (validatedPresetProps as Record<string, unknown>).children\n : callPropsRecord.children,\n } as Show<WithChildren<ResolveProps<Props>>>),\n } as unknown as ComposableComponentProps<Wrapper, Props, Show<WithChildren<ResolveProps<Props>>>>);\n }\n\n PresetComposable.displayName = name;\n\n const debugKey = Symbol.for('@jfdevelops/react-layout/debug');\n const debug = (options as unknown as Record<symbol, unknown>)[debugKey];\n const presetComponent = Object.assign(PresetComposable, {\n ...(debug ? { [debugKey]: debug } : {}),\n props: undefined as unknown as Show<WithChildren<ResolveProps<Props>>>,\n [composablePresetMetaKey]: {\n key: name,\n props,\n } satisfies ComposablePresetMeta<Props>,\n }) as unknown as DefinedComposableComponentRecord<\n Name,\n Props,\n Wrapper\n >[Name];\n\n return {\n [name]: presetComponent,\n } as DefinedComposableComponentRecord<Name, Props, Wrapper>;\n };\n\n Object.defineProperty(factory, 'props', {\n enumerable: true,\n value: props,\n });\n\n return factory as DefinedComposableComponentFactory<Name, Props, Wrapper>;\n}\n\nexport type MakeComposableOptions<\n Composables extends ComposableComponents,\n Name extends string\n> = { components: Composables | undefined; name: Name };\n\nexport type MakeComposable<\n Composables extends ComposableComponents,\n Name extends string\n> = <OverrideName extends string = Name>(\n options?: Partial<\n Pick<MakeComposableOptions<Composables, OverrideName>, 'name'>\n >\n) => ComposableResourceLayout<Composables, Name, any, any, any>;\n\nexport function makeComposable<Props>() {\n return function <\n Composables extends ComposableComponents,\n Name extends string\n >(options: MakeComposableOptions<Composables, Name>) {\n const { components, name: layoutName } = options;\n\n if (!components || typeof components !== 'object') {\n throw new InvalidComponentsError('components must be an object');\n }\n\n const componentNames = Object.keys(components);\n\n if (componentNames.length === 0) {\n throw new EmptyComponentsError(\n 'components must have at least one component'\n );\n }\n\n const create: MakeComposable<Composables, Name> = (overrideOptions) => {\n const resolvedName = overrideOptions?.name ?? layoutName;\n const { Layout, ...rest } = components;\n\n return Object.assign(Layout, {\n displayName: resolvedName,\n props: undefined as unknown as Props,\n ...rest,\n }) as unknown as ComposableResourceLayout<\n Composables,\n Name,\n any,\n any,\n any\n >;\n };\n\n return create;\n };\n}\n"],"mappings":";;;;;;AAkBA,MAAa,0BAA0B,OAAO,IAC5C,iCACF;AAEA,MAAM,2BAA2B,OAAO,0BAA0B;AAUlE,MAAM,+BAA+B,cAEnC,MAAS;AAEX,SAAgB,+BAA+B,EAC7C,OACA,YAIC;CACD,OACE,oBAAC,6BAA6B,UAA9B;EAA8C;EAC3C;CACoC;AAE3C;AAEA,SAAS,yBAAyB,KAAa;CAC7C,OAAO,WAAW,4BAA4B,IAAI;AACpD;AAEA,SAAgB,+BACd,aACA;CACA,IAAI,CAAC,aACH,OAAO,CAAC;CAMV,OAAO,OAAO,QAAQ,WAAW,EAAE,SAAS,CAAC,WAAW,eAAe;EACrE,MAAM,OAAQ,UACZ;EAGF,IAAI,CAAC,MACH,OAAO,CAAC;EAGV,OAAO,CACL;GACE,KAAK,KAAK,OAAO;GACjB,OAAO,KAAK;EACd,CAC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;CACT,CAAC;CAED,OAAO;AACT;AAgBA,SAAgB,iBAAwB;CACtC,OAAO,SAGL,SAAmD;EACnD,MAAM,EAAE,YAAY,MAAM,eAAe;EAEzC,IAAI,CAAC,cAAc,OAAO,eAAe,UACvC,MAAM,IAAI,uBAAuB,8BAA8B;EAKjE,IAFuB,OAAO,KAAK,UAElB,EAAE,WAAW,GAC5B,MAAM,IAAI,qBACR,6CACF;EAGF,MAAM,UAA6C,oBAAoB;GACrE,MAAM,eAAe,iBAAiB,QAAQ;GAC9C,MAAM,EAAE,QAAQ,GAAG,SAAS;GAE5B,OAAO,OAAO,OAAO,QAAQ;IAC3B,aAAa;IACb,OAAO;IACP,GAAG;GACL,CAAC;EAOH;EAEA,OAAO;CACT;AACF"}
|
package/dist/errors.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ImplementedErrorClass } from "./node_modules/.pnpm/@jfdevelops_create-error@0.2.
|
|
1
|
+
import { BlueprintContext, DataSlot, ImplementedErrorClass, ResolveContext, TypeSlot } from "./node_modules/.pnpm/@jfdevelops_create-error@0.2.1/node_modules/@jfdevelops/create-error/dist/types.cjs";
|
|
2
2
|
|
|
3
3
|
//#region src/errors.d.ts
|
|
4
4
|
declare const InvalidComponentsError_base: ImplementedErrorClass<{
|
|
@@ -13,22 +13,22 @@ declare const InvalidComponentsError_base: ImplementedErrorClass<{
|
|
|
13
13
|
readonly property: "context";
|
|
14
14
|
readonly resolve: ({
|
|
15
15
|
input
|
|
16
|
-
}:
|
|
16
|
+
}: ResolveContext<import("arktype/internal/variants/object.ts").ObjectType<{
|
|
17
17
|
code: string;
|
|
18
18
|
}, {}>>) => object;
|
|
19
19
|
};
|
|
20
20
|
readonly message: ({
|
|
21
21
|
data,
|
|
22
22
|
implementation
|
|
23
|
-
}:
|
|
23
|
+
}: BlueprintContext<import("arktype/internal/variants/object.ts").ObjectType<{
|
|
24
24
|
code: string;
|
|
25
|
-
}, {}>>) => string &
|
|
25
|
+
}, {}>>) => string & TypeSlot<"implementationArgument", DataSlot>;
|
|
26
26
|
readonly properties: ({
|
|
27
27
|
definition
|
|
28
|
-
}:
|
|
28
|
+
}: BlueprintContext<import("arktype/internal/variants/object.ts").ObjectType<{
|
|
29
29
|
code: string;
|
|
30
30
|
}, {}>>) => {
|
|
31
|
-
code: string &
|
|
31
|
+
code: string & TypeSlot<"definition", "code">;
|
|
32
32
|
};
|
|
33
33
|
}, {
|
|
34
34
|
readonly code: string;
|
|
@@ -47,22 +47,22 @@ declare const EmptyComponentsError_base: ImplementedErrorClass<{
|
|
|
47
47
|
readonly property: "context";
|
|
48
48
|
readonly resolve: ({
|
|
49
49
|
input
|
|
50
|
-
}:
|
|
50
|
+
}: ResolveContext<import("arktype/internal/variants/object.ts").ObjectType<{
|
|
51
51
|
code: string;
|
|
52
52
|
}, {}>>) => object;
|
|
53
53
|
};
|
|
54
54
|
readonly message: ({
|
|
55
55
|
data,
|
|
56
56
|
implementation
|
|
57
|
-
}:
|
|
57
|
+
}: BlueprintContext<import("arktype/internal/variants/object.ts").ObjectType<{
|
|
58
58
|
code: string;
|
|
59
|
-
}, {}>>) => string &
|
|
59
|
+
}, {}>>) => string & TypeSlot<"implementationArgument", DataSlot>;
|
|
60
60
|
readonly properties: ({
|
|
61
61
|
definition
|
|
62
|
-
}:
|
|
62
|
+
}: BlueprintContext<import("arktype/internal/variants/object.ts").ObjectType<{
|
|
63
63
|
code: string;
|
|
64
64
|
}, {}>>) => {
|
|
65
|
-
code: string &
|
|
65
|
+
code: string & TypeSlot<"definition", "code">;
|
|
66
66
|
};
|
|
67
67
|
}, {
|
|
68
68
|
readonly code: string;
|
package/dist/errors.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.cts","names":[],"sources":["../src/errors.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAca,sBAAA,SAA+B,2BAIV;AAAA,cAAG,yBAAA
|
|
1
|
+
{"version":3,"file":"errors.d.cts","names":[],"sources":["../src/errors.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAca,sBAAA,SAA+B,2BAIV;AAAA,cAAG,yBAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAGxB,oBAAA,SAA6B,yBAIR"}
|
package/dist/errors.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ImplementedErrorClass } from "./node_modules/.pnpm/@jfdevelops_create-error@0.2.
|
|
1
|
+
import { BlueprintContext, DataSlot, ImplementedErrorClass, ResolveContext, TypeSlot } from "./node_modules/.pnpm/@jfdevelops_create-error@0.2.1/node_modules/@jfdevelops/create-error/dist/types.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/errors.d.ts
|
|
4
4
|
declare const InvalidComponentsError_base: ImplementedErrorClass<{
|
|
@@ -13,22 +13,22 @@ declare const InvalidComponentsError_base: ImplementedErrorClass<{
|
|
|
13
13
|
readonly property: "context";
|
|
14
14
|
readonly resolve: ({
|
|
15
15
|
input
|
|
16
|
-
}:
|
|
16
|
+
}: ResolveContext<import("arktype/internal/variants/object.ts").ObjectType<{
|
|
17
17
|
code: string;
|
|
18
18
|
}, {}>>) => object;
|
|
19
19
|
};
|
|
20
20
|
readonly message: ({
|
|
21
21
|
data,
|
|
22
22
|
implementation
|
|
23
|
-
}:
|
|
23
|
+
}: BlueprintContext<import("arktype/internal/variants/object.ts").ObjectType<{
|
|
24
24
|
code: string;
|
|
25
|
-
}, {}>>) => string &
|
|
25
|
+
}, {}>>) => string & TypeSlot<"implementationArgument", DataSlot>;
|
|
26
26
|
readonly properties: ({
|
|
27
27
|
definition
|
|
28
|
-
}:
|
|
28
|
+
}: BlueprintContext<import("arktype/internal/variants/object.ts").ObjectType<{
|
|
29
29
|
code: string;
|
|
30
30
|
}, {}>>) => {
|
|
31
|
-
code: string &
|
|
31
|
+
code: string & TypeSlot<"definition", "code">;
|
|
32
32
|
};
|
|
33
33
|
}, {
|
|
34
34
|
readonly code: string;
|
|
@@ -47,22 +47,22 @@ declare const EmptyComponentsError_base: ImplementedErrorClass<{
|
|
|
47
47
|
readonly property: "context";
|
|
48
48
|
readonly resolve: ({
|
|
49
49
|
input
|
|
50
|
-
}:
|
|
50
|
+
}: ResolveContext<import("arktype/internal/variants/object.ts").ObjectType<{
|
|
51
51
|
code: string;
|
|
52
52
|
}, {}>>) => object;
|
|
53
53
|
};
|
|
54
54
|
readonly message: ({
|
|
55
55
|
data,
|
|
56
56
|
implementation
|
|
57
|
-
}:
|
|
57
|
+
}: BlueprintContext<import("arktype/internal/variants/object.ts").ObjectType<{
|
|
58
58
|
code: string;
|
|
59
|
-
}, {}>>) => string &
|
|
59
|
+
}, {}>>) => string & TypeSlot<"implementationArgument", DataSlot>;
|
|
60
60
|
readonly properties: ({
|
|
61
61
|
definition
|
|
62
|
-
}:
|
|
62
|
+
}: BlueprintContext<import("arktype/internal/variants/object.ts").ObjectType<{
|
|
63
63
|
code: string;
|
|
64
64
|
}, {}>>) => {
|
|
65
|
-
code: string &
|
|
65
|
+
code: string & TypeSlot<"definition", "code">;
|
|
66
66
|
};
|
|
67
67
|
}, {
|
|
68
68
|
readonly code: string;
|
package/dist/errors.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.mts","names":[],"sources":["../src/errors.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAca,sBAAA,SAA+B,2BAIV;AAAA,cAAG,yBAAA
|
|
1
|
+
{"version":3,"file":"errors.d.mts","names":[],"sources":["../src/errors.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAca,sBAAA,SAA+B,2BAIV;AAAA,cAAG,yBAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAGxB,oBAAA,SAA6B,yBAIR"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import { StandardSchemaV1 } from "../../../../../@standard-schema_spec@1.1.0/node_modules/@standard-schema/spec/dist/index.cjs";
|
|
2
|
+
|
|
3
|
+
//#region ../../node_modules/.pnpm/@jfdevelops+create-error@0.2.1/node_modules/@jfdevelops/create-error/dist/types.d.mts
|
|
2
4
|
//#region src/types.d.ts
|
|
3
5
|
declare const typeSlot: unique symbol;
|
|
4
6
|
/** Marks a blueprint value that is resolved by a later builder stage. */
|
|
@@ -8,7 +10,49 @@ type TypeSlot<Kind extends string, Payload = never> = {
|
|
|
8
10
|
readonly payload: Payload;
|
|
9
11
|
};
|
|
10
12
|
};
|
|
13
|
+
type DefinitionOutput<Schema extends StandardSchemaV1> = StandardSchemaV1.InferOutput<Schema>;
|
|
14
|
+
type DefinitionTemplate<Schema extends StandardSchemaV1> = DefinitionOutput<Schema> extends object ? { readonly [Key in keyof DefinitionOutput<Schema>]: DefinitionOutput<Schema>[Key] & TypeSlot<'definition', Key> } : never;
|
|
11
15
|
type DataSlot = TypeSlot<'data'>;
|
|
16
|
+
type ImplementationSlot = TypeSlot<'implementation'> & {
|
|
17
|
+
<const Argument$1>(argument: Argument$1): string & TypeSlot<'implementationArgument', Argument$1>;
|
|
18
|
+
};
|
|
19
|
+
/** Values available while an error instance is being created. */
|
|
20
|
+
interface BlueprintContext<Schema extends StandardSchemaV1> {
|
|
21
|
+
/** The parsed definition captured by the concrete error class. */
|
|
22
|
+
definition: DefinitionTemplate<Schema>;
|
|
23
|
+
/** The resolved, and optionally schema-validated, constructor data. */
|
|
24
|
+
data: DataSlot;
|
|
25
|
+
/**
|
|
26
|
+
* Calls the concrete error's implementation with one argument.
|
|
27
|
+
*
|
|
28
|
+
* The argument passed here defines the implementation callback's parameter
|
|
29
|
+
* type. Concrete definition fields are included automatically when the
|
|
30
|
+
* argument is a plain object.
|
|
31
|
+
*/
|
|
32
|
+
implementation: ImplementationSlot;
|
|
33
|
+
}
|
|
34
|
+
/** Values available when resolving a concrete error's constructor input. */
|
|
35
|
+
interface ResolveContext<Schema extends StandardSchemaV1> {
|
|
36
|
+
/** The parsed definition captured by the concrete error class. */
|
|
37
|
+
definition: DefinitionTemplate<Schema>;
|
|
38
|
+
/** The value passed to the concrete error constructor. */
|
|
39
|
+
input: object;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Configuration accepted by {@link createError}.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```ts
|
|
46
|
+
* const config = {
|
|
47
|
+
* definition,
|
|
48
|
+
* data: {
|
|
49
|
+
* property: 'context',
|
|
50
|
+
* resolve: ({ input }) => input,
|
|
51
|
+
* },
|
|
52
|
+
* message: ({ data, implementation }) => implementation(data),
|
|
53
|
+
* } satisfies CreateErrorConfig<typeof definition>;
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
12
56
|
type ResolveTemplate<Config> = Config extends {
|
|
13
57
|
data: {
|
|
14
58
|
resolve: (...arguments_: infer _Arguments) => infer Resolved;
|
|
@@ -96,5 +140,5 @@ interface ConcreteErrorClass<Input, Instance> extends ErrorClassStatics {
|
|
|
96
140
|
type ImplementedErrorClass<Config, Definition, Input, Data> = ConcreteErrorClass<ConstructorInput<Config, Input>, InstanceProperties<Config, Definition, Data, PassedImplementationCallback<Config, Definition, Data>>>;
|
|
97
141
|
type ExtendsNever<Value, OnTrue, OnFalse> = [Value] extends [never] ? OnTrue : OnFalse;
|
|
98
142
|
//#endregion
|
|
99
|
-
export { ImplementedErrorClass };
|
|
143
|
+
export { BlueprintContext, DataSlot, ImplementedErrorClass, ResolveContext, TypeSlot };
|
|
100
144
|
//# sourceMappingURL=types.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.cts","names":["Kind","Payload","typeSlot","kind","payload","Schema","StandardSchemaV1","InferInput","InferOutput","Input","Definition","Record","Exclude","DefinitionOutput","Key","TypeSlot","Argument$1","argument","definition","DefinitionTemplate","data","DataSlot","implementation","ImplementationSlot","input","property","resolve","ResolveContext","context","message","BlueprintContext","properties","toJSON","Error","error","Config","arguments_","_Arguments","Resolved","Template","PropertyKey","Data","Omit","Extract","InjectedDefinitionKeys","ResolveTemplate","Values","Implementation","Index","ReplaceTemplate","Date","RegExp","ReadonlyMap","ReadonlySet","WeakMap","WeakSet","PromiseLike","ArrayBuffer","ArrayBufferView","Type","OpaqueObject","Arguments","Result","ReplaceTuple","Properties","Property","DataPropertyTemplate","PropertiesTemplate","Json","Message","MessageTemplate","Argument","ImplementationArgumentWithDefinition","ImplementationArgument","PassedImplementationArgument","ExtendsNever","invariant","Condition","ErrorOptions","options","this","condition","InvariantInput","InstanceProperties","ConcreteDefinition","Instance","ErrorClassStatics","ConcreteErrorClass","ConstructorInput","PassedImplementationCallback","Value","OnTrue","OnFalse","InferredData","name","implement","DefaultBuilderData","Expand","ImplementationCallback","BuilderData","ImplementOptions","ImplementedErrorClass","BuilderInput","ImplementationBuilder","defineContext","ContextSchema","DefinitionInput","ExactDefinition","ErrorDefinitionBuilder","FamilyErrorClass","FamilyError","is","value"],"sources":["../../../../../../../../../../node_modules/.pnpm/@jfdevelops+create-error@0.2.
|
|
1
|
+
{"version":3,"file":"types.d.cts","names":["Kind","Payload","typeSlot","kind","payload","Schema","StandardSchemaV1","InferInput","InferOutput","Input","Definition","Record","Exclude","DefinitionOutput","Key","TypeSlot","Argument$1","argument","definition","DefinitionTemplate","data","DataSlot","implementation","ImplementationSlot","input","property","resolve","ResolveContext","context","message","BlueprintContext","properties","toJSON","Error","error","Config","arguments_","_Arguments","Resolved","Template","PropertyKey","Data","Omit","Extract","InjectedDefinitionKeys","ResolveTemplate","Values","Implementation","Index","ReplaceTemplate","Date","RegExp","ReadonlyMap","ReadonlySet","WeakMap","WeakSet","PromiseLike","ArrayBuffer","ArrayBufferView","Type","OpaqueObject","Arguments","Result","ReplaceTuple","Properties","Property","DataPropertyTemplate","PropertiesTemplate","Json","Message","MessageTemplate","Argument","ImplementationArgumentWithDefinition","ImplementationArgument","PassedImplementationArgument","ExtendsNever","invariant","Condition","ErrorOptions","options","this","condition","InvariantInput","InstanceProperties","ConcreteDefinition","Instance","ErrorClassStatics","ConcreteErrorClass","ConstructorInput","PassedImplementationCallback","Value","OnTrue","OnFalse","InferredData","name","implement","DefaultBuilderData","Expand","ImplementationCallback","BuilderData","ImplementOptions","ImplementedErrorClass","BuilderInput","ImplementationBuilder","defineContext","ContextSchema","DefinitionInput","ExactDefinition","ErrorDefinitionBuilder","FamilyErrorClass","FamilyError","is","value"],"sources":["../../../../../../../../../../node_modules/.pnpm/@jfdevelops+create-error@0.2.1/node_modules/@jfdevelops/create-error/dist/types.d.mts"],"x_google_ignoreList":[0],"mappings":";;;;cAGc,QAAA;;KAET,QAAA;EAAA,UACO,QAAA;IAAA,SACCG,IAAAA,EAAM,IAAA;IAAA,SACNC,OAAAA,EAAS,OAAA;EAAA;AAAA;AAAA,KAIjB,gBAAA,gBAAgC,gBAAA,IAAoB,gBAAA,CAAiB,WAAA,CAAY,MAAA;AAAA,KAEjF,kBAAA,gBAAkC,gBAAA,IAAoB,gBAAA,CAAiB,MAAA,4CAAkD,gBAAA,CAAiB,MAAA,IAAU,gBAAA,CAAiB,MAAA,EAAQ,GAAA,IAAO,QAAA,eAAuB,GAAA;AAAA,KAE3M,QAAA,GAAW,QAAQ;AAAA,KACnB,kBAAA,GAAqB,QAAA;EAAA,mBACLa,QAAAA,EAAU,UAAA,YAAsB,QAAA,2BAAmC,UAAA;AAAA;;UAG9E,gBAAA,gBAAgC,gBAAA;EAbpBhB;EAepBiB,UAAAA,EAAY,kBAAA,CAAmB,MAAA;EAfJ;EAiB3BE,IAAAA,EAAM,QAAA;EAba;;;;;;;EAqBnBE,cAAAA,EAAgB,kBAAA;AAAA;;UAGR,cAAA,gBAA8B,gBAAA;EAxB8CjB;EA0BpFa,UAAAA,EAAY,kBAAA,CAAmB,MAAA;EA1B2D;EA4B1FM,KAAAA;AAAAA;;;;;;;;;;;;;;;;KAsGG,eAAA,WAA0B,MAAM;EACnCJ,IAAAA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E;;;;;EAAA,KAkF/GzD,KAAAA,EAAO,KAAA,EAAOuD,OAAAA,GAAU,YAAA,GAAe,QAAA;AAAA;AAAA,KAEzC,qBAAA,oCAAyD,kBAAA,CAAmB,gBAAA,CAAiB,MAAA,EAAQ,KAAA,GAAQ,kBAAA,CAAmB,MAAA,EAAQ,UAAA,EAAY,IAAA,EAAM,4BAAA,CAA6B,MAAA,EAAQ,UAAA,EAAY,IAAA;AAAA,KAC3M,YAAA,4BAAwC,KAAA,oBAAyB,MAAA,GAAS,OAAA"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import { StandardSchemaV1 } from "../../../../../@standard-schema_spec@1.1.0/node_modules/@standard-schema/spec/dist/index.mjs";
|
|
2
|
+
|
|
3
|
+
//#region ../../node_modules/.pnpm/@jfdevelops+create-error@0.2.1/node_modules/@jfdevelops/create-error/dist/types.d.mts
|
|
2
4
|
//#region src/types.d.ts
|
|
3
5
|
declare const typeSlot: unique symbol;
|
|
4
6
|
/** Marks a blueprint value that is resolved by a later builder stage. */
|
|
@@ -8,7 +10,49 @@ type TypeSlot<Kind extends string, Payload = never> = {
|
|
|
8
10
|
readonly payload: Payload;
|
|
9
11
|
};
|
|
10
12
|
};
|
|
13
|
+
type DefinitionOutput<Schema extends StandardSchemaV1> = StandardSchemaV1.InferOutput<Schema>;
|
|
14
|
+
type DefinitionTemplate<Schema extends StandardSchemaV1> = DefinitionOutput<Schema> extends object ? { readonly [Key in keyof DefinitionOutput<Schema>]: DefinitionOutput<Schema>[Key] & TypeSlot<'definition', Key> } : never;
|
|
11
15
|
type DataSlot = TypeSlot<'data'>;
|
|
16
|
+
type ImplementationSlot = TypeSlot<'implementation'> & {
|
|
17
|
+
<const Argument$1>(argument: Argument$1): string & TypeSlot<'implementationArgument', Argument$1>;
|
|
18
|
+
};
|
|
19
|
+
/** Values available while an error instance is being created. */
|
|
20
|
+
interface BlueprintContext<Schema extends StandardSchemaV1> {
|
|
21
|
+
/** The parsed definition captured by the concrete error class. */
|
|
22
|
+
definition: DefinitionTemplate<Schema>;
|
|
23
|
+
/** The resolved, and optionally schema-validated, constructor data. */
|
|
24
|
+
data: DataSlot;
|
|
25
|
+
/**
|
|
26
|
+
* Calls the concrete error's implementation with one argument.
|
|
27
|
+
*
|
|
28
|
+
* The argument passed here defines the implementation callback's parameter
|
|
29
|
+
* type. Concrete definition fields are included automatically when the
|
|
30
|
+
* argument is a plain object.
|
|
31
|
+
*/
|
|
32
|
+
implementation: ImplementationSlot;
|
|
33
|
+
}
|
|
34
|
+
/** Values available when resolving a concrete error's constructor input. */
|
|
35
|
+
interface ResolveContext<Schema extends StandardSchemaV1> {
|
|
36
|
+
/** The parsed definition captured by the concrete error class. */
|
|
37
|
+
definition: DefinitionTemplate<Schema>;
|
|
38
|
+
/** The value passed to the concrete error constructor. */
|
|
39
|
+
input: object;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Configuration accepted by {@link createError}.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```ts
|
|
46
|
+
* const config = {
|
|
47
|
+
* definition,
|
|
48
|
+
* data: {
|
|
49
|
+
* property: 'context',
|
|
50
|
+
* resolve: ({ input }) => input,
|
|
51
|
+
* },
|
|
52
|
+
* message: ({ data, implementation }) => implementation(data),
|
|
53
|
+
* } satisfies CreateErrorConfig<typeof definition>;
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
12
56
|
type ResolveTemplate<Config> = Config extends {
|
|
13
57
|
data: {
|
|
14
58
|
resolve: (...arguments_: infer _Arguments) => infer Resolved;
|
|
@@ -96,5 +140,5 @@ interface ConcreteErrorClass<Input, Instance> extends ErrorClassStatics {
|
|
|
96
140
|
type ImplementedErrorClass<Config, Definition, Input, Data> = ConcreteErrorClass<ConstructorInput<Config, Input>, InstanceProperties<Config, Definition, Data, PassedImplementationCallback<Config, Definition, Data>>>;
|
|
97
141
|
type ExtendsNever<Value, OnTrue, OnFalse> = [Value] extends [never] ? OnTrue : OnFalse;
|
|
98
142
|
//#endregion
|
|
99
|
-
export { ImplementedErrorClass };
|
|
143
|
+
export { BlueprintContext, DataSlot, ImplementedErrorClass, ResolveContext, TypeSlot };
|
|
100
144
|
//# sourceMappingURL=types.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.mts","names":["Kind","Payload","typeSlot","kind","payload","Schema","StandardSchemaV1","InferInput","InferOutput","Input","Definition","Record","Exclude","DefinitionOutput","Key","TypeSlot","Argument$1","argument","definition","DefinitionTemplate","data","DataSlot","implementation","ImplementationSlot","input","property","resolve","ResolveContext","context","message","BlueprintContext","properties","toJSON","Error","error","Config","arguments_","_Arguments","Resolved","Template","PropertyKey","Data","Omit","Extract","InjectedDefinitionKeys","ResolveTemplate","Values","Implementation","Index","ReplaceTemplate","Date","RegExp","ReadonlyMap","ReadonlySet","WeakMap","WeakSet","PromiseLike","ArrayBuffer","ArrayBufferView","Type","OpaqueObject","Arguments","Result","ReplaceTuple","Properties","Property","DataPropertyTemplate","PropertiesTemplate","Json","Message","MessageTemplate","Argument","ImplementationArgumentWithDefinition","ImplementationArgument","PassedImplementationArgument","ExtendsNever","invariant","Condition","ErrorOptions","options","this","condition","InvariantInput","InstanceProperties","ConcreteDefinition","Instance","ErrorClassStatics","ConcreteErrorClass","ConstructorInput","PassedImplementationCallback","Value","OnTrue","OnFalse","InferredData","name","implement","DefaultBuilderData","Expand","ImplementationCallback","BuilderData","ImplementOptions","ImplementedErrorClass","BuilderInput","ImplementationBuilder","defineContext","ContextSchema","DefinitionInput","ExactDefinition","ErrorDefinitionBuilder","FamilyErrorClass","FamilyError","is","value"],"sources":["../../../../../../../../../../node_modules/.pnpm/@jfdevelops+create-error@0.2.
|
|
1
|
+
{"version":3,"file":"types.d.mts","names":["Kind","Payload","typeSlot","kind","payload","Schema","StandardSchemaV1","InferInput","InferOutput","Input","Definition","Record","Exclude","DefinitionOutput","Key","TypeSlot","Argument$1","argument","definition","DefinitionTemplate","data","DataSlot","implementation","ImplementationSlot","input","property","resolve","ResolveContext","context","message","BlueprintContext","properties","toJSON","Error","error","Config","arguments_","_Arguments","Resolved","Template","PropertyKey","Data","Omit","Extract","InjectedDefinitionKeys","ResolveTemplate","Values","Implementation","Index","ReplaceTemplate","Date","RegExp","ReadonlyMap","ReadonlySet","WeakMap","WeakSet","PromiseLike","ArrayBuffer","ArrayBufferView","Type","OpaqueObject","Arguments","Result","ReplaceTuple","Properties","Property","DataPropertyTemplate","PropertiesTemplate","Json","Message","MessageTemplate","Argument","ImplementationArgumentWithDefinition","ImplementationArgument","PassedImplementationArgument","ExtendsNever","invariant","Condition","ErrorOptions","options","this","condition","InvariantInput","InstanceProperties","ConcreteDefinition","Instance","ErrorClassStatics","ConcreteErrorClass","ConstructorInput","PassedImplementationCallback","Value","OnTrue","OnFalse","InferredData","name","implement","DefaultBuilderData","Expand","ImplementationCallback","BuilderData","ImplementOptions","ImplementedErrorClass","BuilderInput","ImplementationBuilder","defineContext","ContextSchema","DefinitionInput","ExactDefinition","ErrorDefinitionBuilder","FamilyErrorClass","FamilyError","is","value"],"sources":["../../../../../../../../../../node_modules/.pnpm/@jfdevelops+create-error@0.2.1/node_modules/@jfdevelops/create-error/dist/types.d.mts"],"x_google_ignoreList":[0],"mappings":";;;;cAGc,QAAA;;KAET,QAAA;EAAA,UACO,QAAA;IAAA,SACCG,IAAAA,EAAM,IAAA;IAAA,SACNC,OAAAA,EAAS,OAAA;EAAA;AAAA;AAAA,KAIjB,gBAAA,gBAAgC,gBAAA,IAAoB,gBAAA,CAAiB,WAAA,CAAY,MAAA;AAAA,KAEjF,kBAAA,gBAAkC,gBAAA,IAAoB,gBAAA,CAAiB,MAAA,4CAAkD,gBAAA,CAAiB,MAAA,IAAU,gBAAA,CAAiB,MAAA,EAAQ,GAAA,IAAO,QAAA,eAAuB,GAAA;AAAA,KAE3M,QAAA,GAAW,QAAQ;AAAA,KACnB,kBAAA,GAAqB,QAAA;EAAA,mBACLa,QAA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,KAAA,MAAWmB,UAAAA,wBAAkC,KAAA,UAAe,KAAA,SAAc,KAAA;AAAA,UAClH,iBAAA;EA1C6KS;;;;;AAA6C;AAAA;;;;;;;;;;;;;;;;EAiElO+B,SAAAA,mBAA4BI,IAAAA,OAAWxD,KAAAA,EAAO,KAAA,EAAOuD,OAAAA,GAAU,YAAA,KAAiB,KAAA,EAAOE,SAAAA,EAAW,SAAA,EAAWzD,KAAAA,EAAO,cAAA,CAAe,KAAA,GAAQuD,OAAAA,GAAU,YAAA,WAAuBE,SAAAA;AAAAA;;;;;;;;UAiBpK,kBAAA,0BAA4C,iBAAA;EA5EgE;;;;;EAAA,KAkF/GzD,KAAAA,EAAO,KAAA,EAAOuD,OAAAA,GAAU,YAAA,GAAe,QAAA;AAAA;AAAA,KAEzC,qBAAA,oCAAyD,kBAAA,CAAmB,gBAAA,CAAiB,MAAA,EAAQ,KAAA,GAAQ,kBAAA,CAAmB,MAAA,EAAQ,UAAA,EAAY,IAAA,EAAM,4BAAA,CAA6B,MAAA,EAAQ,UAAA,EAAY,IAAA;AAAA,KAC3M,YAAA,4BAAwC,KAAA,oBAAyB,MAAA,GAAS,OAAA"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
//#region ../../node_modules/.pnpm/@standard-schema+spec@1.1.0/node_modules/@standard-schema/spec/dist/index.d.ts
|
|
2
|
+
/** The Standard Typed interface. This is a base type extended by other specs. */
|
|
3
|
+
interface StandardTypedV1<Input = unknown, Output = Input> {
|
|
4
|
+
/** The Standard properties. */
|
|
5
|
+
readonly "~standard": StandardTypedV1.Props<Input, Output>;
|
|
6
|
+
}
|
|
7
|
+
declare namespace StandardTypedV1 {
|
|
8
|
+
/** The Standard Typed properties interface. */
|
|
9
|
+
interface Props<Input = unknown, Output = Input> {
|
|
10
|
+
/** The version number of the standard. */
|
|
11
|
+
readonly version: 1;
|
|
12
|
+
/** The vendor name of the schema library. */
|
|
13
|
+
readonly vendor: string;
|
|
14
|
+
/** Inferred types associated with the schema. */
|
|
15
|
+
readonly types?: Types<Input, Output> | undefined;
|
|
16
|
+
}
|
|
17
|
+
/** The Standard Typed types interface. */
|
|
18
|
+
interface Types<Input = unknown, Output = Input> {
|
|
19
|
+
/** The input type of the schema. */
|
|
20
|
+
readonly input: Input;
|
|
21
|
+
/** The output type of the schema. */
|
|
22
|
+
readonly output: Output;
|
|
23
|
+
}
|
|
24
|
+
/** Infers the input type of a Standard Typed. */
|
|
25
|
+
type InferInput<Schema extends StandardTypedV1> = NonNullable<Schema["~standard"]["types"]>["input"];
|
|
26
|
+
/** Infers the output type of a Standard Typed. */
|
|
27
|
+
type InferOutput<Schema extends StandardTypedV1> = NonNullable<Schema["~standard"]["types"]>["output"];
|
|
28
|
+
}
|
|
29
|
+
/** The Standard Schema interface. */
|
|
30
|
+
interface StandardSchemaV1<Input = unknown, Output = Input> {
|
|
31
|
+
/** The Standard Schema properties. */
|
|
32
|
+
readonly "~standard": StandardSchemaV1.Props<Input, Output>;
|
|
33
|
+
}
|
|
34
|
+
declare namespace StandardSchemaV1 {
|
|
35
|
+
/** The Standard Schema properties interface. */
|
|
36
|
+
interface Props<Input = unknown, Output = Input> extends StandardTypedV1.Props<Input, Output> {
|
|
37
|
+
/** Validates unknown input values. */
|
|
38
|
+
readonly validate: (value: unknown, options?: StandardSchemaV1.Options | undefined) => Result<Output> | Promise<Result<Output>>;
|
|
39
|
+
}
|
|
40
|
+
/** The result interface of the validate function. */
|
|
41
|
+
type Result<Output> = SuccessResult<Output> | FailureResult;
|
|
42
|
+
/** The result interface if validation succeeds. */
|
|
43
|
+
interface SuccessResult<Output> {
|
|
44
|
+
/** The typed output value. */
|
|
45
|
+
readonly value: Output;
|
|
46
|
+
/** A falsy value for `issues` indicates success. */
|
|
47
|
+
readonly issues?: undefined;
|
|
48
|
+
}
|
|
49
|
+
interface Options {
|
|
50
|
+
/** Explicit support for additional vendor-specific parameters, if needed. */
|
|
51
|
+
readonly libraryOptions?: Record<string, unknown> | undefined;
|
|
52
|
+
}
|
|
53
|
+
/** The result interface if validation fails. */
|
|
54
|
+
interface FailureResult {
|
|
55
|
+
/** The issues of failed validation. */
|
|
56
|
+
readonly issues: ReadonlyArray<Issue>;
|
|
57
|
+
}
|
|
58
|
+
/** The issue interface of the failure output. */
|
|
59
|
+
interface Issue {
|
|
60
|
+
/** The error message of the issue. */
|
|
61
|
+
readonly message: string;
|
|
62
|
+
/** The path of the issue, if any. */
|
|
63
|
+
readonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined;
|
|
64
|
+
}
|
|
65
|
+
/** The path segment interface of the issue. */
|
|
66
|
+
interface PathSegment {
|
|
67
|
+
/** The key representing a path segment. */
|
|
68
|
+
readonly key: PropertyKey;
|
|
69
|
+
}
|
|
70
|
+
/** The Standard types interface. */
|
|
71
|
+
interface Types<Input = unknown, Output = Input> extends StandardTypedV1.Types<Input, Output> {}
|
|
72
|
+
/** Infers the input type of a Standard. */
|
|
73
|
+
type InferInput<Schema extends StandardTypedV1> = StandardTypedV1.InferInput<Schema>;
|
|
74
|
+
/** Infers the output type of a Standard. */
|
|
75
|
+
type InferOutput<Schema extends StandardTypedV1> = StandardTypedV1.InferOutput<Schema>;
|
|
76
|
+
}
|
|
77
|
+
/** The Standard JSON Schema interface. */
|
|
78
|
+
//#endregion
|
|
79
|
+
export { StandardSchemaV1 };
|
|
80
|
+
//# sourceMappingURL=index.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":["Input","Output","StandardTypedV1","Props","version","vendor","types","Types","input","output","InferInput","Schema","NonNullable","InferOutput","StandardSchemaV1","validate","value","Options","options","Result","Promise","SuccessResult","FailureResult","issues","libraryOptions","Record","ReadonlyArray","Issue","message","path","PropertyKey","PathSegment","key","StandardJSONSchemaV1","jsonSchema","Converter","Target","target"],"sources":["../../../../../../../../../../node_modules/.pnpm/@standard-schema+spec@1.1.0/node_modules/@standard-schema/spec/dist/index.d.ts"],"x_google_ignoreList":[0],"mappings":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B;EAAAA,UAoChCsB,aAAAA;IAlCUtB;IAAAA,SAoCPuB,MAAAA,EAAQ,aAAA,CAAc,KAAA;EAAA;EA/B9Bb;EAAAA,UAkCKiB,KAAAA;IAlCqBzB;IAAAA,SAoClB0B,OAAAA;IApCiDjB;IAAAA,SAsCjDkB,IAAAA,GAAO,aAAA,CAAc,WAAA,GAAc,WAAA;EAAA;EApChB3B;EAAAA,UAuCtB6B,WAAAA;IAvCqDpB;IAAAA,SAyClDqB,GAAAA,EAAK,WAAA;EAAA;EAtCZ;EAAA,UAyCIzB,KAAAA,2BAAgC,KAAA,UAAe,eAAA,CAAgB,KAAA,CAAM,KAAA,EAAO,MAAA;EAzCrC;EAAA,KA4C5CG,UAAAA,gBAA0B,eAAA,IAAmB,eAAA,CAAgB,UAAA,CAAW,MAAA;EA1CzB;EAAA,KA4C/CG,WAAAA,gBAA2B,eAAA,IAAmB,eAAA,CAAgB,WAAA,CAAY,MAAA;AAAA"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
//#region ../../node_modules/.pnpm/@standard-schema+spec@1.1.0/node_modules/@standard-schema/spec/dist/index.d.ts
|
|
2
|
+
/** The Standard Typed interface. This is a base type extended by other specs. */
|
|
3
|
+
interface StandardTypedV1<Input = unknown, Output = Input> {
|
|
4
|
+
/** The Standard properties. */
|
|
5
|
+
readonly "~standard": StandardTypedV1.Props<Input, Output>;
|
|
6
|
+
}
|
|
7
|
+
declare namespace StandardTypedV1 {
|
|
8
|
+
/** The Standard Typed properties interface. */
|
|
9
|
+
interface Props<Input = unknown, Output = Input> {
|
|
10
|
+
/** The version number of the standard. */
|
|
11
|
+
readonly version: 1;
|
|
12
|
+
/** The vendor name of the schema library. */
|
|
13
|
+
readonly vendor: string;
|
|
14
|
+
/** Inferred types associated with the schema. */
|
|
15
|
+
readonly types?: Types<Input, Output> | undefined;
|
|
16
|
+
}
|
|
17
|
+
/** The Standard Typed types interface. */
|
|
18
|
+
interface Types<Input = unknown, Output = Input> {
|
|
19
|
+
/** The input type of the schema. */
|
|
20
|
+
readonly input: Input;
|
|
21
|
+
/** The output type of the schema. */
|
|
22
|
+
readonly output: Output;
|
|
23
|
+
}
|
|
24
|
+
/** Infers the input type of a Standard Typed. */
|
|
25
|
+
type InferInput<Schema extends StandardTypedV1> = NonNullable<Schema["~standard"]["types"]>["input"];
|
|
26
|
+
/** Infers the output type of a Standard Typed. */
|
|
27
|
+
type InferOutput<Schema extends StandardTypedV1> = NonNullable<Schema["~standard"]["types"]>["output"];
|
|
28
|
+
}
|
|
29
|
+
/** The Standard Schema interface. */
|
|
30
|
+
interface StandardSchemaV1<Input = unknown, Output = Input> {
|
|
31
|
+
/** The Standard Schema properties. */
|
|
32
|
+
readonly "~standard": StandardSchemaV1.Props<Input, Output>;
|
|
33
|
+
}
|
|
34
|
+
declare namespace StandardSchemaV1 {
|
|
35
|
+
/** The Standard Schema properties interface. */
|
|
36
|
+
interface Props<Input = unknown, Output = Input> extends StandardTypedV1.Props<Input, Output> {
|
|
37
|
+
/** Validates unknown input values. */
|
|
38
|
+
readonly validate: (value: unknown, options?: StandardSchemaV1.Options | undefined) => Result<Output> | Promise<Result<Output>>;
|
|
39
|
+
}
|
|
40
|
+
/** The result interface of the validate function. */
|
|
41
|
+
type Result<Output> = SuccessResult<Output> | FailureResult;
|
|
42
|
+
/** The result interface if validation succeeds. */
|
|
43
|
+
interface SuccessResult<Output> {
|
|
44
|
+
/** The typed output value. */
|
|
45
|
+
readonly value: Output;
|
|
46
|
+
/** A falsy value for `issues` indicates success. */
|
|
47
|
+
readonly issues?: undefined;
|
|
48
|
+
}
|
|
49
|
+
interface Options {
|
|
50
|
+
/** Explicit support for additional vendor-specific parameters, if needed. */
|
|
51
|
+
readonly libraryOptions?: Record<string, unknown> | undefined;
|
|
52
|
+
}
|
|
53
|
+
/** The result interface if validation fails. */
|
|
54
|
+
interface FailureResult {
|
|
55
|
+
/** The issues of failed validation. */
|
|
56
|
+
readonly issues: ReadonlyArray<Issue>;
|
|
57
|
+
}
|
|
58
|
+
/** The issue interface of the failure output. */
|
|
59
|
+
interface Issue {
|
|
60
|
+
/** The error message of the issue. */
|
|
61
|
+
readonly message: string;
|
|
62
|
+
/** The path of the issue, if any. */
|
|
63
|
+
readonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined;
|
|
64
|
+
}
|
|
65
|
+
/** The path segment interface of the issue. */
|
|
66
|
+
interface PathSegment {
|
|
67
|
+
/** The key representing a path segment. */
|
|
68
|
+
readonly key: PropertyKey;
|
|
69
|
+
}
|
|
70
|
+
/** The Standard types interface. */
|
|
71
|
+
interface Types<Input = unknown, Output = Input> extends StandardTypedV1.Types<Input, Output> {}
|
|
72
|
+
/** Infers the input type of a Standard. */
|
|
73
|
+
type InferInput<Schema extends StandardTypedV1> = StandardTypedV1.InferInput<Schema>;
|
|
74
|
+
/** Infers the output type of a Standard. */
|
|
75
|
+
type InferOutput<Schema extends StandardTypedV1> = StandardTypedV1.InferOutput<Schema>;
|
|
76
|
+
}
|
|
77
|
+
/** The Standard JSON Schema interface. */
|
|
78
|
+
//#endregion
|
|
79
|
+
export { StandardSchemaV1 };
|
|
80
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":["Input","Output","StandardTypedV1","Props","version","vendor","types","Types","input","output","InferInput","Schema","NonNullable","InferOutput","StandardSchemaV1","validate","value","Options","options","Result","Promise","SuccessResult","FailureResult","issues","libraryOptions","Record","ReadonlyArray","Issue","message","path","PropertyKey","PathSegment","key","StandardJSONSchemaV1","jsonSchema","Converter","Target","target"],"sources":["../../../../../../../../../../node_modules/.pnpm/@standard-schema+spec@1.1.0/node_modules/@standard-schema/spec/dist/index.d.ts"],"x_google_ignoreList":[0],"mappings":";;UACU,eAAA,2BAA0C,KAAA;EAA3B;EAAA,SAEZ,WAAA,EAAa,eAAA,CAAgB,KAAA,CAAM,KAAA,EAAO,MAAA;AAAA;AAAA,kBAErC,eAAA;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lCqBzB;IAAAA,SAoClB0B,OAAAA;IApCiDjB;IAAAA,SAsCjDkB,IAAAA,GAAO,aAAA,CAAc,WAAA,GAAc,WAAA;EAAA;EApChB3B;EAAAA,UAuCtB6B,WAAAA;IAvCqDpB;IAAAA,SAyClDqB,GAAAA,EAAK,WAAA;EAAA;EAtCZ;EAAA,UAyCIzB,KAAAA,2BAAgC,KAAA,UAAe,eAAA,CAAgB,KAAA,CAAM,KAAA,EAAO,MAAA;EAzCrC;EAAA,KA4C5CG,UAAAA,gBAA0B,eAAA,IAAmB,eAAA,CAAgB,UAAA,CAAW,MAAA;EA1CzB;EAAA,KA4C/CG,WAAAA,gBAA2B,eAAA,IAAmB,eAAA,CAAgB,WAAA,CAAY,MAAA;AAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jfdevelops/react-layout-composables",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Composable components for react-layout.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -27,9 +27,9 @@
|
|
|
27
27
|
"node": "^20.19.0 || >=22.12.0"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@jfdevelops/create-error": "0.2.
|
|
30
|
+
"@jfdevelops/create-error": "0.2.1",
|
|
31
31
|
"arktype": "2.2.8",
|
|
32
|
-
"@jfdevelops/react-layout-validator": "0.
|
|
32
|
+
"@jfdevelops/react-layout-validator": "0.5.0"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
35
|
"react": ">=18",
|