druxt 0.19.1 → 0.20.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.
@@ -40,6 +40,11 @@ export default {
40
40
  props: {
41
41
  /**
42
42
  * The resource langcode.
43
+ *
44
+ * @example
45
+ * <DruxtModule langcode="en" />
46
+ *
47
+ * @type {string}
43
48
  */
44
49
  langcode: {
45
50
  type: String,
@@ -47,9 +52,15 @@ export default {
47
52
  },
48
53
 
49
54
  /**
50
- * The module value.
55
+ * The module component model value.
56
+ *
57
+ * Used to bypass the Drupal JSON:API fetch, setting the module data
58
+ * directly.
59
+ *
60
+ * @example
61
+ * <DruxtModule v-model="{ foo: bar }" />
51
62
  *
52
- * @type {(Array|Boolean|Date|Number|Object|String)}
63
+ * @type {*}
53
64
  * @model
54
65
  */
55
66
  value: {
@@ -71,7 +82,7 @@ export default {
71
82
  * }"
72
83
  * />
73
84
  *
74
- * @type {(Boolean|Object)}
85
+ * @type {(boolean|object)}
75
86
  */
76
87
  wrapper: {
77
88
  type: [Boolean, Object],
package/dist/druxt.esm.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import chalk from 'chalk';
2
2
  import { DrupalJsonApiParams } from 'drupal-jsonapi-params';
3
- import { join, resolve } from 'path';
3
+ import { join, resolve, normalize } from 'path';
4
4
  import axios from 'axios';
5
5
  import { stringify } from 'querystring';
6
6
  import consola from 'consola';
@@ -135,7 +135,6 @@ class DruxtClient {
135
135
  async get(url, options) {
136
136
  try {
137
137
  const res = await this.axios.get(url, options);
138
- this.checkPermissions(res);
139
138
  return res;
140
139
  } catch (err) {
141
140
  this.error(err, { url });
@@ -251,7 +250,7 @@ class DruxtClient {
251
250
  }
252
251
 
253
252
  var name = "druxt";
254
- var version = "0.19.1";
253
+ var version = "0.20.0";
255
254
  var description = "The Fully Decoupled Drupal Framework for Nuxt.js.";
256
255
  var keywords = [
257
256
  "cms",
@@ -285,7 +284,6 @@ var main = "dist/druxt.ssr.js";
285
284
  var module = "dist/druxt.esm.js";
286
285
  var files = [
287
286
  "dist",
288
- "stories",
289
287
  "templates"
290
288
  ];
291
289
  var dependencies = {
@@ -340,6 +338,8 @@ const DruxtNuxtModule = async function(moduleOptions = {}) {
340
338
  ...moduleOptions,
341
339
  ...(this.options || {}).druxt
342
340
  };
341
+ this.options.baseUrl = options.baseUrl = options.baseUrl.endsWith("/") ? options.baseUrl.slice(0, -1) : options.baseUrl;
342
+ this.options.endpoint = options.endpoint = options.endpoint.startsWith("/") ? options.endpoint : `/${options.endpoint}`;
343
343
  const druxt = new DruxtClient(options.baseUrl, {
344
344
  ...options,
345
345
  proxy: { ...options.proxy || {}, api: false }
@@ -349,7 +349,7 @@ const DruxtNuxtModule = async function(moduleOptions = {}) {
349
349
  if ((options.proxy || {}).api) {
350
350
  proxies[options.endpoint] = options.baseUrl;
351
351
  const languageResourceType = "configurable_language--configurable_language";
352
- if (await druxt.getIndex(languageResourceType)) {
352
+ if ((await druxt.getIndex(languageResourceType) || {}).href) {
353
353
  const query = new DrupalJsonApiParams().addFields(languageResourceType, ["drupal_internal__id"]);
354
354
  const languages = (await druxt.getCollectionAll(languageResourceType, query) || []).map((o) => o.data).flat().filter((o) => !["und", "zxx"].includes(((o || {}).attributes || {}).drupal_internal__id)).map((o) => o.attributes.drupal_internal__id);
355
355
  for (const langcode of languages) {
@@ -365,13 +365,13 @@ const DruxtNuxtModule = async function(moduleOptions = {}) {
365
365
  if (this.options.proxy) {
366
366
  if (Array.isArray(this.options.proxy)) {
367
367
  this.options.proxy = [
368
- ...Object.keys(proxies).map((path) => `${options.baseUrl}${path}`),
369
- ...this.options.proxy
368
+ ...this.options.proxy,
369
+ ...Object.keys(proxies).map((path) => `${options.baseUrl}${path}`)
370
370
  ];
371
371
  } else {
372
372
  this.options.proxy = {
373
- ...proxies,
374
- ...this.options.proxy
373
+ ...this.options.proxy,
374
+ ...proxies
375
375
  };
376
376
  }
377
377
  } else {
@@ -398,10 +398,10 @@ const DruxtNuxtModule = async function(moduleOptions = {}) {
398
398
  const extendPlugins = this.options.extendPlugins;
399
399
  this.options.extendPlugins = (plugins) => {
400
400
  plugins = typeof extendPlugins === "function" ? extendPlugins(plugins) : plugins;
401
- const axiosIndex = plugins.findIndex(({ src }) => src === `${this.options.buildDir}/axios.js`);
401
+ const axiosIndex = plugins.findIndex(({ src }) => src === normalize(`${this.options.buildDir}/axios.js`));
402
402
  const axiosPlugin = plugins[axiosIndex];
403
403
  plugins.splice(axiosIndex, 1);
404
- const druxtIndex = plugins.findIndex(({ src }) => src === `${this.options.buildDir}/druxt.js`);
404
+ const druxtIndex = plugins.findIndex(({ src }) => src === normalize(`${this.options.buildDir}/druxt.js`));
405
405
  const druxtPlugin = plugins[druxtIndex];
406
406
  plugins.splice(druxtIndex, 1);
407
407
  plugins = [axiosPlugin, druxtPlugin, ...plugins];
@@ -416,10 +416,23 @@ const DruxtNuxtModule = async function(moduleOptions = {}) {
416
416
  this.options.components = (_a = this.options.components) != null ? _a : true;
417
417
  this.options.cli.badgeMessages.push(`${chalk.blue.bold("Druxt")} @ v${meta.version}`);
418
418
  this.options.cli.badgeMessages.push(`${chalk.bold("API:")} ${chalk.blue.underline(options.baseUrl + options.endpoint)}`);
419
+ const self = this;
419
420
  this.nuxt.hook("storybook:config", async ({ stories }) => {
420
- stories.push("druxt/stories/*.stories.mdx");
421
- stories.push("druxt/dist/components/*.stories.mdx");
422
- stories.push("druxt/dist/components/*.stories.mjs");
421
+ self.addTemplate({
422
+ src: resolve(__dirname, "../templates/stories/README.stories.mdx"),
423
+ fileName: "stories/druxt-README.stories.mdx"
424
+ });
425
+ stories.push(resolve(self.options.buildDir, "./stories/druxt-README.stories.mdx"));
426
+ self.addTemplate({
427
+ src: resolve(__dirname, "../templates/stories/druxt-module.stories.mdx"),
428
+ fileName: "stories/druxt-module.stories.mdx"
429
+ });
430
+ stories.push(resolve(self.options.buildDir, "./stories/druxt-module.stories.mdx"));
431
+ self.addTemplate({
432
+ src: resolve(__dirname, "../templates/stories/druxt-debug.stories.js"),
433
+ fileName: "stories/druxt-debug.stories.js"
434
+ });
435
+ stories.push(resolve(self.options.buildDir, "./stories/druxt-debug.stories.js"));
423
436
  });
424
437
  };
425
438
 
package/dist/druxt.ssr.js CHANGED
@@ -148,7 +148,6 @@ class DruxtClient {
148
148
  async get(url, options) {
149
149
  try {
150
150
  const res = await this.axios.get(url, options);
151
- this.checkPermissions(res);
152
151
  return res;
153
152
  } catch (err) {
154
153
  this.error(err, { url });
@@ -264,7 +263,7 @@ class DruxtClient {
264
263
  }
265
264
 
266
265
  var name = "druxt";
267
- var version = "0.19.1";
266
+ var version = "0.20.0";
268
267
  var description = "The Fully Decoupled Drupal Framework for Nuxt.js.";
269
268
  var keywords = [
270
269
  "cms",
@@ -298,7 +297,6 @@ var main = "dist/druxt.ssr.js";
298
297
  var module$1 = "dist/druxt.esm.js";
299
298
  var files = [
300
299
  "dist",
301
- "stories",
302
300
  "templates"
303
301
  ];
304
302
  var dependencies = {
@@ -353,6 +351,8 @@ const DruxtNuxtModule = async function(moduleOptions = {}) {
353
351
  ...moduleOptions,
354
352
  ...(this.options || {}).druxt
355
353
  };
354
+ this.options.baseUrl = options.baseUrl = options.baseUrl.endsWith("/") ? options.baseUrl.slice(0, -1) : options.baseUrl;
355
+ this.options.endpoint = options.endpoint = options.endpoint.startsWith("/") ? options.endpoint : `/${options.endpoint}`;
356
356
  const druxt = new DruxtClient(options.baseUrl, {
357
357
  ...options,
358
358
  proxy: { ...options.proxy || {}, api: false }
@@ -362,7 +362,7 @@ const DruxtNuxtModule = async function(moduleOptions = {}) {
362
362
  if ((options.proxy || {}).api) {
363
363
  proxies[options.endpoint] = options.baseUrl;
364
364
  const languageResourceType = "configurable_language--configurable_language";
365
- if (await druxt.getIndex(languageResourceType)) {
365
+ if ((await druxt.getIndex(languageResourceType) || {}).href) {
366
366
  const query = new drupalJsonapiParams.DrupalJsonApiParams().addFields(languageResourceType, ["drupal_internal__id"]);
367
367
  const languages = (await druxt.getCollectionAll(languageResourceType, query) || []).map((o) => o.data).flat().filter((o) => !["und", "zxx"].includes(((o || {}).attributes || {}).drupal_internal__id)).map((o) => o.attributes.drupal_internal__id);
368
368
  for (const langcode of languages) {
@@ -378,13 +378,13 @@ const DruxtNuxtModule = async function(moduleOptions = {}) {
378
378
  if (this.options.proxy) {
379
379
  if (Array.isArray(this.options.proxy)) {
380
380
  this.options.proxy = [
381
- ...Object.keys(proxies).map((path) => `${options.baseUrl}${path}`),
382
- ...this.options.proxy
381
+ ...this.options.proxy,
382
+ ...Object.keys(proxies).map((path) => `${options.baseUrl}${path}`)
383
383
  ];
384
384
  } else {
385
385
  this.options.proxy = {
386
- ...proxies,
387
- ...this.options.proxy
386
+ ...this.options.proxy,
387
+ ...proxies
388
388
  };
389
389
  }
390
390
  } else {
@@ -411,10 +411,10 @@ const DruxtNuxtModule = async function(moduleOptions = {}) {
411
411
  const extendPlugins = this.options.extendPlugins;
412
412
  this.options.extendPlugins = (plugins) => {
413
413
  plugins = typeof extendPlugins === "function" ? extendPlugins(plugins) : plugins;
414
- const axiosIndex = plugins.findIndex(({ src }) => src === `${this.options.buildDir}/axios.js`);
414
+ const axiosIndex = plugins.findIndex(({ src }) => src === path.normalize(`${this.options.buildDir}/axios.js`));
415
415
  const axiosPlugin = plugins[axiosIndex];
416
416
  plugins.splice(axiosIndex, 1);
417
- const druxtIndex = plugins.findIndex(({ src }) => src === `${this.options.buildDir}/druxt.js`);
417
+ const druxtIndex = plugins.findIndex(({ src }) => src === path.normalize(`${this.options.buildDir}/druxt.js`));
418
418
  const druxtPlugin = plugins[druxtIndex];
419
419
  plugins.splice(druxtIndex, 1);
420
420
  plugins = [axiosPlugin, druxtPlugin, ...plugins];
@@ -429,10 +429,23 @@ const DruxtNuxtModule = async function(moduleOptions = {}) {
429
429
  this.options.components = (_a = this.options.components) != null ? _a : true;
430
430
  this.options.cli.badgeMessages.push(`${chalk__default["default"].blue.bold("Druxt")} @ v${meta.version}`);
431
431
  this.options.cli.badgeMessages.push(`${chalk__default["default"].bold("API:")} ${chalk__default["default"].blue.underline(options.baseUrl + options.endpoint)}`);
432
+ const self = this;
432
433
  this.nuxt.hook("storybook:config", async ({ stories }) => {
433
- stories.push("druxt/stories/*.stories.mdx");
434
- stories.push("druxt/dist/components/*.stories.mdx");
435
- stories.push("druxt/dist/components/*.stories.mjs");
434
+ self.addTemplate({
435
+ src: path.resolve(__dirname, "../templates/stories/README.stories.mdx"),
436
+ fileName: "stories/druxt-README.stories.mdx"
437
+ });
438
+ stories.push(path.resolve(self.options.buildDir, "./stories/druxt-README.stories.mdx"));
439
+ self.addTemplate({
440
+ src: path.resolve(__dirname, "../templates/stories/druxt-module.stories.mdx"),
441
+ fileName: "stories/druxt-module.stories.mdx"
442
+ });
443
+ stories.push(path.resolve(self.options.buildDir, "./stories/druxt-module.stories.mdx"));
444
+ self.addTemplate({
445
+ src: path.resolve(__dirname, "../templates/stories/druxt-debug.stories.js"),
446
+ fileName: "stories/druxt-debug.stories.js"
447
+ });
448
+ stories.push(path.resolve(self.options.buildDir, "./stories/druxt-debug.stories.js"));
436
449
  });
437
450
  };
438
451
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "druxt",
3
- "version": "0.19.1",
3
+ "version": "0.20.0",
4
4
  "description": "The Fully Decoupled Drupal Framework for Nuxt.js.",
5
5
  "keywords": [
6
6
  "cms",
@@ -34,7 +34,6 @@
34
34
  "module": "dist/druxt.esm.js",
35
35
  "files": [
36
36
  "dist",
37
- "stories",
38
37
  "templates"
39
38
  ],
40
39
  "dependencies": {
@@ -1,4 +1,4 @@
1
- import DruxtDebug from './DruxtDebug.vue'
1
+ import DruxtDebug from 'druxt/dist/components/DruxtDebug.vue'
2
2
 
3
3
  export default {
4
4
  title: 'Druxt/DruxtDebug',
@@ -27,7 +27,9 @@ Json.args = {
27
27
  }
28
28
  Json.parameters = {
29
29
  docs: {
30
- storyDescription: 'The **json** prop takes any data and runs it through a basic JSON formatter for improved readability.',
30
+ description: {
31
+ story: 'The **json** prop takes any data and runs it through a basic JSON formatter for improved readability.',
32
+ },
31
33
  source: {
32
34
  code: '<DruxtDebug :json="entity" open>Debug information</DruxtDebug>'
33
35
  },
@@ -40,7 +42,9 @@ Summary.args = {
40
42
  }
41
43
  Summary.parameters = {
42
44
  docs: {
43
- storyDescription: 'The **summary** prop can be used to provide a quick explanation of the debug component.',
45
+ description: {
46
+ story: 'The **summary** prop can be used to provide a quick explanation of the debug component.',
47
+ },
44
48
  source: {
45
49
  code: `<DruxtDebug summary="${Summary.args.sumary}">Debug information</DruxtDebug>`
46
50
  },
@@ -102,7 +102,7 @@ Druxt module.
102
102
  import DruxtModule from 'druxt/dist/components/DruxtModule.vue'
103
103
  export default {
104
104
  name: 'MyModule',
105
- extends: DruxtModule
105
+ extends: DruxtModule,
106
106
  druxt: {
107
107
  async fetchConfig() {
108
108
  // Load configuration data here.
@@ -113,7 +113,7 @@ export default {
113
113
  // Build nested arrays of component options based on the context.
114
114
  componentOptions: (context) => ([['default']]),
115
115
  // Map props data from the context.
116
- propsData: (context) => ({ ...context }),
116
+ propsData: (context) => ({}),
117
117
  // Build slots render arrays.
118
118
  slots(h) {
119
119
  return {