niuma-ui 1.2.6 → 1.2.9
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 +22 -0
- package/dist/components/RsAutoComplete.d.ts +39 -0
- package/dist/components/RsAutoComplete.impl.js +306 -0
- package/dist/components/RsAutoComplete.js +5 -0
- package/dist/components/RsCascader.css +81 -0
- package/dist/components/RsCascader.d.ts +34 -0
- package/dist/components/RsCascader.impl.js +138 -0
- package/dist/components/RsCascader.js +8 -0
- package/dist/components/RsCodeEditor.css +38 -38
- package/dist/components/RsCodeEditor.impl.js +15 -4
- package/dist/components/RsCodeEditor.js +1 -1
- package/dist/components/RsMentions-1.css +29 -0
- package/dist/components/RsMentions.css +19 -0
- package/dist/components/RsMentions.d.ts +32 -0
- package/dist/components/RsMentions.impl.js +242 -0
- package/dist/components/RsMentions.js +10 -0
- package/dist/components/RsSelect.css +51 -36
- package/dist/components/RsSelect.d.ts +27 -7
- package/dist/components/RsSelect.impl.js +145 -30
- package/dist/components/RsSelect.js +1 -1
- package/dist/components/RsTabs.d.ts +1 -1
- package/dist/components/RsToaster.d.ts +1 -1
- package/dist/components/RsTree.d.ts +4 -4
- package/dist/components/RsTree.impl.js +1 -1
- package/dist/components/RsTreeSelect.css +60 -0
- package/dist/components/RsTreeSelect.d.ts +33 -0
- package/dist/components/RsTreeSelect.impl.js +145 -0
- package/dist/components/RsTreeSelect.js +8 -0
- package/dist/components/cascader-utils.d.ts +16 -0
- package/dist/components/cascader-utils.js +39 -0
- package/dist/components/mentions-utils.d.ts +46 -0
- package/dist/components/mentions-utils.js +128 -0
- package/dist/components/overlay-utils.d.ts +31 -0
- package/dist/components/overlay-utils.js +29 -1
- package/dist/components/select-utils.d.ts +15 -0
- package/dist/components/select-utils.js +37 -1
- package/dist/components/table/RsTableCellEditor.impl.js +7 -1
- package/dist/components/use-rs-select.d.ts +5 -2
- package/dist/components/use-rs-select.js +31 -19
- package/dist/composables/useRsTableShell.js +1 -1
- package/dist/index.d.ts +9 -3
- package/dist/index.js +6 -0
- package/dist/locale/messages.js +6 -0
- package/dist/styles.css +160 -0
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
.rs-code-editor[data-v-
|
|
2
|
+
.rs-code-editor[data-v-edadd50f] {
|
|
3
3
|
display: flex;
|
|
4
4
|
flex-direction: column;
|
|
5
5
|
overflow: hidden;
|
|
@@ -8,10 +8,10 @@
|
|
|
8
8
|
background: var(--rs-input-bg);
|
|
9
9
|
color: var(--rs-text);
|
|
10
10
|
}
|
|
11
|
-
.rs-code-editor--square[data-v-
|
|
11
|
+
.rs-code-editor--square[data-v-edadd50f] {
|
|
12
12
|
border-radius: 0;
|
|
13
13
|
}
|
|
14
|
-
.rs-code-editor--embedded[data-v-
|
|
14
|
+
.rs-code-editor--embedded[data-v-edadd50f] {
|
|
15
15
|
border: 0;
|
|
16
16
|
border-radius: 0;
|
|
17
17
|
background: transparent;
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
min-height: 0;
|
|
20
20
|
width: 100%;
|
|
21
21
|
}
|
|
22
|
-
.rs-code-editor__toolbar[data-v-
|
|
22
|
+
.rs-code-editor__toolbar[data-v-edadd50f] {
|
|
23
23
|
display: flex;
|
|
24
24
|
align-items: center;
|
|
25
25
|
justify-content: space-between;
|
|
@@ -28,23 +28,23 @@
|
|
|
28
28
|
color: var(--rs-muted);
|
|
29
29
|
font-size: var(--rs-font-size-xs);
|
|
30
30
|
}
|
|
31
|
-
.rs-code-editor__body[data-v-
|
|
31
|
+
.rs-code-editor__body[data-v-edadd50f] {
|
|
32
32
|
position: relative;
|
|
33
33
|
flex: 1;
|
|
34
34
|
min-height: 0;
|
|
35
35
|
display: flex;
|
|
36
36
|
flex-direction: column;
|
|
37
37
|
}
|
|
38
|
-
.rs-code-editor__surface[data-v-
|
|
38
|
+
.rs-code-editor__surface[data-v-edadd50f] {
|
|
39
39
|
flex: 1;
|
|
40
40
|
min-height: 0;
|
|
41
41
|
overflow: hidden;
|
|
42
42
|
}
|
|
43
|
-
.rs-code-editor--embedded .rs-code-editor__body[data-v-
|
|
44
|
-
.rs-code-editor--embedded .rs-code-editor__surface[data-v-
|
|
43
|
+
.rs-code-editor--embedded .rs-code-editor__body[data-v-edadd50f],
|
|
44
|
+
.rs-code-editor--embedded .rs-code-editor__surface[data-v-edadd50f] {
|
|
45
45
|
height: 100%;
|
|
46
46
|
}
|
|
47
|
-
.rs-code-editor__inline-edit[data-v-
|
|
47
|
+
.rs-code-editor__inline-edit[data-v-edadd50f] {
|
|
48
48
|
position: absolute;
|
|
49
49
|
left: 50%;
|
|
50
50
|
top: 12%;
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
background: var(--rs-surface-elevated);
|
|
58
58
|
box-shadow: 0 8px 28px rgba(0, 0, 0, 0.14);
|
|
59
59
|
}
|
|
60
|
-
.rs-code-editor__inline-edit-head[data-v-
|
|
60
|
+
.rs-code-editor__inline-edit-head[data-v-edadd50f] {
|
|
61
61
|
display: flex;
|
|
62
62
|
align-items: center;
|
|
63
63
|
justify-content: space-between;
|
|
@@ -66,14 +66,14 @@
|
|
|
66
66
|
font-weight: var(--rs-font-weight-semibold);
|
|
67
67
|
color: var(--rs-foreground);
|
|
68
68
|
}
|
|
69
|
-
.rs-code-editor__inline-edit-head kbd[data-v-
|
|
69
|
+
.rs-code-editor__inline-edit-head kbd[data-v-edadd50f] {
|
|
70
70
|
padding: 0.1rem 0.35rem;
|
|
71
71
|
border-radius: 4px;
|
|
72
72
|
border: 1px solid var(--rs-border-subtle);
|
|
73
73
|
font-size: var(--rs-font-size-xs);
|
|
74
74
|
color: var(--rs-muted);
|
|
75
75
|
}
|
|
76
|
-
.rs-code-editor__inline-preview[data-v-
|
|
76
|
+
.rs-code-editor__inline-preview[data-v-edadd50f] {
|
|
77
77
|
margin: 0 0 0.5rem;
|
|
78
78
|
padding: 0.35rem 0.5rem;
|
|
79
79
|
border-radius: 4px;
|
|
@@ -86,7 +86,7 @@
|
|
|
86
86
|
max-height: 4.5rem;
|
|
87
87
|
overflow: hidden;
|
|
88
88
|
}
|
|
89
|
-
.rs-code-editor__inline-input[data-v-
|
|
89
|
+
.rs-code-editor__inline-input[data-v-edadd50f] {
|
|
90
90
|
width: 100%;
|
|
91
91
|
box-sizing: border-box;
|
|
92
92
|
margin-bottom: 0.5rem;
|
|
@@ -97,21 +97,21 @@
|
|
|
97
97
|
color: var(--rs-foreground);
|
|
98
98
|
font-size: var(--rs-font-size-sm);
|
|
99
99
|
}
|
|
100
|
-
.rs-code-editor__inline-input[data-v-
|
|
100
|
+
.rs-code-editor__inline-input[data-v-edadd50f]:focus {
|
|
101
101
|
outline: 2px solid color-mix(in srgb, var(--rs-primary) 35%, transparent);
|
|
102
102
|
outline-offset: 1px;
|
|
103
103
|
}
|
|
104
|
-
.rs-code-editor__inline-error[data-v-
|
|
104
|
+
.rs-code-editor__inline-error[data-v-edadd50f] {
|
|
105
105
|
margin: -0.25rem 0 0.5rem;
|
|
106
106
|
font-size: var(--rs-font-size-xs);
|
|
107
107
|
color: var(--rs-danger);
|
|
108
108
|
}
|
|
109
|
-
.rs-code-editor__inline-actions[data-v-
|
|
109
|
+
.rs-code-editor__inline-actions[data-v-edadd50f] {
|
|
110
110
|
display: flex;
|
|
111
111
|
justify-content: flex-end;
|
|
112
112
|
gap: 0.35rem;
|
|
113
113
|
}
|
|
114
|
-
.rs-code-editor__inline-btn[data-v-
|
|
114
|
+
.rs-code-editor__inline-btn[data-v-edadd50f] {
|
|
115
115
|
padding: 0.3rem 0.65rem;
|
|
116
116
|
border: 1px solid var(--rs-border);
|
|
117
117
|
border-radius: var(--rs-radius-sm, 4px);
|
|
@@ -120,69 +120,69 @@
|
|
|
120
120
|
font-size: var(--rs-font-size-xs);
|
|
121
121
|
cursor: pointer;
|
|
122
122
|
}
|
|
123
|
-
.rs-code-editor__inline-btn--primary[data-v-
|
|
123
|
+
.rs-code-editor__inline-btn--primary[data-v-edadd50f] {
|
|
124
124
|
border-color: var(--rs-primary);
|
|
125
125
|
background: var(--rs-primary);
|
|
126
126
|
color: var(--rs-primary-foreground, #fff);
|
|
127
127
|
}
|
|
128
|
-
.rs-code-editor__inline-btn[data-v-
|
|
128
|
+
.rs-code-editor__inline-btn[data-v-edadd50f]:disabled {
|
|
129
129
|
opacity: 0.55;
|
|
130
130
|
cursor: not-allowed;
|
|
131
131
|
}
|
|
132
|
-
.rs-code-editor__surface--disabled[data-v-
|
|
132
|
+
.rs-code-editor__surface--disabled[data-v-edadd50f] {
|
|
133
133
|
opacity: 0.6;
|
|
134
134
|
pointer-events: none;
|
|
135
135
|
}
|
|
136
|
-
.rs-code-editor__surface[data-v-
|
|
136
|
+
.rs-code-editor__surface[data-v-edadd50f] .cm-editor {
|
|
137
137
|
height: 100%;
|
|
138
138
|
background: var(--rs-surface-elevated) !important;
|
|
139
139
|
}
|
|
140
|
-
.rs-code-editor__surface[data-v-
|
|
140
|
+
.rs-code-editor__surface[data-v-edadd50f] .cm-scroller {
|
|
141
141
|
font-family: var(--rs-code-font-family, var(--rs-font-mono));
|
|
142
142
|
font-size: var(--rs-code-font-size, var(--rs-font-size-sm));
|
|
143
143
|
line-height: var(--rs-code-line-height, var(--rs-line-height-relaxed));
|
|
144
144
|
}
|
|
145
|
-
.rs-code-editor__surface[data-v-
|
|
145
|
+
.rs-code-editor__surface[data-v-edadd50f] .cm-gutters {
|
|
146
146
|
background: color-mix(in srgb, var(--rs-surface-elevated) 85%, var(--rs-border) 15%) !important;
|
|
147
147
|
border-right-color: var(--rs-border-subtle) !important;
|
|
148
148
|
color: var(--rs-muted);
|
|
149
149
|
}
|
|
150
|
-
.rs-code-editor--embedded .rs-code-editor__surface[data-v-
|
|
150
|
+
.rs-code-editor--embedded .rs-code-editor__surface[data-v-edadd50f] .cm-editor {
|
|
151
151
|
height: 100%;
|
|
152
152
|
background: transparent !important;
|
|
153
153
|
}
|
|
154
|
-
.rs-code-editor--no-fold .rs-code-editor__surface[data-v-
|
|
154
|
+
.rs-code-editor--no-fold .rs-code-editor__surface[data-v-edadd50f] .cm-foldGutter {
|
|
155
155
|
display: none !important;
|
|
156
156
|
width: 0 !important;
|
|
157
157
|
min-width: 0 !important;
|
|
158
158
|
}
|
|
159
|
-
.rs-code-editor--gutter-fixed .rs-code-editor__surface[data-v-
|
|
159
|
+
.rs-code-editor--gutter-fixed .rs-code-editor__surface[data-v-edadd50f] .cm-gutters {
|
|
160
160
|
min-width: var(--rs-code-editor-gutter-width);
|
|
161
161
|
}
|
|
162
|
-
.rs-code-editor--gutter-fixed.rs-code-editor--no-fold .rs-code-editor__surface[data-v-
|
|
162
|
+
.rs-code-editor--gutter-fixed.rs-code-editor--no-fold .rs-code-editor__surface[data-v-edadd50f] .cm-lineNumbers {
|
|
163
163
|
min-width: var(--rs-code-editor-gutter-width);
|
|
164
164
|
}
|
|
165
|
-
.rs-code-editor--gutter-fixed.rs-code-editor--no-fold .rs-code-editor__surface[data-v-
|
|
165
|
+
.rs-code-editor--gutter-fixed.rs-code-editor--no-fold .rs-code-editor__surface[data-v-edadd50f] .cm-lineNumbers .cm-gutterElement {
|
|
166
166
|
min-width: calc(var(--rs-code-editor-gutter-width) - 8px);
|
|
167
167
|
}
|
|
168
|
-
.rs-code-editor__surface[data-v-
|
|
168
|
+
.rs-code-editor__surface[data-v-edadd50f] .cm-content {
|
|
169
169
|
color: var(--rs-foreground);
|
|
170
170
|
}
|
|
171
|
-
.rs-code-editor__surface[data-v-
|
|
171
|
+
.rs-code-editor__surface[data-v-edadd50f] .cm-lintRange-error {
|
|
172
172
|
background: color-mix(in srgb, var(--rs-danger) 12%, transparent);
|
|
173
173
|
}
|
|
174
|
-
.rs-code-editor__surface[data-v-
|
|
174
|
+
.rs-code-editor__surface[data-v-edadd50f] .cm-lintRange-warning {
|
|
175
175
|
background: color-mix(in srgb, var(--rs-warning) 12%, transparent);
|
|
176
176
|
}
|
|
177
|
-
.rs-code-editor__surface[data-v-
|
|
177
|
+
.rs-code-editor__surface[data-v-edadd50f] .cm-lintRange-info {
|
|
178
178
|
background: color-mix(in srgb, var(--rs-info) 10%, transparent);
|
|
179
179
|
}
|
|
180
|
-
.rs-code-editor__surface[data-v-
|
|
180
|
+
.rs-code-editor__surface[data-v-edadd50f] .rs-code-editor__ghost {
|
|
181
181
|
color: var(--rs-muted);
|
|
182
182
|
opacity: 0.55;
|
|
183
183
|
pointer-events: none;
|
|
184
184
|
}
|
|
185
|
-
.rs-code-editor__surface[data-v-
|
|
185
|
+
.rs-code-editor__surface[data-v-edadd50f] .rs-code-editor__hover {
|
|
186
186
|
max-width: 28rem;
|
|
187
187
|
padding: 0.45rem 0.65rem;
|
|
188
188
|
border-radius: var(--rs-radius-sm, 4px);
|
|
@@ -195,7 +195,7 @@
|
|
|
195
195
|
white-space: pre-wrap;
|
|
196
196
|
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
|
|
197
197
|
}
|
|
198
|
-
.rs-code-editor__diagnostics[data-v-
|
|
198
|
+
.rs-code-editor__diagnostics[data-v-edadd50f] {
|
|
199
199
|
margin: 0;
|
|
200
200
|
padding: var(--rs-space-sm) var(--rs-space-md);
|
|
201
201
|
border-top: 1px solid var(--rs-border-subtle);
|
|
@@ -203,12 +203,12 @@
|
|
|
203
203
|
font-size: var(--rs-font-size-xs);
|
|
204
204
|
list-style: none;
|
|
205
205
|
}
|
|
206
|
-
.rs-code-editor__diagnostic--error[data-v-
|
|
206
|
+
.rs-code-editor__diagnostic--error[data-v-edadd50f] {
|
|
207
207
|
color: var(--rs-danger);
|
|
208
208
|
}
|
|
209
|
-
.rs-code-editor__diagnostic--warning[data-v-
|
|
209
|
+
.rs-code-editor__diagnostic--warning[data-v-edadd50f] {
|
|
210
210
|
color: var(--rs-warning);
|
|
211
211
|
}
|
|
212
|
-
.rs-code-editor__diagnostic--info[data-v-
|
|
212
|
+
.rs-code-editor__diagnostic--info[data-v-edadd50f] {
|
|
213
213
|
color: var(--rs-info);
|
|
214
214
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { codeEditorLanguageLabel, resolveCodeEditorLanguage, resolveCodeEditorSize, resolveCodeEditorTheme } from "./code-editor-utils.js";
|
|
1
|
+
import { codeEditorLanguageLabel, readDocumentTheme, resolveCodeEditorLanguage, resolveCodeEditorSize, resolveCodeEditorTheme } from "./code-editor-utils.js";
|
|
2
2
|
import { isCodeMirrorLightTheme, resolveCodeMirrorLanguage } from "./code-mirror-lang.js";
|
|
3
3
|
import { diagnosticExtensions, setEditorDiagnostics } from "./code-mirror-diagnostics.js";
|
|
4
4
|
import { codeMirrorIntelExtensions, goToPosition } from "./code-mirror-intel.js";
|
|
@@ -89,10 +89,12 @@ var RsCodeEditor_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ def
|
|
|
89
89
|
});
|
|
90
90
|
const resolvedLanguage = computed(() => resolveCodeEditorLanguage(props.language));
|
|
91
91
|
const resolvedLanguageLabel = computed(() => codeEditorLanguageLabel(props.language));
|
|
92
|
-
const
|
|
92
|
+
const documentTheme = ref(readDocumentTheme());
|
|
93
|
+
const resolvedTheme = computed(() => props.theme === "auto" ? documentTheme.value : resolveCodeEditorTheme(props.theme));
|
|
93
94
|
const editorEl = ref(null);
|
|
94
95
|
const view = shallowRef(null);
|
|
95
96
|
const editableCompartment = new Compartment();
|
|
97
|
+
const themeCompartment = new Compartment();
|
|
96
98
|
let themeObserver = null;
|
|
97
99
|
let unmounted = false;
|
|
98
100
|
let syncingFromModel = false;
|
|
@@ -157,6 +159,15 @@ var RsCodeEditor_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ def
|
|
|
157
159
|
ghostTimer = null;
|
|
158
160
|
}
|
|
159
161
|
}
|
|
162
|
+
function codeMirrorThemeExts() {
|
|
163
|
+
return isCodeMirrorLightTheme() ? [] : [oneDark];
|
|
164
|
+
}
|
|
165
|
+
function applyDocumentTheme() {
|
|
166
|
+
documentTheme.value = readDocumentTheme();
|
|
167
|
+
if (!view.value) return;
|
|
168
|
+
view.value.dispatch({ effects: themeCompartment.reconfigure(codeMirrorThemeExts()) });
|
|
169
|
+
view.value.requestMeasure();
|
|
170
|
+
}
|
|
160
171
|
async function initEditor() {
|
|
161
172
|
if (!editorEl.value || unmounted) return;
|
|
162
173
|
const seq = ++initSeq;
|
|
@@ -185,7 +196,7 @@ var RsCodeEditor_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ def
|
|
|
185
196
|
...codeMirrorCompletionExtensions(() => ({ completionRequest: props.completionRequest })),
|
|
186
197
|
...codeMirrorGhostExtensions(() => ({ completionRequest: props.completionRequest }), scheduleGhostCompletion, cancelGhostCompletionSchedule),
|
|
187
198
|
...props.inlineEditRequest ? [codeMirrorInlineEditExtension(onInlineEditTrigger)] : [],
|
|
188
|
-
|
|
199
|
+
themeCompartment.of(codeMirrorThemeExts()),
|
|
189
200
|
EditorView.updateListener.of((update) => {
|
|
190
201
|
if (!update.docChanged || syncingFromModel) return;
|
|
191
202
|
const next = update.state.doc.toString();
|
|
@@ -204,7 +215,7 @@ var RsCodeEditor_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ def
|
|
|
204
215
|
unmounted = false;
|
|
205
216
|
initEditor();
|
|
206
217
|
themeObserver = new MutationObserver(() => {
|
|
207
|
-
|
|
218
|
+
applyDocumentTheme();
|
|
208
219
|
});
|
|
209
220
|
themeObserver.observe(document.documentElement, {
|
|
210
221
|
attributes: true,
|
|
@@ -3,6 +3,6 @@ import _plugin_vue_export_helper_default from "../_virtual/_plugin-vue_export-he
|
|
|
3
3
|
import RsCodeEditor_vue_vue_type_script_setup_true_lang_default from "./RsCodeEditor.impl.js";
|
|
4
4
|
|
|
5
5
|
//#region src/components/RsCodeEditor.vue
|
|
6
|
-
var RsCodeEditor_default = /*#__PURE__*/ _plugin_vue_export_helper_default(RsCodeEditor_vue_vue_type_script_setup_true_lang_default, [["__scopeId", "data-v-
|
|
6
|
+
var RsCodeEditor_default = /*#__PURE__*/ _plugin_vue_export_helper_default(RsCodeEditor_vue_vue_type_script_setup_true_lang_default, [["__scopeId", "data-v-edadd50f"]]);
|
|
7
7
|
//#endregion
|
|
8
8
|
export { RsCodeEditor_default as default };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
|
|
2
|
+
.rs-mentions__list {
|
|
3
|
+
position: fixed;
|
|
4
|
+
z-index: var(--rs-z-dropdown, 80);
|
|
5
|
+
box-sizing: border-box;
|
|
6
|
+
min-width: 10rem;
|
|
7
|
+
max-height: 12rem;
|
|
8
|
+
margin: 0;
|
|
9
|
+
padding: var(--rs-space-xs);
|
|
10
|
+
overflow: auto;
|
|
11
|
+
border: 1px solid var(--rs-border);
|
|
12
|
+
border-radius: var(--rs-radius-sm);
|
|
13
|
+
background: var(--rs-surface);
|
|
14
|
+
box-shadow: var(--rs-shadow-md);
|
|
15
|
+
list-style: none;
|
|
16
|
+
}
|
|
17
|
+
.rs-mentions__item {
|
|
18
|
+
padding: var(--rs-space-xs) var(--rs-space-sm);
|
|
19
|
+
border-radius: var(--rs-radius-xs);
|
|
20
|
+
cursor: pointer;
|
|
21
|
+
}
|
|
22
|
+
.rs-mentions__item--active,
|
|
23
|
+
.rs-mentions__item:hover:not(.rs-mentions__item--disabled) {
|
|
24
|
+
background: var(--rs-surface-hover);
|
|
25
|
+
}
|
|
26
|
+
.rs-mentions__item--disabled {
|
|
27
|
+
opacity: 0.4;
|
|
28
|
+
cursor: not-allowed;
|
|
29
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
|
|
2
|
+
.rs-mentions[data-v-0ab8420e] {
|
|
3
|
+
position: relative;
|
|
4
|
+
width: 100%;
|
|
5
|
+
}
|
|
6
|
+
.rs-mentions__input[data-v-0ab8420e] {
|
|
7
|
+
box-sizing: border-box;
|
|
8
|
+
width: 100%;
|
|
9
|
+
min-height: calc(var(--rs-control-height-md) * 2);
|
|
10
|
+
padding: var(--rs-space-sm) var(--rs-space-md);
|
|
11
|
+
border: 1px solid var(--rs-input-border, var(--rs-border));
|
|
12
|
+
border-radius: var(--rs-radius-sm);
|
|
13
|
+
background: var(--rs-input-bg);
|
|
14
|
+
color: var(--rs-text);
|
|
15
|
+
font-family: inherit;
|
|
16
|
+
font-size: var(--rs-font-size-sm);
|
|
17
|
+
resize: vertical;
|
|
18
|
+
outline: none;
|
|
19
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { RsComponentSize } from '../theme/types';
|
|
2
|
+
import { type RsMentionOption } from './mentions-utils';
|
|
3
|
+
type __VLS_Props = {
|
|
4
|
+
options?: readonly RsMentionOption[];
|
|
5
|
+
prefix?: string | string[];
|
|
6
|
+
split?: string;
|
|
7
|
+
rows?: number;
|
|
8
|
+
placeholder?: string;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
size?: RsComponentSize;
|
|
11
|
+
};
|
|
12
|
+
type __VLS_ModelProps = {
|
|
13
|
+
modelValue?: string;
|
|
14
|
+
};
|
|
15
|
+
type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
|
|
16
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
17
|
+
search: (query: string) => any;
|
|
18
|
+
select: (value: string) => any;
|
|
19
|
+
"update:modelValue": (value: string) => any;
|
|
20
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
21
|
+
onSearch?: ((query: string) => any) | undefined;
|
|
22
|
+
onSelect?: ((value: string) => any) | undefined;
|
|
23
|
+
"onUpdate:modelValue"?: ((value: string) => any) | undefined;
|
|
24
|
+
}>, {
|
|
25
|
+
split: string;
|
|
26
|
+
disabled: boolean;
|
|
27
|
+
options: readonly RsMentionOption[];
|
|
28
|
+
prefix: string | string[];
|
|
29
|
+
rows: number;
|
|
30
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
31
|
+
declare const _default: typeof __VLS_export;
|
|
32
|
+
export default _default;
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
import { useRsI18n } from "../composables/useRsI18n.js";
|
|
2
|
+
import { useResolvedRsComponentSize } from "./resolve-size.js";
|
|
3
|
+
import { applyMention, createTextareaCaretMeter, filterMentionOptions, findActiveMention, placeMentionPopup, resolveMentionPrefixes, stepMentionIndex } from "./mentions-utils.js";
|
|
4
|
+
import { Fragment, Teleport, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, defineComponent, mergeModels, nextTick, normalizeClass, normalizeStyle, onMounted, onUnmounted, openBlock, ref, renderList, toDisplayString, unref, useId, useModel, vModelText, watch, withDirectives, withModifiers } from "vue";
|
|
5
|
+
//#region src/components/RsMentions.vue?vue&type=script&setup=true&lang.ts
|
|
6
|
+
var _hoisted_1 = [
|
|
7
|
+
"rows",
|
|
8
|
+
"placeholder",
|
|
9
|
+
"disabled",
|
|
10
|
+
"aria-expanded",
|
|
11
|
+
"aria-controls",
|
|
12
|
+
"aria-activedescendant"
|
|
13
|
+
];
|
|
14
|
+
var _hoisted_2 = ["id", "aria-label"];
|
|
15
|
+
var _hoisted_3 = [
|
|
16
|
+
"id",
|
|
17
|
+
"aria-selected",
|
|
18
|
+
"aria-disabled",
|
|
19
|
+
"onMousedown"
|
|
20
|
+
];
|
|
21
|
+
var RsMentions_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineComponent({
|
|
22
|
+
name: "RsMentions",
|
|
23
|
+
__name: "RsMentions",
|
|
24
|
+
props: /*@__PURE__*/ mergeModels({
|
|
25
|
+
options: { default: () => [] },
|
|
26
|
+
prefix: { default: "@" },
|
|
27
|
+
split: { default: " " },
|
|
28
|
+
rows: { default: 3 },
|
|
29
|
+
placeholder: {},
|
|
30
|
+
disabled: {
|
|
31
|
+
type: Boolean,
|
|
32
|
+
default: false
|
|
33
|
+
},
|
|
34
|
+
size: {}
|
|
35
|
+
}, {
|
|
36
|
+
"modelValue": { default: "" },
|
|
37
|
+
"modelModifiers": {}
|
|
38
|
+
}),
|
|
39
|
+
emits: /*@__PURE__*/ mergeModels(["select", "search"], ["update:modelValue"]),
|
|
40
|
+
setup(__props, { emit: __emit }) {
|
|
41
|
+
const model = useModel(__props, "modelValue");
|
|
42
|
+
const props = __props;
|
|
43
|
+
const emit = __emit;
|
|
44
|
+
const { t } = useRsI18n();
|
|
45
|
+
const resolvedSize = useResolvedRsComponentSize(() => props.size);
|
|
46
|
+
const listId = useId();
|
|
47
|
+
const areaRef = ref(null);
|
|
48
|
+
const listRef = ref(null);
|
|
49
|
+
const cursor = ref(0);
|
|
50
|
+
const popup = ref({
|
|
51
|
+
top: 0,
|
|
52
|
+
left: 0,
|
|
53
|
+
placement: "bottom"
|
|
54
|
+
});
|
|
55
|
+
const highlight = ref(0);
|
|
56
|
+
const dismissed = ref(false);
|
|
57
|
+
const lastSearch = ref(null);
|
|
58
|
+
const prefixes = computed(() => resolveMentionPrefixes(props.prefix));
|
|
59
|
+
const meter = createTextareaCaretMeter();
|
|
60
|
+
const active = computed(() => dismissed.value ? null : findActiveMention(model.value, cursor.value, prefixes.value, props.split));
|
|
61
|
+
const suggestions = computed(() => active.value ? filterMentionOptions(props.options, active.value.query) : []);
|
|
62
|
+
const open = computed(() => Boolean(active.value && suggestions.value.length));
|
|
63
|
+
const activeOption = computed(() => suggestions.value[highlight.value]);
|
|
64
|
+
const activeOptionId = computed(() => open.value && activeOption.value ? `${listId}-${activeOption.value.value}` : void 0);
|
|
65
|
+
function viewportCaret() {
|
|
66
|
+
const el = areaRef.value;
|
|
67
|
+
const mention = active.value;
|
|
68
|
+
if (!el || !mention) return null;
|
|
69
|
+
const local = meter.measure(el, mention.start);
|
|
70
|
+
const box = el.getBoundingClientRect();
|
|
71
|
+
return {
|
|
72
|
+
top: box.top + local.top,
|
|
73
|
+
left: box.left + local.left,
|
|
74
|
+
height: local.height
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
function placePopup() {
|
|
78
|
+
const caret = viewportCaret();
|
|
79
|
+
if (!caret) return;
|
|
80
|
+
const list = listRef.value?.getBoundingClientRect();
|
|
81
|
+
popup.value = placeMentionPopup(caret, {
|
|
82
|
+
width: list?.width || 160,
|
|
83
|
+
height: list?.height || Math.min(192, suggestions.value.length * 32)
|
|
84
|
+
}, {
|
|
85
|
+
width: window.innerWidth,
|
|
86
|
+
height: window.innerHeight
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
let frame = 0;
|
|
90
|
+
function requestPlace() {
|
|
91
|
+
if (frame) return;
|
|
92
|
+
frame = window.requestAnimationFrame(() => {
|
|
93
|
+
frame = 0;
|
|
94
|
+
placePopup();
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
function syncCursor(emitSearch, keepDismissed = false) {
|
|
98
|
+
const el = areaRef.value;
|
|
99
|
+
cursor.value = el?.selectionStart ?? model.value.length;
|
|
100
|
+
if (!keepDismissed) dismissed.value = false;
|
|
101
|
+
const mention = findActiveMention(model.value, cursor.value, prefixes.value, props.split);
|
|
102
|
+
if (!mention) {
|
|
103
|
+
lastSearch.value = null;
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
if (emitSearch && mention.query !== lastSearch.value) {
|
|
107
|
+
lastSearch.value = mention.query;
|
|
108
|
+
emit("search", mention.query);
|
|
109
|
+
}
|
|
110
|
+
requestPlace();
|
|
111
|
+
}
|
|
112
|
+
function pick(option) {
|
|
113
|
+
if (!active.value || option.disabled) return;
|
|
114
|
+
const next = applyMention(model.value, active.value, option.value, props.split);
|
|
115
|
+
model.value = next.text;
|
|
116
|
+
emit("select", option.value);
|
|
117
|
+
dismissed.value = true;
|
|
118
|
+
nextTick(() => {
|
|
119
|
+
const el = areaRef.value;
|
|
120
|
+
if (!el) return;
|
|
121
|
+
el.focus();
|
|
122
|
+
el.setSelectionRange(next.cursor, next.cursor);
|
|
123
|
+
cursor.value = next.cursor;
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
function onKeydown(event) {
|
|
127
|
+
if (!open.value) return;
|
|
128
|
+
if (event.key === "ArrowDown") {
|
|
129
|
+
event.preventDefault();
|
|
130
|
+
highlight.value = stepMentionIndex(suggestions.value, highlight.value, 1);
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
if (event.key === "ArrowUp") {
|
|
134
|
+
event.preventDefault();
|
|
135
|
+
highlight.value = stepMentionIndex(suggestions.value, highlight.value, -1);
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
if (event.key === "Enter") {
|
|
139
|
+
event.preventDefault();
|
|
140
|
+
if (activeOption.value) pick(activeOption.value);
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
if (event.key === "Escape") {
|
|
144
|
+
event.preventDefault();
|
|
145
|
+
dismissed.value = true;
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
if (event.key === "Home") {
|
|
149
|
+
event.preventDefault();
|
|
150
|
+
highlight.value = stepMentionIndex(suggestions.value, -1, 1);
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
if (event.key === "End") {
|
|
154
|
+
event.preventDefault();
|
|
155
|
+
highlight.value = stepMentionIndex(suggestions.value, suggestions.value.length, -1);
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
if (event.key === "Tab" && activeOption.value) {
|
|
159
|
+
event.preventDefault();
|
|
160
|
+
pick(activeOption.value);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
watch(suggestions, (list) => {
|
|
164
|
+
highlight.value = list.findIndex((item) => !item.disabled);
|
|
165
|
+
if (highlight.value < 0) highlight.value = 0;
|
|
166
|
+
requestPlace();
|
|
167
|
+
});
|
|
168
|
+
watch(open, (isOpen) => {
|
|
169
|
+
if (isOpen) nextTick(() => requestPlace());
|
|
170
|
+
});
|
|
171
|
+
function onWindowChange() {
|
|
172
|
+
if (open.value) requestPlace();
|
|
173
|
+
}
|
|
174
|
+
onMounted(() => {
|
|
175
|
+
window.addEventListener("resize", onWindowChange);
|
|
176
|
+
window.addEventListener("scroll", onWindowChange, true);
|
|
177
|
+
});
|
|
178
|
+
onUnmounted(() => {
|
|
179
|
+
if (frame) window.cancelAnimationFrame(frame);
|
|
180
|
+
meter.dispose();
|
|
181
|
+
window.removeEventListener("resize", onWindowChange);
|
|
182
|
+
window.removeEventListener("scroll", onWindowChange, true);
|
|
183
|
+
});
|
|
184
|
+
return (_ctx, _cache) => {
|
|
185
|
+
return openBlock(), createElementBlock("div", { class: normalizeClass(["rs-mentions", `rs-mentions--${unref(resolvedSize)}`]) }, [withDirectives(createElementVNode("textarea", {
|
|
186
|
+
ref_key: "areaRef",
|
|
187
|
+
ref: areaRef,
|
|
188
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => model.value = $event),
|
|
189
|
+
class: "rs-mentions__input",
|
|
190
|
+
rows: __props.rows,
|
|
191
|
+
placeholder: __props.placeholder ?? unref(t)("mentions.placeholder"),
|
|
192
|
+
disabled: __props.disabled,
|
|
193
|
+
role: "combobox",
|
|
194
|
+
"aria-autocomplete": "list",
|
|
195
|
+
"aria-haspopup": "listbox",
|
|
196
|
+
"aria-expanded": open.value ? "true" : "false",
|
|
197
|
+
"aria-controls": open.value ? unref(listId) : void 0,
|
|
198
|
+
"aria-activedescendant": activeOptionId.value,
|
|
199
|
+
onKeydown,
|
|
200
|
+
onKeyup: _cache[1] || (_cache[1] = ($event) => syncCursor(true, [
|
|
201
|
+
"Escape",
|
|
202
|
+
"Enter",
|
|
203
|
+
"Tab",
|
|
204
|
+
"ArrowUp",
|
|
205
|
+
"ArrowDown",
|
|
206
|
+
"Home",
|
|
207
|
+
"End"
|
|
208
|
+
].includes($event.key))),
|
|
209
|
+
onClick: _cache[2] || (_cache[2] = ($event) => syncCursor(true)),
|
|
210
|
+
onInput: _cache[3] || (_cache[3] = ($event) => syncCursor(true)),
|
|
211
|
+
onScroll: _cache[4] || (_cache[4] = ($event) => syncCursor(false, true))
|
|
212
|
+
}, null, 40, _hoisted_1), [[vModelText, model.value]]), (openBlock(), createBlock(Teleport, { to: "body" }, [open.value ? (openBlock(), createElementBlock("ul", {
|
|
213
|
+
key: 0,
|
|
214
|
+
id: unref(listId),
|
|
215
|
+
ref_key: "listRef",
|
|
216
|
+
ref: listRef,
|
|
217
|
+
class: "rs-mentions__list",
|
|
218
|
+
role: "listbox",
|
|
219
|
+
"aria-label": unref(t)("mentions.suggestions"),
|
|
220
|
+
style: normalizeStyle({
|
|
221
|
+
top: `${popup.value.top}px`,
|
|
222
|
+
left: `${popup.value.left}px`
|
|
223
|
+
})
|
|
224
|
+
}, [(openBlock(true), createElementBlock(Fragment, null, renderList(suggestions.value, (opt, index) => {
|
|
225
|
+
return openBlock(), createElementBlock("li", {
|
|
226
|
+
id: `${unref(listId)}-${opt.value}`,
|
|
227
|
+
key: opt.value,
|
|
228
|
+
role: "option",
|
|
229
|
+
class: normalizeClass(["rs-mentions__item", {
|
|
230
|
+
"rs-mentions__item--disabled": opt.disabled,
|
|
231
|
+
"rs-mentions__item--active": index === highlight.value
|
|
232
|
+
}]),
|
|
233
|
+
"aria-selected": index === highlight.value,
|
|
234
|
+
"aria-disabled": opt.disabled ? "true" : void 0,
|
|
235
|
+
onMousedown: withModifiers(($event) => pick(opt), ["prevent"])
|
|
236
|
+
}, toDisplayString(opt.label), 43, _hoisted_3);
|
|
237
|
+
}), 128))], 12, _hoisted_2)) : createCommentVNode("", true)]))], 2);
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
});
|
|
241
|
+
//#endregion
|
|
242
|
+
export { RsMentions_vue_vue_type_script_setup_true_lang_default as default };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import './RsMentions.css'
|
|
2
|
+
import './RsMentions-1.css'
|
|
3
|
+
import _plugin_vue_export_helper_default from "../_virtual/_plugin-vue_export-helper.js";
|
|
4
|
+
import RsMentions_vue_vue_type_script_setup_true_lang_default from "./RsMentions.impl.js";
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
//#region src/components/RsMentions.vue
|
|
8
|
+
var RsMentions_default = /*#__PURE__*/ _plugin_vue_export_helper_default(RsMentions_vue_vue_type_script_setup_true_lang_default, [["__scopeId", "data-v-0ab8420e"]]);
|
|
9
|
+
//#endregion
|
|
10
|
+
export { RsMentions_default as default };
|