@jfdevelops/react-layout 0.17.1 → 0.17.2
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/props.d.cts
CHANGED
|
@@ -33,18 +33,26 @@ type InPropsFunction<Resources extends ReadonlyArray<ResourceDefinition>> = <Nam
|
|
|
33
33
|
type InPropsDefinition<Resources extends ReadonlyArray<ResourceDefinition>> = InPropsObject | InPropsFunction<Resources>;
|
|
34
34
|
type InferredInProps<Resources extends ReadonlyArray<ResourceDefinition>, Options extends InPropsDefinition<Resources>> = Options extends InPropsFunction<Resources> ? ReturnType<Options> : Options;
|
|
35
35
|
type MergedLayoutInProps<Resources extends ReadonlyArray<ResourceDefinition>, Options extends InPropsDefinition<Resources>, Composables extends ComposableComponents> = InferredInProps<Resources, Options> extends InPropsObject ? InferredInProps<Resources, Options> & MergePresetProps<Composables> : never;
|
|
36
|
+
type RequiredVariant = true | 'required';
|
|
37
|
+
/**
|
|
38
|
+
* @typeParam RequiredVariant How the required props are selected. In application code,
|
|
39
|
+
* it will always be `true`, but internally we need to support `'required'` as well.
|
|
40
|
+
*/
|
|
41
|
+
type PropsType<Variant extends RequiredVariant = true> = Variant | 'optional';
|
|
42
|
+
type InternalPropsType = PropsType<'required'>;
|
|
36
43
|
/**
|
|
37
44
|
* A map of props to include in the layout.
|
|
38
45
|
*/
|
|
39
|
-
type IncludedProps<T extends object> = { [K in keyof T & string]?:
|
|
40
|
-
type
|
|
41
|
-
type
|
|
42
|
-
type
|
|
46
|
+
type IncludedProps<T extends object> = { [K in keyof T & string]?: PropsType };
|
|
47
|
+
type PropsKeys<Props extends InPropsObject, T> = T & keyof Props;
|
|
48
|
+
type GetPropsKey<IncludeProps extends object, Type extends PropsType = true> = { [key in keyof IncludeProps]: IncludeProps[key] extends Type ? key : never }[keyof IncludeProps];
|
|
49
|
+
type SelectedIncludedProps<Props extends InPropsObject, IncludeProps extends IncludedProps<Props>, Type extends InternalPropsType> = Pick<Props, PropsKeys<Props, GetPropsKey<IncludeProps, Type extends 'required' ? true : 'optional'>>>;
|
|
50
|
+
type ResolvedIncludedProps<Props extends InPropsObject, IncludeProps extends IncludedProps<Props>> = ResolveLayoutProps<SelectedIncludedProps<Props, IncludeProps, 'required'>> & Partial<ResolveLayoutProps<SelectedIncludedProps<Props, IncludeProps, 'optional'>>>;
|
|
43
51
|
/**
|
|
44
52
|
* Like {@link ResolvedIncludedProps}, but keeps included prop keys exactly as
|
|
45
53
|
* declared (no `JSX.Element` capitalization).
|
|
46
54
|
*/
|
|
47
|
-
type ResolvedIncludedPropsAsDefined<Props extends InPropsObject, IncludeProps extends IncludedProps<Props>> = ResolveLayoutPropsAsDefined<
|
|
55
|
+
type ResolvedIncludedPropsAsDefined<Props extends InPropsObject, IncludeProps extends IncludedProps<Props>> = ResolveLayoutPropsAsDefined<SelectedIncludedProps<Props, IncludeProps, 'required'>> & Partial<ResolveLayoutPropsAsDefined<SelectedIncludedProps<Props, IncludeProps, 'optional'>>>;
|
|
48
56
|
type LayoutRenderProps<Resources extends ReadonlyArray<ResourceDefinition>, Options extends InPropsDefinition<Resources>, Composables extends ComposableComponents = {}, IncludeProps extends IncludedProps<MergedLayoutInProps<Resources, Options, Composables>> = {}, CustomProps extends InPropsObject = {}> = Show<ResolveProps<CustomProps> & ResolvedIncludedProps<MergedLayoutInProps<Resources, Options, Composables>, IncludeProps>>;
|
|
49
57
|
//#endregion
|
|
50
58
|
export { InPropsDefinition, InPropsFunction, type InPropsObject, InPropsOptions, IncludedProps, InferredInProps, LayoutRenderProps, MergedLayoutInProps, PropsContextRender, PropsRenderDefinition, ResolvedIncludedProps, ResolvedIncludedPropsAsDefined };
|
package/dist/props.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"props.d.cts","names":[],"sources":["../src/props.ts"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"props.d.cts","names":[],"sources":["../src/props.ts"],"mappings":";;;;;;AAsBA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IAAA,GAAO,GAAA,iBACxD,YAAA;AAAA,KACH,qBAAA,eACW,aAAA,uBACO,aAAA,CAAc,KAAA,gBACtB,iBAAA,IACX,IAAA,CACF,KAAA,EACA,SAAA,CACE,KAAA,EACA,WAAA,CAAY,YAAA,EAAc,IAAA;AAAA,KAIlB,qBAAA,eACI,aAAA,uBACO,aAAA,CAAc,KAAA,KACjC,kBAAA,CAAmB,qBAAA,CAAsB,KAAA,EAAO,YAAA,iBAClD,OAAA,CACE,kBAAA,CAAmB,qBAAA,CAAsB,KAAA,EAAO,YAAA;;;AAjEK;AAGzD;KAqEY,8BAAA,eACI,aAAA,uBACO,aAAA,CAAc,KAAA,KACjC,2BAAA,CACF,qBAAA,CAAsB,KAAA,EAAO,YAAA,iBAE7B,OAAA,CACE,2BAAA,CACE,qBAAA,CAAsB,KAAA,EAAO,YAAA;AAAA,KAGvB,iBAAA,mBACQ,aAAA,CAAc,kBAAA,mBAChB,iBAAA,CAAkB,SAAA,uBACd,oBAAA,4BACC,aAAA,CACnB,mBAAA,CAAoB,SAAA,EAAW,OAAA,EAAS,WAAA,6BAEtB,aAAA,SAClB,IAAA,CACF,YAAA,CAAa,WAAA,IACX,qBAAA,CACE,mBAAA,CAAoB,SAAA,EAAW,OAAA,EAAS,WAAA,GACxC,YAAA"}
|
package/dist/props.d.mts
CHANGED
|
@@ -33,18 +33,26 @@ type InPropsFunction<Resources extends ReadonlyArray<ResourceDefinition>> = <Nam
|
|
|
33
33
|
type InPropsDefinition<Resources extends ReadonlyArray<ResourceDefinition>> = InPropsObject | InPropsFunction<Resources>;
|
|
34
34
|
type InferredInProps<Resources extends ReadonlyArray<ResourceDefinition>, Options extends InPropsDefinition<Resources>> = Options extends InPropsFunction<Resources> ? ReturnType<Options> : Options;
|
|
35
35
|
type MergedLayoutInProps<Resources extends ReadonlyArray<ResourceDefinition>, Options extends InPropsDefinition<Resources>, Composables extends ComposableComponents> = InferredInProps<Resources, Options> extends InPropsObject ? InferredInProps<Resources, Options> & MergePresetProps<Composables> : never;
|
|
36
|
+
type RequiredVariant = true | 'required';
|
|
37
|
+
/**
|
|
38
|
+
* @typeParam RequiredVariant How the required props are selected. In application code,
|
|
39
|
+
* it will always be `true`, but internally we need to support `'required'` as well.
|
|
40
|
+
*/
|
|
41
|
+
type PropsType<Variant extends RequiredVariant = true> = Variant | 'optional';
|
|
42
|
+
type InternalPropsType = PropsType<'required'>;
|
|
36
43
|
/**
|
|
37
44
|
* A map of props to include in the layout.
|
|
38
45
|
*/
|
|
39
|
-
type IncludedProps<T extends object> = { [K in keyof T & string]?:
|
|
40
|
-
type
|
|
41
|
-
type
|
|
42
|
-
type
|
|
46
|
+
type IncludedProps<T extends object> = { [K in keyof T & string]?: PropsType };
|
|
47
|
+
type PropsKeys<Props extends InPropsObject, T> = T & keyof Props;
|
|
48
|
+
type GetPropsKey<IncludeProps extends object, Type extends PropsType = true> = { [key in keyof IncludeProps]: IncludeProps[key] extends Type ? key : never }[keyof IncludeProps];
|
|
49
|
+
type SelectedIncludedProps<Props extends InPropsObject, IncludeProps extends IncludedProps<Props>, Type extends InternalPropsType> = Pick<Props, PropsKeys<Props, GetPropsKey<IncludeProps, Type extends 'required' ? true : 'optional'>>>;
|
|
50
|
+
type ResolvedIncludedProps<Props extends InPropsObject, IncludeProps extends IncludedProps<Props>> = ResolveLayoutProps<SelectedIncludedProps<Props, IncludeProps, 'required'>> & Partial<ResolveLayoutProps<SelectedIncludedProps<Props, IncludeProps, 'optional'>>>;
|
|
43
51
|
/**
|
|
44
52
|
* Like {@link ResolvedIncludedProps}, but keeps included prop keys exactly as
|
|
45
53
|
* declared (no `JSX.Element` capitalization).
|
|
46
54
|
*/
|
|
47
|
-
type ResolvedIncludedPropsAsDefined<Props extends InPropsObject, IncludeProps extends IncludedProps<Props>> = ResolveLayoutPropsAsDefined<
|
|
55
|
+
type ResolvedIncludedPropsAsDefined<Props extends InPropsObject, IncludeProps extends IncludedProps<Props>> = ResolveLayoutPropsAsDefined<SelectedIncludedProps<Props, IncludeProps, 'required'>> & Partial<ResolveLayoutPropsAsDefined<SelectedIncludedProps<Props, IncludeProps, 'optional'>>>;
|
|
48
56
|
type LayoutRenderProps<Resources extends ReadonlyArray<ResourceDefinition>, Options extends InPropsDefinition<Resources>, Composables extends ComposableComponents = {}, IncludeProps extends IncludedProps<MergedLayoutInProps<Resources, Options, Composables>> = {}, CustomProps extends InPropsObject = {}> = Show<ResolveProps<CustomProps> & ResolvedIncludedProps<MergedLayoutInProps<Resources, Options, Composables>, IncludeProps>>;
|
|
49
57
|
//#endregion
|
|
50
58
|
export { InPropsDefinition, InPropsFunction, type InPropsObject, InPropsOptions, IncludedProps, InferredInProps, LayoutRenderProps, MergedLayoutInProps, PropsContextRender, PropsRenderDefinition, ResolvedIncludedProps, ResolvedIncludedPropsAsDefined };
|
package/dist/props.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"props.d.mts","names":[],"sources":["../src/props.ts"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"props.d.mts","names":[],"sources":["../src/props.ts"],"mappings":";;;;;;AAsBA;;;;;AAAA,KAAY,kBAAA,4CACV,KAAA,EAAO,WAAA,EACP,OAAA,EAAS,OAAA,KACN,MAAA;;;;;;;;;;;;UAaY,qBAAA,SACP,aAAA,iBACM,KAAA,SAAc,aAAA,GAAgB,YAAA,CAAa,KAAA;EAIzD,KAAA,GAAQ,KAAA;EACR,MAAA,EAAQ,kBAAA,CAAmB,WAAA,EAAa,OAAA,EAAS,MAAA;AAAA;AAAA,KAGvC,cAAA,mBACQ,aAAA,CAAc,kBAAA;EAGhC,IAAA,EAAM,kBAAA,CAAmB,IAAA;EACzB,QAAA,EAAU,eAAA,CAAgB,YAAA,CAAa,SAAA;AAAA;AAAA,KAE7B,eAAA,mBACQ,aAAA,CAAc,kBAAA,2BAEhC,KAAA,EAAO,IAAA,CAAK,cAAA,CAAe,SAAA,EAAW,IAAA,OACnC,aAAA;AAAA,KACO,iB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GvB,iBAAA,mBACQ,aAAA,CAAc,kBAAA,mBAChB,iBAAA,CAAkB,SAAA,uBACd,oBAAA,4BACC,aAAA,CACnB,mBAAA,CAAoB,SAAA,EAAW,OAAA,EAAS,WAAA,6BAEtB,aAAA,SAClB,IAAA,CACF,YAAA,CAAa,WAAA,IACX,qBAAA,CACE,mBAAA,CAAoB,SAAA,EAAW,OAAA,EAAS,WAAA,GACxC,YAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jfdevelops/react-layout",
|
|
3
|
-
"version": "0.17.
|
|
3
|
+
"version": "0.17.2",
|
|
4
4
|
"description": "A React library for creating layout components.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
"node": "^20.19.0 || >=22.12.0"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@jfdevelops/react-layout-composables": "0.2.
|
|
31
|
-
"@jfdevelops/react-layout-validator": "0.2.
|
|
30
|
+
"@jfdevelops/react-layout-composables": "0.2.5",
|
|
31
|
+
"@jfdevelops/react-layout-validator": "0.2.5"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
34
|
"react": ">=18",
|
|
@@ -86,19 +86,18 @@ need distinct render implementations:
|
|
|
86
86
|
const createCalendarPage = createResourceLayout
|
|
87
87
|
.forResources('appointments', 'availability')
|
|
88
88
|
.createComponent({
|
|
89
|
+
props: {
|
|
90
|
+
include: {
|
|
91
|
+
segments: true,
|
|
92
|
+
},
|
|
93
|
+
},
|
|
89
94
|
resources: {
|
|
90
95
|
appointments: {
|
|
91
|
-
segments: {
|
|
92
|
-
title: 'Appointments',
|
|
93
|
-
},
|
|
94
96
|
render: function AppointmentsRender() {
|
|
95
97
|
return <AppointmentsView />;
|
|
96
98
|
},
|
|
97
99
|
},
|
|
98
100
|
availability: {
|
|
99
|
-
segments: {
|
|
100
|
-
title: 'Availability',
|
|
101
|
-
},
|
|
102
101
|
render: function AvailabilityRender() {
|
|
103
102
|
return <AvailabilityView />;
|
|
104
103
|
},
|
|
@@ -121,6 +120,9 @@ const createCalendarPage = createResourceLayout
|
|
|
121
120
|
|
|
122
121
|
export const AppointmentsPage = createCalendarPage('appointments');
|
|
123
122
|
export const AvailabilityPage = createCalendarPage('availability');
|
|
123
|
+
|
|
124
|
+
<AppointmentsPage segments={{ title: 'Appointments' }} />;
|
|
125
|
+
<AvailabilityPage segments={{ title: 'Availability' }} />;
|
|
124
126
|
```
|
|
125
127
|
|
|
126
128
|
Use this pattern only when the resources share meaningful behavior, controls,
|