@ticatec/uniface-element 0.3.11 → 0.3.13

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.
@@ -5,6 +5,9 @@ import type IndicatorColumn from "./lib/IndicatorColumn";
5
5
  import type RowAction from "./lib/RowAction";
6
6
  import type { GetRowActions, ActionFunction } from "./lib/RowAction";
7
7
  import type DataColumn from "./lib/DataColumn";
8
+ import type { CellAction } from "./types";
9
+ import ActionCell from "./parts/ActionCell.svelte";
8
10
  export default DataTable;
11
+ export { ActionCell };
9
12
  export type { ActionsColumn, IndicatorColumn, FormatCell, CellHint, DataColumn };
10
- export type { RowAction, GetRowActions, ActionFunction };
13
+ export type { RowAction, GetRowActions, ActionFunction, CellAction };
@@ -1,2 +1,4 @@
1
1
  import DataTable from "./DataTable.svelte";
2
+ import ActionCell from "./parts/ActionCell.svelte";
2
3
  export default DataTable;
4
+ export { ActionCell };
@@ -0,0 +1,19 @@
1
+ <script lang="ts">
2
+ import type {CellAction, GetCellAction} from "../types";
3
+ import {TextButton} from "../../button";
4
+
5
+ export let data: any;
6
+ export let getAction: GetCellAction;
7
+
8
+ $: action = getAction?.(data);
9
+
10
+ const handleClick = async (event: MouseEvent) => {
11
+ await action?.handle(data)
12
+ }
13
+
14
+ </script>
15
+ {#if action}
16
+ <div style="width: 100; overflow: hidden;">
17
+ <TextButton type={action.type ?? "primary"} label={action.text} onclick={handleClick}></TextButton>
18
+ </div>
19
+ {/if}
@@ -0,0 +1,22 @@
1
+ import type { GetCellAction } from "../types";
2
+ 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> {
3
+ new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
4
+ $$bindings?: Bindings;
5
+ } & Exports;
6
+ (internal: unknown, props: Props & {
7
+ $$events?: Events;
8
+ $$slots?: Slots;
9
+ }): Exports & {
10
+ $set?: any;
11
+ $on?: any;
12
+ };
13
+ z_$$bindings?: Bindings;
14
+ }
15
+ declare const ActionCell: $$__sveltets_2_IsomorphicComponent<{
16
+ data: any;
17
+ getAction: GetCellAction;
18
+ }, {
19
+ [evt: string]: CustomEvent<any>;
20
+ }, {}, {}, string>;
21
+ type ActionCell = InstanceType<typeof ActionCell>;
22
+ export default ActionCell;
@@ -87,7 +87,6 @@
87
87
  }
88
88
 
89
89
  $: if (dataPanel && scrollTop > -1 && !showVerticalScroll) {
90
- console.log('移动', scrollTop)
91
90
  dataPanel.scrollTop = scrollTop;
92
91
  }
93
92
 
@@ -0,0 +1,20 @@
1
+ import type { ButtonType } from "../button";
2
+ /**
3
+ * Action cell中的事件处理
4
+ */
5
+ export type HandleAction = (data: any) => Promise<void>;
6
+ export interface CellAction {
7
+ /**
8
+ * action的文本
9
+ */
10
+ text: string;
11
+ /**
12
+ * action的类型
13
+ */
14
+ type?: ButtonType;
15
+ /**
16
+ * 点击处理
17
+ */
18
+ handle: HandleAction;
19
+ }
20
+ export type GetCellAction = (data: any) => CellAction | undefined;
@@ -0,0 +1 @@
1
+ export {};
@@ -21,6 +21,18 @@
21
21
  let maxFrom;
22
22
  let minTo;
23
23
 
24
+ // 规范化日期值:from设为当天零时,to设为当天23:59:59.999
25
+ const normalizeValue = (date: UniDate, isStart: boolean): Date | null => {
26
+ if (!date) return null;
27
+ return isStart
28
+ ? dayjs(date).startOf('day').toDate()
29
+ : dayjs(date).endOf('day').toDate();
30
+ };
31
+
32
+ // 计算规范化的值(用于内部显示和处理)
33
+ $: normalizedFromValue = normalizeValue(fromValue, true);
34
+ $: normalizedToValue = normalizeValue(toValue, false);
35
+
24
36
 
25
37
  const cleanValue = () => {
26
38
  fromValue = null;
@@ -32,12 +44,12 @@
32
44
  }
33
45
 
34
46
  const handleFormCalendarSelect = (value: dayjs.Dayjs) => {
35
- fromValue = value.toDate();
47
+ fromValue = normalizeValue(value.toDate(), true);
36
48
  }
37
49
 
38
50
 
39
51
  const handleToCalendarSelect = (value: dayjs.Dayjs) => {
40
- toValue = value.toDate();
52
+ toValue = normalizeValue(value.toDate(), false);
41
53
  showPopup = false;
42
54
  }
43
55
 
@@ -45,15 +57,16 @@
45
57
  showPopup = true;
46
58
  }
47
59
 
48
- $: textFrom = toTextValue(fromValue);
49
- $: textTo = toTextValue(toValue);
50
- $: maxFrom = toValue ?? max;
51
- $: minTo = fromValue ?? min;
60
+ // 使用规范化的值进行显示和计算
61
+ $: textFrom = toTextValue(normalizedFromValue);
62
+ $: textTo = toTextValue(normalizedToValue);
63
+ $: maxFrom = normalizedToValue ?? max;
64
+ $: minTo = normalizedFromValue ?? min;
52
65
 
53
66
  let showPopup = false;
54
67
  let rootElement: any;
55
68
 
56
- $: showActionIcon = fromValue != null || toValue != null;
69
+ $: showActionIcon = normalizedFromValue != null || normalizedToValue != null;
57
70
 
58
71
  </script>
59
72
 
@@ -120,7 +120,7 @@
120
120
  idleTime = 0;
121
121
  interval = setInterval(() => {
122
122
  idleTime += 100;
123
- if (idleTime >= 500) {
123
+ if (idleTime >= 200) {
124
124
  clearInterval(interval);
125
125
  lazyLoad(text, 1, false);
126
126
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ticatec/uniface-element",
3
- "version": "0.3.11",
3
+ "version": "0.3.13",
4
4
  "description": "A comprehensive UI component library for Svelte applications with rich form controls, data tables, layouts and interactive elements",
5
5
  "keywords": [
6
6
  "svelte",