@ticatec/uniface-element 0.1.30 → 0.1.31

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.
@@ -12,10 +12,10 @@
12
12
 
13
13
 
14
14
  <div class="uniface-breadcrumbs" {style}>
15
- {#each items as item}
15
+ {#each items as item, idx}
16
16
  <div>
17
17
  <span>{separator}</span>
18
- <span aria-hidden="true" class="breadcrumb" on:click={onItemClick(item.data)}>{item.label}</span>
18
+ <span aria-hidden="true" class="breadcrumb" on:click={idx==items.length-1 ? null : onItemClick(item.data)}>{item.label}</span>
19
19
  </div>
20
20
  {/each}
21
21
  </div>
@@ -0,0 +1,59 @@
1
+ <script lang="ts">
2
+
3
+
4
+ import {DisplayMode} from "../common/DisplayMode";
5
+ import type {OnChangeHandler} from "../common/OnChangeHandler";
6
+ import CommonPicker from "../common/CommonPicker.svelte";
7
+
8
+ type OnActionHandler = () => void;
9
+
10
+ export let showHex = true;
11
+ export let showRgb = false;
12
+
13
+ export let variant: '' | 'plain' | 'outlined' | 'filled' = '';
14
+ export let disabled: boolean = false;
15
+ export let readonly: boolean = false;
16
+ export let compact: boolean = false;
17
+ export let value: any = "#ff3e00";
18
+ export let style: string = '';
19
+ export let onChange: OnChangeHandler<any> = null as unknown as OnChangeHandler<any>;
20
+
21
+
22
+ let oldValue = value;
23
+
24
+ $: if (oldValue != value) {
25
+ oldValue = value;
26
+ }
27
+
28
+ let editor: any;
29
+
30
+ const clean = () => {
31
+
32
+ }
33
+
34
+ const handleActionIconClick = () => {
35
+ editor.click();
36
+ }
37
+
38
+ function handleColorChange(event) {
39
+ selectedColor = event.target.value;
40
+ rgbValues = hexToRgb(selectedColor);
41
+ console.log(selectedColor, rgbValues);
42
+ // dispatch('change', {
43
+ // hex: selectedColor,
44
+ // rgb: rgbValues
45
+ // });
46
+ }
47
+
48
+ </script>
49
+
50
+ <CommonPicker displayMode={DisplayMode.Edit} {variant} {style} {compact} className="multiple" dropDownIcon="icon_google_color_lens"
51
+ canClean={false} autoFit {clean} textValue={value} {readonly} {disabled} iconClickHandler={handleActionIconClick}>
52
+ <!-- <div style="flex: 1 1 auto; width: 50%; height: 60%; border-radius: 4px; background-color: {value}"></div>-->
53
+ <div style="width: 100%; display: flex; overflow: hidden; flex-direction: row; align-items: center; height: 100%; gap: 8px">
54
+ <input bind:this={editor} style="flex: 0 0 auto; width: 40%; height: 80%; border-radius: 8px;" type="color" bind:value on:change={handleColorChange}/>
55
+ <input style="flex: 0 0 auto; width: 50%; text-align: center" class="text-editor" readonly value={value??''} {disabled}/>
56
+ </div>
57
+
58
+
59
+ </CommonPicker>
@@ -0,0 +1,29 @@
1
+ import type { OnChangeHandler } from "../common/OnChangeHandler";
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 ColorPicker: $$__sveltets_2_IsomorphicComponent<{
16
+ showHex?: boolean;
17
+ showRgb?: boolean;
18
+ variant?: "" | "plain" | "outlined" | "filled";
19
+ disabled?: boolean;
20
+ readonly?: boolean;
21
+ compact?: boolean;
22
+ value?: any;
23
+ style?: string;
24
+ onChange?: OnChangeHandler<any>;
25
+ }, {
26
+ [evt: string]: CustomEvent<any>;
27
+ }, {}, {}, string>;
28
+ type ColorPicker = InstanceType<typeof ColorPicker>;
29
+ export default ColorPicker;
@@ -0,0 +1,179 @@
1
+ <script lang="ts">
2
+
3
+
4
+ // Define props with default values
5
+ import i18n from "@ticatec/i18n";
6
+ import langRes from "../i18n_resources/uniface_en_resource";
7
+
8
+ export let initialColor = "#ffffff";
9
+ export let showHex = true;
10
+ export let showRgb = false;
11
+ export let swatches = [];
12
+
13
+ let selectedColor = initialColor;
14
+ let rgbValues = hexToRgb(initialColor);
15
+
16
+
17
+ // Convert hex to RGB
18
+ function hexToRgb(hex) {
19
+ const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
20
+ return result ? {
21
+ r: parseInt(result[1], 16),
22
+ g: parseInt(result[2], 16),
23
+ b: parseInt(result[3], 16)
24
+ } : { r: 0, g: 0, b: 0 };
25
+ }
26
+
27
+ // Emit change event when color changes
28
+ function handleColorChange(event) {
29
+ selectedColor = event.target.value;
30
+ rgbValues = hexToRgb(selectedColor);
31
+ dispatch('change', {
32
+ hex: selectedColor,
33
+ rgb: rgbValues
34
+ });
35
+ }
36
+
37
+ // Select a swatch
38
+ function selectSwatch(color) {
39
+ selectedColor = color;
40
+ rgbValues = hexToRgb(selectedColor);
41
+ // dispatch('change', {
42
+ // hex: selectedColor,
43
+ // rgb: rgbValues
44
+ // });
45
+ }
46
+ </script>
47
+
48
+ <div class="color-picker">
49
+ <label for="color-input">
50
+ {i18n.getText('uniface.pickupColor', langRes.uniface.colorPicker)
51
+ }
52
+ </label>
53
+
54
+ <div class="color-input-group">
55
+ <input
56
+ id="color-input"
57
+ type="color"
58
+ bind:value={selectedColor}
59
+ on:change={handleColorChange}
60
+ />
61
+ <div
62
+ class="color-preview"
63
+ style="background-color: {selectedColor};"
64
+ ></div>
65
+ </div>
66
+
67
+ {#if showHex}
68
+ <div class="color-value">
69
+ <span>HEX:</span> {selectedColor}
70
+ </div>
71
+ {/if}
72
+
73
+ {#if showRgb}
74
+ <div class="color-value">
75
+ <span>RGB:</span> rgb({rgbValues.r}, {rgbValues.g}, {rgbValues.b})
76
+ </div>
77
+ {/if}
78
+
79
+ {#if swatches && swatches.length > 0}
80
+ <div class="swatches">
81
+ {#each swatches as swatch}
82
+ <button
83
+ class="swatch"
84
+ style="background-color: {swatch};"
85
+ on:click={() => selectSwatch(swatch)}
86
+ aria-label={`Select color ${swatch}`}
87
+ class:selected={selectedColor === swatch}
88
+ ></button>
89
+ {/each}
90
+ </div>
91
+ {/if}
92
+ </div>
93
+
94
+ <style>
95
+ .color-picker {
96
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
97
+ padding: 16px;
98
+ border-radius: 8px;
99
+ background-color: #f8f9fa;
100
+ box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
101
+ width: 100%;
102
+ max-width: 300px;
103
+ }
104
+
105
+ label {
106
+ display: block;
107
+ margin-bottom: 8px;
108
+ font-weight: 500;
109
+ color: #333;
110
+ }
111
+
112
+ .color-input-group {
113
+ display: flex;
114
+ align-items: center;
115
+ margin-bottom: 12px;
116
+ }
117
+
118
+ input[type="color"] {
119
+ -webkit-appearance: none;
120
+ width: 40px;
121
+ height: 40px;
122
+ border: none;
123
+ padding: 0;
124
+ background: none;
125
+ cursor: pointer;
126
+ }
127
+
128
+ input[type="color"]::-webkit-color-swatch-wrapper {
129
+ padding: 0;
130
+ }
131
+
132
+ input[type="color"]::-webkit-color-swatch {
133
+ border: 1px solid #ddd;
134
+ border-radius: 4px;
135
+ }
136
+
137
+ .color-preview {
138
+ width: 40px;
139
+ height: 40px;
140
+ margin-left: 12px;
141
+ border-radius: 4px;
142
+ border: 1px solid #ddd;
143
+ }
144
+
145
+ .color-value {
146
+ margin-bottom: 8px;
147
+ font-size: 14px;
148
+ }
149
+
150
+ .color-value span {
151
+ font-weight: 600;
152
+ margin-right: 4px;
153
+ }
154
+
155
+ .swatches {
156
+ display: flex;
157
+ flex-wrap: wrap;
158
+ gap: 8px;
159
+ margin-top: 12px;
160
+ }
161
+
162
+ .swatch {
163
+ width: 24px;
164
+ height: 24px;
165
+ border-radius: 50%;
166
+ border: 1px solid #ddd;
167
+ cursor: pointer;
168
+ transition: transform 0.2s ease;
169
+ }
170
+
171
+ .swatch:hover {
172
+ transform: scale(1.1);
173
+ }
174
+
175
+ .swatch.selected {
176
+ border: 2px solid #333;
177
+ box-shadow: 0 0 0 2px white inset;
178
+ }
179
+ </style>
@@ -0,0 +1,23 @@
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> {
2
+ new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
3
+ $$bindings?: Bindings;
4
+ } & Exports;
5
+ (internal: unknown, props: Props & {
6
+ $$events?: Events;
7
+ $$slots?: Slots;
8
+ }): Exports & {
9
+ $set?: any;
10
+ $on?: any;
11
+ };
12
+ z_$$bindings?: Bindings;
13
+ }
14
+ declare const ColorPickerPanel: $$__sveltets_2_IsomorphicComponent<{
15
+ initialColor?: string;
16
+ showHex?: boolean;
17
+ showRgb?: boolean;
18
+ swatches?: any[];
19
+ }, {
20
+ [evt: string]: CustomEvent<any>;
21
+ }, {}, {}, string>;
22
+ type ColorPickerPanel = InstanceType<typeof ColorPickerPanel>;
23
+ export default ColorPickerPanel;
@@ -0,0 +1,2 @@
1
+ import ColorPicker from "./ColorPicker.svelte";
2
+ export default ColorPicker;
@@ -0,0 +1,2 @@
1
+ import ColorPicker from "./ColorPicker.svelte";
2
+ export default ColorPicker;
@@ -40,7 +40,7 @@
40
40
  {#if readonly || disabled}
41
41
  <input style="width: 100%" class="readonly" class:disabled readonly {disabled} value={textValue}/>
42
42
  {:else}
43
- <div style="flex: 1 1 auto; position: relative; height: 100%">
43
+ <div style="flex: 1 1 auto; position: relative; overflow: hidden; height: 100%">
44
44
  <slot></slot>
45
45
  {#if canClean && textValue && textValue.length > 0}
46
46
  <div class="uniface-editor-clean-icon">
@@ -21,6 +21,7 @@
21
21
  export let inlineRowHeight: number = 80;
22
22
  export let rowBorder: boolean = false;
23
23
  export let colBorder: boolean = false;
24
+ export let emptyIndicator: string | undefined = undefined;
24
25
 
25
26
  export let style: string = '';
26
27
 
@@ -111,7 +112,7 @@
111
112
  {/if}
112
113
 
113
114
  <ContentPanel columns={dataColumns} {orderDirection} {orderColumn} {handleWidthChange} {handleCellClick} {tabWidth} bind:rows
114
- bind:scrollTop {expandRow} {rowHeight} {list} {table} {inlineComponent} bind:inlineRowHeight
115
+ bind:scrollTop {expandRow} {rowHeight} {list} {table} {inlineComponent} bind:inlineRowHeight {emptyIndicator}
115
116
  displayHorizontalScroll={actionsColumn!=null || indicatorColumn != null || fixedCols.length > 0}
116
117
  showVerticalScroll={actionsColumn == null}/>
117
118
  {/if}
@@ -24,6 +24,7 @@ declare const DataTable: $$__sveltets_2_IsomorphicComponent<{
24
24
  inlineRowHeight?: number;
25
25
  rowBorder?: boolean;
26
26
  colBorder?: boolean;
27
+ emptyIndicator?: string | undefined;
27
28
  style?: string;
28
29
  }, {
29
30
  [evt: string]: CustomEvent<any>;
@@ -8,4 +8,8 @@ export default interface ActionsColumn {
8
8
  *
9
9
  */
10
10
  getActions: GetRowActions;
11
+ /**
12
+ * 对齐方式,默认靠左对齐
13
+ */
14
+ align?: 'left' | 'center';
11
15
  }
@@ -56,7 +56,7 @@
56
56
  <div bind:this={scrollPanel} class="rows-container" style="overflow-y: auto" on:scroll|passive={handleActionPanelScroll}>
57
57
  <div>
58
58
  {#each rows as row, idx}
59
- <ActionsRow {row} {rowHeight} parentRect={rect} alternative={idx % 2 == 1} width={actionsColumn.width}
59
+ <ActionsRow {row} {rowHeight} parentRect={rect} alternative={idx % 2 == 1} width={actionsColumn.width} align={actionsColumn.align}
60
60
  actions={actionsColumn.getActions(row.data)}/>
61
61
  {#if row == expandRow}
62
62
  <div class="inline-panel" style="height: {inlineRowHeight??0}px">
@@ -15,6 +15,8 @@
15
15
 
16
16
  export let rowHeight: number;
17
17
 
18
+ export let align: 'left' | 'center' | undefined;
19
+
18
20
  let style: string;
19
21
 
20
22
 
@@ -84,9 +86,8 @@
84
86
  $: style = rowHeight== null ? '' : `height: ${rowHeight}px`
85
87
 
86
88
  </script>
87
- <div class="data-row" class:alternative style="position: relative; width: {width}px; display: block; {style}">
88
- <div class="action-cell" bind:this={cell}
89
- style="">
89
+ <div class="data-row" class:alternative style="position: relative; display: block; width: {width}px; {style}">
90
+ <div class="action-cell" bind:this={cell} style="{align=='center' ? 'margin: 0 auto' : ''}">
90
91
  {#each actionList as action}
91
92
  <TextButton style="flex-shrink: 0; top: 0" size="mini" type="primary" label={action.label} onClick={()=>action.callback(row.data)}/>
92
93
  {/each}
@@ -20,6 +20,7 @@ declare const ActionsRow: $$__sveltets_2_IsomorphicComponent<{
20
20
  parentRect: DOMRect;
21
21
  width: number;
22
22
  rowHeight: number;
23
+ align: "left" | "center" | undefined;
23
24
  }, {
24
25
  [evt: string]: CustomEvent<any>;
25
26
  }, {}, {}, string>;
@@ -23,6 +23,7 @@ declare const langRes: {
23
23
  dataTable: {
24
24
  rowNo: string;
25
25
  actions: string;
26
+ emptyDataSet: string;
26
27
  };
27
28
  };
28
29
  };
@@ -30,7 +30,8 @@ const langRes = {
30
30
  },
31
31
  dataTable: {
32
32
  rowNo: "序号",
33
- actions: "操作"
33
+ actions: "操作",
34
+ emptyDataSet: '空数据集'
34
35
  }
35
36
  }
36
37
  };
@@ -3,6 +3,7 @@ declare const langRes: {
3
3
  btnClose: string;
4
4
  btnCancel: string;
5
5
  btnConfirm: string;
6
+ colorPicker: string;
6
7
  calendar: {
7
8
  months: string[];
8
9
  monthsAbbr: string[];
@@ -23,6 +24,7 @@ declare const langRes: {
23
24
  dataTable: {
24
25
  rowNo: string;
25
26
  actions: string;
27
+ emptyDataSet: string;
26
28
  };
27
29
  };
28
30
  };
@@ -3,6 +3,7 @@ const langRes = {
3
3
  btnClose: "Close",
4
4
  btnCancel: 'Cancel',
5
5
  btnConfirm: "OK",
6
+ colorPicker: "Pick up color",
6
7
  calendar: {
7
8
  months: [
8
9
  'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'
@@ -30,7 +31,8 @@ const langRes = {
30
31
  },
31
32
  dataTable: {
32
33
  rowNo: "Row#",
33
- actions: "Actions"
34
+ actions: "Actions",
35
+ emptyDataSet: 'Empty dataset'
34
36
  }
35
37
  }
36
38
  };
@@ -84,7 +84,7 @@
84
84
  {#each options as op}
85
85
  {#if hideOptions.indexOf(op[keyField]) < 0}
86
86
  {#if itemRender != null}
87
- <svelte:component this={itemRender} item={op} disabled={disableOptions.indexOf(op[keyField])>-1}
87
+ <svelte:component this={itemRender.component} {...itemRender.props} item={op} disabled={disableOptions.indexOf(op[keyField])>-1}
88
88
  on:click={handleItemClick(op)}/>
89
89
  {:else}
90
90
  <div class="option-item" class:disabled={disableOptions.indexOf(op[keyField])>-1} aria-hidden="true"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ticatec/uniface-element",
3
- "version": "0.1.30",
3
+ "version": "0.1.31",
4
4
  "description": "uniface web elements",
5
5
  "scripts": {
6
6
  "dev": "vite dev",
@@ -1,36 +0,0 @@
1
- import type { HrefBuilder } from "./HrefLink";
2
- import type { CellHint, FormatCell } from "./FormatCell";
3
- export default interface AdvColumn {
4
- /**
5
- * 对齐方式,文本,可以取值:left, center, right
6
- */
7
- align: string;
8
- /**
9
- * 对应的字段/属性名
10
- */
11
- field?: string;
12
- /**
13
- * 超链接设置
14
- */
15
- href?: HrefBuilder | null;
16
- /**
17
- * 单元格转换函数
18
- */
19
- formatter?: FormatCell;
20
- /**
21
- * 是否忽略html的转义符
22
- */
23
- escapeHTML: boolean;
24
- /**
25
- * 待显示的提示
26
- */
27
- hint?: CellHint;
28
- /**
29
- * 渲染器
30
- */
31
- render?: any;
32
- /**
33
- * 宽度
34
- */
35
- width: number;
36
- }
@@ -1 +0,0 @@
1
- export {};