druxt-breadcrumb 0.13.4 → 0.15.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.
@@ -13,3 +13,54 @@ const Template = (args, { argTypes }) => ({
13
13
 
14
14
  export const Default = Template.bind({})
15
15
  Default.storyName = 'DruxtBreadcrumb'
16
+
17
+ let code
18
+
19
+ // Wrapper story.
20
+ code = `<template>
21
+ <DruxtDebug :json="crumbs" />
22
+ </template>
23
+
24
+ <script>
25
+ import { DruxtBreadcrumbMixin } from 'druxt-breadcrumb'
26
+ export default {
27
+ mixins: [DruxtBreadcrumbMixin]
28
+ }
29
+ </script>`
30
+ export const Wrapper = (args, { argTypes }) => ({
31
+ components: { DruxtBreadcrumb },
32
+ props: Object.keys(argTypes),
33
+ template: `<DruxtBreadcrumb v-bind="$props" ref="module">
34
+ <template #default>
35
+ Component options:
36
+ <ul>
37
+ <li v-for="option of $refs.module.getModuleComponents()" :key="option.name">{{ option.name }}</li>
38
+ </ul>
39
+ </template>
40
+ </DruxtBreadcrumb>`
41
+ })
42
+ Wrapper.parameters = {
43
+ docs: {
44
+ storyDescription: 'The DruxtBreadcrumb component can be themed by using a Druxt Wrapper component.\n\nCreate an appropriately named component, using the relevant component option, with the following boilerplate:\n\n```jsx\n' + code + '\n```',
45
+ source: { code }
46
+ }
47
+ }
48
+
49
+ // Template injection story.
50
+ code = `<DruxtBreadcrumb>
51
+ <template #default="{ crumbs }">
52
+ <!-- Do whatever you want here -->
53
+ <DruxtDebug :json="crumbs" open />
54
+ </template>
55
+ </DruxtBreadcrumb>`
56
+ export const TemplateInjection = (args, { argTypes }) => ({
57
+ components: { DruxtBreadcrumb },
58
+ props: Object.keys(argTypes),
59
+ template: code.replace('<DruxtBreadcrumb>', '<DruxtBreadcrumb v-bind="$props">')
60
+ })
61
+ TemplateInjection.parameters = {
62
+ docs: {
63
+ storyDescription: 'The DruxtBreadcrumb component can be themed by injecting the default template into the compomnent.\n\n```jsx\n' + code + '\n```',
64
+ source: { code }
65
+ }
66
+ }
@@ -4,10 +4,33 @@ import DruxtModule from 'druxt/dist/components/DruxtModule.vue'
4
4
  import { mapActions, mapState } from 'vuex'
5
5
 
6
6
  /**
7
- * Renders a list of breacrumbs based on the active route.
7
+ * The DruxtBreadcrumb component renders a list of breadcrumbs based on the
8
+ * active route.
8
9
  *
9
10
  * @example @lang vue
10
11
  * <DruxtBreadcrumb />
12
+ *
13
+ * @example @lang vue
14
+ * <DruxtBreadcrumb path="/node/1" />
15
+ *
16
+ * @example <caption>DruxtBreadcrumb Wrapper component boilerplate</caption> @lang vue
17
+ * <template>
18
+ * <DruxtDebug :json="crumbs" />
19
+ * </template>
20
+ *
21
+ * <script>
22
+ * import { DruxtBreadcrumbMixin } from 'druxt-breadcrumb'
23
+ * export default {
24
+ * mixins: [DruxtBreadcrumbMixin]
25
+ * }
26
+ *
27
+ * @example <caption>DruxtBreadcrumb with template injection</caption> @lang vue
28
+ * <DruxtBreadcrumb>
29
+ * <template #default="{ crumbs }">
30
+ * <!-- Do whatever you want here -->
31
+ * <DruxtDebug :json="crumbs" />
32
+ * </template>
33
+ * </DruxtBreadcrumb>
11
34
  */
12
35
  export default {
13
36
  name: 'DruxtBreadcrumb',
@@ -27,6 +50,21 @@ export default {
27
50
  home: {
28
51
  type: Boolean,
29
52
  default: true
53
+ },
54
+
55
+ /**
56
+ * The Decoupled router path.
57
+ *
58
+ * If not set, the Vue router value will be used instead.
59
+ *
60
+ * @type {string}
61
+ *
62
+ * @example @lang vue
63
+ * <DruxtBreacrumb path="/node/1" />
64
+ */
65
+ path: {
66
+ type: String,
67
+ default: undefined
30
68
  }
31
69
  },
32
70
 
@@ -50,6 +88,14 @@ export default {
50
88
  */
51
89
  $route: async function() {
52
90
  await this.$fetch()
91
+ },
92
+
93
+ home() {
94
+ this.$fetch()
95
+ },
96
+
97
+ path() {
98
+ this.$fetch()
53
99
  }
54
100
  },
55
101
 
@@ -58,26 +104,35 @@ export default {
58
104
  * Fetch Crumbs
59
105
  */
60
106
  async fetchCrumbs() {
61
- // If there is no route, stop here.
62
- if (!this.route || !Object.keys(this.route).length) return
107
+ const path = this.path || this.$route.path
108
+ let route = this.route
109
+ if (path && path !== route.path) {
110
+ route = await this.getRoute(path)
111
+ }
112
+
113
+ // If there is no route, throw an error.
114
+ if (!route || !Object.keys(route).length) {
115
+ throw new Error('No route data available.')
116
+ }
63
117
 
64
118
  // If we are at the root and don't want a home crumb, stop here.
65
- if (this.$route.path === '/' && !this.home) return
119
+ if ((path === '/' || route.isHomePath) && !this.home) return
66
120
 
67
121
  // Current route crumb.
68
122
  const crumbs = []
69
- if (this.route.label) {
70
- crumbs.push({ text: this.route.label })
123
+ if (route.label) {
124
+ crumbs.push({ text: route.label })
71
125
  }
72
126
 
73
127
  // If we are at the root of the site, stop here.
74
- if (this.$route.path === '/') {
128
+ if (path === '/' || route.isHomePath) {
75
129
  this.model = crumbs
76
130
  return
77
131
  }
78
132
 
79
133
  // Add crumbs for route parents.
80
- const paths = this.$route.path.split('/').filter(String)
134
+ let addHome = true
135
+ const paths = path.split('/').filter(String)
81
136
  paths.pop()
82
137
  while (paths.length > 0) {
83
138
  const to = '/' + paths.join('/')
@@ -93,11 +148,16 @@ export default {
93
148
  crumbs.push({ to, text: route.label })
94
149
  }
95
150
 
151
+ // If this route is the home path, prevent a duplicate home item.
152
+ if (route.isHomePath) {
153
+ addHome = false
154
+ }
155
+
96
156
  paths.pop()
97
157
  }
98
158
 
99
- // Home crumb.
100
- if (this.home) {
159
+ // Add Home item.
160
+ if (this.home && addHome) {
101
161
  crumbs.push({
102
162
  to: '/',
103
163
  text: 'Home'
@@ -174,11 +234,13 @@ export default {
174
234
  *
175
235
  * @example @lang js
176
236
  * [
237
+ * 'DruxtBreadcrumb[Default][Langcode]',
177
238
  * 'DruxtBreadcrumb[Default]',
178
239
  * ]
179
240
  *
180
241
  * @example @lang js
181
242
  * [
243
+ * 'DruxtBreadcrumbDefaultEn',
182
244
  * 'DruxtBreadcrumbDefault',
183
245
  * ]
184
246
  */
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <DruxtBreadcrumb />
2
+ <DruxtBreadcrumb :langcode="langcode" />
3
3
  </template>
4
4
 
5
5
  <script>
@@ -18,7 +18,7 @@ import { DruxtBlocksBlockMixin } from 'druxt-blocks'
18
18
  * uuid="59121e44-e21b-4f53-b009-5225cd630145"
19
19
  * />
20
20
  *
21
- * @see {@link https://blocks.druxtjs.org/api/components/DruxtBlock.html|DruxtBlock}
21
+ * @see {@link https://blocks.druxtjs.org/api/components/DruxtBlock|DruxtBlock}
22
22
  * @see {@link ../DruxtBreadcrumb|DruxtBreadcrumb}
23
23
  */
24
24
  export default {
@@ -27,7 +27,7 @@ export default {
27
27
  /**
28
28
  * Vue.js Mixins.
29
29
  *
30
- * @see {@link https://blocks.druxtjs.org/api/mixins/block.html|DruxtBlocksBlockMixin}
30
+ * @see {@link https://blocks.druxtjs.org/api/mixins/block|DruxtBlocksBlockMixin}
31
31
  */
32
32
  mixins: [DruxtBlocksBlockMixin],
33
33
  }
@@ -16,9 +16,12 @@ const DruxtBreadcrumbMixin = {
16
16
  crumbs: {
17
17
  type: Array,
18
18
  require: true
19
+ },
20
+ langcode: {
21
+ type: String,
22
+ default: void 0
19
23
  }
20
24
  }
21
25
  };
22
26
 
23
- export default DruxtBreadcrumbModule;
24
- export { DruxtBreadcrumbMixin };
27
+ export { DruxtBreadcrumbMixin, DruxtBreadcrumbModule as default };
@@ -20,9 +20,13 @@ const DruxtBreadcrumbMixin = {
20
20
  crumbs: {
21
21
  type: Array,
22
22
  require: true
23
+ },
24
+ langcode: {
25
+ type: String,
26
+ default: void 0
23
27
  }
24
28
  }
25
29
  };
26
30
 
27
31
  exports.DruxtBreadcrumbMixin = DruxtBreadcrumbMixin;
28
- exports.default = DruxtBreadcrumbModule;
32
+ exports["default"] = DruxtBreadcrumbModule;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "druxt-breadcrumb",
3
- "version": "0.13.4",
3
+ "version": "0.15.0",
4
4
  "description": "Decoupled Router based Breadcrumb Druxt component.",
5
5
  "keywords": [
6
6
  "breadcrumb",
@@ -41,9 +41,9 @@
41
41
  "dist"
42
42
  ],
43
43
  "dependencies": {
44
- "druxt": "^0.16.0",
45
- "druxt-blocks": "^0.14.4",
46
- "druxt-router": "^0.25.0"
44
+ "druxt": "^0.19.0",
45
+ "druxt-blocks": "^0.16.0",
46
+ "druxt-router": "^0.27.0"
47
47
  },
48
48
  "optionalDependencies": {
49
49
  "vue": "^2.6.14",
package/CHANGELOG.md DELETED
@@ -1,192 +0,0 @@
1
- # druxt-breadcrumb
2
-
3
- ## 0.13.4
4
-
5
- ### Patch Changes
6
-
7
- - Updated dependencies [7b749bd]
8
- - druxt@0.16.0
9
- - druxt-router@0.25.0
10
- - druxt-blocks@0.14.4
11
-
12
- ## 0.13.3
13
-
14
- ### Patch Changes
15
-
16
- - Updated dependencies [2ae1d6d]
17
- - druxt@0.15.0
18
- - druxt-blocks@0.14.3
19
- - druxt-router@0.24.2
20
-
21
- ## 0.13.2
22
-
23
- ### Patch Changes
24
-
25
- - Updated dependencies [45bc0b9]
26
- - druxt@0.14.0
27
- - druxt-blocks@0.14.2
28
- - druxt-router@0.24.1
29
-
30
- ## 0.13.1
31
-
32
- ### Patch Changes
33
-
34
- - Updated dependencies [9161b38]
35
- - druxt-router@0.24.0
36
- - druxt-blocks@0.14.1
37
-
38
- ## 0.13.0
39
-
40
- ### Minor Changes
41
-
42
- - e7b1533: Refactored DruxtModule fetch hooks
43
-
44
- ### Patch Changes
45
-
46
- - Updated dependencies [77ab204]
47
- - druxt-blocks@0.14.0
48
- - druxt@0.13.0
49
- - druxt-router@0.23.0
50
-
51
- ## 0.12.1
52
-
53
- ### Patch Changes
54
-
55
- - Updated dependencies [4504a2f]
56
- - druxt@0.12.0
57
- - druxt-router@0.22.0
58
- - druxt-blocks@0.13.1
59
-
60
- ## 0.12.0
61
-
62
- ### Minor Changes
63
-
64
- - 8d28c18: Updated storybook integration
65
-
66
- ### Patch Changes
67
-
68
- - 9a1d720: Fixed error when no crumbs are present
69
- - dae345e: Removed unused `$druxtBreadcrumb` plugin
70
- - Updated dependencies [9d905e8]
71
- - druxt-router@0.21.0
72
- - druxt-blocks@0.13.0
73
- - druxt@0.11.0
74
-
75
- ## 0.11.0
76
-
77
- ### Minor Changes
78
-
79
- - 715e5ef: Updated component registration method to use the Nuxt `components:dirs` hook
80
-
81
- ### Patch Changes
82
-
83
- - Updated dependencies [1ab762c]
84
- - druxt-router@0.20.0
85
- - druxt-blocks@0.12.0
86
- - druxt@0.10.0
87
-
88
- ## 0.10.1
89
-
90
- ### Patch Changes
91
-
92
- - c4616df: Fixed dependencies
93
- - Updated dependencies [c4616df]
94
- - druxt-blocks@0.11.1
95
- - druxt-router@0.19.1
96
-
97
- ## 0.10.0
98
-
99
- ### Minor Changes
100
-
101
- - 21170fb: Moved Vue components out of bundle
102
-
103
- ⚠ Potential breaking change
104
-
105
- _**Note:** This only effects custom Druxt modules and implementations._
106
-
107
- ```diff
108
- -import { DruxtBreadcrumb } from 'druxt-breadcrumb'
109
- +import DruxtBreadcrumb from 'druxt-breadcrumb/dist/components/DruxtBreadcrumb.vue'
110
- ```
111
-
112
- ### Patch Changes
113
-
114
- - Updated dependencies [21170fb]
115
- - druxt-blocks@0.11.0
116
- - druxt@0.9.0
117
- - druxt-router@0.19.0
118
-
119
- ## 0.9.0
120
-
121
- ### Minor Changes
122
-
123
- - Added support for default template injection
124
- - For details, see the [Druxt 0.8.0 release notes](/api/packages/druxt/CHANGELOG#080)
125
-
126
- ## 0.8.0
127
-
128
- ### Minor Changes
129
-
130
- - Updated component to use DruxtModule
131
-
132
- ## 0.7.2
133
-
134
- ### Patch Changes
135
-
136
- - Updated dependencies
137
-
138
- ## 0.7.1
139
-
140
- ### Patch Changes
141
-
142
- - Updated dependencies
143
-
144
- ## 0.7.0
145
-
146
- ### Minor Changes
147
-
148
- - Added support for the Druxt component
149
-
150
- ## 0.6.1
151
-
152
- ### Patch Changes
153
-
154
- - Updated dependencies
155
-
156
- ## 0.6.0
157
-
158
- ### Minor Changes
159
-
160
- - Refactored module
161
-
162
- ## 0.5.0
163
-
164
- ### Minor Changes
165
-
166
- ## 0.4.0
167
-
168
- ### Minor Changes
169
-
170
- ## 0.3.2
171
-
172
- ### Patch Changes
173
-
174
- ## 0.3.1
175
-
176
- ### Patch Changes
177
-
178
- ## 0.3.0
179
-
180
- ### Minor Changes
181
-
182
- ## 0.2.0
183
-
184
- ### Minor Changes
185
-
186
- ## 0.1.1
187
-
188
- ### Patch Changes
189
-
190
- ## 0.1.0
191
-
192
- ### Minor Changes