@ticatec/uniface-element 0.1.54 → 0.1.55

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.
@@ -8,8 +8,8 @@
8
8
  export let title: string = null as unknown as string;
9
9
  export let actions: Array<CardAction> = [];
10
10
  export let variant: 'plain' | '3d' = 'plain';
11
-
12
11
  export let iconColor: string | null = null;
12
+ export let data: any;
13
13
 
14
14
  </script>
15
15
 
@@ -28,7 +28,7 @@
28
28
  <slot/>
29
29
  </div>
30
30
  {#if actions && actions.length > 0}
31
- <CommonCardActionBar color={iconColor} {actions}/>
31
+ <CommonCardActionBar color={iconColor} {actions} {data}/>
32
32
  {:else }
33
33
  {#if $$slots['action-bar']}
34
34
  <div class="card-action-bar">
@@ -23,6 +23,7 @@ declare const Card: $$__sveltets_2_IsomorphicComponent<$$__sveltets_2_PropsWithC
23
23
  actions?: Array<CardAction>;
24
24
  variant?: "plain" | "3d";
25
25
  iconColor?: string | null;
26
+ data: any;
26
27
  }, {
27
28
  'header-bar': {};
28
29
  default: {};
@@ -1,4 +1,4 @@
1
- export type ActionCallback = () => void;
1
+ export type ActionCallback = (data: any) => void;
2
2
  export default interface CardAction {
3
3
  /**
4
4
  * 使用icon字体
@@ -8,6 +8,10 @@ export default interface CardAction {
8
8
  * 直接嵌入图标
9
9
  */
10
10
  img?: string;
11
+ /**
12
+ * 鼠标停留的提示
13
+ */
14
+ hint?: string;
11
15
  /**
12
16
  *
13
17
  */
@@ -4,18 +4,25 @@
4
4
 
5
5
  export let actions: Array<CardAction>;
6
6
  export let color: string | null = null;
7
+ export let data: any;
7
8
 
8
9
  let clickEnable = true;
9
10
 
10
11
  const handleActionClick = (action: CardAction) => async (e: MouseEvent) => {
11
12
  if (clickEnable && !action.disabled) {
12
13
  clickEnable = false;
13
- action.callback?.();
14
+ action.callback?.(data);
14
15
  await utils.sleep(0.5);
15
16
  clickEnable = true;
16
17
  }
17
18
  }
18
19
 
20
+ const showHint = (action: CardAction) => (e: MouseEvent) => {
21
+ if (!action.disabled && action.hint) {
22
+ window.Hint.show(e.target as Element, action.hint, e.x, e.y);
23
+ }
24
+ }
25
+
19
26
  $: fontColor = color ? `color: ${color}` : '';
20
27
 
21
28
  </script>
@@ -24,9 +31,10 @@
24
31
  {#each actions as action}
25
32
  <div class:disabled={action.disabled} class="action-item">
26
33
  {#if action.icon}
27
- <i class={action.icon} aria-hidden="true" on:click={handleActionClick(action)}></i>
34
+ <i class={action.icon} aria-hidden="true" on:click={handleActionClick(action)} on:mouseenter={showHint(action)}></i>
28
35
  {:else if action.img}
29
- <img class="card-action-img" alt="" src={action.img} aria-hidden="true" on:click={handleActionClick(action)}/>
36
+ <img class="card-action-img" alt="" src={action.img} aria-hidden="true" on:click={handleActionClick(action)}
37
+ on:mouseenter={showHint(action)}/>
30
38
  {/if}
31
39
  </div>
32
40
  {/each}
@@ -15,6 +15,7 @@ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> =
15
15
  declare const CommonCardActionBar: $$__sveltets_2_IsomorphicComponent<{
16
16
  actions: Array<CardAction>;
17
17
  color?: string | null;
18
+ data: any;
18
19
  }, {
19
20
  [evt: string]: CustomEvent<any>;
20
21
  }, {}, {}, string>;
package/dist/index.d.ts CHANGED
@@ -4,6 +4,7 @@ import { type IMessageBox, ModalResult } from "./message-box";
4
4
  import type { Toast } from "./toast";
5
5
  import type { Indicator } from "./indicator";
6
6
  import { DisplayMode } from "./common/DisplayMode.js";
7
+ import type IHint from "./popup-hint/IHint";
7
8
  export { DateContext, ModalResult, DisplayMode };
8
9
  declare global {
9
10
  interface Window {
@@ -11,5 +12,6 @@ declare global {
11
12
  Toast: Toast;
12
13
  MessageBox: IMessageBox;
13
14
  Dialog: IDialog;
15
+ Hint: IHint;
14
16
  }
15
17
  }
@@ -120,7 +120,7 @@
120
120
  <div class="box-content" style="min-height: 40px">
121
121
  {#if iconType != null}
122
122
  <div class="box-icon {type}">
123
- <i style="font-size: 40px" class={iconType}></i>
123
+ <i style="font-size: 56px" class={iconType}></i>
124
124
  </div>
125
125
  {/if}
126
126
  <div style="flex: 1 1 auto; display: flex; flex-direction: column; justify-content: center">
@@ -0,0 +1,6 @@
1
+ export type ShowHint = (element: Element, text: string, x: number, y: number) => void;
2
+ export default interface IHint {
3
+ show: ShowHint;
4
+ }
5
+ declare const initialize: (showHint: ShowHint) => void;
6
+ export { initialize };
@@ -0,0 +1,6 @@
1
+ const initialize = (showHint) => {
2
+ window.Hint = {
3
+ show: showHint
4
+ };
5
+ };
6
+ export { initialize };
@@ -1,32 +1,37 @@
1
1
  <script lang="ts">
2
2
  import Portal from "svelte-portal";
3
- import type {ShowHint} from "../common/ShowHint";
4
3
  import utils from "../common/utils";
4
+ import {onMount} from "svelte";
5
+ import {initialize, type ShowHint} from "./IHint";
5
6
 
6
7
  let message = ''; // 提示信息ø
7
8
  let targetElement: Element | null = null;
8
9
  let hintVisible = false;
9
10
  let hintStyle = '';
10
11
 
12
+ onMount(async () => {
13
+ initialize(show);
14
+ })
15
+
11
16
  // 显示提示框函数
12
- export const show: ShowHint = async (element: Element, text: string, x: number, y: number) => {
17
+ const show: ShowHint = async (element: Element, text: string, x: number, y: number) => {
13
18
  if (targetElement != null) {
14
- targetElement.removeEventListener('mouseout', hideHint);
19
+ targetElement.addEventListener('mouseout', hideHint);
15
20
  }
16
- targetElement = element;
17
21
  message = text;
18
- await utils.sleep(1);
19
- targetElement.addEventListener('mouseout', hideHint);
20
22
  calculatePosition(x, y);
21
- hintVisible = true;
23
+ setTimeout(()=> {
24
+ if (targetElement == element) {
25
+ targetElement.addEventListener('mouseout', hideHint);
26
+ hintVisible = true;
27
+ }
28
+ }, 500);
29
+ targetElement = element;
22
30
  };
23
31
 
24
32
  // 计算提示框的位置
25
33
  const calculatePosition = (x: number, y: number) => {
26
- if (targetElement) {
27
- const rect = targetElement.getBoundingClientRect();
28
- hintStyle = `max-width: ${rect.width + 20}px; left: ${x + 10}px; top: ${y}px`;
29
- }
34
+ hintStyle = `max-width: 50%; left: ${x + 6}px; top: ${y + 6}px`;
30
35
  }
31
36
 
32
37
  // 隐藏提示框
@@ -1,9 +1,8 @@
1
- import type { ShowHint } from "../common/ShowHint";
2
1
  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
2
  new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
4
3
  $$bindings?: Bindings;
5
4
  } & Exports;
6
- (internal: unknown, props: Props & {
5
+ (internal: unknown, props: {
7
6
  $$events?: Events;
8
7
  $$slots?: Slots;
9
8
  }): Exports & {
@@ -12,12 +11,8 @@ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> =
12
11
  };
13
12
  z_$$bindings?: Bindings;
14
13
  }
15
- declare const PopupHint: $$__sveltets_2_IsomorphicComponent<{
16
- show?: ShowHint;
17
- }, {
14
+ declare const PopupHint: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
18
15
  [evt: string]: CustomEvent<any>;
19
- }, {}, {
20
- show: ShowHint;
21
- }, string>;
16
+ }, {}, {}, string>;
22
17
  type PopupHint = InstanceType<typeof PopupHint>;
23
18
  export default PopupHint;
@@ -1636,10 +1636,12 @@
1636
1636
  }
1637
1637
  .uniface-message-board .uniface-message-box .box-icon {
1638
1638
  flex: 0 0 auto;
1639
- width: 64px;
1640
1639
  box-sizing: border-box;
1641
1640
  padding: 8px 12px;
1642
1641
  margin-right: 24px;
1642
+ flex-direction: row;
1643
+ display: flex;
1644
+ align-items: center;
1643
1645
  }
1644
1646
  .uniface-message-board .uniface-message-box .box-icon.warning {
1645
1647
  color: orange;
@@ -3989,6 +3991,7 @@ root {
3989
3991
  .uniface-popup-hint {
3990
3992
  position: absolute;
3991
3993
  padding: 8px 16px;
3994
+ width: auto;
3992
3995
  box-sizing: border-box;
3993
3996
  background-color: var(--uniface-popup-hint-bg, #FFFFE1);
3994
3997
  color: var(--uniface-popup-hint-color, #374151);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ticatec/uniface-element",
3
- "version": "0.1.54",
3
+ "version": "0.1.55",
4
4
  "description": "uniface web elements",
5
5
  "scripts": {
6
6
  "dev": "vite dev",
@@ -1 +0,0 @@
1
- export type ShowHint = (src: Element, text: any, x: number, y: number) => void;
@@ -1 +0,0 @@
1
- export {};