Skip to content

Commit

Permalink
feat(utils): wrap-up as ES6 module (#656)
Browse files Browse the repository at this point in the history
* feat (utils, mixins) wrap-up as ES6 module
* feat (utils, mixins) make use of new ES6 modules
  • Loading branch information
mosinve committed Jul 7, 2017
1 parent 7a65721 commit b5f7cfc
Show file tree
Hide file tree
Showing 26 changed files with 52 additions and 46 deletions.
2 changes: 1 addition & 1 deletion lib/components/alert.vue
Expand Up @@ -19,7 +19,7 @@
</template> </template>


<script> <script>
import warn from '../utils/warn'; import {warn} from '../utils';
export default { export default {
data() { data() {
Expand Down
2 changes: 1 addition & 1 deletion lib/components/breadcrumb.vue
Expand Up @@ -18,7 +18,7 @@
<script> <script>
import bLink from './link.vue'; import bLink from './link.vue';
import { props as linkProps } from '../mixins/link'; import { props as linkProps } from '../mixins/link';
import arrayIncludes from '../utils/arrayIncludes'; import {arrayIncludes} from '../utils';
const bLinkPropKeys = Object.keys(linkProps); const bLinkPropKeys = Object.keys(linkProps);
Expand Down
4 changes: 2 additions & 2 deletions lib/components/collapse.vue
Expand Up @@ -20,10 +20,10 @@
</style> </style>


<script> <script>
import listenOnRoot from '../mixins/listen-on-root'; import {listenOnRootMixin} from '../mixins';
export default { export default {
mixins: [listenOnRoot], mixins: [listenOnRootMixin],
data() { data() {
return { return {
show: this.visible show: this.visible
Expand Down
4 changes: 2 additions & 2 deletions lib/components/dropdown.vue
Expand Up @@ -45,11 +45,11 @@
</template> </template>


<script> <script>
import dropdown from '../mixins/dropdown'; import {dropdownMixin} from '../mixins';
import bButton from './button.vue'; import bButton from './button.vue';
export default { export default {
mixins: [dropdown], mixins: [dropdownMixin],
components: {bButton}, components: {bButton},
props: { props: {
split: { split: {
Expand Down
8 changes: 2 additions & 6 deletions lib/components/form-checkbox.vue
Expand Up @@ -21,12 +21,8 @@
</template> </template>


<script> <script>
import formMixin from '../mixins/form'; import {formMixin, formCustomMixin, formCheckBoxMixin} from '../mixins';
import formCustomMixin from '../mixins/form-custom'; import {arrayIncludes, isArray} from '../utils';
import formCheckBoxMixin from '../mixins/form-checkbox';
import arrayIncludes from '../utils/arrayIncludes';
import isArray from '../utils/isArray';
export default { export default {
mixins: [formMixin, formCustomMixin, formCheckBoxMixin], mixins: [formMixin, formCustomMixin, formCheckBoxMixin],
Expand Down
2 changes: 1 addition & 1 deletion lib/components/form-fieldset.vue
Expand Up @@ -33,7 +33,7 @@
</template> </template>


<script> <script>
import warn from '../utils/warn'; import {warn} from '../utils';
export default { export default {
data() { data() {
Expand Down
3 changes: 1 addition & 2 deletions lib/components/form-file.vue
Expand Up @@ -84,8 +84,7 @@
</style> </style>


<script> <script>
import formMixin from '../mixins/form'; import {formCustomMixin, formMixin} from '../mixins';
import formCustomMixin from '../mixins/form-custom';
export default { export default {
mixins: [formMixin, formCustomMixin], mixins: [formMixin, formCustomMixin],
Expand Down
2 changes: 1 addition & 1 deletion lib/components/form-input.vue
Expand Up @@ -30,7 +30,7 @@
</template> </template>


<script> <script>
import formMixin from '../mixins/form'; import {formMixin} from '../mixins';
import bFormInputStatic from './form-input-static.vue'; import bFormInputStatic from './form-input-static.vue';
export default { export default {
Expand Down
5 changes: 1 addition & 4 deletions lib/components/form-radio.vue
Expand Up @@ -27,10 +27,7 @@
</template> </template>


<script> <script>
import formOptionsMixin from '../mixins/form-options'; import {formOptionsMixin, formMixin, formCustomMixin, formCheckBoxMixin} from '../mixins';
import formMixin from '../mixins/form';
import formCustomMixin from '../mixins/form-custom';
import formCheckBoxMixin from '../mixins/form-checkbox';
export default { export default {
mixins: [formMixin, formCustomMixin, formCheckBoxMixin, formOptionsMixin], mixins: [formMixin, formCustomMixin, formCheckBoxMixin, formOptionsMixin],
Expand Down
6 changes: 2 additions & 4 deletions lib/components/form-select.vue
Expand Up @@ -18,12 +18,10 @@
</template> </template>


<script> <script>
import formOptions from '../mixins/form-options'; import {formMixin, formOptionsMixin, formCustomMixin} from '../mixins';
import formMixin from '../mixins/form';
import formCustomMixin from '../mixins/form-custom';
export default { export default {
mixins: [formMixin, formCustomMixin, formOptions], mixins: [formMixin, formCustomMixin, formOptionsMixin],
data() { data() {
return { return {
localValue: this.value localValue: this.value
Expand Down
2 changes: 1 addition & 1 deletion lib/components/link.vue
Expand Up @@ -31,7 +31,7 @@
</template> </template>


<script> <script>
import linkMixin from '../mixins/link'; import {linkMixin} from '../mixins';
export default { export default {
mixins: [linkMixin] mixins: [linkMixin]
Expand Down
2 changes: 1 addition & 1 deletion lib/components/list-group-item.vue
Expand Up @@ -10,7 +10,7 @@
<script> <script>
import bLink from './link.vue'; import bLink from './link.vue';
import { props as originalLinkProps, computed, omitLinkProps } from '../mixins/link'; import { props as originalLinkProps, computed, omitLinkProps } from '../mixins/link';
import arrayIncludes from '../utils/arrayIncludes'; import {arrayIncludes} from '../utils';
// copy link props, but exclude defaults for 'href', 'to', & 'tag' // copy link props, but exclude defaults for 'href', 'to', & 'tag'
// to ensure proper component tag computation // to ensure proper component tag computation
const linkProps = Object.assign(omitLinkProps('href', 'to'), { const linkProps = Object.assign(omitLinkProps('href', 'to'), {
Expand Down
4 changes: 2 additions & 2 deletions lib/components/modal.vue
Expand Up @@ -92,7 +92,7 @@


<script> <script>
import bBtn from './button.vue'; import bBtn from './button.vue';
import listenOnRoot from '../mixins/listen-on-root'; import {listenOnRootMixin} from '../mixins';
const FOCUS_SELECTOR = [ const FOCUS_SELECTOR = [
'button:not([disabled])', 'button:not([disabled])',
Expand Down Expand Up @@ -127,7 +127,7 @@
} }
export default { export default {
mixins: [listenOnRoot], mixins: [listenOnRootMixin],
components: {bBtn}, components: {bBtn},
data() { data() {
return { return {
Expand Down
4 changes: 2 additions & 2 deletions lib/components/nav-toggle.vue
Expand Up @@ -11,10 +11,10 @@
</template> </template>


<script> <script>
import listenOnRoot from '../mixins/listen-on-root'; import {listenOnRootMixin} from '../mixins';
export default { export default {
mixins: [listenOnRoot], mixins: [listenOnRootMixin],
computed: { computed: {
classObject() { classObject() {
return [ return [
Expand Down
4 changes: 2 additions & 2 deletions lib/components/popover.vue
Expand Up @@ -20,10 +20,10 @@
</template> </template>


<script> <script>
import popover from '../mixins/popover'; import {popoverMixin} from '../mixins';
export default { export default {
mixins: [popover], mixins: [popoverMixin],
props: { props: {
title: { title: {
type: String, type: String,
Expand Down
2 changes: 1 addition & 1 deletion lib/components/table.vue
Expand Up @@ -76,7 +76,7 @@
</template> </template>


<script> <script>
import warn from '../utils/warn'; import {warn} from '../utils';
const toString = v => { const toString = v => {
if (!v) { if (!v) {
Expand Down
2 changes: 1 addition & 1 deletion lib/components/tabs.vue
Expand Up @@ -52,7 +52,7 @@
</template> </template>


<script> <script>
import observeDom from '../utils/observe-dom'; import {observeDom} from '../utils';
export default { export default {
data() { data() {
Expand Down
4 changes: 2 additions & 2 deletions lib/components/tooltip.vue
Expand Up @@ -23,10 +23,10 @@
</style> </style>


<script> <script>
import popover from '../mixins/popover'; import {popoverMixin} from '../mixins';
export default { export default {
mixins: [popover], mixins: [popoverMixin],
props: { props: {
content: { content: {
type: String, type: String,
Expand Down
2 changes: 1 addition & 1 deletion lib/directives/scrollspy.js
@@ -1,4 +1,4 @@
import isArray from '../utils/isArray'; import { isArray } from '../utils';
const inBrowser = typeof window !== 'undefined'; const inBrowser = typeof window !== 'undefined';
const isServer = !inBrowser; const isServer = !inBrowser;


Expand Down
8 changes: 4 additions & 4 deletions lib/mixins/dropdown.js
@@ -1,4 +1,4 @@
import clickOut from './clickout'; import clickOutMixin from './clickout';


// Determine if an HTML element is visible - Faster than CSS check // Determine if an HTML element is visible - Faster than CSS check
function isVisible(el) { function isVisible(el) {
Expand Down Expand Up @@ -60,8 +60,8 @@ export default {
// Hide when clicked on links // Hide when clicked on links
this.$root.$on('clicked::link', listener); this.$root.$on('clicked::link', listener);
}, },
mounted: clickOut.mounted, mounted: clickOutMixin.mounted,
destroyed: clickOut.destroyed, destroyed: clickOutMixin.destroyed,
watch: { watch: {
visible(state, old) { visible(state, old) {
if (state === old) { if (state === old) {
Expand Down Expand Up @@ -98,7 +98,7 @@ export default {
} }
}, },
methods: { methods: {
...clickOut.methods, ...clickOutMixin.methods,
noop() { noop() {
// Do nothing event handler (used in visible watch) // Do nothing event handler (used in visible watch)
}, },
Expand Down
2 changes: 1 addition & 1 deletion lib/mixins/form-options.js
@@ -1,4 +1,4 @@
import isArray from '../utils/isArray'; import { isArray }from '../utils';


export default { export default {
computed: { computed: {
Expand Down
11 changes: 11 additions & 0 deletions lib/mixins/index.js
@@ -0,0 +1,11 @@
import clickOutMixin from './clickout';
import dropdownMixin from './dropdown';
import formMixin from './form';
import formCheckBoxMixin from './form-checkbox';
import formCustomMixin from './form-custom';
import formOptionsMixin from './form-options';
import linkMixin from './link';
import listenOnRootMixin from './listen-on-root';
import popoverMixin from './popover';

export {clickOutMixin, dropdownMixin, formMixin, formCheckBoxMixin, formCustomMixin, formOptionsMixin, linkMixin, listenOnRootMixin, popoverMixin};
3 changes: 1 addition & 2 deletions lib/mixins/link.js
@@ -1,5 +1,4 @@
import warn from '../utils/warn'; import {warn, arrayIncludes} from '../utils';
import arrayIncludes from '../utils/arrayIncludes';
// Props compatible with vue-router // Props compatible with vue-router
// https://github.com/vuejs/vue-router/blob/dev/src/components/link.js // https://github.com/vuejs/vue-router/blob/dev/src/components/link.js
export const props = { export const props = {
Expand Down
2 changes: 1 addition & 1 deletion lib/mixins/listen-on-root.js
@@ -1,4 +1,4 @@
import isArray from "../utils/isArray" import { isArray } from "../utils"
/** /**
* Issue #569: collapse::toggle::state triggered too many times * Issue #569: collapse::toggle::state triggered too many times
* @link https://github.com/bootstrap-vue/bootstrap-vue/issues/569 * @link https://github.com/bootstrap-vue/bootstrap-vue/issues/569
Expand Down
2 changes: 1 addition & 1 deletion lib/mixins/popover.js
@@ -1,5 +1,5 @@
import Tether from 'tether'; import Tether from 'tether';
import isArray from '../utils/isArray'; import { isArray } from '../utils';
// Controls which events are mapped for each named trigger, and the expected popover behavior for each. // Controls which events are mapped for each named trigger, and the expected popover behavior for each.
const TRIGGER_LISTENERS = { const TRIGGER_LISTENERS = {
click: {click: 'toggle'}, click: {click: 'toggle'},
Expand Down
6 changes: 6 additions & 0 deletions lib/utils/index.js
@@ -0,0 +1,6 @@
import arrayIncludes from './arrayIncludes';
import isArray from './isArray';
import observeDom from './observe-dom';
import warn from './warn';

export {arrayIncludes, isArray, observeDom, warn};

0 comments on commit b5f7cfc

Please sign in to comment.