@prismicio/vue 3.0.0-beta.6 → 3.0.0-beta.7
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/index.cjs +40 -27
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +91 -17
- package/dist/index.js +40 -27
- package/dist/index.js.map +1 -1
- package/package.json +20 -20
- package/src/components/PrismicImage.ts +4 -3
- package/src/components/PrismicRichText.ts +22 -9
- package/src/components/PrismicText.ts +21 -9
- package/src/components/SliceZone.ts +71 -29
- package/src/components/index.ts +2 -0
- package/src/index.ts +2 -0
- package/vetur/attributes.json +8 -0
- package/vetur/tags.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -5,6 +5,33 @@ import { Client, ClientConfig, predicate, cookie, PrismicError, ParsingError, Fo
|
|
|
5
5
|
import { asText, asHTML, asLink, LinkResolverFunction, asDate, asImageSrc, asImageWidthSrcSet, asImagePixelDensitySrcSet, documentToLinkField, HTMLFunctionSerializer, HTMLMapSerializer } from '@prismicio/helpers';
|
|
6
6
|
import { Slice, EmbedField, ImageField, LinkField, PrismicDocument, RichTextField, Query } from '@prismicio/types';
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* Returns the type of a `SliceLike` type.
|
|
10
|
+
*
|
|
11
|
+
* @typeParam TSlice - The Slice from which the type will be extracted.
|
|
12
|
+
*/
|
|
13
|
+
declare type ExtractSliceType<TSlice extends SliceLike> = TSlice extends SliceLikeRestV2 ? TSlice["slice_type"] : TSlice extends SliceLikeGraphQL ? TSlice["type"] : never;
|
|
14
|
+
/**
|
|
15
|
+
* The minimum required properties to represent a Prismic Slice from the Prismic
|
|
16
|
+
* Rest API V2 for the `<SliceZone>` component.
|
|
17
|
+
*
|
|
18
|
+
* If using Prismic's Rest API V2, use the `Slice` export from
|
|
19
|
+
* `@prismicio/types` for a full interface.
|
|
20
|
+
*
|
|
21
|
+
* @typeParam TSliceType - Type name of the Slice.
|
|
22
|
+
*/
|
|
23
|
+
declare type SliceLikeRestV2<TSliceType extends string = string> = {
|
|
24
|
+
slice_type: Slice<TSliceType>["slice_type"];
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* The minimum required properties to represent a Prismic Slice from the Prismic
|
|
28
|
+
* GraphQL API for the `<SliceZone>` component.
|
|
29
|
+
*
|
|
30
|
+
* @typeParam TSliceType - Type name of the Slice.
|
|
31
|
+
*/
|
|
32
|
+
declare type SliceLikeGraphQL<TSliceType extends string = string> = {
|
|
33
|
+
type: Slice<TSliceType>["slice_type"];
|
|
34
|
+
};
|
|
8
35
|
/**
|
|
9
36
|
* The minimum required properties to represent a Prismic Slice for the
|
|
10
37
|
* `<SliceZone />` component.
|
|
@@ -14,7 +41,7 @@ import { Slice, EmbedField, ImageField, LinkField, PrismicDocument, RichTextFiel
|
|
|
14
41
|
*
|
|
15
42
|
* @typeParam TSliceType - Type name of the Slice
|
|
16
43
|
*/
|
|
17
|
-
declare type SliceLike<TSliceType extends string = string> =
|
|
44
|
+
declare type SliceLike<TSliceType extends string = string> = SliceLikeRestV2<TSliceType> | SliceLikeGraphQL<TSliceType>;
|
|
18
45
|
/**
|
|
19
46
|
* A looser version of the `SliceZone` type from `@prismicio/types` using `SliceLike`.
|
|
20
47
|
*
|
|
@@ -23,7 +50,7 @@ declare type SliceLike<TSliceType extends string = string> = Pick<Slice<TSliceTy
|
|
|
23
50
|
*
|
|
24
51
|
* @typeParam TSlice - The type(s) of slices in the Slice Zone
|
|
25
52
|
*/
|
|
26
|
-
declare type SliceZoneLike<TSlice extends SliceLike> = readonly TSlice[];
|
|
53
|
+
declare type SliceZoneLike<TSlice extends SliceLike = SliceLike> = readonly TSlice[];
|
|
27
54
|
/**
|
|
28
55
|
* Vue props for a component rendering content from a Prismic Slice using the
|
|
29
56
|
* `<SliceZone />` component.
|
|
@@ -32,7 +59,7 @@ declare type SliceZoneLike<TSlice extends SliceLike> = readonly TSlice[];
|
|
|
32
59
|
* @typeParam TContext - Arbitrary data passed to `<SliceZone />` and made
|
|
33
60
|
* available to all Slice components
|
|
34
61
|
*/
|
|
35
|
-
declare type SliceComponentProps<TSlice extends SliceLike =
|
|
62
|
+
declare type SliceComponentProps<TSlice extends SliceLike = any, TContext = unknown> = {
|
|
36
63
|
/**
|
|
37
64
|
* Slice data for this component.
|
|
38
65
|
*/
|
|
@@ -110,21 +137,23 @@ declare type DefineComponentSliceComponentProps<TSlice extends SliceLike = Slice
|
|
|
110
137
|
*
|
|
111
138
|
* @returns Props object to use with {@link defineComponent}
|
|
112
139
|
*/
|
|
113
|
-
declare const getSliceComponentProps: <TSlice extends SliceLike<string> = SliceLike<string>, TContext = unknown>(propsHint?: ["slice", "index", "slices", "context"]
|
|
140
|
+
declare const getSliceComponentProps: <TSlice extends SliceLike<string> = SliceLike<string>, TContext = unknown>(propsHint?: ["slice", "index", "slices", "context"]) => DefineComponentSliceComponentProps<TSlice, TContext>;
|
|
114
141
|
/**
|
|
115
142
|
* A Vue component to be rendered for each instance of its Slice.
|
|
116
143
|
*
|
|
117
144
|
* @typeParam TSlice - The type(s) of slices in the Slice Zone
|
|
118
145
|
* @typeParam TContext - Arbitrary data made available to all Slice components
|
|
119
146
|
*/
|
|
120
|
-
declare type SliceComponentType<TSlice extends SliceLike =
|
|
147
|
+
declare type SliceComponentType<TSlice extends SliceLike = any, TContext = unknown> = DefineComponent<SliceComponentProps<TSlice, TContext>> | FunctionalComponent<SliceComponentProps<TSlice, TContext>>;
|
|
121
148
|
/**
|
|
122
149
|
* This Slice component can be used as a reminder to provide a proper implementation.
|
|
123
150
|
*
|
|
124
151
|
* This is also the default Vue component rendered when a component mapping
|
|
125
152
|
* cannot be found in `<SliceZone />`.
|
|
126
153
|
*/
|
|
127
|
-
declare const TODOSliceComponent: FunctionalComponent<SliceComponentProps<
|
|
154
|
+
declare const TODOSliceComponent: FunctionalComponent<SliceComponentProps<any, unknown>, {}> | DefineComponent<SliceComponentProps<any, unknown>, {}, {}, vue.ComputedOptions, vue.MethodOptions, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, VNodeProps & AllowedComponentProps & ComponentCustomProps, Readonly<SliceComponentProps<any, unknown>>, {
|
|
155
|
+
slice: any;
|
|
156
|
+
}>;
|
|
128
157
|
/**
|
|
129
158
|
* A record of Slice types mapped to Vue components. Each components will be
|
|
130
159
|
* rendered for each instance of their Slice type.
|
|
@@ -133,7 +162,7 @@ declare const TODOSliceComponent: FunctionalComponent<SliceComponentProps<SliceL
|
|
|
133
162
|
* @typeParam TContext - Arbitrary data made available to all Slice components
|
|
134
163
|
*/
|
|
135
164
|
declare type SliceZoneComponents<TSlice extends SliceLike = SliceLike, TContext = unknown> = {
|
|
136
|
-
[SliceType in
|
|
165
|
+
[SliceType in ExtractSliceType<TSlice>]: SliceComponentType<Extract<TSlice, SliceLike<SliceType>>, TContext> | string;
|
|
137
166
|
};
|
|
138
167
|
/**
|
|
139
168
|
* Gets an optimized record of Slice types mapped to Vue components. Each
|
|
@@ -179,7 +208,7 @@ declare type SliceZoneResolverArgs<TSlice extends SliceLike = SliceLike> = {
|
|
|
179
208
|
/**
|
|
180
209
|
* The name of the Slice.
|
|
181
210
|
*/
|
|
182
|
-
sliceName: TSlice
|
|
211
|
+
sliceName: ExtractSliceType<TSlice>;
|
|
183
212
|
/**
|
|
184
213
|
* The index of the Slice in the Slice Zone.
|
|
185
214
|
*/
|
|
@@ -196,18 +225,17 @@ declare type SliceZoneResolverArgs<TSlice extends SliceLike = SliceLike> = {
|
|
|
196
225
|
*
|
|
197
226
|
* @returns The Vue component to render for a Slice.
|
|
198
227
|
*/
|
|
199
|
-
declare type SliceZoneResolver<TSlice extends SliceLike =
|
|
228
|
+
declare type SliceZoneResolver<TSlice extends SliceLike = any, TContext = unknown> = (args: SliceZoneResolverArgs<TSlice>) => SliceComponentType<any, TContext> | string | undefined | null;
|
|
200
229
|
/**
|
|
201
230
|
* Props for `<SliceZone />`.
|
|
202
231
|
*
|
|
203
|
-
* @typeParam TSlice - The type(s) of slices in the Slice Zone
|
|
204
232
|
* @typeParam TContext - Arbitrary data made available to all Slice components
|
|
205
233
|
*/
|
|
206
|
-
declare type SliceZoneProps<
|
|
234
|
+
declare type SliceZoneProps<TContext = unknown> = {
|
|
207
235
|
/**
|
|
208
236
|
* List of Slice data from the Slice Zone.
|
|
209
237
|
*/
|
|
210
|
-
slices: SliceZoneLike
|
|
238
|
+
slices: SliceZoneLike;
|
|
211
239
|
/**
|
|
212
240
|
* A record mapping Slice types to Vue components.
|
|
213
241
|
*/
|
|
@@ -222,7 +250,7 @@ declare type SliceZoneProps<TSlice extends SliceLike = SliceLike, TContext = unk
|
|
|
222
250
|
*
|
|
223
251
|
* @returns The Vue component to render for a Slice.
|
|
224
252
|
*/
|
|
225
|
-
resolver?: SliceZoneResolver<
|
|
253
|
+
resolver?: SliceZoneResolver<any, TContext>;
|
|
226
254
|
/**
|
|
227
255
|
* Arbitrary data made available to all Slice components.
|
|
228
256
|
*/
|
|
@@ -236,7 +264,7 @@ declare type SliceZoneProps<TSlice extends SliceLike = SliceLike, TContext = unk
|
|
|
236
264
|
*
|
|
237
265
|
* @defaultValue The Slice Zone default component provided to `@prismicio/vue` plugin if configured, otherwise `null` when `process.env.NODE_ENV === "production"` else {@link TODOSliceComponent}.
|
|
238
266
|
*/
|
|
239
|
-
defaultComponent?: SliceComponentType<
|
|
267
|
+
defaultComponent?: SliceComponentType<any, TContext>;
|
|
240
268
|
/**
|
|
241
269
|
* An HTML tag name, a component, or a functional component used to wrap the
|
|
242
270
|
* output. The Slice Zone is not wrapped by default.
|
|
@@ -850,7 +878,7 @@ declare type PrismicTextProps = {
|
|
|
850
878
|
/**
|
|
851
879
|
* The Prismic rich text or title field to render.
|
|
852
880
|
*/
|
|
853
|
-
field: RichTextField;
|
|
881
|
+
field: RichTextField | null | undefined;
|
|
854
882
|
/**
|
|
855
883
|
* Separator used to join each element.
|
|
856
884
|
*
|
|
@@ -863,6 +891,11 @@ declare type PrismicTextProps = {
|
|
|
863
891
|
* @defaultValue `"div"`
|
|
864
892
|
*/
|
|
865
893
|
wrapper?: string | ConcreteComponent;
|
|
894
|
+
/**
|
|
895
|
+
* The string value to be rendered when the field is empty. If a fallback is
|
|
896
|
+
* not given, `""` (nothing) will be rendered.
|
|
897
|
+
*/
|
|
898
|
+
fallback?: string;
|
|
866
899
|
};
|
|
867
900
|
/**
|
|
868
901
|
* Options for {@link usePrismicText}.
|
|
@@ -902,7 +935,7 @@ declare type PrismicRichTextProps = {
|
|
|
902
935
|
/**
|
|
903
936
|
* The Prismic rich text or title field to render.
|
|
904
937
|
*/
|
|
905
|
-
field: RichTextField;
|
|
938
|
+
field: RichTextField | null | undefined;
|
|
906
939
|
/**
|
|
907
940
|
* A link resolver function used to resolve link when not using the route
|
|
908
941
|
* resolver parameter with `@prismicio/client`.
|
|
@@ -926,6 +959,11 @@ declare type PrismicRichTextProps = {
|
|
|
926
959
|
* @defaultValue `"div"`
|
|
927
960
|
*/
|
|
928
961
|
wrapper?: string | ConcreteComponent;
|
|
962
|
+
/**
|
|
963
|
+
* The HTML value to be rendered when the field is empty. If a fallback is not
|
|
964
|
+
* given, `""` (nothing) will be rendered.
|
|
965
|
+
*/
|
|
966
|
+
fallback?: string;
|
|
929
967
|
};
|
|
930
968
|
/**
|
|
931
969
|
* Options for {@link usePrismicRichText}.
|
|
@@ -1010,6 +1048,8 @@ declare const usePrismicDocuments: <TDocument extends PrismicDocument<Record<str
|
|
|
1010
1048
|
removeEventListener: any;
|
|
1011
1049
|
dispatchEvent: any;
|
|
1012
1050
|
onabort: any;
|
|
1051
|
+
reason: any;
|
|
1052
|
+
throwIfAborted: any;
|
|
1013
1053
|
} | undefined;
|
|
1014
1054
|
} & ComposableOnlyParameters) | undefined) => ClientComposableReturnType<Query<TDocument>>;
|
|
1015
1055
|
/**
|
|
@@ -1034,6 +1074,8 @@ declare const useFirstPrismicDocument: <TDocument extends PrismicDocument<Record
|
|
|
1034
1074
|
removeEventListener: any;
|
|
1035
1075
|
dispatchEvent: any;
|
|
1036
1076
|
onabort: any;
|
|
1077
|
+
reason: any;
|
|
1078
|
+
throwIfAborted: any;
|
|
1037
1079
|
} | undefined;
|
|
1038
1080
|
} & ComposableOnlyParameters) | undefined) => ClientComposableReturnType<TDocument>;
|
|
1039
1081
|
/**
|
|
@@ -1058,6 +1100,8 @@ declare const usePrismicDocumentByID: <TDocument extends PrismicDocument<Record<
|
|
|
1058
1100
|
removeEventListener: any;
|
|
1059
1101
|
dispatchEvent: any;
|
|
1060
1102
|
onabort: any;
|
|
1103
|
+
reason: any;
|
|
1104
|
+
throwIfAborted: any;
|
|
1061
1105
|
} | undefined;
|
|
1062
1106
|
} & ComposableOnlyParameters) | undefined) => ClientComposableReturnType<TDocument>;
|
|
1063
1107
|
/**
|
|
@@ -1082,6 +1126,8 @@ declare const usePrismicDocumentsByIDs: <TDocument extends PrismicDocument<Recor
|
|
|
1082
1126
|
removeEventListener: any;
|
|
1083
1127
|
dispatchEvent: any;
|
|
1084
1128
|
onabort: any;
|
|
1129
|
+
reason: any;
|
|
1130
|
+
throwIfAborted: any;
|
|
1085
1131
|
} | undefined;
|
|
1086
1132
|
} & ComposableOnlyParameters) | undefined) => ClientComposableReturnType<Query<TDocument>>;
|
|
1087
1133
|
/**
|
|
@@ -1108,6 +1154,8 @@ declare const useAllPrismicDocumentsByIDs: <TDocument extends PrismicDocument<Re
|
|
|
1108
1154
|
removeEventListener: any;
|
|
1109
1155
|
dispatchEvent: any;
|
|
1110
1156
|
onabort: any;
|
|
1157
|
+
reason: any;
|
|
1158
|
+
throwIfAborted: any;
|
|
1111
1159
|
} | undefined;
|
|
1112
1160
|
} & ComposableOnlyParameters) | undefined) => ClientComposableReturnType<TDocument[]>;
|
|
1113
1161
|
/**
|
|
@@ -1134,6 +1182,8 @@ declare const usePrismicDocumentByUID: <TDocument extends PrismicDocument<Record
|
|
|
1134
1182
|
removeEventListener: any;
|
|
1135
1183
|
dispatchEvent: any;
|
|
1136
1184
|
onabort: any;
|
|
1185
|
+
reason: any;
|
|
1186
|
+
throwIfAborted: any;
|
|
1137
1187
|
} | undefined;
|
|
1138
1188
|
} & ComposableOnlyParameters) | undefined) => ClientComposableReturnType<TDocument>;
|
|
1139
1189
|
/**
|
|
@@ -1159,6 +1209,8 @@ declare const usePrismicDocumentsByUIDs: <TDocument extends PrismicDocument<Reco
|
|
|
1159
1209
|
removeEventListener: any;
|
|
1160
1210
|
dispatchEvent: any;
|
|
1161
1211
|
onabort: any;
|
|
1212
|
+
reason: any;
|
|
1213
|
+
throwIfAborted: any;
|
|
1162
1214
|
} | undefined;
|
|
1163
1215
|
} & ComposableOnlyParameters) | undefined) => ClientComposableReturnType<Query<TDocument>>;
|
|
1164
1216
|
/**
|
|
@@ -1186,6 +1238,8 @@ declare const useAllPrismicDocumentsByUIDs: <TDocument extends PrismicDocument<R
|
|
|
1186
1238
|
removeEventListener: any;
|
|
1187
1239
|
dispatchEvent: any;
|
|
1188
1240
|
onabort: any;
|
|
1241
|
+
reason: any;
|
|
1242
|
+
throwIfAborted: any;
|
|
1189
1243
|
} | undefined;
|
|
1190
1244
|
} & ComposableOnlyParameters) | undefined) => ClientComposableReturnType<TDocument[]>;
|
|
1191
1245
|
/**
|
|
@@ -1211,6 +1265,8 @@ declare const useSinglePrismicDocument: <TDocument extends PrismicDocument<Recor
|
|
|
1211
1265
|
removeEventListener: any;
|
|
1212
1266
|
dispatchEvent: any;
|
|
1213
1267
|
onabort: any;
|
|
1268
|
+
reason: any;
|
|
1269
|
+
throwIfAborted: any;
|
|
1214
1270
|
} | undefined;
|
|
1215
1271
|
} & ComposableOnlyParameters) | undefined) => ClientComposableReturnType<TDocument>;
|
|
1216
1272
|
/**
|
|
@@ -1236,6 +1292,8 @@ declare const usePrismicDocumentsByType: <TDocument extends PrismicDocument<Reco
|
|
|
1236
1292
|
removeEventListener: any;
|
|
1237
1293
|
dispatchEvent: any;
|
|
1238
1294
|
onabort: any;
|
|
1295
|
+
reason: any;
|
|
1296
|
+
throwIfAborted: any;
|
|
1239
1297
|
} | undefined;
|
|
1240
1298
|
} & ComposableOnlyParameters) | undefined) => ClientComposableReturnType<Query<TDocument>>;
|
|
1241
1299
|
/**
|
|
@@ -1263,6 +1321,8 @@ declare const useAllPrismicDocumentsByType: <TDocument extends PrismicDocument<R
|
|
|
1263
1321
|
removeEventListener: any;
|
|
1264
1322
|
dispatchEvent: any;
|
|
1265
1323
|
onabort: any;
|
|
1324
|
+
reason: any;
|
|
1325
|
+
throwIfAborted: any;
|
|
1266
1326
|
} | undefined;
|
|
1267
1327
|
} & ComposableOnlyParameters) | undefined) => ClientComposableReturnType<TDocument[]>;
|
|
1268
1328
|
/**
|
|
@@ -1287,6 +1347,8 @@ declare const usePrismicDocumentsByTag: <TDocument extends PrismicDocument<Recor
|
|
|
1287
1347
|
removeEventListener: any;
|
|
1288
1348
|
dispatchEvent: any;
|
|
1289
1349
|
onabort: any;
|
|
1350
|
+
reason: any;
|
|
1351
|
+
throwIfAborted: any;
|
|
1290
1352
|
} | undefined;
|
|
1291
1353
|
} & ComposableOnlyParameters) | undefined) => ClientComposableReturnType<Query<TDocument>>;
|
|
1292
1354
|
/**
|
|
@@ -1314,6 +1376,8 @@ declare const useAllPrismicDocumentsByTag: <TDocument extends PrismicDocument<Re
|
|
|
1314
1376
|
removeEventListener: any;
|
|
1315
1377
|
dispatchEvent: any;
|
|
1316
1378
|
onabort: any;
|
|
1379
|
+
reason: any;
|
|
1380
|
+
throwIfAborted: any;
|
|
1317
1381
|
} | undefined;
|
|
1318
1382
|
} & ComposableOnlyParameters) | undefined) => ClientComposableReturnType<TDocument[]>;
|
|
1319
1383
|
/**
|
|
@@ -1339,6 +1403,8 @@ declare const usePrismicDocumentsByEveryTag: <TDocument extends PrismicDocument<
|
|
|
1339
1403
|
removeEventListener: any;
|
|
1340
1404
|
dispatchEvent: any;
|
|
1341
1405
|
onabort: any;
|
|
1406
|
+
reason: any;
|
|
1407
|
+
throwIfAborted: any;
|
|
1342
1408
|
} | undefined;
|
|
1343
1409
|
} & ComposableOnlyParameters) | undefined) => ClientComposableReturnType<Query<TDocument>>;
|
|
1344
1410
|
/**
|
|
@@ -1366,6 +1432,8 @@ declare const useAllPrismicDocumentsByEveryTag: <TDocument extends PrismicDocume
|
|
|
1366
1432
|
removeEventListener: any;
|
|
1367
1433
|
dispatchEvent: any;
|
|
1368
1434
|
onabort: any;
|
|
1435
|
+
reason: any;
|
|
1436
|
+
throwIfAborted: any;
|
|
1369
1437
|
} | undefined;
|
|
1370
1438
|
} & ComposableOnlyParameters) | undefined) => ClientComposableReturnType<TDocument[]>;
|
|
1371
1439
|
/**
|
|
@@ -1391,6 +1459,8 @@ declare const usePrismicDocumentsBySomeTags: <TDocument extends PrismicDocument<
|
|
|
1391
1459
|
removeEventListener: any;
|
|
1392
1460
|
dispatchEvent: any;
|
|
1393
1461
|
onabort: any;
|
|
1462
|
+
reason: any;
|
|
1463
|
+
throwIfAborted: any;
|
|
1394
1464
|
} | undefined;
|
|
1395
1465
|
} & ComposableOnlyParameters) | undefined) => ClientComposableReturnType<Query<TDocument>>;
|
|
1396
1466
|
/**
|
|
@@ -1419,6 +1489,8 @@ declare const useAllPrismicDocumentsBySomeTags: <TDocument extends PrismicDocume
|
|
|
1419
1489
|
removeEventListener: any;
|
|
1420
1490
|
dispatchEvent: any;
|
|
1421
1491
|
onabort: any;
|
|
1492
|
+
reason: any;
|
|
1493
|
+
throwIfAborted: any;
|
|
1422
1494
|
} | undefined;
|
|
1423
1495
|
} & ComposableOnlyParameters) | undefined) => ClientComposableReturnType<TDocument[]>;
|
|
1424
1496
|
/**
|
|
@@ -1449,6 +1521,8 @@ declare const dangerouslyUseAllPrismicDocuments: <TDocument extends PrismicDocum
|
|
|
1449
1521
|
removeEventListener: any;
|
|
1450
1522
|
dispatchEvent: any;
|
|
1451
1523
|
onabort: any;
|
|
1524
|
+
reason: any;
|
|
1525
|
+
throwIfAborted: any;
|
|
1452
1526
|
} | undefined;
|
|
1453
1527
|
} & ComposableOnlyParameters) | undefined) => ClientComposableReturnType<TDocument[]>;
|
|
1454
1528
|
|
|
@@ -1470,4 +1544,4 @@ declare module "@vue/runtime-core" {
|
|
|
1470
1544
|
}
|
|
1471
1545
|
}
|
|
1472
1546
|
|
|
1473
|
-
export { ClientComposableReturnType, DefineComponentSliceComponentProps, PrismicClientComposableState, PrismicEmbed, PrismicEmbedProps, PrismicImage, PrismicImageProps, PrismicLink, PrismicLinkProps, PrismicPlugin, PrismicPluginOptions, PrismicRichText, PrismicRichTextProps, PrismicText, PrismicTextProps, SliceComponentProps, SliceComponentType, SliceLike, SliceZone, SliceZoneComponents, SliceZoneLike, SliceZoneProps, SliceZoneResolver, TODOSliceComponent, UsePrismicImageOptions, UsePrismicLinkOptions, UsePrismicRichTextOptions, UsePrismicTextOptions, createPrismic, dangerouslyUseAllPrismicDocuments, defineSliceZoneComponents, getSliceComponentProps, prismicKey, useAllPrismicDocumentsByEveryTag, useAllPrismicDocumentsByIDs, useAllPrismicDocumentsBySomeTags, useAllPrismicDocumentsByTag, useAllPrismicDocumentsByType, useAllPrismicDocumentsByUIDs, useFirstPrismicDocument, usePrismic, usePrismicDocumentByID, usePrismicDocumentByUID, usePrismicDocuments, usePrismicDocumentsByEveryTag, usePrismicDocumentsByIDs, usePrismicDocumentsBySomeTags, usePrismicDocumentsByTag, usePrismicDocumentsByType, usePrismicDocumentsByUIDs, usePrismicImage, usePrismicLink, usePrismicRichText, usePrismicText, useSinglePrismicDocument };
|
|
1547
|
+
export { ClientComposableReturnType, DefineComponentSliceComponentProps, PrismicClientComposableState, PrismicEmbed, PrismicEmbedProps, PrismicImage, PrismicImageProps, PrismicLink, PrismicLinkProps, PrismicPlugin, PrismicPluginOptions, PrismicRichText, PrismicRichTextProps, PrismicText, PrismicTextProps, SliceComponentProps, SliceComponentType, SliceLike, SliceLikeGraphQL, SliceLikeRestV2, SliceZone, SliceZoneComponents, SliceZoneLike, SliceZoneProps, SliceZoneResolver, TODOSliceComponent, UsePrismicImageOptions, UsePrismicLinkOptions, UsePrismicRichTextOptions, UsePrismicTextOptions, createPrismic, dangerouslyUseAllPrismicDocuments, defineSliceZoneComponents, getSliceComponentProps, prismicKey, useAllPrismicDocumentsByEveryTag, useAllPrismicDocumentsByIDs, useAllPrismicDocumentsBySomeTags, useAllPrismicDocumentsByTag, useAllPrismicDocumentsByType, useAllPrismicDocumentsByUIDs, useFirstPrismicDocument, usePrismic, usePrismicDocumentByID, usePrismicDocumentByUID, usePrismicDocuments, usePrismicDocumentsByEveryTag, usePrismicDocumentsByIDs, usePrismicDocumentsBySomeTags, usePrismicDocumentsByTag, usePrismicDocumentsByType, usePrismicDocumentsByUIDs, usePrismicImage, usePrismicLink, usePrismicRichText, usePrismicText, useSinglePrismicDocument };
|
package/dist/index.js
CHANGED
|
@@ -37,6 +37,11 @@ const PrismicEmbedImpl = /* @__PURE__ */ defineComponent({
|
|
|
37
37
|
});
|
|
38
38
|
const PrismicEmbed = PrismicEmbedImpl;
|
|
39
39
|
|
|
40
|
+
if (typeof process === "undefined") {
|
|
41
|
+
globalThis.process = { env: {} };
|
|
42
|
+
}
|
|
43
|
+
const __PRODUCTION__ = process.env.NODE_ENV === "production";
|
|
44
|
+
|
|
40
45
|
const prismicKey = Symbol("prismic");
|
|
41
46
|
|
|
42
47
|
const usePrismic = () => {
|
|
@@ -59,8 +64,8 @@ const usePrismicImage = (props) => {
|
|
|
59
64
|
const widths = unref(props.widths);
|
|
60
65
|
const pixelDensities = unref(props.pixelDensities);
|
|
61
66
|
if (widths) {
|
|
62
|
-
if (pixelDensities) {
|
|
63
|
-
console.warn("[PrismicImage] `widths`
|
|
67
|
+
if (!__PRODUCTION__ && pixelDensities) {
|
|
68
|
+
console.warn("[PrismicImage] Only one of `widths` or `pixelDensities` props can be provided. You can resolve this warning by removing either the `widths` or `pixelDensities` prop. `widths` will be used in this case.", props);
|
|
64
69
|
}
|
|
65
70
|
return asImageWidthSrcSet(field, {
|
|
66
71
|
...imgixParams,
|
|
@@ -285,7 +290,12 @@ const PrismicLink = PrismicLinkImpl;
|
|
|
285
290
|
const defaultWrapper$1 = "div";
|
|
286
291
|
const usePrismicText = (props) => {
|
|
287
292
|
const text = computed(() => {
|
|
288
|
-
|
|
293
|
+
var _a;
|
|
294
|
+
const field = unref(props.field);
|
|
295
|
+
if (!isFilled.richText(field)) {
|
|
296
|
+
return (_a = unref(props.fallback)) != null ? _a : "";
|
|
297
|
+
}
|
|
298
|
+
return asText(unref(field), unref(props.separator));
|
|
289
299
|
});
|
|
290
300
|
return {
|
|
291
301
|
text
|
|
@@ -307,12 +317,14 @@ const PrismicTextImpl = /* @__PURE__ */ defineComponent({
|
|
|
307
317
|
type: [String, Object, Function],
|
|
308
318
|
default: void 0,
|
|
309
319
|
required: false
|
|
320
|
+
},
|
|
321
|
+
fallback: {
|
|
322
|
+
type: String,
|
|
323
|
+
default: void 0,
|
|
324
|
+
required: false
|
|
310
325
|
}
|
|
311
326
|
},
|
|
312
327
|
setup(props) {
|
|
313
|
-
if (!props.field) {
|
|
314
|
-
return () => null;
|
|
315
|
-
}
|
|
316
328
|
const { text } = usePrismicText(props);
|
|
317
329
|
return () => {
|
|
318
330
|
const parent = simplyResolveComponent(props.wrapper || defaultWrapper$1);
|
|
@@ -328,10 +340,14 @@ const defaultWrapper = "div";
|
|
|
328
340
|
const usePrismicRichText = (props) => {
|
|
329
341
|
const { options } = usePrismic();
|
|
330
342
|
const html = computed(() => {
|
|
331
|
-
var _a, _b;
|
|
332
|
-
const
|
|
333
|
-
|
|
334
|
-
|
|
343
|
+
var _a, _b, _c;
|
|
344
|
+
const field = unref(props.field);
|
|
345
|
+
if (!isFilled.richText(field)) {
|
|
346
|
+
return (_a = unref(props.fallback)) != null ? _a : "";
|
|
347
|
+
}
|
|
348
|
+
const linkResolver = (_b = unref(props.linkResolver)) != null ? _b : options.linkResolver;
|
|
349
|
+
const htmlSerializer = (_c = unref(props.htmlSerializer)) != null ? _c : options.htmlSerializer;
|
|
350
|
+
return asHTML(unref(field), linkResolver, htmlSerializer);
|
|
335
351
|
});
|
|
336
352
|
return {
|
|
337
353
|
html
|
|
@@ -358,16 +374,18 @@ const PrismicRichTextImpl = /* @__PURE__ */ defineComponent({
|
|
|
358
374
|
type: [String, Object, Function],
|
|
359
375
|
default: void 0,
|
|
360
376
|
required: false
|
|
377
|
+
},
|
|
378
|
+
fallback: {
|
|
379
|
+
type: String,
|
|
380
|
+
default: void 0,
|
|
381
|
+
required: false
|
|
361
382
|
}
|
|
362
383
|
},
|
|
363
384
|
setup(props) {
|
|
364
|
-
if (!props.field) {
|
|
365
|
-
return () => null;
|
|
366
|
-
}
|
|
367
385
|
const { html } = usePrismicRichText(props);
|
|
368
386
|
const root = ref(null);
|
|
369
387
|
const maybeRouter = inject(routerKey, null);
|
|
370
|
-
if (maybeRouter) {
|
|
388
|
+
if (maybeRouter && html.value) {
|
|
371
389
|
let links = [];
|
|
372
390
|
const navigate = function(event) {
|
|
373
391
|
event.preventDefault();
|
|
@@ -410,11 +428,6 @@ const PrismicRichTextImpl = /* @__PURE__ */ defineComponent({
|
|
|
410
428
|
});
|
|
411
429
|
const PrismicRichText = PrismicRichTextImpl;
|
|
412
430
|
|
|
413
|
-
if (typeof process === "undefined") {
|
|
414
|
-
globalThis.process = { env: {} };
|
|
415
|
-
}
|
|
416
|
-
const __PRODUCTION__ = process.env.NODE_ENV === "production";
|
|
417
|
-
|
|
418
431
|
const getSliceComponentProps = (propsHint) => ({
|
|
419
432
|
slice: {
|
|
420
433
|
type: Object,
|
|
@@ -437,16 +450,15 @@ const TODOSliceComponent = __PRODUCTION__ ? () => null : /* @__PURE__ */ defineC
|
|
|
437
450
|
name: "TODOSliceComponent",
|
|
438
451
|
props: getSliceComponentProps(),
|
|
439
452
|
setup(props) {
|
|
453
|
+
const type = computed(() => "slice_type" in props.slice ? props.slice.slice_type : props.slice.type);
|
|
440
454
|
watchEffect(() => {
|
|
441
|
-
console.warn(`[SliceZone] Could not find a component for Slice type "${
|
|
455
|
+
console.warn(`[SliceZone] Could not find a component for Slice type "${type.value}"`, props.slice);
|
|
442
456
|
});
|
|
443
457
|
return () => {
|
|
444
458
|
return h("section", {
|
|
445
459
|
"data-slice-zone-todo-component": "",
|
|
446
|
-
"data-slice-type":
|
|
447
|
-
}, [
|
|
448
|
-
`Could not find a component for Slice type "${props.slice.slice_type}"`
|
|
449
|
-
]);
|
|
460
|
+
"data-slice-type": type.value
|
|
461
|
+
}, [`Could not find a component for Slice type "${type.value}"`]);
|
|
450
462
|
};
|
|
451
463
|
}
|
|
452
464
|
});
|
|
@@ -500,11 +512,12 @@ const SliceZoneImpl = /* @__PURE__ */ defineComponent({
|
|
|
500
512
|
const renderedSlices = computed(() => {
|
|
501
513
|
return props.slices.map((slice, index) => {
|
|
502
514
|
var _a;
|
|
503
|
-
|
|
515
|
+
const type = "slice_type" in slice ? slice.slice_type : slice.type;
|
|
516
|
+
let component = props.components && type in props.components ? props.components[type] : props.defaultComponent || ((_a = options.components) == null ? void 0 : _a.sliceZoneDefaultComponent) || TODOSliceComponent;
|
|
504
517
|
if (props.resolver) {
|
|
505
518
|
const resolvedComponent = props.resolver({
|
|
506
519
|
slice,
|
|
507
|
-
sliceName:
|
|
520
|
+
sliceName: type,
|
|
508
521
|
i: index
|
|
509
522
|
});
|
|
510
523
|
if (resolvedComponent) {
|
|
@@ -512,7 +525,7 @@ const SliceZoneImpl = /* @__PURE__ */ defineComponent({
|
|
|
512
525
|
}
|
|
513
526
|
}
|
|
514
527
|
const p = {
|
|
515
|
-
key: `${
|
|
528
|
+
key: `${index}-${JSON.stringify(slice)}`,
|
|
516
529
|
slice,
|
|
517
530
|
index,
|
|
518
531
|
context: props.context,
|