@ticatec/uniface-element 0.2.1 → 0.2.3

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.
Files changed (89) hide show
  1. package/README.md +62 -15
  2. package/README_CN.md +52 -1
  3. package/dist/accordion/Accordion.svelte +1 -1
  4. package/dist/action-bar/ActionBar.svelte +7 -1
  5. package/dist/attachment-files/FileRender.svelte +1 -1
  6. package/dist/attachment-files/FileUploadBar.svelte +7 -6
  7. package/dist/attachment-files/FileUploadPanel.svelte +2 -2
  8. package/dist/base-calendar/DateContext.js +5 -4
  9. package/dist/base-calendar/YearPickupPanel.svelte +4 -4
  10. package/dist/card/Card.svelte +1 -1
  11. package/dist/card/Card.svelte.d.ts +1 -1
  12. package/dist/cascade-options-select/CascadeOptionSelect.svelte +2 -3
  13. package/dist/cascade-options-select/CascadeOptionSelect.svelte.d.ts +46 -1
  14. package/dist/cascade-options-select/CascadePanel.svelte +1 -1
  15. package/dist/checkbox/CheckBox.svelte +1 -1
  16. package/dist/color-picker/ColorPicker.svelte +9 -9
  17. package/dist/color-picker/ColorPicker.svelte.d.ts +0 -2
  18. package/dist/color-picker/ColorPickerPanel.svelte +11 -15
  19. package/dist/color-picker/ColorPickerPanel.svelte.d.ts +1 -1
  20. package/dist/common/CommonPicker.svelte +2 -2
  21. package/dist/common/CommonPicker.svelte.d.ts +1 -1
  22. package/dist/common/Popover.svelte +28 -6
  23. package/dist/common/Popover.svelte.d.ts +9 -3
  24. package/dist/common/uniface-utils.js +6 -4
  25. package/dist/common-editor/CommonEditor.svelte +1 -1
  26. package/dist/common-editor/CommonEditor.svelte.d.ts +1 -1
  27. package/dist/common-editor/NumberInput.svelte +1 -1
  28. package/dist/common-editor/NumberInput.svelte.d.ts +1 -1
  29. package/dist/concise-data-table/ConciseListTable.svelte +7 -2
  30. package/dist/concise-data-table/ConciseListTable.svelte.d.ts +1 -0
  31. package/dist/concise-data-table/DataRow.svelte +1 -1
  32. package/dist/concise-data-table/TableOptions.d.ts +1 -1
  33. package/dist/data-table/DataTable.svelte +1 -1
  34. package/dist/data-table/parts/ActionsPanel.svelte +4 -3
  35. package/dist/data-table/parts/ActionsRow.svelte +3 -3
  36. package/dist/data-table/parts/ContentPanel.svelte +3 -2
  37. package/dist/data-table/parts/FixedColumnsPanel.svelte +0 -1
  38. package/dist/data-table/parts/FixedColumnsPanel.svelte.d.ts +1 -2
  39. package/dist/data-table/parts/FixedHeaderPanel.svelte +2 -2
  40. package/dist/data-table/parts/FixedRow.svelte +2 -1
  41. package/dist/data-table/parts/FixedRow.svelte.d.ts +1 -1
  42. package/dist/data-table/parts/HrefCell.svelte +23 -2
  43. package/dist/data-table/parts/PopupMenu.svelte +25 -2
  44. package/dist/data-table/parts/PopupMenu.svelte.d.ts +8 -1
  45. package/dist/date-picker/DatePicker.svelte +0 -1
  46. package/dist/date-picker/DateTimePicker.svelte +3 -3
  47. package/dist/date-picker/ScrollBar.svelte +4 -7
  48. package/dist/date-range/DateRangeEditor.svelte +1 -1
  49. package/dist/dialog/CommonDialog.svelte +2 -2
  50. package/dist/dialog/Dialog.svelte +2 -3
  51. package/dist/drawer/Drawer.svelte +1 -1
  52. package/dist/form-field/FormField.svelte +2 -1
  53. package/dist/form-field/FormField.svelte.d.ts +1 -0
  54. package/dist/form-panel/flex-row-form/FormContainer.svelte +1 -1
  55. package/dist/form-panel/grid-form/EmptyCell.svelte +8 -7
  56. package/dist/form-panel/grid-form/EmptyCell.svelte.d.ts +2 -2
  57. package/dist/form-panel/grid-form/GridField.svelte +1 -1
  58. package/dist/i18nRes/i18nRes.d.ts +2 -0
  59. package/dist/i18nRes/i18nRes.js +44 -0
  60. package/dist/i18nRes/index.d.ts +2 -0
  61. package/dist/i18nRes/index.js +2 -0
  62. package/dist/image-files/ImageFilesField.svelte +1 -1
  63. package/dist/indicator/IndicatorBoard.svelte +1 -1
  64. package/dist/inline-cell-editor/InvalidEditor.svelte +1 -0
  65. package/dist/input-options-select/InputOptionsSelect.svelte +6 -6
  66. package/dist/input-options-select/InputOptionsSelect.svelte.d.ts +1 -1
  67. package/dist/layout/flex/FlexBlock.svelte +1 -1
  68. package/dist/lookup-editor/LookupEditor.svelte +1 -1
  69. package/dist/memo-editor/MemoEditor.svelte +2 -2
  70. package/dist/message-box/IMessageBox.d.ts +2 -4
  71. package/dist/message-box/IMessageBox.js +4 -6
  72. package/dist/message-box/MessageBoxBoard.svelte +1 -3
  73. package/dist/options-multi-select/OptionsMultiSelect.svelte +1 -1
  74. package/dist/prompts-text-editor/PromptsTextEditor.svelte +2 -2
  75. package/dist/prompts-text-editor/PromptsTextEditor.svelte.d.ts +1 -1
  76. package/dist/property-editor/PropertyEditor.svelte +3 -3
  77. package/dist/text-editor/PasswordEditor.svelte +1 -1
  78. package/dist/transfer/Transfer.svelte +17 -12
  79. package/dist/transfer/Transfer.svelte.d.ts +0 -1
  80. package/dist/unit-number-editor/UnitNumberEditor.svelte +2 -2
  81. package/package.json +20 -13
  82. package/dist/common-editor/DateInput.svelte +0 -27
  83. package/dist/common-editor/DateInput.svelte.d.ts +0 -29
  84. package/dist/i18n_resources/index.d.ts +0 -3
  85. package/dist/i18n_resources/index.js +0 -3
  86. package/dist/i18n_resources/uniface_cn_resource.d.ts +0 -30
  87. package/dist/i18n_resources/uniface_cn_resource.js +0 -38
  88. package/dist/i18n_resources/uniface_en_resource.d.ts +0 -34
  89. package/dist/i18n_resources/uniface_en_resource.js +0 -42
