Skip to content

Commit 8d7afb4

Browse files
authored
fix(build): avoid circular dependency in icons setup (#21670)
fixes #20436
1 parent 96fd7f5 commit 8d7afb4

File tree

3 files changed

+51
-45
lines changed

3 files changed

+51
-45
lines changed

packages/vuetify/src/composables/icons.tsx

Lines changed: 1 addition & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
// Icons
2-
import { aliases, mdi } from '@/iconsets/mdi'
3-
41
// Utilities
52
import { computed, inject, toValue } from 'vue'
6-
import { consoleWarn, defineComponent, genericComponent, mergeDeep, propsFactory } from '@/util'
3+
import { consoleWarn, defineComponent, genericComponent, propsFactory } from '@/util'
74

85
// Types
96
import type { InjectionKey, MaybeRefOrGetter, PropType } from 'vue'
@@ -188,46 +185,6 @@ export const VClassIcon = defineComponent({
188185
})
189186
export type VClassIcon = InstanceType<typeof VClassIcon>
190187

191-
function genDefaults (): Record<string, IconSet> {
192-
return {
193-
svg: {
194-
component: VSvgIcon,
195-
},
196-
class: {
197-
component: VClassIcon,
198-
},
199-
}
200-
}
201-
202-
// Composables
203-
export function createIcons (options?: IconOptions) {
204-
const sets = genDefaults()
205-
const defaultSet = options?.defaultSet ?? 'mdi'
206-
207-
if (defaultSet === 'mdi' && !sets.mdi) {
208-
sets.mdi = mdi
209-
}
210-
211-
return mergeDeep({
212-
defaultSet,
213-
sets,
214-
aliases: {
215-
...aliases,
216-
/* eslint-disable max-len */
217-
vuetify: [
218-
'M8.2241 14.2009L12 21L22 3H14.4459L8.2241 14.2009Z',
219-
['M7.26303 12.4733L7.00113 12L2 3H12.5261C12.5261 3 12.5261 3 12.5261 3L7.26303 12.4733Z', 0.6],
220-
],
221-
'vuetify-outline': 'svg:M7.26 12.47 12.53 3H2L7.26 12.47ZM14.45 3 8.22 14.2 12 21 22 3H14.45ZM18.6 5 12 16.88 10.51 14.2 15.62 5ZM7.26 8.35 5.4 5H9.13L7.26 8.35Z',
222-
'vuetify-play': [
223-
'm6.376 13.184-4.11-7.192C1.505 4.66 2.467 3 4.003 3h8.532l-.953 1.576-.006.01-.396.677c-.429.732-.214 1.507.194 2.015.404.503 1.092.878 1.869.806a3.72 3.72 0 0 1 1.005.022c.276.053.434.143.523.237.138.146.38.635-.25 2.09-.893 1.63-1.553 1.722-1.847 1.677-.213-.033-.468-.158-.756-.406a4.95 4.95 0 0 1-.8-.927c-.39-.564-1.04-.84-1.66-.846-.625-.006-1.316.27-1.693.921l-.478.826-.911 1.506Z',
224-
['M9.093 11.552c.046-.079.144-.15.32-.148a.53.53 0 0 1 .43.207c.285.414.636.847 1.046 1.2.405.35.914.662 1.516.754 1.334.205 2.502-.698 3.48-2.495l.014-.028.013-.03c.687-1.574.774-2.852-.005-3.675-.37-.391-.861-.586-1.333-.676a5.243 5.243 0 0 0-1.447-.044c-.173.016-.393-.073-.54-.257-.145-.18-.127-.316-.082-.392l.393-.672L14.287 3h5.71c1.536 0 2.499 1.659 1.737 2.992l-7.997 13.996c-.768 1.344-2.706 1.344-3.473 0l-3.037-5.314 1.377-2.278.004-.006.004-.007.481-.831Z', 0.6],
225-
],
226-
/* eslint-enable max-len */
227-
},
228-
}, options) as InternalIconOptions
229-
}
230-
231188
export const useIcon = (props: MaybeRefOrGetter<IconValue | undefined>) => {
232189
const icons = inject(IconSymbol)
233190

packages/vuetify/src/framework.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
// Composables
2+
import { createIcons } from './icons'
23
import { createDate, DateAdapterSymbol, DateOptionsSymbol } from '@/composables/date/date'
34
import { createDefaults, DefaultsSymbol } from '@/composables/defaults'
45
import { createDisplay, DisplaySymbol } from '@/composables/display'
56
import { createGoTo, GoToSymbol } from '@/composables/goto'
6-
import { createIcons, IconSymbol } from '@/composables/icons'
7+
import { IconSymbol } from '@/composables/icons'
78
import { createLocale, LocaleSymbol } from '@/composables/locale'
89
import { createTheme, ThemeSymbol } from '@/composables/theme'
910

packages/vuetify/src/icons.ts

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// Composables
2+
import { VClassIcon, VSvgIcon } from '@/composables/icons'
3+
import { aliases, mdi } from '@/iconsets/mdi'
4+
5+
// Utilities
6+
import { mergeDeep } from '@/util'
7+
8+
// Types
9+
import type { IconOptions, IconSet, InternalIconOptions } from '@/composables/icons'
10+
11+
function genDefaults (): Record<string, IconSet> {
12+
return {
13+
svg: {
14+
component: VSvgIcon,
15+
},
16+
class: {
17+
component: VClassIcon,
18+
},
19+
}
20+
}
21+
22+
export function createIcons (options?: IconOptions) {
23+
const sets = genDefaults()
24+
const defaultSet = options?.defaultSet ?? 'mdi'
25+
26+
if (defaultSet === 'mdi' && !sets.mdi) {
27+
sets.mdi = mdi
28+
}
29+
30+
return mergeDeep({
31+
defaultSet,
32+
sets,
33+
aliases: {
34+
...aliases,
35+
/* eslint-disable max-len */
36+
vuetify: [
37+
'M8.2241 14.2009L12 21L22 3H14.4459L8.2241 14.2009Z',
38+
['M7.26303 12.4733L7.00113 12L2 3H12.5261C12.5261 3 12.5261 3 12.5261 3L7.26303 12.4733Z', 0.6],
39+
],
40+
'vuetify-outline': 'svg:M7.26 12.47 12.53 3H2L7.26 12.47ZM14.45 3 8.22 14.2 12 21 22 3H14.45ZM18.6 5 12 16.88 10.51 14.2 15.62 5ZM7.26 8.35 5.4 5H9.13L7.26 8.35Z',
41+
'vuetify-play': [
42+
'm6.376 13.184-4.11-7.192C1.505 4.66 2.467 3 4.003 3h8.532l-.953 1.576-.006.01-.396.677c-.429.732-.214 1.507.194 2.015.404.503 1.092.878 1.869.806a3.72 3.72 0 0 1 1.005.022c.276.053.434.143.523.237.138.146.38.635-.25 2.09-.893 1.63-1.553 1.722-1.847 1.677-.213-.033-.468-.158-.756-.406a4.95 4.95 0 0 1-.8-.927c-.39-.564-1.04-.84-1.66-.846-.625-.006-1.316.27-1.693.921l-.478.826-.911 1.506Z',
43+
['M9.093 11.552c.046-.079.144-.15.32-.148a.53.53 0 0 1 .43.207c.285.414.636.847 1.046 1.2.405.35.914.662 1.516.754 1.334.205 2.502-.698 3.48-2.495l.014-.028.013-.03c.687-1.574.774-2.852-.005-3.675-.37-.391-.861-.586-1.333-.676a5.243 5.243 0 0 0-1.447-.044c-.173.016-.393-.073-.54-.257-.145-.18-.127-.316-.082-.392l.393-.672L14.287 3h5.71c1.536 0 2.499 1.659 1.737 2.992l-7.997 13.996c-.768 1.344-2.706 1.344-3.473 0l-3.037-5.314 1.377-2.278.004-.006.004-.007.481-.831Z', 0.6],
44+
],
45+
/* eslint-enable max-len */
46+
},
47+
}, options) as InternalIconOptions
48+
}

0 commit comments

Comments
 (0)