@gitlab/ui 94.6.0 → 94.7.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 (96) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/components/base/breadcrumb/breadcrumb.js +2 -1
  3. package/dist/components/base/dropdown/dropdown.js +1 -1
  4. package/dist/components/base/dropdown/dropdown_item.js +1 -1
  5. package/dist/components/base/new_dropdowns/disclosure/disclosure_dropdown_group.js +3 -3
  6. package/dist/components/base/new_dropdowns/listbox/listbox.js +4 -4
  7. package/dist/components/base/new_dropdowns/listbox/listbox_group.js +1 -1
  8. package/dist/index.css +2 -2
  9. package/dist/index.css.map +1 -1
  10. package/dist/tailwind.css +1 -1
  11. package/dist/tailwind.css.map +1 -1
  12. package/dist/tokens/build/js/tokens.dark.js +20 -1
  13. package/dist/tokens/build/js/tokens.js +20 -1
  14. package/dist/tokens/css/tokens.css +19 -0
  15. package/dist/tokens/css/tokens.dark.css +19 -0
  16. package/dist/tokens/js/tokens.dark.js +19 -0
  17. package/dist/tokens/js/tokens.js +19 -0
  18. package/dist/tokens/json/tokens.dark.json +457 -0
  19. package/dist/tokens/json/tokens.json +457 -0
  20. package/dist/tokens/scss/_tokens.dark.scss +19 -0
  21. package/dist/tokens/scss/_tokens.scss +19 -0
  22. package/dist/tokens/scss/_tokens_custom_properties.scss +19 -0
  23. package/dist/tokens/tailwind/tokens.cjs +2 -0
  24. package/dist/vendor/bootstrap-vue/src/constants/components.js +1 -4
  25. package/dist/vendor/bootstrap-vue/src/constants/regex.js +1 -6
  26. package/dist/vendor/bootstrap-vue/src/index.js +0 -4
  27. package/dist/vendor/bootstrap-vue/src/utils/string.js +2 -8
  28. package/package.json +1 -1
  29. package/src/components/base/breadcrumb/breadcrumb.vue +2 -1
  30. package/src/components/base/dropdown/dropdown.scss +6 -9
  31. package/src/components/base/dropdown/dropdown.vue +1 -1
  32. package/src/components/base/dropdown/dropdown_divider.scss +1 -1
  33. package/src/components/base/dropdown/dropdown_item.scss +8 -12
  34. package/src/components/base/dropdown/dropdown_item.vue +1 -1
  35. package/src/components/base/dropdown/dropdown_section_header.scss +1 -1
  36. package/src/components/base/filtered_search/filtered_search_suggestion.scss +2 -2
  37. package/src/components/base/filtered_search/filtered_search_suggestion_list.scss +2 -1
  38. package/src/components/base/new_dropdowns/disclosure/disclosure_dropdown.scss +1 -1
  39. package/src/components/base/new_dropdowns/disclosure/disclosure_dropdown_group.vue +3 -3
  40. package/src/components/base/new_dropdowns/dropdown.scss +5 -5
  41. package/src/components/base/new_dropdowns/dropdown_item.scss +29 -12
  42. package/src/components/base/new_dropdowns/listbox/listbox.scss +2 -2
  43. package/src/components/base/new_dropdowns/listbox/listbox.vue +5 -5
  44. package/src/components/base/new_dropdowns/listbox/listbox_group.vue +1 -1
  45. package/src/tokens/build/css/tokens.css +19 -0
  46. package/src/tokens/build/css/tokens.dark.css +19 -0
  47. package/src/tokens/build/js/tokens.dark.js +19 -0
  48. package/src/tokens/build/js/tokens.js +19 -0
  49. package/src/tokens/build/json/tokens.dark.json +457 -0
  50. package/src/tokens/build/json/tokens.json +457 -0
  51. package/src/tokens/build/scss/_tokens.dark.scss +19 -0
  52. package/src/tokens/build/scss/_tokens.scss +19 -0
  53. package/src/tokens/build/scss/_tokens_custom_properties.scss +19 -0
  54. package/src/tokens/build/tailwind/tokens.cjs +2 -0
  55. package/src/tokens/contextual/dropdown.tokens.json +148 -0
  56. package/src/vendor/bootstrap-vue/nuxt/index.js +1 -13
  57. package/src/vendor/bootstrap-vue/nuxt/plugin.template.js +0 -6
  58. package/src/vendor/bootstrap-vue/package.json +1 -4
  59. package/src/vendor/bootstrap-vue/src/_variables.scss +0 -14
  60. package/src/vendor/bootstrap-vue/src/components/breadcrumb/README.md +0 -1
  61. package/src/vendor/bootstrap-vue/src/components/input-group/README.md +1 -1
  62. package/src/vendor/bootstrap-vue/src/components/navbar/README.md +1 -2
  63. package/src/vendor/bootstrap-vue/src/constants/components.js +0 -3
  64. package/src/vendor/bootstrap-vue/src/constants/regex.js +0 -5
  65. package/src/vendor/bootstrap-vue/src/index.d.ts +0 -3
  66. package/src/vendor/bootstrap-vue/src/index.js +0 -9
  67. package/src/vendor/bootstrap-vue/src/index.scss +0 -3
  68. package/src/vendor/bootstrap-vue/src/utils/string.js +1 -8
  69. package/src/vendor/bootstrap-vue/src/utils/string.spec.js +1 -11
  70. package/dist/vendor/bootstrap-vue/src/browser-icons.js +0 -8
  71. package/dist/vendor/bootstrap-vue/src/icons/helpers/icon-base.js +0 -139
  72. package/dist/vendor/bootstrap-vue/src/icons/helpers/make-icon.js +0 -56
  73. package/dist/vendor/bootstrap-vue/src/icons/icon.js +0 -56
  74. package/dist/vendor/bootstrap-vue/src/icons/icons.js +0 -1377
  75. package/dist/vendor/bootstrap-vue/src/icons/iconstack.js +0 -31
  76. package/dist/vendor/bootstrap-vue/src/icons/index.js +0 -4
  77. package/dist/vendor/bootstrap-vue/src/icons/plugin.js +0 -1410
  78. package/dist/vendor/bootstrap-vue/src/icons-only.js +0 -10
  79. package/src/vendor/bootstrap-vue/src/browser-icons.js +0 -9
  80. package/src/vendor/bootstrap-vue/src/icons/README.md +0 -874
  81. package/src/vendor/bootstrap-vue/src/icons/_icons.scss +0 -156
  82. package/src/vendor/bootstrap-vue/src/icons/helpers/icon-base.js +0 -134
  83. package/src/vendor/bootstrap-vue/src/icons/helpers/make-icon.js +0 -48
  84. package/src/vendor/bootstrap-vue/src/icons/icon.js +0 -54
  85. package/src/vendor/bootstrap-vue/src/icons/icons.d.ts +0 -2757
  86. package/src/vendor/bootstrap-vue/src/icons/icons.js +0 -8241
  87. package/src/vendor/bootstrap-vue/src/icons/icons.spec.js +0 -522
  88. package/src/vendor/bootstrap-vue/src/icons/iconstack.js +0 -31
  89. package/src/vendor/bootstrap-vue/src/icons/iconstack.spec.js +0 -161
  90. package/src/vendor/bootstrap-vue/src/icons/index.d.ts +0 -18
  91. package/src/vendor/bootstrap-vue/src/icons/index.js +0 -16
  92. package/src/vendor/bootstrap-vue/src/icons/index.scss +0 -1
  93. package/src/vendor/bootstrap-vue/src/icons/package.json +0 -72782
  94. package/src/vendor/bootstrap-vue/src/icons/plugin.js +0 -4159
  95. package/src/vendor/bootstrap-vue/src/icons-only.js +0 -33
  96. package/src/vendor/bootstrap-vue/src/icons.scss +0 -8