package/README.md CHANGED
@@ -175,11 +175,63 @@ The library uses CSS custom properties for theming. You can customize the appear
175
175
 
176
176
  The library includes built-in internationalization support:
177
177
 
178
+ default language is english. to load other languages:
179
+
180
+ create a language resource json file in the static web directory, example: `/assets/uniface_zh-CN.json`
181
+ ```json
182
+ {
183
+ "uniface": {
184
+ "common": {
185
+ "btnClose": "关闭",
186
+ "btnCancel": "取消",
187
+ "btnConfirm": "确定",
188
+ "textMore": "加载更多"
189
+ },
190
+ "colorPicker": "选择颜色",
191
+ "calendar": {
192
+ "months": [
193
+ "一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"
194
+ ],
195
+ "monthsAbbr": [
196
+ "一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"
197
+ ],
198
+ "weekTitle": [
199
+ "周日", "周一", "周二", "周三", "周四", "周五", "周六"
200
+ ],
201
+ "weekTitleAbbr": [
202
+ "日", "一", "二", "三", "四", "五", "六"
203
+ ],
204
+ "confirmText": "确定"
205
+ },
206
+ "upload": {
207
+ "btnRetry": "重试",
208
+ "btnRemove": "删除",
209
+ "btnPickup": "选择文件"
210
+ },
211
+ "propertyEditor": {
212
+ "colName": "属性",
213
+ "colValue": "值"
214
+ },
215
+ "dataTable": {
216
+ "rowNo": "#",
217
+ "actions": "操作",
218
+ "emptyDataSet": "暂无数据"
219
+ },
220
+ "transfer": {
221
+ "selectIndicator": "已选择: {{selected}}/{{total}}"
222
+ }
223
+ }
224
+ }
225
+ ```
226
+
227
+ You can load the resource file in the `+page.svelte` or other startup page.
228
+
178
229
  ```typescript
179
- import { i18n } from '@ticatec/uniface-element/i18n_resources';
230
+ import i18n, {i18nUtils} from "@ticatec/i18n";
180
231
 
181
- // Set language
182
- i18n.setLanguage('en'); // or 'zh-CN'
232
+ // 设置语言
233
+ i18n.setLanguage('zh-CN'); // 'en'
234
+ i18nUtils.loadResources('/assets/uniface.json'); //the language code will insert before .json
183
235
  ```
