druxt-breadcrumb 0.13.3 → 0.14.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.
@@ -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: ''
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,34 @@ 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 (this.path && path !== this.$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 === '/' && !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 === '/') {
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
+ const paths = path.split('/').filter(String)
81
135
  paths.pop()
82
136
  while (paths.length > 0) {
83
137
  const to = '/' + paths.join('/')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "druxt-breadcrumb",
3
- "version": "0.13.3",
3
+ "version": "0.14.1",
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.15.0",
45
- "druxt-blocks": "^0.14.3",
46
- "druxt-router": "^0.24.2"
44
+ "druxt": "^0.18.0",
45
+ "druxt-blocks": "^0.15.1",
46
+ "druxt-router": "^0.26.1"
47
47
  },
48
48
  "optionalDependencies": {
49
49
  "vue": "^2.6.14",
package/CHANGELOG.md DELETED
@@ -1,183 +0,0 @@
1
- # druxt-breadcrumb
2
-
3
- ## 0.13.3
4
-
5
- ### Patch Changes
6
-
7
- - Updated dependencies [2ae1d6d]
8
- - druxt@0.15.0
9
- - druxt-blocks@0.14.3
10
- - druxt-router@0.24.2
11
-
12
- ## 0.13.2
13
-
14
- ### Patch Changes
15
-
16
- - Updated dependencies [45bc0b9]
17
- - druxt@0.14.0
18
- - druxt-blocks@0.14.2
19
- - druxt-router@0.24.1
20
-
21
- ## 0.13.1
22
-
23
- ### Patch Changes
24
-
25
- - Updated dependencies [9161b38]
26
- - druxt-router@0.24.0
27
- - druxt-blocks@0.14.1
28
-
29
- ## 0.13.0
30
-
31
- ### Minor Changes
32
-
33
- - e7b1533: Refactored DruxtModule fetch hooks
34
-
35
- ### Patch Changes
36
-
37
- - Updated dependencies [77ab204]
38
- - druxt-blocks@0.14.0
39
- - druxt@0.13.0
40
- - druxt-router@0.23.0
41
-
42
- ## 0.12.1
43
-
44
- ### Patch Changes
45
-
46
- - Updated dependencies [4504a2f]
47
- - druxt@0.12.0
48
- - druxt-router@0.22.0
49
- - druxt-blocks@0.13.1
50
-
51
- ## 0.12.0
52
-
53
- ### Minor Changes
54
-
55
- - 8d28c18: Updated storybook integration
56
-
57
- ### Patch Changes
58
-
59
- - 9a1d720: Fixed error when no crumbs are present
60
- - dae345e: Removed unused `$druxtBreadcrumb` plugin
61
- - Updated dependencies [9d905e8]
62
- - druxt-router@0.21.0
63
- - druxt-blocks@0.13.0
64
- - druxt@0.11.0
65
-
66
- ## 0.11.0
67
-
68
- ### Minor Changes
69
-
70
- - 715e5ef: Updated component registration method to use the Nuxt `components:dirs` hook
71
-
72
- ### Patch Changes
73
-
74
- - Updated dependencies [1ab762c]
75
- - druxt-router@0.20.0
76
- - druxt-blocks@0.12.0
77
- - druxt@0.10.0
78
-
79
- ## 0.10.1
80
-
81
- ### Patch Changes
82
-
83
- - c4616df: Fixed dependencies
84
- - Updated dependencies [c4616df]
85
- - druxt-blocks@0.11.1
86
- - druxt-router@0.19.1
87
-
88
- ## 0.10.0
89
-
90
- ### Minor Changes
91
-
92
- - 21170fb: Moved Vue components out of bundle
93
-
94
- ⚠ Potential breaking change
95
-
96
- _**Note:** This only effects custom Druxt modules and implementations._
97
-
98
- ```diff
99
- -import { DruxtBreadcrumb } from 'druxt-breadcrumb'
100
- +import DruxtBreadcrumb from 'druxt-breadcrumb/dist/components/DruxtBreadcrumb.vue'
101
- ```
102
-
103
- ### Patch Changes
104
-
105
- - Updated dependencies [21170fb]
106
- - druxt-blocks@0.11.0
107
- - druxt@0.9.0
108
- - druxt-router@0.19.0
109
-
110
- ## 0.9.0
111
-
112
- ### Minor Changes
113
-
114
- - Added support for default template injection
115
- - For details, see the [Druxt 0.8.0 release notes](/api/packages/druxt/CHANGELOG#080)
116
-
117
- ## 0.8.0
118
-
119
- ### Minor Changes
120
-
121
- - Updated component to use DruxtModule
122
-
123
- ## 0.7.2
124
-
125
- ### Patch Changes
126
-
127
- - Updated dependencies
128
-
129
- ## 0.7.1
130
-
131
- ### Patch Changes
132
-
133
- - Updated dependencies
134
-
135
- ## 0.7.0
136
-
137
- ### Minor Changes
138
-
139
- - Added support for the Druxt component
140
-
141
- ## 0.6.1
142
-
143
- ### Patch Changes
144
-
145
- - Updated dependencies
146
-
147
- ## 0.6.0
148
-
149
- ### Minor Changes
150
-
151
- - Refactored module
152
-
153
- ## 0.5.0
154
-
155
- ### Minor Changes
156
-
157
- ## 0.4.0
158
-
159
- ### Minor Changes
160
-
161
- ## 0.3.2
162
-
163
- ### Patch Changes
164
-
165
- ## 0.3.1
166
-
167
- ### Patch Changes
168
-
169
- ## 0.3.0
170
-
171
- ### Minor Changes
172
-
173
- ## 0.2.0
174
-
175
- ### Minor Changes
176
-
177
- ## 0.1.1
178
-
179
- ### Patch Changes
180
-
181
- ## 0.1.0
182
-
183
- ### Minor Changes