Skip to content

Commit 407862a

Browse files
committed
fix(preset-theme-default): merge user shortcutOverrides in shortcuts
fixes #41
1 parent a1f46c5 commit 407862a

File tree

5 files changed

+11
-17
lines changed

5 files changed

+11
-17
lines changed

packages/preset-theme-default/build.config.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ export default defineBuildConfig({
1414
externals: [
1515
'@unocss/core',
1616
'@unocss/reset',
17-
'defu',
1817
],
1918
hooks: {
2019
'mkdist:done': () => {

packages/preset-theme-default/package.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,6 @@
4343
"vuejs",
4444
"vue"
4545
],
46-
"dependencies": {
47-
"defu": "^6.1.1"
48-
},
4946
"devDependencies": {
5047
"@types/fs-extra": "^9.0.13",
5148
"@unocss/core": "^0.45.30",

packages/preset-theme-default/src/index.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import type { Preset } from '@unocss/core'
2-
import { defu } from 'defu'
32
import { rules } from './rules'
43
import { shortcuts } from './shortcuts'
54
import { variants } from './variants'
@@ -15,7 +14,7 @@ interface PresetOptions {
1514
export const colors = ['primary', 'success', 'info', 'warning', 'danger'] as const
1615
export type Colors = typeof colors
1716

18-
export function presetThemeDefault(options: PresetOptions = {}): Preset {
17+
export function presetThemeDefault(options: PresetOptions = {}): Preset {
1918
return {
2019
name: '@anu-vue/preset-theme-default',
2120
theme: {
@@ -47,9 +46,11 @@ export function presetThemeDefault(options: PresetOptions = {}): Preset {
4746
...['top', 'right', 'bottom', 'left'].map(dir => `a-drawer-anchor-${dir}`),
4847
],
4948
rules,
50-
shortcuts: options.shortcutOverrides
51-
? defu(options.shortcutOverrides, shortcuts)
52-
: shortcuts,
49+
shortcuts: options.shortcutOverrides === undefined
50+
? shortcuts
51+
: Array.isArray(options.shortcutOverrides)
52+
? [...options.shortcutOverrides, ...shortcuts]
53+
: [...Object.entries(options.shortcutOverrides), ...shortcuts],
5354
variants,
5455
}
5556
}

packages/preset-theme-default/src/shortcuts.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import type { Preset } from '@unocss/core'
1+
import type { Preset, StaticShortcutMap } from '@unocss/core'
22

3-
const shortcuts: Preset['shortcuts'] = [
3+
const shortcuts: Exclude<Preset['shortcuts'], undefined | StaticShortcutMap> = [
44
// 👉 States
55
[/^states:?(\d+)?$/, ([, op]) => `\
66
relative \

pnpm-lock.yaml

Lines changed: 3 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)