@prismicio/react 2.8.0 → 2.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/PrismicImage.d.ts +90 -8
- package/dist/PrismicToolbar.cjs +0 -1
- package/dist/PrismicToolbar.cjs.map +1 -1
- package/dist/PrismicToolbar.js +0 -1
- package/dist/PrismicToolbar.js.map +1 -1
- package/dist/_node_modules/@prismicio/client/dist/errors/PrismicError.cjs +1 -4
- package/dist/_node_modules/@prismicio/client/dist/errors/PrismicError.cjs.map +1 -1
- package/dist/_node_modules/@prismicio/client/dist/errors/PrismicError.js +1 -4
- package/dist/_node_modules/@prismicio/client/dist/errors/PrismicError.js.map +1 -1
- package/dist/_node_modules/@prismicio/client/dist/helpers/asImagePixelDensitySrcSet.cjs +4 -3
- package/dist/_node_modules/@prismicio/client/dist/helpers/asImagePixelDensitySrcSet.cjs.map +1 -1
- package/dist/_node_modules/@prismicio/client/dist/helpers/asImagePixelDensitySrcSet.js +2 -1
- package/dist/_node_modules/@prismicio/client/dist/helpers/asImagePixelDensitySrcSet.js.map +1 -1
- package/dist/_node_modules/@prismicio/client/dist/helpers/asImageWidthSrcSet.cjs +7 -6
- package/dist/_node_modules/@prismicio/client/dist/helpers/asImageWidthSrcSet.cjs.map +1 -1
- package/dist/_node_modules/@prismicio/client/dist/helpers/asImageWidthSrcSet.js +3 -2
- package/dist/_node_modules/@prismicio/client/dist/helpers/asImageWidthSrcSet.js.map +1 -1
- package/dist/_node_modules/@prismicio/client/dist/helpers/asText.cjs +2 -2
- package/dist/_node_modules/@prismicio/client/dist/helpers/asText.cjs.map +1 -1
- package/dist/_node_modules/@prismicio/client/dist/helpers/asText.js +1 -1
- package/dist/_node_modules/@prismicio/client/dist/helpers/asText.js.map +1 -1
- package/dist/_node_modules/@prismicio/client/dist/helpers/documentToLinkField.cjs +1 -0
- package/dist/_node_modules/@prismicio/client/dist/helpers/documentToLinkField.cjs.map +1 -1
- package/dist/_node_modules/@prismicio/client/dist/helpers/documentToLinkField.js +1 -0
- package/dist/_node_modules/@prismicio/client/dist/helpers/documentToLinkField.js.map +1 -1
- package/dist/_node_modules/@prismicio/client/dist/richtext/asText.cjs +13 -0
- package/dist/_node_modules/@prismicio/client/dist/richtext/asText.cjs.map +1 -0
- package/dist/_node_modules/@prismicio/client/dist/richtext/asText.js +13 -0
- package/dist/_node_modules/@prismicio/client/dist/richtext/asText.js.map +1 -0
- package/dist/_node_modules/imgix-url-builder/dist/buildPixelDensitySrcSet.cjs +10 -0
- package/dist/_node_modules/imgix-url-builder/dist/buildPixelDensitySrcSet.cjs.map +1 -0
- package/dist/_node_modules/imgix-url-builder/dist/buildPixelDensitySrcSet.js +10 -0
- package/dist/_node_modules/imgix-url-builder/dist/buildPixelDensitySrcSet.js.map +1 -0
- package/dist/_node_modules/imgix-url-builder/dist/{index.cjs → buildURL.cjs} +1 -13
- package/dist/_node_modules/imgix-url-builder/dist/buildURL.cjs.map +1 -0
- package/dist/_node_modules/imgix-url-builder/dist/{index.js → buildURL.js} +2 -14
- package/dist/_node_modules/imgix-url-builder/dist/buildURL.js.map +1 -0
- package/dist/_node_modules/imgix-url-builder/dist/buildWidthSrcSet.cjs +10 -0
- package/dist/_node_modules/imgix-url-builder/dist/buildWidthSrcSet.cjs.map +1 -0
- package/dist/_node_modules/imgix-url-builder/dist/buildWidthSrcSet.js +10 -0
- package/dist/_node_modules/imgix-url-builder/dist/buildWidthSrcSet.js.map +1 -0
- package/dist/clientHooks.d.ts +18 -72
- package/dist/package.json.cjs +1 -1
- package/dist/package.json.js +1 -1
- package/dist/react-server/PrismicLink.cjs +4 -4
- package/dist/react-server/PrismicLink.cjs.map +1 -1
- package/dist/react-server/PrismicLink.d.ts +6 -1
- package/dist/react-server/PrismicLink.js +4 -4
- package/dist/react-server/PrismicLink.js.map +1 -1
- package/dist/useStatefulPrismicClientMethod.cjs +1 -5
- package/dist/useStatefulPrismicClientMethod.cjs.map +1 -1
- package/dist/useStatefulPrismicClientMethod.d.ts +1 -1
- package/dist/useStatefulPrismicClientMethod.js +1 -5
- package/dist/useStatefulPrismicClientMethod.js.map +1 -1
- package/package.json +3 -3
- package/src/react-server/PrismicLink.tsx +23 -7
- package/src/useStatefulPrismicClientMethod.ts +2 -6
- package/dist/_node_modules/imgix-url-builder/dist/index.cjs.map +0 -1
- package/dist/_node_modules/imgix-url-builder/dist/index.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useStatefulPrismicClientMethod.js","sources":["../../src/useStatefulPrismicClientMethod.ts"],"sourcesContent":["import type * as prismic from \"@prismicio/client\";\n\nimport * as React from \"react\";\n\nimport { PrismicClientHookState } from \"./types\";\nimport { usePrismicClient } from \"./usePrismicClient\";\n\ntype StateMachineState<TData> = {\n\tstate: PrismicClientHookState;\n\tdata?: TData;\n\terror?: Error;\n};\n\ntype StateMachineAction<TData> =\n\t| [type: \"start\"]\n\t| [type: \"succeed\", payload: TData]\n\t| [type: \"fail\", payload: Error];\n\nconst reducer = <TData>(\n\tstate: StateMachineState<TData>,\n\taction: StateMachineAction<TData>,\n): StateMachineState<TData> => {\n\tswitch (action[0]) {\n\t\tcase \"start\": {\n\t\t\treturn { state: \"loading\" };\n\t\t}\n\n\t\tcase \"succeed\": {\n\t\t\treturn { state: \"loaded\", data: action[1] };\n\t\t}\n\n\t\tcase \"fail\": {\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\tstate: \"failed\",\n\t\t\t\terror: action[1],\n\t\t\t};\n\t\t}\n\t}\n};\n\nconst initialState: StateMachineState<never> = {\n\tstate: \"idle\",\n};\n\ntype UnwrapPromise<T> = T extends Promise<infer U> ? U : T;\n\ntype ClientPrototype = typeof prismic.Client.prototype;\n\ntype ClientMethod<MethodName extends keyof ClientPrototype> =\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tClientPrototype[MethodName] extends (...args: any[]) => any\n\t\t? ClientPrototype[MethodName]\n\t\t: never;\n\ntype ClientMethodName = keyof {\n\t[P in keyof prismic.Client as prismic.Client[P] extends (\n\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t...args: any[]\n\t) => // eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tPromise<any>\n\t\t? P\n\t\t: never]: unknown;\n};\n\nexport type ClientMethodParameters<MethodName extends keyof ClientPrototype> =\n\tParameters<ClientMethod<MethodName>>;\n\nexport type HookOnlyParameters = {\n\tclient?: prismic.Client;\n\tskip?: boolean;\n};\n\n/**\n * Determines if a value is a `@prismicio/client` params object.\n *\n * @param value - The value to check.\n *\n * @returns `true` if `value` is a `@prismicio/client` params object, `false`\n * otherwise.\n */\nconst isParams = (\n\tvalue: unknown,\n): value is ClientMethodParameters<\"get\">[0] & HookOnlyParameters => {\n\t// This is a *very* naive check.\n\treturn typeof value === \"object\" && value !== null && !Array.isArray(value);\n};\n\n/**\n * The return value of a `@prismicio/client` React hook.\n *\n * @typeParam TData - Data returned by the client.\n */\nexport type ClientHookReturnType<TData = unknown> = [\n\t/**\n\t * Data returned by the client.\n\t */\n\tdata: TData | undefined,\n\n\t/**\n\t * The current state of the hook's client method call.\n\t */\n\tstate: Pick<StateMachineState<TData>, \"state\" | \"error\">,\n];\n\n/**\n * Creates a React hook that forwards arguments to a specific method of a\n * `@prismicio/client` instance. The created hook has its own internal state\n * manager to report async status, such as pending or error statuses.\n *\n * @param methodName - The `@prismicio/client` method to which hook arguments\n * will be forwarded.\n *\n * @returns A new React hook configured for the provided method.\n *\n * @internal\n */\nexport const useStatefulPrismicClientMethod = <\n\tTMethodName extends ClientMethodName,\n\tTArgs extends Parameters<ClientMethod<TMethodName>>,\n\tTData extends UnwrapPromise<ReturnType<ClientMethod<TMethodName>>>,\n>(\n\tmethodName: TMethodName,\n\targs: TArgs,\n\texplicitClient?: prismic.Client,\n): ClientHookReturnType<TData> => {\n\tconst lastArg = args[args.length - 1];\n\tconst {\n\t\tclient: lastArgExplicitClient,\n\t\tskip,\n\t\t...params\n\t} = isParams(lastArg) ? lastArg : ({} as HookOnlyParameters);\n\tconst argsWithoutParams = isParams(lastArg) ? args.slice(0, -1) : args;\n\n\tconst client = usePrismicClient(explicitClient || lastArgExplicitClient);\n\n\tconst [state, dispatch] = React.useReducer<\n\t\tReact.Reducer<StateMachineState<TData>, StateMachineAction<TData>>\n\t>(reducer, initialState);\n\n\tReact.useEffect(\n\t\t() => {\n\t\t\t// Used to prevent dispatching an action if the hook was cleaned up.\n\t\t\tlet didCancel = false;\n\n\t\t\tif (!skip) {\n\t\t\t\tif (!didCancel) {\n\t\t\t\t\tdispatch([\"start\"]);\n\t\t\t\t}\n\n\t\t\t\
|
|
1
|
+
{"version":3,"file":"useStatefulPrismicClientMethod.js","sources":["../../src/useStatefulPrismicClientMethod.ts"],"sourcesContent":["import type * as prismic from \"@prismicio/client\";\n\nimport * as React from \"react\";\n\nimport { PrismicClientHookState } from \"./types\";\nimport { usePrismicClient } from \"./usePrismicClient\";\n\ntype StateMachineState<TData> = {\n\tstate: PrismicClientHookState;\n\tdata?: TData;\n\terror?: Error;\n};\n\ntype StateMachineAction<TData> =\n\t| [type: \"start\"]\n\t| [type: \"succeed\", payload: TData]\n\t| [type: \"fail\", payload: Error];\n\nconst reducer = <TData>(\n\tstate: StateMachineState<TData>,\n\taction: StateMachineAction<TData>,\n): StateMachineState<TData> => {\n\tswitch (action[0]) {\n\t\tcase \"start\": {\n\t\t\treturn { state: \"loading\" };\n\t\t}\n\n\t\tcase \"succeed\": {\n\t\t\treturn { state: \"loaded\", data: action[1] };\n\t\t}\n\n\t\tcase \"fail\": {\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\tstate: \"failed\",\n\t\t\t\terror: action[1],\n\t\t\t};\n\t\t}\n\t}\n};\n\nconst initialState: StateMachineState<never> = {\n\tstate: \"idle\",\n};\n\ntype UnwrapPromise<T> = T extends Promise<infer U> ? U : T;\n\ntype ClientPrototype = typeof prismic.Client.prototype;\n\ntype ClientMethod<MethodName extends keyof ClientPrototype> =\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tClientPrototype[MethodName] extends (...args: any[]) => any\n\t\t? ClientPrototype[MethodName]\n\t\t: never;\n\ntype ClientMethodName = keyof {\n\t[P in keyof prismic.Client as prismic.Client[P] extends (\n\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t...args: any[]\n\t) => // eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tPromise<any>\n\t\t? P\n\t\t: never]: unknown;\n};\n\nexport type ClientMethodParameters<MethodName extends keyof ClientPrototype> =\n\tParameters<ClientMethod<MethodName>>;\n\nexport type HookOnlyParameters = {\n\tclient?: prismic.Client;\n\tskip?: boolean;\n};\n\n/**\n * Determines if a value is a `@prismicio/client` params object.\n *\n * @param value - The value to check.\n *\n * @returns `true` if `value` is a `@prismicio/client` params object, `false`\n * otherwise.\n */\nconst isParams = (\n\tvalue: unknown,\n): value is ClientMethodParameters<\"get\">[0] & HookOnlyParameters => {\n\t// This is a *very* naive check.\n\treturn typeof value === \"object\" && value !== null && !Array.isArray(value);\n};\n\n/**\n * The return value of a `@prismicio/client` React hook.\n *\n * @typeParam TData - Data returned by the client.\n */\nexport type ClientHookReturnType<TData = unknown> = [\n\t/**\n\t * Data returned by the client.\n\t */\n\tdata: TData | undefined,\n\n\t/**\n\t * The current state of the hook's client method call.\n\t */\n\tstate: Pick<StateMachineState<TData>, \"state\" | \"error\">,\n];\n\n/**\n * Creates a React hook that forwards arguments to a specific method of a\n * `@prismicio/client` instance. The created hook has its own internal state\n * manager to report async status, such as pending or error statuses.\n *\n * @param methodName - The `@prismicio/client` method to which hook arguments\n * will be forwarded.\n *\n * @returns A new React hook configured for the provided method.\n *\n * @internal\n */\nexport const useStatefulPrismicClientMethod = <\n\tTMethodName extends ClientMethodName,\n\tTArgs extends Parameters<ClientMethod<TMethodName>>,\n\tTData extends UnwrapPromise<ReturnType<ClientMethod<TMethodName>>>,\n>(\n\tmethodName: TMethodName,\n\targs: TArgs,\n\texplicitClient?: prismic.Client,\n): ClientHookReturnType<TData> => {\n\tconst lastArg = args[args.length - 1];\n\tconst {\n\t\tclient: lastArgExplicitClient,\n\t\tskip,\n\t\t...params\n\t} = isParams(lastArg) ? lastArg : ({} as HookOnlyParameters);\n\tconst argsWithoutParams = isParams(lastArg) ? args.slice(0, -1) : args;\n\n\tconst client = usePrismicClient(explicitClient || lastArgExplicitClient);\n\n\tconst [state, dispatch] = React.useReducer<\n\t\tReact.Reducer<StateMachineState<TData>, StateMachineAction<TData>>\n\t>(reducer, initialState);\n\n\tReact.useEffect(\n\t\t() => {\n\t\t\t// Used to prevent dispatching an action if the hook was cleaned up.\n\t\t\tlet didCancel = false;\n\n\t\t\tif (!skip) {\n\t\t\t\tif (!didCancel) {\n\t\t\t\t\tdispatch([\"start\"]);\n\t\t\t\t}\n\n\t\t\t\t// @ts-expect-error - Merging method arg types is too complex\n\t\t\t\tclient[methodName]\n\t\t\t\t\t.call(client, ...argsWithoutParams, params)\n\t\t\t\t\t.then((result) => {\n\t\t\t\t\t\tif (!didCancel) {\n\t\t\t\t\t\t\tdispatch([\"succeed\", result as TData]);\n\t\t\t\t\t\t}\n\t\t\t\t\t})\n\t\t\t\t\t.catch((error) => {\n\t\t\t\t\t\tif (!didCancel) {\n\t\t\t\t\t\t\tdispatch([\"fail\", error]);\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t}\n\n\t\t\t// Ensure we don't dispatch an action if the hook is cleaned up.\n\t\t\t() => {\n\t\t\t\tdidCancel = true;\n\t\t\t};\n\t\t},\n\t\t// We must disable exhaustive-deps since we are using\n\t\t// JSON.stringify on params (effectively a deep equality check).\n\t\t// We want this effect to run again anytime params change.\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t\t[\n\t\t\tclient,\n\t\t\tmethodName,\n\t\t\tskip,\n\t\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t\t\tJSON.stringify(argsWithoutParams),\n\t\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t\t\tJSON.stringify(params),\n\t\t],\n\t);\n\n\treturn React.useMemo(\n\t\t() => [\n\t\t\tstate.data,\n\t\t\t{\n\t\t\t\tstate: state.state,\n\t\t\t\terror: state.error,\n\t\t\t},\n\t\t],\n\t\t[state],\n\t);\n};\n"],"names":[],"mappings":";;AAkBA,MAAM,UAAU,CACf,OACA,WAC6B;AACrB,UAAA,OAAO,CAAC,GAAG;AAAA,IAClB,KAAK,SAAS;AACN,aAAA,EAAE,OAAO;IAChB;AAAA,IAED,KAAK,WAAW;AACf,aAAO,EAAE,OAAO,UAAU,MAAM,OAAO,CAAC;IACxC;AAAA,IAED,KAAK,QAAQ;AACL,aAAA;AAAA,QACN,GAAG;AAAA,QACH,OAAO;AAAA,QACP,OAAO,OAAO,CAAC;AAAA,MAAA;AAAA,IAEhB;AAAA,EACD;AACF;AAEA,MAAM,eAAyC;AAAA,EAC9C,OAAO;;AAuCR,MAAM,WAAW,CAChB,UACmE;AAE5D,SAAA,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAC3E;AA+BO,MAAM,iCAAiC,CAK7C,YACA,MACA,mBACgC;AAChC,QAAM,UAAU,KAAK,KAAK,SAAS,CAAC;AAC9B,QAAA,EACL,QAAQ,uBACR,MACA,GAAG,WACA,SAAS,OAAO,IAAI,UAAW;AAC7B,QAAA,oBAAoB,SAAS,OAAO,IAAI,KAAK,MAAM,GAAG,EAAE,IAAI;AAE5D,QAAA,SAAS,iBAAiB,kBAAkB,qBAAqB;AAEvE,QAAM,CAAC,OAAO,QAAQ,IAAI,MAAM,WAE9B,SAAS,YAAY;AAEjB,QAAA;AAAA,IACL,MAAK;AAIJ,UAAI,CAAC,MAAM;AACM;AACN,mBAAA,CAAC,OAAO,CAAC;AAAA,QAClB;AAGM,eAAA,UAAU,EACf,KAAK,QAAQ,GAAG,mBAAmB,MAAM,EACzC,KAAK,CAAC,WAAU;AACA;AACN,qBAAA,CAAC,WAAW,MAAe,CAAC;AAAA,UACrC;AAAA,QAAA,CACD,EACA,MAAM,CAAC,UAAS;AACA;AACN,qBAAA,CAAC,QAAQ,KAAK,CAAC;AAAA,UACxB;AAAA,QAAA,CACD;AAAA,MACF;AAAA,IAMF;AAAA;AAAA;AAAA;AAAA;AAAA,IAKA;AAAA,MACC;AAAA,MACA;AAAA,MACA;AAAA;AAAA,MAEA,KAAK,UAAU,iBAAiB;AAAA;AAAA,MAEhC,KAAK,UAAU,MAAM;AAAA,IACrB;AAAA,EAAA;AAGK,SAAA,MAAM,QACZ,MAAM;AAAA,IACL,MAAM;AAAA,IACN;AAAA,MACC,OAAO,MAAM;AAAA,MACb,OAAO,MAAM;AAAA,IACb;AAAA,EAAA,GAEF,CAAC,KAAK,CAAC;AAET;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prismicio/react",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.9.0",
|
|
4
4
|
"description": "React components and hooks to fetch and present Prismic content",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -69,8 +69,8 @@
|
|
|
69
69
|
"@prismicio/richtext": "^2.1.5"
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
72
|
-
"@prismicio/client": "^7.
|
|
73
|
-
"@prismicio/mock": "
|
|
72
|
+
"@prismicio/client": "^7.11.0",
|
|
73
|
+
"@prismicio/mock": "0.4.0",
|
|
74
74
|
"@size-limit/preset-small-lib": "^8.2.4",
|
|
75
75
|
"@testing-library/react": "^14.0.0",
|
|
76
76
|
"@types/node-fetch": "^3.0.3",
|
|
@@ -45,7 +45,10 @@ export interface LinkProps {
|
|
|
45
45
|
export type PrismicLinkProps<
|
|
46
46
|
InternalComponentProps = React.ComponentProps<typeof defaultComponent>,
|
|
47
47
|
ExternalComponentProps = React.ComponentProps<typeof defaultComponent>,
|
|
48
|
-
> = Omit<
|
|
48
|
+
> = Omit<
|
|
49
|
+
InternalComponentProps & ExternalComponentProps,
|
|
50
|
+
"rel" | "href" | "children"
|
|
51
|
+
> & {
|
|
49
52
|
/**
|
|
50
53
|
* The `rel` attribute for the link. By default, `"noreferrer"` is provided if
|
|
51
54
|
* the link's URL is external. This prop can be provided a function to use the
|
|
@@ -75,6 +78,12 @@ export type PrismicLinkProps<
|
|
|
75
78
|
* The component rendered for external URLs. Defaults to `<a>`.
|
|
76
79
|
*/
|
|
77
80
|
externalComponent?: React.ComponentType<ExternalComponentProps>;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* The children to render for the link. If no children are provided, the
|
|
84
|
+
* link's `text` property will be used.
|
|
85
|
+
*/
|
|
86
|
+
children?: React.ReactNode;
|
|
78
87
|
} & (
|
|
79
88
|
| {
|
|
80
89
|
document: PrismicDocument | null | undefined;
|
|
@@ -97,16 +106,19 @@ export const PrismicLink = React.forwardRef(function PrismicLink<
|
|
|
97
106
|
InternalComponentProps = React.ComponentProps<typeof defaultComponent>,
|
|
98
107
|
ExternalComponentProps = React.ComponentProps<typeof defaultComponent>,
|
|
99
108
|
>(
|
|
100
|
-
|
|
109
|
+
props: PrismicLinkProps<InternalComponentProps, ExternalComponentProps>,
|
|
110
|
+
ref: React.ForwardedRef<Element>,
|
|
111
|
+
): JSX.Element {
|
|
112
|
+
const {
|
|
101
113
|
field,
|
|
102
114
|
document: doc,
|
|
103
115
|
linkResolver,
|
|
104
116
|
internalComponent,
|
|
105
117
|
externalComponent,
|
|
118
|
+
children,
|
|
106
119
|
...restProps
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
): JSX.Element {
|
|
120
|
+
} = props;
|
|
121
|
+
|
|
110
122
|
if (
|
|
111
123
|
typeof process !== "undefined" &&
|
|
112
124
|
process.env.NODE_ENV === "development"
|
|
@@ -123,7 +135,9 @@ export const PrismicLink = React.forwardRef(function PrismicLink<
|
|
|
123
135
|
)}`,
|
|
124
136
|
);
|
|
125
137
|
} else if (
|
|
126
|
-
|
|
138
|
+
("text" in field
|
|
139
|
+
? Object.keys(field).length > 2
|
|
140
|
+
: Object.keys(field).length > 1) &&
|
|
127
141
|
!("url" in field || "uid" in field || "id" in field)
|
|
128
142
|
) {
|
|
129
143
|
console.warn(
|
|
@@ -169,7 +183,9 @@ export const PrismicLink = React.forwardRef(function PrismicLink<
|
|
|
169
183
|
href && isInternalURL(href) ? InternalComponent : ExternalComponent;
|
|
170
184
|
|
|
171
185
|
return (
|
|
172
|
-
<Component ref={ref} {...attrs} {...restProps} href={href} rel={rel}
|
|
186
|
+
<Component ref={ref} {...attrs} {...restProps} href={href} rel={rel}>
|
|
187
|
+
{"children" in props ? children : field?.text}
|
|
188
|
+
</Component>
|
|
173
189
|
);
|
|
174
190
|
}) as <
|
|
175
191
|
InternalComponentProps = React.ComponentProps<typeof defaultComponent>,
|
|
@@ -148,13 +148,9 @@ export const useStatefulPrismicClientMethod = <
|
|
|
148
148
|
dispatch(["start"]);
|
|
149
149
|
}
|
|
150
150
|
|
|
151
|
+
// @ts-expect-error - Merging method arg types is too complex
|
|
151
152
|
client[methodName]
|
|
152
|
-
.call(
|
|
153
|
-
client,
|
|
154
|
-
// @ts-expect-error - Merging method arg types is too complex
|
|
155
|
-
...argsWithoutParams,
|
|
156
|
-
params,
|
|
157
|
-
)
|
|
153
|
+
.call(client, ...argsWithoutParams, params)
|
|
158
154
|
.then((result) => {
|
|
159
155
|
if (!didCancel) {
|
|
160
156
|
dispatch(["succeed", result as TData]);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../../../node_modules/imgix-url-builder/dist/index.mjs"],"sourcesContent":["const camelCaseToParamCase = (input) => {\n return input.replace(/[A-Z]/g, (match) => {\n return `-${match.toLowerCase()}`;\n });\n};\nconst buildURL = (url, params) => {\n const instance = new URL(url);\n for (const camelCasedParamKey in params) {\n const paramKey = camelCaseToParamCase(camelCasedParamKey);\n const paramValue = params[camelCasedParamKey];\n if (paramValue === void 0) {\n instance.searchParams.delete(paramKey);\n } else if (Array.isArray(paramValue)) {\n instance.searchParams.set(paramKey, paramValue.join(\",\"));\n } else {\n instance.searchParams.set(paramKey, `${paramValue}`);\n }\n }\n const s = instance.searchParams.get(\"s\");\n if (s) {\n instance.searchParams.delete(\"s\");\n instance.searchParams.append(\"s\", s);\n }\n return instance.toString();\n};\n\nconst buildPixelDensitySrcSet = (url, { pixelDensities, ...params }) => {\n return pixelDensities.map((dpr) => {\n return `${buildURL(url, { ...params, dpr })} ${dpr}x`;\n }).join(\", \");\n};\n\nconst buildWidthSrcSet = (url, { widths, ...params }) => {\n return widths.map((width) => {\n return `${buildURL(url, { ...params, w: void 0, width })} ${width}w`;\n }).join(\", \");\n};\n\nclass Client {\n constructor(options) {\n this.baseURL = options.baseURL;\n }\n buildURLForPath(path, params = {}) {\n return buildURL(`${new URL(path, this.baseURL)}`, params);\n }\n buildWidthSrcSetForPath(path, params) {\n return buildWidthSrcSet(`${new URL(path, this.baseURL)}`, params);\n }\n buildPixelDensitySrcSetForPath(path, params) {\n return buildPixelDensitySrcSet(`${new URL(path, this.baseURL)}`, params);\n }\n}\n\nexport { Client, buildPixelDensitySrcSet, buildURL, buildWidthSrcSet };\n//# sourceMappingURL=index.mjs.map\n"],"names":[],"mappings":";;AAAA,MAAM,uBAAuB,CAAC,UAAU;AACtC,SAAO,MAAM,QAAQ,UAAU,CAAC,UAAU;AACxC,WAAO,IAAI,MAAM,YAAW;AAAA,EAChC,CAAG;AACH;AACK,MAAC,WAAW,CAAC,KAAK,WAAW;AAChC,QAAM,WAAW,IAAI,IAAI,GAAG;AAC5B,aAAW,sBAAsB,QAAQ;AACvC,UAAM,WAAW,qBAAqB,kBAAkB;AACxD,UAAM,aAAa,OAAO,kBAAkB;AAC5C,QAAI,eAAe,QAAQ;AACzB,eAAS,aAAa,OAAO,QAAQ;AAAA,IACtC,WAAU,MAAM,QAAQ,UAAU,GAAG;AACpC,eAAS,aAAa,IAAI,UAAU,WAAW,KAAK,GAAG,CAAC;AAAA,IAC9D,OAAW;AACL,eAAS,aAAa,IAAI,UAAU,GAAG,YAAY;AAAA,IACpD;AAAA,EACF;AACD,QAAM,IAAI,SAAS,aAAa,IAAI,GAAG;AACvC,MAAI,GAAG;AACL,aAAS,aAAa,OAAO,GAAG;AAChC,aAAS,aAAa,OAAO,KAAK,CAAC;AAAA,EACpC;AACD,SAAO,SAAS;AAClB;AAEK,MAAC,0BAA0B,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAM,MAAO;AACtE,SAAO,eAAe,IAAI,CAAC,QAAQ;AACjC,WAAO,GAAG,SAAS,KAAK,EAAE,GAAG,QAAQ,IAAG,CAAE,KAAK;AAAA,EACnD,CAAG,EAAE,KAAK,IAAI;AACd;AAEK,MAAC,mBAAmB,CAAC,KAAK,EAAE,QAAQ,GAAG,OAAM,MAAO;AACvD,SAAO,OAAO,IAAI,CAAC,UAAU;AAC3B,WAAO,GAAG,SAAS,KAAK,EAAE,GAAG,QAAQ,GAAG,QAAQ,MAAK,CAAE,KAAK;AAAA,EAChE,CAAG,EAAE,KAAK,IAAI;AACd;;;;","x_google_ignoreList":[0]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../node_modules/imgix-url-builder/dist/index.mjs"],"sourcesContent":["const camelCaseToParamCase = (input) => {\n return input.replace(/[A-Z]/g, (match) => {\n return `-${match.toLowerCase()}`;\n });\n};\nconst buildURL = (url, params) => {\n const instance = new URL(url);\n for (const camelCasedParamKey in params) {\n const paramKey = camelCaseToParamCase(camelCasedParamKey);\n const paramValue = params[camelCasedParamKey];\n if (paramValue === void 0) {\n instance.searchParams.delete(paramKey);\n } else if (Array.isArray(paramValue)) {\n instance.searchParams.set(paramKey, paramValue.join(\",\"));\n } else {\n instance.searchParams.set(paramKey, `${paramValue}`);\n }\n }\n const s = instance.searchParams.get(\"s\");\n if (s) {\n instance.searchParams.delete(\"s\");\n instance.searchParams.append(\"s\", s);\n }\n return instance.toString();\n};\n\nconst buildPixelDensitySrcSet = (url, { pixelDensities, ...params }) => {\n return pixelDensities.map((dpr) => {\n return `${buildURL(url, { ...params, dpr })} ${dpr}x`;\n }).join(\", \");\n};\n\nconst buildWidthSrcSet = (url, { widths, ...params }) => {\n return widths.map((width) => {\n return `${buildURL(url, { ...params, w: void 0, width })} ${width}w`;\n }).join(\", \");\n};\n\nclass Client {\n constructor(options) {\n this.baseURL = options.baseURL;\n }\n buildURLForPath(path, params = {}) {\n return buildURL(`${new URL(path, this.baseURL)}`, params);\n }\n buildWidthSrcSetForPath(path, params) {\n return buildWidthSrcSet(`${new URL(path, this.baseURL)}`, params);\n }\n buildPixelDensitySrcSetForPath(path, params) {\n return buildPixelDensitySrcSet(`${new URL(path, this.baseURL)}`, params);\n }\n}\n\nexport { Client, buildPixelDensitySrcSet, buildURL, buildWidthSrcSet };\n//# sourceMappingURL=index.mjs.map\n"],"names":[],"mappings":"AAAA,MAAM,uBAAuB,CAAC,UAAU;AACtC,SAAO,MAAM,QAAQ,UAAU,CAAC,UAAU;AACxC,WAAO,IAAI,MAAM,YAAW;AAAA,EAChC,CAAG;AACH;AACK,MAAC,WAAW,CAAC,KAAK,WAAW;AAChC,QAAM,WAAW,IAAI,IAAI,GAAG;AAC5B,aAAW,sBAAsB,QAAQ;AACvC,UAAM,WAAW,qBAAqB,kBAAkB;AACxD,UAAM,aAAa,OAAO,kBAAkB;AAC5C,QAAI,eAAe,QAAQ;AACzB,eAAS,aAAa,OAAO,QAAQ;AAAA,IACtC,WAAU,MAAM,QAAQ,UAAU,GAAG;AACpC,eAAS,aAAa,IAAI,UAAU,WAAW,KAAK,GAAG,CAAC;AAAA,IAC9D,OAAW;AACL,eAAS,aAAa,IAAI,UAAU,GAAG,YAAY;AAAA,IACpD;AAAA,EACF;AACD,QAAM,IAAI,SAAS,aAAa,IAAI,GAAG;AACvC,MAAI,GAAG;AACL,aAAS,aAAa,OAAO,GAAG;AAChC,aAAS,aAAa,OAAO,KAAK,CAAC;AAAA,EACpC;AACD,SAAO,SAAS;AAClB;AAEK,MAAC,0BAA0B,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAM,MAAO;AACtE,SAAO,eAAe,IAAI,CAAC,QAAQ;AACjC,WAAO,GAAG,SAAS,KAAK,EAAE,GAAG,QAAQ,IAAG,CAAE,KAAK;AAAA,EACnD,CAAG,EAAE,KAAK,IAAI;AACd;AAEK,MAAC,mBAAmB,CAAC,KAAK,EAAE,QAAQ,GAAG,OAAM,MAAO;AACvD,SAAO,OAAO,IAAI,CAAC,UAAU;AAC3B,WAAO,GAAG,SAAS,KAAK,EAAE,GAAG,QAAQ,GAAG,QAAQ,MAAK,CAAE,KAAK;AAAA,EAChE,CAAG,EAAE,KAAK,IAAI;AACd;","x_google_ignoreList":[0]}
|