@gitlab/ui 96.3.0 → 97.1.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 (101) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/dist/components/base/alert/alert.js +1 -1
  3. package/dist/components/base/avatar/avatar.js +4 -4
  4. package/dist/components/base/datepicker/datepicker.js +1 -1
  5. package/dist/components/base/drawer/drawer.js +1 -1
  6. package/dist/components/base/form/form_input/form_input.js +3 -3
  7. package/dist/components/base/form/form_select/form_select.js +3 -3
  8. package/dist/components/base/progress_bar/progress_bar.js +47 -5
  9. package/dist/components/base/toast/toast.js +1 -1
  10. package/dist/components/base/toggle/toggle.js +1 -1
  11. package/dist/components/base/token/token.js +1 -1
  12. package/dist/components/base/token_selector/token_selector.js +17 -7
  13. package/dist/index.css +2 -2
  14. package/dist/index.css.map +1 -1
  15. package/dist/tailwind.css +1 -1
  16. package/dist/tailwind.css.map +1 -1
  17. package/dist/tokens/build/js/tokens.dark.js +2 -1
  18. package/dist/tokens/build/js/tokens.js +2 -1
  19. package/dist/tokens/css/tokens.css +1 -0
  20. package/dist/tokens/css/tokens.dark.css +1 -0
  21. package/dist/tokens/js/tokens.dark.js +1 -0
  22. package/dist/tokens/js/tokens.js +1 -0
  23. package/dist/tokens/json/tokens.dark.json +35 -0
  24. package/dist/tokens/json/tokens.json +35 -0
  25. package/dist/tokens/scss/_tokens.dark.scss +1 -0
  26. package/dist/tokens/scss/_tokens.scss +1 -0
  27. package/dist/tokens/scss/_tokens_custom_properties.scss +1 -0
  28. package/dist/utils/number_utils.js +9 -1
  29. package/dist/vendor/bootstrap-vue/src/constants/components.js +1 -3
  30. package/dist/vendor/bootstrap-vue/src/index.js +0 -2
  31. package/package.json +7 -7
  32. package/src/components/base/alert/alert.vue +1 -1
  33. package/src/components/base/avatar/avatar.vue +4 -4
  34. package/src/components/base/datepicker/datepicker.vue +1 -1
  35. package/src/components/base/drawer/drawer.vue +1 -1
  36. package/src/components/base/form/form_input/form_input.scss +1 -2
  37. package/src/components/base/form/form_input/form_input.vue +3 -3
  38. package/src/components/base/form/form_select/form_select.vue +3 -3
  39. package/src/components/base/modal/modal.scss +1 -2
  40. package/src/components/base/progress_bar/progress_bar.md +25 -0
  41. package/src/components/base/progress_bar/progress_bar.scss +11 -0
  42. package/src/components/base/progress_bar/progress_bar.vue +54 -5
  43. package/src/components/base/toast/toast.js +1 -1
  44. package/src/components/base/toggle/toggle.scss +28 -7
  45. package/src/components/base/toggle/toggle.vue +1 -0
  46. package/src/components/base/token/token.vue +1 -1
  47. package/src/components/base/token_selector/token_selector.scss +8 -3
  48. package/src/components/base/token_selector/token_selector.vue +17 -9
  49. package/src/tokens/build/css/tokens.css +1 -0
  50. package/src/tokens/build/css/tokens.dark.css +1 -0
  51. package/src/tokens/build/js/tokens.dark.js +1 -0
  52. package/src/tokens/build/js/tokens.js +1 -0
  53. package/src/tokens/build/json/tokens.dark.json +35 -0
  54. package/src/tokens/build/json/tokens.json +35 -0
  55. package/src/tokens/build/scss/_tokens.dark.scss +1 -0
  56. package/src/tokens/build/scss/_tokens.scss +1 -0
  57. package/src/tokens/build/scss/_tokens_custom_properties.scss +1 -0
  58. package/src/tokens/contextual/token-selector.tokens.json +20 -0
  59. package/src/utils/number_utils.js +7 -0
  60. package/src/vendor/bootstrap-vue/package.json +3 -42
  61. package/src/vendor/bootstrap-vue/src/components/badge/README.md +2 -2
  62. package/src/vendor/bootstrap-vue/src/components/breadcrumb/README.md +2 -2
  63. package/src/vendor/bootstrap-vue/src/components/button/README.md +7 -9
  64. package/src/vendor/bootstrap-vue/src/components/button-group/README.md +0 -5
  65. package/src/vendor/bootstrap-vue/src/components/collapse/README.md +2 -2
  66. package/src/vendor/bootstrap-vue/src/components/dropdown/README.md +5 -5
  67. package/src/vendor/bootstrap-vue/src/components/form/README.md +21 -26
  68. package/src/vendor/bootstrap-vue/src/components/form-checkbox/README.md +6 -6
  69. package/src/vendor/bootstrap-vue/src/components/form-group/README.md +6 -4
  70. package/src/vendor/bootstrap-vue/src/components/form-input/README.md +4 -4
  71. package/src/vendor/bootstrap-vue/src/components/form-radio/README.md +1 -1
  72. package/src/vendor/bootstrap-vue/src/components/index.d.ts +0 -1
  73. package/src/vendor/bootstrap-vue/src/components/input-group/README.md +4 -9
  74. package/src/vendor/bootstrap-vue/src/components/layout/README.md +3 -3
  75. package/src/vendor/bootstrap-vue/src/components/link/README.md +1 -1
  76. package/src/vendor/bootstrap-vue/src/components/modal/README.md +2 -2
  77. package/src/vendor/bootstrap-vue/src/components/nav/README.md +13 -14
  78. package/src/vendor/bootstrap-vue/src/components/navbar/README.md +5 -6
  79. package/src/vendor/bootstrap-vue/src/components/popover/README.md +4 -4
  80. package/src/vendor/bootstrap-vue/src/components/table/README.md +5 -5
  81. package/src/vendor/bootstrap-vue/src/components/tabs/README.md +2 -2
  82. package/src/vendor/bootstrap-vue/src/components/toast/README.md +5 -5
  83. package/src/vendor/bootstrap-vue/src/components/tooltip/README.md +4 -4
  84. package/src/vendor/bootstrap-vue/src/constants/components.js +0 -2
  85. package/src/vendor/bootstrap-vue/src/directives/toggle/README.md +5 -6
  86. package/src/vendor/bootstrap-vue/src/directives/tooltip/README.md +2 -2
  87. package/src/vendor/bootstrap-vue/src/index.js +0 -4
  88. package/dist/vendor/bootstrap-vue/src/components/progress/index.js +0 -2
  89. package/dist/vendor/bootstrap-vue/src/components/progress/progress-bar.js +0 -128
  90. package/dist/vendor/bootstrap-vue/src/components/progress/progress.js +0 -56
  91. package/src/vendor/bootstrap-vue/nuxt/index.js +0 -164
  92. package/src/vendor/bootstrap-vue/nuxt/plugin.template.js +0 -29
  93. package/src/vendor/bootstrap-vue/src/components/progress/MODIFICATIONS.md +0 -23
  94. package/src/vendor/bootstrap-vue/src/components/progress/README.md +0 -363
  95. package/src/vendor/bootstrap-vue/src/components/progress/index.d.ts +0 -10
  96. package/src/vendor/bootstrap-vue/src/components/progress/index.js +0 -4
  97. package/src/vendor/bootstrap-vue/src/components/progress/package.json +0 -109
  98. package/src/vendor/bootstrap-vue/src/components/progress/progress-bar.js +0 -133
  99. package/src/vendor/bootstrap-vue/src/components/progress/progress-bar.spec.js +0 -270
  100. package/src/vendor/bootstrap-vue/src/components/progress/progress.js +0 -57
  101. package/src/vendor/bootstrap-vue/src/components/progress/progress.spec.js +0 -71
