@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.
- package/.editorconfig +13 -0
- package/CHANGELOG.md +49 -0
- package/CONTRIBUTING.md +92 -0
- package/ISSUE_TEMPLATE.md +19 -0
- package/LICENSE +21 -0
- package/README.md +157 -0
- package/build/optimize.js +49 -0
- package/build/paths.js +12 -0
- package/build/rollup.config.js +106 -0
- package/dist/shards-vue.common.js +13994 -0
- package/dist/shards-vue.common.js.map +1 -0
- package/dist/shards-vue.common.min.js +1 -0
- package/dist/shards-vue.common.min.map +1 -0
- package/dist/shards-vue.esm.js +13990 -0
- package/dist/shards-vue.esm.js.map +1 -0
- package/dist/shards-vue.esm.min.js +1 -0
- package/dist/shards-vue.esm.min.map +1 -0
- package/dist/shards-vue.umd.js +13997 -0
- package/dist/shards-vue.umd.js.map +1 -0
- package/dist/shards-vue.umd.min.js +1 -0
- package/dist/shards-vue.umd.min.map +1 -0
- package/logo.jpg +0 -0
- package/package.json +121 -0
- package/sandbox/Sandbox.vue +45 -0
- package/src/components/alert/Alert.vue +156 -0
- package/src/components/alert/README.md +86 -0
- package/src/components/alert/index.js +17 -0
- package/src/components/badge/Badge.vue +62 -0
- package/src/components/badge/README.md +112 -0
- package/src/components/badge/index.js +17 -0
- package/src/components/breadcrumb/Breadcrumb.vue +55 -0
- package/src/components/breadcrumb/BreadcrumbItem.vue +42 -0
- package/src/components/breadcrumb/BreadcrumbLink.vue +56 -0
- package/src/components/breadcrumb/README.md +53 -0
- package/src/components/breadcrumb/index.js +23 -0
- package/src/components/button/Button.vue +107 -0
- package/src/components/button/ButtonClose.vue +47 -0
- package/src/components/button/README.md +197 -0
- package/src/components/button/index.js +21 -0
- package/src/components/button-group/ButtonGroup.vue +66 -0
- package/src/components/button-group/README.md +72 -0
- package/src/components/button-group/index.js +18 -0
- package/src/components/button-toolbar/ButtonToolbar.vue +29 -0
- package/src/components/button-toolbar/README.md +24 -0
- package/src/components/button-toolbar/index.js +18 -0
- package/src/components/card/Card.vue +57 -0
- package/src/components/card/CardBody.vue +92 -0
- package/src/components/card/CardFooter.vue +61 -0
- package/src/components/card/CardGroup.vue +47 -0
- package/src/components/card/CardHeader.vue +61 -0
- package/src/components/card/CardImg.vue +64 -0
- package/src/components/card/README.md +96 -0
- package/src/components/card/index.js +27 -0
- package/src/components/collapse/Collapse.vue +209 -0
- package/src/components/collapse/README.md +86 -0
- package/src/components/collapse/index.js +17 -0
- package/src/components/container/Col.vue +125 -0
- package/src/components/container/Container.vue +31 -0
- package/src/components/container/README.md +91 -0
- package/src/components/container/Row.vue +64 -0
- package/src/components/container/index.js +21 -0
- package/src/components/datepicker/Datepicker.vue +391 -0
- package/src/components/datepicker/README.md +185 -0
- package/src/components/datepicker/index.js +17 -0
- package/src/components/dropdown/Dropdown.vue +442 -0
- package/src/components/dropdown/DropdownDivider.vue +22 -0
- package/src/components/dropdown/DropdownHeader.vue +29 -0
- package/src/components/dropdown/DropdownItem.vue +25 -0
- package/src/components/dropdown/README.md +177 -0
- package/src/components/dropdown/index.js +23 -0
- package/src/components/embed/Embed.vue +47 -0
- package/src/components/embed/README.md +23 -0
- package/src/components/embed/index.js +17 -0
- package/src/components/form/Form.vue +40 -0
- package/src/components/form/FormFeedback.vue +39 -0
- package/src/components/form/FormInvalidFeedback.vue +39 -0
- package/src/components/form/FormRow.vue +21 -0
- package/src/components/form/FormText.vue +41 -0
- package/src/components/form/FormValidFeedback.vue +39 -0
- package/src/components/form/README.md +84 -0
- package/src/components/form/index.js +29 -0
- package/src/components/form-checkbox/FormCheckbox.vue +200 -0
- package/src/components/form-checkbox/README.md +131 -0
- package/src/components/form-checkbox/index.js +18 -0
- package/src/components/form-input/FormInput.vue +176 -0
- package/src/components/form-input/README.md +110 -0
- package/src/components/form-input/index.js +18 -0
- package/src/components/form-radio/FormRadio.vue +155 -0
- package/src/components/form-radio/README.md +61 -0
- package/src/components/form-radio/index.js +18 -0
- package/src/components/form-select/FormSelect.vue +246 -0
- package/src/components/form-select/README.md +180 -0
- package/src/components/form-select/index.js +18 -0
- package/src/components/form-textarea/FormTextarea.vue +250 -0
- package/src/components/form-textarea/README.md +74 -0
- package/src/components/form-textarea/index.js +18 -0
- package/src/components/image/Image.vue +123 -0
- package/src/components/image/README.md +32 -0
- package/src/components/image/index.js +18 -0
- package/src/components/index.js +63 -0
- package/src/components/input-group/InputGroup.vue +125 -0
- package/src/components/input-group/InputGroupAddon.vue +58 -0
- package/src/components/input-group/InputGroupText.vue +20 -0
- package/src/components/input-group/README.md +188 -0
- package/src/components/input-group/index.js +21 -0
- package/src/components/link/Link.vue +157 -0
- package/src/components/link/README.md +27 -0
- package/src/components/link/create-link-props.js +54 -0
- package/src/components/link/index.js +17 -0
- package/src/components/list-group/ListGroup.vue +30 -0
- package/src/components/list-group/ListGroupItem.vue +90 -0
- package/src/components/list-group/README.md +23 -0
- package/src/components/list-group/index.js +19 -0
- package/src/components/modal/Modal.vue +121 -0
- package/src/components/modal/ModalBody.vue +20 -0
- package/src/components/modal/ModalFooter.vue +21 -0
- package/src/components/modal/ModalHeader.vue +39 -0
- package/src/components/modal/ModalTitle.vue +21 -0
- package/src/components/modal/README.md +74 -0
- package/src/components/modal/index.js +25 -0
- package/src/components/nav/Nav.vue +62 -0
- package/src/components/nav/NavItem.vue +23 -0
- package/src/components/nav/NavText.vue +21 -0
- package/src/components/nav/README.md +94 -0
- package/src/components/nav/index.js +19 -0
- package/src/components/navbar/Navbar.vue +63 -0
- package/src/components/navbar/NavbarBrand.vue +41 -0
- package/src/components/navbar/NavbarNav.vue +38 -0
- package/src/components/navbar/NavbarToggle.vue +55 -0
- package/src/components/navbar/README.md +51 -0
- package/src/components/navbar/index.js +23 -0
- package/src/components/popover/Popover.vue +126 -0
- package/src/components/popover/README.md +73 -0
- package/src/components/popover/index.js +17 -0
- package/src/components/progress/Progress.vue +93 -0
- package/src/components/progress/ProgressBar.vue +123 -0
- package/src/components/progress/README.md +95 -0
- package/src/components/progress/index.js +19 -0
- package/src/components/slider/README.md +120 -0
- package/src/components/slider/Slider.vue +103 -0
- package/src/components/slider/index.js +17 -0
- package/src/components/tabs/README.md +111 -0
- package/src/components/tabs/Tab.vue +132 -0
- package/src/components/tabs/Tabs.vue +290 -0
- package/src/components/tabs/_TabButton.vue +130 -0
- package/src/components/tabs/index.js +19 -0
- package/src/components/tooltip/README.md +70 -0
- package/src/components/tooltip/Tooltip.vue +115 -0
- package/src/components/tooltip/index.js +17 -0
- package/src/directives/index.js +7 -0
- package/src/directives/toggle/index.js +16 -0
- package/src/directives/toggle/toggle.js +45 -0
- package/src/directives/tooltip/README.md +42 -0
- package/src/directives/tooltip/index.js +16 -0
- package/src/directives/tooltip/meta.json +5 -0
- package/src/directives/tooltip/tooltip.js +145 -0
- package/src/index.js +27 -0
- package/src/markdown/getting-started/README.md +80 -0
- package/src/markdown/getting-started/meta.json +4 -0
- package/src/markdown/roadmap/README.md +3 -0
- package/src/markdown/roadmap/meta.json +4 -0
- package/src/mixins/checkbox-radio.mixin.js +73 -0
- package/src/mixins/root-listener.mixin.js +32 -0
- package/src/mixins/tooltip-popover.mixin.js +292 -0
- package/src/scripts/utils.js +18 -0
- package/src/utils/constants.js +191 -0
- package/src/utils/events.js +48 -0
- package/src/utils/index.js +251 -0
- package/src/utils/observer.js +56 -0
- package/src/utils/popover.class.js +91 -0
- package/src/utils/target.js +50 -0
- package/src/utils/tooltip.class.js +60 -0
- package/src/utils/tpmanager.class.js +730 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { registerComponents, vueUse } from '../../utils';
|
|
2
|
+
|
|
3
|
+
import dDropdown from './Dropdown.vue'
|
|
4
|
+
import dDropdownItem from './DropdownItem.vue'
|
|
5
|
+
import dDropdownHeader from './DropdownHeader.vue'
|
|
6
|
+
import dDropdownDivider from './DropdownDivider.vue'
|
|
7
|
+
|
|
8
|
+
const components = {
|
|
9
|
+
dDropdown,
|
|
10
|
+
dDropdownItem,
|
|
11
|
+
dDropdownHeader,
|
|
12
|
+
dDropdownDivider
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const VuePlugin = {
|
|
16
|
+
install (Vue) {
|
|
17
|
+
registerComponents(Vue, components)
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
vueUse(VuePlugin)
|
|
22
|
+
|
|
23
|
+
export default VuePlugin
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<component :is="tag"
|
|
3
|
+
:class="[
|
|
4
|
+
'embed-responsive',
|
|
5
|
+
`embed-responsive-${aspect}`
|
|
6
|
+
]">
|
|
7
|
+
<component :is="type"
|
|
8
|
+
class="embed-responsive-item"
|
|
9
|
+
v-bind="$attrs">
|
|
10
|
+
<slot />
|
|
11
|
+
</component>
|
|
12
|
+
</component>
|
|
13
|
+
</template>
|
|
14
|
+
|
|
15
|
+
<script>
|
|
16
|
+
import { EMBED_TYPES, EMBED_ASPECTS } from './../../utils/constants'
|
|
17
|
+
|
|
18
|
+
export default {
|
|
19
|
+
name: 'd-embed',
|
|
20
|
+
props: {
|
|
21
|
+
/**
|
|
22
|
+
* The embed type.
|
|
23
|
+
*/
|
|
24
|
+
type: {
|
|
25
|
+
type: String,
|
|
26
|
+
default: 'iframe',
|
|
27
|
+
validator: v => EMBED_TYPES.includes(v)
|
|
28
|
+
},
|
|
29
|
+
/**
|
|
30
|
+
* The embed tag.
|
|
31
|
+
*/
|
|
32
|
+
tag: {
|
|
33
|
+
type: String,
|
|
34
|
+
default: 'div'
|
|
35
|
+
},
|
|
36
|
+
/**
|
|
37
|
+
* The embed aspect ratio.
|
|
38
|
+
*/
|
|
39
|
+
aspect: {
|
|
40
|
+
type: String,
|
|
41
|
+
default: '16by9',
|
|
42
|
+
validator: v => EMBED_ASPECTS.includes(v)
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
</script>
|
|
47
|
+
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Embeds
|
|
2
|
+
|
|
3
|
+
Embeds allow you to create responsive video or slideshow embeds based on the width of the parent.
|
|
4
|
+
|
|
5
|
+
## Basic Example
|
|
6
|
+
|
|
7
|
+
The following embed types are supported: `iframe` (by default), `video`, `object` and `embed`.
|
|
8
|
+
|
|
9
|
+
:::demo
|
|
10
|
+
```html
|
|
11
|
+
|
|
12
|
+
<d-embed type="iframe"
|
|
13
|
+
aspect="16by9"
|
|
14
|
+
src="https://www.youtube.com/embed/zpOULjyy-n8?rel=0"
|
|
15
|
+
allowfullscreen />
|
|
16
|
+
|
|
17
|
+
<!-- embeds-1.vue -->
|
|
18
|
+
```
|
|
19
|
+
:::
|
|
20
|
+
|
|
21
|
+
## Aspect Ratios
|
|
22
|
+
|
|
23
|
+
You can also set the embed aspect ratio via the `aspect` prop. The following aspect ratios are available: `21by9`, `16by9`, `4by3`, `1by1`.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { registerComponents, vueUse } from '../../utils';
|
|
2
|
+
|
|
3
|
+
import dEmbed from './Embed.vue';
|
|
4
|
+
|
|
5
|
+
const components = {
|
|
6
|
+
dEmbed,
|
|
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,40 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<form :novalidate="novalidate ? true : false"
|
|
3
|
+
v-bind="$attrs"
|
|
4
|
+
v-on="$listeners"
|
|
5
|
+
:class="[
|
|
6
|
+
inline ? 'form-inline' : '',
|
|
7
|
+
validated ? 'was-validated' : ''
|
|
8
|
+
]">
|
|
9
|
+
<slot />
|
|
10
|
+
</form>
|
|
11
|
+
</template>
|
|
12
|
+
|
|
13
|
+
<script>
|
|
14
|
+
export default {
|
|
15
|
+
name: 'd-form',
|
|
16
|
+
props: {
|
|
17
|
+
/**
|
|
18
|
+
* Whether it should be displayed inline, or not.
|
|
19
|
+
*/
|
|
20
|
+
inline: {
|
|
21
|
+
type: Boolean,
|
|
22
|
+
default: false
|
|
23
|
+
},
|
|
24
|
+
/**
|
|
25
|
+
* Whether it is validated, or not.
|
|
26
|
+
*/
|
|
27
|
+
validated: {
|
|
28
|
+
type: Boolean,
|
|
29
|
+
default: false
|
|
30
|
+
},
|
|
31
|
+
/**
|
|
32
|
+
* Whether it should be validated, or not.
|
|
33
|
+
*/
|
|
34
|
+
novalidate: {
|
|
35
|
+
type: Boolean,
|
|
36
|
+
default: false
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
</script>
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<component :is="tag"
|
|
3
|
+
:class="[
|
|
4
|
+
`${type}-feedback`,
|
|
5
|
+
forceShow ? 'd-block' : ''
|
|
6
|
+
]">
|
|
7
|
+
<slot />
|
|
8
|
+
</component>
|
|
9
|
+
</template>
|
|
10
|
+
|
|
11
|
+
<script>
|
|
12
|
+
export default {
|
|
13
|
+
name: 'd-form-feedback',
|
|
14
|
+
props: {
|
|
15
|
+
/**
|
|
16
|
+
* The feedback tag.
|
|
17
|
+
*/
|
|
18
|
+
tag: {
|
|
19
|
+
type: String,
|
|
20
|
+
default: 'div'
|
|
21
|
+
},
|
|
22
|
+
/**
|
|
23
|
+
* The feedback type.
|
|
24
|
+
*/
|
|
25
|
+
type: {
|
|
26
|
+
type: String,
|
|
27
|
+
default: 'valid',
|
|
28
|
+
validator: v => ['valid', 'invalid'].includes(v)
|
|
29
|
+
},
|
|
30
|
+
/**
|
|
31
|
+
* Whether it should be forcefully shown, or not.
|
|
32
|
+
*/
|
|
33
|
+
forceShow: {
|
|
34
|
+
type: Boolean,
|
|
35
|
+
default: false
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
</script>
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<component :is="tag"
|
|
3
|
+
:id="id"
|
|
4
|
+
:class="[
|
|
5
|
+
'invalid-feedback',
|
|
6
|
+
forceShow ? 'd-block' : ''
|
|
7
|
+
]">
|
|
8
|
+
<slot />
|
|
9
|
+
</component>
|
|
10
|
+
</template>
|
|
11
|
+
|
|
12
|
+
<script>
|
|
13
|
+
export default {
|
|
14
|
+
name: 'd-form-invalid-feedback',
|
|
15
|
+
props: {
|
|
16
|
+
/**
|
|
17
|
+
* The element ID.
|
|
18
|
+
*/
|
|
19
|
+
id: {
|
|
20
|
+
type: String,
|
|
21
|
+
default: null
|
|
22
|
+
},
|
|
23
|
+
/**
|
|
24
|
+
* The element tag.
|
|
25
|
+
*/
|
|
26
|
+
tag: {
|
|
27
|
+
type: String,
|
|
28
|
+
default: 'div'
|
|
29
|
+
},
|
|
30
|
+
/**
|
|
31
|
+
* Whether it should be forcefully shown, or not.
|
|
32
|
+
*/
|
|
33
|
+
forceShow: {
|
|
34
|
+
type: Boolean,
|
|
35
|
+
default: false
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
</script>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<component :is="tag" class="form-row">
|
|
3
|
+
<slot />
|
|
4
|
+
</component>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script>
|
|
8
|
+
export default {
|
|
9
|
+
name: 'd-form-row',
|
|
10
|
+
props: {
|
|
11
|
+
/**
|
|
12
|
+
* The element tag.
|
|
13
|
+
*/
|
|
14
|
+
tag: {
|
|
15
|
+
type: String,
|
|
16
|
+
default: 'div'
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
</script>
|
|
21
|
+
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<component :is="tag"
|
|
3
|
+
:class="[
|
|
4
|
+
!inline ? 'form-text' : '',
|
|
5
|
+
Boolean(theme) ? `text-${theme}` : ''
|
|
6
|
+
]">
|
|
7
|
+
<slot />
|
|
8
|
+
</component>
|
|
9
|
+
</template>
|
|
10
|
+
|
|
11
|
+
<script>
|
|
12
|
+
import { THEMECOLORS } from '../../utils/constants';
|
|
13
|
+
|
|
14
|
+
export default {
|
|
15
|
+
name: 'd-form-text',
|
|
16
|
+
props: {
|
|
17
|
+
/**
|
|
18
|
+
* The element tag.
|
|
19
|
+
*/
|
|
20
|
+
tag: {
|
|
21
|
+
type: String,
|
|
22
|
+
default: 'small'
|
|
23
|
+
},
|
|
24
|
+
/**
|
|
25
|
+
* The theme color.
|
|
26
|
+
*/
|
|
27
|
+
theme: {
|
|
28
|
+
type: String,
|
|
29
|
+
default: 'secondary',
|
|
30
|
+
validator: (v) => THEMECOLORS.includes(v)
|
|
31
|
+
},
|
|
32
|
+
/**
|
|
33
|
+
* Whether it should be displayed inline, or not.
|
|
34
|
+
*/
|
|
35
|
+
inline: {
|
|
36
|
+
type: Boolean,
|
|
37
|
+
default: false
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
</script>
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<component :is="tag"
|
|
3
|
+
:id="id"
|
|
4
|
+
:class="[
|
|
5
|
+
'valid-feedback',
|
|
6
|
+
forceShow ? 'd-block' : ''
|
|
7
|
+
]">
|
|
8
|
+
<slot />
|
|
9
|
+
</component>
|
|
10
|
+
</template>
|
|
11
|
+
|
|
12
|
+
<script>
|
|
13
|
+
export default {
|
|
14
|
+
name: 'd-form-valid-feedback',
|
|
15
|
+
props: {
|
|
16
|
+
/**
|
|
17
|
+
* The element ID.
|
|
18
|
+
*/
|
|
19
|
+
id: {
|
|
20
|
+
type: String,
|
|
21
|
+
default: null
|
|
22
|
+
},
|
|
23
|
+
/**
|
|
24
|
+
* The element tag.
|
|
25
|
+
*/
|
|
26
|
+
tag: {
|
|
27
|
+
type: String,
|
|
28
|
+
default: 'div'
|
|
29
|
+
},
|
|
30
|
+
/**
|
|
31
|
+
* Whether it should be forcefully shown, or not.
|
|
32
|
+
*/
|
|
33
|
+
forceShow: {
|
|
34
|
+
type: Boolean,
|
|
35
|
+
default: false
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
</script>
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# Forms
|
|
2
|
+
|
|
3
|
+
The `<d-form>` component is a form wrapper that supports inline form styles and provides validation states.
|
|
4
|
+
|
|
5
|
+
## Inline Forms
|
|
6
|
+
|
|
7
|
+
You can create inline forms using the `inline` prop.
|
|
8
|
+
|
|
9
|
+
:::demo
|
|
10
|
+
```html
|
|
11
|
+
<d-form inline>
|
|
12
|
+
<label class="sr-only" for="f1_Username">Username</label>
|
|
13
|
+
<d-input id="f1_Username" class="mb-2 mr-sm-2 mb-sm-0" placeholder="Username" />
|
|
14
|
+
|
|
15
|
+
<label class="sr-only" for="f1_Password">Password</label>
|
|
16
|
+
<d-input id="f2_Password" class="mr-2" type="password" placeholder="Password" />
|
|
17
|
+
|
|
18
|
+
<d-button theme="primary">Register</d-button>
|
|
19
|
+
</d-form>
|
|
20
|
+
|
|
21
|
+
<!-- form-1.vue -->
|
|
22
|
+
```
|
|
23
|
+
:::
|
|
24
|
+
|
|
25
|
+
## Form Validation
|
|
26
|
+
|
|
27
|
+
The form component also provides validation states out of the box.
|
|
28
|
+
|
|
29
|
+
:::demo
|
|
30
|
+
```html
|
|
31
|
+
<template>
|
|
32
|
+
<d-form @submit="handleOnSubmit" validated>
|
|
33
|
+
|
|
34
|
+
<div class="form-group">
|
|
35
|
+
<label class="sr-only" for="f2_Email">Email Address</label>
|
|
36
|
+
<d-input id="f2_Email" class="mb-2 mr-sm-2 mb-sm-0" v-model="form.email" placeholder="email@example.com" required />
|
|
37
|
+
<d-form-invalid-feedback>Invalid email address!</d-form-invalid-feedback>
|
|
38
|
+
<d-form-valid-feedback>Your email looks good!</d-form-valid-feedback>
|
|
39
|
+
<small class="form-text text-muted">We'll never share your email with anyone else.</small>
|
|
40
|
+
</div>
|
|
41
|
+
|
|
42
|
+
<div class="form-group">
|
|
43
|
+
<label for="f2_PasswordInput" class="sr-only">Password</label>
|
|
44
|
+
<d-form-input id="f2_PasswordInput" type="password" v-model="form.password" required placeholder="Password"></d-form-input>
|
|
45
|
+
<d-form-invalid-feedback>Please provide a valid password!</d-form-invalid-feedback>
|
|
46
|
+
</div>
|
|
47
|
+
|
|
48
|
+
<div class="form-group">
|
|
49
|
+
<label for="f2_PasswordInput2" class="sr-only">Repeat Password</label>
|
|
50
|
+
<d-form-input id="f2_PasswordInput2" type="password" v-model="form.password2" required placeholder="Repeat Password"></d-form-input>
|
|
51
|
+
</div>
|
|
52
|
+
|
|
53
|
+
<div class="form-group">
|
|
54
|
+
<d-form-checkbox v-model="form.tos" value="tos_agree" unchecked-value="tos_do_not_agree">I agree with the <a href="#">Terms of Service</a></d-form-checkbox>
|
|
55
|
+
</div>
|
|
56
|
+
|
|
57
|
+
<d-button type="submit">Create Account</d-button>
|
|
58
|
+
</d-form>
|
|
59
|
+
</template>
|
|
60
|
+
|
|
61
|
+
<script>
|
|
62
|
+
export default {
|
|
63
|
+
data () {
|
|
64
|
+
return {
|
|
65
|
+
form: {
|
|
66
|
+
email: 'myemail@example.com',
|
|
67
|
+
password: '',
|
|
68
|
+
password2: '',
|
|
69
|
+
tos: 'tos_agree'
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
methods: {
|
|
74
|
+
handleOnSubmit (e) {
|
|
75
|
+
e.preventDefault();
|
|
76
|
+
alert(JSON.stringify(this.form));
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
</script>
|
|
81
|
+
|
|
82
|
+
<!-- form-2.vue -->
|
|
83
|
+
```
|
|
84
|
+
:::
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { registerComponents, vueUse } from '../../utils'
|
|
2
|
+
|
|
3
|
+
import dForm from './Form.vue'
|
|
4
|
+
import dFormRow from './FormRow.vue'
|
|
5
|
+
import dFormText from './FormText.vue'
|
|
6
|
+
import dFormFeedback from './FormFeedback.vue'
|
|
7
|
+
import dFormValidFeedback from './FormValidFeedback.vue'
|
|
8
|
+
import dFormInvalidFeedback from './FormInvalidFeedback.vue'
|
|
9
|
+
|
|
10
|
+
const components = {
|
|
11
|
+
dForm,
|
|
12
|
+
dFormRow,
|
|
13
|
+
dFormText,
|
|
14
|
+
dFormFeedback,
|
|
15
|
+
dFormValidFeedback,
|
|
16
|
+
dValidFeedback: dFormValidFeedback,
|
|
17
|
+
dFormInvalidFeedback,
|
|
18
|
+
dInvalidFeedback: dFormInvalidFeedback
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const VuePlugin = {
|
|
22
|
+
install (Vue) {
|
|
23
|
+
registerComponents(Vue, components)
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
vueUse(VuePlugin)
|
|
28
|
+
|
|
29
|
+
export default VuePlugin
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<label :class="[
|
|
3
|
+
'custom-control',
|
|
4
|
+
!toggle ? 'custom-checkbox' : 'custom-toggle',
|
|
5
|
+
toggle && toggleSmall ? 'custom-toggle-sm' : '',
|
|
6
|
+
inline ? 'custom-control-inline' : '',
|
|
7
|
+
computedStateClass
|
|
8
|
+
]">
|
|
9
|
+
<input type="checkbox"
|
|
10
|
+
ref="check"
|
|
11
|
+
autocomplete="off"
|
|
12
|
+
:aria-required="required ? 'true' : null"
|
|
13
|
+
:id="computedID"
|
|
14
|
+
:class="[ 'custom-control-input', computedStateClass ]"
|
|
15
|
+
:name="name"
|
|
16
|
+
:value="value"
|
|
17
|
+
:true-value="value"
|
|
18
|
+
:false-value="uncheckedValue"
|
|
19
|
+
:disabled="disabled"
|
|
20
|
+
:required="required"
|
|
21
|
+
v-model="computedLocalState"
|
|
22
|
+
@change="handleChange" />
|
|
23
|
+
<label :for="computedID" class="custom-control-label" aria-hidden="true"></label>
|
|
24
|
+
<span :class="['custom-control-description']">
|
|
25
|
+
<slot />
|
|
26
|
+
</span>
|
|
27
|
+
</label>
|
|
28
|
+
</template>
|
|
29
|
+
|
|
30
|
+
<script>
|
|
31
|
+
import { guid } from '../../utils'
|
|
32
|
+
|
|
33
|
+
export default {
|
|
34
|
+
name: 'd-form-checkbox',
|
|
35
|
+
model: {
|
|
36
|
+
prop: 'checked',
|
|
37
|
+
event: 'input'
|
|
38
|
+
},
|
|
39
|
+
data() {
|
|
40
|
+
return {
|
|
41
|
+
localState: this.checked
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
props: {
|
|
45
|
+
/**
|
|
46
|
+
* The checkbox input name.
|
|
47
|
+
*/
|
|
48
|
+
name: {
|
|
49
|
+
type: String
|
|
50
|
+
},
|
|
51
|
+
/**
|
|
52
|
+
* The checkbox input ID.
|
|
53
|
+
*/
|
|
54
|
+
id: {
|
|
55
|
+
type: String,
|
|
56
|
+
default: null
|
|
57
|
+
},
|
|
58
|
+
/**
|
|
59
|
+
* The checkbox input value.
|
|
60
|
+
*/
|
|
61
|
+
value: {
|
|
62
|
+
default: true
|
|
63
|
+
},
|
|
64
|
+
/**
|
|
65
|
+
* The checkbox input unchecked state value.
|
|
66
|
+
*/
|
|
67
|
+
uncheckedValue: {
|
|
68
|
+
default: false
|
|
69
|
+
},
|
|
70
|
+
/**
|
|
71
|
+
* The disabled state.
|
|
72
|
+
*/
|
|
73
|
+
disabled: {
|
|
74
|
+
type: Boolean
|
|
75
|
+
},
|
|
76
|
+
/**
|
|
77
|
+
* The required state.
|
|
78
|
+
*/
|
|
79
|
+
required: {
|
|
80
|
+
type: Boolean,
|
|
81
|
+
default: false
|
|
82
|
+
},
|
|
83
|
+
/**
|
|
84
|
+
* The checked state.
|
|
85
|
+
*/
|
|
86
|
+
checked: {
|
|
87
|
+
type: [Boolean, String, Array]
|
|
88
|
+
},
|
|
89
|
+
/**
|
|
90
|
+
* The indeterminate state.
|
|
91
|
+
*/
|
|
92
|
+
indeterminate: {
|
|
93
|
+
type: Boolean,
|
|
94
|
+
default: false
|
|
95
|
+
},
|
|
96
|
+
/**
|
|
97
|
+
* The validation state.
|
|
98
|
+
*/
|
|
99
|
+
state: {
|
|
100
|
+
type: [Boolean, String],
|
|
101
|
+
default: null
|
|
102
|
+
},
|
|
103
|
+
/**
|
|
104
|
+
* Display as toggle.
|
|
105
|
+
*/
|
|
106
|
+
toggle: {
|
|
107
|
+
type: Boolean,
|
|
108
|
+
default: false
|
|
109
|
+
},
|
|
110
|
+
/**
|
|
111
|
+
* Display as small toggle.
|
|
112
|
+
*/
|
|
113
|
+
toggleSmall: {
|
|
114
|
+
type: Boolean,
|
|
115
|
+
default: false
|
|
116
|
+
},
|
|
117
|
+
/**
|
|
118
|
+
* Whether the checkbox should be displayed inline, or not.
|
|
119
|
+
*/
|
|
120
|
+
inline: {
|
|
121
|
+
type: Boolean,
|
|
122
|
+
default: false
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
computed: {
|
|
126
|
+
computedLocalState: {
|
|
127
|
+
get() {
|
|
128
|
+
return this.localState
|
|
129
|
+
},
|
|
130
|
+
|
|
131
|
+
set(val) {
|
|
132
|
+
this.localState = val
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
computedID() {
|
|
136
|
+
return this.id || `dr-checkbox-${guid()}`
|
|
137
|
+
},
|
|
138
|
+
computedState() {
|
|
139
|
+
if (this.state === true || this.state === 'valid') {
|
|
140
|
+
return true
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
if (this.state === false || this.state === 'invalid') {
|
|
144
|
+
return false
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
return null
|
|
148
|
+
},
|
|
149
|
+
computedStateClass() {
|
|
150
|
+
if (this.computedState === true) {
|
|
151
|
+
return 'is-valid'
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
if (this.computedState === false) {
|
|
155
|
+
return 'is-invalid'
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
return null
|
|
159
|
+
}
|
|
160
|
+
},
|
|
161
|
+
watch: {
|
|
162
|
+
computedLocalState(newVal, oldVal) {
|
|
163
|
+
if (newVal == oldVal) {
|
|
164
|
+
return
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
this.$emit('input', newVal)
|
|
168
|
+
this.$emit('update:indeterminate', this.$refs.check.indeterminate)
|
|
169
|
+
},
|
|
170
|
+
|
|
171
|
+
checked(newVal, oldVal) {
|
|
172
|
+
if (newVal == oldVal) {
|
|
173
|
+
return
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
this.computedLocalState = newVal
|
|
177
|
+
},
|
|
178
|
+
|
|
179
|
+
indeterminate(newVal) {
|
|
180
|
+
this.setIndeterminate(newVal)
|
|
181
|
+
}
|
|
182
|
+
},
|
|
183
|
+
|
|
184
|
+
methods: {
|
|
185
|
+
handleChange(e) {
|
|
186
|
+
this.$emit('change', e.target.checked ? this.value : this.uncheckedValue)
|
|
187
|
+
this.$emit('update:indeterminate', this.$refs.check.indeterminate)
|
|
188
|
+
},
|
|
189
|
+
|
|
190
|
+
setIndeterminate(state) {
|
|
191
|
+
this.$refs.check.indeterminate = state
|
|
192
|
+
this.$emit('update:indeterminate', this.$refs.check.indeterminate)
|
|
193
|
+
}
|
|
194
|
+
},
|
|
195
|
+
|
|
196
|
+
mounted() {
|
|
197
|
+
this.setIndeterminate(this.indeterminate)
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
</script>
|