184
236
 
185
237
  ## Available Imports
@@ -187,23 +239,18 @@ i18n.setLanguage('en'); // or 'zh-CN'
187
239
  ### Modular Imports
188
240
  ```typescript
189
241
  // Individual component imports
190
- import { Button } from '@ticatec/uniface-element/Button';
191
- import { DataTable } from '@ticatec/uniface-element/DataTable';
192
- import { SidebarLayout } from '@ticatec/uniface-element/app-layout/SidebarLayout';
193
- import { AttachmentFilesField } from '@ticatec/uniface-element/AttachmentFiles';
194
- import { ImageFilesField } from '@ticatec/uniface-element/ImageFiles';
195
- import { MemoEditor } from '@ticatec/uniface-element/MemoEditor';
242
+ import Button from '@ticatec/uniface-element/Button';
243
+ import DataTable from '@ticatec/uniface-element/DataTable';
244
+ import SidebarLayout from '@ticatec/uniface-element/app-layout/SidebarLayout';
245
+ import AttachmentFilesField from '@ticatec/uniface-element/AttachmentFiles';
246
+ import ImageFilesField from '@ticatec/uniface-element/ImageFiles';
247
+ import MemoEditor from '@ticatec/uniface-element/MemoEditor';
196
248
 
197
249
  // Utility imports
198
250
  import { utils } from '@ticatec/uniface-element/utils';
199
- import type { DataColumn } from '@ticatec/uniface-element/types';
251
+ import type { DataColumn } from '@ticatec/uniface-element/DataTable';
200
252
  ```
201
253
 
202
- ### Barrel Imports
203
- ```typescript
204
- // Import multiple components from main entry point
205
- import Button, DataTable, Dialog, Card from '@ticatec/uniface-element/Button, DataTable, Dialog, Card';
206
- ```
207
254
 
208
255
  ## Development
209
256
 
package/README_CN.md CHANGED
@@ -277,13 +277,64 @@ await window.MessageBox.showInfo("操作完成", "提示");
277
277
 
278
278
  组件库内置国际化支持:
279
279
 
280
+ 中文资源文件:
281
+ 可以将文件放置在静态网站的目录下,比如`/assets/uniface_zh-CN.json`
282
+ ```json
283
+ {
284
+ "uniface": {
285
+ "common": {
286
+ "btnClose": "关闭",
287
+ "btnCancel": "取消",
288
+ "btnConfirm": "确定",
289
+ "textMore": "加载更多"
290
+ },
291
+ "colorPicker": "选择颜色",
292
+ "calendar": {
293
+ "months": [
294
+ "一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"
295
+ ],
296
+ "monthsAbbr": [
297
+ "一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"
298
+ ],
299
+ "weekTitle": [
300
+ "周日", "周一", "周二", "周三", "周四", "周五", "周六"
301
+ ],
302
+ "weekTitleAbbr": [
303
+ "日", "一", "二", "三", "四", "五", "六"
304
+ ],
305
+ "confirmText": "确定"
306
+ },
307
+ "upload": {
308
+ "btnRetry": "重试",
309
+ "btnRemove": "删除",
310
+ "btnPickup": "选择文件"
311
+ },
312
+ "propertyEditor": {
313
+ "colName": "属性",
314
+ "colValue": "值"
315
+ },
316
+ "dataTable": {
317
+ "rowNo": "#",
318
+ "actions": "操作",
319
+ "emptyDataSet": "暂无数据"
320
+ },
321
+ "transfer": {
322
+ "selectIndicator": "已选择: {{selected}}/{{total}}"
323
+ }
324
+ }
325
+ }
326
+ ```
327
+
280
328
  ```typescript
281
- import { i18n } from '@ticatec/uniface-element/i18n_resources';
329
+ import i18n, {i18nUtils} from "@ticatec/i18n";
282
330
 
283
331
  // 设置语言
284
332
  i18n.setLanguage('zh-CN'); // 或 'en'
333
+ i18nUtils.loadResources('/assets/uniface.json');
285
334
  ```
