@ticatec/uniface-element 0.2.0 → 0.2.1

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 (126) hide show
  1. package/README.md +273 -1
  2. package/README_CN.md +341 -0
  3. package/dist/common/MouseClickHandler.d.ts +1 -1
  4. package/dist/dialog/CommonDialog.svelte +6 -3
  5. package/dist/dialog/CommonDialog.svelte.d.ts +2 -1
  6. package/dist/dialog/Dialog.svelte +36 -10
  7. package/dist/dialog/Dialog.svelte.d.ts +4 -3
  8. package/dist/dialog/DialogBoard.svelte +11 -8
  9. package/dist/dialog/DialogWrapper.svelte +10 -0
  10. package/dist/dialog/DialogWrapper.svelte.d.ts +22 -0
  11. package/dist/dialog/Dialogs.js +1 -1
  12. package/dist/dialog/ModalResult.d.ts +5 -0
  13. package/dist/dialog/ModalResult.js +5 -0
  14. package/docs/buttons/cn/ActionBar.md +459 -0
  15. package/docs/buttons/cn/Button.md +228 -0
  16. package/docs/buttons/cn/IconButton.md +294 -0
  17. package/docs/buttons/cn/README.md +600 -0
  18. package/docs/buttons/cn/TextButton.md +163 -0
  19. package/docs/buttons/en/ActionBar.md +459 -0
  20. package/docs/buttons/en/Button.md +228 -0
  21. package/docs/buttons/en/IconButton.md +294 -0
  22. package/docs/buttons/en/README.md +600 -0
  23. package/docs/buttons/en/TextButton.md +163 -0
  24. package/docs/containers/cn/accordion.md +622 -0
  25. package/docs/containers/cn/box.md +445 -0
  26. package/docs/containers/cn/card.md +404 -0
  27. package/docs/containers/cn/page.md +576 -0
  28. package/docs/containers/cn/tabs.md +686 -0
  29. package/docs/containers/en/accordion.md +622 -0
  30. package/docs/containers/en/box.md +445 -0
  31. package/docs/containers/en/card.md +404 -0
  32. package/docs/containers/en/page.md +576 -0
  33. package/docs/containers/en/tabs.md +686 -0
  34. package/docs/data-display/cn/concise-data-table.md +731 -0
  35. package/docs/data-display/cn/listbox.md +786 -0
  36. package/docs/data-display/cn/treeview.md +863 -0
  37. package/docs/data-display/en/concise-data-table.md +732 -0
  38. package/docs/data-display/en/listbox.md +786 -0
  39. package/docs/data-display/en/treeview.md +863 -0
  40. package/docs/data-table/cn/README.md +596 -0
  41. package/docs/data-table/en/README.md +596 -0
  42. package/docs/dialog/cn/README.md +767 -0
  43. package/docs/dialog/en/README.md +767 -0
  44. package/docs/form/cn/README.md +847 -0
  45. package/docs/form/en/README.md +847 -0
  46. package/docs/form-components/cn/README.md +495 -0
  47. package/docs/form-components/cn/attachmentfilesfield.md +757 -0
  48. package/docs/form-components/cn/cascade-options-select.md +374 -0
  49. package/docs/form-components/cn/checkbox.md +58 -0
  50. package/docs/form-components/cn/date-picker.md +138 -0
  51. package/docs/form-components/cn/datetime-picker.md +228 -0
  52. package/docs/form-components/cn/group-checkbox.md +405 -0
  53. package/docs/form-components/cn/group-radiobox.md +525 -0
  54. package/docs/form-components/cn/imagefilesfield.md +651 -0
  55. package/docs/form-components/cn/input-options-select.md +250 -0
  56. package/docs/form-components/cn/lookup-editor.md +406 -0
  57. package/docs/form-components/cn/memoeditor.md +409 -0
  58. package/docs/form-components/cn/number-editor.md +261 -0
  59. package/docs/form-components/cn/options-multi-select.md +177 -0
  60. package/docs/form-components/cn/options-select.md +83 -0
  61. package/docs/form-components/cn/passwordeditor.md +538 -0
  62. package/docs/form-components/cn/prompts-text-editor.md +241 -0
  63. package/docs/form-components/cn/radiobutton.md +84 -0
  64. package/docs/form-components/cn/switch.md +178 -0
  65. package/docs/form-components/cn/text-editor.md +142 -0
  66. package/docs/form-components/cn/time-editor.md +159 -0
  67. package/docs/form-components/cn/unit-number-editor.md +164 -0
  68. package/docs/form-components/en/README.md +463 -0
  69. package/docs/form-components/en/attachmentfilesfield.md +757 -0
  70. package/docs/form-components/en/cascade-options-select.md +358 -0
  71. package/docs/form-components/en/checkbox.md +59 -0
  72. package/docs/form-components/en/date-picker.md +138 -0
  73. package/docs/form-components/en/datetime-picker.md +228 -0
  74. package/docs/form-components/en/group-checkbox.md +395 -0
  75. package/docs/form-components/en/group-radiobox.md +498 -0
  76. package/docs/form-components/en/imagefilesfield.md +651 -0
  77. package/docs/form-components/en/input-options-select.md +239 -0
  78. package/docs/form-components/en/lookup-editor.md +389 -0
  79. package/docs/form-components/en/memoeditor.md +409 -0
  80. package/docs/form-components/en/number-editor.md +249 -0
  81. package/docs/form-components/en/options-multi-select.md +177 -0
  82. package/docs/form-components/en/options-select.md +83 -0
  83. package/docs/form-components/en/passwordeditor.md +538 -0
  84. package/docs/form-components/en/prompts-text-editor.md +241 -0
  85. package/docs/form-components/en/radiobutton.md +84 -0
  86. package/docs/form-components/en/switch.md +180 -0
  87. package/docs/form-components/en/text-editor.md +142 -0
  88. package/docs/form-components/en/time-editor.md +159 -0
  89. package/docs/form-components/en/unit-number-editor.md +164 -0
  90. package/docs/form-layout/cn/criteria-field.md +652 -0
  91. package/docs/form-layout/cn/flex-form.md +454 -0
  92. package/docs/form-layout/cn/flex-row-form.md +542 -0
  93. package/docs/form-layout/cn/form-field.md +923 -0
  94. package/docs/form-layout/cn/grid-form.md +676 -0
  95. package/docs/form-layout/en/criteria-field.md +652 -0
  96. package/docs/form-layout/en/flex-form.md +454 -0
  97. package/docs/form-layout/en/flex-row-form.md +542 -0
  98. package/docs/form-layout/en/form-field.md +923 -0
  99. package/docs/form-layout/en/grid-form.md +676 -0
  100. package/docs/global/cn/README.md +534 -0
  101. package/docs/global/en/README.md +534 -0
  102. package/docs/layout/cn/classiclayout.md +460 -0
  103. package/docs/layout/cn/headerlayout.md +524 -0
  104. package/docs/layout/cn/sidebarlayout.md +263 -0
  105. package/docs/layout/en/classiclayout.md +951 -0
  106. package/docs/layout/en/headerlayout.md +524 -0
  107. package/docs/layout/en/sidebarlayout.md +262 -0
  108. package/docs/misc/cn/README.md +1217 -0
  109. package/docs/misc/en/README.md +1217 -0
  110. package/docs/navigation/cn/breadcrumb.md +291 -0
  111. package/docs/navigation/cn/navigator.md +322 -0
  112. package/docs/navigation/cn/navigatormenu.md +512 -0
  113. package/docs/navigation/cn/progressbar.md +199 -0
  114. package/docs/navigation/cn/progressstepbar.md +299 -0
  115. package/docs/navigation/en/breadcrumb.md +291 -0
  116. package/docs/navigation/en/navigator.md +322 -0
  117. package/docs/navigation/en/navigatormenu.md +512 -0
  118. package/docs/navigation/en/progressbar.md +199 -0
  119. package/docs/navigation/en/progressstepbar.md +299 -0
  120. package/docs/search-filters/cn/daterange.md +1156 -0
  121. package/docs/search-filters/cn/numberrange.md +688 -0
  122. package/docs/search-filters/cn/searchbox.md +1582 -0
  123. package/docs/search-filters/en/daterange.md +1156 -0
  124. package/docs/search-filters/en/numberrange.md +688 -0
  125. package/docs/search-filters/en/searchbox.md +1582 -0
  126. package/package.json +38 -5
