druxt 0.16.0 → 0.18.1
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/components/DruxtDebug.stories.mjs +48 -0
- package/dist/components/DruxtDebug.vue +7 -2
- package/dist/components/DruxtModule.stories.mdx +126 -0
- package/dist/components/DruxtModule.vue +29 -6
- package/dist/druxt.esm.js +36 -13
- package/dist/druxt.ssr.js +36 -13
- package/package.json +7 -2
- package/stories/README.stories.mdx +74 -0
- package/templates/plugin.js +10 -1
- package/CHANGELOG.md +0 -375
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import DruxtDebug from './DruxtDebug.vue'
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
title: 'Druxt/DruxtDebug',
|
|
5
|
+
component: DruxtDebug
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
const Template = (args) => ({
|
|
9
|
+
components: { DruxtDebug },
|
|
10
|
+
props: Object.keys(args),
|
|
11
|
+
template: `<DruxtDebug v-bind="$props">Debug information.</DruxtDebug>`
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
export const Default = Template.bind({})
|
|
15
|
+
Default.storyName = 'Default slot'
|
|
16
|
+
|
|
17
|
+
export const Json = Template.bind({})
|
|
18
|
+
Json.args = {
|
|
19
|
+
json: {
|
|
20
|
+
type: '',
|
|
21
|
+
id: '',
|
|
22
|
+
links: {},
|
|
23
|
+
attributes: {},
|
|
24
|
+
relationships: {},
|
|
25
|
+
},
|
|
26
|
+
open: true,
|
|
27
|
+
}
|
|
28
|
+
Json.parameters = {
|
|
29
|
+
docs: {
|
|
30
|
+
storyDescription: 'The **json** prop takes any data and runs it through a basic JSON formatter for improved readability.',
|
|
31
|
+
source: {
|
|
32
|
+
code: '<DruxtDebug :json="entity" open>Debug information</DruxtDebug>'
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export const Summary = Template.bind({})
|
|
38
|
+
Summary.args = {
|
|
39
|
+
summary: 'A brief debug message'
|
|
40
|
+
}
|
|
41
|
+
Summary.parameters = {
|
|
42
|
+
docs: {
|
|
43
|
+
storyDescription: 'The **summary** prop can be used to provide a quick explanation of the debug component.',
|
|
44
|
+
source: {
|
|
45
|
+
code: `<DruxtDebug summary="${Summary.args.sumary}">Debug information</DruxtDebug>`
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
}
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
<pre v-if="json"><!--
|
|
5
5
|
--><code>{{ JSON.stringify(json, null, ' ') }}</code><!--
|
|
6
6
|
--></pre>
|
|
7
|
+
<!-- @slot Debug content -->
|
|
7
8
|
<slot />
|
|
8
9
|
</details>
|
|
9
10
|
|
|
@@ -13,10 +14,14 @@
|
|
|
13
14
|
<script>
|
|
14
15
|
|
|
15
16
|
/**
|
|
16
|
-
*
|
|
17
|
+
* The DruxtDebug component can be used to render debug information that is
|
|
18
|
+
* visible only when Nuxt is run in development mode.
|
|
19
|
+
*
|
|
20
|
+
* You can render your debug information through the default slot, or via the
|
|
21
|
+
* **json** prop to format your data, or a combination of the two.
|
|
17
22
|
*
|
|
18
23
|
* @example @lang vue
|
|
19
|
-
* <DruxtDebug :json="entity"
|
|
24
|
+
* <DruxtDebug :json="entity">Debug information</DruxtDebug>
|
|
20
25
|
*/
|
|
21
26
|
export default {
|
|
22
27
|
/** */
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { Canvas, Meta, Story } from '@storybook/addon-docs'
|
|
2
|
+
|
|
3
|
+
<Meta title="Druxt/DruxtModule" />
|
|
4
|
+
|
|
5
|
+
# DruxtModule
|
|
6
|
+
|
|
7
|
+
The DruxtModule component is the core component to be extended by core and
|
|
8
|
+
custom modules.
|
|
9
|
+
|
|
10
|
+
```js
|
|
11
|
+
import DruxtModule from 'druxt/dist/components/DruxtModule.vue'
|
|
12
|
+
export default {
|
|
13
|
+
extends: DruxtModule
|
|
14
|
+
}
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## Fetch config
|
|
20
|
+
|
|
21
|
+
All modules have a two part fetch system available to them; **fetchConfig** and
|
|
22
|
+
**fetchData**.
|
|
23
|
+
|
|
24
|
+
```js
|
|
25
|
+
async fetchConfig() {
|
|
26
|
+
// Load configuration data here.
|
|
27
|
+
this.config = await this.getResource({...})
|
|
28
|
+
},
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Fetch config is used to load information from Drupal to determine the default
|
|
32
|
+
behaviour of that component, as well as to determine the available component
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## Component options
|
|
37
|
+
|
|
38
|
+
The Druxt Wrapper system looks for available Vue components using a specific
|
|
39
|
+
naming convention, determined by the Druxt module **componentOptions**.
|
|
40
|
+
|
|
41
|
+
This allows for targetted theming of components based on the props or
|
|
42
|
+
configuration data.
|
|
43
|
+
|
|
44
|
+
```js
|
|
45
|
+
componentOptions: (context) => ([[context.attributes.foo, 'default']]),
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## Fetch data
|
|
51
|
+
|
|
52
|
+
After the Component options are determined, the first available component is
|
|
53
|
+
determined, and any exported Druxt settings are loaded and used to fetch the
|
|
54
|
+
main module data.
|
|
55
|
+
|
|
56
|
+
```js
|
|
57
|
+
async fetchData(settings) {
|
|
58
|
+
// Load data using the settings determine based on the configuration data.
|
|
59
|
+
this.resource = await this.getResource({
|
|
60
|
+
type: this.config.attributes.foo,
|
|
61
|
+
id: this.id,
|
|
62
|
+
query: this.getQuery(settings)
|
|
63
|
+
})
|
|
64
|
+
},
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
## Props data
|
|
70
|
+
|
|
71
|
+
The **propsData** callback returns the props data for the render Wrapper
|
|
72
|
+
component, making props data available to the frontend developer.
|
|
73
|
+
|
|
74
|
+
```js
|
|
75
|
+
propsData: (context) => ({ foo: context.config.attributes.foo })
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
## Slots
|
|
81
|
+
|
|
82
|
+
The **slots** method builds the slots that are made available to the Wrapper
|
|
83
|
+
component. It is expected to return an object of scoped slot functions.
|
|
84
|
+
|
|
85
|
+
```
|
|
86
|
+
slots(h) {
|
|
87
|
+
return {
|
|
88
|
+
default: () => h('div', ['Hello world']),
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
---
|
|
94
|
+
|
|
95
|
+
### Custom module boilerplate
|
|
96
|
+
|
|
97
|
+
Paste this into a Vue component as a starting point for a custom or contrib
|
|
98
|
+
Druxt module.
|
|
99
|
+
|
|
100
|
+
```vue
|
|
101
|
+
<script>
|
|
102
|
+
import DruxtModule from 'druxt/dist/components/DruxtModule.vue'
|
|
103
|
+
export default {
|
|
104
|
+
name: 'MyModule',
|
|
105
|
+
extends: DruxtModule
|
|
106
|
+
druxt: {
|
|
107
|
+
async fetchConfig() {
|
|
108
|
+
// Load configuration data here.
|
|
109
|
+
},
|
|
110
|
+
async fetchData(settings) {
|
|
111
|
+
// Load data using the settings determine based on the configuration data.
|
|
112
|
+
},
|
|
113
|
+
// Build nested arrays of component options based on the context.
|
|
114
|
+
componentOptions: (context) => ([['default']]),
|
|
115
|
+
// Map props data from the context.
|
|
116
|
+
propsData: (context) => ({ ...context }),
|
|
117
|
+
// Build slots render arrays.
|
|
118
|
+
slots(h) {
|
|
119
|
+
return {
|
|
120
|
+
default: () => h('div', ['Hello world'])
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
</script>
|
|
126
|
+
```
|
|
@@ -6,7 +6,11 @@ import Vue from 'vue'
|
|
|
6
6
|
import DruxtWrapper from './DruxtWrapper.vue'
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
9
|
+
* The DruxtModule component is used to make a Druxt module, simply import and
|
|
10
|
+
* extend the component to get started.
|
|
11
|
+
*
|
|
12
|
+
* The component provides access to the Druxt Wrapper theming and fetch system
|
|
13
|
+
* via the druxt settings object.
|
|
10
14
|
*
|
|
11
15
|
* @example @lang js
|
|
12
16
|
* import DruxtModule from 'druxt/dist/components/DruxtModule.vue'
|
|
@@ -14,11 +18,18 @@ import DruxtWrapper from './DruxtWrapper.vue'
|
|
|
14
18
|
* name: 'DruxtTestModule',
|
|
15
19
|
* extends: DruxtModule,
|
|
16
20
|
* druxt: {
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
+
* async fetchConfig() {},
|
|
22
|
+
* async fetchData(settings) {},
|
|
23
|
+
* componentOptions: (context) => ([[context.foo, context.bar, 'default']]),
|
|
24
|
+
* propsData: (context) => ({
|
|
25
|
+
* foo: context.foo,
|
|
26
|
+
* bar: context.bar,
|
|
21
27
|
* }),
|
|
28
|
+
* slots(h) {
|
|
29
|
+
* return {
|
|
30
|
+
* default: (attrs) => h('DruxtDebug', ['Hello world'])
|
|
31
|
+
* }
|
|
32
|
+
* }
|
|
22
33
|
* }
|
|
23
34
|
* }
|
|
24
35
|
*/
|
|
@@ -226,7 +237,7 @@ export default {
|
|
|
226
237
|
let components = []
|
|
227
238
|
for (const set of options.filter(set => Array.isArray(set))) {
|
|
228
239
|
const variants = []
|
|
229
|
-
components = [...components, ...set.map(item => {
|
|
240
|
+
components = [...components, ...set.filter((o) => o).map(item => {
|
|
230
241
|
// Build array of name parts.
|
|
231
242
|
const parts = variants.length ? [...variants[0].parts] : []
|
|
232
243
|
parts.push(pascalCase(splitByCase(item)))
|
|
@@ -298,6 +309,18 @@ export default {
|
|
|
298
309
|
*/
|
|
299
310
|
getScopedSlots() {
|
|
300
311
|
const h = this.$createElement
|
|
312
|
+
|
|
313
|
+
// Get an array of unmet required props.
|
|
314
|
+
const required = Object.entries(this.$options.props)
|
|
315
|
+
.filter(([k, o]) => o.required && !this[k])
|
|
316
|
+
.map(([k]) => k)
|
|
317
|
+
// Return debug error if any missing props are found.
|
|
318
|
+
if (required.length) {
|
|
319
|
+
return {
|
|
320
|
+
default: () => h('DruxtDebug', { props: { summary: `Missing required props: ${required.join(', ')}.` } })
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
|
|
301
324
|
const scopedSlots = typeof (this.$options.druxt || {}).slots === 'function'
|
|
302
325
|
? this.$options.druxt.slots.call(this, h)
|
|
303
326
|
: {}
|
package/dist/druxt.esm.js
CHANGED
|
@@ -9,7 +9,7 @@ import Vue from 'vue';
|
|
|
9
9
|
import { DrupalJsonApiParams } from 'drupal-jsonapi-params';
|
|
10
10
|
|
|
11
11
|
var name = "druxt";
|
|
12
|
-
var version = "0.
|
|
12
|
+
var version = "0.18.1";
|
|
13
13
|
var description = "The Fully Decoupled Drupal Framework for Nuxt.js.";
|
|
14
14
|
var keywords = [
|
|
15
15
|
"cms",
|
|
@@ -43,11 +43,12 @@ var main = "dist/druxt.ssr.js";
|
|
|
43
43
|
var module = "dist/druxt.esm.js";
|
|
44
44
|
var files = [
|
|
45
45
|
"dist",
|
|
46
|
+
"stories",
|
|
46
47
|
"templates"
|
|
47
48
|
];
|
|
48
49
|
var dependencies = {
|
|
50
|
+
"@nuxtjs/axios": "^5.13.6",
|
|
49
51
|
"@nuxtjs/proxy": "^2.1.0",
|
|
50
|
-
axios: "^0.21.1",
|
|
51
52
|
chalk: "^4.1.2",
|
|
52
53
|
deepmerge: "^4.2.2",
|
|
53
54
|
"drupal-jsonapi-params": "^1.2.1",
|
|
@@ -55,7 +56,11 @@ var dependencies = {
|
|
|
55
56
|
querystring: "^0.2.0",
|
|
56
57
|
scule: "^0.2.0"
|
|
57
58
|
};
|
|
59
|
+
var devDependencies = {
|
|
60
|
+
"@storybook/addon-docs": "^6.4.13"
|
|
61
|
+
};
|
|
58
62
|
var peerDependencies = {
|
|
63
|
+
axios: "*",
|
|
59
64
|
consola: "*"
|
|
60
65
|
};
|
|
61
66
|
var optionalDependencies = {
|
|
@@ -80,6 +85,7 @@ var meta = {
|
|
|
80
85
|
module: module,
|
|
81
86
|
files: files,
|
|
82
87
|
dependencies: dependencies,
|
|
88
|
+
devDependencies: devDependencies,
|
|
83
89
|
peerDependencies: peerDependencies,
|
|
84
90
|
optionalDependencies: optionalDependencies,
|
|
85
91
|
publishConfig: publishConfig
|
|
@@ -119,6 +125,14 @@ const DruxtNuxtModule = function(moduleOptions = {}) {
|
|
|
119
125
|
}
|
|
120
126
|
this.addModule("@nuxtjs/proxy");
|
|
121
127
|
}
|
|
128
|
+
if (!options.axios) {
|
|
129
|
+
this.options.axios = {
|
|
130
|
+
baseURL: options.baseUrl,
|
|
131
|
+
proxy: !!(options.proxy || {}).api,
|
|
132
|
+
...this.options.axios
|
|
133
|
+
};
|
|
134
|
+
this.addModule("@nuxtjs/axios");
|
|
135
|
+
}
|
|
122
136
|
this.nuxt.hook("components:dirs", (dirs) => {
|
|
123
137
|
dirs.push({ path: join(__dirname, "components") });
|
|
124
138
|
});
|
|
@@ -130,10 +144,13 @@ const DruxtNuxtModule = function(moduleOptions = {}) {
|
|
|
130
144
|
const extendPlugins = this.options.extendPlugins;
|
|
131
145
|
this.options.extendPlugins = (plugins) => {
|
|
132
146
|
plugins = typeof extendPlugins === "function" ? extendPlugins(plugins) : plugins;
|
|
133
|
-
const
|
|
134
|
-
const
|
|
135
|
-
plugins.splice(
|
|
136
|
-
plugins.
|
|
147
|
+
const axiosIndex = plugins.findIndex(({ src }) => src === `${this.options.buildDir}/axios.js`);
|
|
148
|
+
const axiosPlugin = plugins[axiosIndex];
|
|
149
|
+
plugins.splice(axiosIndex, 1);
|
|
150
|
+
const druxtIndex = plugins.findIndex(({ src }) => src === `${this.options.buildDir}/druxt.js`);
|
|
151
|
+
const druxtPlugin = plugins[druxtIndex];
|
|
152
|
+
plugins.splice(druxtIndex, 1);
|
|
153
|
+
plugins = [axiosPlugin, druxtPlugin, ...plugins];
|
|
137
154
|
return plugins;
|
|
138
155
|
};
|
|
139
156
|
this.addPlugin({
|
|
@@ -145,6 +162,11 @@ const DruxtNuxtModule = function(moduleOptions = {}) {
|
|
|
145
162
|
this.options.components = (_a = this.options.components) != null ? _a : true;
|
|
146
163
|
this.options.cli.badgeMessages.push(`${chalk.blue.bold("Druxt")} @ v${meta.version}`);
|
|
147
164
|
this.options.cli.badgeMessages.push(`${chalk.bold("API:")} ${chalk.blue.underline(options.baseUrl + options.endpoint)}`);
|
|
165
|
+
this.nuxt.hook("storybook:config", async ({ stories }) => {
|
|
166
|
+
stories.push("druxt/stories/*.stories.mdx");
|
|
167
|
+
stories.push("druxt/dist/components/*.stories.mdx");
|
|
168
|
+
stories.push("druxt/dist/components/*.stories.mjs");
|
|
169
|
+
});
|
|
148
170
|
};
|
|
149
171
|
|
|
150
172
|
class DruxtClient {
|
|
@@ -155,14 +177,15 @@ class DruxtClient {
|
|
|
155
177
|
if (!baseUrl) {
|
|
156
178
|
throw new Error("The 'baseUrl' parameter is required.");
|
|
157
179
|
}
|
|
158
|
-
|
|
159
|
-
if (
|
|
160
|
-
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
|
|
180
|
+
this.axios = {};
|
|
181
|
+
if (typeof options.axios === "function") {
|
|
182
|
+
this.axios = options.axios;
|
|
183
|
+
} else {
|
|
184
|
+
this.axios = axios.create({
|
|
185
|
+
...options.axios || {},
|
|
186
|
+
baseURL: baseUrl
|
|
187
|
+
});
|
|
164
188
|
}
|
|
165
|
-
this.axios = axios.create(axiosSettings);
|
|
166
189
|
if (options.debug) {
|
|
167
190
|
const log = this.log;
|
|
168
191
|
this.axios.interceptors.request.use((config) => {
|
package/dist/druxt.ssr.js
CHANGED
|
@@ -22,7 +22,7 @@ const md5__default = /*#__PURE__*/_interopDefaultLegacy(md5);
|
|
|
22
22
|
const Vue__default = /*#__PURE__*/_interopDefaultLegacy(Vue);
|
|
23
23
|
|
|
24
24
|
var name = "druxt";
|
|
25
|
-
var version = "0.
|
|
25
|
+
var version = "0.18.1";
|
|
26
26
|
var description = "The Fully Decoupled Drupal Framework for Nuxt.js.";
|
|
27
27
|
var keywords = [
|
|
28
28
|
"cms",
|
|
@@ -56,11 +56,12 @@ var main = "dist/druxt.ssr.js";
|
|
|
56
56
|
var module$1 = "dist/druxt.esm.js";
|
|
57
57
|
var files = [
|
|
58
58
|
"dist",
|
|
59
|
+
"stories",
|
|
59
60
|
"templates"
|
|
60
61
|
];
|
|
61
62
|
var dependencies = {
|
|
63
|
+
"@nuxtjs/axios": "^5.13.6",
|
|
62
64
|
"@nuxtjs/proxy": "^2.1.0",
|
|
63
|
-
axios: "^0.21.1",
|
|
64
65
|
chalk: "^4.1.2",
|
|
65
66
|
deepmerge: "^4.2.2",
|
|
66
67
|
"drupal-jsonapi-params": "^1.2.1",
|
|
@@ -68,7 +69,11 @@ var dependencies = {
|
|
|
68
69
|
querystring: "^0.2.0",
|
|
69
70
|
scule: "^0.2.0"
|
|
70
71
|
};
|
|
72
|
+
var devDependencies = {
|
|
73
|
+
"@storybook/addon-docs": "^6.4.13"
|
|
74
|
+
};
|
|
71
75
|
var peerDependencies = {
|
|
76
|
+
axios: "*",
|
|
72
77
|
consola: "*"
|
|
73
78
|
};
|
|
74
79
|
var optionalDependencies = {
|
|
@@ -93,6 +98,7 @@ const meta = {
|
|
|
93
98
|
module: module$1,
|
|
94
99
|
files: files,
|
|
95
100
|
dependencies: dependencies,
|
|
101
|
+
devDependencies: devDependencies,
|
|
96
102
|
peerDependencies: peerDependencies,
|
|
97
103
|
optionalDependencies: optionalDependencies,
|
|
98
104
|
publishConfig: publishConfig
|
|
@@ -132,6 +138,14 @@ const DruxtNuxtModule = function(moduleOptions = {}) {
|
|
|
132
138
|
}
|
|
133
139
|
this.addModule("@nuxtjs/proxy");
|
|
134
140
|
}
|
|
141
|
+
if (!options.axios) {
|
|
142
|
+
this.options.axios = {
|
|
143
|
+
baseURL: options.baseUrl,
|
|
144
|
+
proxy: !!(options.proxy || {}).api,
|
|
145
|
+
...this.options.axios
|
|
146
|
+
};
|
|
147
|
+
this.addModule("@nuxtjs/axios");
|
|
148
|
+
}
|
|
135
149
|
this.nuxt.hook("components:dirs", (dirs) => {
|
|
136
150
|
dirs.push({ path: path.join(__dirname, "components") });
|
|
137
151
|
});
|
|
@@ -143,10 +157,13 @@ const DruxtNuxtModule = function(moduleOptions = {}) {
|
|
|
143
157
|
const extendPlugins = this.options.extendPlugins;
|
|
144
158
|
this.options.extendPlugins = (plugins) => {
|
|
145
159
|
plugins = typeof extendPlugins === "function" ? extendPlugins(plugins) : plugins;
|
|
146
|
-
const
|
|
147
|
-
const
|
|
148
|
-
plugins.splice(
|
|
149
|
-
plugins.
|
|
160
|
+
const axiosIndex = plugins.findIndex(({ src }) => src === `${this.options.buildDir}/axios.js`);
|
|
161
|
+
const axiosPlugin = plugins[axiosIndex];
|
|
162
|
+
plugins.splice(axiosIndex, 1);
|
|
163
|
+
const druxtIndex = plugins.findIndex(({ src }) => src === `${this.options.buildDir}/druxt.js`);
|
|
164
|
+
const druxtPlugin = plugins[druxtIndex];
|
|
165
|
+
plugins.splice(druxtIndex, 1);
|
|
166
|
+
plugins = [axiosPlugin, druxtPlugin, ...plugins];
|
|
150
167
|
return plugins;
|
|
151
168
|
};
|
|
152
169
|
this.addPlugin({
|
|
@@ -158,6 +175,11 @@ const DruxtNuxtModule = function(moduleOptions = {}) {
|
|
|
158
175
|
this.options.components = (_a = this.options.components) != null ? _a : true;
|
|
159
176
|
this.options.cli.badgeMessages.push(`${chalk__default['default'].blue.bold("Druxt")} @ v${meta.version}`);
|
|
160
177
|
this.options.cli.badgeMessages.push(`${chalk__default['default'].bold("API:")} ${chalk__default['default'].blue.underline(options.baseUrl + options.endpoint)}`);
|
|
178
|
+
this.nuxt.hook("storybook:config", async ({ stories }) => {
|
|
179
|
+
stories.push("druxt/stories/*.stories.mdx");
|
|
180
|
+
stories.push("druxt/dist/components/*.stories.mdx");
|
|
181
|
+
stories.push("druxt/dist/components/*.stories.mjs");
|
|
182
|
+
});
|
|
161
183
|
};
|
|
162
184
|
|
|
163
185
|
class DruxtClient {
|
|
@@ -168,14 +190,15 @@ class DruxtClient {
|
|
|
168
190
|
if (!baseUrl) {
|
|
169
191
|
throw new Error("The 'baseUrl' parameter is required.");
|
|
170
192
|
}
|
|
171
|
-
|
|
172
|
-
if (
|
|
173
|
-
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
|
|
193
|
+
this.axios = {};
|
|
194
|
+
if (typeof options.axios === "function") {
|
|
195
|
+
this.axios = options.axios;
|
|
196
|
+
} else {
|
|
197
|
+
this.axios = axios__default['default'].create({
|
|
198
|
+
...options.axios || {},
|
|
199
|
+
baseURL: baseUrl
|
|
200
|
+
});
|
|
177
201
|
}
|
|
178
|
-
this.axios = axios__default['default'].create(axiosSettings);
|
|
179
202
|
if (options.debug) {
|
|
180
203
|
const log = this.log;
|
|
181
204
|
this.axios.interceptors.request.use((config) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "druxt",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.1",
|
|
4
4
|
"description": "The Fully Decoupled Drupal Framework for Nuxt.js.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cms",
|
|
@@ -34,11 +34,12 @@
|
|
|
34
34
|
"module": "dist/druxt.esm.js",
|
|
35
35
|
"files": [
|
|
36
36
|
"dist",
|
|
37
|
+
"stories",
|
|
37
38
|
"templates"
|
|
38
39
|
],
|
|
39
40
|
"dependencies": {
|
|
41
|
+
"@nuxtjs/axios": "^5.13.6",
|
|
40
42
|
"@nuxtjs/proxy": "^2.1.0",
|
|
41
|
-
"axios": "^0.21.1",
|
|
42
43
|
"chalk": "^4.1.2",
|
|
43
44
|
"deepmerge": "^4.2.2",
|
|
44
45
|
"drupal-jsonapi-params": "^1.2.1",
|
|
@@ -46,7 +47,11 @@
|
|
|
46
47
|
"querystring": "^0.2.0",
|
|
47
48
|
"scule": "^0.2.0"
|
|
48
49
|
},
|
|
50
|
+
"devDependencies": {
|
|
51
|
+
"@storybook/addon-docs": "^6.4.13"
|
|
52
|
+
},
|
|
49
53
|
"peerDependencies": {
|
|
54
|
+
"axios": "*",
|
|
50
55
|
"consola": "*"
|
|
51
56
|
},
|
|
52
57
|
"optionalDependencies": {
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { Meta } from '@storybook/addon-docs'
|
|
2
|
+
|
|
3
|
+
<Meta title="Druxt/README" />
|
|
4
|
+
|
|
5
|
+
# Druxt Storybook
|
|
6
|
+
|
|
7
|
+
> Druxt + @nuxtjs/Storybook
|
|
8
|
+
|
|
9
|
+
The following documentation and stories are provided by
|
|
10
|
+
[DruxtJS](https://druxtjs.org) and the installed Druxt modules.
|
|
11
|
+
|
|
12
|
+
The stories are connected to your Drupal JSON:API via the DruxtClient; this
|
|
13
|
+
allows you to test your Druxt Wrapper components using live data.
|
|
14
|
+
|
|
15
|
+
- For more information, refer to the
|
|
16
|
+
[Druxt Storybook guide](https://druxtjs.org/guide/storybook).
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## Introduction
|
|
21
|
+
|
|
22
|
+
This is a live Druxt Storybook, with autogenerated stories based on the
|
|
23
|
+
configuration of your Drupal backend.
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
### Autogenerated stories
|
|
28
|
+
|
|
29
|
+
Each Druxt module is able to use configuration from your Drupal backend to craft
|
|
30
|
+
site specific stories.
|
|
31
|
+
|
|
32
|
+
For instance, the DruxtEntity module will create a story for each Entity type,
|
|
33
|
+
Bundle and Display mode, while the Block module will create a story for each
|
|
34
|
+
backend Theme, Region and Block.
|
|
35
|
+
|
|
36
|
+
Search or navigate through the Druxt components and stories in the Storybook
|
|
37
|
+
sidebar.
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
### What is Druxt?
|
|
42
|
+
|
|
43
|
+
> Drupal + Nuxt = Druxt
|
|
44
|
+
|
|
45
|
+
Druxt is a framework for building Fully Decoupled Drupal and Nuxt.js
|
|
46
|
+
applications and sites. It allows you to leverage the content modelling and
|
|
47
|
+
management power of Drupal, and build elegant user experiences with Nuxt.js.
|
|
48
|
+
|
|
49
|
+
- Find out more @ [DruxtJS.org](https://druxtjs.org)
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
### Druxt components
|
|
54
|
+
|
|
55
|
+
Druxt components are provided by Druxt modules to provide targetted decoupled
|
|
56
|
+
Drupal functionality; A **DruxtEntity** component to render Drupal Content
|
|
57
|
+
entities, or a **DruxtMenu** component to render a Drupal menu, etc.
|
|
58
|
+
|
|
59
|
+
- See the core Druxt components @
|
|
60
|
+
[https://druxtjs.org/api/components](https://druxtjs.org/api/components)
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
### Druxt Wrapper theme system
|
|
65
|
+
|
|
66
|
+
Druxt components that extend the **DruxtModule** use slot based wrapper system,
|
|
67
|
+
providing the frontend developer the ability to create theme templates per
|
|
68
|
+
Content type, or Display mode, and many more component options depending on the
|
|
69
|
+
module.
|
|
70
|
+
|
|
71
|
+
The available component options are provided via the `component.options` data
|
|
72
|
+
on the relevant Druxt module component.
|
|
73
|
+
|
|
74
|
+
- For more information, see the [Themeing guide](https://druxtjs.org/guide/theming)
|
package/templates/plugin.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DruxtClient } from 'druxt'
|
|
2
2
|
|
|
3
|
-
export default (
|
|
3
|
+
export default ({ app }, inject) => {
|
|
4
4
|
const options = <%= JSON.stringify(options) %>
|
|
5
5
|
|
|
6
6
|
// Disable the proxy for server side requests.
|
|
@@ -8,6 +8,15 @@ export default (context, inject) => {
|
|
|
8
8
|
options.proxy.api = false
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
+
<% if (typeof options.axios === 'object') { %>
|
|
12
|
+
// Axios settings.
|
|
13
|
+
console.warn('[druxt] Axios instance settings are deprecated, use @nuxtjs/axios module configuration instead.')
|
|
14
|
+
options.axios = <%= JSON.stringify(options.axios) %>
|
|
15
|
+
<% } else { %>
|
|
16
|
+
// Use the @nuxtjs/axios module Axios instance.
|
|
17
|
+
options.axios = app.$axios
|
|
18
|
+
<% } %>
|
|
19
|
+
|
|
11
20
|
const druxt = new DruxtClient(options.baseUrl, options)
|
|
12
21
|
druxt.settings = options
|
|
13
22
|
inject('druxt', druxt)
|
package/CHANGELOG.md
DELETED
|
@@ -1,375 +0,0 @@
|
|
|
1
|
-
# druxt
|
|
2
|
-
|
|
3
|
-
## 0.16.0
|
|
4
|
-
|
|
5
|
-
### Minor Changes
|
|
6
|
-
|
|
7
|
-
- dc226c2: Made the \$druxt plugin first to be available to all Druxt module plugins.
|
|
8
|
-
- 7b749bd: Added improved error handling.
|
|
9
|
-
|
|
10
|
-
## 0.15.0
|
|
11
|
-
|
|
12
|
-
### Minor Changes
|
|
13
|
-
|
|
14
|
-
- 2ae1d6d: Reduced Fetch based UI flicker in the DruxtModule
|
|
15
|
-
|
|
16
|
-
## 0.14.0
|
|
17
|
-
|
|
18
|
-
### Minor Changes
|
|
19
|
-
|
|
20
|
-
- 85fff42: Added debug mode and Axios request logging.
|
|
21
|
-
|
|
22
|
-
```
|
|
23
|
-
export default {
|
|
24
|
-
druxt: {
|
|
25
|
-
// Enable debug log messages.
|
|
26
|
-
debug: true,
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
- 39e2e2e: Added ability to render readable JSON with the DruxtDebug component
|
|
32
|
-
|
|
33
|
-
```jsx
|
|
34
|
-
<DruxtDebug :json="{ data: [{ one: true, two: false }] }" />
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
- 9c33d82: Made summary prop optional on DruxtDebug component
|
|
38
|
-
- 45bc0b9: Added Druxt version to Nuxt badge
|
|
39
|
-
|
|
40
|
-
## 0.13.0
|
|
41
|
-
|
|
42
|
-
### Minor Changes
|
|
43
|
-
|
|
44
|
-
- 77ab204: Added ability to proxy the API
|
|
45
|
-
|
|
46
|
-
```js
|
|
47
|
-
export default {
|
|
48
|
-
druxt: {
|
|
49
|
-
proxy: {
|
|
50
|
-
api: true
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
Creates two proxy entries:
|
|
57
|
-
|
|
58
|
-
- The JSON:API: `${ENDPOINT}` -> `${BASEURL}${ENDPOINT}`
|
|
59
|
-
- The Decoupled Router:`/router/translate-path` -> `${BASEURL}/router/translate-path`
|
|
60
|
-
|
|
61
|
-
- 77ab204: Added ability to proxy the Drupal file system
|
|
62
|
-
|
|
63
|
-
```js
|
|
64
|
-
export default {
|
|
65
|
-
druxt: {
|
|
66
|
-
proxy: {
|
|
67
|
-
files: "default"
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
Creates a proxy entry:
|
|
74
|
-
|
|
75
|
-
- `/sites/${PATH}/files` -> `${BASEURL}/site/${PATH}/files`
|
|
76
|
-
|
|
77
|
-
- c4457e1: Changed template injected module components to not use a DruxtWrapper component by default.
|
|
78
|
-
- e7b1533: Refactored DruxtModule fetch hooks
|
|
79
|
-
|
|
80
|
-
## 0.12.0
|
|
81
|
-
|
|
82
|
-
### Minor Changes
|
|
83
|
-
|
|
84
|
-
- 897dcbc: Added createResource method to DruxtClient
|
|
85
|
-
|
|
86
|
-
```js
|
|
87
|
-
this.$druxt.createResource({ type, attributes: {}, relationships: {} });
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
- 897dcbc: Added updateResource method to DruxtClient
|
|
91
|
-
|
|
92
|
-
```js
|
|
93
|
-
await this.$druxt.updateResource({
|
|
94
|
-
type,
|
|
95
|
-
id,
|
|
96
|
-
attributes: {},
|
|
97
|
-
relationships: {}
|
|
98
|
-
});
|
|
99
|
-
```
|
|
100
|
-
|
|
101
|
-
- 4504a2f: Added getRelated() method
|
|
102
|
-
|
|
103
|
-
```js
|
|
104
|
-
await this.$druxt.getRelated(type, id, related);
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
- e3e634c: Enabled Components auto-discovery by default
|
|
108
|
-
|
|
109
|
-
## 0.11.0
|
|
110
|
-
|
|
111
|
-
### Minor Changes
|
|
112
|
-
|
|
113
|
-
- dae345e: Added Druxt modules settings to `$druxt.settings`
|
|
114
|
-
|
|
115
|
-
### Patch Changes
|
|
116
|
-
|
|
117
|
-
- 75ff8a9: Fixed issue with Axios settings and Storybook
|
|
118
|
-
|
|
119
|
-
## 0.10.0
|
|
120
|
-
|
|
121
|
-
### Minor Changes
|
|
122
|
-
|
|
123
|
-
- 715e5ef: Updated component registration method to use the Nuxt `components:dirs` hook
|
|
124
|
-
- 2b8c3f3: Added DruxtDebug component
|
|
125
|
-
- 317184e: Added Druxt API URL to Nuxt CLI badge
|
|
126
|
-
|
|
127
|
-
## 0.9.0
|
|
128
|
-
|
|
129
|
-
### Minor Changes
|
|
130
|
-
|
|
131
|
-
- 21170fb: Moved Vue components out of bundle
|
|
132
|
-
|
|
133
|
-
⚠ Potential breaking change
|
|
134
|
-
|
|
135
|
-
_**Note:** This only effects custom Druxt modules and implementations._
|
|
136
|
-
|
|
137
|
-
```diff
|
|
138
|
-
-import { DruxtModule } from 'druxt'
|
|
139
|
-
+import DruxtModule from 'druxt/dist/components/DruxtModule.vue'
|
|
140
|
-
```
|
|
141
|
-
|
|
142
|
-
## 0.8.3
|
|
143
|
-
|
|
144
|
-
### Patch Changes
|
|
145
|
-
|
|
146
|
-
- Fixed issue with attrs passthrough
|
|
147
|
-
|
|
148
|
-
## 0.8.2
|
|
149
|
-
|
|
150
|
-
### Patch Changes
|
|
151
|
-
|
|
152
|
-
- Fixed bug with fetchKey and attrs passthrough
|
|
153
|
-
|
|
154
|
-
## 0.8.1
|
|
155
|
-
|
|
156
|
-
### Patch Changes
|
|
157
|
-
|
|
158
|
-
- Fixed DruxtModule emit behavior
|
|
159
|
-
|
|
160
|
-
## 0.8.0
|
|
161
|
-
|
|
162
|
-
### Minor Changes
|
|
163
|
-
|
|
164
|
-
- Added support for default template injection to DruxtModule
|
|
165
|
-
|
|
166
|
-
_**Example:** Default template injection with DruxtEntity and DruxtMenu components_
|
|
167
|
-
|
|
168
|
-
```vue
|
|
169
|
-
<DruxtEntity v-bind="props">
|
|
170
|
-
<template #default="{ entity }">
|
|
171
|
-
<h2>{{ entity.attributes.title }}</h2>
|
|
172
|
-
<DruxtMenu name="main" :depth="1" :parentId="parentId(entity)">
|
|
173
|
-
<template #default="{ items }">
|
|
174
|
-
{{ items }}
|
|
175
|
-
</template>
|
|
176
|
-
</DruxtMenu>
|
|
177
|
-
</template>
|
|
178
|
-
</DruxtEntity>
|
|
179
|
-
```
|
|
180
|
-
|
|
181
|
-
## 0.7.1
|
|
182
|
-
|
|
183
|
-
### Patch Changes
|
|
184
|
-
|
|
185
|
-
- Fixed issue with attrs passthrough
|
|
186
|
-
- Updated support for Drupal JSON-API Params
|
|
187
|
-
|
|
188
|
-
Thanks to [d34dman](https://github.com/d34dman)
|
|
189
|
-
|
|
190
|
-
## 0.7.0
|
|
191
|
-
|
|
192
|
-
### Minor Changes
|
|
193
|
-
|
|
194
|
-
- Added support for v-model to DruxtModule
|
|
195
|
-
|
|
196
|
-
_**Example:** Passing a custom entity model to the DruxtEntity component_
|
|
197
|
-
|
|
198
|
-
```vue
|
|
199
|
-
<DruxtEntity
|
|
200
|
-
type="node--article"
|
|
201
|
-
v-model="{
|
|
202
|
-
attributes: {
|
|
203
|
-
title: 'My Entity',
|
|
204
|
-
field_name: 'Value'
|
|
205
|
-
},
|
|
206
|
-
relationships: {}
|
|
207
|
-
}"
|
|
208
|
-
/>
|
|
209
|
-
```
|
|
210
|
-
|
|
211
|
-
## 0.6.1
|
|
212
|
-
|
|
213
|
-
### Patch Changes
|
|
214
|
-
|
|
215
|
-
- Fixed issue with normalizaton of include/sort data
|
|
216
|
-
- Fixed issue with queryobject in getResource action
|
|
217
|
-
- Updated dependencies
|
|
218
|
-
|
|
219
|
-
## 0.6.0
|
|
220
|
-
|
|
221
|
-
### Minor Changes
|
|
222
|
-
|
|
223
|
-
- Refactored DruxtStore
|
|
224
|
-
- Added support for partial resources
|
|
225
|
-
- Added dehyrdation/rehydration of included resources and collections
|
|
226
|
-
- Fixed issue with DruxtStore reactivity
|
|
227
|
-
|
|
228
|
-
## 0.5.1
|
|
229
|
-
|
|
230
|
-
### Patch Changes
|
|
231
|
-
|
|
232
|
-
- Fixed issue with getWrapperData
|
|
233
|
-
- Fixed issue with DruxtStore reactivity
|
|
234
|
-
|
|
235
|
-
## 0.5.0
|
|
236
|
-
|
|
237
|
-
### Minor Changes
|
|
238
|
-
|
|
239
|
-
- Added DruxtModule component
|
|
240
|
-
|
|
241
|
-
```vue
|
|
242
|
-
<script>
|
|
243
|
-
import { DruxtModule } from "druxt";
|
|
244
|
-
export default {
|
|
245
|
-
name: "MyCustomDruxtModule",
|
|
246
|
-
extends: DruxtModule
|
|
247
|
-
};
|
|
248
|
-
</script>
|
|
249
|
-
```
|
|
250
|
-
|
|
251
|
-
- For more details, refer to the [DruxtModule API documentation](/api/packages/druxt/components/DruxtModule)
|
|
252
|
-
|
|
253
|
-
- Added \$attrs/props splitting
|
|
254
|
-
|
|
255
|
-
## 0.4.2
|
|
256
|
-
|
|
257
|
-
### Patch Changes
|
|
258
|
-
|
|
259
|
-
- Added metadata to Nuxt module
|
|
260
|
-
|
|
261
|
-
## 0.4.1
|
|
262
|
-
|
|
263
|
-
### Patch Changes
|
|
264
|
-
|
|
265
|
-
- Fixed dependency issues
|
|
266
|
-
|
|
267
|
-
## 0.4.0
|
|
268
|
-
|
|
269
|
-
### Minor Changes
|
|
270
|
-
|
|
271
|
-
- Added DruxtClient
|
|
272
|
-
|
|
273
|
-
_**Example:** Using the DruxtClient to load a JSON:API resource in a node.js application_
|
|
274
|
-
|
|
275
|
-
```js
|
|
276
|
-
import { DruxtClient } from 'druxt'
|
|
277
|
-
const druxt = new DruxtClient('https://demo-api.druxtjs.org')
|
|
278
|
-
druxt.getResource('node--page', uuid, query).then((resource) => {
|
|
279
|
-
console.log('getResource', resource)
|
|
280
|
-
}))
|
|
281
|
-
```
|
|
282
|
-
|
|
283
|
-
- For more details, refer to the [DruxtClient API documentation](/api/packages/druxt/client)
|
|
284
|
-
|
|
285
|
-
- Added DruxtStore
|
|
286
|
-
|
|
287
|
-
_**Example:** Using the DruxtStore to load a JSON:API resource within Nuxt_
|
|
288
|
-
|
|
289
|
-
```vue
|
|
290
|
-
<script>
|
|
291
|
-
export default {
|
|
292
|
-
data: () => ({
|
|
293
|
-
resource: null
|
|
294
|
-
}),
|
|
295
|
-
|
|
296
|
-
async fetch() {
|
|
297
|
-
const resource = await this.$store.dispatch("druxt/getResource", {
|
|
298
|
-
type: "node--article",
|
|
299
|
-
id: uuid,
|
|
300
|
-
query
|
|
301
|
-
});
|
|
302
|
-
this.resource = resource;
|
|
303
|
-
}
|
|
304
|
-
};
|
|
305
|
-
</script>
|
|
306
|
-
```
|
|
307
|
-
|
|
308
|
-
- For more details, refer to the [DruxtStore API documentation](/api/packages/druxt/stores/druxt)
|
|
309
|
-
|
|
310
|
-
- Added \$druxt plugin wrapper for DruxtClient
|
|
311
|
-
|
|
312
|
-
## 0.3.4
|
|
313
|
-
|
|
314
|
-
### Patch Changes
|
|
315
|
-
|
|
316
|
-
- Updated dependencies
|
|
317
|
-
|
|
318
|
-
## 0.3.3
|
|
319
|
-
|
|
320
|
-
### Patch Changes
|
|
321
|
-
|
|
322
|
-
- Added Inner prop to DruxtComponentMixin
|
|
323
|
-
|
|
324
|
-
## 0.3.2
|
|
325
|
-
|
|
326
|
-
### Patch Changes
|
|
327
|
-
|
|
328
|
-
- Added sorting of component options
|
|
329
|
-
- Fixed issue with component options
|
|
330
|
-
|
|
331
|
-
## 0.3.1
|
|
332
|
-
|
|
333
|
-
### Patch Changes
|
|
334
|
-
|
|
335
|
-
- Added DruxtWrapper to DruxtComponentMixin
|
|
336
|
-
- Added unique filter to component options
|
|
337
|
-
|
|
338
|
-
## 0.3.0
|
|
339
|
-
|
|
340
|
-
### Minor Changes
|
|
341
|
-
|
|
342
|
-
- Moved Site functionality to the [DruxtSite module](/modules/site)
|
|
343
|
-
- Added Druxt component and mixin
|
|
344
|
-
- Added available component options data
|
|
345
|
-
- Removed unused Class and Store
|
|
346
|
-
|
|
347
|
-
## 0.2.1
|
|
348
|
-
|
|
349
|
-
### Patch Changes
|
|
350
|
-
|
|
351
|
-
- Added @nuxtjs/proxy and default configuration
|
|
352
|
-
- Updated dependencies for no-JS support
|
|
353
|
-
|
|
354
|
-
## 0.2.0
|
|
355
|
-
|
|
356
|
-
### Minor Changes
|
|
357
|
-
|
|
358
|
-
- Updated dependencies for no-JS support
|
|
359
|
-
|
|
360
|
-
## 0.1.2
|
|
361
|
-
|
|
362
|
-
### Patch Changes
|
|
363
|
-
|
|
364
|
-
- Fixed Vuex store installation
|
|
365
|
-
- Updated dependencies
|
|
366
|
-
|
|
367
|
-
## 0.1.1
|
|
368
|
-
|
|
369
|
-
### Patch Changes
|
|
370
|
-
|
|
371
|
-
- Removed schema generation workaround
|
|
372
|
-
|
|
373
|
-
## 0.1.0
|
|
374
|
-
|
|
375
|
-
### Initial release
|