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
|
@@ -1,775 +1,560 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
|
|
3
|
-
import { computed, ref, watch } from 'vue'
|
|
2
|
+
import { computed, ref, useAttrs } from 'vue'
|
|
4
3
|
|
|
5
4
|
import { useRsI18n } from '../composables/useRsI18n'
|
|
6
5
|
import type { RsComponentSize, RsRadius } from '../theme/types'
|
|
7
6
|
import { RS_COMPONENT_SIZE_ICON_PX } from '../theme/types'
|
|
8
7
|
|
|
9
8
|
import RsIcon from './RsIcon.vue'
|
|
10
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
isRsFormItemBoundControl,
|
|
11
|
+
useRsFormContext,
|
|
12
|
+
useRsFormField,
|
|
13
|
+
useRsFormItemContext,
|
|
14
|
+
} from './form-utils'
|
|
15
|
+
import {
|
|
16
|
+
buildLocalInputRules,
|
|
17
|
+
runFormFieldRules,
|
|
18
|
+
type RsFormRuleTrigger,
|
|
19
|
+
} from './form-rules'
|
|
11
20
|
import { useResolvedRsComponentSize } from './resolve-size'
|
|
12
21
|
import { rsRadiusCss, useResolvedRsRadius } from './resolve-radius'
|
|
13
|
-
|
|
14
22
|
import {
|
|
15
|
-
|
|
16
|
-
buildOptionDisabledMap,
|
|
17
|
-
|
|
18
|
-
buildOptionLabelMap,
|
|
19
|
-
|
|
20
|
-
filterSelectOptions,
|
|
21
|
-
|
|
22
|
-
flattenSelectOptions,
|
|
23
|
-
|
|
24
|
-
flattenSelectValues,
|
|
25
|
-
|
|
26
23
|
isSelectOptionGroup,
|
|
27
|
-
|
|
24
|
+
toComboboxValue,
|
|
25
|
+
type RsSelectFieldNames,
|
|
26
|
+
type RsSelectFilterOption,
|
|
27
|
+
type RsSelectFilterSort,
|
|
28
|
+
type RsSelectGetPopupContainer,
|
|
29
|
+
type RsSelectModelValue,
|
|
30
|
+
type RsSelectOption,
|
|
31
|
+
type RsSelectOptionFilterProp,
|
|
32
|
+
type RsSelectOptionsInput,
|
|
33
|
+
type RsSelectPlacement,
|
|
34
|
+
type RsSelectStatus,
|
|
35
|
+
type RsSelectValue,
|
|
28
36
|
} from './select-utils'
|
|
29
|
-
|
|
37
|
+
import { useRsSelect } from './use-rs-select'
|
|
30
38
|
import {
|
|
31
|
-
|
|
32
39
|
ComboboxAnchor,
|
|
33
|
-
|
|
34
40
|
ComboboxContent,
|
|
35
|
-
|
|
36
41
|
ComboboxEmpty,
|
|
37
|
-
|
|
38
42
|
ComboboxGroup,
|
|
39
|
-
|
|
40
43
|
ComboboxInput,
|
|
41
|
-
|
|
42
44
|
ComboboxItem,
|
|
43
|
-
|
|
44
45
|
ComboboxItemIndicator,
|
|
45
|
-
|
|
46
46
|
ComboboxLabel,
|
|
47
|
-
|
|
48
47
|
ComboboxPortal,
|
|
49
|
-
|
|
50
48
|
ComboboxRoot,
|
|
51
|
-
|
|
52
49
|
ComboboxTrigger,
|
|
53
|
-
|
|
54
50
|
ComboboxViewport,
|
|
55
|
-
|
|
56
51
|
ComboboxVirtualizer,
|
|
57
|
-
|
|
58
|
-
useFilter,
|
|
59
|
-
|
|
60
52
|
} from './reka'
|
|
61
53
|
|
|
54
|
+
defineOptions({ inheritAttrs: false })
|
|
62
55
|
|
|
63
|
-
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
|
|
56
|
+
const model = defineModel<RsSelectModelValue>({ default: '' })
|
|
57
|
+
const open = defineModel<boolean>('open', { default: false })
|
|
58
|
+
const searchQuery = defineModel<string>('searchValue', { default: '' })
|
|
67
59
|
|
|
68
60
|
const props = withDefaults(
|
|
69
|
-
|
|
70
61
|
defineProps<{
|
|
71
|
-
|
|
72
|
-
options: RsSelectOptions
|
|
73
|
-
|
|
62
|
+
options: RsSelectOptionsInput
|
|
74
63
|
placeholder?: string
|
|
75
|
-
|
|
76
64
|
disabled?: boolean
|
|
77
|
-
|
|
78
65
|
id?: string
|
|
79
|
-
|
|
80
|
-
/** 下拉内搜索过滤 */
|
|
81
|
-
|
|
82
66
|
searchable?: boolean
|
|
83
|
-
|
|
84
67
|
/**
|
|
85
68
|
* 允许把搜索框内容作为自定义值提交(Enter 或点「使用 xxx」)。
|
|
86
|
-
* 专业工具常见:类型名 / 枚举等不在预设列表时仍可手输。
|
|
87
69
|
* 开启后若未显式关 searchable,将自动启用搜索框。
|
|
88
70
|
*/
|
|
89
71
|
creatable?: boolean
|
|
90
|
-
|
|
91
|
-
/** 多选,v-model 为 string[] */
|
|
92
|
-
|
|
93
72
|
multiple?: boolean
|
|
94
73
|
required?: boolean
|
|
95
|
-
|
|
96
|
-
/** 显示清空按钮 */
|
|
97
|
-
|
|
74
|
+
name?: string
|
|
98
75
|
clearable?: boolean
|
|
99
|
-
|
|
100
|
-
/** 启用虚拟滚动(长列表) */
|
|
101
|
-
|
|
102
76
|
virtual?: boolean
|
|
103
|
-
|
|
104
|
-
/** 超过该数量自动启用虚拟滚动 */
|
|
105
|
-
|
|
106
77
|
virtualThreshold?: number
|
|
107
|
-
|
|
108
|
-
/** 远程搜索:关闭内置过滤,通过 @search 拉取 options */
|
|
109
|
-
|
|
110
78
|
remote?: boolean
|
|
111
|
-
|
|
112
|
-
/** 远程加载中 */
|
|
113
|
-
|
|
114
79
|
loading?: boolean
|
|
115
|
-
|
|
116
80
|
searchPlaceholder?: string
|
|
117
|
-
|
|
118
81
|
emptyText?: string
|
|
119
|
-
|
|
120
82
|
loadingText?: string
|
|
121
|
-
|
|
122
83
|
size?: RsComponentSize
|
|
123
|
-
|
|
124
|
-
/** 圆角档位;默认 sm。直角 UI 传 `none`。 */
|
|
125
|
-
|
|
126
84
|
radius?: RsRadius
|
|
127
|
-
|
|
128
85
|
/**
|
|
129
86
|
* 下拉面板是否与触发器等宽。
|
|
130
|
-
*
|
|
131
|
-
* - 默认 `false`:面板 `min-width` 对齐触发器,可随选项文案变宽(受 max-width 限制),避免长文案大量省略。
|
|
132
|
-
* - `true`:面板强制与触发器同宽,适合表单栅格、筛选条等需要对齐的场景;长文案仍会 ellipsis。
|
|
133
|
-
*
|
|
134
|
-
* 注意:开启虚拟滚动时,列表项多为绝对定位,无法可靠把面板撑到「全局最长文案」宽度,
|
|
135
|
-
* 宽度可能随可见项变化或退回到触发器宽度;长列表若强依赖内容撑宽,请关闭 virtual,
|
|
136
|
-
* 或改用 `matchTriggerWidth` + 截断项 Tooltip。
|
|
87
|
+
* 默认 false:面板可随文案变宽;true:与触发器同宽。
|
|
137
88
|
*/
|
|
138
89
|
matchTriggerWidth?: boolean
|
|
139
|
-
|
|
140
|
-
/** 根节点占满父级宽度(与按钮并排时用)。 */
|
|
141
90
|
block?: boolean
|
|
142
|
-
|
|
91
|
+
invalid?: boolean
|
|
92
|
+
showValidateMessage?: boolean
|
|
93
|
+
filterOption?: RsSelectFilterOption | boolean
|
|
94
|
+
optionFilterProp?: RsSelectOptionFilterProp
|
|
95
|
+
maxTagCount?: number
|
|
96
|
+
maxTagPlaceholder?: string | ((omitted: number) => string)
|
|
97
|
+
multipleLimit?: number
|
|
98
|
+
labelInValue?: boolean
|
|
99
|
+
filterSort?: RsSelectFilterSort
|
|
100
|
+
maxTagTextLength?: number
|
|
101
|
+
maxTagTooltip?: boolean
|
|
102
|
+
tokenSeparators?: string[]
|
|
103
|
+
autoClearSearchValue?: boolean
|
|
104
|
+
showArrow?: boolean
|
|
105
|
+
listHeight?: number
|
|
106
|
+
placement?: RsSelectPlacement
|
|
107
|
+
popupClassName?: string
|
|
108
|
+
status?: RsSelectStatus
|
|
109
|
+
/** 把业务字段映射为 label / value / options,对齐 Ant fieldNames */
|
|
110
|
+
fieldNames?: RsSelectFieldNames
|
|
111
|
+
/** 触发器展示用的选项字段,默认 label。对齐 Ant optionLabelProp */
|
|
112
|
+
optionLabelProp?: string
|
|
113
|
+
/** 下拉挂载容器,对齐 Ant getPopupContainer */
|
|
114
|
+
getPopupContainer?: RsSelectGetPopupContainer
|
|
143
115
|
}>(),
|
|
144
|
-
|
|
145
116
|
{
|
|
146
|
-
|
|
147
117
|
disabled: false,
|
|
148
|
-
|
|
149
118
|
searchable: false,
|
|
150
|
-
|
|
151
119
|
creatable: false,
|
|
152
|
-
|
|
153
120
|
multiple: false,
|
|
154
121
|
required: false,
|
|
155
|
-
|
|
156
122
|
clearable: false,
|
|
157
|
-
|
|
158
123
|
virtual: false,
|
|
159
|
-
|
|
160
124
|
virtualThreshold: 50,
|
|
161
|
-
|
|
162
125
|
remote: false,
|
|
163
|
-
|
|
164
126
|
loading: false,
|
|
165
|
-
|
|
166
127
|
matchTriggerWidth: false,
|
|
167
|
-
|
|
168
128
|
block: false,
|
|
169
|
-
|
|
129
|
+
optionFilterProp: 'label',
|
|
130
|
+
optionLabelProp: 'label',
|
|
131
|
+
labelInValue: false,
|
|
132
|
+
maxTagTooltip: true,
|
|
133
|
+
autoClearSearchValue: true,
|
|
134
|
+
showArrow: true,
|
|
135
|
+
listHeight: 256,
|
|
136
|
+
placement: 'bottom',
|
|
137
|
+
status: '',
|
|
170
138
|
},
|
|
171
|
-
|
|
172
139
|
)
|
|
173
140
|
|
|
174
|
-
|
|
175
|
-
|
|
176
141
|
const emit = defineEmits<{
|
|
177
|
-
|
|
178
142
|
search: [query: string]
|
|
179
|
-
|
|
143
|
+
select: [value: RsSelectValue, option?: RsSelectOption]
|
|
144
|
+
deselect: [value: RsSelectValue, option?: RsSelectOption]
|
|
145
|
+
clear: []
|
|
180
146
|
}>()
|
|
181
147
|
|
|
182
|
-
|
|
183
|
-
|
|
184
148
|
const { t } = useRsI18n()
|
|
149
|
+
const attrs = useAttrs()
|
|
185
150
|
const formContext = useRsFormContext()
|
|
186
|
-
|
|
187
|
-
const
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
const searchQuery = ref('')
|
|
192
|
-
|
|
193
|
-
/** 下拉显隐;支持 v-model:open(如表格多选关闭时提交) */
|
|
194
|
-
const open = defineModel<boolean>('open', { default: false })
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
const resolvedPlaceholder = computed(() => props.placeholder ?? t('select.placeholder'))
|
|
199
|
-
|
|
200
|
-
const resolvedSearchPlaceholder = computed(
|
|
201
|
-
|
|
202
|
-
() => props.searchPlaceholder ?? t('select.searchPlaceholder'),
|
|
203
|
-
|
|
204
|
-
)
|
|
205
|
-
|
|
206
|
-
const resolvedEmptyText = computed(() => props.emptyText ?? t('select.empty'))
|
|
207
|
-
|
|
208
|
-
const resolvedLoadingText = computed(() => props.loadingText ?? t('select.loading'))
|
|
209
|
-
|
|
210
|
-
/** creatable 默认带搜索框,便于手输 */
|
|
211
|
-
const isSearchable = computed(() => props.searchable || props.creatable)
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
const labelMap = computed(() => buildOptionLabelMap(props.options))
|
|
216
|
-
|
|
217
|
-
const disabledMap = computed(() => buildOptionDisabledMap(props.options))
|
|
218
|
-
|
|
219
|
-
const flatOptions = computed(() => flattenSelectOptions(props.options))
|
|
220
|
-
|
|
221
|
-
const flatCount = computed(() => flatOptions.value.length)
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
const useVirtual = computed(
|
|
226
|
-
|
|
227
|
-
() => props.virtual || flatCount.value > props.virtualThreshold,
|
|
228
|
-
|
|
151
|
+
const formItem = useRsFormItemContext()
|
|
152
|
+
const boundToItem = computed(() =>
|
|
153
|
+
isRsFormItemBoundControl(formItem, { id: props.id, name: props.name }),
|
|
229
154
|
)
|
|
155
|
+
const anchorRef = ref<{ $el?: HTMLElement } | HTMLElement | null>(null)
|
|
156
|
+
|
|
157
|
+
const {
|
|
158
|
+
resolvedPlaceholder,
|
|
159
|
+
resolvedSearchPlaceholder,
|
|
160
|
+
resolvedEmptyText,
|
|
161
|
+
resolvedLoadingText,
|
|
162
|
+
isSearchable,
|
|
163
|
+
labelMap,
|
|
164
|
+
useVirtual,
|
|
165
|
+
useManualFilter,
|
|
166
|
+
displayOptions,
|
|
167
|
+
createValue,
|
|
168
|
+
canCreate,
|
|
169
|
+
createOptionLabel,
|
|
170
|
+
virtualValues,
|
|
171
|
+
selectedValues,
|
|
172
|
+
hasValue,
|
|
173
|
+
visibleTagTokens,
|
|
174
|
+
omittedTagCount,
|
|
175
|
+
omittedTagLabel,
|
|
176
|
+
omittedTagTitle,
|
|
177
|
+
singleDisplayLabel,
|
|
178
|
+
comboboxModel,
|
|
179
|
+
tokenLabel,
|
|
180
|
+
truncateTagLabel,
|
|
181
|
+
optionFromToken,
|
|
182
|
+
optionOrCreate,
|
|
183
|
+
isOptionLimited,
|
|
184
|
+
isTokenDisabled,
|
|
185
|
+
restoreTokenValue,
|
|
186
|
+
onSearchKeydown,
|
|
187
|
+
onClear,
|
|
188
|
+
removeTag,
|
|
189
|
+
setValue,
|
|
190
|
+
resetSearch,
|
|
191
|
+
} = useRsSelect(props, model, open, searchQuery, emit, t)
|
|
230
192
|
|
|
231
|
-
const useManualFilter = computed(() => props.remote || useVirtual.value)
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
const displayOptions = computed(() => {
|
|
235
|
-
if (props.remote) return props.options
|
|
236
|
-
if (!useManualFilter.value) return props.options
|
|
237
|
-
return filterSelectOptions(props.options, searchQuery.value, contains)
|
|
238
|
-
})
|
|
239
|
-
|
|
240
|
-
const createValue = computed(() => searchQuery.value.trim())
|
|
241
|
-
|
|
242
|
-
const canCreate = computed(() => {
|
|
243
|
-
if (!props.creatable) return false
|
|
244
|
-
const q = createValue.value
|
|
245
|
-
if (!q) return false
|
|
246
|
-
const lower = q.toLowerCase()
|
|
247
|
-
return !flatOptions.value.some(
|
|
248
|
-
(opt) => opt.value.toLowerCase() === lower || String(opt.label).toLowerCase() === lower,
|
|
249
|
-
)
|
|
250
|
-
})
|
|
251
|
-
|
|
252
|
-
const createOptionLabel = computed(() =>
|
|
253
|
-
t('select.createOption', '使用 “{query}”').replace('{query}', createValue.value),
|
|
254
|
-
)
|
|
255
|
-
|
|
256
|
-
const virtualValues = computed(() => {
|
|
257
|
-
const values = flattenSelectValues(displayOptions.value)
|
|
258
|
-
if (!canCreate.value) return values
|
|
259
|
-
return [createValue.value, ...values.filter((v) => String(v) !== createValue.value)]
|
|
260
|
-
})
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
const selectedValues = computed<string[]>(() => {
|
|
265
|
-
|
|
266
|
-
if (props.multiple) {
|
|
267
|
-
|
|
268
|
-
const value = model.value
|
|
269
|
-
|
|
270
|
-
if (Array.isArray(value)) return value.map(String)
|
|
271
|
-
|
|
272
|
-
return value ? [String(value)] : []
|
|
273
|
-
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
const value = model.value
|
|
277
|
-
|
|
278
|
-
return value !== '' && value !== undefined && value !== null ? [String(value)] : []
|
|
279
|
-
|
|
280
|
-
})
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
const hasValue = computed(() => selectedValues.value.length > 0)
|
|
285
193
|
const resolvedDisabled = computed(() => props.disabled || formContext?.disabled.value || false)
|
|
286
194
|
const resolvedSize = useResolvedRsComponentSize(() => props.size)
|
|
287
195
|
const resolvedRadius = useResolvedRsRadius(() => props.radius, 'sm')
|
|
288
196
|
const triggerIconSize = computed(() => RS_COMPONENT_SIZE_ICON_PX[resolvedSize.value])
|
|
289
197
|
const rootStyle = computed(() => ({
|
|
290
198
|
'--rs-select-radius': rsRadiusCss(resolvedRadius.value),
|
|
199
|
+
'--rs-select-list-height': `${props.listHeight}px`,
|
|
291
200
|
}))
|
|
292
201
|
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
const
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
return labelMap.value.get(selectedValues.value[0]!) ?? selectedValues.value[0]!
|
|
300
|
-
|
|
301
|
-
})
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
const comboboxModel = computed<string | string[] | undefined>({
|
|
306
|
-
|
|
307
|
-
get() {
|
|
308
|
-
|
|
309
|
-
if (props.multiple) return selectedValues.value
|
|
310
|
-
|
|
311
|
-
return hasValue.value ? selectedValues.value[0] : undefined
|
|
312
|
-
|
|
313
|
-
},
|
|
314
|
-
|
|
315
|
-
set(value) {
|
|
316
|
-
|
|
317
|
-
if (props.multiple) {
|
|
318
|
-
|
|
319
|
-
model.value = Array.isArray(value) ? value.map(String) : []
|
|
320
|
-
|
|
321
|
-
} else {
|
|
322
|
-
|
|
323
|
-
model.value = value == null || value === '' ? '' : String(value)
|
|
324
|
-
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
},
|
|
328
|
-
|
|
329
|
-
})
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
watch(searchQuery, (query) => {
|
|
334
|
-
|
|
335
|
-
if (props.remote) emit('search', query)
|
|
336
|
-
|
|
337
|
-
})
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
watch(open, (isOpen) => {
|
|
342
|
-
if (isOpen) searchQuery.value = ''
|
|
202
|
+
const portalTo = computed(() => {
|
|
203
|
+
if (!props.getPopupContainer) return undefined
|
|
204
|
+
const raw = anchorRef.value
|
|
205
|
+
const el = raw instanceof HTMLElement ? raw : raw?.$el
|
|
206
|
+
return props.getPopupContainer(el instanceof HTMLElement ? el : undefined)
|
|
343
207
|
})
|
|
344
208
|
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
searchQuery.value = ''
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
function onSearchKeydown(event: KeyboardEvent): void {
|
|
359
|
-
if (event.key !== 'Enter' || event.isComposing) return
|
|
360
|
-
if (!canCreate.value) return
|
|
361
|
-
// 无精确匹配时 Enter 提交手输值;有匹配时交给 Combobox 默认选中行为
|
|
362
|
-
event.preventDefault()
|
|
363
|
-
event.stopPropagation()
|
|
364
|
-
commitCreatedValue(createValue.value)
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
function onClear(event: MouseEvent) {
|
|
370
|
-
|
|
371
|
-
event.preventDefault()
|
|
372
|
-
|
|
373
|
-
event.stopPropagation()
|
|
374
|
-
|
|
375
|
-
model.value = props.multiple ? [] : ''
|
|
376
|
-
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
function removeTag(value: string, event: MouseEvent) {
|
|
382
|
-
|
|
383
|
-
event.preventDefault()
|
|
384
|
-
|
|
385
|
-
event.stopPropagation()
|
|
386
|
-
|
|
387
|
-
if (!props.multiple) return
|
|
388
|
-
|
|
389
|
-
model.value = selectedValues.value.filter((item) => item !== value)
|
|
209
|
+
const autoMessage = ref('')
|
|
210
|
+
const isInvalid = computed(() =>
|
|
211
|
+
Boolean(
|
|
212
|
+
props.invalid ||
|
|
213
|
+
props.status === 'error' ||
|
|
214
|
+
(boundToItem.value && formItem?.invalid.value) ||
|
|
215
|
+
autoMessage.value,
|
|
216
|
+
),
|
|
217
|
+
)
|
|
218
|
+
const isWarning = computed(() => props.status === 'warning' && !isInvalid.value)
|
|
390
219
|
|
|
220
|
+
function clearValidation(): void {
|
|
221
|
+
resetSearch()
|
|
222
|
+
autoMessage.value = ''
|
|
391
223
|
}
|
|
392
224
|
|
|
393
|
-
function
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
model.value = []
|
|
401
|
-
}
|
|
402
|
-
return
|
|
225
|
+
async function runValidate(trigger: RsFormRuleTrigger = 'submit') {
|
|
226
|
+
const formRules = formContext?.getFieldRules(props.name) ?? []
|
|
227
|
+
const localRules = buildLocalInputRules({ required: props.required })
|
|
228
|
+
const rules = [...formRules, ...localRules]
|
|
229
|
+
if (!rules.length) {
|
|
230
|
+
autoMessage.value = ''
|
|
231
|
+
return { valid: true as const, name: props.name }
|
|
403
232
|
}
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
function clearValidation(): void {
|
|
408
|
-
searchQuery.value = ''
|
|
233
|
+
const result = await runFormFieldRules(model.value, rules, { trigger })
|
|
234
|
+
autoMessage.value = result.message ?? ''
|
|
235
|
+
return { valid: result.valid, message: result.message, name: props.name }
|
|
409
236
|
}
|
|
410
237
|
|
|
411
238
|
useRsFormField(() => ({
|
|
239
|
+
get name() {
|
|
240
|
+
return props.name
|
|
241
|
+
},
|
|
412
242
|
getValue: () => model.value,
|
|
413
243
|
setValue,
|
|
414
|
-
validate: () => (
|
|
244
|
+
validate: (trigger) => runValidate(trigger ?? 'submit'),
|
|
415
245
|
clearValidation,
|
|
246
|
+
setError: (message: string) => {
|
|
247
|
+
autoMessage.value = message
|
|
248
|
+
},
|
|
416
249
|
}))
|
|
417
250
|
|
|
418
251
|
defineExpose({
|
|
419
252
|
setValue,
|
|
420
253
|
clearValidation,
|
|
254
|
+
validate: runValidate,
|
|
421
255
|
})
|
|
422
|
-
|
|
423
256
|
</script>
|
|
424
257
|
|
|
425
|
-
|
|
426
|
-
|
|
427
258
|
<template>
|
|
428
|
-
|
|
429
259
|
<ComboboxRoot
|
|
430
|
-
|
|
431
260
|
v-model="comboboxModel"
|
|
432
|
-
|
|
433
261
|
v-model:open="open"
|
|
434
|
-
|
|
435
262
|
class="rs-select"
|
|
436
|
-
|
|
437
263
|
:class="{
|
|
438
|
-
|
|
439
264
|
'rs-select--multiple': multiple,
|
|
440
|
-
|
|
441
265
|
'rs-select--searchable': isSearchable,
|
|
442
266
|
'rs-select--creatable': creatable,
|
|
443
|
-
|
|
444
267
|
'rs-select--block': block,
|
|
445
|
-
|
|
446
268
|
[`rs-select--${resolvedSize}`]: true,
|
|
447
|
-
|
|
448
269
|
}"
|
|
449
|
-
|
|
450
270
|
:style="rootStyle"
|
|
451
|
-
|
|
452
271
|
:multiple="multiple"
|
|
453
|
-
|
|
454
272
|
:disabled="resolvedDisabled"
|
|
455
|
-
|
|
456
273
|
:ignore-filter="useManualFilter"
|
|
457
|
-
|
|
458
|
-
:reset-search-term-on-select="!multiple"
|
|
459
|
-
|
|
274
|
+
:reset-search-term-on-select="autoClearSearchValue"
|
|
460
275
|
open-on-click
|
|
461
|
-
|
|
462
276
|
>
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
277
|
+
<ComboboxAnchor ref="anchorRef" as-child>
|
|
278
|
+
<ComboboxTrigger
|
|
279
|
+
v-bind="attrs"
|
|
280
|
+
:id="id"
|
|
281
|
+
class="rs-select__trigger"
|
|
282
|
+
:class="{
|
|
283
|
+
'rs-select__trigger--invalid': isInvalid,
|
|
284
|
+
'rs-select__trigger--warning': isWarning,
|
|
285
|
+
}"
|
|
286
|
+
:aria-invalid="isInvalid || undefined"
|
|
287
|
+
>
|
|
288
|
+
<span v-if="$slots.prefix" class="rs-select__prefix">
|
|
289
|
+
<slot name="prefix" />
|
|
290
|
+
</span>
|
|
467
291
|
|
|
468
292
|
<span v-if="multiple" class="rs-select__value rs-select__value--multiple">
|
|
469
|
-
|
|
470
293
|
<template v-if="hasValue">
|
|
471
|
-
|
|
472
294
|
<span
|
|
473
|
-
|
|
474
|
-
v-for="value in selectedValues"
|
|
475
|
-
|
|
295
|
+
v-for="value in visibleTagTokens"
|
|
476
296
|
:key="value"
|
|
477
|
-
|
|
478
297
|
class="rs-select__tag"
|
|
479
|
-
|
|
480
298
|
>
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
type="button"
|
|
487
|
-
|
|
488
|
-
class="rs-select__tag-remove"
|
|
489
|
-
|
|
490
|
-
:aria-label="t('select.clear')"
|
|
491
|
-
|
|
492
|
-
@pointerdown.stop
|
|
493
|
-
|
|
494
|
-
@click="removeTag(value, $event)"
|
|
495
|
-
|
|
299
|
+
<slot
|
|
300
|
+
name="tag"
|
|
301
|
+
:value="restoreTokenValue(value)"
|
|
302
|
+
:label="tokenLabel(value)"
|
|
303
|
+
:closable="true"
|
|
496
304
|
>
|
|
497
|
-
|
|
498
|
-
<
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
305
|
+
<span class="rs-select__tag-label">{{ truncateTagLabel(tokenLabel(value)) }}</span>
|
|
306
|
+
<button
|
|
307
|
+
type="button"
|
|
308
|
+
class="rs-select__tag-remove"
|
|
309
|
+
:aria-label="t('select.clear')"
|
|
310
|
+
@pointerdown.stop
|
|
311
|
+
@click="removeTag(value, $event)"
|
|
312
|
+
>
|
|
313
|
+
<RsIcon name="x" :size="12" />
|
|
314
|
+
</button>
|
|
315
|
+
</slot>
|
|
316
|
+
</span>
|
|
317
|
+
<span
|
|
318
|
+
v-if="omittedTagCount > 0"
|
|
319
|
+
class="rs-select__tag rs-select__tag--rest"
|
|
320
|
+
:title="omittedTagTitle"
|
|
321
|
+
>
|
|
322
|
+
<slot name="maxTagPlaceholder" :omitted="omittedTagCount">
|
|
323
|
+
{{ omittedTagLabel }}
|
|
324
|
+
</slot>
|
|
502
325
|
</span>
|
|
503
|
-
|
|
504
326
|
</template>
|
|
505
|
-
|
|
506
327
|
<span v-else class="rs-select__placeholder">{{ resolvedPlaceholder }}</span>
|
|
507
|
-
|
|
508
328
|
</span>
|
|
509
329
|
|
|
510
330
|
<span v-else class="rs-select__value">
|
|
511
|
-
|
|
512
331
|
<span v-if="hasValue" class="rs-select__single-label">{{ singleDisplayLabel }}</span>
|
|
513
|
-
|
|
514
332
|
<span v-else class="rs-select__placeholder">{{ resolvedPlaceholder }}</span>
|
|
515
|
-
|
|
516
333
|
</span>
|
|
517
334
|
|
|
518
|
-
|
|
519
|
-
|
|
520
335
|
<span class="rs-select__actions">
|
|
521
|
-
|
|
522
336
|
<button
|
|
523
|
-
|
|
524
337
|
v-if="clearable && hasValue && !resolvedDisabled"
|
|
525
|
-
|
|
526
338
|
type="button"
|
|
527
|
-
|
|
528
339
|
class="rs-select__clear"
|
|
529
|
-
|
|
530
340
|
:aria-label="t('select.clear')"
|
|
531
|
-
|
|
532
341
|
@pointerdown.stop
|
|
533
|
-
|
|
534
342
|
@click="onClear"
|
|
535
|
-
|
|
536
343
|
>
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
344
|
+
<slot name="clearIcon">
|
|
345
|
+
<RsIcon name="x" :size="14" />
|
|
346
|
+
</slot>
|
|
540
347
|
</button>
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
348
|
+
<span v-if="showArrow" class="rs-select__suffix">
|
|
349
|
+
<slot name="suffixIcon">
|
|
350
|
+
<RsIcon name="chevron-down" :size="triggerIconSize" class="rs-select__icon" />
|
|
351
|
+
</slot>
|
|
352
|
+
</span>
|
|
544
353
|
</span>
|
|
545
|
-
|
|
546
354
|
</ComboboxTrigger>
|
|
547
|
-
|
|
548
355
|
</ComboboxAnchor>
|
|
549
356
|
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
<ComboboxPortal>
|
|
553
|
-
|
|
357
|
+
<ComboboxPortal :to="portalTo">
|
|
554
358
|
<ComboboxContent
|
|
555
359
|
class="rs-select__content"
|
|
556
|
-
:class="
|
|
360
|
+
:class="[
|
|
361
|
+
popupClassName,
|
|
362
|
+
{ 'rs-select__content--match-trigger': matchTriggerWidth },
|
|
363
|
+
]"
|
|
364
|
+
:style="{ '--rs-select-list-height': `${listHeight}px` }"
|
|
557
365
|
align="start"
|
|
366
|
+
:side="placement"
|
|
558
367
|
:side-offset="4"
|
|
559
368
|
position="popper"
|
|
560
369
|
>
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
<RsIcon name="search" :size="14" class="rs-select__search-icon" aria-hidden="true" />
|
|
565
|
-
<ComboboxInput
|
|
566
|
-
v-model="searchQuery"
|
|
567
|
-
class="rs-select__search"
|
|
568
|
-
:placeholder="resolvedSearchPlaceholder"
|
|
569
|
-
auto-focus
|
|
570
|
-
@keydown="onSearchKeydown"
|
|
571
|
-
/>
|
|
370
|
+
<slot name="dropdownRender">
|
|
371
|
+
<div v-if="$slots.header" class="rs-select__panel-header" @mousedown.prevent>
|
|
372
|
+
<slot name="header" />
|
|
572
373
|
</div>
|
|
573
|
-
</div>
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
<div v-if="loading" class="rs-select__status">{{ resolvedLoadingText }}</div>
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
<ComboboxEmpty v-if="!loading && !canCreate" class="rs-select__empty">
|
|
582
|
-
|
|
583
|
-
{{ resolvedEmptyText }}
|
|
584
|
-
|
|
585
|
-
</ComboboxEmpty>
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
<ComboboxViewport class="rs-select__viewport">
|
|
590
|
-
|
|
591
|
-
<ComboboxVirtualizer
|
|
592
|
-
|
|
593
|
-
v-if="useVirtual"
|
|
594
|
-
|
|
595
|
-
v-slot="{ option }"
|
|
596
|
-
|
|
597
|
-
:options="virtualValues"
|
|
598
|
-
|
|
599
|
-
:text-content="(value) => labelMap.get(String(value)) ?? String(value)"
|
|
600
|
-
|
|
601
|
-
:estimate-size="36"
|
|
602
|
-
|
|
603
|
-
>
|
|
604
|
-
|
|
605
|
-
<ComboboxItem
|
|
606
|
-
:value="option"
|
|
607
|
-
:disabled="disabledMap.get(String(option))"
|
|
608
|
-
:text-value="labelMap.get(String(option)) ?? String(option)"
|
|
609
|
-
class="rs-select__item"
|
|
610
|
-
:class="{ 'rs-select__item--create': canCreate && String(option) === createValue }"
|
|
611
|
-
>
|
|
612
|
-
<span class="rs-select__item-label">
|
|
613
|
-
{{
|
|
614
|
-
canCreate && String(option) === createValue
|
|
615
|
-
? createOptionLabel
|
|
616
|
-
: (labelMap.get(String(option)) ?? option)
|
|
617
|
-
}}
|
|
618
|
-
</span>
|
|
619
|
-
<ComboboxItemIndicator class="rs-select__item-check">
|
|
620
|
-
<RsIcon name="check" :size="14" />
|
|
621
|
-
</ComboboxItemIndicator>
|
|
622
|
-
</ComboboxItem>
|
|
623
|
-
|
|
624
|
-
</ComboboxVirtualizer>
|
|
625
|
-
|
|
626
374
|
|
|
375
|
+
<div v-if="isSearchable" class="rs-select__search-bar">
|
|
376
|
+
<div class="rs-select__search-wrap">
|
|
377
|
+
<RsIcon name="search" :size="14" class="rs-select__search-icon" aria-hidden="true" />
|
|
378
|
+
<ComboboxInput
|
|
379
|
+
v-model="searchQuery"
|
|
380
|
+
class="rs-select__search"
|
|
381
|
+
:placeholder="resolvedSearchPlaceholder"
|
|
382
|
+
auto-focus
|
|
383
|
+
@keydown="onSearchKeydown"
|
|
384
|
+
/>
|
|
385
|
+
</div>
|
|
386
|
+
</div>
|
|
627
387
|
|
|
628
|
-
<
|
|
388
|
+
<div v-if="loading" class="rs-select__status">
|
|
389
|
+
<slot name="loading">{{ resolvedLoadingText }}</slot>
|
|
390
|
+
</div>
|
|
629
391
|
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
392
|
+
<ComboboxEmpty v-if="!loading && !canCreate" class="rs-select__empty">
|
|
393
|
+
<slot name="empty">{{ resolvedEmptyText }}</slot>
|
|
394
|
+
</ComboboxEmpty>
|
|
395
|
+
|
|
396
|
+
<ComboboxViewport class="rs-select__viewport">
|
|
397
|
+
<ComboboxVirtualizer
|
|
398
|
+
v-if="useVirtual"
|
|
399
|
+
v-slot="{ option }"
|
|
400
|
+
:options="virtualValues"
|
|
401
|
+
:text-content="(value) => labelMap.get(String(value)) ?? String(value)"
|
|
402
|
+
:estimate-size="36"
|
|
635
403
|
>
|
|
636
|
-
<
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
404
|
+
<ComboboxItem
|
|
405
|
+
:value="option"
|
|
406
|
+
:disabled="isTokenDisabled(String(option))"
|
|
407
|
+
:text-value="labelMap.get(String(option)) ?? String(option)"
|
|
408
|
+
class="rs-select__item"
|
|
409
|
+
:class="{ 'rs-select__item--create': canCreate && String(option) === createValue }"
|
|
410
|
+
:title="optionFromToken(String(option))?.title"
|
|
411
|
+
>
|
|
412
|
+
<span class="rs-select__item-label">
|
|
413
|
+
<slot
|
|
414
|
+
name="option"
|
|
415
|
+
:option="optionOrCreate(String(option))"
|
|
416
|
+
:selected="selectedValues.includes(String(option))"
|
|
417
|
+
>
|
|
418
|
+
{{
|
|
419
|
+
canCreate && String(option) === createValue
|
|
420
|
+
? createOptionLabel
|
|
421
|
+
: (labelMap.get(String(option)) ?? String(option))
|
|
422
|
+
}}
|
|
423
|
+
</slot>
|
|
424
|
+
</span>
|
|
425
|
+
<ComboboxItemIndicator class="rs-select__item-check">
|
|
426
|
+
<RsIcon name="check" :size="14" />
|
|
427
|
+
</ComboboxItemIndicator>
|
|
428
|
+
</ComboboxItem>
|
|
429
|
+
</ComboboxVirtualizer>
|
|
647
430
|
|
|
648
|
-
|
|
431
|
+
<template v-else>
|
|
432
|
+
<ComboboxItem
|
|
433
|
+
v-if="canCreate"
|
|
434
|
+
:value="createValue"
|
|
435
|
+
:text-value="createValue"
|
|
436
|
+
class="rs-select__item rs-select__item--create"
|
|
437
|
+
>
|
|
438
|
+
<span class="rs-select__item-label">{{ createOptionLabel }}</span>
|
|
439
|
+
<ComboboxItemIndicator class="rs-select__item-check">
|
|
440
|
+
<RsIcon name="check" :size="14" />
|
|
441
|
+
</ComboboxItemIndicator>
|
|
442
|
+
</ComboboxItem>
|
|
649
443
|
|
|
650
|
-
|
|
444
|
+
<template v-for="(entry, index) in displayOptions" :key="index">
|
|
445
|
+
<ComboboxGroup v-if="isSelectOptionGroup(entry)" class="rs-select__group">
|
|
446
|
+
<ComboboxLabel class="rs-select__group-label">
|
|
447
|
+
{{ entry.label }}
|
|
448
|
+
</ComboboxLabel>
|
|
449
|
+
<ComboboxItem
|
|
450
|
+
v-for="opt in entry.options"
|
|
451
|
+
:key="toComboboxValue(opt.value)"
|
|
452
|
+
:value="toComboboxValue(opt.value)"
|
|
453
|
+
:disabled="opt.disabled || isOptionLimited(opt)"
|
|
454
|
+
:text-value="opt.label"
|
|
455
|
+
class="rs-select__item"
|
|
456
|
+
:title="opt.title"
|
|
457
|
+
>
|
|
458
|
+
<span class="rs-select__item-label">
|
|
459
|
+
<slot
|
|
460
|
+
name="option"
|
|
461
|
+
:option="opt"
|
|
462
|
+
:selected="selectedValues.includes(toComboboxValue(opt.value))"
|
|
463
|
+
>
|
|
464
|
+
{{ opt.label }}
|
|
465
|
+
</slot>
|
|
466
|
+
</span>
|
|
467
|
+
<ComboboxItemIndicator class="rs-select__item-check">
|
|
468
|
+
<RsIcon name="check" :size="14" />
|
|
469
|
+
</ComboboxItemIndicator>
|
|
470
|
+
</ComboboxItem>
|
|
471
|
+
</ComboboxGroup>
|
|
651
472
|
|
|
652
473
|
<ComboboxItem
|
|
653
|
-
v-
|
|
654
|
-
:key="
|
|
655
|
-
:value="
|
|
656
|
-
:disabled="
|
|
657
|
-
:text-value="
|
|
474
|
+
v-else
|
|
475
|
+
:key="toComboboxValue(entry.value)"
|
|
476
|
+
:value="toComboboxValue(entry.value)"
|
|
477
|
+
:disabled="entry.disabled || isOptionLimited(entry)"
|
|
478
|
+
:text-value="entry.label"
|
|
658
479
|
class="rs-select__item"
|
|
480
|
+
:title="entry.title"
|
|
659
481
|
>
|
|
660
|
-
<span class="rs-select__item-label">
|
|
482
|
+
<span class="rs-select__item-label">
|
|
483
|
+
<slot
|
|
484
|
+
name="option"
|
|
485
|
+
:option="entry"
|
|
486
|
+
:selected="selectedValues.includes(toComboboxValue(entry.value))"
|
|
487
|
+
>
|
|
488
|
+
{{ entry.label }}
|
|
489
|
+
</slot>
|
|
490
|
+
</span>
|
|
661
491
|
<ComboboxItemIndicator class="rs-select__item-check">
|
|
662
492
|
<RsIcon name="check" :size="14" />
|
|
663
493
|
</ComboboxItemIndicator>
|
|
664
494
|
</ComboboxItem>
|
|
665
|
-
|
|
666
|
-
</ComboboxGroup>
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
<ComboboxItem
|
|
671
|
-
v-else
|
|
672
|
-
:key="entry.value"
|
|
673
|
-
:value="entry.value"
|
|
674
|
-
:disabled="entry.disabled"
|
|
675
|
-
:text-value="entry.label"
|
|
676
|
-
class="rs-select__item"
|
|
677
|
-
>
|
|
678
|
-
<span class="rs-select__item-label">{{ entry.label }}</span>
|
|
679
|
-
<ComboboxItemIndicator class="rs-select__item-check">
|
|
680
|
-
<RsIcon name="check" :size="14" />
|
|
681
|
-
</ComboboxItemIndicator>
|
|
682
|
-
</ComboboxItem>
|
|
683
|
-
|
|
495
|
+
</template>
|
|
684
496
|
</template>
|
|
497
|
+
</ComboboxViewport>
|
|
685
498
|
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
499
|
+
<div v-if="$slots.footer" class="rs-select__panel-footer" @mousedown.prevent>
|
|
500
|
+
<slot name="footer" />
|
|
501
|
+
</div>
|
|
502
|
+
</slot>
|
|
690
503
|
</ComboboxContent>
|
|
691
|
-
|
|
692
504
|
</ComboboxPortal>
|
|
693
|
-
|
|
694
505
|
</ComboboxRoot>
|
|
695
|
-
|
|
696
506
|
</template>
|
|
697
507
|
|
|
698
|
-
|
|
699
|
-
|
|
700
508
|
<style scoped>
|
|
701
|
-
|
|
702
509
|
.rs-select {
|
|
703
|
-
|
|
704
510
|
display: inline-flex;
|
|
705
|
-
|
|
706
511
|
width: 100%;
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
512
|
+
max-width: 100%;
|
|
513
|
+
vertical-align: middle;
|
|
514
|
+
box-sizing: border-box;
|
|
710
515
|
}
|
|
711
516
|
|
|
712
517
|
.rs-select__trigger {
|
|
713
|
-
|
|
714
518
|
display: inline-flex;
|
|
715
|
-
|
|
716
519
|
align-items: center;
|
|
717
|
-
|
|
718
520
|
justify-content: space-between;
|
|
719
|
-
|
|
720
521
|
gap: var(--rs-space-sm);
|
|
721
|
-
|
|
522
|
+
box-sizing: border-box;
|
|
722
523
|
width: 100%;
|
|
723
|
-
|
|
524
|
+
height: var(--rs-control-height-md);
|
|
724
525
|
min-height: var(--rs-control-height-md);
|
|
725
|
-
|
|
726
526
|
padding: 0 var(--rs-space-md);
|
|
727
|
-
|
|
728
527
|
border-radius: var(--rs-select-radius, var(--rs-radius-sm));
|
|
729
|
-
|
|
730
528
|
border: 1px solid var(--rs-input-border, var(--rs-border));
|
|
731
|
-
|
|
732
529
|
background: var(--rs-input-bg);
|
|
733
|
-
|
|
734
530
|
color: var(--rs-text);
|
|
735
|
-
|
|
736
531
|
font-size: var(--rs-font-size-sm);
|
|
737
|
-
|
|
738
|
-
line-height: var(--rs-line-height-normal);
|
|
739
|
-
|
|
532
|
+
line-height: var(--rs-line-height-tight);
|
|
740
533
|
text-align: left;
|
|
741
|
-
|
|
742
534
|
cursor: pointer;
|
|
743
|
-
|
|
535
|
+
outline: none;
|
|
744
536
|
box-shadow: var(--rs-input-shadow, none);
|
|
745
|
-
|
|
746
537
|
transition:
|
|
747
|
-
|
|
748
538
|
border-color var(--rs-transition-fast),
|
|
749
|
-
|
|
750
539
|
box-shadow var(--rs-transition-fast),
|
|
751
|
-
|
|
752
540
|
background var(--rs-transition-fast);
|
|
753
|
-
|
|
754
541
|
}
|
|
755
542
|
|
|
756
543
|
.rs-select--multiple .rs-select__trigger {
|
|
757
|
-
|
|
758
544
|
min-height: var(--rs-control-height-md);
|
|
759
|
-
|
|
760
545
|
height: auto;
|
|
761
|
-
|
|
762
546
|
padding-top: var(--rs-space-xs);
|
|
763
|
-
|
|
764
547
|
padding-bottom: var(--rs-space-xs);
|
|
765
|
-
|
|
766
548
|
}
|
|
767
549
|
|
|
768
550
|
.rs-select--block {
|
|
769
551
|
display: flex;
|
|
770
552
|
flex-direction: column;
|
|
771
553
|
width: 100%;
|
|
554
|
+
max-width: none;
|
|
772
555
|
min-width: 0;
|
|
556
|
+
align-self: stretch;
|
|
557
|
+
box-sizing: border-box;
|
|
773
558
|
}
|
|
774
559
|
|
|
775
560
|
.rs-select--block .rs-select__anchor,
|
|
@@ -778,6 +563,7 @@ defineExpose({
|
|
|
778
563
|
}
|
|
779
564
|
|
|
780
565
|
.rs-select--ssm .rs-select__trigger {
|
|
566
|
+
height: var(--rs-control-height-ssm);
|
|
781
567
|
min-height: var(--rs-control-height-ssm);
|
|
782
568
|
padding: 0 var(--rs-space-xs);
|
|
783
569
|
font-size: var(--rs-font-size-xs);
|
|
@@ -788,6 +574,7 @@ defineExpose({
|
|
|
788
574
|
}
|
|
789
575
|
|
|
790
576
|
.rs-select--sm .rs-select__trigger {
|
|
577
|
+
height: var(--rs-control-height-sm);
|
|
791
578
|
min-height: var(--rs-control-height-sm);
|
|
792
579
|
padding: 0 var(--rs-space-sm);
|
|
793
580
|
font-size: var(--rs-font-size-xs);
|
|
@@ -798,6 +585,7 @@ defineExpose({
|
|
|
798
585
|
}
|
|
799
586
|
|
|
800
587
|
.rs-select--lg .rs-select__trigger {
|
|
588
|
+
height: var(--rs-control-height-lg);
|
|
801
589
|
min-height: var(--rs-control-height-lg);
|
|
802
590
|
padding: 0 var(--rs-space-lg);
|
|
803
591
|
font-size: var(--rs-font-size-base);
|
|
@@ -808,238 +596,180 @@ defineExpose({
|
|
|
808
596
|
}
|
|
809
597
|
|
|
810
598
|
.rs-select__trigger:hover:not([data-disabled]) {
|
|
811
|
-
|
|
812
599
|
border-color: var(--rs-input-border-hover, var(--rs-border));
|
|
813
|
-
|
|
814
600
|
}
|
|
815
601
|
|
|
816
602
|
.rs-select__trigger:focus-visible {
|
|
817
|
-
|
|
818
603
|
outline: none;
|
|
819
|
-
|
|
820
604
|
border-color: var(--rs-focus-border, var(--rs-primary));
|
|
821
|
-
|
|
822
605
|
background: var(--rs-input-bg);
|
|
823
|
-
|
|
824
606
|
box-shadow:
|
|
825
|
-
|
|
826
607
|
var(--rs-input-shadow, none),
|
|
827
|
-
|
|
828
608
|
0 0 0 var(--rs-focus-ring-width, 2px) var(--rs-focus-ring);
|
|
829
|
-
|
|
830
609
|
}
|
|
831
610
|
|
|
832
611
|
.rs-select__trigger[data-disabled] {
|
|
833
|
-
|
|
834
612
|
opacity: 0.38;
|
|
835
|
-
|
|
836
613
|
cursor: not-allowed;
|
|
837
|
-
|
|
838
614
|
background: var(--rs-surface-hover);
|
|
615
|
+
}
|
|
839
616
|
|
|
617
|
+
.rs-select__trigger--invalid {
|
|
618
|
+
border-color: var(--rs-danger);
|
|
840
619
|
}
|
|
841
620
|
|
|
842
|
-
.rs-
|
|
621
|
+
.rs-select__trigger--invalid:focus-visible {
|
|
622
|
+
border-color: var(--rs-danger);
|
|
623
|
+
box-shadow:
|
|
624
|
+
var(--rs-input-shadow, none),
|
|
625
|
+
0 0 0 var(--rs-focus-ring-width, 2px)
|
|
626
|
+
color-mix(in srgb, var(--rs-danger) 14%, transparent);
|
|
627
|
+
}
|
|
843
628
|
|
|
844
|
-
|
|
629
|
+
.rs-select__trigger--warning {
|
|
630
|
+
border-color: var(--rs-warning, #d97706);
|
|
631
|
+
}
|
|
845
632
|
|
|
846
|
-
|
|
633
|
+
.rs-select__trigger--warning:focus-visible {
|
|
634
|
+
border-color: var(--rs-warning, #d97706);
|
|
635
|
+
box-shadow:
|
|
636
|
+
var(--rs-input-shadow, none),
|
|
637
|
+
0 0 0 var(--rs-focus-ring-width, 2px)
|
|
638
|
+
color-mix(in srgb, var(--rs-warning, #d97706) 14%, transparent);
|
|
639
|
+
}
|
|
847
640
|
|
|
641
|
+
.rs-select__value {
|
|
642
|
+
flex: 1;
|
|
643
|
+
min-width: 0;
|
|
848
644
|
text-align: left;
|
|
849
|
-
|
|
850
645
|
overflow: hidden;
|
|
851
|
-
|
|
852
646
|
text-overflow: ellipsis;
|
|
853
|
-
|
|
854
647
|
white-space: nowrap;
|
|
855
|
-
|
|
856
648
|
}
|
|
857
649
|
|
|
858
650
|
.rs-select__value--multiple {
|
|
859
|
-
|
|
860
651
|
display: flex;
|
|
861
|
-
|
|
862
652
|
flex-wrap: nowrap;
|
|
863
|
-
|
|
864
653
|
gap: var(--rs-space-xs);
|
|
865
|
-
|
|
866
654
|
align-items: center;
|
|
867
|
-
|
|
868
655
|
white-space: nowrap;
|
|
869
|
-
|
|
870
656
|
overflow: hidden;
|
|
657
|
+
}
|
|
871
658
|
|
|
659
|
+
.rs-select__prefix {
|
|
660
|
+
display: inline-flex;
|
|
661
|
+
flex-shrink: 0;
|
|
662
|
+
align-items: center;
|
|
663
|
+
color: var(--rs-muted);
|
|
872
664
|
}
|
|
873
665
|
|
|
874
|
-
.rs-
|
|
666
|
+
.rs-select__tag--rest {
|
|
667
|
+
padding-right: 0.5rem;
|
|
668
|
+
color: var(--rs-muted);
|
|
669
|
+
background: var(--rs-surface-hover);
|
|
670
|
+
border-color: var(--rs-border);
|
|
671
|
+
}
|
|
875
672
|
|
|
673
|
+
.rs-select__placeholder {
|
|
876
674
|
color: var(--rs-placeholder);
|
|
877
|
-
|
|
878
675
|
}
|
|
879
676
|
|
|
880
677
|
.rs-select__single-label {
|
|
881
|
-
|
|
882
678
|
display: block;
|
|
883
|
-
|
|
884
679
|
overflow: hidden;
|
|
885
|
-
|
|
886
680
|
text-overflow: ellipsis;
|
|
887
|
-
|
|
888
681
|
white-space: nowrap;
|
|
889
|
-
|
|
890
682
|
}
|
|
891
683
|
|
|
892
684
|
.rs-select__tag {
|
|
893
|
-
|
|
894
685
|
display: inline-flex;
|
|
895
|
-
|
|
896
686
|
align-items: center;
|
|
897
|
-
|
|
898
687
|
gap: 0.125rem;
|
|
899
|
-
|
|
900
688
|
flex: 0 0 auto;
|
|
901
|
-
|
|
902
689
|
max-width: 10rem;
|
|
903
|
-
|
|
904
690
|
padding: 0.125rem 0.25rem 0.125rem 0.5rem;
|
|
905
|
-
|
|
906
691
|
border-radius: var(--rs-radius-xs);
|
|
907
|
-
|
|
908
692
|
border: 1px solid color-mix(in srgb, var(--rs-primary) 24%, transparent);
|
|
909
|
-
|
|
910
693
|
background: var(--rs-primary-container);
|
|
911
|
-
|
|
912
694
|
color: var(--rs-on-primary-container);
|
|
913
|
-
|
|
914
695
|
font-size: var(--rs-font-size-xs);
|
|
915
|
-
|
|
916
696
|
line-height: var(--rs-line-height-tight);
|
|
917
|
-
|
|
918
697
|
}
|
|
919
698
|
|
|
920
699
|
.rs-select__tag-label {
|
|
921
|
-
|
|
922
700
|
overflow: hidden;
|
|
923
|
-
|
|
924
701
|
text-overflow: ellipsis;
|
|
925
|
-
|
|
926
702
|
white-space: nowrap;
|
|
927
|
-
|
|
928
703
|
}
|
|
929
704
|
|
|
930
705
|
.rs-select__tag-remove {
|
|
931
|
-
|
|
932
706
|
display: inline-flex;
|
|
933
|
-
|
|
934
707
|
align-items: center;
|
|
935
|
-
|
|
936
708
|
justify-content: center;
|
|
937
|
-
|
|
938
709
|
width: 1rem;
|
|
939
|
-
|
|
940
710
|
height: 1rem;
|
|
941
|
-
|
|
942
711
|
padding: 0;
|
|
943
|
-
|
|
944
712
|
border: none;
|
|
945
|
-
|
|
946
713
|
border-radius: var(--rs-radius-xs);
|
|
947
|
-
|
|
948
714
|
background: transparent;
|
|
949
|
-
|
|
950
715
|
color: var(--rs-muted);
|
|
951
|
-
|
|
952
716
|
cursor: pointer;
|
|
953
|
-
|
|
954
717
|
transition:
|
|
955
|
-
|
|
956
718
|
color var(--rs-transition-fast),
|
|
957
|
-
|
|
958
719
|
background var(--rs-transition-fast);
|
|
959
|
-
|
|
960
720
|
}
|
|
961
721
|
|
|
962
722
|
.rs-select__tag-remove:hover {
|
|
963
|
-
|
|
964
723
|
color: var(--rs-on-primary-container);
|
|
965
|
-
|
|
966
724
|
background: color-mix(in srgb, var(--rs-primary) 16%, transparent);
|
|
967
|
-
|
|
968
725
|
}
|
|
969
726
|
|
|
970
727
|
.rs-select__actions {
|
|
971
|
-
|
|
972
728
|
display: inline-flex;
|
|
973
|
-
|
|
974
729
|
align-items: center;
|
|
975
|
-
|
|
976
730
|
gap: var(--rs-space-xs);
|
|
977
|
-
|
|
978
731
|
flex-shrink: 0;
|
|
979
|
-
|
|
980
732
|
}
|
|
981
733
|
|
|
982
734
|
.rs-select__clear {
|
|
983
|
-
|
|
984
735
|
display: inline-flex;
|
|
985
|
-
|
|
986
736
|
align-items: center;
|
|
987
|
-
|
|
988
737
|
justify-content: center;
|
|
989
|
-
|
|
990
738
|
width: 1.25rem;
|
|
991
|
-
|
|
992
739
|
height: 1.25rem;
|
|
993
|
-
|
|
994
740
|
padding: 0;
|
|
995
|
-
|
|
996
741
|
border: none;
|
|
997
|
-
|
|
998
742
|
border-radius: var(--rs-radius-xs);
|
|
999
|
-
|
|
1000
743
|
background: transparent;
|
|
1001
|
-
|
|
1002
744
|
color: var(--rs-muted);
|
|
1003
|
-
|
|
1004
745
|
cursor: pointer;
|
|
1005
|
-
|
|
1006
746
|
transition:
|
|
1007
|
-
|
|
1008
747
|
color var(--rs-transition-fast),
|
|
1009
|
-
|
|
1010
748
|
background var(--rs-transition-fast);
|
|
1011
|
-
|
|
1012
749
|
}
|
|
1013
750
|
|
|
1014
751
|
.rs-select__clear:hover {
|
|
1015
|
-
|
|
1016
752
|
color: var(--rs-text);
|
|
1017
|
-
|
|
1018
753
|
background: var(--rs-item-hover);
|
|
754
|
+
}
|
|
1019
755
|
|
|
756
|
+
.rs-select__suffix {
|
|
757
|
+
display: inline-flex;
|
|
758
|
+
align-items: center;
|
|
1020
759
|
}
|
|
1021
760
|
|
|
1022
761
|
.rs-select__icon {
|
|
1023
|
-
|
|
1024
762
|
color: var(--rs-muted);
|
|
1025
|
-
|
|
1026
763
|
flex-shrink: 0;
|
|
1027
|
-
|
|
1028
764
|
transition: transform var(--rs-transition-fast);
|
|
1029
|
-
|
|
1030
765
|
}
|
|
1031
766
|
|
|
1032
767
|
.rs-select__trigger[data-state='open'] .rs-select__icon {
|
|
1033
|
-
|
|
1034
768
|
transform: rotate(180deg);
|
|
1035
|
-
|
|
1036
769
|
}
|
|
1037
770
|
|
|
1038
771
|
.rs-select__item--create .rs-select__item-label {
|
|
1039
772
|
color: var(--rs-primary);
|
|
1040
|
-
font-weight:
|
|
773
|
+
font-weight: var(--rs-font-weight-medium);
|
|
1041
774
|
}
|
|
1042
|
-
|
|
1043
775
|
</style>
|
|
1044
|
-
|
|
1045
|
-
|