@@ -0,0 +1,159 @@
1
+ # TimeEditor 组件
2
+
3
+ 时间输入组件,支持小时和分钟的选择。
4
+
5
+ ## 属性
6
+
7
+ | 属性 | 类型 | 默认值 | 描述 |
8
+ |------|------|--------|------|
9
+ | `variant` | `'' \| 'plain' \| 'outlined' \| 'filled'` | `''` | 外观变体 |
10
+ | `disabled` | `boolean` | `false` | 是否禁用 |
11
+ | `readonly` | `boolean` | `false` | 是否只读 |
12
+ | `compact` | `boolean` | `false` | 是否紧凑模式 |
13
+ | `value` | `string` | `''` | 时间值(格式:HH:MM) |
14
+ | `placeholder` | `string` | `''` | 占位符文本 |
15
+ | `displayMode` | `DisplayMode` | `DisplayMode.Edit` | 显示模式 |
16
+ | `format24h` | `boolean` | `true` | 是否使用24小时格式 |
17
+ | `minuteStep` | `number` | `1` | 分钟步长 |
18
+ | `style` | `string` | `''` | 自定义样式 |
19
+ | `onChange` | `OnChangeHandler<string>` | - | 值变化回调 |
20
+
21
+ ## 使用示例
22
+
23
+ ```svelte
24
+ <script lang="ts">
25
+ import TimeEditor from '@ticatec/uniface-element/TimeEditor';
26
+
27
+ let startTime: string = '09:00';
28
+ let endTime: string = '17:30';
29
+
30
+ const handleStartTimeChange = (value: string) => {
31
+ startTime = value;
32
+ console.log('开始时间:', value);
33
+ };
34
+
35
+ const handleEndTimeChange = (value: string) => {
36
+ endTime = value;
37
+ console.log('结束时间:', value);
38
+ };
39
+ </script>
40
+
41
+ <!-- 开始时间 -->
42
+ <TimeEditor
43
+ placeholder="请选择开始时间"
44
+ bind:value={startTime}
45
+ onChange={handleStartTimeChange}
46
+ />
47
+
48
+ <!-- 结束时间(15分钟间隔) -->
49
+ <TimeEditor
50
+ placeholder="请选择结束时间"
51
+ minuteStep={15}
52
+ bind:value={endTime}
53
+ onChange={handleEndTimeChange}
54
+ />
55
+ ```
56
+
57
+ ## 高级用法
58
+
59
+ ### 工作时间设置
60
+ ```svelte
61
+ <script lang="ts">
62
+ interface WorkingHours {
63
+ start: string;
64
+ end: string;
65
+ break_start: string;
66
+ break_end: string;
67
+ }
68
+
69
+ let workingHours: WorkingHours = {
70
+ start: '09:00',
71
+ end: '18:00',
72
+ break_start: '12:00',
73
+ break_end: '13:00'
74
+ };
75
+
76
+ const updateWorkingHours = (field: keyof WorkingHours) => (value: string) => {
77
+ workingHours = { ...workingHours, [field]: value };
78
+ };
79
+ </script>
80
+
81
+ <div class="working-hours">
82
+ <div class="time-range">
83
+ <label>工作时间:</label>
84
+ <TimeEditor
85
+ placeholder="开始时间"
86
+ minuteStep={30}
87
+ bind:value={workingHours.start}
88
+ onChange={updateWorkingHours('start')}
89
+ />
90
+ <span>至</span>
91
+ <TimeEditor
92
+ placeholder="结束时间"
93
+ minuteStep={30}
94
+ bind:value={workingHours.end}
95
+ onChange={updateWorkingHours('end')}
96
+ />
97
+ </div>
98
+
99
+ <div class="time-range">
100
+ <label>休息时间:</label>
101
+ <TimeEditor
102
+ placeholder="开始时间"
103
+ minuteStep={15}
104
+ bind:value={workingHours.break_start}
105
+ onChange={updateWorkingHours('break_start')}
106
+ />
107
+ <span>至</span>
108
+ <TimeEditor
109
+ placeholder="结束时间"
110
+ minuteStep={15}
111
+ bind:value={workingHours.break_end}
112
+ onChange={updateWorkingHours('break_end')}
113
+ />
114
+ </div>
115
+ </div>
116
+ ```
117
+
118
+ ## 最佳实践
119
+
120
+ ### 1. 设置合适的步长
121
+ ```svelte
122
+ <!-- 会议时间:15分钟间隔 -->
123
+ <TimeEditor minuteStep={15} />
124
+
125
+ <!-- 工作班次:30分钟间隔 -->
126
+ <TimeEditor minuteStep={30} />
127
+
128
+ <!-- 精确时间:1分钟间隔 -->
129
+ <TimeEditor minuteStep={1} />
130
+ ```
131
+
132
+ ### 2. 时间范围验证
133
+ ```svelte
134
+ <script lang="ts">
135
+ let startTime: string = '';
136
+ let endTime: string = '';
137
+ let timeError: string = '';
138
+
139
+ const validateTimeRange = (start: string, end: string): void => {
140
+ if (start && end) {
141
+ const startMinutes = timeToMinutes(start);
142
+ const endMinutes = timeToMinutes(end);
143
+
144
+ if (startMinutes >= endMinutes) {
145
+ timeError = '结束时间必须晚于开始时间';
146
+ } else {
147
+ timeError = '';
148
+ }
149
+ }
150
+ };
151
+
152
+ const timeToMinutes = (time: string): number => {
153
+ const [hours, minutes] = time.split(':').map(Number);
154
+ return hours * 60 + minutes;
155
+ };
156
+
157
+ $: validateTimeRange(startTime, endTime);
158
+ </script>
159
+ ```
@@ -0,0 +1,164 @@
1
+ # UnitNumberEditor 组件
2
+
3
+ 带单位的数字输入组件,允许用户选择不同的计量单位。
4
+
5
+ ## 类型定义
6
+
7
+ ```typescript
8
+ interface UnitOption {
9
+ code: string;
10
+ text: string;
11
+ ratio: number; // 与基础单位的换算比例
12
+ }
13
+ ```
14
+
15
+ ## 属性
16
+
17
+ | 属性 | 类型 | 默认值 | 描述 |
18
+ |------|------|--------|------|
19
+ | `variant` | `'' \| 'plain' \| 'outlined' \| 'filled'` | `''` | 外观变体 |
20
+ | `disabled` | `boolean` | `false` | 是否禁用 |
21
+ | `readonly` | `boolean` | `false` | 是否只读 |
22
+ | `compact` | `boolean` | `false` | 是否紧凑模式 |
23
+ | `value` | `number \| null` | `null` | 数值 |
24
+ | `unit` | `string` | `''` | 当前选择的单位代码 |
25
+ | `units` | `UnitOption[]` | `[]` | 可用单位选项 |
26
+ | `placeholder` | `string` | `''` | 占位符文本 |
27
+ | `displayMode` | `DisplayMode` | `DisplayMode.Edit` | 显示模式 |
28
+ | `precision` | `number \| null` | `null` | 小数位数 |
29
+ | `style` | `string` | `''` | 自定义样式 |
30
+ | `onChange` | `OnChangeHandler<{value: number, unit: string}>` | - | 值变化回调 |
31
+
32
+ ## 使用示例
33
+
34
+ ```svelte
35
+ <script lang="ts">
36
+ import UnitNumberEditor, { type UnitOption } from '@ticatec/uniface-element/UnitNumberEditor';
37
+
38
+ // 重量单位选项
39
+ const weightUnits: UnitOption[] = [
40
+ { code: 'kg', text: '千克', ratio: 1 },
41
+ { code: 'g', text: '克', ratio: 0.001 },
42
+ { code: 'lb', text: '磅', ratio: 0.453592 }
43
+ ];
44
+
45
+ // 距离单位选项
46
+ const distanceUnits: UnitOption[] = [
47
+ { code: 'm', text: '米', ratio: 1 },
48
+ { code: 'cm', text: '厘米', ratio: 0.01 },
49
+ { code: 'km', text: '公里', ratio: 1000 },
50
+ { code: 'in', text: '英寸', ratio: 0.0254 }
51
+ ];
52
+
53
+ let weight: number | null = null;
54
+ let weightUnit: string = 'kg';
55
+ let distance: number | null = null;
56
+ let distanceUnit: string = 'm';
57
+
58
+ interface UnitValue {
59
+ value: number;
60
+ unit: string;
61
+ }
62
+
63
+ const handleWeightChange = ({value, unit}: UnitValue): void => {
64
+ weight = value;
65
+ weightUnit = unit;
66
+ console.log(`重量: ${value} ${unit}`);
67
+ };
68
+
69
+ const handleDistanceChange = ({value, unit}: UnitValue): void => {
70
+ distance = value;
71
+ distanceUnit = unit;
72
+ console.log(`距离: ${value} ${unit}`);
73
+ };
74
+ </script>
75
+
76
+ <!-- 重量输入 -->
77
+ <UnitNumberEditor
78
+ placeholder="请输入重量"
79
+ units={weightUnits}
80
+ precision={2}
81
+ bind:value={weight}
82
+ bind:unit={weightUnit}
83
+ onChange={handleWeightChange}
84
+ />
85
+
86
+ <!-- 距离输入 -->
87
+ <UnitNumberEditor
88
+ placeholder="请输入距离"
89
+ units={distanceUnits}
90
+ precision={2}
91
+ bind:value={distance}
92
+ bind:unit={distanceUnit}
93
+ onChange={handleDistanceChange}
94
+ />
95
+ ```
96
+
97
+ ## 高级用法
98
+
99
+ ### 单位换算
100
+ ```svelte
101
+ <script lang="ts">
102
+ let inputValue: number | null = null;
103
+ let inputUnit: string = 'kg';
104
+ let baseValue: number | null = null; // 基础单位值
105
+
106
+ const convertToBase = (value: number, unit: string, units: UnitOption[]): number => {
107
+ const unitOption = units.find(u => u.code === unit);
108
+ return value * (unitOption?.ratio || 1);
109
+ };
110
+
111
+ const handleValueChange = ({value, unit}: UnitValue): void => {
112
+ inputValue = value;
113
+ inputUnit = unit;
114
+
115
+ if (value !== null) {
116
+ baseValue = convertToBase(value, unit, weightUnits);
117
+ console.log(`基础值: ${baseValue} kg`);
118
+ } else {
119
+ baseValue = null;
120
+ }
121
+ };
122
+ </script>
123
+
124
+ <UnitNumberEditor
125
+ placeholder="请输入重量"
126
+ units={weightUnits}
127
+ precision={3}
128
+ bind:value={inputValue}
129
+ bind:unit={inputUnit}
130
+ onChange={handleValueChange}
131
+ />
132
+
133
+ {#if baseValue !== null}
134
+ <p>等于: {baseValue.toFixed(3)} kg</p>
135
+ {/if}
136
+ ```
137
+
138
+ ## 最佳实践
139
+
140
+ ### 1. 合理设置精度
141
+ ```svelte
142
+ <!-- 重量:3位小数 -->
143
+ <UnitNumberEditor units={weightUnits} precision={3} />
144
+
145
+ <!-- 距离:2位小数 -->
146
+ <UnitNumberEditor units={distanceUnits} precision={2} />
147
+
148
+ <!-- 温度:1位小数 -->
149
+ <UnitNumberEditor units={temperatureUnits} precision={1} />
150
+ ```
151
+
152
+ ### 2. 提供常用单位
153
+ ```svelte
154
+ <script lang="ts">
155
+ // 按使用频率排序
156
+ const lengthUnits: UnitOption[] = [
157
+ { code: 'm', text: '米', ratio: 1 }, // 最常用
158
+ { code: 'cm', text: '厘米', ratio: 0.01 }, // 常用
159
+ { code: 'mm', text: '毫米', ratio: 0.001 }, // 常用
160
+ { code: 'km', text: '公里', ratio: 1000 }, // 较少用
161
+ { code: 'in', text: '英寸', ratio: 0.0254 } // 特殊需求
162
+ ];
163
+ </script>
164
+ ```