@cedarjs/web 6.0.0-canary.2871 → 6.0.0-canary.2874
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/components/cell/cellTypes.d.ts +15 -8
- package/dist/components/cell/cellTypes.d.ts.map +1 -1
- package/dist/components/cell/createCell.d.ts +2 -1
- package/dist/components/cell/createCell.d.ts.map +1 -1
- package/dist/components/cell/createCell.js +30 -33
- package/dist/components/cell/createFragmentCell.d.ts +2 -1
- package/dist/components/cell/createFragmentCell.d.ts.map +1 -1
- package/dist/components/cell/createFragmentCell.js +4 -2
- package/dist/components/cell/createServerCell.d.ts +3 -2
- package/dist/components/cell/createServerCell.d.ts.map +1 -1
- package/dist/components/cell/createServerCell.js +4 -2
- package/dist/components/cell/createSuspendingCell.d.ts +2 -1
- package/dist/components/cell/createSuspendingCell.d.ts.map +1 -1
- package/dist/components/cell/createSuspendingCell.js +19 -30
- package/package.json +6 -6
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ComponentProps, JSXElementConstructor } from 'react';
|
|
2
|
-
import type { ApolloClient, NetworkStatus, OperationVariables } from '@apollo/client';
|
|
2
|
+
import type { ApolloClient, NetworkStatus, OperationVariables, TypedDocumentNode } from '@apollo/client';
|
|
3
3
|
import type { QueryRef, SkipToken, useBackgroundQuery, useQuery } from '@apollo/client/react';
|
|
4
4
|
import type { DocumentNode } from 'graphql';
|
|
5
5
|
import type { A, L, O, U } from 'ts-toolbelt';
|
|
@@ -22,7 +22,7 @@ type CellPropsVariables<Cell, GQLVariables> = Cell extends {
|
|
|
22
22
|
* Cell component props which is the combination of query variables and Success props.
|
|
23
23
|
*/
|
|
24
24
|
export type CellProps<CellSuccess extends keyof JSX.IntrinsicElements | JSXElementConstructor<any>, GQLResult, CellType, GQLVariables> = A.Compute<Omit<ComponentProps<CellSuccess>, keyof CellPropsVariables<CellType, GQLVariables> | keyof (GQLVariables extends Record<string, never> ? unknown : GQLVariables) | keyof GQLResult | 'updating' | 'queryResult'> & CellPropsVariables<CellType, GQLVariables>>;
|
|
25
|
-
type InputVarProps<T> = T extends {
|
|
25
|
+
type InputVarProps<T> = unknown extends T ? unknown : T extends {
|
|
26
26
|
[key: string]: never;
|
|
27
27
|
} ? unknown : T;
|
|
28
28
|
export type CellLoadingProps<TVariables extends OperationVariables = any> = {
|
|
@@ -104,15 +104,22 @@ export type CellBeforeQueryOptions<CellVariables> = {
|
|
|
104
104
|
export type CellBeforeQueryResult<CellVariables> = CellBeforeQueryOptions<CellVariables> | SkipToken;
|
|
105
105
|
/**
|
|
106
106
|
* The main interface.
|
|
107
|
+
*
|
|
108
|
+
* @param GQLResult - The shape of the data returned by `QUERY` (or, for
|
|
109
|
+
* fragment Cells, the shape of the fragment's data). This is what
|
|
110
|
+
* `Success`/`Empty` receive their data as. Defaults to `any` so Cells that
|
|
111
|
+
* don't -- or can't -- type their `QUERY` with `TypedDocumentNode` (e.g. in
|
|
112
|
+
* tests, or Cells built from a plain string) keep the pre-existing loose
|
|
113
|
+
* behavior instead of erroring.
|
|
107
114
|
*/
|
|
108
|
-
export interface CreateCellProps<CellProps, CellVariables> {
|
|
115
|
+
export interface CreateCellProps<CellProps, CellVariables extends OperationVariables = OperationVariables, GQLResult = any> {
|
|
109
116
|
/**
|
|
110
117
|
* The GraphQL syntax tree to execute or function to call that returns it.
|
|
111
118
|
* If `QUERY` is a function, it's called with the result of `beforeQuery`.
|
|
112
119
|
*
|
|
113
120
|
* Either `QUERY` or `FRAGMENT` must be provided.
|
|
114
121
|
*/
|
|
115
|
-
QUERY?: DocumentNode | ((variables: Record<string, unknown>) => DocumentNode);
|
|
122
|
+
QUERY?: TypedDocumentNode<GQLResult, CellVariables> | DocumentNode | ((variables: Record<string, unknown>) => DocumentNode);
|
|
116
123
|
/**
|
|
117
124
|
* A GraphQL fragment that declares this Cell's data requirements. Fragment
|
|
118
125
|
* Cells don't fire their own query. Instead a parent Cell spreads the
|
|
@@ -160,19 +167,19 @@ export interface CreateCellProps<CellProps, CellVariables> {
|
|
|
160
167
|
/**
|
|
161
168
|
* If the query's in flight and there's no stale data, render this.
|
|
162
169
|
*/
|
|
163
|
-
Loading?: React.FC<CellLoadingProps & Partial<CellProps>>;
|
|
170
|
+
Loading?: React.FC<CellLoadingProps<CellVariables> & Partial<CellProps>>;
|
|
164
171
|
/**
|
|
165
172
|
* If something went wrong, render this.
|
|
166
173
|
*/
|
|
167
|
-
Failure?: React.FC<CellFailureProps & Partial<CellProps>>;
|
|
174
|
+
Failure?: React.FC<CellFailureProps<CellVariables> & Partial<CellProps>>;
|
|
168
175
|
/**
|
|
169
176
|
* If no data was returned, render this.
|
|
170
177
|
*/
|
|
171
|
-
Empty?: React.FC<CellSuccessProps & Partial<CellProps>>;
|
|
178
|
+
Empty?: React.FC<CellSuccessProps<GQLResult, CellVariables> & Partial<CellProps>>;
|
|
172
179
|
/**
|
|
173
180
|
* If data was returned, render this.
|
|
174
181
|
*/
|
|
175
|
-
Success: React.FC<CellSuccessProps & Partial<CellProps>>;
|
|
182
|
+
Success: React.FC<CellSuccessProps<GQLResult, CellVariables> & Partial<CellProps>>;
|
|
176
183
|
/**
|
|
177
184
|
* What to call the Cell. Defaults to the filename.
|
|
178
185
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cellTypes.d.ts","sourceRoot":"","sources":["../../../src/components/cell/cellTypes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,OAAO,CAAA;AAElE,OAAO,KAAK,EACV,YAAY,EACZ,aAAa,EACb,kBAAkB,
|
|
1
|
+
{"version":3,"file":"cellTypes.d.ts","sourceRoot":"","sources":["../../../src/components/cell/cellTypes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,OAAO,CAAA;AAElE,OAAO,KAAK,EACV,YAAY,EACZ,aAAa,EACb,kBAAkB,EAClB,iBAA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C/B,CAAA;AAED,MAAM,MAAM,0BAA0B,CACpC,UAAU,SAAS,kBAAkB,GAAG,GAAG,EAC3C,KAAK,GAAG,GAAG,IACT,OAAO,CACT,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,EAAE,UAAU,CAAC,EAAE,SAAS,GAAG,OAAO,GAAG,MAAM,CAAC,CACvE,CAAA;AAID,MAAM,WAAW,uBAAuB,CACtC,MAAM,GAAG,GAAG,EACZ,WAAW,SAAS,kBAAkB,GAAG,GAAG,CAC5C,SAAQ,kBAAkB,CAAC,MAAM,CAAC,UAAU,CAAC;IAC7C,MAAM,EAAE,YAAY,CAAA;IAEpB,aAAa,CAAC,EAAE,aAAa,CAAA;IAC7B,MAAM,EAAE,OAAO,CAAA;CAChB"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import type { OperationVariables } from '@apollo/client';
|
|
2
3
|
import type { CreateCellProps } from './cellTypes.js';
|
|
3
|
-
export declare function createCell<CellProps extends Record<string, unknown>, CellVariables extends
|
|
4
|
+
export declare function createCell<CellProps extends Record<string, unknown>, CellVariables extends OperationVariables = OperationVariables, GQLResult = any>(createCellProps: CreateCellProps<CellProps, CellVariables, GQLResult>): React.FC<CellProps>;
|
|
4
5
|
//# sourceMappingURL=createCell.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createCell.d.ts","sourceRoot":"","sources":["../../../src/components/cell/createCell.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"createCell.d.ts","sourceRoot":"","sources":["../../../src/components/cell/createCell.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AAQxD,OAAO,KAAK,EAAE,eAAe,EAAc,MAAM,gBAAgB,CAAA;AAKjE,wBAAgB,UAAU,CACxB,SAAS,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACzC,aAAa,SAAS,kBAAkB,GAAG,kBAAkB,EAC7D,SAAS,GAAG,GAAG,EAEf,eAAe,EAAE,eAAe,CAAC,SAAS,EAAE,aAAa,EAAE,SAAS,CAAC,GACpE,KAAK,CAAC,EAAE,CAAC,SAAS,CAAC,CAoCrB"}
|
|
@@ -16,7 +16,9 @@ function createCell(createCellProps) {
|
|
|
16
16
|
}
|
|
17
17
|
if (RWJS_ENV.RWJS_EXP_STREAMING_SSR) {
|
|
18
18
|
const suspendingCellProps = createCellProps;
|
|
19
|
-
return createSuspendingCell(
|
|
19
|
+
return createSuspendingCell(
|
|
20
|
+
suspendingCellProps
|
|
21
|
+
);
|
|
20
22
|
}
|
|
21
23
|
return createNonSuspendingCell(createCellProps);
|
|
22
24
|
}
|
|
@@ -98,47 +100,42 @@ function createNonSuspendingCell({
|
|
|
98
100
|
}
|
|
99
101
|
if (error) {
|
|
100
102
|
if (Failure) {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
errorCode:
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
}
|
|
113
|
-
);
|
|
103
|
+
const failureProps = {
|
|
104
|
+
error,
|
|
105
|
+
errorCode: (
|
|
106
|
+
// Use the ad-hoc QueryResultWithErrorCode type to access the errorCode
|
|
107
|
+
queryResult.errorCode ?? (CombinedGraphQLErrors.is(error) ? error.errors[0]?.extensions?.["code"] : void 0)
|
|
108
|
+
),
|
|
109
|
+
...props,
|
|
110
|
+
updating: loading,
|
|
111
|
+
queryResult
|
|
112
|
+
};
|
|
113
|
+
return /* @__PURE__ */ React.createElement(Failure, { ...failureProps });
|
|
114
114
|
} else {
|
|
115
115
|
throw error instanceof Error ? error : new Error(error.message);
|
|
116
116
|
}
|
|
117
117
|
} else if (data) {
|
|
118
118
|
const afterQueryData = afterQuery(data);
|
|
119
119
|
if (isEmpty(data, { isDataEmpty }) && Empty) {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
}
|
|
128
|
-
);
|
|
120
|
+
const emptyProps = {
|
|
121
|
+
...props,
|
|
122
|
+
...afterQueryData,
|
|
123
|
+
updating: loading,
|
|
124
|
+
queryResult
|
|
125
|
+
};
|
|
126
|
+
return /* @__PURE__ */ React.createElement(Empty, { ...emptyProps });
|
|
129
127
|
} else {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
}
|
|
138
|
-
);
|
|
128
|
+
const successProps = {
|
|
129
|
+
...props,
|
|
130
|
+
...afterQueryData,
|
|
131
|
+
updating: loading,
|
|
132
|
+
queryResult
|
|
133
|
+
};
|
|
134
|
+
return /* @__PURE__ */ React.createElement(Success, { ...successProps });
|
|
139
135
|
}
|
|
140
136
|
} else if (loading) {
|
|
141
|
-
|
|
137
|
+
const loadingProps = { ...props, queryResult };
|
|
138
|
+
return /* @__PURE__ */ React.createElement(Loading, { ...loadingProps });
|
|
142
139
|
} else {
|
|
143
140
|
console.warn(
|
|
144
141
|
`If you're using Apollo Client, check for its debug logs here in the console, which may help explain the error.`
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import type { OperationVariables } from '@apollo/client';
|
|
2
3
|
import type { CreateCellProps } from './cellTypes.js';
|
|
3
4
|
/**
|
|
4
5
|
* Creates a Cell out of a GraphQL fragment and components that render its
|
|
@@ -15,5 +16,5 @@ import type { CreateCellProps } from './cellTypes.js';
|
|
|
15
16
|
* mutations update the underlying entity. If the cache read is incomplete,
|
|
16
17
|
* the passed-in object itself is used as the data snapshot.
|
|
17
18
|
*/
|
|
18
|
-
export declare function createFragmentCell<CellProps extends Record<string, unknown>, CellVariables extends
|
|
19
|
+
export declare function createFragmentCell<CellProps extends Record<string, unknown>, CellVariables extends OperationVariables = OperationVariables, GQLResult = any>({ FRAGMENT, afterQuery, isEmpty, Empty, Success, displayName, }: CreateCellProps<CellProps, CellVariables, GQLResult>): React.FC<CellProps>;
|
|
19
20
|
//# sourceMappingURL=createFragmentCell.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createFragmentCell.d.ts","sourceRoot":"","sources":["../../../src/components/cell/createFragmentCell.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"createFragmentCell.d.ts","sourceRoot":"","sources":["../../../src/components/cell/createFragmentCell.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AAMxD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAqDrD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,kBAAkB,CAChC,SAAS,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACzC,aAAa,SAAS,kBAAkB,GAAG,kBAAkB,EAC7D,SAAS,GAAG,GAAG,EACf,EACA,QAAQ,EACR,UAA2B,EAC3B,OAAqB,EACrB,KAAK,EACL,OAAO,EACP,WAAoB,GACrB,EAAE,eAAe,CAAC,SAAS,EAAE,aAAa,EAAE,SAAS,CAAC,GAAG,KAAK,CAAC,EAAE,CAAC,SAAS,CAAC,CAiF5E"}
|
|
@@ -58,10 +58,12 @@ function createFragmentCell({
|
|
|
58
58
|
}
|
|
59
59
|
const data = fragmentResult.complete ? fragmentResult.data : dataRef ?? null;
|
|
60
60
|
const afterQueryData = afterQuery({ [propName]: data });
|
|
61
|
+
const restProps = rest;
|
|
62
|
+
const successProps = { ...restProps, ...afterQueryData };
|
|
61
63
|
if (isEmpty({ [propName]: data }, { isDataEmpty }) && Empty) {
|
|
62
|
-
return /* @__PURE__ */ React.createElement(Empty, { ...
|
|
64
|
+
return /* @__PURE__ */ React.createElement(Empty, { ...successProps });
|
|
63
65
|
}
|
|
64
|
-
return /* @__PURE__ */ React.createElement(Success, { ...
|
|
66
|
+
return /* @__PURE__ */ React.createElement(Success, { ...successProps });
|
|
65
67
|
}
|
|
66
68
|
NamedCell.displayName = displayName;
|
|
67
69
|
return (props) => {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import type { OperationVariables } from '@apollo/client';
|
|
2
3
|
import type { CreateCellProps } from './cellTypes.js';
|
|
3
|
-
type CreateServerCellProps<CellProps, CellVariables> = Omit<CreateCellProps<CellProps, CellVariables>, 'QUERY' | 'Failure'> & {
|
|
4
|
+
type CreateServerCellProps<CellProps, CellVariables extends OperationVariables = OperationVariables, GQLResult = any> = Omit<CreateCellProps<CellProps, CellVariables, GQLResult>, 'QUERY' | 'Failure'> & {
|
|
4
5
|
data: (variables?: AnyObj) => any;
|
|
5
6
|
Failure?: React.ComponentType<{
|
|
6
7
|
error: unknown;
|
|
@@ -10,6 +11,6 @@ type CreateServerCellProps<CellProps, CellVariables> = Omit<CreateCellProps<Cell
|
|
|
10
11
|
}>;
|
|
11
12
|
};
|
|
12
13
|
type AnyObj = Record<string, unknown>;
|
|
13
|
-
export declare function createServerCell<CellProps extends AnyObj, CellVariables extends
|
|
14
|
+
export declare function createServerCell<CellProps extends AnyObj, CellVariables extends OperationVariables = OperationVariables, GQLResult = any>(createCellProps: CreateServerCellProps<CellProps, CellVariables, GQLResult>): React.FC<CellProps>;
|
|
14
15
|
export {};
|
|
15
16
|
//# sourceMappingURL=createServerCell.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createServerCell.d.ts","sourceRoot":"","sources":["../../../src/components/cell/createServerCell.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAmB,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"createServerCell.d.ts","sourceRoot":"","sources":["../../../src/components/cell/createServerCell.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAmB,MAAM,OAAO,CAAA;AAEvC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AAMxD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAIrD,KAAK,qBAAqB,CACxB,SAAS,EACT,aAAa,SAAS,kBAAkB,GAAG,kBAAkB,EAC7D,SAAS,GAAG,GAAG,IACb,IAAI,CACN,eAAe,CAAC,SAAS,EAAE,aAAa,EAAE,SAAS,CAAC,EACpD,OAAO,GAAG,SAAS,CACpB,GAAG;IACF,IAAI,EAAE,CAAC,SAAS,CAAC,EAAE,MAAM,KAAK,GAAG,CAAA;IACjC,OAAO,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;QAC5B,KAAK,EAAE,OAAO,CAAA;QACd,WAAW,EAAE;YAAE,OAAO,EAAE,CAAC,SAAS,EAAE,SAAS,KAAK,MAAM,CAAA;SAAE,CAAA;KAC3D,CAAC,CAAA;CACH,CAAA;AAED,KAAK,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;AAErC,wBAAgB,gBAAgB,CAC9B,SAAS,SAAS,MAAM,EACxB,aAAa,SAAS,kBAAkB,GAAG,kBAAkB,EAC7D,SAAS,GAAG,GAAG,EAEf,eAAe,EAAE,qBAAqB,CAAC,SAAS,EAAE,aAAa,EAAE,SAAS,CAAC,GAC1E,KAAK,CAAC,EAAE,CAAC,SAAS,CAAC,CAuFrB"}
|
|
@@ -26,9 +26,11 @@ function createServerCell(createCellProps) {
|
|
|
26
26
|
try {
|
|
27
27
|
const data = await dataFn(variables);
|
|
28
28
|
if (isEmpty(data, { isDataEmpty }) && Empty) {
|
|
29
|
-
|
|
29
|
+
const emptyProps = { ...props, ...data };
|
|
30
|
+
return /* @__PURE__ */ React.createElement(Empty, { ...emptyProps });
|
|
30
31
|
}
|
|
31
|
-
|
|
32
|
+
const successProps = { ...data, ...props };
|
|
33
|
+
return /* @__PURE__ */ React.createElement(Success, { ...successProps });
|
|
32
34
|
} catch (error) {
|
|
33
35
|
return /* @__PURE__ */ React.createElement(FailureComponent, { error });
|
|
34
36
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import type { OperationVariables } from '@apollo/client';
|
|
2
3
|
import type { CreateCellProps } from './cellTypes.js';
|
|
3
4
|
type AnyObj = Record<string, unknown>;
|
|
4
5
|
/**
|
|
@@ -6,6 +7,6 @@ type AnyObj = Record<string, unknown>;
|
|
|
6
7
|
* using the hooks useBackgroundQuery and useReadQuery
|
|
7
8
|
*
|
|
8
9
|
*/
|
|
9
|
-
export declare function createSuspendingCell<CellProps extends AnyObj, CellVariables extends
|
|
10
|
+
export declare function createSuspendingCell<CellProps extends AnyObj, CellVariables extends OperationVariables = OperationVariables, GQLResult = any>(createCellProps: CreateCellProps<AnyObj, CellVariables, GQLResult>): React.FC<CellProps>;
|
|
10
11
|
export {};
|
|
11
12
|
//# sourceMappingURL=createSuspendingCell.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createSuspendingCell.d.ts","sourceRoot":"","sources":["../../../src/components/cell/createSuspendingCell.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"createSuspendingCell.d.ts","sourceRoot":"","sources":["../../../src/components/cell/createSuspendingCell.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAA;AAEvC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AAWxD,OAAO,KAAK,EAEV,eAAe,EAIhB,MAAM,gBAAgB,CAAA;AAGvB,KAAK,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;AACrC;;;;GAIG;AACH,wBAAgB,oBAAoB,CAClC,SAAS,SAAS,MAAM,EACxB,aAAa,SAAS,kBAAkB,GAAG,kBAAkB,EAC7D,SAAS,GAAG,GAAG,EAEf,eAAe,EAAE,eAAe,CAAC,MAAM,EAAE,aAAa,EAAE,SAAS,CAAC,GACjE,KAAK,CAAC,EAAE,CAAC,SAAS,CAAC,CAmNrB"}
|
|
@@ -49,23 +49,19 @@ function createSuspendingCell(createCellProps) {
|
|
|
49
49
|
networkStatus
|
|
50
50
|
};
|
|
51
51
|
if (isEmpty(data, { isDataEmpty }) && Empty) {
|
|
52
|
-
|
|
53
|
-
Empty,
|
|
54
|
-
{
|
|
55
|
-
...userProps,
|
|
56
|
-
...afterQueryData,
|
|
57
|
-
queryResult: queryResultWithNetworkStatus
|
|
58
|
-
}
|
|
59
|
-
);
|
|
60
|
-
}
|
|
61
|
-
return /* @__PURE__ */ React.createElement(
|
|
62
|
-
Success,
|
|
63
|
-
{
|
|
64
|
-
...afterQueryData,
|
|
52
|
+
const emptyProps = {
|
|
65
53
|
...userProps,
|
|
54
|
+
...afterQueryData,
|
|
66
55
|
queryResult: queryResultWithNetworkStatus
|
|
67
|
-
}
|
|
68
|
-
|
|
56
|
+
};
|
|
57
|
+
return /* @__PURE__ */ React.createElement(Empty, { ...emptyProps });
|
|
58
|
+
}
|
|
59
|
+
const successProps = {
|
|
60
|
+
...afterQueryData,
|
|
61
|
+
...userProps,
|
|
62
|
+
queryResult: queryResultWithNetworkStatus
|
|
63
|
+
};
|
|
64
|
+
return /* @__PURE__ */ React.createElement(Success, { ...successProps });
|
|
69
65
|
}
|
|
70
66
|
SuspendingSuccess.displayName = displayName;
|
|
71
67
|
return (props) => {
|
|
@@ -102,26 +98,19 @@ function createSuspendingCell(createCellProps) {
|
|
|
102
98
|
return suspenseQueryResult.refetch?.(variables2);
|
|
103
99
|
}
|
|
104
100
|
};
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
}
|
|
112
|
-
);
|
|
101
|
+
const failureProps = {
|
|
102
|
+
error,
|
|
103
|
+
errorCode: CombinedGraphQLErrors.is(error) ? error.errors[0]?.extensions?.["code"] : void 0,
|
|
104
|
+
queryResult: queryResultWithErrorReset
|
|
105
|
+
};
|
|
106
|
+
return /* @__PURE__ */ React.createElement(Failure, { ...failureProps });
|
|
113
107
|
};
|
|
114
108
|
const wrapInSuspenseIfLoadingPresent = (suspendingSuccessElement, LoadingComponent) => {
|
|
115
109
|
if (!LoadingComponent) {
|
|
116
110
|
return suspendingSuccessElement;
|
|
117
111
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
{
|
|
121
|
-
fallback: /* @__PURE__ */ React.createElement(LoadingComponent, { ...props, queryResult: suspenseQueryResult })
|
|
122
|
-
},
|
|
123
|
-
suspendingSuccessElement
|
|
124
|
-
);
|
|
112
|
+
const loadingProps = { ...props, queryResult: suspenseQueryResult };
|
|
113
|
+
return /* @__PURE__ */ React.createElement(Suspense, { fallback: /* @__PURE__ */ React.createElement(LoadingComponent, { ...loadingProps }) }, suspendingSuccessElement);
|
|
125
114
|
};
|
|
126
115
|
return /* @__PURE__ */ React.createElement(CellErrorBoundary, { renderFallback: FailureComponent }, wrapInSuspenseIfLoadingPresent(
|
|
127
116
|
/* @__PURE__ */ React.createElement(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cedarjs/web",
|
|
3
|
-
"version": "6.0.0-canary.
|
|
3
|
+
"version": "6.0.0-canary.2874",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/cedarjs/cedar.git",
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
},
|
|
82
82
|
"dependencies": {
|
|
83
83
|
"@apollo/client": "4.2.7",
|
|
84
|
-
"@cedarjs/server-store": "6.0.0-canary.
|
|
84
|
+
"@cedarjs/server-store": "6.0.0-canary.2874",
|
|
85
85
|
"@dr.pogodin/react-helmet": "2.0.4",
|
|
86
86
|
"@whatwg-node/fetch": "0.10.13",
|
|
87
87
|
"apollo-upload-client": "19.0.0",
|
|
@@ -101,9 +101,9 @@
|
|
|
101
101
|
"@babel/core": "^7.26.10",
|
|
102
102
|
"@babel/plugin-transform-runtime": "7.29.7",
|
|
103
103
|
"@babel/runtime": "7.29.7",
|
|
104
|
-
"@cedarjs/auth": "6.0.0-canary.
|
|
105
|
-
"@cedarjs/framework-tools": "6.0.0-canary.
|
|
106
|
-
"@cedarjs/internal": "6.0.0-canary.
|
|
104
|
+
"@cedarjs/auth": "6.0.0-canary.2874",
|
|
105
|
+
"@cedarjs/framework-tools": "6.0.0-canary.2874",
|
|
106
|
+
"@cedarjs/internal": "6.0.0-canary.2874",
|
|
107
107
|
"@rollup/plugin-babel": "6.1.0",
|
|
108
108
|
"@testing-library/dom": "10.4.1",
|
|
109
109
|
"@testing-library/jest-dom": "6.9.1",
|
|
@@ -121,7 +121,7 @@
|
|
|
121
121
|
"vitest": "4.1.10"
|
|
122
122
|
},
|
|
123
123
|
"peerDependencies": {
|
|
124
|
-
"@cedarjs/auth": "6.0.0-canary.
|
|
124
|
+
"@cedarjs/auth": "6.0.0-canary.2874",
|
|
125
125
|
"react": "19.2.3",
|
|
126
126
|
"react-dom": "19.2.3"
|
|
127
127
|
},
|