@gorse/shards-vue 1.0.8

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.
Files changed (173) hide show
  1. package/.editorconfig +13 -0
  2. package/CHANGELOG.md +49 -0
  3. package/CONTRIBUTING.md +92 -0
  4. package/ISSUE_TEMPLATE.md +19 -0
  5. package/LICENSE +21 -0
  6. package/README.md +157 -0
  7. package/build/optimize.js +49 -0
  8. package/build/paths.js +12 -0
  9. package/build/rollup.config.js +106 -0
  10. package/dist/shards-vue.common.js +13994 -0
  11. package/dist/shards-vue.common.js.map +1 -0
  12. package/dist/shards-vue.common.min.js +1 -0
  13. package/dist/shards-vue.common.min.map +1 -0
  14. package/dist/shards-vue.esm.js +13990 -0
  15. package/dist/shards-vue.esm.js.map +1 -0
  16. package/dist/shards-vue.esm.min.js +1 -0
  17. package/dist/shards-vue.esm.min.map +1 -0
  18. package/dist/shards-vue.umd.js +13997 -0
  19. package/dist/shards-vue.umd.js.map +1 -0
  20. package/dist/shards-vue.umd.min.js +1 -0
  21. package/dist/shards-vue.umd.min.map +1 -0
  22. package/logo.jpg +0 -0
  23. package/package.json +121 -0
  24. package/sandbox/Sandbox.vue +45 -0
  25. package/src/components/alert/Alert.vue +156 -0
  26. package/src/components/alert/README.md +86 -0
  27. package/src/components/alert/index.js +17 -0
  28. package/src/components/badge/Badge.vue +62 -0
  29. package/src/components/badge/README.md +112 -0
  30. package/src/components/badge/index.js +17 -0
  31. package/src/components/breadcrumb/Breadcrumb.vue +55 -0
  32. package/src/components/breadcrumb/BreadcrumbItem.vue +42 -0
  33. package/src/components/breadcrumb/BreadcrumbLink.vue +56 -0
  34. package/src/components/breadcrumb/README.md +53 -0
  35. package/src/components/breadcrumb/index.js +23 -0
  36. package/src/components/button/Button.vue +107 -0
  37. package/src/components/button/ButtonClose.vue +47 -0
  38. package/src/components/button/README.md +197 -0
  39. package/src/components/button/index.js +21 -0
  40. package/src/components/button-group/ButtonGroup.vue +66 -0
  41. package/src/components/button-group/README.md +72 -0
  42. package/src/components/button-group/index.js +18 -0
  43. package/src/components/button-toolbar/ButtonToolbar.vue +29 -0
  44. package/src/components/button-toolbar/README.md +24 -0
  45. package/src/components/button-toolbar/index.js +18 -0
  46. package/src/components/card/Card.vue +57 -0
  47. package/src/components/card/CardBody.vue +92 -0
  48. package/src/components/card/CardFooter.vue +61 -0
  49. package/src/components/card/CardGroup.vue +47 -0
  50. package/src/components/card/CardHeader.vue +61 -0
  51. package/src/components/card/CardImg.vue +64 -0
  52. package/src/components/card/README.md +96 -0
  53. package/src/components/card/index.js +27 -0
  54. package/src/components/collapse/Collapse.vue +209 -0
  55. package/src/components/collapse/README.md +86 -0
  56. package/src/components/collapse/index.js +17 -0
  57. package/src/components/container/Col.vue +125 -0
  58. package/src/components/container/Container.vue +31 -0
  59. package/src/components/container/README.md +91 -0
  60. package/src/components/container/Row.vue +64 -0
  61. package/src/components/container/index.js +21 -0
  62. package/src/components/datepicker/Datepicker.vue +391 -0
  63. package/src/components/datepicker/README.md +185 -0
  64. package/src/components/datepicker/index.js +17 -0
  65. package/src/components/dropdown/Dropdown.vue +442 -0
  66. package/src/components/dropdown/DropdownDivider.vue +22 -0
  67. package/src/components/dropdown/DropdownHeader.vue +29 -0
  68. package/src/components/dropdown/DropdownItem.vue +25 -0
  69. package/src/components/dropdown/README.md +177 -0
  70. package/src/components/dropdown/index.js +23 -0
  71. package/src/components/embed/Embed.vue +47 -0
  72. package/src/components/embed/README.md +23 -0
  73. package/src/components/embed/index.js +17 -0
  74. package/src/components/form/Form.vue +40 -0
  75. package/src/components/form/FormFeedback.vue +39 -0
  76. package/src/components/form/FormInvalidFeedback.vue +39 -0
  77. package/src/components/form/FormRow.vue +21 -0
  78. package/src/components/form/FormText.vue +41 -0
  79. package/src/components/form/FormValidFeedback.vue +39 -0
  80. package/src/components/form/README.md +84 -0
  81. package/src/components/form/index.js +29 -0
  82. package/src/components/form-checkbox/FormCheckbox.vue +200 -0
  83. package/src/components/form-checkbox/README.md +131 -0
  84. package/src/components/form-checkbox/index.js +18 -0
  85. package/src/components/form-input/FormInput.vue +176 -0
  86. package/src/components/form-input/README.md +110 -0
  87. package/src/components/form-input/index.js +18 -0
  88. package/src/components/form-radio/FormRadio.vue +155 -0
  89. package/src/components/form-radio/README.md +61 -0
  90. package/src/components/form-radio/index.js +18 -0
  91. package/src/components/form-select/FormSelect.vue +246 -0
  92. package/src/components/form-select/README.md +180 -0
  93. package/src/components/form-select/index.js +18 -0
  94. package/src/components/form-textarea/FormTextarea.vue +250 -0
  95. package/src/components/form-textarea/README.md +74 -0
  96. package/src/components/form-textarea/index.js +18 -0
  97. package/src/components/image/Image.vue +123 -0
  98. package/src/components/image/README.md +32 -0
  99. package/src/components/image/index.js +18 -0
  100. package/src/components/index.js +63 -0
  101. package/src/components/input-group/InputGroup.vue +125 -0
  102. package/src/components/input-group/InputGroupAddon.vue +58 -0
  103. package/src/components/input-group/InputGroupText.vue +20 -0
  104. package/src/components/input-group/README.md +188 -0
  105. package/src/components/input-group/index.js +21 -0
  106. package/src/components/link/Link.vue +157 -0
  107. package/src/components/link/README.md +27 -0
  108. package/src/components/link/create-link-props.js +54 -0
  109. package/src/components/link/index.js +17 -0
  110. package/src/components/list-group/ListGroup.vue +30 -0
  111. package/src/components/list-group/ListGroupItem.vue +90 -0
  112. package/src/components/list-group/README.md +23 -0
  113. package/src/components/list-group/index.js +19 -0
  114. package/src/components/modal/Modal.vue +121 -0
  115. package/src/components/modal/ModalBody.vue +20 -0
  116. package/src/components/modal/ModalFooter.vue +21 -0
  117. package/src/components/modal/ModalHeader.vue +39 -0
  118. package/src/components/modal/ModalTitle.vue +21 -0
  119. package/src/components/modal/README.md +74 -0
  120. package/src/components/modal/index.js +25 -0
  121. package/src/components/nav/Nav.vue +62 -0
  122. package/src/components/nav/NavItem.vue +23 -0
  123. package/src/components/nav/NavText.vue +21 -0
  124. package/src/components/nav/README.md +94 -0
  125. package/src/components/nav/index.js +19 -0
  126. package/src/components/navbar/Navbar.vue +63 -0
  127. package/src/components/navbar/NavbarBrand.vue +41 -0
  128. package/src/components/navbar/NavbarNav.vue +38 -0
  129. package/src/components/navbar/NavbarToggle.vue +55 -0
  130. package/src/components/navbar/README.md +51 -0
  131. package/src/components/navbar/index.js +23 -0
  132. package/src/components/popover/Popover.vue +126 -0
  133. package/src/components/popover/README.md +73 -0
  134. package/src/components/popover/index.js +17 -0
  135. package/src/components/progress/Progress.vue +93 -0
  136. package/src/components/progress/ProgressBar.vue +123 -0
  137. package/src/components/progress/README.md +95 -0
  138. package/src/components/progress/index.js +19 -0
  139. package/src/components/slider/README.md +120 -0
  140. package/src/components/slider/Slider.vue +103 -0
  141. package/src/components/slider/index.js +17 -0
  142. package/src/components/tabs/README.md +111 -0
  143. package/src/components/tabs/Tab.vue +132 -0
  144. package/src/components/tabs/Tabs.vue +290 -0
  145. package/src/components/tabs/_TabButton.vue +130 -0
  146. package/src/components/tabs/index.js +19 -0
  147. package/src/components/tooltip/README.md +70 -0
  148. package/src/components/tooltip/Tooltip.vue +115 -0
  149. package/src/components/tooltip/index.js +17 -0
  150. package/src/directives/index.js +7 -0
  151. package/src/directives/toggle/index.js +16 -0
  152. package/src/directives/toggle/toggle.js +45 -0
  153. package/src/directives/tooltip/README.md +42 -0
  154. package/src/directives/tooltip/index.js +16 -0
  155. package/src/directives/tooltip/meta.json +5 -0
  156. package/src/directives/tooltip/tooltip.js +145 -0
  157. package/src/index.js +27 -0
  158. package/src/markdown/getting-started/README.md +80 -0
  159. package/src/markdown/getting-started/meta.json +4 -0
  160. package/src/markdown/roadmap/README.md +3 -0
  161. package/src/markdown/roadmap/meta.json +4 -0
  162. package/src/mixins/checkbox-radio.mixin.js +73 -0
  163. package/src/mixins/root-listener.mixin.js +32 -0
  164. package/src/mixins/tooltip-popover.mixin.js +292 -0
  165. package/src/scripts/utils.js +18 -0
  166. package/src/utils/constants.js +191 -0
  167. package/src/utils/events.js +48 -0
  168. package/src/utils/index.js +251 -0
  169. package/src/utils/observer.js +56 -0
  170. package/src/utils/popover.class.js +91 -0
  171. package/src/utils/target.js +50 -0
  172. package/src/utils/tooltip.class.js +60 -0
  173. package/src/utils/tpmanager.class.js +730 -0
