bootstrap-vue-wrapper 1.11.2 → 2.0.0

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 (35) hide show
  1. package/CHANGELOG.md +83 -0
  2. package/README.md +2 -45
  3. package/dist/bootstrap-vue-wrapper.mjs +7403 -0
  4. package/dist/bootstrap-vue-wrapper.umd.js +25 -0
  5. package/dist/components/bs-breadcrumb/BsBreadcrumb.vue.d.ts +33 -0
  6. package/dist/components/bs-checkbox/BsCheckbox.vue.d.ts +141 -0
  7. package/dist/components/bs-form/BsForm.vue.d.ts +13 -0
  8. package/dist/components/bs-input/BsInput.vue.d.ts +106 -0
  9. package/dist/components/bs-modal/BsModal.vue.d.ts +71 -0
  10. package/dist/components/bs-offcanvas/BsOffcanvas.vue.d.ts +34 -0
  11. package/dist/components/bs-paginator/BsPaginator.vue.d.ts +157 -0
  12. package/dist/components/bs-radio/BsRadio.vue.d.ts +139 -0
  13. package/dist/components/bs-select/BsSelect.vue.d.ts +139 -0
  14. package/dist/components/bs-table/BsTable.vue.d.ts +150 -0
  15. package/dist/components/bs-textarea/BsTextarea.vue.d.ts +106 -0
  16. package/dist/components/bs-toast/BsToast.vue.d.ts +18 -0
  17. package/dist/components/validator/Validator.d.ts +6 -0
  18. package/dist/index.d.ts +13 -0
  19. package/dist/style.css +1 -0
  20. package/package.json +53 -26
  21. package/src/.DS_Store +0 -0
  22. package/src/components/bs-breadcrumb/BsBreadcrumb.vue +0 -45
  23. package/src/components/bs-checkbox/BsCheckbox.vue +0 -148
  24. package/src/components/bs-form/BsForm.vue +0 -37
  25. package/src/components/bs-input/BsInput.vue +0 -92
  26. package/src/components/bs-modal/BsModal.vue +0 -90
  27. package/src/components/bs-offcanvas/BsOffcanvas.vue +0 -67
  28. package/src/components/bs-paginator/BsPaginator.vue +0 -215
  29. package/src/components/bs-radio/BsRadio.vue +0 -118
  30. package/src/components/bs-select/BsSelect.vue +0 -122
  31. package/src/components/bs-table/BsTable.vue +0 -202
  32. package/src/components/bs-textarea/BsTextarea.vue +0 -92
  33. package/src/components/bs-toast/BsToast.vue +0 -23
  34. package/src/index.js +0 -29
  35. package/src/mixins/validator.js +0 -107
