|
1 |
| -// Import our components |
2 |
| -import FormInput from './FormInput' |
3 |
| -import FormCheckbox from './FormCheckbox' |
4 |
| -import FormRadioButtonGroup from './FormRadioButtonGroup' |
5 |
| -import FormSelect from './FormSelect' |
6 |
| -import FormSelectList from './FormSelectList' |
7 |
| -import FormTextArea from './FormTextArea' |
8 |
| -import FormDatePicker from './FormDatePicker' |
9 |
| -import FormAccordion from './FormAccordion' |
10 |
| -import FormHtmlEditor from './FormHtmlEditor' |
11 |
| -import FormHtmlViewer from './FormHtmlViewer' |
12 |
| -import FormDelayTimeControl from './FormDelayTimeControl' |
13 |
| -import FormMultiSelect from './FormMultiSelect'; |
14 |
| -import FormPlainMultiSelect from './FormPlainMultiSelect'; |
15 |
| -import RequiredAsterisk from './common/RequiredAsterisk'; |
16 |
| -import * as dateUtils from '../dateUtils'; |
| 1 | +import * as dateUtils from "../dateUtils"; |
17 | 2 |
|
18 |
| -import BFormComponent from './FormBootstrapVueComponents/BFormComponent' |
19 |
| -import BWrapperComponent from './FormBootstrapVueComponents/BWrapperComponent' |
| 3 | +export { default as FormAccordion } from "./FormAccordion.vue"; |
| 4 | +export { default as FormCheckbox } from "./FormCheckbox.vue"; |
| 5 | +export { default as FormDatePicker } from "./FormDatePicker.vue"; |
| 6 | +export { default as FormDelayTimeControl } from "./FormDelayTimeControl.vue"; |
| 7 | +export { default as FormHtmlEditor } from "./FormHtmlEditor.vue"; |
| 8 | +export { default as FormHtmlViewer } from "./FormHtmlViewer.vue"; |
| 9 | +export { default as FormInput } from "./FormInput.vue"; |
| 10 | +export { default as FormMultiSelect } from "./FormMultiSelect.vue"; |
| 11 | +export { default as FormPlainMultiSelect } from "./FormPlainMultiSelect.vue"; |
| 12 | +export { default as FormRadioButtonGroup } from "./FormRadioButtonGroup.vue"; |
| 13 | +export { default as FormSelect } from "./FormSelect.vue"; |
| 14 | +export { default as FormSelectList } from "./FormSelectList.vue"; |
| 15 | +export { default as FormTextArea } from "./FormTextArea.vue"; |
| 16 | +export * from "./common"; |
| 17 | +export * from "./FormBootstrapVueComponents"; |
| 18 | +export * from "./FormSelectList"; |
| 19 | +export * from "./mixins"; |
| 20 | +export { dateUtils }; |
20 | 21 |
|
21 |
| -// Export our components |
22 |
| -let components = { |
23 |
| - FormInput, |
24 |
| - FormCheckbox, |
25 |
| - FormRadioButtonGroup, |
26 |
| - FormSelect, |
27 |
| - FormSelectList, |
28 |
| - FormTextArea, |
29 |
| - FormDatePicker, |
30 |
| - FormAccordion, |
31 |
| - FormHtmlEditor, |
32 |
| - FormHtmlViewer, |
33 |
| - FormDelayTimeControl, |
34 |
| - FormMultiSelect, |
35 |
| - FormPlainMultiSelect, |
36 |
| - BFormComponent, |
37 |
| - BWrapperComponent, |
38 |
| -} |
| 22 | +// Export our Vue plugin as our default |
| 23 | +export default function install(Vue) { |
| 24 | + // First check to see if we're already installed |
| 25 | + if (Vue._processMakerVueFormElementsInstalled) { |
| 26 | + return; |
| 27 | + } |
39 | 28 |
|
40 |
| -// Export our named exports |
41 |
| -export { |
42 |
| - FormInput, |
43 |
| - FormCheckbox, |
44 |
| - FormRadioButtonGroup, |
45 |
| - FormSelect, |
46 |
| - FormSelectList, |
47 |
| - FormTextArea, |
48 |
| - FormDatePicker, |
49 |
| - FormAccordion, |
50 |
| - FormHtmlEditor, |
51 |
| - FormHtmlViewer, |
52 |
| - FormDelayTimeControl, |
53 |
| - FormMultiSelect, |
54 |
| - FormPlainMultiSelect, |
55 |
| - dateUtils, |
56 |
| - RequiredAsterisk, |
57 |
| - BFormComponent, |
58 |
| - BWrapperComponent, |
59 |
| -} |
| 29 | + // Boolean flag to see if we're already installed |
| 30 | + Vue._processMakerVueFormElementsInstalled = true; |
60 | 31 |
|
61 |
| -// Export our Vue plugin as our default |
62 |
| -export default { |
63 |
| - install: function (Vue) { |
64 |
| - // First check to see if we're already installed |
65 |
| - if (Vue._processMakerVueFormElementsInstalled) { |
66 |
| - return |
67 |
| - } |
| 32 | + // Register each of our components |
| 33 | + const vueComponents = require.context("./", true, /\.(vue)$/); |
| 34 | + |
| 35 | + vueComponents.keys().forEach((key) => { |
| 36 | + const component = vueComponents(key).default; |
68 | 37 |
|
69 |
| - // Boolean flag to see if we're already installed |
70 |
| - Vue._processMakerVueFormElementsInstalled = true |
| 38 | + // if a component has a name defined use the name, else use the path as the component name |
| 39 | + const name = component.name ? component.name : key.replace(/^.*[\\\/]/, "").replace(/\.[^/.]+$/, ""); |
71 | 40 |
|
72 |
| - // Register each of our components |
73 |
| - for (let component in components) { |
74 |
| - Vue.component(component, components[component]) |
75 |
| - } |
76 |
| - } |
| 41 | + Vue.component(name, component); |
| 42 | + }); |
| 43 | +} |
| 44 | + |
| 45 | +const plugin = { |
| 46 | + install |
| 47 | +}; |
| 48 | + |
| 49 | +// Auto-install when vue is found (eg. in browser via <script> tag) |
| 50 | +let GlobalVue = null; |
| 51 | +if (typeof window !== "undefined") { |
| 52 | + GlobalVue = window.Vue; |
| 53 | +} else if (typeof global !== "undefined") { |
| 54 | + GlobalVue = global.Vue; |
| 55 | +} |
| 56 | +if (GlobalVue) { |
| 57 | + GlobalVue.use(plugin); |
77 | 58 | }
|
0 commit comments