niuma-ui 1.0.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/CHANGELOG.md +29 -0
- package/LICENSE +202 -0
- package/NOTICE +25 -0
- package/README.en.md +99 -0
- package/README.md +161 -0
- package/package.json +106 -0
- package/src/__tests__/RsBadge.spec.ts +40 -0
- package/src/__tests__/RsBreadcrumb.spec.ts +172 -0
- package/src/__tests__/RsButton.spec.ts +108 -0
- package/src/__tests__/RsCalendarGrid.spec.ts +82 -0
- package/src/__tests__/RsCard.spec.ts +97 -0
- package/src/__tests__/RsCheckbox.spec.ts +36 -0
- package/src/__tests__/RsCodeEditor.spec.ts +111 -0
- package/src/__tests__/RsConfirmDialog.spec.ts +158 -0
- package/src/__tests__/RsContainer.spec.ts +89 -0
- package/src/__tests__/RsContextMenu.spec.ts +118 -0
- package/src/__tests__/RsDatePicker.spec.ts +88 -0
- package/src/__tests__/RsDateTimePicker.spec.ts +69 -0
- package/src/__tests__/RsDialog.spec.ts +404 -0
- package/src/__tests__/RsDrawer.spec.ts +145 -0
- package/src/__tests__/RsDropdown.spec.ts +135 -0
- package/src/__tests__/RsEmpty.spec.ts +99 -0
- package/src/__tests__/RsForm.spec.ts +173 -0
- package/src/__tests__/RsIcon.spec.ts +244 -0
- package/src/__tests__/RsInput.spec.ts +269 -0
- package/src/__tests__/RsInputNumber.spec.ts +118 -0
- package/src/__tests__/RsLabel.spec.ts +106 -0
- package/src/__tests__/RsLink.spec.ts +49 -0
- package/src/__tests__/RsLoading.spec.ts +84 -0
- package/src/__tests__/RsMarkdown.spec.ts +143 -0
- package/src/__tests__/RsMenu.spec.ts +119 -0
- package/src/__tests__/RsNewComponents.spec.ts +17 -0
- package/src/__tests__/RsPagination.spec.ts +158 -0
- package/src/__tests__/RsPopover.spec.ts +126 -0
- package/src/__tests__/RsScrollbar.spec.ts +53 -0
- package/src/__tests__/RsSelect.spec.ts +291 -0
- package/src/__tests__/RsSidebar.spec.ts +119 -0
- package/src/__tests__/RsSplitPane.spec.ts +177 -0
- package/src/__tests__/RsStatCard.spec.ts +79 -0
- package/src/__tests__/RsSteps.spec.ts +125 -0
- package/src/__tests__/RsTable.perf.spec.ts +103 -0
- package/src/__tests__/RsTable.spec.ts +1135 -0
- package/src/__tests__/RsTabs.spec.ts +328 -0
- package/src/__tests__/RsTerminal.spec.ts +218 -0
- package/src/__tests__/RsTimePicker.spec.ts +77 -0
- package/src/__tests__/RsToaster.spec.ts +95 -0
- package/src/__tests__/RsToolbar.spec.ts +75 -0
- package/src/__tests__/RsTooltip.spec.ts +111 -0
- package/src/__tests__/RsTree.spec.ts +572 -0
- package/src/__tests__/RsUpload.spec.ts +160 -0
- package/src/__tests__/RsVirtualList.spec.ts +77 -0
- package/src/__tests__/date-picker-utils.spec.ts +70 -0
- package/src/__tests__/dialog-viewport.spec.ts +38 -0
- package/src/__tests__/iso-local-datetime.spec.ts +58 -0
- package/src/__tests__/rs-clipboard.spec.ts +142 -0
- package/src/__tests__/setup.ts +12 -0
- package/src/__tests__/split-pane-utils.spec.ts +136 -0
- package/src/__tests__/table-drag.spec.ts +35 -0
- package/src/__tests__/table-edit-utils.spec.ts +194 -0
- package/src/__tests__/table-utils.spec.ts +286 -0
- package/src/__tests__/theme.spec.ts +22 -0
- package/src/__tests__/tree-utils.spec.ts +234 -0
- package/src/__tests__/useTableCellTooltip.spec.ts +101 -0
- package/src/components/RsAvatar.vue +115 -0
- package/src/components/RsBadge.vue +59 -0
- package/src/components/RsBreadcrumb.vue +65 -0
- package/src/components/RsBreadcrumbItems.vue +36 -0
- package/src/components/RsButton.vue +393 -0
- package/src/components/RsCalendarGrid.vue +284 -0
- package/src/components/RsCard.vue +237 -0
- package/src/components/RsCheckbox.vue +189 -0
- package/src/components/RsCodeBlock.vue +278 -0
- package/src/components/RsCodeEditor.vue +597 -0
- package/src/components/RsConfigProvider.vue +92 -0
- package/src/components/RsConfirmDialog.vue +178 -0
- package/src/components/RsContainer.vue +235 -0
- package/src/components/RsContextMenu.vue +238 -0
- package/src/components/RsContextMenuItems.vue +77 -0
- package/src/components/RsDatePicker.vue +756 -0
- package/src/components/RsDateTimePicker.vue +42 -0
- package/src/components/RsDialog.vue +486 -0
- package/src/components/RsDrawer.vue +175 -0
- package/src/components/RsDropdown.vue +252 -0
- package/src/components/RsDropdownItems.vue +90 -0
- package/src/components/RsEmpty.vue +107 -0
- package/src/components/RsForm.vue +131 -0
- package/src/components/RsIcon.vue +104 -0
- package/src/components/RsInput.vue +1101 -0
- package/src/components/RsInputNumber.vue +532 -0
- package/src/components/RsLabel.vue +54 -0
- package/src/components/RsLink.vue +106 -0
- package/src/components/RsLoading.vue +171 -0
- package/src/components/RsMarkdown.vue +329 -0
- package/src/components/RsMenu.vue +256 -0
- package/src/components/RsMenuItems.vue +125 -0
- package/src/components/RsMonacoEditor.vue +541 -0
- package/src/components/RsPagination.vue +184 -0
- package/src/components/RsPopover.vue +77 -0
- package/src/components/RsProseEditor.vue +160 -0
- package/src/components/RsScrollbar.vue +171 -0
- package/src/components/RsSelect.vue +1045 -0
- package/src/components/RsSidebar.vue +121 -0
- package/src/components/RsSidebarGroup.vue +32 -0
- package/src/components/RsSidebarItem.vue +72 -0
- package/src/components/RsSplitPane.vue +619 -0
- package/src/components/RsStatCard.vue +85 -0
- package/src/components/RsSteps.vue +138 -0
- package/src/components/RsTable.vue +2664 -0
- package/src/components/RsTableColgroup.vue +17 -0
- package/src/components/RsTableHeaderRow.vue +30 -0
- package/src/components/RsTabs.vue +951 -0
- package/src/components/RsTerminal.vue +697 -0
- package/src/components/RsTimePicker.vue +554 -0
- package/src/components/RsTimePickerColumns.vue +226 -0
- package/src/components/RsToaster.vue +396 -0
- package/src/components/RsToolbar.vue +135 -0
- package/src/components/RsTooltip.vue +142 -0
- package/src/components/RsTooltipProvider.vue +20 -0
- package/src/components/RsTree.vue +1248 -0
- package/src/components/RsUpload.vue +279 -0
- package/src/components/RsVirtualList.vue +217 -0
- package/src/components/avatar-utils.ts +19 -0
- package/src/components/breadcrumb-utils.ts +19 -0
- package/src/components/class-utils.ts +29 -0
- package/src/components/code-editor-utils.ts +106 -0
- package/src/components/code-mirror-completion.ts +40 -0
- package/src/components/code-mirror-diagnostics.ts +52 -0
- package/src/components/code-mirror-ghost.ts +158 -0
- package/src/components/code-mirror-inline-edit.ts +55 -0
- package/src/components/code-mirror-intel.ts +81 -0
- package/src/components/code-mirror-lang.ts +128 -0
- package/src/components/context-menu-utils.ts +20 -0
- package/src/components/date-picker-utils.ts +284 -0
- package/src/components/date-range-validation.ts +29 -0
- package/src/components/date-validation.ts +38 -0
- package/src/components/dialog-viewport.ts +48 -0
- package/src/components/dialog-window.ts +253 -0
- package/src/components/dropdown-utils.ts +31 -0
- package/src/components/form-utils.ts +77 -0
- package/src/components/input-number-utils.ts +128 -0
- package/src/components/input-rules.ts +84 -0
- package/src/components/loading-utils.ts +8 -0
- package/src/components/markdown-utils.ts +126 -0
- package/src/components/menu-utils.ts +48 -0
- package/src/components/overlay-utils.ts +47 -0
- package/src/components/pagination-utils.ts +38 -0
- package/src/components/popover-utils.ts +8 -0
- package/src/components/reka.ts +106 -0
- package/src/components/resolve-radius.ts +22 -0
- package/src/components/resolve-size.ts +29 -0
- package/src/components/scrollbar-utils.ts +10 -0
- package/src/components/select-utils.ts +72 -0
- package/src/components/split-pane-utils.ts +187 -0
- package/src/components/steps-utils.ts +22 -0
- package/src/components/table/RsTableBodyRow.vue +287 -0
- package/src/components/table/RsTableCell.vue +239 -0
- package/src/components/table/RsTableCellContent.ts +18 -0
- package/src/components/table/RsTableCellEditor.vue +351 -0
- package/src/components/table/RsTableEditGutter.vue +54 -0
- package/src/components/table/RsTableHeaderFilter.vue +107 -0
- package/src/components/table/RsTableRowStatus.vue +69 -0
- package/src/components/table/rs-table.css +1141 -0
- package/src/components/table/table-context-menu.ts +53 -0
- package/src/components/table/table-edit-utils.ts +496 -0
- package/src/components/table/table-keys.ts +12 -0
- package/src/components/table-drag.ts +215 -0
- package/src/components/table-utils.ts +950 -0
- package/src/components/tabs-utils.ts +107 -0
- package/src/components/terminal-utils.ts +301 -0
- package/src/components/terminal-wheel.ts +49 -0
- package/src/components/time-picker-utils.ts +167 -0
- package/src/components/time-range-validation.ts +23 -0
- package/src/components/time-validation.ts +20 -0
- package/src/components/tree-utils.ts +518 -0
- package/src/components/upload-utils.ts +55 -0
- package/src/components/virtual-list-utils.ts +17 -0
- package/src/composables/useClickOutside.ts +22 -0
- package/src/composables/useRsConfig.ts +91 -0
- package/src/composables/useRsI18n.ts +22 -0
- package/src/composables/useRsTabsNav.ts +187 -0
- package/src/composables/useRsToast.ts +48 -0
- package/src/composables/useTableCellTooltip.ts +239 -0
- package/src/composables/useTableEdit.ts +271 -0
- package/src/composables/useTableRowHighlight.ts +50 -0
- package/src/dev/vite-codemirror-deps.ts +20 -0
- package/src/icons/custom/api.ts +54 -0
- package/src/icons/custom/clickhouse.ts +52 -0
- package/src/icons/custom/dameng.ts +83 -0
- package/src/icons/custom/ftp.ts +61 -0
- package/src/icons/custom/kingbase.ts +52 -0
- package/src/icons/custom/mongodb.ts +50 -0
- package/src/icons/custom/mysql.ts +51 -0
- package/src/icons/custom/oracle.ts +52 -0
- package/src/icons/custom/redis.ts +51 -0
- package/src/icons/custom/sqlite.ts +50 -0
- package/src/icons/custom/sqlserver.ts +52 -0
- package/src/icons/custom/vastbase.ts +57 -0
- package/src/icons/lucide.ts +78 -0
- package/src/icons/registry.ts +35 -0
- package/src/index.ts +425 -0
- package/src/lib/iso-local-datetime.ts +152 -0
- package/src/lib/rs-dayjs.ts +56 -0
- package/src/locale/messages.ts +362 -0
- package/src/locale/types.ts +5 -0
- package/src/monaco/debug-decorations.css +20 -0
- package/src/monaco/debug-decorations.ts +70 -0
- package/src/monaco/index.ts +22 -0
- package/src/monaco/languages/index.ts +21 -0
- package/src/monaco/languages/mongodb-shell.ts +125 -0
- package/src/monaco/languages/types.ts +55 -0
- package/src/monaco/setup.ts +101 -0
- package/src/styles.css +1040 -0
- package/src/theme/apply.ts +12 -0
- package/src/theme/brand.example.css +37 -0
- package/src/theme/presets.ts +69 -0
- package/src/theme/types.ts +81 -0
- package/src/utils/rs-clipboard.ts +272 -0
- package/src/vite-env.d.ts +7 -0
- package/vite-plugins/monaco-zh-nls.ts +101 -0
- package/vite-plugins/silence-antlr-parse-console.ts +29 -0
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed, nextTick, onMounted, onUnmounted, useTemplateRef, watch } from 'vue'
|
|
3
|
+
import { useRsI18n } from '../composables/useRsI18n'
|
|
4
|
+
import {
|
|
5
|
+
parseTimeValue,
|
|
6
|
+
rangeInclusive,
|
|
7
|
+
scheduleAfterPaint,
|
|
8
|
+
} from './time-picker-utils'
|
|
9
|
+
|
|
10
|
+
const model = defineModel<string>({ default: '00:00' })
|
|
11
|
+
|
|
12
|
+
const props = withDefaults(
|
|
13
|
+
defineProps<{
|
|
14
|
+
minuteStep?: number
|
|
15
|
+
second?: boolean
|
|
16
|
+
disabled?: boolean
|
|
17
|
+
isUnitDisabled?: (unit: 'hour' | 'minute' | 'second', value: number) => boolean
|
|
18
|
+
}>(),
|
|
19
|
+
{
|
|
20
|
+
minuteStep: 1,
|
|
21
|
+
second: false,
|
|
22
|
+
disabled: false,
|
|
23
|
+
},
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
const { t } = useRsI18n()
|
|
27
|
+
|
|
28
|
+
const hourListRef = useTemplateRef<HTMLDivElement>('hourListRef')
|
|
29
|
+
const minuteListRef = useTemplateRef<HTMLDivElement>('minuteListRef')
|
|
30
|
+
const secondListRef = useTemplateRef<HTMLDivElement>('secondListRef')
|
|
31
|
+
|
|
32
|
+
let cancelScheduledScroll: (() => void) | undefined
|
|
33
|
+
|
|
34
|
+
const hourOptions = computed(() => rangeInclusive(23))
|
|
35
|
+
const minuteOptions = computed(() =>
|
|
36
|
+
rangeInclusive(59).filter((value) => value % props.minuteStep === 0),
|
|
37
|
+
)
|
|
38
|
+
const secondOptions = computed(() => rangeInclusive(59))
|
|
39
|
+
|
|
40
|
+
const parts = computed(() => {
|
|
41
|
+
const parsed = parseTimeValue(model.value, props.second)
|
|
42
|
+
if (parsed) {
|
|
43
|
+
return { hour: parsed.hour, minute: parsed.minute, second: parsed.second }
|
|
44
|
+
}
|
|
45
|
+
return { hour: 0, minute: 0, second: 0 }
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
function isDisabled(unit: 'hour' | 'minute' | 'second', value: number): boolean {
|
|
49
|
+
return props.isUnitDisabled?.(unit, value) ?? false
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function scrollColumn(
|
|
53
|
+
container: HTMLDivElement | null,
|
|
54
|
+
unit: 'hour' | 'minute' | 'second',
|
|
55
|
+
value: number,
|
|
56
|
+
): void {
|
|
57
|
+
if (!container) return
|
|
58
|
+
const selected = container.querySelector<HTMLElement>(
|
|
59
|
+
`[data-unit="${unit}"][data-value="${value}"]`,
|
|
60
|
+
)
|
|
61
|
+
selected?.scrollIntoView({ block: 'center', behavior: 'auto' })
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function scrollToSelection(): void {
|
|
65
|
+
scrollColumn(hourListRef.value, 'hour', parts.value.hour)
|
|
66
|
+
scrollColumn(minuteListRef.value, 'minute', parts.value.minute)
|
|
67
|
+
if (props.second) {
|
|
68
|
+
scrollColumn(secondListRef.value, 'second', parts.value.second)
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function scrollToSelectionAfterPaint(): void {
|
|
73
|
+
cancelScheduledScroll?.()
|
|
74
|
+
cancelScheduledScroll = scheduleAfterPaint(scrollToSelection)
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function selectUnit(unit: 'hour' | 'minute' | 'second', value: number): void {
|
|
78
|
+
if (isDisabled(unit, value) || props.disabled) return
|
|
79
|
+
const next = { ...parts.value, [unit]: value }
|
|
80
|
+
model.value = props.second
|
|
81
|
+
? `${String(next.hour).padStart(2, '0')}:${String(next.minute).padStart(2, '0')}:${String(next.second).padStart(2, '0')}`
|
|
82
|
+
: `${String(next.hour).padStart(2, '0')}:${String(next.minute).padStart(2, '0')}`
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
watch(
|
|
86
|
+
() => [parts.value.hour, parts.value.minute, parts.value.second, props.second] as const,
|
|
87
|
+
() => {
|
|
88
|
+
nextTick(scrollToSelection)
|
|
89
|
+
},
|
|
90
|
+
{ flush: 'post' },
|
|
91
|
+
)
|
|
92
|
+
|
|
93
|
+
onMounted(() => {
|
|
94
|
+
scrollToSelectionAfterPaint()
|
|
95
|
+
})
|
|
96
|
+
|
|
97
|
+
onUnmounted(() => {
|
|
98
|
+
cancelScheduledScroll?.()
|
|
99
|
+
})
|
|
100
|
+
|
|
101
|
+
defineExpose({
|
|
102
|
+
scrollToSelection,
|
|
103
|
+
scrollToSelectionAfterPaint,
|
|
104
|
+
})
|
|
105
|
+
</script>
|
|
106
|
+
|
|
107
|
+
<template>
|
|
108
|
+
<div class="rs-time-columns" :class="{ 'rs-time-columns--seconds': second }">
|
|
109
|
+
<div class="rs-time-columns__column">
|
|
110
|
+
<span class="rs-time-columns__label">{{ t('timePicker.hour') }}</span>
|
|
111
|
+
<div ref="hourListRef" class="rs-time-columns__list">
|
|
112
|
+
<button
|
|
113
|
+
v-for="option in hourOptions"
|
|
114
|
+
:key="option"
|
|
115
|
+
type="button"
|
|
116
|
+
class="rs-time-columns__item"
|
|
117
|
+
:class="{ 'rs-time-columns__item--active': parts.hour === option }"
|
|
118
|
+
data-unit="hour"
|
|
119
|
+
:data-value="option"
|
|
120
|
+
:disabled="disabled || isDisabled('hour', option)"
|
|
121
|
+
@click="selectUnit('hour', option)"
|
|
122
|
+
>
|
|
123
|
+
{{ String(option).padStart(2, '0') }}
|
|
124
|
+
</button>
|
|
125
|
+
</div>
|
|
126
|
+
</div>
|
|
127
|
+
|
|
128
|
+
<div class="rs-time-columns__column">
|
|
129
|
+
<span class="rs-time-columns__label">{{ t('timePicker.minute') }}</span>
|
|
130
|
+
<div ref="minuteListRef" class="rs-time-columns__list">
|
|
131
|
+
<button
|
|
132
|
+
v-for="option in minuteOptions"
|
|
133
|
+
:key="option"
|
|
134
|
+
type="button"
|
|
135
|
+
class="rs-time-columns__item"
|
|
136
|
+
:class="{ 'rs-time-columns__item--active': parts.minute === option }"
|
|
137
|
+
data-unit="minute"
|
|
138
|
+
:data-value="option"
|
|
139
|
+
:disabled="disabled || isDisabled('minute', option)"
|
|
140
|
+
@click="selectUnit('minute', option)"
|
|
141
|
+
>
|
|
142
|
+
{{ String(option).padStart(2, '0') }}
|
|
143
|
+
</button>
|
|
144
|
+
</div>
|
|
145
|
+
</div>
|
|
146
|
+
|
|
147
|
+
<div v-if="second" class="rs-time-columns__column">
|
|
148
|
+
<span class="rs-time-columns__label">{{ t('timePicker.second') }}</span>
|
|
149
|
+
<div ref="secondListRef" class="rs-time-columns__list">
|
|
150
|
+
<button
|
|
151
|
+
v-for="option in secondOptions"
|
|
152
|
+
:key="option"
|
|
153
|
+
type="button"
|
|
154
|
+
class="rs-time-columns__item"
|
|
155
|
+
:class="{ 'rs-time-columns__item--active': parts.second === option }"
|
|
156
|
+
data-unit="second"
|
|
157
|
+
:data-value="option"
|
|
158
|
+
:disabled="disabled || isDisabled('second', option)"
|
|
159
|
+
@click="selectUnit('second', option)"
|
|
160
|
+
>
|
|
161
|
+
{{ String(option).padStart(2, '0') }}
|
|
162
|
+
</button>
|
|
163
|
+
</div>
|
|
164
|
+
</div>
|
|
165
|
+
</div>
|
|
166
|
+
</template>
|
|
167
|
+
|
|
168
|
+
<style scoped>
|
|
169
|
+
.rs-time-columns {
|
|
170
|
+
display: grid;
|
|
171
|
+
grid-template-columns: repeat(2, minmax(0, 1fr));
|
|
172
|
+
gap: var(--rs-space-sm);
|
|
173
|
+
}
|
|
174
|
+
.rs-time-columns--seconds {
|
|
175
|
+
grid-template-columns: repeat(3, minmax(0, 1fr));
|
|
176
|
+
}
|
|
177
|
+
.rs-time-columns__column {
|
|
178
|
+
display: flex;
|
|
179
|
+
min-width: 0;
|
|
180
|
+
flex-direction: column;
|
|
181
|
+
gap: 0.25rem;
|
|
182
|
+
}
|
|
183
|
+
.rs-time-columns__label {
|
|
184
|
+
text-align: center;
|
|
185
|
+
font-size: 0.6875rem;
|
|
186
|
+
font-weight: 500;
|
|
187
|
+
letter-spacing: 0.02em;
|
|
188
|
+
color: var(--rs-muted);
|
|
189
|
+
}
|
|
190
|
+
.rs-time-columns__list {
|
|
191
|
+
max-height: 10rem;
|
|
192
|
+
overflow-y: auto;
|
|
193
|
+
padding: 0.25rem;
|
|
194
|
+
border: 1px solid var(--rs-border-subtle);
|
|
195
|
+
border-radius: var(--rs-radius-sm);
|
|
196
|
+
background: color-mix(in srgb, var(--rs-surface) 72%, transparent);
|
|
197
|
+
}
|
|
198
|
+
.rs-time-columns__item {
|
|
199
|
+
display: flex;
|
|
200
|
+
width: 100%;
|
|
201
|
+
align-items: center;
|
|
202
|
+
justify-content: center;
|
|
203
|
+
border: 0;
|
|
204
|
+
border-radius: var(--rs-radius-sm);
|
|
205
|
+
padding: 0.375rem 0;
|
|
206
|
+
background: transparent;
|
|
207
|
+
color: var(--rs-text);
|
|
208
|
+
font-size: var(--rs-font-size-sm);
|
|
209
|
+
cursor: pointer;
|
|
210
|
+
transition: background var(--rs-transition-fast), color var(--rs-transition-fast);
|
|
211
|
+
}
|
|
212
|
+
.rs-time-columns__item:hover:not(:disabled) {
|
|
213
|
+
background: var(--rs-surface-hover);
|
|
214
|
+
}
|
|
215
|
+
.rs-time-columns__item--active {
|
|
216
|
+
background: var(--rs-primary);
|
|
217
|
+
color: var(--rs-primary-foreground);
|
|
218
|
+
}
|
|
219
|
+
.rs-time-columns__item--active:hover:not(:disabled) {
|
|
220
|
+
opacity: 0.92;
|
|
221
|
+
}
|
|
222
|
+
.rs-time-columns__item:disabled {
|
|
223
|
+
opacity: 0.38;
|
|
224
|
+
cursor: not-allowed;
|
|
225
|
+
}
|
|
226
|
+
</style>
|
|
@@ -0,0 +1,396 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed, inject } from 'vue'
|
|
3
|
+
import { Toaster } from 'vue-sonner'
|
|
4
|
+
import { rsConfigKey } from '../composables/useRsConfig'
|
|
5
|
+
import type { RsToastPosition } from './overlay-utils'
|
|
6
|
+
import { RS_TOAST_DEFAULT_GAP, RS_TOAST_DEFAULT_POSITION } from './overlay-utils'
|
|
7
|
+
|
|
8
|
+
withDefaults(
|
|
9
|
+
defineProps<{
|
|
10
|
+
position?: RsToastPosition
|
|
11
|
+
closeButton?: boolean
|
|
12
|
+
richColors?: boolean
|
|
13
|
+
expand?: boolean
|
|
14
|
+
gap?: number
|
|
15
|
+
}>(),
|
|
16
|
+
{
|
|
17
|
+
position: RS_TOAST_DEFAULT_POSITION,
|
|
18
|
+
closeButton: true,
|
|
19
|
+
richColors: false,
|
|
20
|
+
expand: true,
|
|
21
|
+
gap: RS_TOAST_DEFAULT_GAP,
|
|
22
|
+
},
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
const config = inject(rsConfigKey, null)
|
|
26
|
+
|
|
27
|
+
const sonnerTheme = computed<'light' | 'dark'>(() => {
|
|
28
|
+
if (config?.theme.value) {
|
|
29
|
+
return config.theme.value === 'dark' ? 'dark' : 'light'
|
|
30
|
+
}
|
|
31
|
+
if (typeof document !== 'undefined') {
|
|
32
|
+
const mode = document.documentElement.dataset.rsTheme
|
|
33
|
+
if (mode === 'dark' || mode === 'light') return mode
|
|
34
|
+
}
|
|
35
|
+
return 'dark'
|
|
36
|
+
})
|
|
37
|
+
</script>
|
|
38
|
+
|
|
39
|
+
<template>
|
|
40
|
+
<Teleport to="body">
|
|
41
|
+
<Toaster
|
|
42
|
+
:theme="sonnerTheme"
|
|
43
|
+
:position="position"
|
|
44
|
+
:close-button="closeButton"
|
|
45
|
+
:expand="expand"
|
|
46
|
+
:gap="gap"
|
|
47
|
+
close-button-position="top-right"
|
|
48
|
+
:rich-colors="richColors"
|
|
49
|
+
class="rs-toaster"
|
|
50
|
+
:toast-options="{
|
|
51
|
+
unstyled: true,
|
|
52
|
+
classes: {
|
|
53
|
+
toast: 'rs-toast',
|
|
54
|
+
title: 'rs-toast__title',
|
|
55
|
+
description: 'rs-toast__description',
|
|
56
|
+
closeButton: 'rs-toast__close',
|
|
57
|
+
actionButton: 'rs-toast__action',
|
|
58
|
+
cancelButton: 'rs-toast__action rs-toast__action--secondary',
|
|
59
|
+
},
|
|
60
|
+
}"
|
|
61
|
+
/>
|
|
62
|
+
</Teleport>
|
|
63
|
+
</template>
|
|
64
|
+
|
|
65
|
+
<style>
|
|
66
|
+
[data-sonner-toaster].rs-toaster {
|
|
67
|
+
--rs-toast-radius: 1rem;
|
|
68
|
+
--rs-toast-bg: color-mix(in srgb, var(--rs-surface-elevated) 86%, transparent);
|
|
69
|
+
--rs-toast-border: color-mix(in srgb, var(--rs-border) 72%, rgb(255 255 255 / 0.08));
|
|
70
|
+
--rs-toast-shadow:
|
|
71
|
+
0 16px 40px -20px rgb(0 0 0 / 0.3),
|
|
72
|
+
0 8px 18px -14px rgb(0 0 0 / 0.18),
|
|
73
|
+
0 0 0 0.5px rgb(255 255 255 / 0.08);
|
|
74
|
+
--rs-toast-tint: color-mix(in srgb, var(--rs-info) 7%, transparent);
|
|
75
|
+
--rs-toast-highlight: rgb(255 255 255 / 0.08);
|
|
76
|
+
z-index: var(--rs-z-toast);
|
|
77
|
+
font-family: inherit;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
[data-rs-theme='light'] [data-sonner-toaster].rs-toaster {
|
|
81
|
+
--rs-toast-bg: color-mix(in srgb, var(--rs-surface-elevated) 94%, rgb(255 255 255 / 0.8));
|
|
82
|
+
--rs-toast-border: color-mix(in srgb, var(--rs-border) 84%, rgb(255 255 255 / 0.9));
|
|
83
|
+
--rs-toast-shadow:
|
|
84
|
+
0 18px 42px -24px rgb(15 23 42 / 0.2),
|
|
85
|
+
0 8px 18px -14px rgb(15 23 42 / 0.12),
|
|
86
|
+
0 0 0 0.5px rgb(255 255 255 / 0.86);
|
|
87
|
+
--rs-toast-tint: color-mix(in srgb, var(--rs-info) 4%, #ffffff);
|
|
88
|
+
--rs-toast-highlight: rgb(255 255 255 / 0.72);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
[data-sonner-toaster].rs-toaster [data-sonner-toast].rs-toast {
|
|
92
|
+
position: absolute;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
[data-sonner-toaster].rs-toaster [data-sonner-toast].rs-toast[data-y-position='top'] {
|
|
96
|
+
top: 0;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
[data-sonner-toaster].rs-toaster [data-sonner-toast].rs-toast[data-y-position='bottom'] {
|
|
100
|
+
top: auto;
|
|
101
|
+
bottom: 0;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
[data-sonner-toaster].rs-toaster [data-sonner-toast].rs-toast[data-x-position='left'] {
|
|
105
|
+
left: 0;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
[data-sonner-toaster].rs-toaster [data-sonner-toast].rs-toast[data-x-position='right'] {
|
|
109
|
+
right: 0;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
[data-sonner-toaster].rs-toaster [data-sonner-toast].rs-toast[data-x-position='center'] {
|
|
113
|
+
left: 0;
|
|
114
|
+
right: 0;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.rs-toast {
|
|
118
|
+
--rs-toast-accent: color-mix(in srgb, var(--rs-info) 68%, transparent);
|
|
119
|
+
overflow: hidden;
|
|
120
|
+
display: grid;
|
|
121
|
+
grid-template-columns: auto minmax(0, 1fr);
|
|
122
|
+
align-items: start;
|
|
123
|
+
column-gap: 0.75rem;
|
|
124
|
+
row-gap: 0.25rem;
|
|
125
|
+
width: var(--width, auto);
|
|
126
|
+
min-width: 19rem;
|
|
127
|
+
max-width: min(29rem, calc(100vw - 1.5rem));
|
|
128
|
+
padding: 0.875rem 0.9375rem 0.9375rem;
|
|
129
|
+
border: 1px solid var(--rs-toast-border);
|
|
130
|
+
border-radius: var(--rs-toast-radius);
|
|
131
|
+
background:
|
|
132
|
+
linear-gradient(
|
|
133
|
+
180deg,
|
|
134
|
+
transparent 0.625rem,
|
|
135
|
+
var(--rs-toast-accent) 0.625rem calc(100% - 0.625rem),
|
|
136
|
+
transparent calc(100% - 0.625rem)
|
|
137
|
+
)
|
|
138
|
+
0.5rem 0 / 2px 100% no-repeat,
|
|
139
|
+
linear-gradient(180deg, var(--rs-toast-highlight), transparent 38%),
|
|
140
|
+
linear-gradient(135deg, var(--rs-toast-tint), transparent 34%),
|
|
141
|
+
var(--rs-toast-bg);
|
|
142
|
+
color: var(--rs-text);
|
|
143
|
+
box-shadow:
|
|
144
|
+
var(--rs-toast-shadow),
|
|
145
|
+
inset 0 1px 0 rgb(255 255 255 / 0.08);
|
|
146
|
+
backdrop-filter: blur(20px) saturate(150%);
|
|
147
|
+
-webkit-backdrop-filter: blur(20px) saturate(150%);
|
|
148
|
+
transition:
|
|
149
|
+
box-shadow var(--rs-transition-normal),
|
|
150
|
+
border-color var(--rs-transition-fast),
|
|
151
|
+
background var(--rs-transition-fast);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
.rs-toast:hover {
|
|
155
|
+
box-shadow:
|
|
156
|
+
0 18px 42px -20px rgb(0 0 0 / 0.34),
|
|
157
|
+
0 10px 24px -16px rgb(0 0 0 / 0.22),
|
|
158
|
+
0 0 0 0.5px rgb(255 255 255 / 0.1),
|
|
159
|
+
inset 0 1px 0 rgb(255 255 255 / 0.08);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
.rs-toast[data-styled='true'] {
|
|
163
|
+
gap: 0;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
.rs-toast [data-icon] {
|
|
167
|
+
position: relative;
|
|
168
|
+
z-index: 1;
|
|
169
|
+
display: inline-flex;
|
|
170
|
+
grid-row: 1 / span 2;
|
|
171
|
+
align-items: center;
|
|
172
|
+
justify-content: center;
|
|
173
|
+
width: 1.75rem;
|
|
174
|
+
height: 1.75rem;
|
|
175
|
+
margin-top: 0.125rem;
|
|
176
|
+
border-radius: 999px;
|
|
177
|
+
background: transparent;
|
|
178
|
+
color: var(--rs-info);
|
|
179
|
+
box-shadow: none;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
.rs-toast [data-content] {
|
|
183
|
+
position: relative;
|
|
184
|
+
z-index: 1;
|
|
185
|
+
display: grid;
|
|
186
|
+
gap: 0.1875rem;
|
|
187
|
+
min-width: 0;
|
|
188
|
+
padding-right: 1.5rem;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
.rs-toast [data-button] {
|
|
192
|
+
position: relative;
|
|
193
|
+
z-index: 1;
|
|
194
|
+
margin-top: 0.625rem;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
.rs-toast__title {
|
|
198
|
+
margin: 0;
|
|
199
|
+
color: var(--rs-text);
|
|
200
|
+
font-size: 0.875rem;
|
|
201
|
+
font-weight: 600;
|
|
202
|
+
line-height: 1.3;
|
|
203
|
+
letter-spacing: -0.012em;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
.rs-toast__description {
|
|
207
|
+
margin: 0;
|
|
208
|
+
color: color-mix(in srgb, var(--rs-muted) 94%, var(--rs-text) 6%);
|
|
209
|
+
font-size: 0.8125rem;
|
|
210
|
+
line-height: 1.4;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
.rs-toast [data-close-button].rs-toast__close {
|
|
214
|
+
position: absolute;
|
|
215
|
+
inset: 0.75rem 0.75rem auto auto;
|
|
216
|
+
z-index: 2;
|
|
217
|
+
display: inline-flex;
|
|
218
|
+
align-items: center;
|
|
219
|
+
justify-content: center;
|
|
220
|
+
width: 1.25rem;
|
|
221
|
+
height: 1.25rem;
|
|
222
|
+
padding: 0;
|
|
223
|
+
border: 1px solid transparent;
|
|
224
|
+
border-radius: 999px;
|
|
225
|
+
background: transparent;
|
|
226
|
+
color: var(--rs-muted);
|
|
227
|
+
box-shadow: none;
|
|
228
|
+
cursor: pointer;
|
|
229
|
+
transform: none;
|
|
230
|
+
opacity: 0.72;
|
|
231
|
+
transition:
|
|
232
|
+
opacity var(--rs-transition-fast),
|
|
233
|
+
color var(--rs-transition-fast),
|
|
234
|
+
border-color var(--rs-transition-fast),
|
|
235
|
+
background var(--rs-transition-fast),
|
|
236
|
+
box-shadow var(--rs-transition-fast);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
.rs-toast [data-close-button].rs-toast__close svg {
|
|
240
|
+
width: 0.75rem;
|
|
241
|
+
height: 0.75rem;
|
|
242
|
+
flex-shrink: 0;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
.rs-toast [data-close-button].rs-toast__close:hover {
|
|
246
|
+
opacity: 0.96;
|
|
247
|
+
color: var(--rs-text);
|
|
248
|
+
border-color: color-mix(in srgb, var(--rs-border) 68%, transparent);
|
|
249
|
+
background: color-mix(in srgb, var(--rs-surface-hover) 70%, transparent);
|
|
250
|
+
box-shadow:
|
|
251
|
+
inset 0 1px 0 rgb(255 255 255 / 0.08),
|
|
252
|
+
0 1px 4px rgb(0 0 0 / 0.08);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
.rs-toast [data-close-button].rs-toast__close:focus-visible {
|
|
256
|
+
outline: none;
|
|
257
|
+
box-shadow:
|
|
258
|
+
inset 0 1px 0 rgb(255 255 255 / 0.08),
|
|
259
|
+
0 0 0 var(--rs-focus-ring-width, 2px) var(--rs-focus-ring);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
.rs-toast__action {
|
|
263
|
+
display: inline-flex;
|
|
264
|
+
align-items: center;
|
|
265
|
+
justify-content: center;
|
|
266
|
+
min-width: 4.5rem;
|
|
267
|
+
min-height: 2rem;
|
|
268
|
+
padding: 0 0.75rem;
|
|
269
|
+
border: 1px solid transparent;
|
|
270
|
+
border-radius: 999px;
|
|
271
|
+
background: color-mix(in srgb, var(--rs-primary) 92%, white 8%);
|
|
272
|
+
color: var(--rs-primary-foreground);
|
|
273
|
+
font-size: 0.75rem;
|
|
274
|
+
font-weight: 600;
|
|
275
|
+
line-height: 1;
|
|
276
|
+
letter-spacing: 0.01em;
|
|
277
|
+
box-shadow:
|
|
278
|
+
inset 0 1px 0 rgb(255 255 255 / 0.16),
|
|
279
|
+
0 1px 2px rgb(0 0 0 / 0.08);
|
|
280
|
+
cursor: pointer;
|
|
281
|
+
transition:
|
|
282
|
+
transform var(--rs-transition-fast),
|
|
283
|
+
background var(--rs-transition-fast),
|
|
284
|
+
border-color var(--rs-transition-fast),
|
|
285
|
+
box-shadow var(--rs-transition-fast),
|
|
286
|
+
color var(--rs-transition-fast);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
.rs-toast__action:hover {
|
|
290
|
+
transform: translateY(-0.5px);
|
|
291
|
+
background: color-mix(in srgb, var(--rs-primary-hover) 94%, white 6%);
|
|
292
|
+
box-shadow:
|
|
293
|
+
inset 0 1px 0 rgb(255 255 255 / 0.18),
|
|
294
|
+
0 4px 10px rgb(0 0 0 / 0.12);
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
.rs-toast__action:active {
|
|
298
|
+
transform: translateY(0);
|
|
299
|
+
box-shadow:
|
|
300
|
+
inset 0 1px 1px rgb(0 0 0 / 0.08),
|
|
301
|
+
0 1px 3px rgb(0 0 0 / 0.08);
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
.rs-toast__action:focus-visible {
|
|
305
|
+
outline: none;
|
|
306
|
+
box-shadow:
|
|
307
|
+
inset 0 1px 0 rgb(255 255 255 / 0.18),
|
|
308
|
+
0 0 0 var(--rs-focus-ring-width, 2px) var(--rs-focus-ring);
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
.rs-toast__action--secondary {
|
|
312
|
+
border-color: color-mix(in srgb, var(--rs-border) 72%, transparent);
|
|
313
|
+
background: color-mix(in srgb, var(--rs-surface) 82%, transparent);
|
|
314
|
+
color: var(--rs-text);
|
|
315
|
+
box-shadow:
|
|
316
|
+
inset 0 1px 0 rgb(255 255 255 / 0.08),
|
|
317
|
+
0 1px 2px rgb(0 0 0 / 0.04);
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
.rs-toast__action--secondary:hover {
|
|
321
|
+
background: color-mix(in srgb, var(--rs-surface-hover) 82%, transparent);
|
|
322
|
+
border-color: color-mix(in srgb, var(--rs-border) 88%, transparent);
|
|
323
|
+
box-shadow:
|
|
324
|
+
inset 0 1px 0 rgb(255 255 255 / 0.1),
|
|
325
|
+
0 3px 8px rgb(0 0 0 / 0.08);
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
.rs-toast[data-type='success'] {
|
|
329
|
+
--rs-toast-accent: color-mix(in srgb, var(--rs-success) 68%, transparent);
|
|
330
|
+
--rs-toast-tint: color-mix(in srgb, var(--rs-success) 7%, transparent);
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
.rs-toast[data-type='success'] [data-icon] {
|
|
334
|
+
color: var(--rs-success);
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
.rs-toast[data-type='error'] {
|
|
338
|
+
--rs-toast-accent: color-mix(in srgb, var(--rs-danger) 68%, transparent);
|
|
339
|
+
--rs-toast-tint: color-mix(in srgb, var(--rs-danger) 7%, transparent);
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
.rs-toast[data-type='error'] [data-icon] {
|
|
343
|
+
color: var(--rs-danger);
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
.rs-toast[data-type='warning'] {
|
|
347
|
+
--rs-toast-accent: color-mix(in srgb, var(--rs-warning) 72%, transparent);
|
|
348
|
+
--rs-toast-tint: color-mix(in srgb, var(--rs-warning) 8%, transparent);
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
.rs-toast[data-type='warning'] [data-icon] {
|
|
352
|
+
color: var(--rs-warning);
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
.rs-toast[data-type='info'],
|
|
356
|
+
.rs-toast[data-type='default'] {
|
|
357
|
+
--rs-toast-accent: color-mix(in srgb, var(--rs-info) 68%, transparent);
|
|
358
|
+
--rs-toast-tint: color-mix(in srgb, var(--rs-info) 7%, transparent);
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
.rs-toast[data-type='loading'] {
|
|
362
|
+
--rs-toast-accent: color-mix(in srgb, var(--rs-primary) 68%, transparent);
|
|
363
|
+
--rs-toast-tint: color-mix(in srgb, var(--rs-primary) 7%, transparent);
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
.rs-toast[data-type='loading'] [data-icon] {
|
|
367
|
+
color: var(--rs-primary);
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
@media (max-width: 640px) {
|
|
371
|
+
.rs-toast {
|
|
372
|
+
min-width: min(100%, 18.5rem);
|
|
373
|
+
max-width: calc(100vw - 1rem);
|
|
374
|
+
padding: 0.8125rem 0.875rem 0.875rem;
|
|
375
|
+
border-radius: 0.9375rem;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
.rs-toast [data-close-button].rs-toast__close {
|
|
379
|
+
inset: 0.625rem 0.625rem auto auto;
|
|
380
|
+
width: 1.25rem;
|
|
381
|
+
height: 1.25rem;
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
.rs-toast__action {
|
|
385
|
+
min-height: 1.875rem;
|
|
386
|
+
padding: 0 0.6875rem;
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
@media (prefers-reduced-motion: reduce) {
|
|
391
|
+
.rs-toast,
|
|
392
|
+
.rs-toast__action {
|
|
393
|
+
transition: none;
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
</style>
|