@@ -0,0 +1,148 @@
1
+ {
2
+ "dropdown": {
3
+ "background": {
4
+ "color": {
5
+ "$value": "{background.color.overlap}",
6
+ "$type": "color",
7
+ "$description": "Used for the background of a dropdown."
8
+ }
9
+ },
10
+ "border": {
11
+ "color": {
12
+ "$value": {
13
+ "default": "{color.neutral.200}",
14
+ "dark": "{color.neutral.700}"
15
+ },
16
+ "$type": "color",
17
+ "$description": "Used for the border of a dropdown."
18
+ }
19
+ },
20
+ "option": {
21
+ "text": {
22
+ "color": {
23
+ "default": {
24
+ "$value": "{action.neutral.foreground.color.default}",
25
+ "$type": "color",
26
+ "$description": "Used for the text of a dropdown option in the default state."
27
+ },
28
+ "hover": {
29
+ "$value": "{action.neutral.foreground.color.hover}",
30
+ "$type": "color",
31
+ "$description": "Used for the text of a dropdown option in the hover state."
32
+ },
33
+ "focus": {
34
+ "$value": "{action.neutral.foreground.color.focus}",
35
+ "$type": "color",
36
+ "$description": "Used for the text of a dropdown option in the focus state."
37
+ },
38
+ "active": {
39
+ "$value": "{action.neutral.foreground.color.active}",
40
+ "$type": "color",
41
+ "$description": "Used for the text of a dropdown option in the active state."
42
+ },
43
+ "disabled": {
44
+ "$value": "{action.disabled.foreground.color}",
45
+ "$type": "color",
46
+ "$description": "Used for the text of a dropdown option in the disabled state."
47
+ }
48
+ }
49
+ },
50
+ "indicator": {
51
+ "color": {
52
+ "selected": {
53
+ "default": {
54
+ "$value": {
55
+ "default": "{control.background.color.selected.default}",
56
+ "dark": "{color.neutral.0}"
57
+ },
58
+ "$type": "color",
59
+ "$description": "Used for the dropdown selected option indicator in the default state."
60
+ },
61
+ "hover": {
62
+ "$value": {
63
+ "default": "{control.background.color.selected.hover}",
64
+ "dark": "{color.neutral.0}"
65
+ },
66
+ "$type": "color",
67
+ "$description": "Used for the dropdown selected option indicator in the hover state."
68
+ },
69
+ "focus": {
70
+ "$value": {
71
+ "default": "{control.background.color.selected.focus}",
72
+ "dark": "{color.neutral.0}"
73
+ },
74
+ "$type": "color",
75
+ "$description": "Used for the dropdown selected option indicator in the focus state."
76
+ },
77
+ "active": {
78
+ "$value": {
79
+ "default": "{color.blue.700}",
80
+ "dark": "{color.neutral.100}"
81
+ },
82
+ "$type": "color",
83
+ "$description": "Used for the dropdown selected option indicator in the active state."
84
+ }
85
+ }
86
+ }
87
+ },
88
+ "background": {
89
+ "color": {
90
+ "unselected": {
91
+ "default": {
92
+ "$value": "{action.neutral.background.color.default}",
93
+ "$type": "color",
94
+ "$description": "Used for the background of an unselected dropdown option in the default state."
95
+ },
96
+ "hover": {
97
+ "$value": "{action.neutral.background.color.hover}",
98
+ "$type": "color",
99
+ "$description": "Used for the background of an unselected dropdown option in the hover state."
100
+ },
101
+ "focus": {
102
+ "$value": "{action.neutral.background.color.focus}",
103
+ "$type": "color",
104
+ "$description": "Used for the background of an unselected dropdown option in the focus state."
105
+ },
106
+ "active": {
107
+ "$value": "{action.neutral.background.color.active}",
108
+ "$type": "color",
109
+ "$description": "Used for the background of an unselected dropdown option in the active state."
110
+ }
111
+ },
112
+ "selected": {
113
+ "default": {
114
+ "$value": {
115
+ "default": "{color.neutral.50}",
116
+ "dark": "{color.neutral.800}"
117
+ },
118
+ "$type": "color",
119
+ "$description": "Used for the background of a selected dropdown option in the default state."
120
+ },
121
+ "hover": {
122
+ "$value": {
123
+ "default": "{color.neutral.100}",
124
+ "dark": "{color.neutral.700}"
125
+ },
126
+ "$type": "color",
127
+ "$description": "Used for the background of a selected dropdown option in the hover state."
128
+ },
129
+ "focus": {
130
+ "$value": "{dropdown.option.background.color.selected.hover}",
131
+ "$type": "color",
132
+ "$description": "Used for the background of a selected dropdown option in the focus state."
133
+ },
134
+ "active": {
135
+ "$value": {
136
+ "default": "{color.neutral.200}",
137
+ "dark": "{color.neutral.900}"
138
+ },
139
+ "$type": "color",
140
+ "$description": "Used for the background of a selected dropdown option in the active state."
141
+ }
142
+ }
143
+ }
144
+ }
145
+ }
146
+ }
147
+ }
148
+
@@ -103,8 +103,7 @@ module.exports = function nuxtBootstrapVue(moduleOptions = {}) {
103
103
  // Base options available to template
104
104
  const templateOptions = {
105
105
  // Flag if we are tree shaking
106
- treeShake: false,
107
- icons: !!options.icons
106
+ treeShake: false
108
107
  }
109
108
 
110
109
  // Specific component and/or directive plugins
@@ -148,17 +147,6 @@ module.exports = function nuxtBootstrapVue(moduleOptions = {}) {
148
147
  }
149
148
  }