@@ -0,0 +1,290 @@
1
+ <template>
2
+ <component :is="tag"
3
+ :id="computedID"
4
+ :class="computedTabsClasses">
5
+
6
+ <div :class="computedNavListWrapperClasses">
7
+ <ul :class="computedNavListClasses"
8
+ role="tablist"
9
+ tabindex='0'
10
+ :id="computedTabControlsID"
11
+ @keydown="handleOnKeynav">
12
+ <d-tab-button v-for="(tab, index) in tabs" :key="index"
13
+ :content="tab.headHtml || tab.title"
14
+ :href="tab.href"
15
+ :id="computedTabButtonID"
16
+ :active="tab.localActiveState"
17
+ :disabled="tab.disabled"
18
+ :setSize="tabs.length"
19
+ :posInSet="index + 1"
20
+ :controls="_tabsContainerID"
21
+ :linkClass="tab.titleLinkClass"
22
+ :itemClass="tab.titleItemClass"
23
+ @click="setTab(index)" />
24
+ <slot name="tabs" />
25
+ </ul>
26
+ </div>
27
+
28
+ <div ref="tabsContainer"
29
+ :class="computedTabsContainerClasses"
30
+ :id="_tabsContainerID">
31
+ <slot />
32
+ </div>
33
+ </component>
34
+ </template>
35
+
36
+ <script>
37
+ import { guid } from '../../utils'
38
+ import { KEYCODES } from '../../utils/constants'
39
+ import dTabButton from './_TabButton.vue'
40
+
41
+ export default {
42
+ name: 'd-tabs',
43
+ components: {
44
+ dTabButton
45
+ },
46
+ data() {
47
+ return {
48
+ currentTab: this.value,
49
+ tabs: [],
50
+ // eslint-disable-next-line
51
+ _tabsContainerID: null
52
+ }
53
+ },
54
+ watch: {
55
+ currentTab (newVal, oldVal) {
56
+ if (newVal === oldVal) {
57
+ return
58
+ }
59
+
60
+ this.$emit('input', newVal)
61
+ this.tabs[newVal].$emit('click')
62
+ },
63
+ value (newVal, oldVal) {
64
+ if (newVal === oldVal) {
65
+ return
66
+ }
67
+
68
+ if (typeof oldVal !== 'number') {
69
+ oldVal = 0
70
+ }
71
+
72
+ const direction = newVal < oldVal ? -1 : 1
73
+ this.setTab(newVal, false, direction)
74
+ }
75
+ },
76
+ props: {
77
+ /**
78
+ * The element ID.
79
+ */
80
+ id: {
81
+ type: String,
82
+ default: null
83
+ },
84
+ /**
85
+ * The element tag.
86
+ */
87
+ tag: {
88
+ type: String,
89
+ default: 'div'
90
+ },
91
+ /**
92
+ * Whether it should be displayed as a card, or not.
93
+ */
94
+ card: {
95
+ type: Boolean,
96
+ default: false
97
+ },
98
+ /**
99
+ * The value used to set the current tab.
100
+ */
101
+ value: {
102
+ type: Number,
103
+ default: null
104
+ },
105
+ /**
106
+ * Whether the tab controls should be displayed as pills, or not.
107
+ */
108
+ pills: {
109
+ type: Boolean,
110
+ default: false
111
+ },
112
+ /**
113
+ * Whether the tab controls should be displayed vertically, or not.
114
+ */
115
+ vertical: {
116
+ type: Boolean,
117
+ default: false
118
+ },
119
+ /**
120
+ * The content class.
121
+ */
122
+ contentClass: {
123
+ type: String,
124
+ default: null
125
+ },
126
+ /**
127
+ * The nav class.
128
+ */
129
+ navClass: {
130
+ type: String,
131
+ default: null
132
+ },
133
+ /**
134
+ * The nav wrapper class.
135
+ */
136
+ navWrapperClass: {
137
+ type: String,
138
+ default: null
139
+ }
140
+ },
141
+ computed: {
142
+ computedID() {
143
+ return this.id || `dr-tabs-${guid()}`
144
+ },
145
+ computedTabControlsID() {
146
+ return `dr-tab-controls-${guid()}`
147
+ },
148
+ computedTabButtonID() {
149
+ return `dr-tabs-tab-${guid()}`
150
+ },
151
+ navStyle() {
152
+ return this.pills ? 'pills' : 'tabs'
153
+ },
154
+ computedTabsClasses() {
155
+ return [
156
+ 'tabs',
157
+ this.vertical ? 'row' : '',
158
+ (this.vertical && this.card) ? 'no-gutters' : '',
159
+ ]
160
+ },
161
+ computedNavListClasses() {
162
+ return [
163
+ 'nav',
164
+ `nav-${this.navStyle}`,
165
+ (this.card && !this.vertical) ? `card-header-${this.navStyle}` : '',
166
+ (this.card && this.vertical) ? 'card-header' : '',
167
+ (this.card && this.vertical) ? 'h-100' : '',
168
+ this.vertical ? 'flex-column' : '',
169
+ this.vertical ? 'border-bottom-0' : '',
170
+ this.vertical ? 'rounded-0' : '',
171
+ this.vertical ? 'd-tabs-vertical-nav' : '',
172
+ this.navClass
173
+ ]
174
+ },
175
+ computedNavListWrapperClasses() {
176
+ return [
177
+ this.card && !this.vertical ? 'card-header' : '',
178
+ this.vertical ? 'col-auto' : '',
179
+ this.navWrapperClass
180
+ ]
181
+ },
182
+ computedTabsContainerClasses() {
183
+ return [
184
+ 'tab-content',
185
+ this.vertical ? 'col' : '',
186
+ this.contentClass
187
+ ]
188
+ }
189
+ },
190
+ created() {
191
+ this._tabsContainerID = `tabs-container-${guid()}`
192
+ },
193
+ methods: {
194
+ handleOnKeynav(e) {
195
+ if (Object.keys(KEYCODES).some((k) => KEYCODES[k] === e.keyCode)) {
196
+ e.preventDefault()
197
+ e.stopPropagation()
198
+ }
199
+
200
+ if (e.keyCode === KEYCODES.UP || e.keyCode === KEYCODES.LEFT ) {
201
+ this.previousTab()
202
+ }
203
+
204
+ if (e.keyCode === KEYCODES.DOWN || e.keyCode === KEYCODES.RIGHT) {
205
+ this.nextTab()
206
+ }
207
+ },
208
+ nextTab() {
209
+ this.setTab(this.currentTab + 1, false, 1)
210
+ },
211
+ previousTab() {
212
+ this.setTab(this.currentTab - 1, false, -1)
213
+ },
214
+ setTab(index, force, direction) {
215
+ direction = direction || 0
216
+ index = index || 0
217
+
218
+ direction = direction === 0 ? 0 : (direction > 0 ? 1 : -1)
219
+
220
+ if (!force && index === this.currentTab) {
221
+ return
222
+ }
223
+
224
+ const tab = this.tabs[index]
225
+
226
+ if (!tab) {
227
+ this.$emit('input', this.currentTab)
228
+ return
229
+ }
230
+
231
+ if (tab.disabled) {
232
+ if (direction) {
233
+ this.setTab(index + direction, force, direction)
234
+ }
235
+
236
+ return
237
+ }
238
+
239
+ this.tabs.forEach(_tab => {
240
+ if (_tab === tab) {
241
+ this.$set(_tab, 'localActiveState', true)
242
+ return
243
+ }
244
+
245
+ this.$set(_tab, 'localActiveState', false)
246
+ })
247
+
248
+ this.currentTab = index
249
+ },
250
+ updateTabs() {
251
+ this.tabs = this.$children.filter(child => child._isTab)
252
+ let tabIndex = null
253
+
254
+ this.tabs.forEach((tab, index) => {
255
+ if (tab.localActiveState && !tab.disabled) {
256
+ tabIndex = index
257
+ }
258
+ })
259
+
260
+ if (tabIndex === null) {
261
+ if (this.currentTab >= this.tabs.length) {
262
+ this.setTab(this.tabs.length - 1, true, -1)
263
+ return
264
+ }
265
+
266
+ if (this.tabs[this.currentTab] && !this.tabs[this.currentTab].disabled) {
267
+ tabIndex = this.currentTab
268
+ }
269
+
270
+ this.tabs.forEach((tab, index) => {
271
+ if (!tab.disabled && tabIndex === null) {
272
+ tabIndex = index
273
+ }
274
+ })
275
+ }
276
+
277
+ this.setTab(tabIndex || 0, true, 0)
278
+ }
279
+ },
280
+ mounted() {
281
+ this.updateTabs()
282
+ }
283
+ }
284
+ </script>
285
+
286
+ <style scoped>
287
+ .d-tabs-vertical-nav:hover {
288
+ background: rgba(90, 97, 105, 0.06);
289
+ }
290
+ </style>
@@ -0,0 +1,130 @@
1
+ <template>
2
+ <li :class="['nav-item', itemClass]" role="presentation">
3
+ <a :class="[
4
+ 'nav-link',
5
+ active ? 'active' : '',
6
+ disabled ? 'disabled' : '',
7
+ linkClass
8
+ ]"
9
+ role="tab"
10
+ tabindex="-1"
11
+ :id="computedID"
12
+ :disabled="disabled"
13
+ :aria-selected="active ? 'true' : 'false'"
14
+ :aria-setsize="setSize"
15
+ :aria-posinset="posInSet"
16
+ :aria-controls="controls"
17
+ v-html="content"
18
+ @click="handleClick"
19
+ @keydown="handleClick" />
20
+ </li>
21
+ </template>
22
+
23
+ <script>
24
+ import { guid } from '../../utils'
25
+ import { KEYCODES } from '../../utils/constants';
26
+
27
+ export default {
28
+ name: 'd-tab-button',
29
+ props: {
30
+ /**
31
+ * The element ID.
32
+ */
33
+ id: {
34
+ type: String,
35
+ default: null
36
+ },
37
+ /**
38
+ * The active state.
39
+ */
40
+ active: {
41
+ type: Boolean,
42
+ default: false
43
+ },
44
+ /**
45
+ * The disabled state.
46
+ */
47
+ disabled: {
48
+ type: Boolean,
49
+ default: false
50
+ },
51
+ /**
52
+ * The link class.
53
+ */
54
+ linkClass: {
55
+ type: String,
56
+ default: null
57
+ },
58
+ /**
59
+ * The item class.
60
+ */
61
+ itemClass: {
62
+ type: String,
63
+ default: null
64
+ },
65
+ /**
66
+ * The aria-setsize value.
67
+ */
68
+ setSize: {
69
+ type: Number,
70
+ default: 0,
71
+ },
72
+ /**
73
+ * The position in set value (aria-posinset).
74
+ */
75
+ posInSet: {
76
+ type: Number,
77
+ default: 0,
78
+ },
79
+ /**
80
+ * The aria-controls value.
81
+ */
82
+ controls: {
83
+ type: String,
84
+ default: null
85
+ },
86
+ /**
87
+ * The content.
88
+ */
89
+ content: {
90
+ type: String,
91
+ default: null
92
+ }
93
+ },
94
+ methods: {
95
+ handleClick(e) {
96
+ if (this.disabled) {
97
+ e.preventDefault()
98
+ e.stopPropagation()
99
+ }
100
+
101
+ if (e.type === 'click'
102
+ || e.keyCode === KEYCODES.ENTER
103
+ || e.keyCode === KEYCODES.SPACE) {
104
+ e.preventDefault()
105
+ e.stopPropagation()
106
+ this.$emit('click', e)
107
+ }
108
+ }
109
+ },
110
+ computed: {
111
+ computedID() {
112
+ return this.id || `d-tab-btn-${guid()}`
113
+ }
114
+ }
115
+ }
116
+ </script>
117
+
118
+ <style scoped>
119
+ .nav-link.active {
120
+ border-bottom: 1px solid transparent;
121
+ }
122
+
123
+ .nav-link:hover {
124
+ cursor: pointer;
125
+ }
126
+
127
+ .nav-link.disabled:hover {
128
+ cursor: not-allowed;
129
+ }
130
+ </style>
@@ -0,0 +1,19 @@
1
+ import { registerComponents, vueUse } from '../../utils';
2
+
3
+ import dTabs from './Tabs.vue';
4
+ import dTab from './Tab.vue';
5
+
6
+ const components = {
7
+ dTabs,
8
+ dTab
9
+ }
10
+
11
+ const VuePlugin = {
12
+ install (Vue) {
13
+ registerComponents(Vue, components)
14
+ }
15
+ }
16
+
17
+ vueUse(VuePlugin)
18
+
19
+ export default VuePlugin
@@ -0,0 +1,70 @@
1
+ # Tooltips
2
+
3
+ Tooltips are powerful components powered behind the scenes by Popper.js that can be attached to any element.
4
+
5
+ > Note: The `container` prop is not always necessary and it is required in the following examples just for demo purposes.
6
+
7
+
8
+ ## Directive
9
+
10
+ You can also create tooltips using the [tooltip directive](/docs/directives/tooltip).
11
+
12
+
13
+ ## Basic Example
14
+
15
+ :::demo
16
+ ```html
17
+
18
+ <div>
19
+ <d-button id="example-tooltip-1"/>
20
+ <d-tooltip target="#example-tooltip-1"
21
+ container=".shards-demo--example--tooltip-01">
22
+ 😃 Wooo! I am a tooltip!
23
+ </d-tooltip>
24
+ </div>
25
+
26
+ <!-- tooltip-1.vue -->
27
+ ```
28
+ :::
29
+
30
+
31
+ ## Placement
32
+
33
+ The tooltip's position can be changed via the `placement` prop. The following placement options are available: `top`, `topleft`, `topright`, `right`, `righttop`, `rightbottom`, `bottom`, `bottomleft`, `bottomright`, `left`, `lefttop`, and `leftbottom`.
34
+
35
+ :::demo
36
+ ```html
37
+
38
+ <div>
39
+ <d-button id="example-tooltip-2"/>
40
+ <d-tooltip target="#example-tooltip-2"
41
+ container=".shards-demo--example--tooltip-02"
42
+ placement="right">
43
+ 👈 Wooo! I am on the left!
44
+ </d-tooltip>
45
+ </div>
46
+
47
+ <!-- tooltip-2.vue -->
48
+ ```
49
+ :::
50
+
51
+
52
+ ## Triggers
53
+
54
+ Using the `triggers` prop you can control on which events the tooltip should be displayed.
55
+
56
+ :::demo
57
+ ```html
58
+
59
+ <div>
60
+ <d-button id="example-tooltip-3">Click Me</d-button>
61
+ <d-tooltip target="#example-tooltip-3"
62
+ container=".shards-demo--example--tooltip-03"
63
+ :triggers="['click']">
64
+ 🖱 You just clicked me!
65
+ </d-tooltip>
66
+ </div>
67
+
68
+ <!-- tooltip-3.vue -->
69
+ ```
70
+ :::
@@ -0,0 +1,115 @@
1
+ <template>
2
+ <div class="d-none" style="display: none;" aria-hiden="true">
3
+ <div ref="title">
4
+ <slot />
5
+ </div>
6
+ </div>
7
+ </template>
8
+
9
+ <script>
10
+ import Tooltip from '../../utils/tooltip.class'
11
+ import TooltipPopoverMixin from '../../mixins/tooltip-popover.mixin'
12
+ import { TP_PLACEMENTS } from '../../utils/constants'
13
+
14
+ export default {
15
+ name: 'd-tooltip',
16
+ mixins: [ TooltipPopoverMixin ],
17
+ props: {
18
+ /**
19
+ * Title.
20
+ */
21
+ title: {
22
+ type: String,
23
+ default: ''
24
+ },
25
+ /**
26
+ * Triggers.
27
+ */
28
+ triggers: {
29
+ type: [String, Array],
30
+ default: 'hover focus'
31
+ },
32
+ /**
33
+ * Placement.
34
+ */
35
+ placement: {
36
+ type: String,
37
+ default: 'top',
38
+ validator: val => Object.keys(TP_PLACEMENTS).map(p => p.toLowerCase()).includes(val)
39
+ },
40
+ /**
41
+ * The target element.
42
+ */
43
+ target: {
44
+ type: [String, Object, Function]
45
+ },
46
+ /**
47
+ * Delay in miliseconds.
48
+ */
49
+ delay: {
50
+ type: [Number, Object, String],
51
+ default: 0
52
+ },
53
+ /**
54
+ * Offset.
55
+ */
56
+ offset: {
57
+ type: [Number, String]
58
+ },
59
+ /**
60
+ * Disable animations.
61
+ */
62
+ noFade: {
63
+ type: Boolean,
64
+ default: false
65
+ },
66
+ /**
67
+ * Wrapping container.
68
+ */
69
+ container: {
70
+ type: String,
71
+ default: null
72
+ },
73
+ /**
74
+ * Instance boundaries.
75
+ */
76
+ boundary: {
77
+ type: [String, Object],
78
+ default: 'scrollParent'
79
+ },
80
+ /**
81
+ * Show state.
82
+ */
83
+ show: {
84
+ type: Boolean,
85
+ default: false
86
+ },
87
+ /**
88
+ * Disabled state.
89
+ */
90
+ disabled: {
91
+ type: Boolean,
92
+ default: false
93
+ },
94
+ },
95
+ methods: {
96
+ /**
97
+ * Gets the target and if the target exists, it initializes the Tooltip.
98
+ * Used inside the TooltipPopoverMixin
99
+ */
100
+ bootstrap() {
101
+ const target = this.getTarget()
102
+
103
+ if (target) {
104
+ this._TPInstance = new Tooltip(
105
+ target,
106
+ this.getUpdatedConfig(),
107
+ this.$root
108
+ )
109
+ }
110
+
111
+ return this._TPInstance
112
+ }
113
+ }
114
+ }
115
+ </script>
@@ -0,0 +1,17 @@
1
+ import { registerComponents, vueUse } from './../../utils';
2
+
3
+ import dTooltip from './Tooltip.vue';
4
+
5
+ const components = {
6
+ dTooltip
7
+ }
8
+
9
+ const VuePlugin = {
10
+ install (Vue) {
11
+ registerComponents(Vue, components)
12
+ }
13
+ }
14
+
15
+ vueUse(VuePlugin)
16
+
17
+ export default VuePlugin
@@ -0,0 +1,7 @@
1
+ import dToggle from './toggle'
2
+ import dTooltip from './tooltip'
3
+
4
+ export {
5
+ dToggle,
6
+ dTooltip
7
+ }
@@ -0,0 +1,16 @@
1
+ import dToggle from './toggle'
2
+ import { registerDirectives, vueUse } from '../../utils'
3
+
4
+ const directives = {
5
+ dToggle
6
+ }
7
+
8
+ const VuePlugin = {
9
+ install (Vue) {
10
+ registerDirectives(Vue, directives)
11
+ }
12
+ }
13
+
14
+ vueUse(VuePlugin)
15
+
16
+ export default VuePlugin
@@ -0,0 +1,45 @@
1
+ import target from '../../utils/target'
2
+ import { COLLAPSE_EVENTS } from '../../utils/constants'
3
+ import { setAttr, addClass, removeClass } from '../../utils'
4
+
5
+ const inBrowser = typeof window !== 'undefined'
6
+ const DR_TOGGLE = '__DRTOGGLE'
7
+
8
+ export default {
9
+ bind(element, binding, vnode) {
10
+ const targets = target(vnode, binding, { click: true }, ({ targets, vnode }) => {
11
+ targets.forEach(target => vnode.context.$root.$emit(COLLAPSE_EVENTS.TOGGLE, target));
12
+ });
13
+
14
+ if (inBrowser && vnode.context && targets.length > 0) {
15
+ setAttr(element, 'aria-controls', targets.join(' '))
16
+ setAttr(element, 'aria-expanded', 'false')
17
+
18
+ if (element.tagName !== 'BUTTON') {
19
+ setAttr(element, 'role', 'button')
20
+ }
21
+
22
+ element[DR_TOGGLE] = function toggleDirectiveHandler(id, state) {
23
+ if (targets.indexOf(id) !== -1) {
24
+ setAttr(element, 'aria-expanded', state ? 'true' : 'false');
25
+
26
+ if (state) {
27
+ removeClass(element, 'collapsed');
28
+ return;
29
+ }
30
+
31
+ addClass(element, 'collapsed');
32
+ }
33
+ }
34
+ vnode.context.$root.$on(COLLAPSE_EVENTS.STATE, element[DR_TOGGLE])
35
+ }
36
+ },
37
+ unbind(element, binding, vnode) {
38
+ if (!element[DR_TOGGLE]) {
39
+ return
40
+ }
41
+
42
+ vnode.context.$root.$off(COLLAPSE_EVENTS.STATE, element[DR_TOGGLE])
43
+ element[DR_TOGGLE] = null
44
+ }
45
+ }