@@ -1,363 +0,0 @@
1
- # Progress
2
-
3
- > Use our custom progress component for displaying simple or complex progress bars, featuring
4
- > support for horizontally stacked bars, animated backgrounds, and text labels.
5
-
6
- ```html
7
- <template>
8
- <div>
9
- <b-progress :value="value" :max="max" show-progress animated></b-progress>
10
- <b-progress class="mt-2" :max="max" show-value>
11
- <b-progress-bar :value="value * (6 / 10)" variant="success"></b-progress-bar>
12
- <b-progress-bar :value="value * (2.5 / 10)" variant="warning"></b-progress-bar>
13
- <b-progress-bar :value="value * (1.5 / 10)" variant="danger"></b-progress-bar>
14
- </b-progress>
15
-
16
- <b-button class="mt-3" @click="randomValue">Click me</b-button>
17
- </div>
18
- </template>
19
-
20
- <script>
21
- export default {
22
- data() {
23
- return {
24
- value: 45,
25
- max: 100
26
- }
27
- },
28
- methods: {
29
- randomValue() {
30
- this.value = Math.random() * this.max
31
- }
32
- }
33
- }
34
- </script>
35
-
36
- <!-- b-progress.vue -->
37
- ```
38
-
39
- ## Value
40
-
41
- Set the maximum value with the `max` prop (default is `100`), and the current value via the `value`
42
- prop (default `0`).
43
-
44
- When creating multiple bars in a single process, place the value prop on the individual
45
- `<b-progress-bar>` sub components (see the **Multiple Bars** section below for more details)
46
-
47
- ## Labels
48
-
49
- Add labels to your progress bars by either enabling `show-progress` (percentage of max) or
50
- `show-value`for the current absolute value. You may also set the precision (number of digits after
51
- the decimal) via the `precision` prop (default is `0`digits after the decimal).
52
-
53
- ```html
54
- <template>
55
- <div>
56
- <h5>No label</h5>
57
- <b-progress :value="value" :max="max" class="mb-3"></b-progress>
58
-
59
- <h5>Value label</h5>
60
- <b-progress :value="value" :max="max" show-value class="mb-3"></b-progress>
61
-
62
- <h5>Progress label</h5>
63
- <b-progress :value="value" :max="max" show-progress class="mb-3"></b-progress>
64
-
65
- <h5>Value label with precision</h5>
66
- <b-progress :value="value" :max="max" :precision="2" show-value class="mb-3"></b-progress>
67
-
68
- <h5>Progress label with precision</h5>
69
- <b-progress :value="value" :max="max" :precision="2" show-progress class="mb-3"></b-progress>
70
- </div>
71
- </template>
72
-
73
- <script>
74
- export default {
75
- data() {
76
- return {
77
- value: 33.333333333,
78
- max: 50
79
- }
80
- }
81
- }
82
- </script>
83
-
84
- <!-- b-progress-labels.vue -->
85
- ```
86
-
87
- ### Custom progress label
88
-
89
- Need more control over the label? Provide your own label by using the default slot within a
90
- `<b-progress-bar>` sub-component, or by using the `label` or `label-html` property on
91
- `<b-progress-bar>`:
92
-
93
- ```html
94
- <template>
95
- <div>
96
- <h5>Custom label via default slot</h5>
97
- <b-progress :max="max" height="2rem">
98
- <b-progress-bar :value="value">
99
- <span>Progress: <strong>{{ value.toFixed(2) }} / {{ max }}</strong></span>
100
- </b-progress-bar>
101
- </b-progress>
102
-
103
- <h5 class="mt-3">Custom label via property</h5>
104
- <b-progress :max="max">
105
- <b-progress-bar :value="value" :label="`${((value / max) * 100).toFixed(2)}%`"></b-progress-bar>
106
- </b-progress>
107
-
108
- <h5 class="mt-3">Custom label via property (HTML support)</h5>
109
- <b-progress :max="max">
110
- <b-progress-bar :value="value" :label-html="`<del>${value}</del>`"></b-progress-bar>
111
- </b-progress>
112
- </div>
113
- </template>
114
-
115
- <script>
116
- export default {
117
- data() {
118
- return {
119
- value: 33.333333333,
120
- max: 50
121
- }
122
- }
123
- }
124
- </script>
125
-
126
- <!-- b-progress-custom-labels.vue -->
127
- ```
128
-
129
- Precedence order for label methods (top-most has precedence):
130
-
131
- - default slot of `<b-progress-bar>`
132
- - `label` prop of `<b-progress-bar>`
133
- - `show-progress` prop of `<b-progress-bar>`
134
- - `show-value` prop of `<b-progress-bar>`
135
- - `show-progress` prop of `<b-progress>`
136
- - `show-value` prop of `<b-progress>`
137
- - no label
138
-
139
- ## Width and height
140
-
141
- `<b-progress>` will always expand to the maximum with of its parent container. To change the width,
142
- place `<b-progress>` in a standard Bootstrap column or apply one of the standard Bootstrap width
143
- classes.
144
-
145
- ```html
146
- <template>
147
- <div>
148
- <h5>Default width</h5>
149
- <b-progress :value="value" class="mb-3"></b-progress>
150
-
151
- <h5>Custom widths</h5>
152
- <b-progress :value="value" class="w-75 mb-2"></b-progress>
153
- <b-progress :value="value" class="w-50 mb-2"></b-progress>
154
- <b-progress :value="value" class="w-25"></b-progress>
155
- </div>
156
- </template>
157
-
158
- <script>
159
- export default {
160
- data() {
161
- return {
162
- value: 75
163
- }
164
- }
165
- }
166
- </script>
167
-
168
- <!-- b-progress-width.vue -->
169
- ```
170
-
171
- The height of the progress bar can be controlled with the `height` prop. The height value should be
172
- a standard CSS dimension (`px`, `rem`, `em`, etc.). The default height is `1rem`.
173
-
174
- ```html
175
- <template>
176
- <div>
177
- <h5>Default height</h5>
178
- <b-progress :value="value" show-progress class="mb-3"></b-progress>
179
-
180
- <h5>Custom heights</h5>
181
- <b-progress height="2rem" :value="value" show-progress class="mb-2"></b-progress>
182
- <b-progress height="20px" :value="value" show-progress class="mb-2"></b-progress>
183
- <b-progress height="2px" :value="value"></b-progress>
184
- </div>
185
- </template>
186
-
187
- <script>
188
- export default {
189
- data() {
190
- return {
191
- value: 75
192
- }
193
- }
194
- }
195
- </script>
196
-
197
- <!-- b-progress-height.vue -->
198
- ```
199
-
200
- ## Backgrounds
201
-
202
- Use background variants to change the appearance of individual progress bars. The default variant is
203
- `primary`.
204
-
205
- ### Solid background variants
206
-
207
- ```html
208
- <template>
209
- <div>
210
- <div v-for="bar in bars" class="row mb-1">
211
- <div class="col-sm-2">{{ bar.variant }}:</div>
212
- <div class="col-sm-10 pt-1">
213
- <b-progress :value="bar.value" :variant="bar.variant" :key="bar.variant"></b-progress>
214
- </div>
215
- </div>
216
- </div>
217
- </template>
218
-
219
- <script>
220
- export default {
221
- data() {
222
- return {
223
- bars: [
224
- { variant: 'success', value: 75 },
225
- { variant: 'warning', value: 75 },
226
- { variant: 'danger', value: 75 },
227
- { variant: 'primary', value: 75 },
228
- ],
229
- timer: null
230
- }
231
- },
232
- mounted() {
233
- this.timer = setInterval(() => {
234
- this.bars.forEach(bar => (bar.value = 25 + Math.random() * 75))
235
- }, 2000)
236
- },
237
- beforeDestroy() {
238
- clearInterval(this.timer)
239
- this.timer = null
240
- }
241
- }
242
- </script>
243
-
244
- <!-- b-progress-backgrounds.vue -->
245
- ```
246
-
247
- ### Striped backgrounds
248
-
249
- Set `striped` to apply a stripe via CSS gradient over the progress bar's background variant.
250
-
251
- ```html
252
- <template>
253
- <div>
254
- <b-progress :value="25" variant="success" :striped="striped"></b-progress>
255
- <b-progress :value="75" variant="warning" :striped="striped" class="mt-2"></b-progress>
256
- <b-progress :value="100" variant="danger" :striped="striped" class="mt-2"></b-progress>
257
- </div>
258
- </template>
259
-
260
- <script>
261
- export default {
262
- data() {
263
- return {
264
- striped: true
265
- }
266
- }
267
- }
268
- </script>
269
-
270
- <!-- b-progress-striped.vue -->
271
- ```
272
-
273
- ### Animated backgrounds
274
-
275
- The striped gradient can also be animated by setting the `animated`prop.
276
-
277
- ```html
278
- <template>
279
- <div>
280
- <b-progress :value="25" variant="success" striped :animated="animate"></b-progress>
281
- <b-progress :value="75" variant="warning" striped :animated="animate" class="mt-2"></b-progress>
282
- <b-progress :value="100" variant="danger" :animated="animate" class="mt-3"></b-progress>
283
- </div>
284
- </template>
285
-
286
- <script>
287
- export default {
288
- data() {
289
- return {
290
- animate: true
291
- }
292
- }
293
- }
294
- </script>
295
-
296
- <!-- b-progress-animated.vue -->
297
- ```
298
-
299
- Notes:
300
-
301
- - if `animated` is true, `striped` will automatically be enabled.
302
- - Animated progress bars don't work in Opera 12 — as they don't support CSS3 animations.
303
- - The animation effect of this component is dependent on the `prefers-reduced-motion` media query.
304
- See the [reduced motion section of our accessibility documentation](/docs/reference/accessibility)
305
- for additional details.
306
-
307
- ## Multiple bars
308
-
309
- Include multiple `<b-progress-bar>` sub-components in a `<b-progress>` component to build a
310
- horizontally stacked set of progress bars.
311
-
312
- ```html
313
- <template>
314
- <div>
315
- <b-progress :max="max" class="mb-3">
316
- <b-progress-bar variant="primary" :value="values[0]"></b-progress-bar>
317
- <b-progress-bar variant="success" :value="values[1]"></b-progress-bar>
318
- <b-progress-bar variant="danger" :value="values[2]"></b-progress-bar>
319
- </b-progress>
320
-
321
- <b-progress show-progress :max="max" class="mb-3">
322
- <b-progress-bar variant="primary" :value="values[0]"></b-progress-bar>
323
- <b-progress-bar variant="success" :value="values[1]"></b-progress-bar>
324
- <b-progress-bar variant="danger" :value="values[2]"></b-progress-bar>
325
- </b-progress>
326
-
327
- <b-progress show-value striped :max="max" class="mb-3">
328
- <b-progress-bar variant="primary" :value="values[0]"></b-progress-bar>
329
- <b-progress-bar variant="success" :value="values[1]"></b-progress-bar>
330
- <b-progress-bar variant="danger" :value="values[2]"></b-progress-bar>
331
- </b-progress>
332
-
333
- <b-progress :max="max">
334
- <b-progress-bar variant="primary" :value="values[0]" show-progress></b-progress-bar>
335
- <b-progress-bar variant="success" :value="values[1]" animated show-progress></b-progress-bar>
336
- <b-progress-bar variant="danger" :value="values[2]" striped show-progress></b-progress-bar>
337
- </b-progress>
338
- </div>
339
- </template>
340
-
341
- <script>
342
- export default {
343
- data() {
344
- return {
345
- values: [15, 30, 20],
346
- max: 100
347
- }
348
- }
349
- }
350
- </script>
351
-
352
- <!-- b-progress-multiple.vue -->
353
- ```
354
-
355
- `<b-progress-bar>` will inherit most of the props from the `<b-progress>` parent component, but you
356
- can override any of the props by setting them on the `<b-progress-bar>`
357
-
358
- Notes:
359
-
360
- - `height`, if specified, should always set on the `<b-progress>` component.
361
- - `<b-progress-bar>` will not inherit `value` from `<b-progress>`.
362
-
363
- <!-- Component reference added automatically from component package.json -->
@@ -1,10 +0,0 @@
1
- //
2
- // Progress
3
- //
4
- import { BvComponent } from '../../'
5
-
6
- // Component: b-progress
7
- export declare class BProgress extends BvComponent {}
8
-
9
- // Component: b-progress-bar
10
- export declare class BProgressBar extends BvComponent {}
@@ -1,4 +0,0 @@
1
- import { BProgress } from './progress'
2
- import { BProgressBar } from './progress-bar'
3
-
4
- export { BProgress, BProgressBar }
@@ -1,109 +0,0 @@
1
- {
2
- "name": "@bootstrap-vue/progress",
3
- "version": "1.0.0",
4
- "meta": {
5
- "title": "Progress",
6
- "description": "A custom progress component for displaying simple or complex progress bars, featuring support for horizontally stacked bars, animated backgrounds, and text labels.",
7
- "components": [
8
- {
9
- "component": "BProgress",
10
- "props": [
11
- {
12
- "prop": "animated",
13
- "description": "Enable the animated background. Also automatically sets 'striped'"
14
- },
15
- {
16
- "prop": "height",
17
- "description": "Override the default height by specifying a CSS height value (including units)"
18
- },
19
- {
20
- "prop": "max",
21
- "description": "Set the maximum value"
22
- },
23
- {
24
- "prop": "precision",
25
- "description": "The number of digits after the decimal to round the value to"
26
- },
27
- {
28
- "prop": "showProgress",
29
- "description": "Displays the current progress value as a percentage"
30
- },
31
- {
32
- "prop": "showValue",
33
- "description": "Displays the current progress value"
34
- },
35
- {
36
- "prop": "striped",
37
- "description": "Enable the striped background"
38
- },
39
- {
40
- "prop": "value",
41
- "description": "The current value of the progress bar"
42
- },
43
- {
44
- "prop": "variant",
45
- "description": "Applies one of the Bootstrap theme color variants to the component"
46
- }
47
- ],
48
- "slots": [
49
- {
50
- "name": "default",
51
- "description": "Content (progress bars) to place in the progress element"
52
- }
53
- ]
54
- },
55
- {
56
- "component": "BProgressBar",
57
- "props": [
58
- {
59
- "prop": "animated",
60
- "description": "Enable the animated background. Also automatically sets 'striped'"
61
- },
62
- {
63
- "prop": "label",
64
- "description": "Text string to explicitly set the label as"
65
- },
66
- {
67
- "prop": "labelHtml",
68
- "description": "HTML string to explicitly set the label as",
69
- "xss": true
70
- },
71
- {
72
- "prop": "max",
73
- "description": "Set the maximum value"
74
- },
75
- {
76
- "prop": "precision",
77
- "description": "The number of digits after the decimal to round the value to"
78
- },
79
- {
80
- "prop": "showProgress",
81
- "description": "Displays the current progress value as a percentage"
82
- },
83
- {
84
- "prop": "showValue",
85
- "description": "Displays the current progress value"
86
- },
87
- {
88
- "prop": "striped",
89
- "description": "Enable the striped background"
90
- },
91
- {
92
- "prop": "value",
93
- "description": "The current value of the progress bar"
94
- },
95
- {
96
- "prop": "variant",
97
- "description": "Applies one of the Bootstrap theme color variants to the component"
98
- }
99
- ],
100
- "slots": [
101
- {
102
- "name": "default",
103
- "description": "Content to place in the progress bar. Overrides the `label`, `label-html`, `show-progress` and `show-value` props"
104
- }
105
- ]
106
- }
107
- ]
108
- }
109
- }
@@ -1,133 +0,0 @@
1
- import { extend } from '../../vue'
2
- import { NAME_PROGRESS_BAR } from '../../constants/components'
3
- import { PROP_TYPE_BOOLEAN, PROP_TYPE_NUMBER_STRING, PROP_TYPE_STRING } from '../../constants/props'
4
- import { htmlOrText } from '../../utils/html'
5
- import { isBoolean } from '../../utils/inspect'
6
- import { mathMax, mathPow } from '../../utils/math'
7
- import { toFixed, toFloat, toInteger } from '../../utils/number'
8
- import { makeProp, makePropsConfigurable } from '../../utils/props'
9
- import { toString } from '../../utils/string'
10
- import { normalizeSlotMixin } from '../../mixins/normalize-slot'
11
-
12
- // --- Props ---
13
-
14
- export const props = makePropsConfigurable(
15
- {
16
- animated: makeProp(PROP_TYPE_BOOLEAN, null),
17
- label: makeProp(PROP_TYPE_STRING),
18
- labelHtml: makeProp(PROP_TYPE_STRING),
19
- max: makeProp(PROP_TYPE_NUMBER_STRING, null),
20
- precision: makeProp(PROP_TYPE_NUMBER_STRING, null),
21
- showProgress: makeProp(PROP_TYPE_BOOLEAN, null),
22
- showValue: makeProp(PROP_TYPE_BOOLEAN, null),
23
- striped: makeProp(PROP_TYPE_BOOLEAN, null),
24
- value: makeProp(PROP_TYPE_NUMBER_STRING, 0),
25
- variant: makeProp(PROP_TYPE_STRING)
26
- },
27
- NAME_PROGRESS_BAR
28
- )
29
-
30
- // --- Main component ---
31
-
32
- // @vue/component
33
- export const BProgressBar = /*#__PURE__*/ extend({
34
- name: NAME_PROGRESS_BAR,
35
- mixins: [normalizeSlotMixin],
36
- inject: {
37
- getBvProgress: {
38
- default: /* istanbul ignore next */ () => () => ({})
39
- }
40
- },
41
- props,
42
- computed: {
43
- bvProgress() {
44
- return this.getBvProgress()
45
- },
46
- progressBarClasses() {
47
- const { computedAnimated, computedVariant } = this
48
- return [
49
- computedVariant ? `bg-${computedVariant}` : '',
50
- this.computedStriped || computedAnimated ? 'progress-bar-striped' : '',
51
- computedAnimated ? 'progress-bar-animated' : ''
52
- ]
53
- },
54
- progressBarStyles() {
55
- return {
56
- width: 100 * (this.computedValue / this.computedMax) + '%'
57
- }
58
- },
59
- computedValue() {
60
- return toFloat(this.value, 0)
61
- },
62
- computedMax() {
63
- // Prefer our max over parent setting
64
- // Default to `100` for invalid values (`-x`, `0`, `NaN`)
65
- const max = toFloat(this.max) || toFloat(this.bvProgress.max, 0)
66
- return max > 0 ? max : 100
67
- },
68
- computedPrecision() {
69
- // Prefer our precision over parent setting
70
- // Default to `0` for invalid values (`-x`, `NaN`)
71
- return mathMax(toInteger(this.precision, toInteger(this.bvProgress.precision, 0)), 0)
72
- },
73
- computedProgress() {
74
- const precision = this.computedPrecision
75
- const p = mathPow(10, precision)
76
- return toFixed((100 * p * this.computedValue) / this.computedMax / p, precision)
77
- },
78
- computedVariant() {
79
- // Prefer our variant over parent setting
80
- return this.variant || this.bvProgress.variant
81
- },
82
- computedStriped() {
83
- // Prefer our striped over parent setting
84
- return isBoolean(this.striped) ? this.striped : this.bvProgress.striped || false
85
- },
86
- computedAnimated() {
87
- // Prefer our animated over parent setting
88
- return isBoolean(this.animated) ? this.animated : this.bvProgress.animated || false
89
- },
90
- computedShowProgress() {
91
- // Prefer our showProgress over parent setting
92
- return isBoolean(this.showProgress)
93
- ? this.showProgress
94
- : this.bvProgress.showProgress || false
95
- },
96
- computedShowValue() {
97
- // Prefer our showValue over parent setting
98
- return isBoolean(this.showValue) ? this.showValue : this.bvProgress.showValue || false
99
- }
100
- },
101
- render(h) {
102
- const { label, labelHtml, computedValue, computedPrecision } = this
103
-
104
- let $children
105
- let domProps = {}
106
- if (this.hasNormalizedSlot()) {
107
- $children = this.normalizeSlot()
108
- } else if (label || labelHtml) {
109
- domProps = htmlOrText(labelHtml, label)
110
- } else if (this.computedShowProgress) {
111
- $children = this.computedProgress
112
- } else if (this.computedShowValue) {
113
- $children = toFixed(computedValue, computedPrecision)
114
- }
115
-
116
- return h(
117
- 'div',
118
- {
119
- staticClass: 'progress-bar',
120
- class: this.progressBarClasses,
121
- style: this.progressBarStyles,
122
- attrs: {
123
- role: 'progressbar',
124
- 'aria-valuemin': '0',
125
- 'aria-valuemax': toString(this.computedMax),
126
- 'aria-valuenow': toFixed(computedValue, computedPrecision)
127
- },
128
- domProps
129
- },
130
- $children
131
- )
132
- }
133
- })