150
149
 
151
- // If tree shaking, and icons requested, add in
152
- // the IconsPlugin if not already specified
153
- if (
154
- templateOptions.treeShake &&
155
- templateOptions.icons &&
156
- templateOptions.componentPlugins.indexOf('IconsPlugin') === -1 &&
157
- templateOptions.componentPlugins.indexOf('BootstrapVueIcons') === -1
158
- ) {
159
- templateOptions.componentPlugins.push('IconsPlugin')
160
- }
161
-
162
150
  // Add BootstrapVue configuration if present
163
151
  if (options.config && Object.prototype.toString.call(options.config) === '[object Object]') {
164
152
  templateOptions.config = { ...options.config }
@@ -1,12 +1,6 @@
1
1
  import Vue from 'vue';
2
2
 
3
3
  <% if (!options.treeShake) { %>
4
- <% if (options.icons) { %>
5
- import { BootstrapVue, BootstrapVueIcons } from 'bootstrap-vue';
6
-
7
- Vue.use(BootstrapVue, <%= JSON.stringify(options.config || {}, undefined, 2) %>);
8
- Vue.use(BootstrapVueIcons);
9
- <% } else { %>
10
4
  import { BootstrapVue } from 'bootstrap-vue';
11
5
 
12
6
  Vue.use(BootstrapVue, <%= JSON.stringify(options.config || {}, undefined, 2) %>);
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bootstrap-vue",
3
3
  "version": "2.23.1",
4
- "description": "With more than 85 components, over 45 available plugins, several directives, and 1000+ icons, BootstrapVue provides one of the most comprehensive implementations of the Bootstrap v4 component and grid system available for Vue.js v2.6, complete with extensive and automated WAI-ARIA accessibility markup.",
4
+ "description": "With many components and several directives, BootstrapVue provides one of the most comprehensive implementations of the Bootstrap v4 component and grid system available for Vue.js v2.6, complete with extensive and automated WAI-ARIA accessibility markup.",
5
5
  "main": "./dist/bootstrap-vue.common.js",
6
6
  "web": "./dist/bootstrap-vue.js",
7
7
  "module": "./esm/index.js",
@@ -99,7 +99,6 @@
99
99
  "babel-eslint": "^10.1.0",
100
100
  "babel-jest": "^26.6.3",
101
101
  "babel-plugin-istanbul": "^6.0.0",
102
- "bootstrap-icons": "^1.5.0",
103
102
  "clean-css-cli": "^4.3.0",
104
103
  "codemirror": "^5.61.0",
105
104
  "codesandbox": "^2.2.3",
@@ -152,8 +151,6 @@
152
151
  "Web",
153
152
  "Components",
154
153
  "Directives",
155
- "Icons",
156
- "Bootstrap Icons",
157
154
  "ARIA",
158
155
  "Accessibility",
159
156
  "a11y",
@@ -39,20 +39,6 @@ $b-custom-switch-indicator-size-sm: calc(
39
39
  #{$b-custom-control-indicator-size-sm} - #{$custom-control-indicator-border-width * 4}
40
40
  ) !default;
41
41
 
42
- // --- Icons ---
43
-
44
- $b-icon-vertical-offset: -0.15em;
45
-
46
- // Animations
47
- $b-icon-animation-cylon-duration: 0.75s !default;
48
- $b-icon-animation-cylon-vertical-duration: $b-icon-animation-cylon-duration !default;
49
- $b-icon-animation-fade-duration: 0.75s !default;
50
- $b-icon-animation-spin-duration: 2s !default;
51
- $b-icon-animation-spin-reverse-duration: $b-icon-animation-spin-duration !default;
52
- $b-icon-animation-spin-pulse-duration: 1s !default;
53
- $b-icon-animation-spin-reverse-pulse-duration: $b-icon-animation-spin-pulse-duration !default;
54
- $b-icon-animation-throb-duration: 0.75s !default;
55
-
56
42
  // --- Tables ---
57
43
 
58
44
  // Table busy state
@@ -75,7 +75,6 @@ over the content of each item:
75
75
  <template>
76
76
  <b-breadcrumb>
77
77
  <b-breadcrumb-item href="#home">
78
- <b-icon icon="house-fill" scale="1.25" shift-v="1.25" aria-hidden="true"></b-icon>
79
78
  Home
80
79
  </b-breadcrumb-item>
81
80
  <b-breadcrumb-item href="#foo">Foo</b-breadcrumb-item>
@@ -99,7 +99,7 @@ wrapped in these components for proper styling.
99
99
  <b-button variant="outline-secondary">Button</b-button>
100
100
  <b-button variant="outline-primary">Button</b-button>
101
101
  <b-input-group-text>
102
- <b-icon icon="x" />
102
+ x
103
103
  </b-input-group-text>
104
104
  </b-input-group-append>
105
105
  </b-input-group>
@@ -300,8 +300,7 @@ and not an `array`.
300
300
 
301
301
  <b-navbar-toggle target="navbar-toggle-collapse">
302
302
  <template #default="{ expanded }">
303
- <b-icon v-if="expanded" icon="chevron-bar-up"></b-icon>
304
- <b-icon v-else icon="chevron-bar-down"></b-icon>
303
+ {{ expanded ? 'Close' : 'Open' }}
305
304
  </template>
306
305
  </b-navbar-toggle>
307
306
 
@@ -31,9 +31,6 @@ export const NAME_FORM_SELECT_OPTION_GROUP = 'BFormSelectOptionGroup'
31
31
  export const NAME_FORM_TEXT = 'BFormText'
32
32
  export const NAME_FORM_TEXTAREA = 'BFormTextarea'
33
33
  export const NAME_FORM_VALID_FEEDBACK = 'BFormValidFeedback'
34
- export const NAME_ICON = 'BIcon'
35
- export const NAME_ICONSTACK = 'BIconstack'
36
- export const NAME_ICON_BASE = 'BIconBase'
37
34
  export const NAME_INPUT_GROUP = 'BInputGroup'
38
35
  export const NAME_INPUT_GROUP_ADDON = 'BInputGroupAddon'
39
36
  export const NAME_INPUT_GROUP_APPEND = 'BInputGroupAppend'
@@ -17,7 +17,6 @@ export const RX_START_SPACE_WORD = /(\s|^)(\w)/g
17
17
  export const RX_TRIM_LEFT = /^\s+/
18
18
  export const RX_TRIM_RIGHT = /\s+$/
19
19
  export const RX_UNDERSCORE = /_/g
20
- export const RX_UN_KEBAB = /-(\w)/g
21
20
 
22
21
  // --- URL ---
23
22
 
@@ -29,10 +28,6 @@ export const RX_QUERY_START = /^(\?|#|&)/
29
28
 
30
29
  export const RX_COL_CLASS = /^col-/
31
30
 
32
- // --- Icon ---
33
-
34
- export const RX_ICON_PREFIX = /^BIcon/
35
-
36
31
  // --- Locale ---
37
32
 
38
33
  export const RX_STRIP_LOCALE_MODS = /-u-.+/
@@ -53,9 +53,6 @@ export * from './bv-config'
53
53
  // Components & Plugins
54
54
  export * from './components'
55
55
 
56
- // Icons & Plugin
57
- export * from './icons'
58
-
59
56
  // BootstrapVue plugin
60
57
  export interface BootstrapVuePlugin extends BvPlugin {
61
58
  setConfig: (config: BvConfigOptions) => void
@@ -49,15 +49,6 @@ export { BVToastPlugin } from './components/toast/helpers/bv-toast'
49
49
  // can be reverted back to `export * from './table'` when Webpack v5 is released
50
50
  // See: https://github.com/webpack/webpack/pull/9203 (available in Webpack v5.0.0-alpha.15)
51
51
 
52
- // -- Export Icon components and IconPlugin/BootstrapVueIcons ---
53
- // export * from './icons'
54
- export { IconsPlugin, BootstrapVueIcons } from './icons/plugin'
55
- export { BIcon } from './icons/icon'
56
- export { BIconstack } from './icons/iconstack'
57
- // This re-export is only a single level deep, which
58
- // Webpack 4 (usually) handles correctly when tree shaking
59
- export * from './icons/icons'
60
-
61
52
  // --- Export all individual components and component group plugins as named exports ---
62
53
 
63
54
  // export * from './components/badge'
@@ -9,6 +9,3 @@
9
9
 
10
10
  // Include custom SCSS for components
11
11
  @import "components/index";
12
-
13
- // Include custom SCSS for icons
14
- @import "icons/index";
@@ -6,8 +6,7 @@ import {
6
6
  RX_START_SPACE_WORD,
7
7
  RX_TRIM_LEFT,
8
8
  RX_TRIM_RIGHT,
9
- RX_UNDERSCORE,
10
- RX_UN_KEBAB
9
+ RX_UNDERSCORE
11
10
  } from '../constants/regex'
12
11
  import { isArray, isPlainObject, isString, isUndefinedOrNull } from './inspect'
13
12
 
@@ -18,12 +17,6 @@ export const kebabCase = str => {
18
17
  return str.replace(RX_HYPHENATE, '-$1').toLowerCase()
19
18
  }
20
19
 
21
- // Converts a kebab-case or camelCase string to PascalCase
22
- export const pascalCase = str => {
23
- str = kebabCase(str).replace(RX_UN_KEBAB, (_, c) => (c ? c.toUpperCase() : ''))
24
- return str.charAt(0).toUpperCase() + str.slice(1)
25
- }
26
-
27
20
  // Converts a string, including strings in camelCase or snake_case, into Start Case
28
21
  // It keeps original single quote and hyphen in the word
29
22
  // https://github.com/UrbanCompass/to-start-case
@@ -1,4 +1,4 @@
1
- import { escapeRegExp, kebabCase, pascalCase, startCase, toString, upperFirst } from './string'
1
+ import { escapeRegExp, kebabCase, startCase, toString, upperFirst } from './string'
2
2
 
3
3
  describe('utils/string', () => {
4
4
  it('kebabCase() works', async () => {
@@ -9,16 +9,6 @@ describe('utils/string', () => {
9
9
  expect(kebabCase('XFooBar')).toBe('x-foo-bar')
10
10
  })
11
11
 
12
- it('pascalCase() works', async () => {
13
- expect(pascalCase('foo')).toBe('Foo')
14
- expect(pascalCase('Foo')).toBe('Foo')
15
- expect(pascalCase('fooBar')).toBe('FooBar')
16
- expect(pascalCase('FooBar')).toBe('FooBar')
17
- expect(pascalCase('foo-bar')).toBe('FooBar')
18
- expect(pascalCase('x-foo-bar')).toBe('XFooBar')
19
- expect(pascalCase('xFooBar')).toBe('XFooBar')
20
- })
21
-
22
12
  it('startCase() works', async () => {
23
13
  expect(startCase('foobar')).toBe('Foobar')
24
14
  expect(startCase('Foobar')).toBe('Foobar')
@@ -1,8 +0,0 @@
1
- import { vueUse } from './utils/plugins';
2
- import { BootstrapVueIcons } from './icons-only';
3
- export { BootstrapVueIcons as default } from './icons-only';
4
-
5
- // Main entry point for the browser icons-only build
6
-
7
- // Auto installation only occurs if window.Vue exists
8
- vueUse(BootstrapVueIcons);
@@ -1,139 +0,0 @@
1
- import { extend, mergeData } from '../../vue';
2
- import { NAME_ICON_BASE } from '../../constants/components';
3
- import { PROP_TYPE_STRING, PROP_TYPE_BOOLEAN, PROP_TYPE_NUMBER_STRING } from '../../constants/props';
4
- import { identity } from '../../utils/identity';
5
- import { isUndefinedOrNull } from '../../utils/inspect';
6
- import { mathMax } from '../../utils/math';
7
- import { toFloat } from '../../utils/number';
8
- import { makeProp } from '../../utils/props';
9
-
10
- // --- Constants ---
11
-
12
- // Base attributes needed on all icons
13
- const BASE_ATTRS = {
14
- viewBox: '0 0 16 16',
15
- width: '1em',
16
- height: '1em',
17
- focusable: 'false',
18
- role: 'img',
19
- 'aria-label': 'icon'
20
- };
21
-
22
- // Attributes that are nulled out when stacked
23
- const STACKED_ATTRS = {
24
- width: null,
25
- height: null,
26
- focusable: null,
27
- role: null,
28
- 'aria-label': null
29
- };
30
-
31
- // --- Props ---
32
-
33
- const props = {
34
- animation: makeProp(PROP_TYPE_STRING),
35
- content: makeProp(PROP_TYPE_STRING),
36
- flipH: makeProp(PROP_TYPE_BOOLEAN, false),
37
- flipV: makeProp(PROP_TYPE_BOOLEAN, false),
38
- fontScale: makeProp(PROP_TYPE_NUMBER_STRING, 1),
39
- rotate: makeProp(PROP_TYPE_NUMBER_STRING, 0),
40
- scale: makeProp(PROP_TYPE_NUMBER_STRING, 1),
41
- shiftH: makeProp(PROP_TYPE_NUMBER_STRING, 0),
42
- shiftV: makeProp(PROP_TYPE_NUMBER_STRING, 0),
43
- stacked: makeProp(PROP_TYPE_BOOLEAN, false),
44
- title: makeProp(PROP_TYPE_STRING),
45
- variant: makeProp(PROP_TYPE_STRING)
46
- };
47
-
48
- // --- Main component ---
49
-
50
- // Shared private base component to reduce bundle/runtime size
51
- // @vue/component
52
- const BVIconBase = /*#__PURE__*/extend({
53
- name: NAME_ICON_BASE,
54
- functional: true,
55
- props,
56
- render(h, _ref) {
57
- let {
58
- data,
59
- props,
60
- children
61
- } = _ref;
62
- const {
63
- animation,
64
- content,
65
- flipH,
66
- flipV,
67
- stacked,
68
- title,
69
- variant
70
- } = props;
71
- const fontScale = mathMax(toFloat(props.fontScale, 1), 0) || 1;
72
- const scale = mathMax(toFloat(props.scale, 1), 0) || 1;
73
- const rotate = toFloat(props.rotate, 0);
74
- const shiftH = toFloat(props.shiftH, 0);
75
- const shiftV = toFloat(props.shiftV, 0);
76
- // Compute the transforms
77
- // Note that order is important as SVG transforms are applied in order from
78
- // left to right and we want flipping/scale to occur before rotation
79
- // Note shifting is applied separately
80
- // Assumes that the viewbox is `0 0 16 16` (`8 8` is the center)
81
- const hasScale = flipH || flipV || scale !== 1;
82
- const hasTransforms = hasScale || rotate;
83
- const hasShift = shiftH || shiftV;
84
- const hasContent = !isUndefinedOrNull(content);
85
- const transforms = [hasTransforms ? 'translate(8 8)' : null, hasScale ? `scale(${(flipH ? -1 : 1) * scale} ${(flipV ? -1 : 1) * scale})` : null, rotate ? `rotate(${rotate})` : null, hasTransforms ? 'translate(-8 -8)' : null].filter(identity);
86
-
87
- // We wrap the content in a `<g>` for handling the transforms (except shift)
88
- let $inner = h('g', {
89
- attrs: {
90
- transform: transforms.join(' ') || null
91
- },
92
- domProps: hasContent ? {
93
- innerHTML: content || ''
94
- } : {}
95
- }, children);
96
-
97
- // If needed, we wrap in an additional `<g>` in order to handle the shifting
98
- if (hasShift) {
99
- $inner = h('g', {
100
- attrs: {
101
- transform: `translate(${16 * shiftH / 16} ${-16 * shiftV / 16})`
102
- }
103
- }, [$inner]);
104
- }
105
-
106
- // Wrap in an additional `<g>` for proper animation handling if stacked
107
- if (stacked) {
108
- $inner = h('g', [$inner]);
109
- }
110
- const $title = title ? h('title', title) : null;
111
- const $content = [$title, $inner].filter(identity);
112
- return h('svg', mergeData({
113
- staticClass: 'b-icon bi',
114
- class: {
115
- [`text-${variant}`]: variant,
116
- [`b-icon-animation-${animation}`]: animation
117
- },
118
- attrs: BASE_ATTRS,
119
- style: stacked ? {} : {
120
- fontSize: fontScale === 1 ? null : `${fontScale * 100}%`
121
- }
122
- },
123
- // Merge in user supplied data
124
- data,
125
- // If icon is stacked, null-out some attrs
126
- stacked ? {
127
- attrs: STACKED_ATTRS
128
- } : {},
129
- // These cannot be overridden by users
130
- {
131
- attrs: {
132
- xmlns: stacked ? null : 'http://www.w3.org/2000/svg',
133
- fill: 'currentColor'
134
- }
135
- }), $content);
136
- }
137
- });
138
-
139
- export { BVIconBase, props };
@@ -1,56 +0,0 @@
1
- import { extend, mergeData } from '../../vue';
2
- import { omit } from '../../utils/object';
3
- import { kebabCase, pascalCase, trim } from '../../utils/string';
4
- import { props, BVIconBase } from './icon-base';
5
-
6
- const iconProps = omit(props, ['content']);
7
-
8
- /**
9
- * Icon component generator function
10
- *
11
- * @param {string} icon name (minus the leading `BIcon`)
12
- * @param {string} raw `innerHTML` for SVG
13
- * @return {VueComponent}
14
- */
15
- const makeIcon = (name, content) => {
16
- // For performance reason we pre-compute some values, so that
17
- // they are not computed on each render of the icon component
18
- const kebabName = kebabCase(name);
19
- const iconName = `BIcon${pascalCase(name)}`;
20
- const iconNameClass = `bi-${kebabName}`;
21
- const iconTitle = kebabName.replace(/-/g, ' ');
22
- const svgContent = trim(content || '');
23
- return /*#__PURE__*/extend({
24
- name: iconName,
25
- functional: true,
26
- props: iconProps,
27
- render(h, _ref) {
28
- let {
29
- data,
30
- props
31
- } = _ref;
32
- return h(BVIconBase, mergeData(
33
- // Defaults
34
- {
35
- props: {
36
- title: iconTitle
37
- },
38
- attrs: {
39
- 'aria-label': iconTitle
40
- }
41
- },
42
- // User data
43
- data,
44
- // Required data
45
- {
46
- staticClass: iconNameClass,
47
- props: {
48
- ...props,
49
- content: svgContent
50
- }
51
- }));
52
- }
53
- });
54
- };
55
-
56
- export { makeIcon };
@@ -1,56 +0,0 @@
1
- import { extend, mergeData, Vue } from '../vue';
2
- import { NAME_ICON } from '../constants/components';
3
- import { PROP_TYPE_STRING } from '../constants/props';
4
- import { RX_ICON_PREFIX } from '../constants/regex';
5
- import { omit, sortKeys } from '../utils/object';
6
- import { makePropsConfigurable, makeProp, pluckProps } from '../utils/props';
7
- import { pascalCase, trim } from '../utils/string';
8
- import { BIconBlank } from './icons';
9
- import { props as props$1 } from './helpers/icon-base';
10
-
11
- // --- Helper methods ---
12
-
13
- const findIconComponent = (ctx, iconName) => {
14
- if (!ctx) {
15
- return Vue.component(iconName);
16
- }
17
- const components = (ctx.$options || {}).components;
18
- const iconComponent = components && components[iconName];
19
- return iconComponent || findIconComponent(ctx.$parent, iconName);
20
- };
21
-
22
- // --- Props ---
23
-
24
- const iconProps = omit(props$1, ['content']);
25
- const props = makePropsConfigurable(sortKeys({
26
- ...iconProps,
27
- icon: makeProp(PROP_TYPE_STRING)
28
- }), NAME_ICON);
29
-
30
- // --- Main component ---
31
-
32
- // Helper BIcon component
33
- // Requires the requested icon component to be installed
34
- // @vue/component
35
- const BIcon = /*#__PURE__*/extend({
36
- name: NAME_ICON,
37
- functional: true,
38
- props,
39
- render(h, _ref) {
40
- let {
41
- data,
42
- props,
43
- parent
44
- } = _ref;
45
- const icon = pascalCase(trim(props.icon || '')).replace(RX_ICON_PREFIX, '');
46
-
47
- // If parent context exists, we check to see if the icon has been registered
48
- // either locally in the parent component, or globally at the `$root` level
49
- // If not registered, we render a blank icon
50
- return h(icon ? findIconComponent(parent, `BIcon${icon}`) || BIconBlank : BIconBlank, mergeData(data, {
51
- props: pluckProps(iconProps, props)
52
- }));
53
- }
54
- });
55
-
56
- export { BIcon, props };