@ticatec/uniface-element 0.3.7 → 0.3.8
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/dist/input-options-select/InputOptionsSelect.svelte +17 -9
- package/dist/input-options-select/InputOptionsSelect.svelte.d.ts +6 -4
- package/dist/input-options-select/index.d.ts +2 -0
- package/dist/input-options-select/types.d.ts +1 -0
- package/dist/input-options-select/types.js +1 -0
- package/dist/list-box/ListBox.svelte +1 -4
- package/dist/list-box/ListBox.svelte.d.ts +1 -0
- package/dist/number-editor/NumberEditor.svelte +2 -1
- package/dist/types.d.ts +6 -0
- package/package.json +1 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
|
|
3
|
-
import {DisplayMode} from "../
|
|
4
|
-
import type {OnChangeHandler} from "../
|
|
5
|
-
import {tick} from "svelte";
|
|
3
|
+
import {DisplayMode} from "../types";
|
|
4
|
+
import type {OnChangeHandler} from "../types";
|
|
6
5
|
import CommonPicker from "../common/CommonPicker.svelte";
|
|
7
6
|
import loadingGif from "../assets/loading.gif";
|
|
8
|
-
import type {LazyLoader} from "../
|
|
7
|
+
import type {LazyLoader} from "../types";
|
|
8
|
+
import type {RetrieveOptionText} from "../types";
|
|
9
9
|
|
|
10
10
|
export let variant: '' | 'plain' | 'outlined' | 'filled' = '';
|
|
11
11
|
export let disabled: boolean = false;
|
|
@@ -14,7 +14,8 @@
|
|
|
14
14
|
export let text: string = '';
|
|
15
15
|
export let value: any = null;
|
|
16
16
|
export let keyField: string = "code";
|
|
17
|
-
export let textField: string =
|
|
17
|
+
export let textField: string | undefined = undefined;
|
|
18
|
+
export let retrieveText: RetrieveOptionText | undefined = undefined;
|
|
18
19
|
export let displayCode: boolean = false;
|
|
19
20
|
export let menu$height: number = 0;
|
|
20
21
|
export let style: string = '';
|
|
@@ -150,10 +151,14 @@
|
|
|
150
151
|
const handleItemClick = (data: any) => () => {
|
|
151
152
|
isUserTyping = false;
|
|
152
153
|
value = data[keyField];
|
|
153
|
-
text = data[textField];
|
|
154
154
|
if (value != oldValue) {
|
|
155
155
|
onchange?.(data);
|
|
156
156
|
}
|
|
157
|
+
if (retrieveText) {
|
|
158
|
+
text = retrieveText(data)
|
|
159
|
+
} else if (textField) {
|
|
160
|
+
text = data[textField]
|
|
161
|
+
}
|
|
157
162
|
editor.focus();
|
|
158
163
|
showPopup = false;
|
|
159
164
|
}
|
|
@@ -194,7 +199,6 @@
|
|
|
194
199
|
const handleBlur = (event: FocusEvent) => {
|
|
195
200
|
setTimeout(() => {
|
|
196
201
|
const focused = scrollElement!=null && scrollElement.contains(document.activeElement);
|
|
197
|
-
console.log('当前组合组件是否聚集', focused, value)
|
|
198
202
|
if (!focused) {
|
|
199
203
|
hasFocus = false;
|
|
200
204
|
if (value == null) {
|
|
@@ -205,6 +209,10 @@
|
|
|
205
209
|
}, 50)
|
|
206
210
|
};
|
|
207
211
|
|
|
212
|
+
const getDisplayText = (item: any) => {
|
|
213
|
+
return retrieveText?.(item) ?? item[textField ?? keyField];
|
|
214
|
+
}
|
|
215
|
+
|
|
208
216
|
const clean = () => {
|
|
209
217
|
value = null;
|
|
210
218
|
text = '';
|
|
@@ -230,7 +238,7 @@
|
|
|
230
238
|
// 如果已选择值,根据焦点状态显示keyField或textField
|
|
231
239
|
let selectedItem = options.find(op => op[keyField] == value);
|
|
232
240
|
if (selectedItem) {
|
|
233
|
-
inputText = hasFocus && displayCode ? selectedItem[keyField] : selectedItem
|
|
241
|
+
inputText = hasFocus && displayCode ? selectedItem[keyField] : getDisplayText(selectedItem);
|
|
234
242
|
} else {
|
|
235
243
|
inputText = hasFocus && displayCode ? value : text;
|
|
236
244
|
}
|
|
@@ -279,7 +287,7 @@
|
|
|
279
287
|
<svelte:component this={itemRender} item={op}/>
|
|
280
288
|
{:else}
|
|
281
289
|
<div style="padding: 6px 8px">
|
|
282
|
-
<span>{op
|
|
290
|
+
<span>{getDisplayText(op)}</span>
|
|
283
291
|
</div>
|
|
284
292
|
{/if}
|
|
285
293
|
</div>
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { DisplayMode } from "../
|
|
2
|
-
import type { OnChangeHandler } from "../
|
|
3
|
-
import type { LazyLoader } from "../
|
|
1
|
+
import { DisplayMode } from "../types";
|
|
2
|
+
import type { OnChangeHandler } from "../types";
|
|
3
|
+
import type { LazyLoader } from "../types";
|
|
4
|
+
import type { RetrieveOptionText } from "../types";
|
|
4
5
|
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
5
6
|
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
6
7
|
$$bindings?: Bindings;
|
|
@@ -22,7 +23,8 @@ declare const InputOptionsSelect: $$__sveltets_2_IsomorphicComponent<{
|
|
|
22
23
|
text?: string;
|
|
23
24
|
value?: any;
|
|
24
25
|
keyField?: string;
|
|
25
|
-
textField?: string;
|
|
26
|
+
textField?: string | undefined;
|
|
27
|
+
retrieveText?: RetrieveOptionText | undefined;
|
|
26
28
|
displayCode?: boolean;
|
|
27
29
|
menu$height?: number;
|
|
28
30
|
style?: string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -28,12 +28,11 @@
|
|
|
28
28
|
export let onSelectChange: OnSelectChange = null as unknown as OnSelectChange;
|
|
29
29
|
export let onItemDblClick: OnItemDblClick = null as unknown as OnItemDblClick;
|
|
30
30
|
export let onItemClick: OnItemClick = null as unknown as OnItemDblClick;
|
|
31
|
-
|
|
32
31
|
export let title: string = null as unknown as string;
|
|
33
32
|
export let round: boolean = false;
|
|
34
33
|
export let footer$style: string | null = null;
|
|
34
|
+
export let filterText: string = '';
|
|
35
35
|
|
|
36
|
-
let filterText: string;
|
|
37
36
|
let hasMore: boolean;
|
|
38
37
|
let isBusy: boolean = false;
|
|
39
38
|
let pageNo: number = 1;
|
|
@@ -146,8 +145,6 @@
|
|
|
146
145
|
|
|
147
146
|
onMount(async () => {
|
|
148
147
|
if (lazyLoader != null) {
|
|
149
|
-
console.log('加载数据...')
|
|
150
|
-
filterText = '';
|
|
151
148
|
await lazyLoad();
|
|
152
149
|
}
|
|
153
150
|
})
|
|
@@ -40,8 +40,9 @@
|
|
|
40
40
|
editor.setFocus();
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
let textValue: string = utils.formatNumber(value, precision);
|
|
43
|
+
//let textValue: string = utils.formatNumber(value, precision);
|
|
44
44
|
|
|
45
|
+
$: textValue = utils.formatNumber(value, precision);
|
|
45
46
|
|
|
46
47
|
</script>
|
|
47
48
|
<CommonEditor {displayMode} {style} value={textValue} {suffix} {prefix} {readonly} {variant} {compact} class={className}
|
package/dist/types.d.ts
CHANGED
|
@@ -3,5 +3,11 @@ import type { MouseClickHandler } from "./common/MouseClickHandler";
|
|
|
3
3
|
import { DisplayMode } from "./common/DisplayMode.js";
|
|
4
4
|
import { DateContext } from "./base-calendar";
|
|
5
5
|
import { ModalResult } from "./message-box";
|
|
6
|
+
import type { LazyLoader } from "./list-box";
|
|
7
|
+
/**
|
|
8
|
+
* 从选中的Option中获取对于的文字值
|
|
9
|
+
*/
|
|
10
|
+
type RetrieveOptionText = (item: any) => string;
|
|
6
11
|
export { DateContext, ModalResult, DisplayMode };
|
|
12
|
+
export type { RetrieveOptionText, LazyLoader };
|
|
7
13
|
export type { OnChangeHandler, MouseClickHandler };
|
package/package.json
CHANGED