@keyfunc/keybricks-ds 2.6.0 → 2.8.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.
- package/DEPLOY.md +3 -3
- package/DESIGN.md +21 -5
- package/INTEGRATION.md +35 -4
- package/_adherence.oxlintrc.json +56 -11
- package/_ds_bundle.js +2153 -216
- package/_scripts/build-index.mjs +1 -1
- package/_src/icon-index.js +1 -1
- package/{components/feedback → _vue-services}/MESSAGE_SERVICES.md +2 -2
- package/_vue-services/_internal/MessageBoxView.vue +150 -0
- package/{components/feedback → _vue-services}/_internal/service-utils.js +0 -12
- package/_vue-services/message.js +87 -0
- package/assets/icons/icon-index.json +1 -1
- package/changelog.js +21 -2
- package/components/_cards/accordion.card.html +1 -1
- package/components/_cards/action-chip.card.html +1 -1
- package/components/_cards/activity.card.html +1 -1
- package/components/_cards/alert.card.html +1 -1
- package/components/_cards/app-chrome.card.html +1 -1
- package/components/_cards/banner.card.html +1 -1
- package/components/_cards/breadcrumb.card.html +1 -1
- package/components/_cards/button-1-base.card.html +5 -2
- package/components/_cards/button-2-states.card.html +5 -5
- package/components/_cards/button-3-sizes-icons.card.html +2 -2
- package/components/_cards/button-4-group.card.html +2 -2
- package/components/_cards/button-5-ai.card.html +34 -0
- package/components/_cards/canvas-zoom-controls.card.html +1 -1
- package/components/_cards/cards-indicators.card.html +1 -1
- package/components/_cards/charts-1-sparkline.card.html +1 -1
- package/components/_cards/charts-10-gauge.card.html +1 -1
- package/components/_cards/charts-11-funnel.card.html +1 -1
- package/components/_cards/charts-12-treemap.card.html +1 -1
- package/components/_cards/charts-14-radar.card.html +1 -1
- package/components/_cards/charts-15-distribution.card.html +1 -1
- package/components/_cards/charts-16-pareto.card.html +1 -1
- package/components/_cards/charts-17-candlestick.card.html +1 -1
- package/components/_cards/charts-18-sankey.card.html +1 -1
- package/components/_cards/charts-19-chord.card.html +1 -1
- package/components/_cards/charts-2-line.card.html +1 -1
- package/components/_cards/charts-20-sunburst.card.html +1 -1
- package/components/_cards/charts-21-worldmap.card.html +1 -1
- package/components/_cards/charts-22-gantt.card.html +1 -1
- package/components/_cards/charts-23-bar3d.card.html +1 -1
- package/components/_cards/charts-24-pie3d.card.html +1 -1
- package/components/_cards/charts-25-surface3d.card.html +1 -1
- package/components/_cards/charts-26-scatter3d.card.html +1 -1
- package/components/_cards/charts-27-ribbon3d.card.html +1 -1
- package/components/_cards/charts-3-bar.card.html +1 -1
- package/components/_cards/charts-4-barlist.card.html +1 -1
- package/components/_cards/charts-5-donut.card.html +1 -1
- package/components/_cards/charts-6-scatter.card.html +1 -1
- package/components/_cards/charts-7-heatmap.card.html +1 -1
- package/components/_cards/charts-8-waterfall.card.html +1 -1
- package/components/_cards/charts-9-bullet.card.html +1 -1
- package/components/_cards/charts-99-fullpage.card.html +1 -1
- package/components/_cards/checkbox.card.html +1 -1
- package/components/_cards/codeblock.card.html +1 -1
- package/components/_cards/combobox.card.html +1 -1
- package/components/_cards/context-menu.card.html +1 -1
- package/components/_cards/date-picker.card.html +1 -1
- package/components/_cards/diffvalue.card.html +1 -1
- package/components/_cards/divider.card.html +1 -1
- package/components/_cards/drawer.card.html +1 -1
- package/components/_cards/dropdown-menu.card.html +1 -1
- package/components/_cards/dropzone.card.html +1 -1
- package/components/_cards/empty-state.card.html +1 -1
- package/components/_cards/filter-bar.card.html +1 -1
- package/components/_cards/icon-button.card.html +1 -1
- package/components/_cards/icons-0-usage.card.html +2 -2
- package/components/_cards/icons-1-core.card.html +1 -1
- package/components/_cards/icons-2-feather.card.html +1 -1
- package/components/_cards/icons-2b-lucide.card.html +1 -1
- package/components/_cards/icons-3-unicons.card.html +1 -1
- package/components/_cards/icons-4-datasource.card.html +1 -1
- package/components/_cards/input.card.html +1 -1
- package/components/_cards/kbd.card.html +5 -7
- package/components/_cards/keyvalue.card.html +1 -1
- package/components/_cards/listrow.card.html +1 -1
- package/components/_cards/loading.card.html +1 -1
- package/components/_cards/log-viewer.card.html +1 -1
- package/components/_cards/modal.card.html +8 -2
- package/components/_cards/multi-select.card.html +1 -1
- package/components/_cards/number-stepper.card.html +1 -1
- package/components/_cards/pagination.card.html +1 -1
- package/components/_cards/people.card.html +1 -1
- package/components/_cards/pipeline-node.card.html +1 -1
- package/components/_cards/pipeline-palette.card.html +1 -1
- package/components/_cards/radio.card.html +1 -1
- package/components/_cards/relative-time-picker.card.html +1 -1
- package/components/_cards/search-global.card.html +72 -0
- package/components/_cards/search.card.html +1 -1
- package/components/_cards/segmented-control.card.html +1 -1
- package/components/_cards/select.card.html +1 -1
- package/components/_cards/slider.card.html +1 -1
- package/components/_cards/smart-table.card.html +1 -1
- package/components/_cards/spreadsheet.card.html +1 -1
- package/components/_cards/stepper.card.html +1 -1
- package/components/_cards/table.card.html +10 -1
- package/components/_cards/tabs.card.html +1 -1
- package/components/_cards/tag.card.html +1 -1
- package/components/_cards/textarea.card.html +1 -1
- package/components/_cards/timeline.card.html +1 -1
- package/components/_cards/toast.card.html +11 -1
- package/components/_cards/toggles.card.html +1 -1
- package/components/_cards/tooltip.card.html +1 -1
- package/components/_cards/tree.card.html +22 -1
- package/components/_vue/index.mjs +2 -0
- package/components/buttons/Button.d.ts +14 -5
- package/components/buttons/Button.jsx +45 -8
- package/components/buttons/Button.vue +40 -38
- package/components/buttons/Button.vue.d.ts +4 -1
- package/components/buttons/ai-button.js +54 -0
- package/components/buttons/buttons.prompt.md +7 -2
- package/components/data/Table.d.ts +5 -0
- package/components/data/Table.jsx +10 -5
- package/components/data/Table.vue +9 -3
- package/components/data/data.prompt.md +2 -0
- package/components/data/row-open.js +13 -0
- package/components/display/Kbd.d.ts +3 -1
- package/components/display/Kbd.jsx +8 -3
- package/components/display/Kbd.vue +7 -3
- package/components/display/display.prompt.md +3 -1
- package/components/feedback/Modal.d.ts +65 -7
- package/components/feedback/Modal.jsx +52 -22
- package/components/feedback/Modal.vue +24 -6
- package/components/feedback/Toast.vue +7 -7
- package/components/feedback/ToastStack.vue +37 -4
- package/components/feedback/feedback.prompt.md +6 -0
- package/components/feedback/modal-behavior.js +50 -0
- package/components/forms/GlobalSearch.d.ts +83 -0
- package/components/forms/GlobalSearch.jsx +172 -0
- package/components/forms/GlobalSearch.vue +161 -0
- package/components/forms/forms.prompt.md +7 -0
- package/components/forms/global-search.js +161 -0
- package/components/icons/Icon.d.ts +2 -0
- package/components/icons/Icon.jsx +14 -6
- package/components/icons/Icon.vue +11 -4
- package/components/icons/icon-paths.js +4 -2
- package/components/index.d.ts +1 -0
- package/components/index.js +1 -0
- package/components/navigation/TopBar.d.ts +9 -3
- package/components/navigation/TopBar.jsx +5 -7
- package/components/navigation/TopBar.vue +5 -6
- package/components/navigation/Tree.d.ts +5 -1
- package/components/navigation/Tree.jsx +9 -7
- package/components/navigation/Tree.vue +7 -6
- package/components/navigation/navigation.prompt.md +2 -0
- package/covers.js +4 -2
- package/gallery.html +1 -1
- package/guidelines/brand-logo.html +1 -1
- package/guidelines/colors-schemes.html +1 -1
- package/guidelines/colors-transparency.html +1 -1
- package/guidelines/foundations-borders.html +1 -1
- package/guidelines/foundations-chrome.html +1 -1
- package/guidelines/foundations-motion.html +1 -1
- package/guidelines/foundations-size-tiers.html +1 -1
- package/guidelines/foundations-spacing.html +1 -1
- package/guidelines/interaction-states.html +1 -1
- package/guidelines/type-extended.html +1 -1
- package/guidelines/type-mono.html +1 -1
- package/guidelines/type-scale.html +1 -1
- package/guidelines/type-weights.html +1 -1
- package/index.html +10 -10
- package/package.json +7 -6
- package/readme.md +4 -4
- package/readme.zh-CN.md +4 -4
- package/site-nav.js +1 -1
- package/styles.css +1 -0
- package/tokens/ai.css +17 -0
- package/tokens/colors.css +1 -1
- package/tokens/tokens.d.ts +28 -0
- package/tokens/tokens.js +47 -5
- package/tokens/tokens.json +123 -5
- package/components/feedback/_internal/MessageBoxView.vue +0 -237
- package/components/feedback/_internal/MessageView.vue +0 -73
- package/components/feedback/message.js +0 -68
- /package/{components/feedback → _vue-services}/message-box.d.ts +0 -0
- /package/{components/feedback → _vue-services}/message-box.js +0 -0
- /package/{components/feedback → _vue-services}/message.d.ts +0 -0
package/tokens/tokens.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@keyfunc/keybricks-ds",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.8.0",
|
|
4
4
|
"source": "tokens/*.css",
|
|
5
5
|
"note": "Generated by _scripts/build-tokens.mjs — CSS is the source of truth.",
|
|
6
6
|
"tokens": {
|
|
@@ -81,6 +81,91 @@
|
|
|
81
81
|
"value": "#2b7fff"
|
|
82
82
|
}
|
|
83
83
|
},
|
|
84
|
+
"--ai-glow-blur": {
|
|
85
|
+
"group": "ai",
|
|
86
|
+
"light": {
|
|
87
|
+
"raw": "6px",
|
|
88
|
+
"value": "6px"
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
"--ai-glow-opacity": {
|
|
92
|
+
"group": "ai",
|
|
93
|
+
"light": {
|
|
94
|
+
"raw": ".4",
|
|
95
|
+
"value": ".4"
|
|
96
|
+
},
|
|
97
|
+
"dark": {
|
|
98
|
+
"raw": ".3",
|
|
99
|
+
"value": ".3"
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
"--ai-gradient-end": {
|
|
103
|
+
"group": "ai",
|
|
104
|
+
"light": {
|
|
105
|
+
"raw": "var(--pink-500)",
|
|
106
|
+
"value": "#e355b2"
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
"--ai-gradient-start": {
|
|
110
|
+
"group": "ai",
|
|
111
|
+
"light": {
|
|
112
|
+
"raw": "var(--blue-500)",
|
|
113
|
+
"value": "#2b7fff"
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
"--ai-gradient-stops": {
|
|
117
|
+
"group": "ai",
|
|
118
|
+
"light": {
|
|
119
|
+
"raw": "var(--ai-gradient-start),var(--ai-gradient-end),var(--ai-gradient-start)",
|
|
120
|
+
"value": "#2b7fff,#e355b2,#2b7fff"
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
"--ai-ring-rest-track": {
|
|
124
|
+
"group": "ai",
|
|
125
|
+
"light": {
|
|
126
|
+
"raw": "var(--border-control)",
|
|
127
|
+
"value": "#e5e5e5"
|
|
128
|
+
},
|
|
129
|
+
"dark": {
|
|
130
|
+
"raw": "var(--border-control)",
|
|
131
|
+
"value": "#333333"
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
"--ai-ring-width": {
|
|
135
|
+
"group": "ai",
|
|
136
|
+
"light": {
|
|
137
|
+
"raw": "1px",
|
|
138
|
+
"value": "1px"
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
"--ai-spin-hover": {
|
|
142
|
+
"group": "ai",
|
|
143
|
+
"light": {
|
|
144
|
+
"raw": "1.2s",
|
|
145
|
+
"value": "1.2s"
|
|
146
|
+
}
|
|
147
|
+
},
|
|
148
|
+
"--ai-spin-rest": {
|
|
149
|
+
"group": "ai",
|
|
150
|
+
"light": {
|
|
151
|
+
"raw": "5s",
|
|
152
|
+
"value": "5s"
|
|
153
|
+
}
|
|
154
|
+
},
|
|
155
|
+
"--ai-tint": {
|
|
156
|
+
"group": "ai",
|
|
157
|
+
"light": {
|
|
158
|
+
"raw": "8%",
|
|
159
|
+
"value": "8%"
|
|
160
|
+
}
|
|
161
|
+
},
|
|
162
|
+
"--ai-tint-press": {
|
|
163
|
+
"group": "ai",
|
|
164
|
+
"light": {
|
|
165
|
+
"raw": "14%",
|
|
166
|
+
"value": "14%"
|
|
167
|
+
}
|
|
168
|
+
},
|
|
84
169
|
"--amber-100": {
|
|
85
170
|
"group": "colors-extended",
|
|
86
171
|
"light": {
|
|
@@ -2431,6 +2516,17 @@
|
|
|
2431
2516
|
"value": "#8f8f8f"
|
|
2432
2517
|
}
|
|
2433
2518
|
},
|
|
2519
|
+
"--shadow-drawer": {
|
|
2520
|
+
"group": "dark",
|
|
2521
|
+
"light": {
|
|
2522
|
+
"raw": "-8px 0 24px rgba(0,0,0,.12)",
|
|
2523
|
+
"value": "-8px 0 24px rgba(0,0,0,.12)"
|
|
2524
|
+
},
|
|
2525
|
+
"dark": {
|
|
2526
|
+
"raw": "-8px 0 24px rgba(0,0,0,.5)",
|
|
2527
|
+
"value": "-8px 0 24px rgba(0,0,0,.5)"
|
|
2528
|
+
}
|
|
2529
|
+
},
|
|
2434
2530
|
"--shadow-menu": {
|
|
2435
2531
|
"group": "dark",
|
|
2436
2532
|
"light": {
|
|
@@ -2464,6 +2560,17 @@
|
|
|
2464
2560
|
"value": "0 1px 3px 0 rgba(0,0,0,.6),0 1px 2px -1px rgba(0,0,0,.5)"
|
|
2465
2561
|
}
|
|
2466
2562
|
},
|
|
2563
|
+
"--shadow-raised": {
|
|
2564
|
+
"group": "dark",
|
|
2565
|
+
"light": {
|
|
2566
|
+
"raw": "0 1px 2px rgba(0,0,0,.08)",
|
|
2567
|
+
"value": "0 1px 2px rgba(0,0,0,.08)"
|
|
2568
|
+
},
|
|
2569
|
+
"dark": {
|
|
2570
|
+
"raw": "0 1px 2px rgba(0,0,0,.4)",
|
|
2571
|
+
"value": "0 1px 2px rgba(0,0,0,.4)"
|
|
2572
|
+
}
|
|
2573
|
+
},
|
|
2467
2574
|
"--shadow-selected": {
|
|
2468
2575
|
"group": "dark",
|
|
2469
2576
|
"light": {
|
|
@@ -2475,6 +2582,17 @@
|
|
|
2475
2582
|
"value": "0 0 0 2px rgba(43,127,255,.32),0 1px 3px 0 rgba(0,0,0,.6)"
|
|
2476
2583
|
}
|
|
2477
2584
|
},
|
|
2585
|
+
"--shadow-thumb": {
|
|
2586
|
+
"group": "dark",
|
|
2587
|
+
"light": {
|
|
2588
|
+
"raw": "0 1px 2px rgba(0,0,0,.15)",
|
|
2589
|
+
"value": "0 1px 2px rgba(0,0,0,.15)"
|
|
2590
|
+
},
|
|
2591
|
+
"dark": {
|
|
2592
|
+
"raw": "0 1px 2px rgba(0,0,0,.5)",
|
|
2593
|
+
"value": "0 1px 2px rgba(0,0,0,.5)"
|
|
2594
|
+
}
|
|
2595
|
+
},
|
|
2478
2596
|
"--sidebar-w": {
|
|
2479
2597
|
"group": "layout",
|
|
2480
2598
|
"light": {
|
|
@@ -2584,15 +2702,15 @@
|
|
|
2584
2702
|
"--switch-h": {
|
|
2585
2703
|
"group": "layout",
|
|
2586
2704
|
"light": {
|
|
2587
|
-
"raw": "
|
|
2588
|
-
"value": "
|
|
2705
|
+
"raw": "18px",
|
|
2706
|
+
"value": "18px"
|
|
2589
2707
|
}
|
|
2590
2708
|
},
|
|
2591
2709
|
"--switch-w": {
|
|
2592
2710
|
"group": "layout",
|
|
2593
2711
|
"light": {
|
|
2594
|
-
"raw": "
|
|
2595
|
-
"value": "
|
|
2712
|
+
"raw": "32px",
|
|
2713
|
+
"value": "32px"
|
|
2596
2714
|
}
|
|
2597
2715
|
},
|
|
2598
2716
|
"--t-hover": {
|
|
@@ -1,237 +0,0 @@
|
|
|
1
|
-
<script setup>
|
|
2
|
-
import { computed, h, isVNode, nextTick, onBeforeUnmount, onMounted, ref } from 'vue'
|
|
3
|
-
import Button from '../../buttons/Button.vue'
|
|
4
|
-
import IconButton from '../../buttons/IconButton.vue'
|
|
5
|
-
import Icon from '../../icons/Icon.vue'
|
|
6
|
-
import { contentNode, lockBody } from './service-utils.js'
|
|
7
|
-
|
|
8
|
-
const props = defineProps({ options: { type: Object, required: true } })
|
|
9
|
-
const emit = defineEmits(['action'])
|
|
10
|
-
const panel = ref(null)
|
|
11
|
-
const input = ref(null)
|
|
12
|
-
const error = ref('')
|
|
13
|
-
const validating = ref(false)
|
|
14
|
-
const Content = () => contentNode(props.options.message, props.options.dangerouslyUseHTMLString)
|
|
15
|
-
const Title = () => contentNode(props.options.title)
|
|
16
|
-
const icons = { success: 'circle-check', warning: 'triangle-alert', error: 'triangle-alert', info: 'info' }
|
|
17
|
-
const colors = { success: 'var(--success-strong)', warning: 'var(--warning)', error: 'var(--danger)', info: 'var(--action-primary)' }
|
|
18
|
-
const icon = computed(() => props.options.icon || icons[props.options.type])
|
|
19
|
-
const CustomIcon = () => isVNode(icon.value) ? icon.value : h(icon.value)
|
|
20
|
-
const confirmVariant = computed(() => props.options.confirmButtonClass?.includes('el-button--danger') ? 'danger' : 'primary')
|
|
21
|
-
let unlock
|
|
22
|
-
let previousFocus
|
|
23
|
-
let disposed = false
|
|
24
|
-
let validationRevision = 0
|
|
25
|
-
|
|
26
|
-
async function confirm() {
|
|
27
|
-
const options = props.options
|
|
28
|
-
if (validating.value || options.confirmButtonDisabled || options.confirmButtonLoading) return
|
|
29
|
-
if (options.showInput) {
|
|
30
|
-
const revision = ++validationRevision
|
|
31
|
-
const value = options.inputValue ?? ''
|
|
32
|
-
validating.value = true
|
|
33
|
-
let message = ''
|
|
34
|
-
try {
|
|
35
|
-
if (options.inputPattern) {
|
|
36
|
-
// 避免全局正则的 lastIndex 导致同一输入校验结果交替。
|
|
37
|
-
const pattern = new RegExp(options.inputPattern.source, options.inputPattern.flags)
|
|
38
|
-
if (!pattern.test(value)) message = options.inputErrorMessage || 'Invalid input'
|
|
39
|
-
}
|
|
40
|
-
if (!message && options.inputValidator) {
|
|
41
|
-
const result = await options.inputValidator(value)
|
|
42
|
-
if (result === false || typeof result === 'string') message = result || options.inputErrorMessage || 'Invalid input'
|
|
43
|
-
}
|
|
44
|
-
} catch (reason) {
|
|
45
|
-
message = options.inputErrorMessage || reason?.message || 'Invalid input'
|
|
46
|
-
} finally {
|
|
47
|
-
validating.value = false
|
|
48
|
-
}
|
|
49
|
-
if (disposed || revision !== validationRevision) return
|
|
50
|
-
error.value = message
|
|
51
|
-
if (message) { input.value?.focus(); return }
|
|
52
|
-
}
|
|
53
|
-
emit('action', 'confirm')
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
function close() { emit('action', 'close') }
|
|
57
|
-
function onKeydown(event) {
|
|
58
|
-
if (event.key === 'Escape' && props.options.closeOnPressEscape) {
|
|
59
|
-
event.preventDefault()
|
|
60
|
-
event.stopImmediatePropagation()
|
|
61
|
-
close()
|
|
62
|
-
}
|
|
63
|
-
if (event.key !== 'Tab') return
|
|
64
|
-
const focusable = [...panel.value.querySelectorAll('button:not(:disabled), input:not(:disabled), textarea:not(:disabled), select:not(:disabled), a[href], [tabindex]:not([tabindex="-1"])')]
|
|
65
|
-
.filter(node => node.getClientRects().length)
|
|
66
|
-
const first = focusable[0], last = focusable[focusable.length - 1]
|
|
67
|
-
if (!first) { event.preventDefault(); panel.value.focus(); return }
|
|
68
|
-
if (event.shiftKey && (document.activeElement === first || !panel.value.contains(document.activeElement))) {
|
|
69
|
-
event.preventDefault(); last.focus()
|
|
70
|
-
} else if (!event.shiftKey && (document.activeElement === last || !panel.value.contains(document.activeElement))) {
|
|
71
|
-
event.preventDefault(); first.focus()
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
function keepFocus(event) {
|
|
75
|
-
if (!panel.value.contains(event.target)) panel.value.focus()
|
|
76
|
-
}
|
|
77
|
-
function changeInput(event) {
|
|
78
|
-
validationRevision++
|
|
79
|
-
props.options.inputValue = event.target.value
|
|
80
|
-
error.value = ''
|
|
81
|
-
}
|
|
82
|
-
onMounted(async () => {
|
|
83
|
-
previousFocus = document.activeElement
|
|
84
|
-
if (props.options.lockScroll) unlock = lockBody()
|
|
85
|
-
document.addEventListener('keydown', onKeydown, true)
|
|
86
|
-
document.addEventListener('focusin', keepFocus)
|
|
87
|
-
await nextTick()
|
|
88
|
-
if (disposed || !props.options.autofocus) return
|
|
89
|
-
const target = input.value || panel.value.querySelector('[data-confirm] button') || panel.value
|
|
90
|
-
target.focus()
|
|
91
|
-
if (input.value) input.value.select()
|
|
92
|
-
})
|
|
93
|
-
onBeforeUnmount(() => {
|
|
94
|
-
disposed = true
|
|
95
|
-
unlock?.()
|
|
96
|
-
document.removeEventListener('keydown', onKeydown, true)
|
|
97
|
-
document.removeEventListener('focusin', keepFocus)
|
|
98
|
-
if (previousFocus?.isConnected) previousFocus.focus()
|
|
99
|
-
})
|
|
100
|
-
</script>
|
|
101
|
-
|
|
102
|
-
<template>
|
|
103
|
-
<div
|
|
104
|
-
:class="['kb-message-box-overlay', options.modalClass]"
|
|
105
|
-
:style="{ zIndex: options.zIndex ?? 'var(--z-modal)', background: options.modal === false ? 'transparent' : undefined }"
|
|
106
|
-
@click.self="options.closeOnClickModal && close()"
|
|
107
|
-
>
|
|
108
|
-
<section
|
|
109
|
-
ref="panel"
|
|
110
|
-
:class="['kb-message-box', options.customClass, { 'kb-message-box--center': options.center, 'kb-message-box--round': options.roundButton }]"
|
|
111
|
-
:style="{ width: typeof options.width === 'number' ? `${options.width}px` : options.width }"
|
|
112
|
-
:data-size="options.size || 'lg'"
|
|
113
|
-
:aria-labelledby="`${options.id}-title`"
|
|
114
|
-
:aria-describedby="`${options.id}-content`"
|
|
115
|
-
role="alertdialog"
|
|
116
|
-
aria-modal="true"
|
|
117
|
-
tabindex="-1"
|
|
118
|
-
>
|
|
119
|
-
<header class="kb-message-box__header">
|
|
120
|
-
<span :id="`${options.id}-title`"><Title /></span>
|
|
121
|
-
<IconButton v-if="options.showClose" icon="x" :label="options.closeLabel || 'Close'" @click="close" />
|
|
122
|
-
</header>
|
|
123
|
-
<div :id="`${options.id}-content`" class="kb-message-box__body">
|
|
124
|
-
<div class="kb-message-box__message">
|
|
125
|
-
<span v-if="icon" :style="{ color: colors[options.type], display: 'inline-flex' }">
|
|
126
|
-
<Icon v-if="typeof icon === 'string'" :name="icon" :size="20" />
|
|
127
|
-
<CustomIcon v-else />
|
|
128
|
-
</span>
|
|
129
|
-
<div><Content /></div>
|
|
130
|
-
</div>
|
|
131
|
-
<div v-if="options.showInput" class="kb-message-box__input-wrap">
|
|
132
|
-
<component
|
|
133
|
-
:is="options.inputType === 'textarea' ? 'textarea' : 'input'"
|
|
134
|
-
ref="input"
|
|
135
|
-
class="kb-message-box__input"
|
|
136
|
-
:type="options.inputType === 'textarea' ? undefined : options.inputType"
|
|
137
|
-
:value="options.inputValue"
|
|
138
|
-
:placeholder="options.inputPlaceholder"
|
|
139
|
-
:aria-label="options.inputPlaceholder || options.title || 'Input'"
|
|
140
|
-
:aria-invalid="!!error"
|
|
141
|
-
:aria-describedby="error ? `${options.id}-error` : undefined"
|
|
142
|
-
@input="changeInput"
|
|
143
|
-
@keydown.enter="!$event.isComposing && options.inputType !== 'textarea' && confirm()"
|
|
144
|
-
/>
|
|
145
|
-
<div v-if="error" :id="`${options.id}-error`" class="kb-message-box__error" role="alert">{{ error }}</div>
|
|
146
|
-
</div>
|
|
147
|
-
</div>
|
|
148
|
-
<footer class="kb-message-box__footer">
|
|
149
|
-
<Button
|
|
150
|
-
v-if="options.showCancelButton"
|
|
151
|
-
variant="outline"
|
|
152
|
-
:class="options.cancelButtonClass"
|
|
153
|
-
:disabled="options.cancelButtonDisabled"
|
|
154
|
-
:loading="options.cancelButtonLoading"
|
|
155
|
-
@click="emit('action', 'cancel')"
|
|
156
|
-
>
|
|
157
|
-
{{ options.cancelButtonText ?? 'Cancel' }}
|
|
158
|
-
</Button>
|
|
159
|
-
<span v-if="options.showConfirmButton" data-confirm>
|
|
160
|
-
<Button
|
|
161
|
-
:variant="confirmVariant"
|
|
162
|
-
:class="options.confirmButtonClass"
|
|
163
|
-
:disabled="options.confirmButtonDisabled"
|
|
164
|
-
:loading="options.confirmButtonLoading || validating"
|
|
165
|
-
@click="confirm"
|
|
166
|
-
>
|
|
167
|
-
{{ options.confirmButtonText ?? 'OK' }}
|
|
168
|
-
</Button>
|
|
169
|
-
</span>
|
|
170
|
-
</footer>
|
|
171
|
-
</section>
|
|
172
|
-
</div>
|
|
173
|
-
</template>
|
|
174
|
-
|
|
175
|
-
<style scoped>
|
|
176
|
-
.kb-message-box-overlay {
|
|
177
|
-
position: fixed;
|
|
178
|
-
inset: 0;
|
|
179
|
-
display: flex;
|
|
180
|
-
align-items: center;
|
|
181
|
-
justify-content: center;
|
|
182
|
-
background: var(--bg-scrim);
|
|
183
|
-
animation: kb-fade-in var(--dur-fast) var(--ease-out);
|
|
184
|
-
}
|
|
185
|
-
.kb-message-box {
|
|
186
|
-
width: 440px;
|
|
187
|
-
max-width: 92vw;
|
|
188
|
-
max-height: 92vh;
|
|
189
|
-
overflow: auto;
|
|
190
|
-
box-sizing: border-box;
|
|
191
|
-
background: var(--bg-raised);
|
|
192
|
-
border: 1px solid var(--border-card);
|
|
193
|
-
border-radius: var(--radius-lg);
|
|
194
|
-
box-shadow: var(--shadow-modal);
|
|
195
|
-
font-family: var(--font-sans);
|
|
196
|
-
font-size: var(--text-base);
|
|
197
|
-
line-height: var(--leading-base);
|
|
198
|
-
letter-spacing: var(--tracking-base);
|
|
199
|
-
color: var(--text-body);
|
|
200
|
-
animation: kb-rise var(--dur) var(--ease-out);
|
|
201
|
-
}
|
|
202
|
-
.kb-message-box__header {
|
|
203
|
-
display: flex;
|
|
204
|
-
align-items: center;
|
|
205
|
-
justify-content: space-between;
|
|
206
|
-
gap: var(--group-gap);
|
|
207
|
-
padding: var(--section-gap) var(--section-gap) 0;
|
|
208
|
-
font-weight: var(--weight-semibold);
|
|
209
|
-
font-size: var(--text-md);
|
|
210
|
-
line-height: var(--leading-md);
|
|
211
|
-
letter-spacing: var(--tracking-md);
|
|
212
|
-
color: var(--text-heading);
|
|
213
|
-
}
|
|
214
|
-
.kb-message-box__header > span { min-width: 0; overflow-wrap: anywhere; }
|
|
215
|
-
.kb-message-box__body { padding: 20px var(--section-gap) 0; }
|
|
216
|
-
.kb-message-box__message { display: flex; align-items: flex-start; gap: var(--control-px); }
|
|
217
|
-
.kb-message-box__message > div { min-width: 0; overflow-wrap: anywhere; white-space: pre-wrap; }
|
|
218
|
-
.kb-message-box__input-wrap { margin-top: var(--group-gap); }
|
|
219
|
-
.kb-message-box__input {
|
|
220
|
-
box-sizing: border-box;
|
|
221
|
-
width: 100%;
|
|
222
|
-
min-height: var(--control-h);
|
|
223
|
-
padding: 0 var(--control-px);
|
|
224
|
-
font: inherit;
|
|
225
|
-
color: var(--text-heading);
|
|
226
|
-
background: var(--bg-surface);
|
|
227
|
-
border: 1px solid var(--border-control);
|
|
228
|
-
border-radius: var(--radius-md);
|
|
229
|
-
}
|
|
230
|
-
.kb-message-box__input:focus { outline: none; border-color: var(--focus-border); box-shadow: var(--ring-focus); }
|
|
231
|
-
.kb-message-box__input[aria-invalid="true"] { border-color: var(--danger); }
|
|
232
|
-
.kb-message-box__error { margin-top: var(--control-gap); color: var(--danger-text); }
|
|
233
|
-
.kb-message-box__footer { display: flex; justify-content: flex-end; gap: var(--control-gap); padding: var(--section-gap); }
|
|
234
|
-
.kb-message-box--center .kb-message-box__message { justify-content: center; text-align: center; }
|
|
235
|
-
.kb-message-box--center .kb-message-box__footer { justify-content: center; }
|
|
236
|
-
.kb-message-box--round :deep(.kb-message-box__footer button) { border-radius: var(--radius-full) !important; }
|
|
237
|
-
</style>
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
<script setup>
|
|
2
|
-
import { computed, h, isVNode, onBeforeUnmount, onMounted, ref, watch } from 'vue'
|
|
3
|
-
import Toast from '../Toast.vue'
|
|
4
|
-
import Icon from '../../icons/Icon.vue'
|
|
5
|
-
import { contentNode } from './service-utils.js'
|
|
6
|
-
|
|
7
|
-
const props = defineProps({ options: { type: Object, required: true } })
|
|
8
|
-
const emit = defineEmits(['close', 'height'])
|
|
9
|
-
const root = ref(null)
|
|
10
|
-
const tone = computed(() => props.options.type === 'error' ? 'danger' : props.options.type)
|
|
11
|
-
const Content = () => contentNode(props.options.message, props.options.dangerouslyUseHTMLString)
|
|
12
|
-
const CustomIcon = () => typeof props.options.icon === 'string'
|
|
13
|
-
? h(Icon, { name: props.options.icon, size: 16 })
|
|
14
|
-
: isVNode(props.options.icon) ? props.options.icon : h(props.options.icon)
|
|
15
|
-
let timer
|
|
16
|
-
let observer
|
|
17
|
-
let paused = false
|
|
18
|
-
function stop() { clearTimeout(timer) }
|
|
19
|
-
function start() {
|
|
20
|
-
stop()
|
|
21
|
-
if (!paused && props.options.duration > 0) timer = setTimeout(() => emit('close'), props.options.duration)
|
|
22
|
-
}
|
|
23
|
-
function onEscape(event) {
|
|
24
|
-
if (event.key === 'Escape') emit('close')
|
|
25
|
-
}
|
|
26
|
-
watch(() => [props.options.restart, props.options.duration], start)
|
|
27
|
-
onMounted(() => {
|
|
28
|
-
start()
|
|
29
|
-
const measure = () => emit('height', root.value.getBoundingClientRect().height)
|
|
30
|
-
measure()
|
|
31
|
-
if (typeof ResizeObserver !== 'undefined') {
|
|
32
|
-
observer = new ResizeObserver(measure)
|
|
33
|
-
observer.observe(root.value)
|
|
34
|
-
}
|
|
35
|
-
document.addEventListener('keydown', onEscape)
|
|
36
|
-
})
|
|
37
|
-
onBeforeUnmount(() => {
|
|
38
|
-
stop()
|
|
39
|
-
observer?.disconnect()
|
|
40
|
-
document.removeEventListener('keydown', onEscape)
|
|
41
|
-
})
|
|
42
|
-
</script>
|
|
43
|
-
|
|
44
|
-
<template>
|
|
45
|
-
<div
|
|
46
|
-
:id="options.id"
|
|
47
|
-
ref="root"
|
|
48
|
-
:class="['kb-message', options.customClass, { 'kb-message--center': options.center, 'kb-message--plain': options.plain }]"
|
|
49
|
-
:role="options.type === 'error' || options.type === 'warning' ? 'alert' : 'status'"
|
|
50
|
-
:style="{ position: 'fixed', top: `${options.top}px`, left: '50%', transform: 'translateX(-50%)', zIndex: options.zIndex ?? 'var(--z-toast)', maxWidth: '92vw' }"
|
|
51
|
-
@mouseenter="paused = true; stop()"
|
|
52
|
-
@mouseleave="paused = false; start()"
|
|
53
|
-
@focusin="paused = true; stop()"
|
|
54
|
-
@focusout="paused = false; start()"
|
|
55
|
-
>
|
|
56
|
-
<Toast
|
|
57
|
-
:tone="tone"
|
|
58
|
-
:dismissible="options.showClose"
|
|
59
|
-
:close-label="options.closeLabel"
|
|
60
|
-
:style="{ minWidth: 'min(280px, 92vw)', maxWidth: '100%', boxSizing: 'border-box', ...(options.plain ? { boxShadow: 'none' } : {}) }"
|
|
61
|
-
@close="emit('close')"
|
|
62
|
-
>
|
|
63
|
-
<template v-if="options.icon" #icon><CustomIcon /></template>
|
|
64
|
-
<Content />
|
|
65
|
-
<span v-if="options.repeatNum > 1" class="kb-message__count"> × {{ options.repeatNum }}</span>
|
|
66
|
-
</Toast>
|
|
67
|
-
</div>
|
|
68
|
-
</template>
|
|
69
|
-
|
|
70
|
-
<style scoped>
|
|
71
|
-
.kb-message--center { text-align: center; }
|
|
72
|
-
.kb-message__count { color: var(--text-secondary); font-variant-numeric: tabular-nums; }
|
|
73
|
-
</style>
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { getCurrentInstance, isVNode, reactive } from 'vue'
|
|
2
|
-
import MessageView from './_internal/MessageView.vue'
|
|
3
|
-
import { mountService, resolveTarget } from './_internal/service-utils.js'
|
|
4
|
-
|
|
5
|
-
const instances = []
|
|
6
|
-
let seed = 0
|
|
7
|
-
const normalize = value => typeof value === 'string' || typeof value === 'function' || isVNode(value)
|
|
8
|
-
? { message: value } : { ...value }
|
|
9
|
-
|
|
10
|
-
/** Vue 消息服务;样式由 Toast 提供,业务错误脱敏仍由应用处理。 */
|
|
11
|
-
export function Message(value = {}, appContext) {
|
|
12
|
-
if (typeof document === 'undefined') return { close() {} }
|
|
13
|
-
const options = { type: 'info', duration: 3000, offset: 16, ...Message.defaults, ...normalize(value) }
|
|
14
|
-
const target = resolveTarget(options)
|
|
15
|
-
if (options.grouping) {
|
|
16
|
-
const existing = instances.find(item => item.target === target && item.options.message === options.message)
|
|
17
|
-
if (existing) {
|
|
18
|
-
existing.options.repeatNum++
|
|
19
|
-
existing.options.type = options.type
|
|
20
|
-
existing.options.restart++
|
|
21
|
-
return existing.handle
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
const state = reactive({ ...options, id: `kb-message-${++seed}`, repeatNum: 1, restart: 0, height: 0, top: options.offset })
|
|
25
|
-
let dispose
|
|
26
|
-
let closed = false
|
|
27
|
-
const handle = { close() {
|
|
28
|
-
if (closed) return
|
|
29
|
-
closed = true
|
|
30
|
-
instances.splice(instances.indexOf(entry), 1)
|
|
31
|
-
dispose?.()
|
|
32
|
-
reflow()
|
|
33
|
-
options.onClose?.(handle)
|
|
34
|
-
} }
|
|
35
|
-
const entry = { options: state, handle, target }
|
|
36
|
-
function reflow() {
|
|
37
|
-
const tops = new Map()
|
|
38
|
-
for (const item of instances) {
|
|
39
|
-
const target = item.target
|
|
40
|
-
item.options.top = Math.max(Number(item.options.offset) || 0, tops.get(target) || 0)
|
|
41
|
-
tops.set(target, item.options.top + item.options.height + 16)
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
instances.push(entry)
|
|
45
|
-
try {
|
|
46
|
-
dispose = mountService(MessageView, {
|
|
47
|
-
options: state, onClose: handle.close,
|
|
48
|
-
onHeight: height => { state.height = height; reflow() },
|
|
49
|
-
}, options, appContext || getCurrentInstance()?.appContext)
|
|
50
|
-
} catch (error) {
|
|
51
|
-
instances.splice(instances.indexOf(entry), 1)
|
|
52
|
-
reflow()
|
|
53
|
-
throw error
|
|
54
|
-
}
|
|
55
|
-
reflow()
|
|
56
|
-
return handle
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
for (const type of ['success', 'info', 'warning', 'error']) {
|
|
60
|
-
Message[type] = (value, appContext) => Message({ ...normalize(value), type }, appContext)
|
|
61
|
-
}
|
|
62
|
-
Message.closeAll = type => {
|
|
63
|
-
for (const entry of [...instances]) {
|
|
64
|
-
if (!type || entry.options.type === type) entry.handle.close()
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
export default Message
|
|
68
|
-
Message.defaults = {}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|