@wix/headless-bookings 0.0.14 → 0.0.15
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/cjs/dist/react/core/service-list/ServiceList.d.ts +4 -0
- package/cjs/dist/react/core/service-list/ServiceList.js +4 -0
- package/cjs/dist/react/service/Service.js +1 -11
- package/cjs/dist/react/service-list/ServiceList.d.ts +2 -0
- package/cjs/dist/react/service-list/ServiceList.js +23 -35
- package/dist/react/core/service-list/ServiceList.d.ts +4 -0
- package/dist/react/core/service-list/ServiceList.js +4 -0
- package/dist/react/service/Service.js +1 -11
- package/dist/react/service-list/ServiceList.d.ts +2 -0
- package/dist/react/service-list/ServiceList.js +23 -35
- package/package.json +2 -2
|
@@ -46,6 +46,10 @@ export interface ServicesRenderProps {
|
|
|
46
46
|
queryOptions: QueryOptions;
|
|
47
47
|
/** Pagination metadata (limit, offset, count, hasNext) */
|
|
48
48
|
pagingMetadata: PagingMetadata;
|
|
49
|
+
/** Whether more services can be loaded */
|
|
50
|
+
hasMore: boolean;
|
|
51
|
+
/** Function to load more services */
|
|
52
|
+
loadMore: (count: number) => Promise<void>;
|
|
49
53
|
}
|
|
50
54
|
/**
|
|
51
55
|
* Component that provides services list data through render props.
|
|
@@ -48,11 +48,15 @@ export function Services(props) {
|
|
|
48
48
|
const error = serviceListService.errorSignal.get();
|
|
49
49
|
const queryOptions = serviceListService.queryOptionsSignal.get();
|
|
50
50
|
const pagingMetadata = serviceListService.pagingMetadataSignal.get();
|
|
51
|
+
const hasMore = serviceListService.hasMoreServicesSignal.get();
|
|
52
|
+
const loadMore = serviceListService.actions.loadMore;
|
|
51
53
|
return props.children({
|
|
52
54
|
services,
|
|
53
55
|
isLoading,
|
|
54
56
|
error,
|
|
55
57
|
queryOptions,
|
|
56
58
|
pagingMetadata,
|
|
59
|
+
hasMore,
|
|
60
|
+
loadMore,
|
|
57
61
|
});
|
|
58
62
|
}
|
|
@@ -535,17 +535,7 @@ export const StaffMemberRepeater = React.forwardRef((props, ref) => {
|
|
|
535
535
|
const staffMemberItemWrapper = ({ item: member, children: itemChildren, }) => {
|
|
536
536
|
return (_jsxs(React.Fragment, { children: [_jsx("span", { "data-testid": TestIds.serviceStaffMemberRepeater, children: member.name }), itemChildren] }, member.id));
|
|
537
537
|
};
|
|
538
|
-
|
|
539
|
-
if (asChild && typeof children === 'function') {
|
|
540
|
-
return (_jsx(GenericList.Repeater, { ref: ref, asChild: true, itemWrapper: staffMemberItemWrapper, children: (genericProps) => {
|
|
541
|
-
const renderProps = {
|
|
542
|
-
items: genericProps.items,
|
|
543
|
-
itemWrapper: staffMemberItemWrapper,
|
|
544
|
-
};
|
|
545
|
-
return children(renderProps);
|
|
546
|
-
} }));
|
|
547
|
-
}
|
|
548
|
-
return (_jsx(GenericList.Repeater, { ref: ref, itemWrapper: staffMemberItemWrapper, children: children }));
|
|
538
|
+
return (_jsx(GenericList.Repeater, { ref: ref, itemWrapper: staffMemberItemWrapper, asChild: asChild, children: children }));
|
|
549
539
|
});
|
|
550
540
|
StaffMemberRepeater.displayName = 'Service.StaffMembers.StaffMemberRepeater';
|
|
551
541
|
/**
|
|
@@ -15,6 +15,8 @@ export interface ServiceListRootProps {
|
|
|
15
15
|
serviceListConfig?: ServiceListServiceConfig;
|
|
16
16
|
className?: string;
|
|
17
17
|
variant?: ListVariant;
|
|
18
|
+
/** Number of items to load per page. Defaults to config limit or 100 */
|
|
19
|
+
pageSize?: number;
|
|
18
20
|
}
|
|
19
21
|
/**
|
|
20
22
|
* Root component that provides the ServiceList service context for rendering services lists.
|
|
@@ -5,8 +5,6 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
5
5
|
*/
|
|
6
6
|
import React from 'react';
|
|
7
7
|
import { GenericList, } from '@wix/headless-components/react';
|
|
8
|
-
import { useService } from '@wix/services-manager-react';
|
|
9
|
-
import { ServiceListServiceDefinition } from '../../services/service-list/service-list.js';
|
|
10
8
|
import * as CoreServiceList from '../core/service-list/ServiceList.js';
|
|
11
9
|
import * as Service from '../service/Service.js';
|
|
12
10
|
/**
|
|
@@ -44,7 +42,7 @@ var TestIds;
|
|
|
44
42
|
* ```
|
|
45
43
|
*/
|
|
46
44
|
export const Root = React.forwardRef((props, ref) => {
|
|
47
|
-
const { children, serviceListConfig, className, variant } = props;
|
|
45
|
+
const { children, serviceListConfig, className, variant, pageSize } = props;
|
|
48
46
|
const serviceConfig = serviceListConfig || {
|
|
49
47
|
services: [],
|
|
50
48
|
options: {
|
|
@@ -56,22 +54,29 @@ export const Root = React.forwardRef((props, ref) => {
|
|
|
56
54
|
},
|
|
57
55
|
},
|
|
58
56
|
};
|
|
59
|
-
|
|
57
|
+
// Calculate effective page size: prop > config limit > default
|
|
58
|
+
const effectivePageSize = pageSize ??
|
|
59
|
+
serviceListConfig?.options?.pagingMetadata?.limit ??
|
|
60
|
+
DEFAULT_PAGE_SIZE;
|
|
61
|
+
return (_jsx(CoreServiceList.Root, { serviceListConfig: serviceConfig, children: _jsx(RootContent, { className: className, ref: ref, variant: variant, pageSize: effectivePageSize, children: children }) }));
|
|
60
62
|
});
|
|
61
63
|
Root.displayName = 'ServiceList.Root';
|
|
64
|
+
/**
|
|
65
|
+
* Default page size for load more
|
|
66
|
+
*/
|
|
67
|
+
const DEFAULT_PAGE_SIZE = 100;
|
|
62
68
|
/**
|
|
63
69
|
* Internal component to handle the Root content with service access
|
|
64
70
|
*/
|
|
65
71
|
const RootContent = React.forwardRef((props, ref) => {
|
|
66
|
-
const { children, className, variant } = props;
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
return (_jsx(GenericList.Root, { items: items, loadMore: () => serviceListService.actions.loadMore(10), hasMore: serviceListService.hasMoreServicesSignal.get(), isLoading: serviceListService.isLoadingSignal.get(), className: className, ref: ref, "data-testid": TestIds.serviceListRoot, variant: variant, children: children }));
|
|
72
|
+
const { children, className, variant, pageSize = DEFAULT_PAGE_SIZE } = props;
|
|
73
|
+
return (_jsx(CoreServiceList.Services, { children: ({ services: servicesList, isLoading, hasMore, loadMore }) => {
|
|
74
|
+
const items = servicesList.map((service) => ({
|
|
75
|
+
...service,
|
|
76
|
+
id: service._id,
|
|
77
|
+
}));
|
|
78
|
+
return (_jsx(GenericList.Root, { items: items, loadMore: () => loadMore(pageSize), hasMore: hasMore, isLoading: isLoading, className: className, ref: ref, "data-testid": TestIds.serviceListRoot, variant: variant, children: children }));
|
|
79
|
+
} }));
|
|
75
80
|
});
|
|
76
81
|
/**
|
|
77
82
|
* Container for the services list with empty state support.
|
|
@@ -126,37 +131,20 @@ Services.displayName = 'ServiceList.Services';
|
|
|
126
131
|
*/
|
|
127
132
|
export const ServiceRepeater = React.forwardRef((props, ref) => {
|
|
128
133
|
const { children, asChild } = props;
|
|
129
|
-
const serviceListService = useService(ServiceListServiceDefinition);
|
|
130
|
-
const appId = serviceListService.queryOptionsSignal.get().appId;
|
|
131
134
|
// Check if children is a function that matches ServiceRootChildren pattern
|
|
132
135
|
// (function with single parameter that receives { selected, bookable })
|
|
133
136
|
const isServiceRootFunction = typeof children === 'function' && children.length === 1 && !asChild;
|
|
134
137
|
// Custom itemWrapper that matches ItemWrapperProps signature
|
|
135
138
|
const serviceItemWrapper = (wrapperProps) => {
|
|
136
139
|
const { item: service, children: itemChildren } = wrapperProps;
|
|
137
|
-
return (_jsx(Service.Root, { service: service,
|
|
140
|
+
return (_jsx(Service.Root, { service: service, "data-testid": TestIds.serviceListService, "data-service-id": service._id, "data-item-id": service._id, children: isServiceRootFunction
|
|
138
141
|
? children
|
|
139
142
|
: itemChildren }, service._id));
|
|
140
143
|
};
|
|
141
|
-
//
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
const renderProps = {
|
|
146
|
-
items: genericProps.items,
|
|
147
|
-
variant: genericProps.variant,
|
|
148
|
-
itemWrapper: (props) => serviceItemWrapper({
|
|
149
|
-
item: props.item,
|
|
150
|
-
index: props.index ?? 0,
|
|
151
|
-
children: props.children,
|
|
152
|
-
}),
|
|
153
|
-
};
|
|
154
|
-
return children(renderProps, ref);
|
|
155
|
-
}
|
|
156
|
-
: isServiceRootFunction
|
|
157
|
-
? undefined
|
|
158
|
-
: children;
|
|
159
|
-
return (_jsx(GenericList.Repeater, { ref: ref, asChild: asChild, itemWrapper: serviceItemWrapper, children: transformedChildren }));
|
|
144
|
+
// When isServiceRootFunction is true, children is a function for Service.Root (not repeater render props)
|
|
145
|
+
// so we pass undefined and let itemWrapper handle the children
|
|
146
|
+
const repeaterChildren = isServiceRootFunction ? undefined : children;
|
|
147
|
+
return (_jsx(GenericList.Repeater, { ref: ref, asChild: asChild, itemWrapper: serviceItemWrapper, children: repeaterChildren }));
|
|
160
148
|
});
|
|
161
149
|
ServiceRepeater.displayName = 'ServiceList.ServiceRepeater';
|
|
162
150
|
/**
|
|
@@ -46,6 +46,10 @@ export interface ServicesRenderProps {
|
|
|
46
46
|
queryOptions: QueryOptions;
|
|
47
47
|
/** Pagination metadata (limit, offset, count, hasNext) */
|
|
48
48
|
pagingMetadata: PagingMetadata;
|
|
49
|
+
/** Whether more services can be loaded */
|
|
50
|
+
hasMore: boolean;
|
|
51
|
+
/** Function to load more services */
|
|
52
|
+
loadMore: (count: number) => Promise<void>;
|
|
49
53
|
}
|
|
50
54
|
/**
|
|
51
55
|
* Component that provides services list data through render props.
|
|
@@ -48,11 +48,15 @@ export function Services(props) {
|
|
|
48
48
|
const error = serviceListService.errorSignal.get();
|
|
49
49
|
const queryOptions = serviceListService.queryOptionsSignal.get();
|
|
50
50
|
const pagingMetadata = serviceListService.pagingMetadataSignal.get();
|
|
51
|
+
const hasMore = serviceListService.hasMoreServicesSignal.get();
|
|
52
|
+
const loadMore = serviceListService.actions.loadMore;
|
|
51
53
|
return props.children({
|
|
52
54
|
services,
|
|
53
55
|
isLoading,
|
|
54
56
|
error,
|
|
55
57
|
queryOptions,
|
|
56
58
|
pagingMetadata,
|
|
59
|
+
hasMore,
|
|
60
|
+
loadMore,
|
|
57
61
|
});
|
|
58
62
|
}
|
|
@@ -535,17 +535,7 @@ export const StaffMemberRepeater = React.forwardRef((props, ref) => {
|
|
|
535
535
|
const staffMemberItemWrapper = ({ item: member, children: itemChildren, }) => {
|
|
536
536
|
return (_jsxs(React.Fragment, { children: [_jsx("span", { "data-testid": TestIds.serviceStaffMemberRepeater, children: member.name }), itemChildren] }, member.id));
|
|
537
537
|
};
|
|
538
|
-
|
|
539
|
-
if (asChild && typeof children === 'function') {
|
|
540
|
-
return (_jsx(GenericList.Repeater, { ref: ref, asChild: true, itemWrapper: staffMemberItemWrapper, children: (genericProps) => {
|
|
541
|
-
const renderProps = {
|
|
542
|
-
items: genericProps.items,
|
|
543
|
-
itemWrapper: staffMemberItemWrapper,
|
|
544
|
-
};
|
|
545
|
-
return children(renderProps);
|
|
546
|
-
} }));
|
|
547
|
-
}
|
|
548
|
-
return (_jsx(GenericList.Repeater, { ref: ref, itemWrapper: staffMemberItemWrapper, children: children }));
|
|
538
|
+
return (_jsx(GenericList.Repeater, { ref: ref, itemWrapper: staffMemberItemWrapper, asChild: asChild, children: children }));
|
|
549
539
|
});
|
|
550
540
|
StaffMemberRepeater.displayName = 'Service.StaffMembers.StaffMemberRepeater';
|
|
551
541
|
/**
|
|
@@ -15,6 +15,8 @@ export interface ServiceListRootProps {
|
|
|
15
15
|
serviceListConfig?: ServiceListServiceConfig;
|
|
16
16
|
className?: string;
|
|
17
17
|
variant?: ListVariant;
|
|
18
|
+
/** Number of items to load per page. Defaults to config limit or 100 */
|
|
19
|
+
pageSize?: number;
|
|
18
20
|
}
|
|
19
21
|
/**
|
|
20
22
|
* Root component that provides the ServiceList service context for rendering services lists.
|
|
@@ -5,8 +5,6 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
5
5
|
*/
|
|
6
6
|
import React from 'react';
|
|
7
7
|
import { GenericList, } from '@wix/headless-components/react';
|
|
8
|
-
import { useService } from '@wix/services-manager-react';
|
|
9
|
-
import { ServiceListServiceDefinition } from '../../services/service-list/service-list.js';
|
|
10
8
|
import * as CoreServiceList from '../core/service-list/ServiceList.js';
|
|
11
9
|
import * as Service from '../service/Service.js';
|
|
12
10
|
/**
|
|
@@ -44,7 +42,7 @@ var TestIds;
|
|
|
44
42
|
* ```
|
|
45
43
|
*/
|
|
46
44
|
export const Root = React.forwardRef((props, ref) => {
|
|
47
|
-
const { children, serviceListConfig, className, variant } = props;
|
|
45
|
+
const { children, serviceListConfig, className, variant, pageSize } = props;
|
|
48
46
|
const serviceConfig = serviceListConfig || {
|
|
49
47
|
services: [],
|
|
50
48
|
options: {
|
|
@@ -56,22 +54,29 @@ export const Root = React.forwardRef((props, ref) => {
|
|
|
56
54
|
},
|
|
57
55
|
},
|
|
58
56
|
};
|
|
59
|
-
|
|
57
|
+
// Calculate effective page size: prop > config limit > default
|
|
58
|
+
const effectivePageSize = pageSize ??
|
|
59
|
+
serviceListConfig?.options?.pagingMetadata?.limit ??
|
|
60
|
+
DEFAULT_PAGE_SIZE;
|
|
61
|
+
return (_jsx(CoreServiceList.Root, { serviceListConfig: serviceConfig, children: _jsx(RootContent, { className: className, ref: ref, variant: variant, pageSize: effectivePageSize, children: children }) }));
|
|
60
62
|
});
|
|
61
63
|
Root.displayName = 'ServiceList.Root';
|
|
64
|
+
/**
|
|
65
|
+
* Default page size for load more
|
|
66
|
+
*/
|
|
67
|
+
const DEFAULT_PAGE_SIZE = 100;
|
|
62
68
|
/**
|
|
63
69
|
* Internal component to handle the Root content with service access
|
|
64
70
|
*/
|
|
65
71
|
const RootContent = React.forwardRef((props, ref) => {
|
|
66
|
-
const { children, className, variant } = props;
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
return (_jsx(GenericList.Root, { items: items, loadMore: () => serviceListService.actions.loadMore(10), hasMore: serviceListService.hasMoreServicesSignal.get(), isLoading: serviceListService.isLoadingSignal.get(), className: className, ref: ref, "data-testid": TestIds.serviceListRoot, variant: variant, children: children }));
|
|
72
|
+
const { children, className, variant, pageSize = DEFAULT_PAGE_SIZE } = props;
|
|
73
|
+
return (_jsx(CoreServiceList.Services, { children: ({ services: servicesList, isLoading, hasMore, loadMore }) => {
|
|
74
|
+
const items = servicesList.map((service) => ({
|
|
75
|
+
...service,
|
|
76
|
+
id: service._id,
|
|
77
|
+
}));
|
|
78
|
+
return (_jsx(GenericList.Root, { items: items, loadMore: () => loadMore(pageSize), hasMore: hasMore, isLoading: isLoading, className: className, ref: ref, "data-testid": TestIds.serviceListRoot, variant: variant, children: children }));
|
|
79
|
+
} }));
|
|
75
80
|
});
|
|
76
81
|
/**
|
|
77
82
|
* Container for the services list with empty state support.
|
|
@@ -126,37 +131,20 @@ Services.displayName = 'ServiceList.Services';
|
|
|
126
131
|
*/
|
|
127
132
|
export const ServiceRepeater = React.forwardRef((props, ref) => {
|
|
128
133
|
const { children, asChild } = props;
|
|
129
|
-
const serviceListService = useService(ServiceListServiceDefinition);
|
|
130
|
-
const appId = serviceListService.queryOptionsSignal.get().appId;
|
|
131
134
|
// Check if children is a function that matches ServiceRootChildren pattern
|
|
132
135
|
// (function with single parameter that receives { selected, bookable })
|
|
133
136
|
const isServiceRootFunction = typeof children === 'function' && children.length === 1 && !asChild;
|
|
134
137
|
// Custom itemWrapper that matches ItemWrapperProps signature
|
|
135
138
|
const serviceItemWrapper = (wrapperProps) => {
|
|
136
139
|
const { item: service, children: itemChildren } = wrapperProps;
|
|
137
|
-
return (_jsx(Service.Root, { service: service,
|
|
140
|
+
return (_jsx(Service.Root, { service: service, "data-testid": TestIds.serviceListService, "data-service-id": service._id, "data-item-id": service._id, children: isServiceRootFunction
|
|
138
141
|
? children
|
|
139
142
|
: itemChildren }, service._id));
|
|
140
143
|
};
|
|
141
|
-
//
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
const renderProps = {
|
|
146
|
-
items: genericProps.items,
|
|
147
|
-
variant: genericProps.variant,
|
|
148
|
-
itemWrapper: (props) => serviceItemWrapper({
|
|
149
|
-
item: props.item,
|
|
150
|
-
index: props.index ?? 0,
|
|
151
|
-
children: props.children,
|
|
152
|
-
}),
|
|
153
|
-
};
|
|
154
|
-
return children(renderProps, ref);
|
|
155
|
-
}
|
|
156
|
-
: isServiceRootFunction
|
|
157
|
-
? undefined
|
|
158
|
-
: children;
|
|
159
|
-
return (_jsx(GenericList.Repeater, { ref: ref, asChild: asChild, itemWrapper: serviceItemWrapper, children: transformedChildren }));
|
|
144
|
+
// When isServiceRootFunction is true, children is a function for Service.Root (not repeater render props)
|
|
145
|
+
// so we pass undefined and let itemWrapper handle the children
|
|
146
|
+
const repeaterChildren = isServiceRootFunction ? undefined : children;
|
|
147
|
+
return (_jsx(GenericList.Repeater, { ref: ref, asChild: asChild, itemWrapper: serviceItemWrapper, children: repeaterChildren }));
|
|
160
148
|
});
|
|
161
149
|
ServiceRepeater.displayName = 'ServiceList.ServiceRepeater';
|
|
162
150
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wix/headless-bookings",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.15",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
@@ -68,5 +68,5 @@
|
|
|
68
68
|
"groupId": "com.wixpress.headless-components"
|
|
69
69
|
}
|
|
70
70
|
},
|
|
71
|
-
"falconPackageHash": "
|
|
71
|
+
"falconPackageHash": "d56b9bfa88501c3f0e6edec7314578de67940d2a7e425c0c34fa3c3c"
|
|
72
72
|
}
|