@cedarjs/web 6.0.0-canary.2780 → 6.0.0-canary.2782
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/bins/cedar.js +14 -0
- package/dist/bins/cfw.js +14 -0
- package/dist/bins/cross-env.js +8 -0
- package/dist/bins/msw.js +6 -0
- package/dist/bins/redwood.js +14 -0
- package/dist/bins/storybook.js +27 -0
- package/dist/bins/tsc.js +8 -0
- package/dist/bundled/apollo-upload-client.js +2727 -1
- package/package.json +41 -110
- package/dist/cjs/apollo/ApolloProviderWithFetchConfig.d.ts +0 -15
- package/dist/cjs/apollo/ApolloProviderWithFetchConfig.d.ts.map +0 -1
- package/dist/cjs/apollo/ApolloProviderWithFetchConfig.js +0 -170
- package/dist/cjs/apollo/CedarApolloProvider.d.ts +0 -14
- package/dist/cjs/apollo/CedarApolloProvider.d.ts.map +0 -1
- package/dist/cjs/apollo/CedarApolloProvider.js +0 -69
- package/dist/cjs/apollo/ErrorBoundary.d.ts +0 -13
- package/dist/cjs/apollo/ErrorBoundary.d.ts.map +0 -1
- package/dist/cjs/apollo/ErrorBoundary.js +0 -47
- package/dist/cjs/apollo/apolloLinkTypes.d.ts +0 -60
- package/dist/cjs/apollo/apolloLinkTypes.d.ts.map +0 -1
- package/dist/cjs/apollo/apolloLinkTypes.js +0 -16
- package/dist/cjs/apollo/fragmentRegistry.d.ts +0 -68
- package/dist/cjs/apollo/fragmentRegistry.d.ts.map +0 -1
- package/dist/cjs/apollo/fragmentRegistry.js +0 -108
- package/dist/cjs/apollo/index.d.ts +0 -56
- package/dist/cjs/apollo/index.d.ts.map +0 -1
- package/dist/cjs/apollo/index.js +0 -39
- package/dist/cjs/apollo/links.d.ts +0 -26
- package/dist/cjs/apollo/links.d.ts.map +0 -1
- package/dist/cjs/apollo/links.js +0 -122
- package/dist/cjs/apollo/sseLink.d.ts +0 -26
- package/dist/cjs/apollo/sseLink.d.ts.map +0 -1
- package/dist/cjs/apollo/sseLink.js +0 -117
- package/dist/cjs/apollo/suspense.d.ts +0 -69
- package/dist/cjs/apollo/suspense.d.ts.map +0 -1
- package/dist/cjs/apollo/suspense.js +0 -118
- package/dist/cjs/apollo/useCache.d.ts +0 -20
- package/dist/cjs/apollo/useCache.d.ts.map +0 -1
- package/dist/cjs/apollo/useCache.js +0 -49
- package/dist/cjs/bins/cedar.d.ts +0 -9
- package/dist/cjs/bins/cedar.d.ts.map +0 -1
- package/dist/cjs/bins/cedar.js +0 -36
- package/dist/cjs/bins/cfw.d.ts +0 -3
- package/dist/cjs/bins/cfw.d.ts.map +0 -1
- package/dist/cjs/bins/cfw.js +0 -36
- package/dist/cjs/bins/cross-env.d.ts +0 -3
- package/dist/cjs/bins/cross-env.d.ts.map +0 -1
- package/dist/cjs/bins/cross-env.js +0 -30
- package/dist/cjs/bins/msw.d.ts +0 -3
- package/dist/cjs/bins/msw.d.ts.map +0 -1
- package/dist/cjs/bins/msw.js +0 -28
- package/dist/cjs/bins/redwood.d.ts +0 -9
- package/dist/cjs/bins/redwood.d.ts.map +0 -1
- package/dist/cjs/bins/redwood.js +0 -36
- package/dist/cjs/bins/storybook.d.ts +0 -3
- package/dist/cjs/bins/storybook.d.ts.map +0 -1
- package/dist/cjs/bins/storybook.js +0 -49
- package/dist/cjs/bins/tsc.d.ts +0 -3
- package/dist/cjs/bins/tsc.d.ts.map +0 -1
- package/dist/cjs/bins/tsc.js +0 -30
- package/dist/cjs/bundled/apollo-upload-client.d.ts +0 -3
- package/dist/cjs/bundled/apollo-upload-client.d.ts.map +0 -1
- package/dist/cjs/bundled/apollo-upload-client.js +0 -2753
- package/dist/cjs/components/DevFatalErrorPage.d.ts +0 -21
- package/dist/cjs/components/DevFatalErrorPage.d.ts.map +0 -1
- package/dist/cjs/components/DevFatalErrorPage.js +0 -552
- package/dist/cjs/components/FatalErrorBoundary.d.ts +0 -24
- package/dist/cjs/components/FatalErrorBoundary.d.ts.map +0 -1
- package/dist/cjs/components/FatalErrorBoundary.js +0 -63
- package/dist/cjs/components/FetchConfigProvider.d.ts +0 -26
- package/dist/cjs/components/FetchConfigProvider.d.ts.map +0 -1
- package/dist/cjs/components/FetchConfigProvider.js +0 -80
- package/dist/cjs/components/MetaTags.d.ts +0 -52
- package/dist/cjs/components/MetaTags.d.ts.map +0 -1
- package/dist/cjs/components/MetaTags.js +0 -68
- package/dist/cjs/components/Metadata.d.ts +0 -9
- package/dist/cjs/components/Metadata.d.ts.map +0 -1
- package/dist/cjs/components/Metadata.js +0 -94
- package/dist/cjs/components/PortalHead.d.ts +0 -4
- package/dist/cjs/components/PortalHead.d.ts.map +0 -1
- package/dist/cjs/components/PortalHead.js +0 -59
- package/dist/cjs/components/RedwoodProvider.d.ts +0 -9
- package/dist/cjs/components/RedwoodProvider.d.ts.map +0 -1
- package/dist/cjs/components/RedwoodProvider.js +0 -57
- package/dist/cjs/components/ServerInject.d.ts +0 -26
- package/dist/cjs/components/ServerInject.d.ts.map +0 -1
- package/dist/cjs/components/ServerInject.js +0 -75
- package/dist/cjs/components/cell/CellCacheContext.d.ts +0 -20
- package/dist/cjs/components/cell/CellCacheContext.d.ts.map +0 -1
- package/dist/cjs/components/cell/CellCacheContext.js +0 -53
- package/dist/cjs/components/cell/CellErrorBoundary.d.ts +0 -26
- package/dist/cjs/components/cell/CellErrorBoundary.d.ts.map +0 -1
- package/dist/cjs/components/cell/CellErrorBoundary.js +0 -66
- package/dist/cjs/components/cell/cellTypes.d.ts +0 -166
- package/dist/cjs/components/cell/cellTypes.d.ts.map +0 -1
- package/dist/cjs/components/cell/cellTypes.js +0 -16
- package/dist/cjs/components/cell/createCell.d.ts +0 -4
- package/dist/cjs/components/cell/createCell.d.ts.map +0 -1
- package/dist/cjs/components/cell/createCell.js +0 -185
- package/dist/cjs/components/cell/createFragmentCell.d.ts +0 -19
- package/dist/cjs/components/cell/createFragmentCell.d.ts.map +0 -1
- package/dist/cjs/components/cell/createFragmentCell.js +0 -107
- package/dist/cjs/components/cell/createServerCell.d.ts +0 -15
- package/dist/cjs/components/cell/createServerCell.d.ts.map +0 -1
- package/dist/cjs/components/cell/createServerCell.js +0 -91
- package/dist/cjs/components/cell/createSuspendingCell.d.ts +0 -11
- package/dist/cjs/components/cell/createSuspendingCell.d.ts.map +0 -1
- package/dist/cjs/components/cell/createSuspendingCell.js +0 -158
- package/dist/cjs/components/cell/isCellEmpty.d.ts +0 -41
- package/dist/cjs/components/cell/isCellEmpty.d.ts.map +0 -1
- package/dist/cjs/components/cell/isCellEmpty.js +0 -35
- package/dist/cjs/components/htmlTags.d.ts +0 -52
- package/dist/cjs/components/htmlTags.d.ts.map +0 -1
- package/dist/cjs/components/htmlTags.js +0 -88
- package/dist/cjs/config.d.ts +0 -2
- package/dist/cjs/config.d.ts.map +0 -1
- package/dist/cjs/config.js +0 -6
- package/dist/cjs/global.web-auto-imports.d.ts +0 -14
- package/dist/cjs/global.web-auto-imports.d.ts.map +0 -1
- package/dist/cjs/global.web-auto-imports.js +0 -1
- package/dist/cjs/graphql.d.ts +0 -23
- package/dist/cjs/graphql.d.ts.map +0 -1
- package/dist/cjs/graphql.js +0 -36
- package/dist/cjs/index.d.ts +0 -22
- package/dist/cjs/index.d.ts.map +0 -1
- package/dist/cjs/index.js +0 -73
- package/dist/cjs/package.json +0 -1
- package/dist/cjs/routeHooks.types.d.ts +0 -12
- package/dist/cjs/routeHooks.types.d.ts.map +0 -1
- package/dist/cjs/routeHooks.types.js +0 -16
- package/dist/cjs/server/MiddlewareRequest.d.ts +0 -28
- package/dist/cjs/server/MiddlewareRequest.d.ts.map +0 -1
- package/dist/cjs/server/MiddlewareRequest.js +0 -71
- package/dist/cjs/server/MiddlewareResponse.d.ts +0 -44
- package/dist/cjs/server/MiddlewareResponse.d.ts.map +0 -1
- package/dist/cjs/server/MiddlewareResponse.js +0 -130
- package/dist/cjs/server/middleware.d.ts +0 -17
- package/dist/cjs/server/middleware.d.ts.map +0 -1
- package/dist/cjs/server/middleware.js +0 -24
- package/dist/cjs/server/request.d.ts +0 -2
- package/dist/cjs/server/request.d.ts.map +0 -1
- package/dist/cjs/server/request.js +0 -34
- package/dist/cjs/streamUtils/useDocumentReady.d.ts +0 -11
- package/dist/cjs/streamUtils/useDocumentReady.d.ts.map +0 -1
- package/dist/cjs/streamUtils/useDocumentReady.js +0 -41
- package/dist/cjs/toast/index.d.ts +0 -3
- package/dist/cjs/toast/index.d.ts.map +0 -1
- package/dist/cjs/toast/index.js +0 -41
- package/dist/package.json +0 -1
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var CellCacheContext_exports = {};
|
|
30
|
-
__export(CellCacheContext_exports, {
|
|
31
|
-
CellCacheContextProvider: () => CellCacheContextProvider,
|
|
32
|
-
useCellCacheContext: () => useCellCacheContext
|
|
33
|
-
});
|
|
34
|
-
module.exports = __toCommonJS(CellCacheContext_exports);
|
|
35
|
-
var import_react = __toESM(require("react"), 1);
|
|
36
|
-
const CellCacheContext = (0, import_react.createContext)(void 0);
|
|
37
|
-
const CellCacheContextProvider = ({ queryCache, children }) => {
|
|
38
|
-
return /* @__PURE__ */ import_react.default.createElement(CellCacheContext.Provider, { value: { queryCache } }, children);
|
|
39
|
-
};
|
|
40
|
-
function useCellCacheContext() {
|
|
41
|
-
const context = (0, import_react.useContext)(CellCacheContext);
|
|
42
|
-
if (!context) {
|
|
43
|
-
throw new Error(
|
|
44
|
-
"useCellCacheContext must be used within a CellCacheContextProvider"
|
|
45
|
-
);
|
|
46
|
-
}
|
|
47
|
-
return context;
|
|
48
|
-
}
|
|
49
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
50
|
-
0 && (module.exports = {
|
|
51
|
-
CellCacheContextProvider,
|
|
52
|
-
useCellCacheContext
|
|
53
|
-
});
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import type { useQuery } from '@apollo/client/react';
|
|
3
|
-
import type { CellFailureProps } from './cellTypes.js';
|
|
4
|
-
export type FallbackProps = {
|
|
5
|
-
error: useQuery.Result['error'];
|
|
6
|
-
resetErrorBoundary: () => void;
|
|
7
|
-
};
|
|
8
|
-
export type CellErrorBoundaryProps = {
|
|
9
|
-
renderFallback: (fbProps: FallbackProps) => React.ReactElement<CellFailureProps>;
|
|
10
|
-
children: React.ReactNode;
|
|
11
|
-
};
|
|
12
|
-
interface ErrState {
|
|
13
|
-
hasError: boolean;
|
|
14
|
-
error?: useQuery.Result['error'];
|
|
15
|
-
}
|
|
16
|
-
export declare class CellErrorBoundary extends React.Component<CellErrorBoundaryProps, ErrState> {
|
|
17
|
-
constructor(props: CellErrorBoundaryProps);
|
|
18
|
-
static getDerivedStateFromError(error: Error): {
|
|
19
|
-
hasError: boolean;
|
|
20
|
-
error: Error;
|
|
21
|
-
};
|
|
22
|
-
componentDidCatch(error: Error, errorInfo: React.ErrorInfo): void;
|
|
23
|
-
render(): React.ReactNode;
|
|
24
|
-
}
|
|
25
|
-
export {};
|
|
26
|
-
//# sourceMappingURL=CellErrorBoundary.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CellErrorBoundary.d.ts","sourceRoot":"","sources":["../../../../src/components/cell/CellErrorBoundary.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAEpD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AAEtD,MAAM,MAAM,aAAa,GAAG;IAC1B,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;IAC/B,kBAAkB,EAAE,MAAM,IAAI,CAAA;CAC/B,CAAA;AAED,MAAM,MAAM,sBAAsB,GAAG;IAGnC,cAAc,EAAE,CACd,OAAO,EAAE,aAAa,KACnB,KAAK,CAAC,YAAY,CAAC,gBAAgB,CAAC,CAAA;IACzC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAC1B,CAAA;AAED,UAAU,QAAQ;IAChB,QAAQ,EAAE,OAAO,CAAA;IACjB,KAAK,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;CACjC;AAED,qBAAa,iBAAkB,SAAQ,KAAK,CAAC,SAAS,CACpD,sBAAsB,EACtB,QAAQ,CACT;gBACa,KAAK,EAAE,sBAAsB;IAKzC,MAAM,CAAC,wBAAwB,CAAC,KAAK,EAAE,KAAK;;;;IAI5C,iBAAiB,CAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS;IAQ1D,MAAM;CAgBP"}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
"use client";
|
|
3
|
-
var __create = Object.create;
|
|
4
|
-
var __defProp = Object.defineProperty;
|
|
5
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
-
var __export = (target, all) => {
|
|
10
|
-
for (var name in all)
|
|
11
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
-
};
|
|
13
|
-
var __copyProps = (to, from, except, desc) => {
|
|
14
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
-
for (let key of __getOwnPropNames(from))
|
|
16
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
-
}
|
|
19
|
-
return to;
|
|
20
|
-
};
|
|
21
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
-
mod
|
|
28
|
-
));
|
|
29
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
-
var CellErrorBoundary_exports = {};
|
|
31
|
-
__export(CellErrorBoundary_exports, {
|
|
32
|
-
CellErrorBoundary: () => CellErrorBoundary
|
|
33
|
-
});
|
|
34
|
-
module.exports = __toCommonJS(CellErrorBoundary_exports);
|
|
35
|
-
var import_react = __toESM(require("react"), 1);
|
|
36
|
-
class CellErrorBoundary extends import_react.default.Component {
|
|
37
|
-
constructor(props) {
|
|
38
|
-
super(props);
|
|
39
|
-
this.state = { hasError: false };
|
|
40
|
-
}
|
|
41
|
-
static getDerivedStateFromError(error) {
|
|
42
|
-
return { hasError: true, error };
|
|
43
|
-
}
|
|
44
|
-
componentDidCatch(error, errorInfo) {
|
|
45
|
-
console.log("Cell failure: ", {
|
|
46
|
-
error,
|
|
47
|
-
errorInfo
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
render() {
|
|
51
|
-
const { renderFallback } = this.props;
|
|
52
|
-
if (this.state.hasError) {
|
|
53
|
-
return renderFallback({
|
|
54
|
-
error: this.state.error,
|
|
55
|
-
resetErrorBoundary: () => {
|
|
56
|
-
this.setState({ hasError: false, error: void 0 });
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
return this.props.children;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
64
|
-
0 && (module.exports = {
|
|
65
|
-
CellErrorBoundary
|
|
66
|
-
});
|
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
import type { ComponentProps, JSXElementConstructor } from 'react';
|
|
2
|
-
import type { ApolloClient, NetworkStatus, OperationVariables } from '@apollo/client';
|
|
3
|
-
import type { QueryRef, useBackgroundQuery, useQuery } from '@apollo/client/react';
|
|
4
|
-
import type { DocumentNode } from 'graphql';
|
|
5
|
-
import type { A, L, O, U } from 'ts-toolbelt';
|
|
6
|
-
/**
|
|
7
|
-
* If the Cell has a `beforeQuery` function, then the variables are not required,
|
|
8
|
-
* but instead the arguments of the `beforeQuery` function are required.
|
|
9
|
-
*
|
|
10
|
-
* If the Cell does not have a `beforeQuery` function, then the variables are required.
|
|
11
|
-
*
|
|
12
|
-
* Note that a query that doesn't take any variables is defined as {[x: string]: never}
|
|
13
|
-
* The ternary at the end makes sure we don't include it, otherwise it won't allow merging any
|
|
14
|
-
* other custom props from the Success component.
|
|
15
|
-
*/
|
|
16
|
-
type CellPropsVariables<Cell, GQLVariables> = Cell extends {
|
|
17
|
-
beforeQuery: (...args: any[]) => any;
|
|
18
|
-
} ? Parameters<Cell['beforeQuery']>[0] extends unknown ? Record<string, unknown> : Parameters<Cell['beforeQuery']>[0] : GQLVariables extends Record<string, never> ? unknown : GQLVariables;
|
|
19
|
-
/**
|
|
20
|
-
* Cell component props which is the combination of query variables and Success props.
|
|
21
|
-
*/
|
|
22
|
-
export type CellProps<CellSuccess extends keyof JSX.IntrinsicElements | JSXElementConstructor<any>, GQLResult, CellType, GQLVariables> = A.Compute<Omit<ComponentProps<CellSuccess>, keyof CellPropsVariables<CellType, GQLVariables> | keyof GQLResult | 'updating' | 'queryResult'> & CellPropsVariables<CellType, GQLVariables>>;
|
|
23
|
-
type InputVarProps<T> = T extends {
|
|
24
|
-
[key: string]: never;
|
|
25
|
-
} ? unknown : T;
|
|
26
|
-
export type CellLoadingProps<TVariables extends OperationVariables = any> = {
|
|
27
|
-
queryResult?: NonSuspenseCellQueryResult<TVariables, any> | SuspenseCellQueryResult;
|
|
28
|
-
} & InputVarProps<TVariables>;
|
|
29
|
-
export type CellFailureProps<TVariables extends OperationVariables = any> = {
|
|
30
|
-
queryResult?: NonSuspenseCellQueryResult<TVariables, any> | SuspenseCellQueryResult;
|
|
31
|
-
error?: useQuery.Result['error'] | Error;
|
|
32
|
-
/**
|
|
33
|
-
* @see {@link https://www.apollographql.com/docs/apollo-server/data/errors/#error-codes}
|
|
34
|
-
*/
|
|
35
|
-
errorCode?: string;
|
|
36
|
-
updating?: boolean;
|
|
37
|
-
} & InputVarProps<TVariables>;
|
|
38
|
-
type Guaranteed<T> = {
|
|
39
|
-
[K in keyof T]-?: NonNullable<T[K]>;
|
|
40
|
-
};
|
|
41
|
-
type KeyCount<T extends object> = L.Length<U.ListOf<O.SelectKeys<T, any>>>;
|
|
42
|
-
type ConditionallyGuaranteed<T extends object> = KeyCount<T> extends 1 ? Guaranteed<T> : T;
|
|
43
|
-
/**
|
|
44
|
-
* @param TData - Type of data based on your graphql query. This can be imported
|
|
45
|
-
* from 'types/graphql'
|
|
46
|
-
*
|
|
47
|
-
* @example
|
|
48
|
-
* import type { FindPosts } from 'types/graphql'
|
|
49
|
-
*
|
|
50
|
-
* const { post }: CellSuccessData<FindPosts> = props
|
|
51
|
-
*/
|
|
52
|
-
export type CellSuccessData<TData = any> = ConditionallyGuaranteed<Omit<TData, '__typename'>>;
|
|
53
|
-
/**
|
|
54
|
-
* @MARK not sure about this partial, but we need to do this for tests and storybook.
|
|
55
|
-
*
|
|
56
|
-
* `updating` is just `loading` renamed; since Cells default to stale-while-refetch,
|
|
57
|
-
* this prop lets users render something like a spinner to show that a request is in-flight.
|
|
58
|
-
*/
|
|
59
|
-
export type CellSuccessProps<TData = any, TVariables extends OperationVariables = any> = {
|
|
60
|
-
queryResult?: NonSuspenseCellQueryResult<TVariables, TData> | SuspenseCellQueryResult;
|
|
61
|
-
updating?: boolean;
|
|
62
|
-
} & InputVarProps<TVariables> & A.Compute<CellSuccessData<TData>>;
|
|
63
|
-
/**
|
|
64
|
-
* A coarse type for the `data` prop returned by `useQuery`.
|
|
65
|
-
*
|
|
66
|
-
* ```js
|
|
67
|
-
* {
|
|
68
|
-
* data: {
|
|
69
|
-
* post: { ... }
|
|
70
|
-
* }
|
|
71
|
-
* }
|
|
72
|
-
* ```
|
|
73
|
-
*/
|
|
74
|
-
export type DataObject = {
|
|
75
|
-
[key: string]: unknown;
|
|
76
|
-
};
|
|
77
|
-
/**
|
|
78
|
-
* The main interface.
|
|
79
|
-
*/
|
|
80
|
-
export interface CreateCellProps<CellProps, CellVariables> {
|
|
81
|
-
/**
|
|
82
|
-
* The GraphQL syntax tree to execute or function to call that returns it.
|
|
83
|
-
* If `QUERY` is a function, it's called with the result of `beforeQuery`.
|
|
84
|
-
*
|
|
85
|
-
* Either `QUERY` or `FRAGMENT` must be provided.
|
|
86
|
-
*/
|
|
87
|
-
QUERY?: DocumentNode | ((variables: Record<string, unknown>) => DocumentNode);
|
|
88
|
-
/**
|
|
89
|
-
* A GraphQL fragment that declares this Cell's data requirements. Fragment
|
|
90
|
-
* Cells don't fire their own query. Instead a parent Cell spreads the
|
|
91
|
-
* fragment in its `QUERY` and passes the fetched data object down via a
|
|
92
|
-
* prop named after the fragment (`AuthorCell_author` -> `author`). The
|
|
93
|
-
* fragment is automatically registered with the GraphQL client's fragment
|
|
94
|
-
* registry, so parent queries can spread it by name.
|
|
95
|
-
*
|
|
96
|
-
* Either `QUERY` or `FRAGMENT` must be provided.
|
|
97
|
-
*/
|
|
98
|
-
FRAGMENT?: DocumentNode;
|
|
99
|
-
/**
|
|
100
|
-
* Parse `props` into query variables. Most of the time `props` are appropriate variables as is.
|
|
101
|
-
*/
|
|
102
|
-
beforeQuery?: ((props: CellProps) => {
|
|
103
|
-
variables: CellVariables;
|
|
104
|
-
}) | (() => {
|
|
105
|
-
variables: CellVariables;
|
|
106
|
-
});
|
|
107
|
-
/**
|
|
108
|
-
* Sanitize the data returned from the query.
|
|
109
|
-
*/
|
|
110
|
-
afterQuery?: (data: DataObject) => DataObject;
|
|
111
|
-
/**
|
|
112
|
-
* How to decide if the result of a query should render the `Empty` component.
|
|
113
|
-
* The default implementation checks that the first field isn't `null` or an empty array.
|
|
114
|
-
*
|
|
115
|
-
* @example
|
|
116
|
-
*
|
|
117
|
-
* In the example below, only `users` is checked:
|
|
118
|
-
*
|
|
119
|
-
* ```js
|
|
120
|
-
* export const QUERY = gql`
|
|
121
|
-
* users {
|
|
122
|
-
* name
|
|
123
|
-
* }
|
|
124
|
-
* posts {
|
|
125
|
-
* title
|
|
126
|
-
* }
|
|
127
|
-
* `
|
|
128
|
-
* ```
|
|
129
|
-
*/
|
|
130
|
-
isEmpty?: (response: DataObject, options: {
|
|
131
|
-
isDataEmpty: (data: DataObject) => boolean;
|
|
132
|
-
}) => boolean;
|
|
133
|
-
/**
|
|
134
|
-
* If the query's in flight and there's no stale data, render this.
|
|
135
|
-
*/
|
|
136
|
-
Loading?: React.FC<CellLoadingProps & Partial<CellProps>>;
|
|
137
|
-
/**
|
|
138
|
-
* If something went wrong, render this.
|
|
139
|
-
*/
|
|
140
|
-
Failure?: React.FC<CellFailureProps & Partial<CellProps>>;
|
|
141
|
-
/**
|
|
142
|
-
* If no data was returned, render this.
|
|
143
|
-
*/
|
|
144
|
-
Empty?: React.FC<CellSuccessProps & Partial<CellProps>>;
|
|
145
|
-
/**
|
|
146
|
-
* If data was returned, render this.
|
|
147
|
-
*/
|
|
148
|
-
Success: React.FC<CellSuccessProps & Partial<CellProps>>;
|
|
149
|
-
/**
|
|
150
|
-
* What to call the Cell. Defaults to the filename.
|
|
151
|
-
*/
|
|
152
|
-
displayName?: string;
|
|
153
|
-
}
|
|
154
|
-
export type SuspendingSuccessProps = React.PropsWithChildren<Record<string, unknown>> & {
|
|
155
|
-
queryRef: QueryRef<DataObject>;
|
|
156
|
-
suspenseQueryResult: SuspenseCellQueryResult<DataObject, any>;
|
|
157
|
-
userProps: Record<string, any>;
|
|
158
|
-
};
|
|
159
|
-
export type NonSuspenseCellQueryResult<TVariables extends OperationVariables = any, TData = any> = Partial<Omit<useQuery.Result<TData, TVariables>, 'loading' | 'error' | 'data'>>;
|
|
160
|
-
export interface SuspenseCellQueryResult<_TData = any, _TVariables extends OperationVariables = any> extends useBackgroundQuery.Result {
|
|
161
|
-
client: ApolloClient;
|
|
162
|
-
networkStatus?: NetworkStatus;
|
|
163
|
-
called: boolean;
|
|
164
|
-
}
|
|
165
|
-
export {};
|
|
166
|
-
//# sourceMappingURL=cellTypes.d.ts.map
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,CAAA;CAChB"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __copyProps = (to, from, except, desc) => {
|
|
7
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
-
for (let key of __getOwnPropNames(from))
|
|
9
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
-
}
|
|
12
|
-
return to;
|
|
13
|
-
};
|
|
14
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
-
var cellTypes_exports = {};
|
|
16
|
-
module.exports = __toCommonJS(cellTypes_exports);
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import type { CreateCellProps } from './cellTypes.js';
|
|
3
|
-
export declare function createCell<CellProps extends Record<string, unknown>, CellVariables extends Record<string, unknown>>(createCellProps: CreateCellProps<CellProps, CellVariables>): React.FC<CellProps>;
|
|
4
|
-
//# sourceMappingURL=createCell.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createCell.d.ts","sourceRoot":"","sources":["../../../../src/components/cell/createCell.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AASzB,OAAO,KAAK,EAAE,eAAe,EAAc,MAAM,gBAAgB,CAAA;AAKjE,wBAAgB,UAAU,CACxB,SAAS,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACzC,aAAa,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAE7C,eAAe,EAAE,eAAe,CAAC,SAAS,EAAE,aAAa,CAAC,GACzD,KAAK,CAAC,EAAE,CAAC,SAAS,CAAC,CAiCrB"}
|
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var createCell_exports = {};
|
|
30
|
-
__export(createCell_exports, {
|
|
31
|
-
createCell: () => createCell
|
|
32
|
-
});
|
|
33
|
-
module.exports = __toCommonJS(createCell_exports);
|
|
34
|
-
var import_react = __toESM(require("react"), 1);
|
|
35
|
-
var import_client = require("@apollo/client");
|
|
36
|
-
var import_react2 = require("@apollo/client/react");
|
|
37
|
-
var import_fragmentRegistry = require("../../apollo/fragmentRegistry.js");
|
|
38
|
-
var import_graphql = require("../../graphql.js");
|
|
39
|
-
var import_CellCacheContext = require("./CellCacheContext.js");
|
|
40
|
-
var import_createFragmentCell = require("./createFragmentCell.js");
|
|
41
|
-
var import_createSuspendingCell = require("./createSuspendingCell.js");
|
|
42
|
-
var import_isCellEmpty = require("./isCellEmpty.js");
|
|
43
|
-
function createCell(createCellProps) {
|
|
44
|
-
if (createCellProps.FRAGMENT) {
|
|
45
|
-
if (!createCellProps.QUERY) {
|
|
46
|
-
return (0, import_createFragmentCell.createFragmentCell)(createCellProps);
|
|
47
|
-
}
|
|
48
|
-
import_fragmentRegistry.fragmentRegistry.register(createCellProps.FRAGMENT);
|
|
49
|
-
}
|
|
50
|
-
if (RWJS_ENV.RWJS_EXP_STREAMING_SSR) {
|
|
51
|
-
const suspendingCellProps = createCellProps;
|
|
52
|
-
return (0, import_createSuspendingCell.createSuspendingCell)(suspendingCellProps);
|
|
53
|
-
}
|
|
54
|
-
return createNonSuspendingCell(createCellProps);
|
|
55
|
-
}
|
|
56
|
-
function createNonSuspendingCell({
|
|
57
|
-
QUERY,
|
|
58
|
-
beforeQuery = (props) => ({
|
|
59
|
-
// By default, we assume that the props are the gql-variables.
|
|
60
|
-
variables: props,
|
|
61
|
-
/**
|
|
62
|
-
* We're duplicating these props here due to a suspected bug in Apollo Client v3.5.4
|
|
63
|
-
* (it doesn't seem to be respecting `defaultOptions` in `RedwoodApolloProvider`.)
|
|
64
|
-
*
|
|
65
|
-
* @see {@link https://github.com/apollographql/apollo-client/issues/9105}
|
|
66
|
-
*/
|
|
67
|
-
fetchPolicy: "cache-and-network",
|
|
68
|
-
notifyOnNetworkStatusChange: true
|
|
69
|
-
}),
|
|
70
|
-
afterQuery = (data) => data,
|
|
71
|
-
isEmpty = import_isCellEmpty.isDataEmpty,
|
|
72
|
-
Loading = () => /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, "Loading..."),
|
|
73
|
-
Failure,
|
|
74
|
-
Empty,
|
|
75
|
-
Success,
|
|
76
|
-
displayName = "Cell"
|
|
77
|
-
}) {
|
|
78
|
-
if (!QUERY) {
|
|
79
|
-
throw new Error(
|
|
80
|
-
`Can't create a Cell (${displayName}) without a QUERY or FRAGMENT export`
|
|
81
|
-
);
|
|
82
|
-
}
|
|
83
|
-
const cellQuery = QUERY;
|
|
84
|
-
function NamedCell(props) {
|
|
85
|
-
const { children: _, ...variables } = props;
|
|
86
|
-
const options = beforeQuery(variables);
|
|
87
|
-
const query = typeof cellQuery === "function" ? cellQuery(options) : cellQuery;
|
|
88
|
-
let {
|
|
89
|
-
// eslint-disable-next-line prefer-const
|
|
90
|
-
error,
|
|
91
|
-
loading,
|
|
92
|
-
data,
|
|
93
|
-
...queryResult
|
|
94
|
-
} = (0, import_react2.useQuery)(query, options);
|
|
95
|
-
if (globalThis.__REDWOOD__PRERENDERING) {
|
|
96
|
-
const { queryCache } = (0, import_CellCacheContext.useCellCacheContext)();
|
|
97
|
-
const operationName = (0, import_graphql.getOperationName)(query);
|
|
98
|
-
const transformedQuery = import_fragmentRegistry.fragmentRegistry.transform(query);
|
|
99
|
-
let cacheKey;
|
|
100
|
-
if (operationName) {
|
|
101
|
-
cacheKey = operationName + "_" + JSON.stringify(variables);
|
|
102
|
-
} else {
|
|
103
|
-
const cellName = displayName === "Cell" ? "the cell" : displayName;
|
|
104
|
-
throw new Error(
|
|
105
|
-
`The gql query in ${cellName} is missing an operation name. Something like FindBlogPostQuery in \`query FindBlogPostQuery($id: Int!)\``
|
|
106
|
-
);
|
|
107
|
-
}
|
|
108
|
-
const queryInfo = queryCache[cacheKey];
|
|
109
|
-
if (queryInfo?.renderLoading) {
|
|
110
|
-
loading = true;
|
|
111
|
-
} else {
|
|
112
|
-
if (queryInfo?.hasProcessed) {
|
|
113
|
-
loading = false;
|
|
114
|
-
data = queryInfo.data;
|
|
115
|
-
queryResult = { variables };
|
|
116
|
-
} else {
|
|
117
|
-
queryCache[cacheKey] ||= {
|
|
118
|
-
query: transformedQuery,
|
|
119
|
-
variables: options.variables,
|
|
120
|
-
hasProcessed: false
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
if (error) {
|
|
126
|
-
if (Failure) {
|
|
127
|
-
return /* @__PURE__ */ import_react.default.createElement(
|
|
128
|
-
Failure,
|
|
129
|
-
{
|
|
130
|
-
error,
|
|
131
|
-
errorCode: (
|
|
132
|
-
// Use the ad-hoc QueryResultWithErrorCode type to access the errorCode
|
|
133
|
-
queryResult.errorCode ?? (import_client.CombinedGraphQLErrors.is(error) ? error.errors[0]?.extensions?.["code"] : void 0)
|
|
134
|
-
),
|
|
135
|
-
...props,
|
|
136
|
-
updating: loading,
|
|
137
|
-
queryResult
|
|
138
|
-
}
|
|
139
|
-
);
|
|
140
|
-
} else {
|
|
141
|
-
throw error instanceof Error ? error : new Error(error.message);
|
|
142
|
-
}
|
|
143
|
-
} else if (data) {
|
|
144
|
-
const afterQueryData = afterQuery(data);
|
|
145
|
-
if (isEmpty(data, { isDataEmpty: import_isCellEmpty.isDataEmpty }) && Empty) {
|
|
146
|
-
return /* @__PURE__ */ import_react.default.createElement(
|
|
147
|
-
Empty,
|
|
148
|
-
{
|
|
149
|
-
...props,
|
|
150
|
-
...afterQueryData,
|
|
151
|
-
updating: loading,
|
|
152
|
-
queryResult
|
|
153
|
-
}
|
|
154
|
-
);
|
|
155
|
-
} else {
|
|
156
|
-
return /* @__PURE__ */ import_react.default.createElement(
|
|
157
|
-
Success,
|
|
158
|
-
{
|
|
159
|
-
...props,
|
|
160
|
-
...afterQueryData,
|
|
161
|
-
updating: loading,
|
|
162
|
-
queryResult
|
|
163
|
-
}
|
|
164
|
-
);
|
|
165
|
-
}
|
|
166
|
-
} else if (loading) {
|
|
167
|
-
return /* @__PURE__ */ import_react.default.createElement(Loading, { ...props, queryResult });
|
|
168
|
-
} else {
|
|
169
|
-
console.warn(
|
|
170
|
-
`If you're using Apollo Client, check for its debug logs here in the console, which may help explain the error.`
|
|
171
|
-
);
|
|
172
|
-
throw new Error(
|
|
173
|
-
"Cannot render Cell: reached an unexpected state where the query succeeded but `data` is `null`. If this happened in Storybook, your query could be missing fields; otherwise this is most likely a GraphQL caching bug. Note that adding an `id` field to all the fields on your query may fix the issue."
|
|
174
|
-
);
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
NamedCell.displayName = displayName;
|
|
178
|
-
return (props) => {
|
|
179
|
-
return /* @__PURE__ */ import_react.default.createElement(NamedCell, { ...props });
|
|
180
|
-
};
|
|
181
|
-
}
|
|
182
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
183
|
-
0 && (module.exports = {
|
|
184
|
-
createCell
|
|
185
|
-
});
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import type { CreateCellProps } from './cellTypes.js';
|
|
3
|
-
/**
|
|
4
|
-
* Creates a Cell out of a GraphQL fragment and components that render its
|
|
5
|
-
* data.
|
|
6
|
-
*
|
|
7
|
-
* Fragment Cells don't fire queries of their own. A parent Cell spreads the
|
|
8
|
-
* fragment in its QUERY and passes the matching slice of the query result
|
|
9
|
-
* down via a prop named after the fragment (`AuthorCell_author` -> `author`).
|
|
10
|
-
* `Success` receives the data as that same prop. The data is read
|
|
11
|
-
* synchronously, so fragment Cells never render `Loading`.
|
|
12
|
-
*
|
|
13
|
-
* When the GraphQL client supports it (Apollo does), the fragment data is
|
|
14
|
-
* read from the client's cache, so the Cell re-renders when other queries or
|
|
15
|
-
* mutations update the underlying entity. If the cache read is incomplete,
|
|
16
|
-
* the passed-in object itself is used as the data snapshot.
|
|
17
|
-
*/
|
|
18
|
-
export declare function createFragmentCell<CellProps extends Record<string, unknown>, CellVariables extends Record<string, unknown>>({ FRAGMENT, afterQuery, isEmpty, Empty, Success, displayName, }: CreateCellProps<CellProps, CellVariables>): React.FC<CellProps>;
|
|
19
|
-
//# sourceMappingURL=createFragmentCell.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createFragmentCell.d.ts","sourceRoot":"","sources":["../../../../src/components/cell/createFragmentCell.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAOzB,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,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7C,EACA,QAAQ,EACR,UAA2B,EAC3B,OAAqB,EACrB,KAAK,EACL,OAAO,EACP,WAAoB,GACrB,EAAE,eAAe,CAAC,SAAS,EAAE,aAAa,CAAC,GAAG,KAAK,CAAC,EAAE,CAAC,SAAS,CAAC,CAkEjE"}
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var createFragmentCell_exports = {};
|
|
30
|
-
__export(createFragmentCell_exports, {
|
|
31
|
-
createFragmentCell: () => createFragmentCell
|
|
32
|
-
});
|
|
33
|
-
module.exports = __toCommonJS(createFragmentCell_exports);
|
|
34
|
-
var import_react = __toESM(require("react"), 1);
|
|
35
|
-
var import_graphql = require("graphql");
|
|
36
|
-
var import_fragmentRegistry = require("../../apollo/fragmentRegistry.js");
|
|
37
|
-
var import_isCellEmpty = require("./isCellEmpty.js");
|
|
38
|
-
function getFragmentDefinition(fragment, displayName) {
|
|
39
|
-
const fragmentDefinition = fragment.definitions.find(
|
|
40
|
-
(definition) => definition.kind === import_graphql.Kind.FRAGMENT_DEFINITION
|
|
41
|
-
);
|
|
42
|
-
if (!fragmentDefinition) {
|
|
43
|
-
throw new Error(
|
|
44
|
-
`The FRAGMENT export in ${displayName} must contain a GraphQL fragment definition, like \`fragment AuthorCell_author on User { fullName }\``
|
|
45
|
-
);
|
|
46
|
-
}
|
|
47
|
-
return fragmentDefinition;
|
|
48
|
-
}
|
|
49
|
-
function getFragmentPropName(fragmentDefinition) {
|
|
50
|
-
const fragmentName = fragmentDefinition.name.value;
|
|
51
|
-
const underscoreIndex = fragmentName.lastIndexOf("_");
|
|
52
|
-
if (underscoreIndex > 0 && underscoreIndex < fragmentName.length - 1) {
|
|
53
|
-
return fragmentName.slice(underscoreIndex + 1);
|
|
54
|
-
}
|
|
55
|
-
const typename = fragmentDefinition.typeCondition.name.value;
|
|
56
|
-
return typename.charAt(0).toLowerCase() + typename.slice(1);
|
|
57
|
-
}
|
|
58
|
-
function isDataRef(value) {
|
|
59
|
-
return typeof value === "object" && value !== null;
|
|
60
|
-
}
|
|
61
|
-
function createFragmentCell({
|
|
62
|
-
FRAGMENT,
|
|
63
|
-
afterQuery = (data) => data,
|
|
64
|
-
isEmpty = import_isCellEmpty.isDataEmpty,
|
|
65
|
-
Empty,
|
|
66
|
-
Success,
|
|
67
|
-
displayName = "Cell"
|
|
68
|
-
}) {
|
|
69
|
-
if (!FRAGMENT) {
|
|
70
|
-
throw new Error(
|
|
71
|
-
`createFragmentCell() for ${displayName} requires a FRAGMENT`
|
|
72
|
-
);
|
|
73
|
-
}
|
|
74
|
-
const fragment = FRAGMENT;
|
|
75
|
-
const fragmentDefinition = getFragmentDefinition(fragment, displayName);
|
|
76
|
-
const fragmentName = fragmentDefinition.name.value;
|
|
77
|
-
const propName = getFragmentPropName(fragmentDefinition);
|
|
78
|
-
import_fragmentRegistry.fragmentRegistry.register(fragment);
|
|
79
|
-
function NamedCell(props) {
|
|
80
|
-
const { children: _, [propName]: rawSlice, ...rest } = props;
|
|
81
|
-
const dataRef = isDataRef(rawSlice) ? rawSlice : void 0;
|
|
82
|
-
const fragmentResult = (0, import_fragmentRegistry.useFragment)({
|
|
83
|
-
fragment,
|
|
84
|
-
fragmentName,
|
|
85
|
-
from: dataRef ?? {}
|
|
86
|
-
});
|
|
87
|
-
if (!(propName in props)) {
|
|
88
|
-
throw new Error(
|
|
89
|
-
`${displayName} must be passed a \`${propName}\` prop. Render it from a parent Cell that spreads \`...${fragmentName}\` in its QUERY, and pass the matching data object: \`<${displayName} ${propName}={data.someField} />\``
|
|
90
|
-
);
|
|
91
|
-
}
|
|
92
|
-
const data = fragmentResult.complete ? fragmentResult.data : dataRef ?? null;
|
|
93
|
-
const afterQueryData = afterQuery({ [propName]: data });
|
|
94
|
-
if (isEmpty({ [propName]: data }, { isDataEmpty: import_isCellEmpty.isDataEmpty }) && Empty) {
|
|
95
|
-
return /* @__PURE__ */ import_react.default.createElement(Empty, { ...rest, ...afterQueryData });
|
|
96
|
-
}
|
|
97
|
-
return /* @__PURE__ */ import_react.default.createElement(Success, { ...rest, ...afterQueryData });
|
|
98
|
-
}
|
|
99
|
-
NamedCell.displayName = displayName;
|
|
100
|
-
return (props) => {
|
|
101
|
-
return /* @__PURE__ */ import_react.default.createElement(NamedCell, { ...props });
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
105
|
-
0 && (module.exports = {
|
|
106
|
-
createFragmentCell
|
|
107
|
-
});
|