vue-datocms 1.1.0 → 2.0.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/README.md +1 -1
- package/dist/index.d.ts +103 -39
- package/dist/index.esm.js +93 -165
- package/dist/index.min.js +104 -174
- package/dist/index.umd.js +104 -174
- package/package.json +16 -20
package/README.md
CHANGED
|
@@ -433,7 +433,7 @@ You can also pass custom renderers for special nodes (inline records, record lin
|
|
|
433
433
|
<script>
|
|
434
434
|
import { request } from './lib/datocms';
|
|
435
435
|
import { StructuredText, Image } from 'vue-datocms';
|
|
436
|
-
import { h } from 'vue
|
|
436
|
+
import { h } from 'vue';
|
|
437
437
|
|
|
438
438
|
const query = gql`
|
|
439
439
|
query {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import { PropType, VNodeProps, VNode } from 'vue
|
|
1
|
+
import * as vue from 'vue';
|
|
2
|
+
import { PropType, VNodeProps, VNode } from 'vue';
|
|
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';
|
|
@@ -29,7 +29,7 @@ declare type ResponsiveImageType = {
|
|
|
29
29
|
/** Title attribute (`title`) for the image */
|
|
30
30
|
title?: string;
|
|
31
31
|
};
|
|
32
|
-
declare const Image:
|
|
32
|
+
declare const Image: vue.DefineComponent<{
|
|
33
33
|
/** The actual response you get from a DatoCMS `responsiveImage` GraphQL query */
|
|
34
34
|
data: {
|
|
35
35
|
type: PropType<ResponsiveImageType>;
|
|
@@ -72,22 +72,53 @@ declare const Image: vue_demi.DefineComponent<{
|
|
|
72
72
|
type: BooleanConstructor;
|
|
73
73
|
};
|
|
74
74
|
}, {
|
|
75
|
-
inView:
|
|
76
|
-
elRef:
|
|
77
|
-
loaded:
|
|
75
|
+
inView: vue.Ref<boolean>;
|
|
76
|
+
elRef: vue.Ref<HTMLElement | null>;
|
|
77
|
+
loaded: vue.Ref<boolean>;
|
|
78
78
|
handleLoad: () => void;
|
|
79
|
-
}, unknown, {}, {},
|
|
80
|
-
|
|
81
|
-
data:
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
79
|
+
}, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, Record<string, any>, string, vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps, Readonly<vue.ExtractPropTypes<{
|
|
80
|
+
/** The actual response you get from a DatoCMS `responsiveImage` GraphQL query */
|
|
81
|
+
data: {
|
|
82
|
+
type: PropType<ResponsiveImageType>;
|
|
83
|
+
required: true;
|
|
84
|
+
};
|
|
85
|
+
/** Additional CSS class for the image inside the `<picture />` tag */
|
|
86
|
+
pictureClass: {
|
|
87
|
+
type: StringConstructor;
|
|
88
|
+
};
|
|
89
|
+
/** Duration (in ms) of the fade-in transition effect upoad image loading */
|
|
90
|
+
fadeInDuration: {
|
|
91
|
+
type: NumberConstructor;
|
|
92
|
+
};
|
|
93
|
+
/** @deprecated Use the intersectionThreshold prop */
|
|
94
|
+
intersectionTreshold: {
|
|
95
|
+
type: NumberConstructor;
|
|
96
|
+
default: number;
|
|
97
|
+
};
|
|
98
|
+
/** Indicate at what percentage of the placeholder visibility the loading of the image should be triggered. A value of 0 means that as soon as even one pixel is visible, the callback will be run. A value of 1.0 means that the threshold isn't considered passed until every pixel is visible */
|
|
99
|
+
intersectionThreshold: {
|
|
100
|
+
type: NumberConstructor;
|
|
101
|
+
};
|
|
102
|
+
/** Margin around the placeholder. Can have values similar to the CSS margin property (top, right, bottom, left). The values can be percentages. This set of values serves to grow or shrink each side of the placeholder element's bounding box before computing intersections */
|
|
103
|
+
intersectionMargin: {
|
|
104
|
+
type: StringConstructor;
|
|
105
|
+
default: string;
|
|
106
|
+
};
|
|
107
|
+
/** Wheter enable lazy loading or not */
|
|
108
|
+
lazyLoad: {
|
|
109
|
+
type: BooleanConstructor;
|
|
110
|
+
default: boolean;
|
|
111
|
+
};
|
|
112
|
+
/** Additional CSS rules to add to the image inside the `<picture />` tag */
|
|
113
|
+
pictureStyle: {
|
|
114
|
+
type: ObjectConstructor;
|
|
115
|
+
default: () => {};
|
|
116
|
+
};
|
|
117
|
+
/** Wheter the image wrapper should explicitely declare the width of the image or keep it fluid */
|
|
118
|
+
explicitWidth: {
|
|
119
|
+
type: BooleanConstructor;
|
|
120
|
+
};
|
|
121
|
+
}>>, {
|
|
91
122
|
lazyLoad: boolean;
|
|
92
123
|
intersectionTreshold: number;
|
|
93
124
|
intersectionMargin: string;
|
|
@@ -100,8 +131,8 @@ declare const DatocmsImagePlugin: {
|
|
|
100
131
|
|
|
101
132
|
declare type AdapterReturn = VNode | string | null;
|
|
102
133
|
declare const defaultAdapter: {
|
|
103
|
-
renderNode: (tagName: string, props?: VNodeProps
|
|
104
|
-
renderMark: (tagName: string, props?: VNodeProps
|
|
134
|
+
renderNode: (tagName: string, props?: VNodeProps, childOrChildren?: AdapterReturn | AdapterReturn[]) => AdapterReturn;
|
|
135
|
+
renderMark: (tagName: string, props?: VNodeProps, childOrChildren?: AdapterReturn | AdapterReturn[]) => AdapterReturn;
|
|
105
136
|
renderFragment: (children: AdapterReturn[], key: string) => AdapterReturn;
|
|
106
137
|
renderText: (text: string, key: string) => AdapterReturn;
|
|
107
138
|
};
|
|
@@ -120,22 +151,67 @@ declare type RenderRecordLinkContext = {
|
|
|
120
151
|
declare type RenderBlockContext = {
|
|
121
152
|
record: Record$1;
|
|
122
153
|
};
|
|
123
|
-
declare const StructuredText:
|
|
154
|
+
declare const StructuredText: vue.DefineComponent<{
|
|
155
|
+
/** The actual field value you get from DatoCMS **/
|
|
156
|
+
data: {
|
|
157
|
+
type: PropType<StructuredText$1<Record$1, Record$1> | Document | Node | null | undefined>;
|
|
158
|
+
};
|
|
159
|
+
/** @deprecated use customNodeRules **/
|
|
160
|
+
customRules: {
|
|
161
|
+
type: PropType<RenderRule<(tagName: string, props?: VNodeProps, childOrChildren?: AdapterReturn | AdapterReturn[]) => AdapterReturn, (text: string, key: string) => AdapterReturn, (children: AdapterReturn[], key: string) => AdapterReturn>[]>;
|
|
162
|
+
};
|
|
163
|
+
/** A set of additional rules to convert the document to JSX **/
|
|
164
|
+
customNodeRules: {
|
|
165
|
+
type: PropType<RenderRule<(tagName: string, props?: VNodeProps, childOrChildren?: AdapterReturn | AdapterReturn[]) => AdapterReturn, (text: string, key: string) => AdapterReturn, (children: AdapterReturn[], key: string) => AdapterReturn>[]>;
|
|
166
|
+
};
|
|
167
|
+
/** A set of additional rules to convert the document to JSX **/
|
|
168
|
+
customMarkRules: {
|
|
169
|
+
type: PropType<RenderMarkRule<(tagName: string, props?: VNodeProps, childOrChildren?: AdapterReturn | AdapterReturn[]) => AdapterReturn, (text: string, key: string) => AdapterReturn, (children: AdapterReturn[], key: string) => AdapterReturn>[]>;
|
|
170
|
+
};
|
|
171
|
+
/** Fuction that converts an 'inlineItem' node into React **/
|
|
172
|
+
renderInlineRecord: {
|
|
173
|
+
type: PropType<(context: RenderInlineRecordContext) => AdapterReturn>;
|
|
174
|
+
};
|
|
175
|
+
/** Fuction that converts an 'itemLink' node into React **/
|
|
176
|
+
renderLinkToRecord: {
|
|
177
|
+
type: PropType<(context: RenderRecordLinkContext) => AdapterReturn>;
|
|
178
|
+
};
|
|
179
|
+
/** Fuction that converts a 'block' node into React **/
|
|
180
|
+
renderBlock: {
|
|
181
|
+
type: PropType<(context: RenderBlockContext) => AdapterReturn>;
|
|
182
|
+
};
|
|
183
|
+
/** Function that converts 'link' and 'itemLink' `meta` into HTML props */
|
|
184
|
+
metaTransformer: {
|
|
185
|
+
type: PropType<TransformMetaFn>;
|
|
186
|
+
};
|
|
187
|
+
/** Fuction that converts a simple string text into React **/
|
|
188
|
+
renderText: {
|
|
189
|
+
type: PropType<(text: string, key: string) => AdapterReturn>;
|
|
190
|
+
};
|
|
191
|
+
/** React.createElement-like function to use to convert a node into React **/
|
|
192
|
+
renderNode: {
|
|
193
|
+
type: PropType<(tagName: string, props?: VNodeProps, childOrChildren?: AdapterReturn | AdapterReturn[]) => AdapterReturn>;
|
|
194
|
+
};
|
|
195
|
+
/** Function to use to generate a React.Fragment **/
|
|
196
|
+
renderFragment: {
|
|
197
|
+
type: PropType<(children: AdapterReturn[], key: string) => AdapterReturn>;
|
|
198
|
+
};
|
|
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<{
|
|
124
200
|
/** The actual field value you get from DatoCMS **/
|
|
125
201
|
data: {
|
|
126
|
-
type: PropType<StructuredText$1<Record$1> | Document | Node | null | undefined>;
|
|
202
|
+
type: PropType<StructuredText$1<Record$1, Record$1> | Document | Node | null | undefined>;
|
|
127
203
|
};
|
|
128
204
|
/** @deprecated use customNodeRules **/
|
|
129
205
|
customRules: {
|
|
130
|
-
type: PropType<RenderRule<(tagName: string, props?: VNodeProps
|
|
206
|
+
type: PropType<RenderRule<(tagName: string, props?: VNodeProps, childOrChildren?: AdapterReturn | AdapterReturn[]) => AdapterReturn, (text: string, key: string) => AdapterReturn, (children: AdapterReturn[], key: string) => AdapterReturn>[]>;
|
|
131
207
|
};
|
|
132
208
|
/** A set of additional rules to convert the document to JSX **/
|
|
133
209
|
customNodeRules: {
|
|
134
|
-
type: PropType<RenderRule<(tagName: string, props?: VNodeProps
|
|
210
|
+
type: PropType<RenderRule<(tagName: string, props?: VNodeProps, childOrChildren?: AdapterReturn | AdapterReturn[]) => AdapterReturn, (text: string, key: string) => AdapterReturn, (children: AdapterReturn[], key: string) => AdapterReturn>[]>;
|
|
135
211
|
};
|
|
136
212
|
/** A set of additional rules to convert the document to JSX **/
|
|
137
213
|
customMarkRules: {
|
|
138
|
-
type: PropType<RenderMarkRule<(tagName: string, props?: VNodeProps
|
|
214
|
+
type: PropType<RenderMarkRule<(tagName: string, props?: VNodeProps, childOrChildren?: AdapterReturn | AdapterReturn[]) => AdapterReturn, (text: string, key: string) => AdapterReturn, (children: AdapterReturn[], key: string) => AdapterReturn>[]>;
|
|
139
215
|
};
|
|
140
216
|
/** Fuction that converts an 'inlineItem' node into React **/
|
|
141
217
|
renderInlineRecord: {
|
|
@@ -159,25 +235,13 @@ declare const StructuredText: vue_demi.DefineComponent<{
|
|
|
159
235
|
};
|
|
160
236
|
/** React.createElement-like function to use to convert a node into React **/
|
|
161
237
|
renderNode: {
|
|
162
|
-
type: PropType<(tagName: string, props?: VNodeProps
|
|
238
|
+
type: PropType<(tagName: string, props?: VNodeProps, childOrChildren?: AdapterReturn | AdapterReturn[]) => AdapterReturn>;
|
|
163
239
|
};
|
|
164
240
|
/** Function to use to generate a React.Fragment **/
|
|
165
241
|
renderFragment: {
|
|
166
242
|
type: PropType<(children: AdapterReturn[], key: string) => AdapterReturn>;
|
|
167
243
|
};
|
|
168
|
-
}
|
|
169
|
-
data?: StructuredText$1<Record$1> | Document | Node | null | undefined;
|
|
170
|
-
customRules?: RenderRule<(tagName: string, props?: VNodeProps | undefined, childOrChildren?: AdapterReturn | AdapterReturn[] | undefined) => AdapterReturn, (text: string, key: string) => AdapterReturn, (children: AdapterReturn[], key: string) => AdapterReturn>[] | undefined;
|
|
171
|
-
customNodeRules?: RenderRule<(tagName: string, props?: VNodeProps | undefined, childOrChildren?: AdapterReturn | AdapterReturn[] | undefined) => AdapterReturn, (text: string, key: string) => AdapterReturn, (children: AdapterReturn[], key: string) => AdapterReturn>[] | undefined;
|
|
172
|
-
customMarkRules?: RenderMarkRule<(tagName: string, props?: VNodeProps | undefined, childOrChildren?: AdapterReturn | AdapterReturn[] | undefined) => AdapterReturn, (text: string, key: string) => AdapterReturn, (children: AdapterReturn[], key: string) => AdapterReturn>[] | undefined;
|
|
173
|
-
renderInlineRecord?: ((context: RenderInlineRecordContext) => AdapterReturn) | undefined;
|
|
174
|
-
renderLinkToRecord?: ((context: RenderRecordLinkContext) => AdapterReturn) | undefined;
|
|
175
|
-
renderBlock?: ((context: RenderBlockContext) => AdapterReturn) | undefined;
|
|
176
|
-
metaTransformer?: TransformMetaFn | undefined;
|
|
177
|
-
renderText?: ((text: string, key: string) => AdapterReturn) | undefined;
|
|
178
|
-
renderNode?: ((tagName: string, props?: VNodeProps | undefined, childOrChildren?: AdapterReturn | AdapterReturn[] | undefined) => AdapterReturn) | undefined;
|
|
179
|
-
renderFragment?: ((children: AdapterReturn[], key: string) => AdapterReturn) | undefined;
|
|
180
|
-
}>, {}>;
|
|
244
|
+
}>>, {}>;
|
|
181
245
|
declare const DatocmsStructuredTextPlugin: {
|
|
182
246
|
install: (Vue: any) => void;
|
|
183
247
|
};
|
package/dist/index.esm.js
CHANGED
|
@@ -1,68 +1,29 @@
|
|
|
1
1
|
import hypenateStyleName from 'hyphenate-style-name';
|
|
2
|
-
import {
|
|
2
|
+
import { defineComponent, ref, h, onMounted, onBeforeUnmount, isVNode, cloneVNode } from 'vue';
|
|
3
3
|
import { render, renderNodeRule, defaultMetaTransformer } 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 { isRoot, isInlineItem, RenderError, isStructuredText, isItemLink, isBlock } from 'datocms-structured-text-utils';
|
|
6
6
|
export { RenderError } from 'datocms-structured-text-utils';
|
|
7
7
|
|
|
8
|
-
var __defProp$2 = Object.defineProperty;
|
|
9
|
-
var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
|
|
10
|
-
var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
|
|
11
|
-
var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
|
|
12
|
-
var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, {enumerable: true, configurable: true, writable: true, value}) : obj[key] = value;
|
|
13
|
-
var __objSpread$2 = (a, b) => {
|
|
14
|
-
for (var prop in b || (b = {}))
|
|
15
|
-
if (__hasOwnProp$3.call(b, prop))
|
|
16
|
-
__defNormalProp$2(a, prop, b[prop]);
|
|
17
|
-
if (__getOwnPropSymbols$3)
|
|
18
|
-
for (var prop of __getOwnPropSymbols$3(b)) {
|
|
19
|
-
if (__propIsEnum$3.call(b, prop))
|
|
20
|
-
__defNormalProp$2(a, prop, b[prop]);
|
|
21
|
-
}
|
|
22
|
-
return a;
|
|
23
|
-
};
|
|
24
|
-
var __objRest$1 = (source, exclude) => {
|
|
25
|
-
var target = {};
|
|
26
|
-
for (var prop in source)
|
|
27
|
-
if (__hasOwnProp$3.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
28
|
-
target[prop] = source[prop];
|
|
29
|
-
if (source != null && __getOwnPropSymbols$3)
|
|
30
|
-
for (var prop of __getOwnPropSymbols$3(source)) {
|
|
31
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum$3.call(source, prop))
|
|
32
|
-
target[prop] = source[prop];
|
|
33
|
-
}
|
|
34
|
-
return target;
|
|
35
|
-
};
|
|
36
|
-
function crossH(tag, data, ...rest) {
|
|
37
|
-
if (isVue3) {
|
|
38
|
-
let vue3Data = null;
|
|
39
|
-
if (data) {
|
|
40
|
-
const _a = data, {domProps, attrs, props, on} = _a, other = __objRest$1(_a, ["domProps", "attrs", "props", "on"]);
|
|
41
|
-
vue3Data = __objSpread$2(__objSpread$2(__objSpread$2(__objSpread$2(__objSpread$2({}, other), attrs), props), domProps), Object.entries(on || {}).reduce((acc, [key, value]) => __objSpread$2(__objSpread$2({}, acc), {
|
|
42
|
-
[`on${key.charAt(0).toUpperCase() + key.slice(1)}`]: value
|
|
43
|
-
}), {}));
|
|
44
|
-
}
|
|
45
|
-
return h(tag, vue3Data, ...rest);
|
|
46
|
-
}
|
|
47
|
-
return h(tag, data, ...rest);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
8
|
var __defProp$1 = Object.defineProperty;
|
|
51
|
-
var
|
|
52
|
-
var
|
|
53
|
-
var
|
|
54
|
-
var
|
|
55
|
-
var
|
|
9
|
+
var __defProps$1 = Object.defineProperties;
|
|
10
|
+
var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
|
|
11
|
+
var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
|
|
12
|
+
var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
|
|
13
|
+
var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
|
|
14
|
+
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
15
|
+
var __spreadValues$1 = (a, b) => {
|
|
56
16
|
for (var prop in b || (b = {}))
|
|
57
|
-
if (__hasOwnProp$
|
|
17
|
+
if (__hasOwnProp$1.call(b, prop))
|
|
58
18
|
__defNormalProp$1(a, prop, b[prop]);
|
|
59
|
-
if (__getOwnPropSymbols$
|
|
60
|
-
for (var prop of __getOwnPropSymbols$
|
|
61
|
-
if (__propIsEnum$
|
|
19
|
+
if (__getOwnPropSymbols$1)
|
|
20
|
+
for (var prop of __getOwnPropSymbols$1(b)) {
|
|
21
|
+
if (__propIsEnum$1.call(b, prop))
|
|
62
22
|
__defNormalProp$1(a, prop, b[prop]);
|
|
63
23
|
}
|
|
64
24
|
return a;
|
|
65
25
|
};
|
|
26
|
+
var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
|
|
66
27
|
const escape = (s) => {
|
|
67
28
|
s = "" + s;
|
|
68
29
|
s = s.replace(/&/g, "&");
|
|
@@ -99,9 +60,11 @@ const tag = (tagName, attrs, content) => {
|
|
|
99
60
|
const attrsString = serializedAttrs.length > 0 ? ` ${serializedAttrs.join(" ")}` : "";
|
|
100
61
|
return content ? `<${tagName}${attrsString}>${content.join("")}</${tagName}>` : `<${tagName}${attrsString} />`;
|
|
101
62
|
};
|
|
102
|
-
const isSsr = typeof window === "undefined";
|
|
103
|
-
const isIntersectionObserverAvailable =
|
|
104
|
-
|
|
63
|
+
const isSsr = () => typeof window === "undefined";
|
|
64
|
+
const isIntersectionObserverAvailable = () => {
|
|
65
|
+
return isSsr() ? false : !!window.IntersectionObserver;
|
|
66
|
+
};
|
|
67
|
+
const universalBtoa = (str) => isSsr() ? Buffer.from(str.toString(), "binary").toString("base64") : window.btoa(str);
|
|
105
68
|
const absolutePositioning = {
|
|
106
69
|
position: "absolute",
|
|
107
70
|
left: "0px",
|
|
@@ -109,12 +72,12 @@ const absolutePositioning = {
|
|
|
109
72
|
width: "100%",
|
|
110
73
|
height: "100%"
|
|
111
74
|
};
|
|
112
|
-
const useInView = ({threshold, rootMargin}) => {
|
|
75
|
+
const useInView = ({ threshold, rootMargin }) => {
|
|
113
76
|
const observer = ref(null);
|
|
114
77
|
const elRef = ref(null);
|
|
115
78
|
const inView = ref(false);
|
|
116
79
|
onMounted(() => {
|
|
117
|
-
if (isIntersectionObserverAvailable) {
|
|
80
|
+
if (isIntersectionObserverAvailable()) {
|
|
118
81
|
observer.value = new IntersectionObserver((entries) => {
|
|
119
82
|
const image = entries[0];
|
|
120
83
|
if (image.isIntersecting && observer.value) {
|
|
@@ -131,32 +94,32 @@ const useInView = ({threshold, rootMargin}) => {
|
|
|
131
94
|
}
|
|
132
95
|
});
|
|
133
96
|
onBeforeUnmount(() => {
|
|
134
|
-
if (isIntersectionObserverAvailable && observer.value) {
|
|
97
|
+
if (isIntersectionObserverAvailable() && observer.value) {
|
|
135
98
|
observer.value.disconnect();
|
|
136
99
|
}
|
|
137
100
|
});
|
|
138
|
-
return {inView, elRef};
|
|
101
|
+
return { inView, elRef };
|
|
139
102
|
};
|
|
140
|
-
const imageAddStrategy = ({lazyLoad, inView, loaded}) => {
|
|
103
|
+
const imageAddStrategy = ({ lazyLoad, inView, loaded }) => {
|
|
141
104
|
if (!lazyLoad) {
|
|
142
105
|
return true;
|
|
143
106
|
}
|
|
144
|
-
if (isSsr) {
|
|
107
|
+
if (isSsr()) {
|
|
145
108
|
return false;
|
|
146
109
|
}
|
|
147
|
-
if (isIntersectionObserverAvailable) {
|
|
110
|
+
if (isIntersectionObserverAvailable()) {
|
|
148
111
|
return inView || loaded;
|
|
149
112
|
}
|
|
150
113
|
return true;
|
|
151
114
|
};
|
|
152
|
-
const imageShowStrategy = ({lazyLoad, loaded}) => {
|
|
115
|
+
const imageShowStrategy = ({ lazyLoad, loaded }) => {
|
|
153
116
|
if (!lazyLoad) {
|
|
154
117
|
return true;
|
|
155
118
|
}
|
|
156
|
-
if (isSsr) {
|
|
119
|
+
if (isSsr()) {
|
|
157
120
|
return false;
|
|
158
121
|
}
|
|
159
|
-
if (isIntersectionObserverAvailable) {
|
|
122
|
+
if (isIntersectionObserverAvailable()) {
|
|
160
123
|
return loaded;
|
|
161
124
|
}
|
|
162
125
|
return true;
|
|
@@ -202,7 +165,7 @@ const Image = defineComponent({
|
|
|
202
165
|
function handleLoad() {
|
|
203
166
|
loaded.value = true;
|
|
204
167
|
}
|
|
205
|
-
const {inView, elRef} = useInView({
|
|
168
|
+
const { inView, elRef } = useInView({
|
|
206
169
|
threshold: props.intersectionThreshold || props.intersectionTreshold || 0,
|
|
207
170
|
rootMargin: props.intersectionMargin || "0px 0px 0px 0px"
|
|
208
171
|
});
|
|
@@ -224,22 +187,18 @@ const Image = defineComponent({
|
|
|
224
187
|
inView: this.inView,
|
|
225
188
|
loaded: this.loaded
|
|
226
189
|
});
|
|
227
|
-
const webpSource = this.data.webpSrcSet &&
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
type: "image/webp"
|
|
232
|
-
}
|
|
190
|
+
const webpSource = this.data.webpSrcSet && h("source", {
|
|
191
|
+
srcset: this.data.webpSrcSet,
|
|
192
|
+
sizes: this.data.sizes,
|
|
193
|
+
type: "image/webp"
|
|
233
194
|
});
|
|
234
|
-
const regularSource = this.data.srcSet &&
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
sizes: this.data.sizes
|
|
238
|
-
}
|
|
195
|
+
const regularSource = this.data.srcSet && h("source", {
|
|
196
|
+
srcset: this.data.srcSet,
|
|
197
|
+
sizes: this.data.sizes
|
|
239
198
|
});
|
|
240
199
|
const transition = typeof this.fadeInDuration === "undefined" || this.fadeInDuration > 0 ? `opacity ${this.fadeInDuration || 500}ms ${this.fadeInDuration || 500}ms` : void 0;
|
|
241
|
-
const placeholder =
|
|
242
|
-
style:
|
|
200
|
+
const placeholder = h("div", {
|
|
201
|
+
style: __spreadValues$1({
|
|
243
202
|
backgroundImage: this.data.base64 ? `url(${this.data.base64})` : null,
|
|
244
203
|
backgroundColor: this.data.bgColor,
|
|
245
204
|
backgroundSize: "cover",
|
|
@@ -247,21 +206,19 @@ const Image = defineComponent({
|
|
|
247
206
|
transition
|
|
248
207
|
}, absolutePositioning)
|
|
249
208
|
});
|
|
250
|
-
const {width, aspectRatio} = this.data;
|
|
209
|
+
const { width, aspectRatio } = this.data;
|
|
251
210
|
const height = this.data.height || width / aspectRatio;
|
|
252
211
|
const svg = `<svg xmlns="http://www.w3.org/2000/svg" width="${width}" height="${height}"></svg>`;
|
|
253
|
-
const sizer =
|
|
212
|
+
const sizer = h("img", {
|
|
254
213
|
class: this.pictureClass,
|
|
255
|
-
style:
|
|
214
|
+
style: __spreadValues$1({
|
|
256
215
|
display: "block",
|
|
257
216
|
width: this.explicitWidth ? `${width}px` : "100%"
|
|
258
217
|
}, this.pictureStyle),
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
role: "presentation"
|
|
262
|
-
}
|
|
218
|
+
src: `data:image/svg+xml;base64,${universalBtoa(svg)}`,
|
|
219
|
+
role: "presentation"
|
|
263
220
|
});
|
|
264
|
-
return
|
|
221
|
+
return h("div", {
|
|
265
222
|
style: {
|
|
266
223
|
display: this.explicitWidth ? "inline-block" : "block",
|
|
267
224
|
overflow: "hidden",
|
|
@@ -271,47 +228,41 @@ const Image = defineComponent({
|
|
|
271
228
|
}, [
|
|
272
229
|
sizer,
|
|
273
230
|
placeholder,
|
|
274
|
-
addImage &&
|
|
231
|
+
addImage && h("picture", null, [
|
|
275
232
|
webpSource,
|
|
276
233
|
regularSource,
|
|
277
|
-
this.data.src &&
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
},
|
|
283
|
-
on: {
|
|
284
|
-
load: this.handleLoad
|
|
285
|
-
},
|
|
234
|
+
this.data.src && h("img", {
|
|
235
|
+
src: this.data.src,
|
|
236
|
+
alt: this.data.alt,
|
|
237
|
+
title: this.data.title,
|
|
238
|
+
onLoad: this.handleLoad,
|
|
286
239
|
class: this.pictureClass,
|
|
287
|
-
style:
|
|
240
|
+
style: __spreadProps$1(__spreadValues$1(__spreadValues$1({}, absolutePositioning), this.pictureStyle), {
|
|
288
241
|
opacity: showImage ? 1 : 0,
|
|
289
242
|
transition
|
|
290
243
|
})
|
|
291
244
|
})
|
|
292
245
|
]),
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
this.data.webpSrcSet
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
this.data.srcSet
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
])
|
|
314
|
-
}
|
|
246
|
+
h("noscript", {
|
|
247
|
+
innerHTML: tag("picture", {}, [
|
|
248
|
+
this.data.webpSrcSet && tag("source", {
|
|
249
|
+
srcset: this.data.webpSrcSet,
|
|
250
|
+
sizes: this.data.sizes,
|
|
251
|
+
type: "image/webp"
|
|
252
|
+
}),
|
|
253
|
+
this.data.srcSet && tag("source", {
|
|
254
|
+
srcset: this.data.srcSet,
|
|
255
|
+
sizes: this.data.sizes
|
|
256
|
+
}),
|
|
257
|
+
tag("img", {
|
|
258
|
+
src: this.data.src,
|
|
259
|
+
alt: this.data.alt,
|
|
260
|
+
title: this.data.title,
|
|
261
|
+
class: this.pictureClass,
|
|
262
|
+
style: toCss(__spreadValues$1(__spreadValues$1({}, this.pictureStyle), absolutePositioning)),
|
|
263
|
+
loading: "lazy"
|
|
264
|
+
})
|
|
265
|
+
])
|
|
315
266
|
})
|
|
316
267
|
]);
|
|
317
268
|
}
|
|
@@ -322,28 +273,8 @@ const DatocmsImagePlugin = {
|
|
|
322
273
|
}
|
|
323
274
|
};
|
|
324
275
|
|
|
325
|
-
var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
|
|
326
|
-
var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
|
|
327
|
-
var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
|
|
328
|
-
var __objRest = (source, exclude) => {
|
|
329
|
-
var target = {};
|
|
330
|
-
for (var prop in source)
|
|
331
|
-
if (__hasOwnProp$1.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
332
|
-
target[prop] = source[prop];
|
|
333
|
-
if (source != null && __getOwnPropSymbols$1)
|
|
334
|
-
for (var prop of __getOwnPropSymbols$1(source)) {
|
|
335
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum$1.call(source, prop))
|
|
336
|
-
target[prop] = source[prop];
|
|
337
|
-
}
|
|
338
|
-
return target;
|
|
339
|
-
};
|
|
340
276
|
const hAdapter = (tagName, props, childOrChildren) => {
|
|
341
|
-
|
|
342
|
-
if (props) {
|
|
343
|
-
const _a = props, {key} = _a, attrs = __objRest(_a, ["key"]);
|
|
344
|
-
data = {key, attrs};
|
|
345
|
-
}
|
|
346
|
-
return crossH(tagName, data, Array.isArray(childOrChildren) ? childOrChildren : [childOrChildren]);
|
|
277
|
+
return h(tagName, props, Array.isArray(childOrChildren) ? childOrChildren : [childOrChildren]);
|
|
347
278
|
};
|
|
348
279
|
const defaultAdapter = {
|
|
349
280
|
renderNode: hAdapter,
|
|
@@ -352,14 +283,8 @@ const defaultAdapter = {
|
|
|
352
283
|
renderText: (text, key) => text
|
|
353
284
|
};
|
|
354
285
|
function appendKeyToValidElement(element, key) {
|
|
355
|
-
if (
|
|
356
|
-
|
|
357
|
-
if (isVNode(element) && element.key === null) {
|
|
358
|
-
return cloneVNode(element, {key});
|
|
359
|
-
}
|
|
360
|
-
} else if (element && typeof element === "object" && (element.key === null || element.key === void 0)) {
|
|
361
|
-
element.key = key;
|
|
362
|
-
return element;
|
|
286
|
+
if (isVNode(element) && element.key === null) {
|
|
287
|
+
return cloneVNode(element, { key });
|
|
363
288
|
}
|
|
364
289
|
return element;
|
|
365
290
|
}
|
|
@@ -387,10 +312,10 @@ const StructuredText = defineComponent({
|
|
|
387
312
|
renderBlock: {
|
|
388
313
|
type: Function
|
|
389
314
|
},
|
|
390
|
-
metaTransformer: {type: Function},
|
|
391
|
-
renderText: {type: Function},
|
|
392
|
-
renderNode: {type: Function},
|
|
393
|
-
renderFragment: {type: Function}
|
|
315
|
+
metaTransformer: { type: Function },
|
|
316
|
+
renderText: { type: Function },
|
|
317
|
+
renderNode: { type: Function },
|
|
318
|
+
renderFragment: { type: Function }
|
|
394
319
|
},
|
|
395
320
|
setup(props) {
|
|
396
321
|
return () => {
|
|
@@ -403,10 +328,10 @@ const StructuredText = defineComponent({
|
|
|
403
328
|
metaTransformer: props.metaTransformer,
|
|
404
329
|
customMarkRules: props.customMarkRules,
|
|
405
330
|
customNodeRules: [
|
|
406
|
-
renderNodeRule(isRoot, ({adapter: {renderNode}, key, children}) => {
|
|
407
|
-
return renderNode("div", {key}, children);
|
|
331
|
+
renderNodeRule(isRoot, ({ adapter: { renderNode }, key, children }) => {
|
|
332
|
+
return renderNode("div", { key }, children);
|
|
408
333
|
}),
|
|
409
|
-
renderNodeRule(isInlineItem, ({node, key}) => {
|
|
334
|
+
renderNodeRule(isInlineItem, ({ node, key }) => {
|
|
410
335
|
if (!props.renderInlineRecord) {
|
|
411
336
|
throw new RenderError(`The Structured Text document contains an 'inlineItem' node, but no 'renderInlineRecord' prop is specified!`, node);
|
|
412
337
|
}
|
|
@@ -417,9 +342,9 @@ const StructuredText = defineComponent({
|
|
|
417
342
|
if (!item) {
|
|
418
343
|
throw new RenderError(`The Structured Text document contains an 'inlineItem' node, but cannot find a record with ID ${node.item} inside .links!`, node);
|
|
419
344
|
}
|
|
420
|
-
return appendKeyToValidElement(props.renderInlineRecord({record: item}), key);
|
|
345
|
+
return appendKeyToValidElement(props.renderInlineRecord({ record: item }), key);
|
|
421
346
|
}),
|
|
422
|
-
renderNodeRule(isItemLink, ({node, key, children}) => {
|
|
347
|
+
renderNodeRule(isItemLink, ({ node, key, children }) => {
|
|
423
348
|
if (!props.renderLinkToRecord) {
|
|
424
349
|
throw new RenderError(`The Structured Text document contains an 'itemLink' node, but no 'renderLinkToRecord' prop is specified!`, node);
|
|
425
350
|
}
|
|
@@ -439,7 +364,7 @@ const StructuredText = defineComponent({
|
|
|
439
364
|
}) : null
|
|
440
365
|
}), key);
|
|
441
366
|
}),
|
|
442
|
-
renderNodeRule(isBlock, ({node, key}) => {
|
|
367
|
+
renderNodeRule(isBlock, ({ node, key }) => {
|
|
443
368
|
if (!props.renderBlock) {
|
|
444
369
|
throw new RenderError(`The Structured Text document contains a 'block' node, but no 'renderBlock' prop is specified!`, node);
|
|
445
370
|
}
|
|
@@ -450,7 +375,7 @@ const StructuredText = defineComponent({
|
|
|
450
375
|
if (!item) {
|
|
451
376
|
throw new RenderError(`The Structured Text document contains a 'block' node, but cannot find a record with ID ${node.item} inside .blocks!`, node);
|
|
452
377
|
}
|
|
453
|
-
return appendKeyToValidElement(props.renderBlock({record: item}), key);
|
|
378
|
+
return appendKeyToValidElement(props.renderBlock({ record: item }), key);
|
|
454
379
|
}),
|
|
455
380
|
...props.customNodeRules || props.customRules || []
|
|
456
381
|
]
|
|
@@ -465,11 +390,13 @@ const DatocmsStructuredTextPlugin = {
|
|
|
465
390
|
};
|
|
466
391
|
|
|
467
392
|
var __defProp = Object.defineProperty;
|
|
468
|
-
var
|
|
393
|
+
var __defProps = Object.defineProperties;
|
|
394
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
469
395
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
396
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
470
397
|
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
471
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {enumerable: true, configurable: true, writable: true, value}) : obj[key] = value;
|
|
472
|
-
var
|
|
398
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
399
|
+
var __spreadValues = (a, b) => {
|
|
473
400
|
for (var prop in b || (b = {}))
|
|
474
401
|
if (__hasOwnProp.call(b, prop))
|
|
475
402
|
__defNormalProp(a, prop, b[prop]);
|
|
@@ -480,6 +407,7 @@ var __objSpread = (a, b) => {
|
|
|
480
407
|
}
|
|
481
408
|
return a;
|
|
482
409
|
};
|
|
410
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
483
411
|
const toHead = (...args) => {
|
|
484
412
|
const tags = [].concat(...args);
|
|
485
413
|
const titleTag = tags && tags.find((t) => t.tag === "title");
|
|
@@ -489,14 +417,14 @@ const toHead = (...args) => {
|
|
|
489
417
|
title: titleTag && titleTag.content,
|
|
490
418
|
meta: metaTags.map((tag) => {
|
|
491
419
|
var _a, _b, _c, _d;
|
|
492
|
-
return
|
|
420
|
+
return __spreadProps(__spreadValues({}, tag.attributes), {
|
|
493
421
|
hid: ((_a = tag.attributes) == null ? void 0 : _a.name) || ((_b = tag.attributes) == null ? void 0 : _b.property),
|
|
494
422
|
vmid: ((_c = tag.attributes) == null ? void 0 : _c.name) || ((_d = tag.attributes) == null ? void 0 : _d.property)
|
|
495
423
|
});
|
|
496
424
|
}),
|
|
497
425
|
link: linkTags.map((tag) => {
|
|
498
426
|
var _a, _b, _c, _d, _e, _f;
|
|
499
|
-
return
|
|
427
|
+
return __spreadProps(__spreadValues({}, tag.attributes), {
|
|
500
428
|
hid: ((_a = tag.attributes) == null ? void 0 : _a.name) || `${(_b = tag.attributes) == null ? void 0 : _b.rel}-${(_c = tag.attributes) == null ? void 0 : _c.sizes}`,
|
|
501
429
|
vmid: ((_d = tag.attributes) == null ? void 0 : _d.name) || `${(_e = tag.attributes) == null ? void 0 : _e.rel}-${(_f = tag.attributes) == null ? void 0 : _f.sizes}`
|
|
502
430
|
});
|