vue-datocms 2.0.0 → 3.0.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/index.d.ts CHANGED
@@ -1,9 +1,10 @@
1
- import * as vue from 'vue';
2
- import { PropType, VNodeProps, VNode } from 'vue';
1
+ import * as vue_demi from 'vue-demi';
2
+ import { PropType, VNodeProps, VNode, Ref } from 'vue-demi';
3
3
  import { TransformedMeta, RenderMarkRule, TransformMetaFn } from 'datocms-structured-text-generic-html-renderer';
4
4
  export { renderMarkRule, renderNodeRule, renderNodeRule as renderRule } from 'datocms-structured-text-generic-html-renderer';
5
5
  import { Record as Record$1, RenderResult, StructuredText as StructuredText$1, Document, Node, RenderRule } from 'datocms-structured-text-utils';
6
6
  export { RenderError, Document as StructuredTextDocument, StructuredText as StructuredTextGraphQlResponse } from 'datocms-structured-text-utils';
7
+ import { Options, ConnectionStatus } from 'datocms-listen';
7
8
 
8
9
  declare type ResponsiveImageType = {
9
10
  /** The aspect ratio (width/height) of the image */
@@ -29,7 +30,7 @@ declare type ResponsiveImageType = {
29
30
  /** Title attribute (`title`) for the image */
30
31
  title?: string;
31
32
  };
32
- declare const Image: vue.DefineComponent<{
33
+ declare const Image: vue_demi.DefineComponent<{
33
34
  /** The actual response you get from a DatoCMS `responsiveImage` GraphQL query */
34
35
  data: {
35
36
  type: PropType<ResponsiveImageType>;
@@ -62,6 +63,11 @@ declare const Image: vue.DefineComponent<{
62
63
  type: BooleanConstructor;
63
64
  default: boolean;
64
65
  };
66
+ /** Additional CSS rules to add to the root node */
67
+ rootStyle: {
68
+ type: ObjectConstructor;
69
+ default: () => {};
70
+ };
65
71
  /** Additional CSS rules to add to the image inside the `<picture />` tag */
66
72
  pictureStyle: {
67
73
  type: ObjectConstructor;
@@ -71,12 +77,35 @@ declare const Image: vue.DefineComponent<{
71
77
  explicitWidth: {
72
78
  type: BooleanConstructor;
73
79
  };
80
+ /**
81
+ * The layout behavior of the image as the viewport changes size
82
+ *
83
+ * Possible values:
84
+ *
85
+ * * `intrinsic`: the image will scale the dimensions down for smaller viewports, but maintain the original dimensions for larger viewports
86
+ * * `fixed`: the image dimensions will not change as the viewport changes (no responsiveness) similar to the native img element
87
+ * * `responsive` (default): the image will sscasle the dimensions down for smaller viewports and scale up for larger viewports
88
+ * * `fill`: image will stretch both width and height to the dimensions of the parent element, provided the parent element is `relative`
89
+ **/
90
+ layout: {
91
+ type: StringConstructor;
92
+ default: () => string;
93
+ validator: (value: string) => boolean;
94
+ };
95
+ /** Defines how the image will fit into its parent container when using layout="fill" */
96
+ objectFit: {
97
+ type: StringConstructor;
98
+ };
99
+ /** Defines how the image is positioned within its parent element when using layout="fill". */
100
+ objectPosition: {
101
+ type: StringConstructor;
102
+ };
74
103
  }, {
75
- inView: vue.Ref<boolean>;
76
- elRef: vue.Ref<HTMLElement | null>;
77
- loaded: vue.Ref<boolean>;
104
+ inView: vue_demi.Ref<boolean>;
105
+ elRef: vue_demi.Ref<HTMLElement | null>;
106
+ loaded: vue_demi.Ref<boolean>;
78
107
  handleLoad: () => void;
79
- }, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, Record<string, any>, string, vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps, Readonly<vue.ExtractPropTypes<{
108
+ }, unknown, {}, {}, vue_demi.ComponentOptionsMixin, vue_demi.ComponentOptionsMixin, {}, string, vue_demi.VNodeProps & vue_demi.AllowedComponentProps & vue_demi.ComponentCustomProps, Readonly<vue_demi.ExtractPropTypes<{
80
109
  /** The actual response you get from a DatoCMS `responsiveImage` GraphQL query */
81
110
  data: {
82
111
  type: PropType<ResponsiveImageType>;
@@ -109,6 +138,11 @@ declare const Image: vue.DefineComponent<{
109
138
  type: BooleanConstructor;
110
139
  default: boolean;
111
140
  };
141
+ /** Additional CSS rules to add to the root node */
142
+ rootStyle: {
143
+ type: ObjectConstructor;
144
+ default: () => {};
145
+ };
112
146
  /** Additional CSS rules to add to the image inside the `<picture />` tag */
113
147
  pictureStyle: {
114
148
  type: ObjectConstructor;
@@ -118,12 +152,37 @@ declare const Image: vue.DefineComponent<{
118
152
  explicitWidth: {
119
153
  type: BooleanConstructor;
120
154
  };
155
+ /**
156
+ * The layout behavior of the image as the viewport changes size
157
+ *
158
+ * Possible values:
159
+ *
160
+ * * `intrinsic`: the image will scale the dimensions down for smaller viewports, but maintain the original dimensions for larger viewports
161
+ * * `fixed`: the image dimensions will not change as the viewport changes (no responsiveness) similar to the native img element
162
+ * * `responsive` (default): the image will sscasle the dimensions down for smaller viewports and scale up for larger viewports
163
+ * * `fill`: image will stretch both width and height to the dimensions of the parent element, provided the parent element is `relative`
164
+ **/
165
+ layout: {
166
+ type: StringConstructor;
167
+ default: () => string;
168
+ validator: (value: string) => boolean;
169
+ };
170
+ /** Defines how the image will fit into its parent container when using layout="fill" */
171
+ objectFit: {
172
+ type: StringConstructor;
173
+ };
174
+ /** Defines how the image is positioned within its parent element when using layout="fill". */
175
+ objectPosition: {
176
+ type: StringConstructor;
177
+ };
121
178
  }>>, {
179
+ explicitWidth: boolean;
122
180
  lazyLoad: boolean;
123
181
  intersectionTreshold: number;
124
182
  intersectionMargin: string;
183
+ rootStyle: Record<string, any>;
125
184
  pictureStyle: Record<string, any>;
126
- explicitWidth: boolean;
185
+ layout: string;
127
186
  }>;
128
187
  declare const DatocmsImagePlugin: {
129
188
  install: (Vue: any) => void;
@@ -151,7 +210,7 @@ declare type RenderRecordLinkContext = {
151
210
  declare type RenderBlockContext = {
152
211
  record: Record$1;
153
212
  };
154
- declare const StructuredText: vue.DefineComponent<{
213
+ declare const StructuredText: vue_demi.DefineComponent<{
155
214
  /** The actual field value you get from DatoCMS **/
156
215
  data: {
157
216
  type: PropType<StructuredText$1<Record$1, Record$1> | Document | Node | null | undefined>;
@@ -196,7 +255,7 @@ declare const StructuredText: vue.DefineComponent<{
196
255
  renderFragment: {
197
256
  type: PropType<(children: AdapterReturn[], key: string) => AdapterReturn>;
198
257
  };
199
- }, () => RenderResult<(tagName: string, props?: VNodeProps, childOrChildren?: AdapterReturn | AdapterReturn[]) => AdapterReturn, (text: string, key: string) => AdapterReturn, (children: AdapterReturn[], key: string) => AdapterReturn>, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, Record<string, any>, string, VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps, Readonly<vue.ExtractPropTypes<{
258
+ }, () => RenderResult<(tagName: string, props?: VNodeProps, childOrChildren?: AdapterReturn | AdapterReturn[]) => AdapterReturn, (text: string, key: string) => AdapterReturn, (children: AdapterReturn[], key: string) => AdapterReturn>, unknown, {}, {}, vue_demi.ComponentOptionsMixin, vue_demi.ComponentOptionsMixin, {}, string, VNodeProps & vue_demi.AllowedComponentProps & vue_demi.ComponentCustomProps, Readonly<vue_demi.ExtractPropTypes<{
200
259
  /** The actual field value you get from DatoCMS **/
201
260
  data: {
202
261
  type: PropType<StructuredText$1<Record$1, Record$1> | Document | Node | null | undefined>;
@@ -246,6 +305,115 @@ declare const DatocmsStructuredTextPlugin: {
246
305
  install: (Vue: any) => void;
247
306
  };
248
307
 
308
+ declare type SubscribeToQueryOptions<QueryResult, QueryVariables> = Omit<Options<QueryResult, QueryVariables>, 'onStatusChange' | 'onUpdate' | 'onChannelError'>;
309
+ declare type EnabledQueryListenerOptions<QueryResult, QueryVariables> = {
310
+ /** Whether the subscription has to be performed or not */
311
+ enabled?: true;
312
+ /** The initial data to use while the initial request is being performed */
313
+ initialData?: QueryResult;
314
+ } & SubscribeToQueryOptions<QueryResult, QueryVariables>;
315
+ declare type DisabledQueryListenerOptions<QueryResult, QueryVariables> = {
316
+ /** Whether the subscription has to be performed or not */
317
+ enabled: false;
318
+ /** The initial data to use while the initial request is being performed */
319
+ initialData?: QueryResult;
320
+ } & Partial<SubscribeToQueryOptions<QueryResult, QueryVariables>>;
321
+ declare type QueryListenerOptions<QueryResult, QueryVariables> = EnabledQueryListenerOptions<QueryResult, QueryVariables> | DisabledQueryListenerOptions<QueryResult, QueryVariables>;
322
+ declare function useQuerySubscription<QueryResult = any, QueryVariables = Record<string, any>>(options: QueryListenerOptions<QueryResult, QueryVariables>): {
323
+ error: Ref<{
324
+ code: string;
325
+ message: string;
326
+ fatal: boolean;
327
+ response?: any;
328
+ } | null>;
329
+ status: Ref<ConnectionStatus>;
330
+ data: Ref<QueryResult | null>;
331
+ };
332
+
333
+ declare type SearchResultInstancesHrefSchema = {
334
+ page?: {
335
+ offset?: number;
336
+ limit?: number;
337
+ [k: string]: unknown;
338
+ };
339
+ filter: {
340
+ fuzzy?: string;
341
+ query: string;
342
+ build_trigger_id?: string;
343
+ locale?: string;
344
+ [k: string]: unknown;
345
+ };
346
+ [k: string]: unknown;
347
+ };
348
+ declare type SearchResultInstancesTargetSchema = {
349
+ data: RawSearchResult[];
350
+ meta: {
351
+ total_count: number;
352
+ };
353
+ };
354
+ declare type RawSearchResult = {
355
+ type: 'search_result';
356
+ id: string;
357
+ attributes: {
358
+ title: string;
359
+ body_excerpt: string;
360
+ url: string;
361
+ score: number;
362
+ highlight: {
363
+ title?: string[] | null;
364
+ body?: string[] | null;
365
+ };
366
+ };
367
+ };
368
+ declare class GenericClient {
369
+ config: {
370
+ apiToken: string | null;
371
+ };
372
+ searchResults: {
373
+ rawList(queryParams: SearchResultInstancesHrefSchema): Promise<SearchResultInstancesTargetSchema>;
374
+ };
375
+ }
376
+ declare type UseSiteSearchConfig<Client extends GenericClient> = {
377
+ client: Client;
378
+ buildTriggerId: string;
379
+ fuzzySearch?: boolean;
380
+ resultsPerPage?: number;
381
+ initialState?: {
382
+ locale?: string;
383
+ page?: number;
384
+ query?: string;
385
+ };
386
+ };
387
+ declare type HighlightPiece = {
388
+ text: string;
389
+ isMatch: boolean;
390
+ };
391
+ declare type ResultHighlight = HighlightPiece[];
392
+ declare type SearchResult = {
393
+ id: string;
394
+ title: string;
395
+ titleHighlights: ResultHighlight[];
396
+ bodyExcerpt: string;
397
+ bodyHighlights: ResultHighlight[];
398
+ url: string;
399
+ raw: RawSearchResult;
400
+ };
401
+ declare type UseSiteSearchData = {
402
+ pageResults: SearchResult[];
403
+ totalResults: number;
404
+ totalPages: number;
405
+ };
406
+ declare type UseSiteSearchResult = {
407
+ state: {
408
+ query: string;
409
+ locale: string | undefined;
410
+ page: number;
411
+ };
412
+ data?: Ref<UseSiteSearchData>;
413
+ error: Ref<string | undefined>;
414
+ };
415
+ declare function useSiteSearch<Client extends GenericClient>(config: UseSiteSearchConfig<Client>): UseSiteSearchResult;
416
+
249
417
  declare type SeoMetaTagType = {
250
418
  /** the tag for the meta information */
251
419
  tag: string;
@@ -267,4 +435,4 @@ declare const toHead: (...args: ToMetaTagsType[]) => {
267
435
  }[];
268
436
  };
269
437
 
270
- export { DatocmsImagePlugin, DatocmsStructuredTextPlugin, Image, RenderBlockContext, RenderInlineRecordContext, RenderRecordLinkContext, ResponsiveImageType, SeoMetaTagType, StructuredText, ToMetaTagsType, appendKeyToValidElement, defaultAdapter, toHead };
438
+ export { DatocmsImagePlugin, DatocmsStructuredTextPlugin, DisabledQueryListenerOptions, EnabledQueryListenerOptions, Image, QueryListenerOptions, RawSearchResult, RenderBlockContext, RenderInlineRecordContext, RenderRecordLinkContext, ResponsiveImageType, SeoMetaTagType, StructuredText, SubscribeToQueryOptions, ToMetaTagsType, UseSiteSearchConfig, UseSiteSearchData, UseSiteSearchResult, appendKeyToValidElement, defaultAdapter, toHead, useQuerySubscription, useSiteSearch };