@@ -1,202 +0,0 @@
1
- <template>
2
- <table class="table">
3
- <thead>
4
- <tr>
5
- <template v-for="field in fields" :key="field.key">
6
- <th
7
- :class="{
8
- 'cursor-pointer': isSortableField(field),
9
- 'text-decoration-underline': isActiveOrderBy(field.key),
10
- thClass,
11
- }"
12
- @click="onHeadClick(field)"
13
- >
14
- <slot name="tr">
15
- {{ field.label }}
16
- <i v-if="isActiveOrderBy(field.key) && this.sortDesc !== null" :class="getSortIconClass()" />
17
- </slot>
18
- </th>
19
- </template>
20
- </tr>
21
- </thead>
22
- <tbody>
23
- <tr v-if="isLoading">
24
- <td :colspan="fields.length">
25
- <slot name="loading">
26
- <div class="d-flex justify-content-center p-2">
27
- <div class="spinner-border spinner-border-sm" />
28
- </div>
29
- </slot>
30
- </td>
31
- </tr>
32
- <tr v-else-if="items.length === 0">
33
- <td :colspan="fields.length">
34
- <slot name="empty">
35
- <div v-t="'table.empty_text'" class="text-center text-muted small" />
36
- </slot>
37
- </td>
38
- </tr>
39
- <tr
40
- v-for="(item, key) in items"
41
- v-else
42
- :key="key"
43
- :class="item.trClass"
44
- >
45
- <template v-for="field in fields" :key="field.key">
46
- <td
47
- :class="tdClass"
48
- >
49
- <!-- "item" prop deprecated, its name is too general, "value" should be used instead -->
50
- <slot
51
- :key="key"
52
- name="td"
53
- :field="field.key"
54
- :row="item"
55
- :item="field.key in item ? item[field.key] : null"
56
- :value="field.key in item ? item[field.key] : null"
57
- >
58
- {{ item[field.key] }}
59
- </slot>
60
- </td>
61
- </template>
62
- </tr>
63
- </tbody>
64
- </table>
65
- </template>
66
-
67
- <script>
68
- /**
69
- * @typedef {{
70
- * key: String,
71
- * label: String,
72
- * ?sort: Boolean,
73
- * }[],
74
- * }} Field
75
- */
76
- export default {
77
- name: 'TableList',
78
- props: {
79
- /**
80
- * Field list
81
- */
82
- fields: {
83
- /** @type {{ new(): Field[] }} */
84
- type: Array,
85
- required: true,
86
- },
87
- /**
88
- * Item list
89
- */
90
- items: {
91
- type: Array,
92
- required: true,
93
- },
94
- /**
95
- * Items is loading
96
- */
97
- isLoading: {
98
- type: Boolean,
99
- default: false,
100
- },
101
- /**
102
- * Order by field name
103
- */
104
- orderBy: {
105
- type: String,
106
- default: null,
107
- },
108
- /**
109
- * Sort is descending or ascending
110
- */
111
- sortDesc: {
112
- type: Boolean,
113
- default: null,
114
- },
115
- /**
116
- * th element css lass
117
- */
118
- thClass: {
119
- type: String,
120
- default: null,
121
- },
122
- /**
123
- * td element css class
124
- */
125
- tdClass: {
126
- type: String,
127
- default: null,
128
- },
129
- },
130
- emits: ['orderChanged'],
131
- methods: {
132
- /**
133
- * Is order by active by field?
134
- *
135
- * @param field
136
- * @returns {boolean}
137
- */
138
- isActiveOrderBy(field) {
139
- return field === this.orderBy
140
- },
141
- /**
142
- * Is field sortable?
143
- *
144
- * @param field
145
- * @returns {boolean}
146
- */
147
- isSortableField(field) {
148
- return field.sort === undefined || field.sort
149
- },
150
- /**
151
- * Sort icon class.
152
- *
153
- * @returns {string}
154
- */
155
- getSortIconClass() {
156
- if (this.sortDesc === null) {
157
- throw new Error('Sort desc value is null, cannot calculate the sort icon!')
158
- }
159
-
160
- return this.sortDesc ? 'bi bi-caret-up-fill' : 'bi bi-caret-down-fill'
161
- },
162
- /**
163
- * Calcuate sort desc value on click
164
- * Returns null if there is no sortDesc value.
165
- */
166
- calcSortDesc(field) {
167
- if (this.sortDesc === null) {
168
- return null
169
- }
170
-
171
- if (!this.isOrderByChanged(field)) {
172
- // if the given order is already active, the sort will be the opposite
173
- return !this.sortDesc
174
- }
175
-
176
- return false // default (first click) sort is ASC
177
- },
178
- /**
179
- * Is order by changed?
180
- */
181
- isOrderByChanged(field) {
182
- return this.orderBy !== field
183
- },
184
- /**
185
- * Table head clicked.
186
- */
187
- onHeadClick(field) {
188
- if (!this.isSortableField(field)) {
189
- return
190
- }
191
-
192
- this.$emit('orderChanged', { sortDesc: this.calcSortDesc(field.key), orderBy: field.key })
193
- },
194
- },
195
- }
196
- </script>
197
-
198
- <style lang="scss" scoped>
199
- .cursor-pointer {
200
- cursor: pointer;
201
- }
202
- </style>
@@ -1,92 +0,0 @@
1
- <template>
2
- <label
3
- v-if="label !== null"
4
- :for="id"
5
- class="form-label"
6
- v-text="label"
7
- />
8
- <textarea
9
- :id="id"
10
- ref="inputRef"
11
- :value="modelValue"
12
- v-bind="$attrs"
13
- class="form-control"
14
- :aria-describedby="hint !== null ? getHintId() : null"
15
- @input="onInput"
16
- @invalid="onInvalid"
17
- />
18
- <div
19
- v-if="invalidMessage !== null && !hideValidationMessage"
20
- class="invalid-feedback"
21
- v-text="invalidMessage"
22
- />
23
- <div
24
- v-if="hint !== null"
25
- :id="getHintId()"
26
- class="form-text"
27
- v-text="hint"
28
- />
29
- </template>
30
-
31
- <script>
32
- import validator from '../../mixins/validator.js'
33
-
34
- export default {
35
- name: 'BsTextarea',
36
- mixins: [validator],
37
- props: {
38
- /**
39
- * Value for v-model
40
- */
41
- modelValue: {
42
- type: [String, Number],
43
- default: null,
44
- },
45
- /**
46
- * Html id
47
- */
48
- id: {
49
- type: String,
50
- required: true,
51
- },
52
- /**
53
- * Label for textarea
54
- */
55
- label: {
56
- type: String,
57
- default: null,
58
- },
59
- /**
60
- * Attribute hint
61
- */
62
- hint: {
63
- type: String,
64
- default: null,
65
- },
66
- /**
67
- * If this is true the validation message does not appear.
68
- */
69
- hideValidationMessage: {
70
- type: Boolean,
71
- default: false,
72
- },
73
- },
74
- emits: ['update:modelValue'],
75
- methods: {
76
- /**
77
- * Hint id is generated
78
- */
79
- getHintId() {
80
- return this.id + 'Hint'
81
- },
82
- /**
83
- * On input event
84
- *
85
- * @param event
86
- */
87
- onInput(event) {
88
- this.$emit('update:modelValue', event.target.value)
89
- },
90
- },
91
- }
92
- </script>
@@ -1,23 +0,0 @@
1
- <template>
2
- <div
3
- ref="toastRef"
4
- class="toast hide"
5
- role="alert"
6
- aria-live="assertive"
7
- aria-atomic="true"
8
- >
9
- <slot />
10
- </div>
11
- </template>
12
-
13
- <script>
14
- import { Toast } from 'bootstrap'
15
-
16
- export default {
17
- name: 'BsToast',
18
- mounted() {
19
- const toastElement = this.$refs.toastRef
20
- Toast.getOrCreateInstance(toastElement).show()
21
- },
22
- }
23
- </script>
package/src/index.js DELETED
@@ -1,29 +0,0 @@
1
- import BsBreadcrumb from './components/bs-breadcrumb/BsBreadcrumb.vue'
2
- import BsForm from './components/bs-form/BsForm.vue'
3
- import BsInput from './components/bs-input/BsInput.vue'
4
- import BsCheckbox from './components/bs-checkbox/BsCheckbox.vue'
5
- import BsTextarea from './components/bs-textarea/BsTextarea.vue'
6
- import BsPaginator from './components/bs-paginator/BsPaginator.vue'
7
- import BsTable from './components/bs-table/BsTable.vue'
8
- import BsToast from './components/bs-toast/BsToast.vue'
9
- import BsModal from './components/bs-modal/BsModal.vue'
10
- import BsSelect from './components/bs-select/BsSelect.vue'
11
- import BsRadio from './components/bs-radio/BsRadio.vue'
12
- import BsOffcanvas from './components/bs-offcanvas/BsOffcanvas.vue'
13
- import Validator from './mixins/validator.js'
14
-
15
- export {
16
- BsBreadcrumb,
17
- BsForm,
18
- BsInput,
19
- BsCheckbox,
20
- BsTextarea,
21
- BsPaginator,
22
- BsTable,
23
- BsToast,
24
- BsModal,
25
- BsSelect,
26
- BsRadio,
27
- Validator,
28
- BsOffcanvas,
29
- }
@@ -1,107 +0,0 @@
1
- export default {
2
- name: 'Validator',
3
- data() {
4
- return {
5
- /**
6
- * Invalid message
7
- */
8
- invalidMessage: null,
9
- }
10
- },
11
- emits: ['invalid'],
12
- methods: {
13
- /**
14
- * On invalid event.
15
- *
16
- * @param event
17
- */
18
- onInvalid(event) {
19
- this.invalidMessage = this.getInvalidMessage(event.target)
20
- this.$emit('invalid', this.invalidMessage)
21
- },
22
- /**
23
- * Set custom error
24
- *
25
- * Use in parent component, e.g.: this.$refs.emailInputRef.setCustomError('Email is already taken.')
26
- *
27
- * @param data
28
- */
29
- setCustomError(data) {
30
- const validationTarget = this.$refs.inputRef
31
-
32
- if (data !== null) {
33
- validationTarget.setCustomValidity(data)
34
- validationTarget.classList.add('is-invalid')
35
- } else {
36
- validationTarget.setCustomValidity('')
37
- validationTarget.classList.remove('is-invalid')
38
- }
39
-
40
- this.invalidMessage = this.getInvalidMessage(validationTarget)
41
- this.$emit('invalid', this.invalidMessage)
42
- },
43
- /**
44
- * Return invalid message.
45
- *
46
- * @param input
47
- * @returns {string|null}
48
- */
49
- getInvalidMessage(input) {
50
- if (input.validity.valueMissing) {
51
- return this.$t('validator.error.value_missing')
52
- }
53
-
54
- if (input.validity.tooShort) {
55
- return this.$t('validator.error.too_short', [input.minLength])
56
- }
57
-
58
- if (input.validity.tooLong) {
59
- return this.$t('validator.error.too_long', [input.maxLength])
60
- }
61
-
62
- if (input.validity.rangeUnderflow) {
63
- return this.$t('validator.error.range_underflow', [input.min])
64
- }
65
-
66
- if (input.validity.rangeOverflow) {
67
- return this.$t('validator.error.range_overflow', [input.max])
68
- }
69
-
70
- if (input.validity.typeMismatch) {
71
- if (input.type === 'email') {
72
- return this.$t('validator.error.type_mismatch.email')
73
- }
74
-
75
- if (input.type === 'url') {
76
- return this.$t('validator.error.type_mismatch.url')
77
- }
78
- }
79
-
80
- if (input.validity.badInput) {
81
- if (input.type === 'number') {
82
- return this.$t('validator.error.bad_input.number')
83
- }
84
- if (input.type === 'date') {
85
- return this.$t('validator.error.bad_input.date')
86
- }
87
- }
88
-
89
- if (input.validity.patternMismatch) {
90
- return this.$t('validator.error.pattern_mismatch')
91
- }
92
-
93
- if (input.validity.stepMismatch) {
94
- const nearestMin = Math.floor(input.value / input.step) * input.step
95
- const nearestMax = Math.ceil(input.value / input.step) * input.step
96
-
97
- return this.$t('validator.error.step_mismatch', [nearestMin, nearestMax])
98
- }
99
-
100
- if (input.validity.customError) {
101
- return input.validationMessage
102
- }
103
-
104
- return null
105
- },
106
- },
107
- }