286
335
 
336
+
337
+
287
338
  ## 可用导入
288
339
 
289
340
  ### 模块化导入
@@ -22,7 +22,7 @@
22
22
  }
23
23
  })
24
24
 
25
- const handleAccordionClick = (accordion: AccordionItem) => (event: MouseEvent) => {
25
+ const handleAccordionClick = (accordion: AccordionItem) => async (event: MouseEvent) => {
26
26
  if (exclusive) {
27
27
  if (activeItem != accordion) {
28
28
  activeItem = accordion;
@@ -1,5 +1,6 @@
1
1
  <script lang="ts">
2
2
 
3
+ import type ButtonAction from "./ButtonAction";
3
4
  import type {ButtonActions} from "./ButtonAction";
4
5
  import Button from "../button/Button.svelte";
5
6
  import Separator from "../separator/Separator.svelte";
@@ -8,13 +9,18 @@
8
9
  export let style: string = '';
9
10
  export let gap: number = 8;
10
11
 
12
+ const handleButtonClick = (button: ButtonAction) => (event: MouseEvent) => {
13
+ button.handler?.(event)
14
+ }
15
+
11
16
 
12
17
  </script>
13
18
 
14
19
  <div class="uniface-action-bar" style="gap: {gap}px; {style}">
15
20
  {#each (buttons ?? []) as button}
16
21
  {#if button}
17
- <Button label={button.label} icon={button.icon} disabled={button.disabled===true} type={button.type} onClick={button.handler}/>
22
+ <Button label={button.label} icon={button.icon} disabled={button.disabled===true} type={button.type}
23
+ onClick={handleButtonClick(button)}/>
18
24
  {:else }
19
25
  <Separator height="24px"/>
20
26
  {/if}
@@ -48,7 +48,7 @@
48
48
 
49
49
  <div style="width: 80px; height: 100%; box-sizing: border-box; padding: 6px 8px;">
50
50
  <div class="file-icon">
51
- <img src={icon} width="64px" height="64px"/>
51
+ <img src={icon} alt="icon" width="64px" height="64px"/>
52
52
  <div class="action-icon" style="top: 15px;">
53
53
  <i class="icon_google_file_download" ></i>
54
54
  </div>
@@ -5,7 +5,8 @@
5
5
  import {ProgressStatus} from "../progress-bar/ProgressStatus";
6
6
  import {onMount} from "svelte";
7
7
  import type UploadFile from "./UploadFile";
8
- import i18n from "@ticatec/i18n";
8
+ import i18nRes from "../i18nRes";
9
+
9
10
 
10
11
  export let file: UploadFile;
11
12
  export let removeFile: (file: any) => void;
@@ -13,9 +14,9 @@
13
14
  let status: ProgressStatus;
14
15
  let progress: number = 0;
15
16
 
16
- let cancelLabel: string = i18n.getText('uniface.upload.btnCancel', 'Cancel');
17
- let retryLabel: string = i18n.getText('uniface.upload.btnRetry', 'Retry');
18
- let removeLabel: string = i18n.getText('uniface.upload.btnRemove', 'Delete');
17
+ let cancelLabel: string = i18nRes.common.btnCancel;
18
+ let retryLabel: string = i18nRes.upload.btnRetry;
19
+ let removeLabel: string = i18nRes.upload.btnRemove;
19
20
 
20
21
  const cancelUpload = async () => {
21
22
  if (await file.cancel()) {
@@ -23,11 +24,11 @@
23
24
  }
24
25
  }
25
26
 
26
- const retryUpload = () => {
27
+ const retryUpload = async () => {
27
28
  file.restart();
28
29
  }
29
30
 
30
- const removeUploadFile = () => {
31
+ const removeUploadFile = async () => {
31
32
  removeFile?.(file);
32
33
  }
33
34
 
@@ -8,7 +8,7 @@
8
8
  import type {FileUpload} from "./FileUpload";
9
9
  import utils from "../common/utils";
10
10
  import ModalPopover from "../common/ModalPopover.svelte";
11
- import i18n from "@ticatec/i18n";
11
+ import i18nRes from "../i18nRes";
12
12
 
13
13
  export let accept: string = "*/*";
14
14
  export let maxSize: number = 1024 * 1024 * 10;
@@ -19,7 +19,7 @@
19
19
  export let canClose: boolean = false;
20
20
  export let visible: boolean = false;
21
21
 
22
- let btnPickup: string = i18n.getText('uniface.upload.btnPickup', "Pickup files");
22
+ let btnPickup: string = i18nRes.upload.btnPickup;
23
23
 
24
24
  let files: Array<UploadFile> = [];
25
25
  let dropZone: any;
@@ -1,3 +1,4 @@
1
+ import i18nRes from "../i18nRes";
1
2
  import i18n from "@ticatec/i18n";
2
3
  export default class DateContext {
3
4
  _weekBegin = 1;
@@ -13,16 +14,16 @@ export default class DateContext {
13
14
  return DateContext.instance;
14
15
  }
15
16
  get months() {
16
- return i18n.get("uniface.calendar.months");
17
+ return i18nRes.calendar.months;
17
18
  }
18
19
  get monthsAbbr() {
19
- return i18n.get("uniface.calendar.monthsAbbr");
20
+ return i18nRes.calendar.monthsAbbr;
20
21
  }
21
22
  get weekTitle() {
22
- return i18n.get("uniface.calendar.weekTitle");
23
+ return i18nRes.calendar.weekTitle;
23
24
  }
24
25
  get weekTitleAbbr() {
25
- return i18n.get("uniface.calendar.weekTitleAbbr");
26
+ return i18nRes.calendar.weekTitleAbbr;
26
27
  }
27
28
  set weekBegin(value) {
28
29
  if (value < 0 || value > 6) {
@@ -28,24 +28,24 @@
28
28
  const isDisabled = (y: number) => (maxYear!=null && y > maxYear) || (minYear!=null && y < minYear);
29
29
 
30
30
  </script>
31
- <div class="uniface-year-pickup-panel" on:click={onClick}>
31
+ <div class="uniface-year-pickup-panel" aria-hidden="true" on:click={onClick}>
32
32
  <div>
33
33
  <div>
34
34
  <div style="text-align: center">
35
35
  <div style="display: inline-block; width: 30px; height: 10px; padding: 6px 0">
36
- <i class="icon_google_keyboard_arrow_up" on:click={showYears(-years)}></i>
36
+ <i class="icon_google_keyboard_arrow_up" aria-hidden="true" on:click={showYears(-years)}></i>
37
37
  </div>
38
38
  </div>
39
39
  <div style="display: grid; grid-template-columns: auto auto auto auto; width: 100%; overflow: hidden">
40
40
  {#each Array(years) as _, i}
41
- <div class="year-block" on:click={handleYearClick(i)} class:disabled={isDisabled(year-offset+i)} class:selected={year===year-offset+i}>
41
+ <div class="year-block" on:click={handleYearClick(i)} aria-hidden="true" class:disabled={isDisabled(year-offset+i)} class:selected={year===year-offset+i}>
42
42
  <span>{year-offset+i}</span>
43
43
  </div>
44
44
  {/each}
45
45
  </div>
46
46
  <div style="text-align: center">
47
47
  <div style="display: inline-block; width: 30px; height: 10px; padding: 6px 0">
48
- <i class="icon_google_keyboard_arrow_down" on:click={showYears(years)}></i>
48
+ <i class="icon_google_keyboard_arrow_down" aria-hidden="true" on:click={showYears(years)}></i>
49
49
  </div>
50
50
  </div>
51
51
  </div>
@@ -9,7 +9,7 @@
9
9
  export let actions: Array<CardAction> = [];
10
10
  export let variant: 'plain' | '3d' = 'plain';
11
11
  export let iconColor: string | null = null;
12
- export let data: any;
12
+ export let data: any = null;
13
13
 
14
14
  </script>
15
15
 
@@ -23,7 +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
+ data?: any;
27
27
  }, {
28
28
  'header-bar': {};
29
29
  default: {};
@@ -134,6 +134,5 @@
134
134
  </div>
135
135
  {/if}
136
136
  </div>
137
- </CommonPicker>
138
-
139
- <!--{/if}-->
137
+ </div>
138
+ </CommonPicker>
@@ -1 +1,46 @@
1
- export {};
1
+ import { DisplayMode } from "../common/DisplayMode";
2
+ import type { OnChangeHandler } from "../common/OnChangeHandler";
3
+ import type { IsLeafDetermine } from "./isLeafDetermine";
4
+ 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
+ new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
6
+ $$bindings?: Bindings;
7
+ } & Exports;
8
+ (internal: unknown, props: Props & {
9
+ $$events?: Events;
10
+ $$slots?: Slots;
11
+ }): Exports & {
12
+ $set?: any;
13
+ $on?: any;
14
+ };
15
+ z_$$bindings?: Bindings;
16
+ }
17
+ declare const CascadeOptionSelect: $$__sveltets_2_IsomorphicComponent<{
18
+ variant?: "" | "plain" | "outlined" | "filled";
19
+ disabled?: boolean;
20
+ readonly?: boolean;
21
+ compact?: boolean;
22
+ mandatory?: boolean;
23
+ value?: any;
24
+ keyField?: string;
25
+ textField?: string;
26
+ abbrField?: string;
27
+ childrenField?: string;
28
+ style?: string;
29
+ placeholder?: string;
30
+ displayMode?: DisplayMode;
31
+ emptyText?: string | null;
32
+ checkLeaf?: IsLeafDetermine | null;
33
+ text?: string;
34
+ nodes?: Array<any>;
35
+ menu$height?: number;
36
+ onSelect: (item: any) => Promise<Array<any>>;
37
+ box$style?: string;
38
+ onChange?: OnChangeHandler<any>;
39
+ }, {
40
+ blur: FocusEvent;
41
+ focus: FocusEvent;
42
+ } & {
43
+ [evt: string]: CustomEvent<any>;
44
+ }, {}, {}, string>;
45
+ type CascadeOptionSelect = InstanceType<typeof CascadeOptionSelect>;
46
+ export default CascadeOptionSelect;
@@ -43,7 +43,7 @@
43
43
  <div style="position: absolute; top: 0; bottom: 0; left: 0; right: 0; background-color: #e1e1e110;">
44
44
  <div style="position: relative; width: 100%; height: 100%; display: flex; flex-direction: column; justify-content: center">
45
45
  <div style="width: 100px; margin: 0 auto; text-align: center; background-color: #f0f0f0; border-radius: 4px; padding: 8px 12px; box-sizing: border-box;">
46
- <img src={iconLoading} width="32" height="32"/>
46
+ <img src={iconLoading} alt="loading" width="32" height="32"/>
47
47
  </div>
48
48
  </div>
49
49
  </div>
@@ -59,7 +59,7 @@
59
59
 
60
60
  </script>
61
61
  <div class="uniface-checkbox" class:disabled class:compact {style}>
62
- <label on:click={handleClickEvent}>
62
+ <label aria-hidden="true" on:click={handleClickEvent}>
63
63
  <input bind:this={checkbox} type="checkbox" bind:checked={checked} {readonly} {disabled}/>
64
64
  {#if label}
65
65
  <span>{label}</span>
@@ -5,10 +5,10 @@
5
5
  import type {OnChangeHandler} from "../common/OnChangeHandler";
6
6
  import CommonPicker from "../common/CommonPicker.svelte";
7
7
 
8
- type OnActionHandler = () => void;
8
+ //type OnActionHandler = () => void;
9
9
 
10
- export let showHex = true;
11
- export let showRgb = false;
10
+ //export let showHex = true;
11
+ //export let showRgb = false;
12
12
 
13
13
  export let variant: '' | 'plain' | 'outlined' | 'filled' = '';
14
14
  export let disabled: boolean = false;
@@ -28,17 +28,17 @@
28
28
  let editor: any;
29
29
 
30
30
  const clean = () => {
31
-
31
+ onChange(null)
32
32
  }
33
33
 
34
- const handleActionIconClick = () => {
34
+ const handleActionIconClick = async () => {
35
35
  editor.click();
36
36
  }
37
37
 
38
- function handleColorChange(event) {
39
- selectedColor = event.target.value;
40
- rgbValues = hexToRgb(selectedColor);
41
- console.log(selectedColor, rgbValues);
38
+ function handleColorChange(event: Event) {
39
+ // selectedColor = (event.target as HTMLElement).value;
40
+ // rgbValues = hexToRgb(selectedColor);
41
+ // console.log(selectedColor, rgbValues);
42
42
  // dispatch('change', {
43
43
  // hex: selectedColor,
44
44
  // rgb: rgbValues
@@ -13,8 +13,6 @@ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> =
13
13
  z_$$bindings?: Bindings;
14
14
  }
15
15
  declare const ColorPicker: $$__sveltets_2_IsomorphicComponent<{
16
- showHex?: boolean;
17
- showRgb?: boolean;
18
16
  variant?: "" | "plain" | "outlined" | "filled";
19
17
  disabled?: boolean;
20
18
  readonly?: boolean;
@@ -1,21 +1,19 @@
1
1
  <script lang="ts">
2
2
 
3
3
 
4
- // Define props with default values
5
- import i18n from "@ticatec/i18n";
6
- import langRes from "../i18n_resources/uniface_en_resource";
4
+ import i18nRes from "../i18nRes";
7
5
 
8
6
  export let initialColor = "#ffffff";
9
7
  export let showHex = true;
10
8
  export let showRgb = false;
11
- export let swatches = [];
9
+ export let swatches: Array<any> = [];
12
10
 
13
11
  let selectedColor = initialColor;
14
12
  let rgbValues = hexToRgb(initialColor);
15
13
 
16
14
 
17
15
  // Convert hex to RGB
18
- function hexToRgb(hex) {
16
+ function hexToRgb(hex: string) {
19
17
  const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
20
18
  return result ? {
21
19
  r: parseInt(result[1], 16),
@@ -25,17 +23,17 @@
25
23
  }
26
24
 
27
25
  // Emit change event when color changes
28
- function handleColorChange(event) {
29
- selectedColor = event.target.value;
26
+ function handleColorChange(event: Event) {
27
+ selectedColor = "0x000000"; //event.target?.value;
30
28
  rgbValues = hexToRgb(selectedColor);
31
- dispatch('change', {
32
- hex: selectedColor,
33
- rgb: rgbValues
34
- });
29
+ // dispatch('change', {
30
+ // hex: selectedColor,
31
+ // rgb: rgbValues
32
+ // });
35
33
  }
36
34
 
37
35
  // Select a swatch
38
- function selectSwatch(color) {
36
+ function selectSwatch(color: any) {
39
37
  selectedColor = color;
40
38
  rgbValues = hexToRgb(selectedColor);
41
39
  // dispatch('change', {
@@ -47,8 +45,7 @@
47
45
 
48
46
  <div class="color-picker">
49
47
  <label for="color-input">
50
- {i18n.getText('uniface.pickupColor', langRes.uniface.colorPicker)
51
- }
48
+ {i18nRes.pickupColor}
52
49
  </label>
53
50
 
54
51
  <div class="color-input-group">
@@ -116,7 +113,6 @@
116
113
  }
117
114
 
118
115
  input[type="color"] {
119
- -webkit-appearance: none;
120
116
  width: 40px;
121
117
  height: 40px;
122
118
  border: none;
@@ -15,7 +15,7 @@ declare const ColorPickerPanel: $$__sveltets_2_IsomorphicComponent<{
15
15
  initialColor?: string;
16
16
  showHex?: boolean;
17
17
  showRgb?: boolean;
18
- swatches?: any[];
18
+ swatches?: Array<any>;
19
19
  }, {
20
20
  [evt: string]: CustomEvent<any>;
21
21
  }, {}, {}, string>;
@@ -15,7 +15,7 @@
15
15
  export let autoFit: boolean = true;
16
16
  export let canClean: boolean;
17
17
  export let textValue: string;
18
- export let dropDownIcon: string | null = null;
18
+ export let dropDownIcon: string = null as unknown as string;
19
19
  export let clean: () => void;
20
20
  export let iconClickHandler: MouseClickHandler = null as unknown as MouseClickHandler;
21
21
  export let showPopup: boolean = false;
@@ -58,7 +58,7 @@
58
58
  {/if}
59
59
  </div>
60
60
  {#if showPopup}
61
- <Popover target={editorElement} on:close={()=>{showPopup=false}} {autoFit}>
61
+ <Popover target={editorElement} onClose={()=>{showPopup=false}} {autoFit}>
62
62
  <slot name="popup-panel"></slot>
63
63
  </Popover>
64
64
  {/if}
@@ -29,7 +29,7 @@ declare const CommonPicker: $$__sveltets_2_IsomorphicComponent<$$__sveltets_2_Pr
29
29
  autoFit?: boolean;
30
30
  canClean: boolean;
31
31
  textValue: string;
32
- dropDownIcon?: string | null;
32
+ dropDownIcon?: string;
33
33
  clean: () => void;
34
34
  iconClickHandler?: MouseClickHandler;
35
35
  showPopup?: boolean;
@@ -1,10 +1,33 @@
1
1
 
2
2
  <script lang="ts">
3
- import {createEventDispatcher, onMount} from 'svelte';
4
- import {clickOutside} from './uniface-utils';
3
+ import { onDestroy, onMount} from 'svelte';
5
4
  import Portal from "svelte-portal";
6
5
 
7
- const dispatch = createEventDispatcher();
6
+ export let onClose: (()=>void) | null = null;
7
+
8
+ export function outerClick(node: HTMLElement, callback: () => void) {
9
+ const handleClick = (event: MouseEvent) => {
10
+ // 如果点击目标不在node内,则触发回调
11
+ if (!node.contains(event.target as Node)) {
12
+ callback();
13
+ }
14
+ };
15
+
16
+ // 监听全局点击事件(useCapture=true,避免事件冒泡造成的问题)
17
+ document.addEventListener('click', handleClick, true);
18
+
19
+ // 清理事件监听器
20
+ onDestroy(() => {
21
+ document.removeEventListener('click', handleClick, true);
22
+ });
23
+
24
+ // action 必须返回一个对象,可以选实现 update 和 destroy
25
+ return {
26
+ destroy() {
27
+ document.removeEventListener('click', handleClick, true);
28
+ }
29
+ };
30
+ }
8
31
 
9
32
  export let style: string = '';
10
33
  export let target: any;
@@ -89,7 +112,7 @@
89
112
  });
90
113
 
91
114
  const close = () => {
92
- dispatch('close');
115
+ onClose?.();
93
116
  };
94
117
 
95
118
  let contentPanel: any;
@@ -103,8 +126,7 @@
103
126
  <svelte:window bind:innerWidth={w} bind:innerHeight={h}/>
104
127
  <Portal target="body">
105
128
  <div class="uniface-popover-wrapper" class:hidden style="{vertPos}; height: auto; left: {position.left-margin}px; width: {position.width}px; ">
106
- <div class="uniface-popover" use:clickOutside
107
- on:outerClick={close}>
129
+ <div class="uniface-popover" use:outerClick={close}>
108
130
  <div bind:this={contentPanel} style="{horzPos}">
109
131
  <div class="contents" style="{style}">
110
132
  <div class="contents-inner">
@@ -17,6 +17,10 @@ type $$__sveltets_2_PropsWithChildren<Props, Slots> = Props & (Slots extends {
17
17
  children?: any;
18
18
  } : {});
19
19
  declare const Popover: $$__sveltets_2_IsomorphicComponent<$$__sveltets_2_PropsWithChildren<{
20
+ onClose?: (() => void) | null;
21
+ outerClick?: (node: HTMLElement, callback: () => void) => {
22
+ destroy(): void;
23
+ };
20
24
  style?: string;
21
25
  target: any;
22
26
  align?: "left" | "right" | "center";
@@ -25,11 +29,13 @@ declare const Popover: $$__sveltets_2_IsomorphicComponent<$$__sveltets_2_PropsWi
25
29
  }, {
26
30
  default: {};
27
31
  }>, {
28
- close: CustomEvent<any>;
29
- } & {
30
32
  [evt: string]: CustomEvent<any>;
31
33
  }, {
32
34
  default: {};
33
- }, {}, string>;
35
+ }, {
36
+ outerClick: (node: HTMLElement, callback: () => void) => {
37
+ destroy(): void;
38
+ };
39
+ }, string>;
34
40
  type Popover = InstanceType<typeof Popover>;
35
41
  export default Popover;