niuma-ui 1.0.1 → 1.1.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 +65 -1
- package/package.json +10 -2
- package/src/__tests__/RsButton.spec.ts +47 -0
- package/src/__tests__/RsCard.spec.ts +160 -1
- package/src/__tests__/RsConfirmDialog.spec.ts +127 -0
- package/src/__tests__/RsContextMenu.spec.ts +12 -0
- package/src/__tests__/RsDatePicker.spec.ts +21 -0
- package/src/__tests__/RsDateTimePicker.spec.ts +11 -0
- package/src/__tests__/RsDescriptions.spec.ts +50 -0
- package/src/__tests__/RsDialog.spec.ts +178 -0
- package/src/__tests__/RsDrawer.spec.ts +96 -3
- package/src/__tests__/RsDynamicTags.spec.ts +52 -0
- package/src/__tests__/RsForm.spec.ts +250 -6
- package/src/__tests__/RsFormItem.spec.ts +478 -0
- package/src/__tests__/RsFormList.spec.ts +109 -0
- package/src/__tests__/RsInput.spec.ts +108 -1
- package/src/__tests__/RsInputNumber.spec.ts +33 -0
- package/src/__tests__/RsMenu.spec.ts +406 -14
- package/src/__tests__/RsPagination.spec.ts +67 -2
- package/src/__tests__/RsSelect.spec.ts +465 -2
- package/src/__tests__/RsSwitch.spec.ts +74 -0
- package/src/__tests__/RsTable.a11y.spec.ts +83 -0
- package/src/__tests__/RsTable.dom-baseline.spec.ts +87 -0
- package/src/__tests__/RsTable.perf.spec.ts +23 -4
- package/src/__tests__/RsTable.spec.ts +63 -8
- package/src/__tests__/RsTable.ssr.spec.ts +71 -0
- package/src/__tests__/RsTable.summary.spec.ts +45 -0
- package/src/__tests__/RsTabs.spec.ts +102 -4
- package/src/__tests__/RsTimePicker.spec.ts +20 -0
- package/src/__tests__/RsTooltip.spec.ts +43 -0
- package/src/__tests__/RsUpload.spec.ts +62 -6
- package/src/__tests__/createRsDialog.spec.ts +145 -0
- package/src/__tests__/css-token.spec.ts +51 -0
- package/src/__tests__/date-picker-utils.spec.ts +49 -0
- package/src/__tests__/dialog-utils.spec.ts +43 -0
- package/src/__tests__/form-path.spec.ts +46 -0
- package/src/__tests__/form-rules.spec.ts +139 -0
- package/src/__tests__/perf-budgets.ts +32 -0
- package/src/__tests__/rs-table-api.spec.ts +206 -0
- package/src/__tests__/rs-table-compat-matrix.spec.ts +108 -0
- package/src/__tests__/rs-table-echarts-adapter.spec.ts +43 -0
- package/src/__tests__/rs-table-grid-nav.spec.ts +63 -0
- package/src/__tests__/rs-table-isolation.spec.ts +158 -0
- package/src/__tests__/split-pane-utils.spec.ts +21 -0
- package/src/__tests__/table-chart-utils.spec.ts +88 -0
- package/src/__tests__/table-summary-utils.spec.ts +62 -0
- package/src/__tests__/table-utils.spec.ts +124 -0
- package/src/__tests__/theme.spec.ts +27 -0
- package/src/__tests__/useRsTableColumnResize.spec.ts +25 -0
- package/src/__tests__/useRsTableCore.perf.spec.ts +170 -0
- package/src/components/RsAlert.vue +212 -0
- package/src/components/RsAvatar.vue +1 -1
- package/src/components/RsBadge.vue +1 -1
- package/src/components/RsBreadcrumb.vue +1 -1
- package/src/components/RsButton.vue +147 -23
- package/src/components/RsCalendarGrid.vue +3 -3
- package/src/components/RsCard.vue +204 -20
- package/src/components/RsCodeBlock.vue +4 -4
- package/src/components/RsCodeEditor.vue +8 -8
- package/src/components/RsConfirmDialog.vue +217 -30
- package/src/components/RsContextMenu.vue +57 -17
- package/src/components/RsDatePicker.vue +316 -39
- package/src/components/RsDateTimePicker.vue +27 -2
- package/src/components/RsDescriptions.vue +186 -0
- package/src/components/RsDescriptionsItem.vue +32 -0
- package/src/components/RsDialog.vue +374 -52
- package/src/components/RsDivider.vue +89 -0
- package/src/components/RsDrawer.vue +559 -34
- package/src/components/RsDropdown.vue +34 -3
- package/src/components/RsDynamicTags.vue +531 -0
- package/src/components/RsEmpty.vue +1 -1
- package/src/components/RsForm.vue +164 -8
- package/src/components/RsFormItem.vue +423 -0
- package/src/components/RsFormItemControl.vue +21 -0
- package/src/components/RsFormList.vue +117 -0
- package/src/components/RsInput.vue +491 -100
- package/src/components/RsInputNumber.vue +77 -27
- package/src/components/RsLabel.vue +20 -5
- package/src/components/RsLink.vue +1 -1
- package/src/components/RsLoadingBar.vue +151 -0
- package/src/components/RsMarkdown.vue +5 -5
- package/src/components/RsMenu.vue +74 -16
- package/src/components/RsMenuItems.vue +147 -9
- package/src/components/RsMonacoEditor.vue +9 -3
- package/src/components/RsPagination.vue +93 -14
- package/src/components/RsProseEditor.vue +3 -3
- package/src/components/RsRadio.vue +81 -0
- package/src/components/RsRadioItem.vue +156 -0
- package/src/components/RsSelect.vue +372 -642
- package/src/components/RsSidebarGroup.vue +1 -1
- package/src/components/RsSplitPane.vue +90 -1
- package/src/components/RsStatCard.vue +2 -2
- package/src/components/RsSteps.vue +2 -2
- package/src/components/RsSwitch.vue +192 -0
- package/src/components/RsTable.vue +653 -2555
- package/src/components/RsTabs.vue +422 -90
- package/src/components/RsTag.vue +191 -0
- package/src/components/RsTerminal.vue +58 -19
- package/src/components/RsTimePicker.vue +72 -9
- package/src/components/RsTimePickerColumns.vue +137 -78
- package/src/components/RsToaster.vue +64 -24
- package/src/components/RsTooltip.vue +10 -1
- package/src/components/RsTooltipProvider.vue +11 -1
- package/src/components/RsTree.vue +45 -27
- package/src/components/RsUpload.vue +147 -14
- package/src/components/RsVNodeHost.vue +20 -0
- package/src/components/button-utils.ts +39 -0
- package/src/components/context-menu-utils.ts +6 -0
- package/src/components/date-picker-utils.ts +195 -4
- package/src/components/descriptions-utils.ts +24 -0
- package/src/components/dialog-utils.ts +182 -0
- package/src/components/dialog-window.ts +74 -9
- package/src/components/drawer-utils.ts +73 -0
- package/src/components/form-item-control.ts +55 -0
- package/src/components/form-path.ts +92 -0
- package/src/components/form-rules.ts +311 -0
- package/src/components/form-utils.ts +145 -3
- package/src/components/menu-utils.ts +11 -0
- package/src/components/overlay-utils.ts +3 -0
- package/src/components/radio-utils.ts +12 -0
- package/src/components/reka.ts +5 -0
- package/src/components/select-utils.ts +285 -6
- package/src/components/split-pane-utils.ts +65 -12
- package/src/components/table/RsTableBody.vue +217 -0
- package/src/components/table/RsTableBodyRow.vue +90 -1
- package/src/components/table/RsTableColGroup.vue +41 -0
- package/src/components/table/RsTableHeader.vue +158 -0
- package/src/components/table/RsTableHeaderFilter.vue +1 -1
- package/src/components/table/RsTableSummaryRow.vue +52 -0
- package/src/components/table/rs-table-api.ts +99 -0
- package/src/components/table/rs-table-compat-matrix.ts +71 -0
- package/src/components/table/rs-table-echarts-adapter.ts +81 -0
- package/src/components/table/rs-table-feature-host.ts +178 -0
- package/src/components/table/rs-table-grid-nav.ts +122 -0
- package/src/components/table/rs-table-header-types.ts +47 -0
- package/src/components/table/rs-table-module-registry.ts +72 -0
- package/src/components/table/rs-table-props.ts +274 -0
- package/src/components/table/rs-table-view-context.ts +258 -0
- package/src/components/table/rs-table.css +85 -7
- package/src/components/table/table-chart-utils.ts +165 -0
- package/src/components/table/table-features.ts +284 -0
- package/src/components/table/table-summary-utils.ts +194 -0
- package/src/components/table-utils.ts +452 -2
- package/src/components/tabs-utils.ts +142 -2
- package/src/components/time-picker-utils.ts +76 -3
- package/src/components/upload-utils.ts +122 -0
- package/src/components/use-rs-select.ts +436 -0
- package/src/components/virtual-list-utils.ts +15 -2
- package/src/composables/assembleRsTableApi.ts +79 -0
- package/src/composables/bindRsTableViewContext.ts +269 -0
- package/src/composables/createRsDialog.ts +357 -0
- package/src/composables/createRsTableEditEmitBridge.ts +38 -0
- package/src/composables/useRsConfig.ts +10 -3
- package/src/composables/useRsI18n.ts +16 -5
- package/src/composables/useRsLoadingBar.ts +36 -0
- package/src/composables/useRsTable.ts +134 -0
- package/src/composables/useRsTableA11y.ts +52 -0
- package/src/composables/useRsTableChartBridge.ts +79 -0
- package/src/composables/useRsTableColumnLayout.ts +320 -0
- package/src/composables/useRsTableColumnResize.ts +244 -0
- package/src/composables/useRsTableColumnVirtual.ts +180 -0
- package/src/composables/useRsTableColumns.ts +200 -0
- package/src/composables/useRsTableContextMenu.ts +257 -0
- package/src/composables/useRsTableCore.ts +256 -0
- package/src/composables/useRsTableEditActions.ts +606 -0
- package/src/composables/useRsTableEditLayer.ts +251 -0
- package/src/composables/useRsTableEngine.ts +357 -0
- package/src/composables/useRsTableGridKeyboard.ts +123 -0
- package/src/composables/useRsTableHeadless.ts +137 -0
- package/src/composables/useRsTableInteraction.ts +433 -0
- package/src/composables/useRsTableScrollHost.ts +75 -0
- package/src/composables/useRsTableScrollLayout.ts +255 -0
- package/src/composables/useRsTableSelectionSource.ts +89 -0
- package/src/composables/useRsTableShell.ts +416 -0
- package/src/composables/useRsTableShellChrome.ts +170 -0
- package/src/composables/useRsTableSummary.ts +113 -0
- package/src/composables/useRsTableViewProvide.ts +263 -0
- package/src/composables/useRsTableVirtual.ts +154 -0
- package/src/composables/useRsTabsNav.ts +4 -0
- package/src/composables/useTableEdit.ts +1 -1
- package/src/index.ts +378 -10
- package/src/locale/interpolate.ts +32 -0
- package/src/locale/messages.ts +40 -0
- package/src/styles.css +365 -56
- package/src/theme/brand.example.css +24 -2
- package/src/theme/css-token.ts +107 -0
- package/src/theme/presets.ts +4 -0
- package/src/theme/types.ts +68 -0
- package/src/components/RsTableColgroup.vue +0 -17
- package/src/components/RsTableHeaderRow.vue +0 -30
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed } from 'vue'
|
|
3
|
+
import { useRsI18n } from '../composables/useRsI18n'
|
|
4
|
+
import type { RsComponentSize, RsRadius } from '../theme/types'
|
|
5
|
+
import { rsRadiusCss, useResolvedRsRadius } from './resolve-radius'
|
|
6
|
+
import { useResolvedRsComponentSize } from './resolve-size'
|
|
7
|
+
import RsIcon from './RsIcon.vue'
|
|
8
|
+
|
|
9
|
+
export type RsTagVariant = 'default' | 'primary' | 'success' | 'warning' | 'danger' | 'info'
|
|
10
|
+
|
|
11
|
+
const props = withDefaults(
|
|
12
|
+
defineProps<{
|
|
13
|
+
variant?: RsTagVariant
|
|
14
|
+
closable?: boolean
|
|
15
|
+
disabled?: boolean
|
|
16
|
+
/** 胶囊圆角快捷开关;等价于 radius="full" */
|
|
17
|
+
round?: boolean
|
|
18
|
+
size?: RsComponentSize
|
|
19
|
+
radius?: RsRadius
|
|
20
|
+
}>(),
|
|
21
|
+
{
|
|
22
|
+
variant: 'default',
|
|
23
|
+
closable: false,
|
|
24
|
+
disabled: false,
|
|
25
|
+
round: false,
|
|
26
|
+
},
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
const emit = defineEmits<{
|
|
30
|
+
close: [event: MouseEvent]
|
|
31
|
+
}>()
|
|
32
|
+
|
|
33
|
+
const { t } = useRsI18n()
|
|
34
|
+
const resolvedSize = useResolvedRsComponentSize(() => props.size)
|
|
35
|
+
const resolvedRadius = useResolvedRsRadius(
|
|
36
|
+
() => (props.round ? 'full' : props.radius),
|
|
37
|
+
'sm',
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
const rootClass = computed(() => [
|
|
41
|
+
'rs-tag',
|
|
42
|
+
`rs-tag--${props.variant}`,
|
|
43
|
+
`rs-tag--${resolvedSize.value}`,
|
|
44
|
+
{
|
|
45
|
+
'rs-tag--closable': props.closable,
|
|
46
|
+
'rs-tag--disabled': props.disabled,
|
|
47
|
+
'rs-tag--round': props.round || resolvedRadius.value === 'full',
|
|
48
|
+
},
|
|
49
|
+
])
|
|
50
|
+
|
|
51
|
+
const rootStyle = computed(() => ({
|
|
52
|
+
'--rs-tag-radius': rsRadiusCss(resolvedRadius.value),
|
|
53
|
+
}))
|
|
54
|
+
|
|
55
|
+
function onClose(event: MouseEvent): void {
|
|
56
|
+
if (props.disabled) return
|
|
57
|
+
event.stopPropagation()
|
|
58
|
+
emit('close', event)
|
|
59
|
+
}
|
|
60
|
+
</script>
|
|
61
|
+
|
|
62
|
+
<template>
|
|
63
|
+
<span :class="rootClass" :style="rootStyle">
|
|
64
|
+
<span class="rs-tag__content">
|
|
65
|
+
<slot />
|
|
66
|
+
</span>
|
|
67
|
+
<button
|
|
68
|
+
v-if="closable"
|
|
69
|
+
type="button"
|
|
70
|
+
class="rs-tag__close"
|
|
71
|
+
:disabled="disabled"
|
|
72
|
+
:aria-label="t('tag.close')"
|
|
73
|
+
@click="onClose"
|
|
74
|
+
>
|
|
75
|
+
<RsIcon name="x" :size="12" />
|
|
76
|
+
</button>
|
|
77
|
+
</span>
|
|
78
|
+
</template>
|
|
79
|
+
|
|
80
|
+
<style scoped>
|
|
81
|
+
.rs-tag {
|
|
82
|
+
display: inline-flex;
|
|
83
|
+
align-items: center;
|
|
84
|
+
gap: var(--rs-space-xs);
|
|
85
|
+
max-width: 100%;
|
|
86
|
+
border-radius: var(--rs-tag-radius, var(--rs-radius-sm));
|
|
87
|
+
font-weight: var(--rs-tag-font-weight, 400);
|
|
88
|
+
line-height: var(--rs-line-height-tight);
|
|
89
|
+
box-sizing: border-box;
|
|
90
|
+
vertical-align: middle;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.rs-tag--ssm {
|
|
94
|
+
padding: 0 var(--rs-space-xs);
|
|
95
|
+
font-size: var(--rs-font-size-xs);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.rs-tag--sm {
|
|
99
|
+
padding: 0.0625rem var(--rs-space-xs);
|
|
100
|
+
font-size: var(--rs-font-size-xs);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.rs-tag--md {
|
|
104
|
+
padding: 0.125rem var(--rs-space-sm);
|
|
105
|
+
font-size: var(--rs-font-size-xs);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.rs-tag--lg {
|
|
109
|
+
padding: var(--rs-space-xs) var(--rs-space-sm);
|
|
110
|
+
font-size: var(--rs-font-size-sm);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
.rs-tag--round {
|
|
114
|
+
border-radius: var(--rs-radius-full);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.rs-tag--disabled {
|
|
118
|
+
opacity: 0.55;
|
|
119
|
+
cursor: not-allowed;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.rs-tag__content {
|
|
123
|
+
overflow: hidden;
|
|
124
|
+
text-overflow: ellipsis;
|
|
125
|
+
white-space: nowrap;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
.rs-tag__close {
|
|
129
|
+
display: inline-flex;
|
|
130
|
+
align-items: center;
|
|
131
|
+
justify-content: center;
|
|
132
|
+
margin: 0;
|
|
133
|
+
padding: 0;
|
|
134
|
+
border: 0;
|
|
135
|
+
border-radius: var(--rs-radius-full);
|
|
136
|
+
background: transparent;
|
|
137
|
+
color: inherit;
|
|
138
|
+
cursor: pointer;
|
|
139
|
+
opacity: 0.75;
|
|
140
|
+
outline: none;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
.rs-tag__close:hover:not(:disabled) {
|
|
144
|
+
opacity: 1;
|
|
145
|
+
background: color-mix(in srgb, currentColor 12%, transparent);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
.rs-tag__close:focus-visible {
|
|
149
|
+
box-shadow: 0 0 0 var(--rs-focus-ring-width, 2px) var(--rs-focus-ring);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
.rs-tag__close:disabled {
|
|
153
|
+
cursor: not-allowed;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
.rs-tag--default {
|
|
157
|
+
background: var(--rs-surface-hover);
|
|
158
|
+
color: var(--rs-text);
|
|
159
|
+
border: 1px solid var(--rs-border);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
.rs-tag--primary {
|
|
163
|
+
background: var(--rs-primary-container);
|
|
164
|
+
color: var(--rs-on-primary-container);
|
|
165
|
+
border: 1px solid color-mix(in srgb, var(--rs-primary) var(--rs-tag-border-alpha, 40%), transparent);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
.rs-tag--success {
|
|
169
|
+
background: var(--rs-success-container);
|
|
170
|
+
color: var(--rs-on-success-container);
|
|
171
|
+
border: 1px solid color-mix(in srgb, var(--rs-success) var(--rs-tag-border-alpha, 40%), transparent);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
.rs-tag--warning {
|
|
175
|
+
background: var(--rs-warning-container);
|
|
176
|
+
color: var(--rs-on-warning-container);
|
|
177
|
+
border: 1px solid color-mix(in srgb, var(--rs-warning) var(--rs-tag-border-alpha, 40%), transparent);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
.rs-tag--danger {
|
|
181
|
+
background: var(--rs-danger-container);
|
|
182
|
+
color: var(--rs-on-danger-container);
|
|
183
|
+
border: 1px solid color-mix(in srgb, var(--rs-danger) var(--rs-tag-border-alpha, 40%), transparent);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
.rs-tag--info {
|
|
187
|
+
background: var(--rs-info-container);
|
|
188
|
+
color: var(--rs-on-info-container);
|
|
189
|
+
border: 1px solid color-mix(in srgb, var(--rs-info) var(--rs-tag-border-alpha, 40%), transparent);
|
|
190
|
+
}
|
|
191
|
+
</style>
|
|
@@ -5,6 +5,12 @@ import { Terminal } from '@xterm/xterm'
|
|
|
5
5
|
import '@xterm/xterm/css/xterm.css'
|
|
6
6
|
import { computed, nextTick, onBeforeUnmount, onMounted, ref, watch } from 'vue'
|
|
7
7
|
import { useRsI18n } from '../composables/useRsI18n'
|
|
8
|
+
import {
|
|
9
|
+
readTerminalFontFamily,
|
|
10
|
+
readTerminalFontSizePx,
|
|
11
|
+
readTerminalFontWeight,
|
|
12
|
+
readTerminalFontWeightBold,
|
|
13
|
+
} from '../theme/css-token'
|
|
8
14
|
import {
|
|
9
15
|
beginClipboardPrefetch,
|
|
10
16
|
copyTextToClipboard,
|
|
@@ -29,16 +35,33 @@ import {
|
|
|
29
35
|
|
|
30
36
|
const TERMINAL_LINE_HEIGHT = 1.2
|
|
31
37
|
|
|
38
|
+
type RsTerminalFontWeight =
|
|
39
|
+
| 'normal'
|
|
40
|
+
| 'bold'
|
|
41
|
+
| '100'
|
|
42
|
+
| '200'
|
|
43
|
+
| '300'
|
|
44
|
+
| '400'
|
|
45
|
+
| '500'
|
|
46
|
+
| '600'
|
|
47
|
+
| '700'
|
|
48
|
+
| '800'
|
|
49
|
+
| '900'
|
|
50
|
+
|
|
32
51
|
const props = withDefaults(
|
|
33
52
|
defineProps<{
|
|
34
53
|
loading?: boolean
|
|
35
54
|
overlay?: string
|
|
36
55
|
inputEnabled?: boolean
|
|
37
56
|
cursorBlink?: boolean
|
|
57
|
+
/** 缺省读取 `--rs-terminal-font-family` / `--rs-font-mono` */
|
|
38
58
|
fontFamily?: string
|
|
59
|
+
/** 缺省读取 `--rs-terminal-font-size`(对齐 `--rs-font-size-sm`) */
|
|
39
60
|
fontSize?: number
|
|
40
|
-
|
|
41
|
-
|
|
61
|
+
/** 缺省读取 `--rs-terminal-font-weight` */
|
|
62
|
+
fontWeight?: RsTerminalFontWeight
|
|
63
|
+
/** 缺省读取 `--rs-terminal-font-weight-bold` */
|
|
64
|
+
fontWeightBold?: RsTerminalFontWeight
|
|
42
65
|
allowTransparency?: boolean
|
|
43
66
|
/** auto 跟随 data-rs-theme;也可强制 light / dark */
|
|
44
67
|
themeMode?: RsTerminalThemeMode
|
|
@@ -68,11 +91,6 @@ const props = withDefaults(
|
|
|
68
91
|
overlay: '',
|
|
69
92
|
inputEnabled: true,
|
|
70
93
|
cursorBlink: true,
|
|
71
|
-
fontFamily:
|
|
72
|
-
'"SF Mono", "Cascadia Code", "Cascadia Mono", Consolas, "Liberation Mono", Menlo, monospace',
|
|
73
|
-
fontSize: 13,
|
|
74
|
-
fontWeight: '300',
|
|
75
|
-
fontWeightBold: '400',
|
|
76
94
|
allowTransparency: false,
|
|
77
95
|
themeMode: 'auto',
|
|
78
96
|
theme: () => ({}),
|
|
@@ -109,13 +127,34 @@ const zebraRowStepPx = ref<number | null>(null)
|
|
|
109
127
|
|
|
110
128
|
const showLoading = computed(() => !terminalReady.value || props.loading)
|
|
111
129
|
|
|
130
|
+
function asTerminalFontWeight(value: string): RsTerminalFontWeight {
|
|
131
|
+
return value as RsTerminalFontWeight
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function resolveTerminalFontFamily(): string {
|
|
135
|
+
return props.fontFamily || readTerminalFontFamily(hostEl.value)
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function resolveTerminalFontSize(): number {
|
|
139
|
+
return props.fontSize ?? readTerminalFontSizePx(hostEl.value)
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function resolveTerminalFontWeight(): RsTerminalFontWeight {
|
|
143
|
+
return props.fontWeight ?? asTerminalFontWeight(readTerminalFontWeight(hostEl.value))
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function resolveTerminalFontWeightBold(): RsTerminalFontWeight {
|
|
147
|
+
return props.fontWeightBold ?? asTerminalFontWeight(readTerminalFontWeightBold(hostEl.value))
|
|
148
|
+
}
|
|
149
|
+
|
|
112
150
|
const zebraStyle = computed((): Record<string, string> | undefined => {
|
|
113
151
|
if (!props.zebraStripes) {
|
|
114
152
|
return undefined
|
|
115
153
|
}
|
|
116
|
-
const
|
|
154
|
+
const fontSize = resolveTerminalFontSize()
|
|
155
|
+
const step = zebraRowStepPx.value ?? fontSize * TERMINAL_LINE_HEIGHT
|
|
117
156
|
return {
|
|
118
|
-
'--rs-terminal-font-size': `${
|
|
157
|
+
'--rs-terminal-font-size': `${fontSize}px`,
|
|
119
158
|
'--rs-terminal-line-height': String(TERMINAL_LINE_HEIGHT),
|
|
120
159
|
'--rs-terminal-zebra-step': `${step}px`,
|
|
121
160
|
}
|
|
@@ -468,10 +507,10 @@ watch(
|
|
|
468
507
|
}
|
|
469
508
|
refreshResolvedTheme()
|
|
470
509
|
terminal.options.cursorBlink = props.cursorBlink
|
|
471
|
-
terminal.options.fontFamily =
|
|
472
|
-
terminal.options.fontSize =
|
|
473
|
-
terminal.options.fontWeight =
|
|
474
|
-
terminal.options.fontWeightBold =
|
|
510
|
+
terminal.options.fontFamily = resolveTerminalFontFamily()
|
|
511
|
+
terminal.options.fontSize = resolveTerminalFontSize()
|
|
512
|
+
terminal.options.fontWeight = resolveTerminalFontWeight()
|
|
513
|
+
terminal.options.fontWeightBold = resolveTerminalFontWeightBold()
|
|
475
514
|
terminal.options.allowTransparency = resolveAllowTransparency()
|
|
476
515
|
terminal.options.convertEol = props.convertEol
|
|
477
516
|
attachWheelGuard()
|
|
@@ -487,10 +526,10 @@ onMounted(async () => {
|
|
|
487
526
|
refreshResolvedTheme()
|
|
488
527
|
terminal = new Terminal({
|
|
489
528
|
cursorBlink: props.cursorBlink,
|
|
490
|
-
fontFamily:
|
|
491
|
-
fontSize:
|
|
492
|
-
fontWeight:
|
|
493
|
-
fontWeightBold:
|
|
529
|
+
fontFamily: resolveTerminalFontFamily(),
|
|
530
|
+
fontSize: resolveTerminalFontSize(),
|
|
531
|
+
fontWeight: resolveTerminalFontWeight(),
|
|
532
|
+
fontWeightBold: resolveTerminalFontWeightBold(),
|
|
494
533
|
lineHeight: TERMINAL_LINE_HEIGHT,
|
|
495
534
|
allowTransparency: resolveAllowTransparency(),
|
|
496
535
|
drawBoldTextInBrightColors: true,
|
|
@@ -636,7 +675,7 @@ defineExpose({
|
|
|
636
675
|
pointer-events: none;
|
|
637
676
|
font-family: var(--rs-font-mono);
|
|
638
677
|
font-size: var(--rs-font-size-xs);
|
|
639
|
-
font-weight:
|
|
678
|
+
font-weight: var(--rs-font-weight-regular);
|
|
640
679
|
line-height: var(--rs-line-height-normal);
|
|
641
680
|
}
|
|
642
681
|
|
|
@@ -658,7 +697,7 @@ defineExpose({
|
|
|
658
697
|
}
|
|
659
698
|
|
|
660
699
|
.rs-terminal--zebra :deep(.xterm) {
|
|
661
|
-
font-size: var(--rs-terminal-font-size
|
|
700
|
+
font-size: var(--rs-terminal-font-size);
|
|
662
701
|
line-height: var(--rs-terminal-line-height, 1.2);
|
|
663
702
|
}
|
|
664
703
|
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { computed, nextTick, ref, useId, useTemplateRef, watch } from 'vue'
|
|
2
|
+
import { computed, nextTick, ref, useAttrs, useId, useTemplateRef, watch } from 'vue'
|
|
3
3
|
import { PopoverContent, PopoverPortal, PopoverRoot, PopoverTrigger } from './reka'
|
|
4
4
|
import RsIcon from './RsIcon.vue'
|
|
5
5
|
import RsTimePickerColumns from './RsTimePickerColumns.vue'
|
|
6
6
|
import { useRsI18n } from '../composables/useRsI18n'
|
|
7
|
+
import { RS_COMPONENT_SIZE_ICON_PX, type RsComponentSize } from '../theme/types'
|
|
8
|
+
import { useResolvedRsComponentSize } from './resolve-size'
|
|
9
|
+
import { isRsFormItemBoundControl, useRsFormItemContext } from './form-utils'
|
|
7
10
|
import {
|
|
8
11
|
EMPTY_TIME_RANGE,
|
|
9
12
|
formatTimeFromParts,
|
|
@@ -16,9 +19,10 @@ import {
|
|
|
16
19
|
pickEarlierTime,
|
|
17
20
|
pickLaterTime,
|
|
18
21
|
type RsTimeRangeValue,
|
|
22
|
+
type RsTimeUnit,
|
|
19
23
|
} from './time-picker-utils'
|
|
20
24
|
|
|
21
|
-
defineOptions({ name: 'RsTimePicker' })
|
|
25
|
+
defineOptions({ name: 'RsTimePicker', inheritAttrs: false })
|
|
22
26
|
|
|
23
27
|
export type { RsTimeRangeValue } from './time-picker-utils'
|
|
24
28
|
export type RsTimePickerLabelPosition = 'top' | 'left'
|
|
@@ -43,6 +47,9 @@ const props = withDefaults(
|
|
|
43
47
|
maxTime?: string
|
|
44
48
|
embedded?: boolean
|
|
45
49
|
labelPosition?: RsTimePickerLabelPosition
|
|
50
|
+
size?: RsComponentSize
|
|
51
|
+
id?: string
|
|
52
|
+
invalid?: boolean
|
|
46
53
|
}>(),
|
|
47
54
|
{
|
|
48
55
|
disabled: false,
|
|
@@ -55,7 +62,16 @@ const props = withDefaults(
|
|
|
55
62
|
)
|
|
56
63
|
|
|
57
64
|
const fieldId = useId()
|
|
65
|
+
const attrs = useAttrs()
|
|
58
66
|
const { t } = useRsI18n()
|
|
67
|
+
const formItem = useRsFormItemContext()
|
|
68
|
+
const boundToItem = computed(() => isRsFormItemBoundControl(formItem, { id: props.id }))
|
|
69
|
+
const isInvalid = computed(() =>
|
|
70
|
+
Boolean(props.invalid || (boundToItem.value && formItem?.invalid.value)),
|
|
71
|
+
)
|
|
72
|
+
const triggerId = computed(() => props.id || fieldId)
|
|
73
|
+
const resolvedSize = useResolvedRsComponentSize(() => props.size)
|
|
74
|
+
const triggerIconSize = computed(() => RS_COMPONENT_SIZE_ICON_PX[resolvedSize.value])
|
|
59
75
|
const columnsRef = useTemplateRef<InstanceType<typeof RsTimePickerColumns>>('columnsRef')
|
|
60
76
|
|
|
61
77
|
const draftHour = ref(0)
|
|
@@ -171,7 +187,7 @@ function syncDraftFromModel(): void {
|
|
|
171
187
|
syncSingleDraft()
|
|
172
188
|
}
|
|
173
189
|
|
|
174
|
-
function isUnitDisabled(unit:
|
|
190
|
+
function isUnitDisabled(unit: RsTimeUnit, value: number): boolean {
|
|
175
191
|
const hour = unit === 'hour' ? value : draftHour.value
|
|
176
192
|
const minute = unit === 'minute' ? value : draftMinute.value
|
|
177
193
|
const second = unit === 'second' ? value : draftSecond.value
|
|
@@ -275,6 +291,7 @@ watch(open, async (isOpen) => {
|
|
|
275
291
|
<div
|
|
276
292
|
:class="[
|
|
277
293
|
embedded ? 'rs-time-picker-embedded' : 'rs-field',
|
|
294
|
+
`rs-time-picker--${resolvedSize}`,
|
|
278
295
|
!embedded && `rs-field--label-${labelPosition}`,
|
|
279
296
|
]"
|
|
280
297
|
>
|
|
@@ -287,20 +304,28 @@ watch(open, async (isOpen) => {
|
|
|
287
304
|
<div class="rs-time-picker">
|
|
288
305
|
<PopoverRoot v-model:open="open" :modal="!embedded">
|
|
289
306
|
<PopoverTrigger
|
|
290
|
-
|
|
307
|
+
v-bind="embedded ? undefined : attrs"
|
|
308
|
+
:id="embedded ? undefined : triggerId"
|
|
291
309
|
type="button"
|
|
292
310
|
class="rs-time-picker__trigger"
|
|
293
311
|
:class="{
|
|
294
312
|
'rs-time-picker__trigger--placeholder': isEmpty,
|
|
295
313
|
'rs-time-picker__trigger--embedded': embedded,
|
|
314
|
+
'rs-time-picker__trigger--invalid': !embedded && isInvalid,
|
|
296
315
|
}"
|
|
297
316
|
:disabled="disabled"
|
|
317
|
+
:aria-invalid="!embedded && isInvalid ? true : undefined"
|
|
298
318
|
>
|
|
299
319
|
<span class="rs-time-picker__leading">
|
|
300
|
-
<RsIcon
|
|
320
|
+
<RsIcon
|
|
321
|
+
v-if="!embedded"
|
|
322
|
+
name="clock"
|
|
323
|
+
:size="triggerIconSize"
|
|
324
|
+
class="rs-time-picker__icon"
|
|
325
|
+
/>
|
|
301
326
|
<span class="rs-time-picker__value">{{ displayValue }}</span>
|
|
302
327
|
</span>
|
|
303
|
-
<RsIcon name="chevron-down" :size="
|
|
328
|
+
<RsIcon name="chevron-down" :size="triggerIconSize" class="rs-time-picker__chevron" />
|
|
304
329
|
</PopoverTrigger>
|
|
305
330
|
|
|
306
331
|
<PopoverPortal>
|
|
@@ -321,6 +346,7 @@ watch(open, async (isOpen) => {
|
|
|
321
346
|
<RsTimePicker
|
|
322
347
|
v-model="draftStartTime"
|
|
323
348
|
embedded
|
|
349
|
+
:size="resolvedSize"
|
|
324
350
|
:with-seconds="withSeconds"
|
|
325
351
|
:min-time="minTime"
|
|
326
352
|
:max-time="startMaxTime"
|
|
@@ -333,6 +359,7 @@ watch(open, async (isOpen) => {
|
|
|
333
359
|
<RsTimePicker
|
|
334
360
|
v-model="draftEndTime"
|
|
335
361
|
embedded
|
|
362
|
+
:size="resolvedSize"
|
|
336
363
|
:with-seconds="withSeconds"
|
|
337
364
|
:min-time="endMinTime"
|
|
338
365
|
:max-time="maxTime"
|
|
@@ -347,6 +374,7 @@ watch(open, async (isOpen) => {
|
|
|
347
374
|
ref="columnsRef"
|
|
348
375
|
v-model="draftTime"
|
|
349
376
|
:second="withSeconds"
|
|
377
|
+
:size="resolvedSize"
|
|
350
378
|
:disabled="disabled"
|
|
351
379
|
:is-unit-disabled="isUnitDisabled"
|
|
352
380
|
/>
|
|
@@ -392,7 +420,9 @@ watch(open, async (isOpen) => {
|
|
|
392
420
|
align-items: center;
|
|
393
421
|
justify-content: space-between;
|
|
394
422
|
gap: var(--rs-space-sm);
|
|
423
|
+
box-sizing: border-box;
|
|
395
424
|
width: 100%;
|
|
425
|
+
height: var(--rs-control-height-md);
|
|
396
426
|
min-height: var(--rs-control-height-md);
|
|
397
427
|
padding: 0 var(--rs-space-md);
|
|
398
428
|
border: 1px solid var(--rs-input-border, var(--rs-border));
|
|
@@ -401,21 +431,44 @@ watch(open, async (isOpen) => {
|
|
|
401
431
|
color: var(--rs-text);
|
|
402
432
|
font: inherit;
|
|
403
433
|
font-size: var(--rs-font-size-sm);
|
|
434
|
+
line-height: var(--rs-line-height-tight);
|
|
404
435
|
text-align: left;
|
|
405
436
|
cursor: pointer;
|
|
437
|
+
outline: none;
|
|
406
438
|
box-shadow: var(--rs-input-shadow, none);
|
|
407
439
|
transition:
|
|
408
440
|
border-color var(--rs-transition-fast),
|
|
409
441
|
box-shadow var(--rs-transition-fast),
|
|
410
442
|
background var(--rs-transition-fast);
|
|
411
443
|
}
|
|
412
|
-
.rs-time-
|
|
444
|
+
.rs-time-picker--ssm .rs-time-picker__trigger {
|
|
445
|
+
height: var(--rs-control-height-ssm);
|
|
446
|
+
min-height: var(--rs-control-height-ssm);
|
|
447
|
+
padding: 0 var(--rs-space-xs);
|
|
448
|
+
font-size: var(--rs-font-size-xs);
|
|
449
|
+
}
|
|
450
|
+
.rs-time-picker--sm .rs-time-picker__trigger {
|
|
451
|
+
height: var(--rs-control-height-sm);
|
|
413
452
|
min-height: var(--rs-control-height-sm);
|
|
414
|
-
min-width: 5.5rem;
|
|
415
453
|
padding: 0 var(--rs-space-sm);
|
|
416
454
|
font-size: var(--rs-font-size-xs);
|
|
455
|
+
}
|
|
456
|
+
.rs-time-picker--lg .rs-time-picker__trigger {
|
|
457
|
+
height: var(--rs-control-height-lg);
|
|
458
|
+
min-height: var(--rs-control-height-lg);
|
|
459
|
+
padding: 0 var(--rs-space-lg);
|
|
460
|
+
font-size: var(--rs-font-size-base);
|
|
461
|
+
}
|
|
462
|
+
.rs-time-picker__trigger--embedded {
|
|
463
|
+
min-width: 5.5rem;
|
|
417
464
|
background: color-mix(in srgb, var(--rs-surface) 72%, transparent);
|
|
418
465
|
}
|
|
466
|
+
.rs-time-picker--ssm .rs-time-picker__trigger--embedded {
|
|
467
|
+
min-width: 4.75rem;
|
|
468
|
+
}
|
|
469
|
+
.rs-time-picker--lg .rs-time-picker__trigger--embedded {
|
|
470
|
+
min-width: 6.25rem;
|
|
471
|
+
}
|
|
419
472
|
.rs-time-picker__trigger:hover:not(:disabled) {
|
|
420
473
|
border-color: var(--rs-input-border-hover, var(--rs-border));
|
|
421
474
|
}
|
|
@@ -433,6 +486,16 @@ watch(open, async (isOpen) => {
|
|
|
433
486
|
.rs-time-picker__trigger--placeholder .rs-time-picker__value {
|
|
434
487
|
color: var(--rs-placeholder);
|
|
435
488
|
}
|
|
489
|
+
.rs-time-picker__trigger--invalid {
|
|
490
|
+
border-color: var(--rs-danger, var(--rs-color-danger, #dc2626));
|
|
491
|
+
}
|
|
492
|
+
.rs-time-picker__trigger--invalid:focus-visible {
|
|
493
|
+
border-color: var(--rs-danger, var(--rs-color-danger, #dc2626));
|
|
494
|
+
box-shadow:
|
|
495
|
+
var(--rs-input-shadow, none),
|
|
496
|
+
0 0 0 var(--rs-focus-ring-width, 2px)
|
|
497
|
+
color-mix(in srgb, var(--rs-danger, #dc2626) 14%, transparent);
|
|
498
|
+
}
|
|
436
499
|
.rs-time-picker__leading {
|
|
437
500
|
display: inline-flex;
|
|
438
501
|
min-width: 0;
|
|
@@ -497,7 +560,7 @@ watch(open, async (isOpen) => {
|
|
|
497
560
|
}
|
|
498
561
|
.rs-time-picker__pane-title {
|
|
499
562
|
font-size: var(--rs-font-size-xs);
|
|
500
|
-
font-weight:
|
|
563
|
+
font-weight: var(--rs-font-weight-semibold);
|
|
501
564
|
color: var(--rs-muted);
|
|
502
565
|
}
|
|
503
566
|
.rs-time-picker__footer {
|