@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,42 @@
1
+ # Tooltip
2
+
3
+ The `v-d-tooltip` directive can be applied to any component in order to create powerful and dynamic tooltips.
4
+
5
+ ## Basic Example
6
+
7
+ :::demo
8
+ ```html
9
+
10
+ <d-button v-d-tooltip="'👋 Hello there!'">Hover Me</d-button>
11
+
12
+ <!-- tooltip-1.vue -->
13
+ ```
14
+ :::
15
+
16
+ ## Placement
17
+
18
+ Changing the tooltip's placement can be achieved using the, `auto`, `top`, `bottom`, `left`, `right`, `topleft`, `topright`, `bottomleft`, `bottomright`, `lefttop`, `leftbottom`, `righttop` or `rightbottom` modifiers.
19
+
20
+ :::demo
21
+ ```html
22
+
23
+ <d-button v-d-tooltip.bottomright="'I\'m down here!'">Hover Me</d-button>
24
+
25
+ <!-- tooltip-2.vue -->
26
+ ```
27
+ :::
28
+
29
+ ## Triggers
30
+
31
+ You can change the default trigger (hover) using either the `click`, `hover` or `focus` modifier.
32
+
33
+ :::demo
34
+ ```html
35
+
36
+ <d-button v-d-tooltip.click="'👋 Hello there!'">Click Me</d-button>
37
+
38
+ <!-- tooltip-3.vue -->
39
+ ```
40
+ :::
41
+
42
+
@@ -0,0 +1,16 @@
1
+ import dTooltip from './tooltip'
2
+ import { registerDirectives, vueUse } from '../../utils'
3
+
4
+ const directives = {
5
+ dTooltip
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,5 @@
1
+ {
2
+ "type": "directive",
3
+ "name": "Tooltip",
4
+ "slug": "tooltip"
5
+ }
@@ -0,0 +1,145 @@
1
+ import Tooltip from '../../utils/tooltip.class'
2
+
3
+ const inBrowser = typeof window !== 'undefined' && typeof document !== 'undefined'
4
+ const KEY = '_DR_TOOLTIP_'
5
+ const validTriggers = {
6
+ 'focus': true,
7
+ 'hover': true,
8
+ 'click': true,
9
+ 'blur': true
10
+ }
11
+
12
+ /**
13
+ * Bindings parser.
14
+ */
15
+ function parseBindings(bindings) {
16
+ let config = {}
17
+
18
+ switch (typeof bindings.value) {
19
+ case 'string':
20
+ case 'function':
21
+ config.title = bindings.value
22
+ break
23
+ case 'object':
24
+ config = { ...bindings.value }
25
+ }
26
+
27
+ // Parse args (eg: v-d-tooltip:my-container)
28
+ if (bindings.arg) {
29
+ config.container = `#${bindings.arg}` // #my-container
30
+ }
31
+
32
+ // Parse modifiers. eg: v-d-tooltip.my-modifier
33
+ Object.keys(bindings.modifiers).forEach(mod => {
34
+ // Parse if the title allows HTML
35
+ if (/^html$/.test(mod)) {
36
+ config.html = true
37
+
38
+ // Parse animation
39
+ } else if (/^nofade$/.test(mod)) {
40
+ config.animation = false
41
+
42
+ // Parse placement
43
+ } else if (/^(auto|top(left|right)?|bottom(left|right)?|left(top|bottom)?|right(top|bottom)?)$/.test(mod)) {
44
+ config.placement = mod
45
+
46
+ // Parse boundary
47
+ } else if (/^(window|viewport)$/.test(mod)) {
48
+ config.boundary = mod
49
+
50
+ // Parse delay
51
+ } else if (/^d\d+$/.test(mod)) {
52
+ const delay = parseInt(mod.slice(1), 10) || 0
53
+ if (delay) {
54
+ config.delay = delay
55
+ }
56
+
57
+ // Parse offset
58
+ } else if (/^o-?\d+$/.test(mod)) {
59
+ const offset = parseInt(mod.slice(1), 10) || 0
60
+ if (offset) {
61
+ config.offset = offset
62
+ }
63
+ }
64
+ })
65
+
66
+ // Parse selected triggers.
67
+ const selectedTriggers = {}
68
+ let triggers = typeof config.trigger === 'string' ? config.trigger.trim().split(/\s+/) : []
69
+
70
+ triggers.forEach(trigger => {
71
+ if (validTriggers[trigger]) {
72
+ selectedTriggers[trigger] = true
73
+ }
74
+ })
75
+
76
+ // Parse trigger modifiers. eg: v-d-tooltip.click
77
+ Object.keys(validTriggers).forEach(trigger => {
78
+ if (bindings.modifiers[trigger]) {
79
+ selectedTriggers[trigger] = true
80
+ }
81
+ })
82
+
83
+ config.trigger = Object.keys(selectedTriggers).join(' ')
84
+
85
+ // Convert `blur` to `focus`
86
+ if (config.trigger === 'blur') {
87
+ config.trigger = 'focus'
88
+ }
89
+
90
+ // If there's no trigger assigned, just delete the key.
91
+ if (!config.trigger) {
92
+ delete config.trigger
93
+ }
94
+
95
+ return config
96
+ }
97
+
98
+ function applyTooltip(el, bindings, vnode) {
99
+ if (!inBrowser) {
100
+ return
101
+ }
102
+
103
+ const parsedBindings = parseBindings(bindings)
104
+
105
+ if (!el[KEY]) {
106
+ el[KEY] = new Tooltip(el, parsedBindings, vnode.context.$root)
107
+ return
108
+ }
109
+
110
+ el[KEY].updateConfig(parsedBindings)
111
+ }
112
+
113
+ export default {
114
+ bind (el, bindings, vnode) {
115
+ applyTooltip(el, bindings, vnode)
116
+ },
117
+
118
+ inserted(el, bindings, vnode) {
119
+ applyTooltip(el, bindings, vnode)
120
+ },
121
+
122
+ update (el, bindings, vnode) {
123
+ if (bindings.value !== bindings.oldValue) {
124
+ applyTooltip(el, bindings, vnode)
125
+ }
126
+ },
127
+
128
+ componentUpdated (el, bindings, vnode) {
129
+ if (bindings.value !== bindings.oldValue) {
130
+ applyTooltip(el, bindings, vnode)
131
+ }
132
+ },
133
+
134
+ unbind (el) {
135
+ if (!inBrowser) {
136
+ return
137
+ }
138
+
139
+ if (el[KEY]) {
140
+ el[KEY].destroy()
141
+ el[KEY] = null
142
+ delete el[KEY]
143
+ }
144
+ }
145
+ }
package/src/index.js ADDED
@@ -0,0 +1,27 @@
1
+ import * as components from './components'
2
+ import * as directives from './directives'
3
+ import { vueUse } from './utils'
4
+
5
+ const VuePlugin = {
6
+ install: function (Vue) {
7
+ if (Vue._shards_vue_installed) {
8
+ return
9
+ }
10
+
11
+ Vue._shards_vue_installed = true;
12
+
13
+ // Register component plugins
14
+ for (let component in components) {
15
+ Vue.use(components[component])
16
+ }
17
+
18
+ // Register directive plugins
19
+ for (let directive in directives) {
20
+ Vue.use(directives[directive])
21
+ }
22
+ }
23
+ }
24
+
25
+ vueUse(VuePlugin)
26
+
27
+ export default VuePlugin
@@ -0,0 +1,80 @@
1
+ # Getting Started
2
+
3
+ Shards Vue is really easy to get started with. Make sure to follow the guide below to get a better understanding about some of the decisions behind Shards Vue and how to use it to kick-start your next project.
4
+
5
+ > **Note:** This page is currently a work in progress.
6
+
7
+ ## Installation
8
+
9
+ If you are using a module bundler such as [Webpack](https://webpack.js.org/) or [Rollup](https://rollupjs.org/), you can install **Shards Vue** via [pnpm](https://pnpm.io/), [Yarn](https://yarnpkg.com/en/) or [npm](https://www.npmjs.com/) and import Shards Vue directly into your project.
10
+
11
+ ```bash
12
+ // Install via pnpm
13
+ pnpm add @gorse/shards-vue
14
+
15
+ // Install via Yarn
16
+ yarn add @gorse/shards-vue
17
+
18
+ // Install via npm
19
+ npm i @gorse/shards-vue
20
+ ```
21
+
22
+ ## Module Bundlers
23
+
24
+ You can register the entire UI kit as a Vue plugin in your app's entry point:
25
+
26
+ ```javascript
27
+ import Vue from 'vue'
28
+ import ShardsVue from '@gorse/shards-vue'
29
+
30
+ // Import base styles (Bootstrap and Shards)
31
+ import 'bootstrap/dist/css/bootstrap.css'
32
+ import '@gorse/shards-ui/dist/css/shards.css'
33
+
34
+ Vue.use(ShardsVue);
35
+ ```
36
+
37
+ ## Registering Components as Vue Plugins
38
+
39
+ If you'd like to register only certain components as Vue plugins, make sure to import just the component you'd like to use.
40
+
41
+ ```javascript
42
+ import Vue from 'vue'
43
+
44
+ // Import base styles (Bootstrap and Shards)
45
+ import 'bootstrap/dist/css/bootstrap.css'
46
+ import '@gorse/shards-ui/dist/css/shards.css'
47
+
48
+ import { Button } from '@gorse/shards-vue/src/components'
49
+ Vue.use(Button)
50
+
51
+ ```
52
+
53
+ ## Importing Single File Components
54
+
55
+ Importing single file components is also possible.
56
+
57
+ ```vue
58
+ <template>
59
+ <d-button @click="handleClick">Click Me!</d-button>
60
+ </template>
61
+
62
+ <script>
63
+ import dButton from '@gorse/shards-vue/src/components/button/Button'
64
+
65
+ export default {
66
+ components: {
67
+ dButton
68
+ },
69
+ methods: {
70
+ handleClick() {
71
+ alert('You just clicked me!')
72
+ }
73
+ }
74
+ }
75
+ </script>
76
+ ```
77
+
78
+ ## Naming Decisions
79
+
80
+ You will notice that all components are prefixed with `<d-{name}>`. The reason behind this decision is to provide a consistent naming experience across all existing and future products from DesignRevision.
@@ -0,0 +1,4 @@
1
+ {
2
+ "name": "Getting Started",
3
+ "slug": "getting-started"
4
+ }
@@ -0,0 +1,3 @@
1
+ # Roadmap
2
+
3
+ > **Note:** This page is currently under development.
@@ -0,0 +1,4 @@
1
+ {
2
+ "name": "Getting Started",
3
+ "slug": "getting-started"
4
+ }
@@ -0,0 +1,73 @@
1
+ export default {
2
+ data() {
3
+ return {
4
+ localChecked: this.checked,
5
+ hasFocus: false
6
+ }
7
+ },
8
+ model: {
9
+ prop: 'checked',
10
+ event: 'input'
11
+ },
12
+ props: {
13
+ value: {},
14
+ checked: {},
15
+ buttonTheme: {
16
+ type: String,
17
+ default: null
18
+ }
19
+ },
20
+ computed: {
21
+ computedLocalChecked: {
22
+ get() {
23
+ this.isChild ? this.$parent.localChecked : this.localChecked
24
+ },
25
+ set (val) {
26
+ if (this.isChild) {
27
+ this.$parent.localChecked = val
28
+ return
29
+ }
30
+
31
+ this.localChecked = val
32
+ }
33
+ },
34
+ isChild() {
35
+ return Boolean(this.$parent && this.$parent.is_RadioCheckGroup)
36
+ },
37
+ isDisabled() {
38
+ return Boolean(this.isChild ? (this.$parent.disabled || this.disabled) : this.disabled)
39
+ },
40
+ isPlain() {
41
+ return Boolean(this.isChild ? this.$parent.plain : this.plain)
42
+ },
43
+ getSize() {
44
+ return this.isChild ? this.$parent.size : this.size
45
+ },
46
+ getState() {
47
+ if (this.isChild && typeof this.$parent.getState === 'boolean') {
48
+ return this.$parent.getState
49
+ }
50
+
51
+ return this.computedState
52
+ },
53
+ getStateClass() {
54
+ return typeof this.getState === 'boolean' ? (this.getState ? 'is-valid' : 'is-invalid') : ''
55
+ },
56
+ isStacked() {
57
+ return Boolean(this.isChild && this.$parent.stacked)
58
+ },
59
+ getButtonTheme() {
60
+ return this.buttonTheme || (this.isChild ? this.$parent.buttonTheme : null) || 'secondary'
61
+ },
62
+ buttonClasses() {
63
+ return [
64
+ 'btn',
65
+ `btn-${this.getButtonTheme}`,
66
+ this.getSize ? `btn-${this.getSize}` : '',
67
+ this.isDisabled ? 'disabled' : '',
68
+ this.hasFocus ? 'focus' : '',
69
+ this.isStacked ? 'mb-0' : ''
70
+ ]
71
+ }
72
+ }
73
+ }
@@ -0,0 +1,32 @@
1
+ import { isArray } from '../utils';
2
+
3
+ const _DR_RL_ = '_DR_RL_';
4
+
5
+ export default {
6
+ methods: {
7
+ listenOnRoot(event, callback) {
8
+ if (!this[_DR_RL_] || !isArray(this[_DR_RL_])) {
9
+ this[_DR_RL_] = []
10
+ }
11
+
12
+ this[_DR_RL_].push({ event, callback })
13
+ this.$root.$on(event, callback)
14
+
15
+ return this
16
+ },
17
+ emitOnRoot(event, ...args) {
18
+ this.$root.$emit(event, ...args)
19
+ return this
20
+ }
21
+ },
22
+ beforeDestroy() {
23
+ if (!this[_DR_RL_] && !isArray(this[_DR_RL_])) {
24
+ return
25
+ }
26
+
27
+ while (this[_DR_RL_].length > 0) {
28
+ const { event, callback } = this[_DR_RL_].shift()
29
+ this.$root.$off(event, callback)
30
+ }
31
+ }
32
+ }