@ticatec/uniface-element 0.2.0 → 0.2.2

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 (209) hide show
  1. package/README.md +320 -1
  2. package/README_CN.md +392 -0
  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/MouseClickHandler.d.ts +1 -1
  23. package/dist/common/Popover.svelte +28 -6
  24. package/dist/common/Popover.svelte.d.ts +9 -3
  25. package/dist/common/uniface-utils.js +6 -4
  26. package/dist/common-editor/CommonEditor.svelte +1 -1
  27. package/dist/common-editor/CommonEditor.svelte.d.ts +1 -1
  28. package/dist/common-editor/NumberInput.svelte +1 -1
  29. package/dist/common-editor/NumberInput.svelte.d.ts +1 -1
  30. package/dist/concise-data-table/ConciseListTable.svelte +7 -2
  31. package/dist/concise-data-table/ConciseListTable.svelte.d.ts +1 -0
  32. package/dist/concise-data-table/DataRow.svelte +1 -1
  33. package/dist/concise-data-table/TableOptions.d.ts +1 -1
  34. package/dist/data-table/DataTable.svelte +1 -1
  35. package/dist/data-table/parts/ActionsPanel.svelte +4 -3
  36. package/dist/data-table/parts/ActionsRow.svelte +3 -3
  37. package/dist/data-table/parts/ContentPanel.svelte +3 -2
  38. package/dist/data-table/parts/FixedColumnsPanel.svelte +0 -1
  39. package/dist/data-table/parts/FixedColumnsPanel.svelte.d.ts +1 -2
  40. package/dist/data-table/parts/FixedHeaderPanel.svelte +2 -2
  41. package/dist/data-table/parts/FixedRow.svelte +2 -1
  42. package/dist/data-table/parts/FixedRow.svelte.d.ts +1 -1
  43. package/dist/data-table/parts/HrefCell.svelte +23 -2
  44. package/dist/data-table/parts/PopupMenu.svelte +25 -2
  45. package/dist/data-table/parts/PopupMenu.svelte.d.ts +8 -1
  46. package/dist/date-picker/DatePicker.svelte +0 -1
  47. package/dist/date-picker/DateTimePicker.svelte +3 -3
  48. package/dist/date-picker/ScrollBar.svelte +4 -7
  49. package/dist/date-range/DateRangeEditor.svelte +1 -1
  50. package/dist/dialog/CommonDialog.svelte +8 -5
  51. package/dist/dialog/CommonDialog.svelte.d.ts +2 -1
  52. package/dist/dialog/Dialog.svelte +37 -12
  53. package/dist/dialog/Dialog.svelte.d.ts +4 -3
  54. package/dist/dialog/DialogBoard.svelte +11 -8
  55. package/dist/dialog/DialogWrapper.svelte +10 -0
  56. package/dist/{common-editor/DateInput.svelte.d.ts → dialog/DialogWrapper.svelte.d.ts} +6 -13
  57. package/dist/dialog/Dialogs.js +1 -1
  58. package/dist/dialog/ModalResult.d.ts +5 -0
  59. package/dist/dialog/ModalResult.js +5 -0
  60. package/dist/drawer/Drawer.svelte +1 -1
  61. package/dist/form-field/FormField.svelte +2 -1
  62. package/dist/form-field/FormField.svelte.d.ts +1 -0
  63. package/dist/form-panel/flex-row-form/FormContainer.svelte +1 -1
  64. package/dist/form-panel/grid-form/EmptyCell.svelte +8 -7
  65. package/dist/form-panel/grid-form/EmptyCell.svelte.d.ts +2 -2
  66. package/dist/form-panel/grid-form/GridField.svelte +1 -1
  67. package/dist/i18nRes/i18nRes.d.ts +2 -0
  68. package/dist/i18nRes/i18nRes.js +44 -0
  69. package/dist/i18nRes/index.d.ts +2 -0
  70. package/dist/i18nRes/index.js +2 -0
  71. package/dist/image-files/ImageFilesField.svelte +1 -1
  72. package/dist/indicator/IndicatorBoard.svelte +1 -1
  73. package/dist/inline-cell-editor/InvalidEditor.svelte +1 -0
  74. package/dist/input-options-select/InputOptionsSelect.svelte +6 -6
  75. package/dist/input-options-select/InputOptionsSelect.svelte.d.ts +1 -1
  76. package/dist/layout/flex/FlexBlock.svelte +1 -1
  77. package/dist/lookup-editor/LookupEditor.svelte +1 -1
  78. package/dist/memo-editor/MemoEditor.svelte +2 -2
  79. package/dist/message-box/IMessageBox.d.ts +2 -4
  80. package/dist/message-box/IMessageBox.js +4 -6
  81. package/dist/message-box/MessageBoxBoard.svelte +1 -3
  82. package/dist/options-multi-select/OptionsMultiSelect.svelte +1 -1
  83. package/dist/prompts-text-editor/PromptsTextEditor.svelte +2 -2
  84. package/dist/prompts-text-editor/PromptsTextEditor.svelte.d.ts +1 -1
  85. package/dist/property-editor/PropertyEditor.svelte +3 -3
  86. package/dist/text-editor/PasswordEditor.svelte +1 -1
  87. package/dist/transfer/Transfer.svelte +17 -12
  88. package/dist/transfer/Transfer.svelte.d.ts +0 -1
  89. package/dist/unit-number-editor/UnitNumberEditor.svelte +2 -2
  90. package/docs/buttons/cn/ActionBar.md +459 -0
  91. package/docs/buttons/cn/Button.md +228 -0
  92. package/docs/buttons/cn/IconButton.md +294 -0
  93. package/docs/buttons/cn/README.md +600 -0
  94. package/docs/buttons/cn/TextButton.md +163 -0
  95. package/docs/buttons/en/ActionBar.md +459 -0
  96. package/docs/buttons/en/Button.md +228 -0
  97. package/docs/buttons/en/IconButton.md +294 -0
  98. package/docs/buttons/en/README.md +600 -0
  99. package/docs/buttons/en/TextButton.md +163 -0
  100. package/docs/containers/cn/accordion.md +622 -0
  101. package/docs/containers/cn/box.md +445 -0
  102. package/docs/containers/cn/card.md +404 -0
  103. package/docs/containers/cn/page.md +576 -0
  104. package/docs/containers/cn/tabs.md +686 -0
  105. package/docs/containers/en/accordion.md +622 -0
  106. package/docs/containers/en/box.md +445 -0
  107. package/docs/containers/en/card.md +404 -0
  108. package/docs/containers/en/page.md +576 -0
  109. package/docs/containers/en/tabs.md +686 -0
  110. package/docs/data-display/cn/concise-data-table.md +731 -0
  111. package/docs/data-display/cn/listbox.md +786 -0
  112. package/docs/data-display/cn/treeview.md +863 -0
  113. package/docs/data-display/en/concise-data-table.md +732 -0
  114. package/docs/data-display/en/listbox.md +786 -0
  115. package/docs/data-display/en/treeview.md +863 -0
  116. package/docs/data-table/cn/README.md +596 -0
  117. package/docs/data-table/en/README.md +596 -0
  118. package/docs/dialog/cn/README.md +767 -0
  119. package/docs/dialog/en/README.md +767 -0
  120. package/docs/form/cn/README.md +847 -0
  121. package/docs/form/en/README.md +847 -0
  122. package/docs/form-components/cn/README.md +495 -0
  123. package/docs/form-components/cn/attachmentfilesfield.md +757 -0
  124. package/docs/form-components/cn/cascade-options-select.md +374 -0
  125. package/docs/form-components/cn/checkbox.md +58 -0
  126. package/docs/form-components/cn/date-picker.md +138 -0
  127. package/docs/form-components/cn/datetime-picker.md +228 -0
  128. package/docs/form-components/cn/group-checkbox.md +405 -0
  129. package/docs/form-components/cn/group-radiobox.md +525 -0
  130. package/docs/form-components/cn/imagefilesfield.md +651 -0
  131. package/docs/form-components/cn/input-options-select.md +250 -0
  132. package/docs/form-components/cn/lookup-editor.md +406 -0
  133. package/docs/form-components/cn/memoeditor.md +409 -0
  134. package/docs/form-components/cn/number-editor.md +261 -0
  135. package/docs/form-components/cn/options-multi-select.md +177 -0
  136. package/docs/form-components/cn/options-select.md +83 -0
  137. package/docs/form-components/cn/passwordeditor.md +538 -0
  138. package/docs/form-components/cn/prompts-text-editor.md +241 -0
  139. package/docs/form-components/cn/radiobutton.md +84 -0
  140. package/docs/form-components/cn/switch.md +178 -0
  141. package/docs/form-components/cn/text-editor.md +142 -0
  142. package/docs/form-components/cn/time-editor.md +159 -0
  143. package/docs/form-components/cn/unit-number-editor.md +164 -0
  144. package/docs/form-components/en/README.md +463 -0
  145. package/docs/form-components/en/attachmentfilesfield.md +757 -0
  146. package/docs/form-components/en/cascade-options-select.md +358 -0
  147. package/docs/form-components/en/checkbox.md +59 -0
  148. package/docs/form-components/en/date-picker.md +138 -0
  149. package/docs/form-components/en/datetime-picker.md +228 -0
  150. package/docs/form-components/en/group-checkbox.md +395 -0
  151. package/docs/form-components/en/group-radiobox.md +498 -0
  152. package/docs/form-components/en/imagefilesfield.md +651 -0
  153. package/docs/form-components/en/input-options-select.md +239 -0
  154. package/docs/form-components/en/lookup-editor.md +389 -0
  155. package/docs/form-components/en/memoeditor.md +409 -0
  156. package/docs/form-components/en/number-editor.md +249 -0
  157. package/docs/form-components/en/options-multi-select.md +177 -0
  158. package/docs/form-components/en/options-select.md +83 -0
  159. package/docs/form-components/en/passwordeditor.md +538 -0
  160. package/docs/form-components/en/prompts-text-editor.md +241 -0
  161. package/docs/form-components/en/radiobutton.md +84 -0
  162. package/docs/form-components/en/switch.md +180 -0
  163. package/docs/form-components/en/text-editor.md +142 -0
  164. package/docs/form-components/en/time-editor.md +159 -0
  165. package/docs/form-components/en/unit-number-editor.md +164 -0
  166. package/docs/form-layout/cn/criteria-field.md +652 -0
  167. package/docs/form-layout/cn/flex-form.md +454 -0
  168. package/docs/form-layout/cn/flex-row-form.md +542 -0
  169. package/docs/form-layout/cn/form-field.md +923 -0
  170. package/docs/form-layout/cn/grid-form.md +676 -0
  171. package/docs/form-layout/en/criteria-field.md +652 -0
  172. package/docs/form-layout/en/flex-form.md +454 -0
  173. package/docs/form-layout/en/flex-row-form.md +542 -0
  174. package/docs/form-layout/en/form-field.md +923 -0
  175. package/docs/form-layout/en/grid-form.md +676 -0
  176. package/docs/global/cn/README.md +534 -0
  177. package/docs/global/en/README.md +534 -0
  178. package/docs/layout/cn/classiclayout.md +460 -0
  179. package/docs/layout/cn/headerlayout.md +524 -0
  180. package/docs/layout/cn/sidebarlayout.md +263 -0
  181. package/docs/layout/en/classiclayout.md +951 -0
  182. package/docs/layout/en/headerlayout.md +524 -0
  183. package/docs/layout/en/sidebarlayout.md +262 -0
  184. package/docs/misc/cn/README.md +1217 -0
  185. package/docs/misc/en/README.md +1217 -0
  186. package/docs/navigation/cn/breadcrumb.md +291 -0
  187. package/docs/navigation/cn/navigator.md +322 -0
  188. package/docs/navigation/cn/navigatormenu.md +512 -0
  189. package/docs/navigation/cn/progressbar.md +199 -0
  190. package/docs/navigation/cn/progressstepbar.md +299 -0
  191. package/docs/navigation/en/breadcrumb.md +291 -0
  192. package/docs/navigation/en/navigator.md +322 -0
  193. package/docs/navigation/en/navigatormenu.md +512 -0
  194. package/docs/navigation/en/progressbar.md +199 -0
  195. package/docs/navigation/en/progressstepbar.md +299 -0
  196. package/docs/search-filters/cn/daterange.md +1156 -0
  197. package/docs/search-filters/cn/numberrange.md +688 -0
  198. package/docs/search-filters/cn/searchbox.md +1582 -0
  199. package/docs/search-filters/en/daterange.md +1156 -0
  200. package/docs/search-filters/en/numberrange.md +688 -0
  201. package/docs/search-filters/en/searchbox.md +1582 -0
  202. package/package.json +53 -13
  203. package/dist/common-editor/DateInput.svelte +0 -27
  204. package/dist/i18n_resources/index.d.ts +0 -3
  205. package/dist/i18n_resources/index.js +0 -3
  206. /package/dist/{i18n_resources → i18nRes}/uniface_cn_resource.d.ts +0 -0
  207. /package/dist/{i18n_resources → i18nRes}/uniface_cn_resource.js +0 -0
  208. /package/dist/{i18n_resources → i18nRes}/uniface_en_resource.d.ts +0 -0
  209. /package/dist/{i18n_resources → i18nRes}/uniface_en_resource.js +0 -0
@@ -0,0 +1,159 @@
1
+ # TimeEditor Component
2
+
3
+ Time input component supporting hour and minute selection.
4
+
5
+ ## Properties
6
+
7
+ | Property | Type | Default | Description |
8
+ |----------|------|---------|-------------|
9
+ | `variant` | `'' \| 'plain' \| 'outlined' \| 'filled'` | `''` | Appearance variant |
10
+ | `disabled` | `boolean` | `false` | Whether disabled |
11
+ | `readonly` | `boolean` | `false` | Whether read-only |
12
+ | `compact` | `boolean` | `false` | Whether compact mode |
13
+ | `value` | `string` | `''` | Time value (format: HH:MM) |
14
+ | `placeholder` | `string` | `''` | Placeholder text |
15
+ | `displayMode` | `DisplayMode` | `DisplayMode.Edit` | Display mode |
16
+ | `format24h` | `boolean` | `true` | Whether to use 24-hour format |
17
+ | `minuteStep` | `number` | `1` | Minute step |
18
+ | `style` | `string` | `''` | Custom styles |
19
+ | `onChange` | `OnChangeHandler<string>` | - | Value change callback |
20
+
21
+ ## Usage Examples
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('Start time:', value);
33
+ };
34
+
35
+ const handleEndTimeChange = (value: string) => {
36
+ endTime = value;
37
+ console.log('End time:', value);
38
+ };
39
+ </script>
40
+
41
+ <!-- Start time -->
42
+ <TimeEditor
43
+ placeholder="Select start time"
44
+ bind:value={startTime}
45
+ onChange={handleStartTimeChange}
46
+ />
47
+
48
+ <!-- End time (15-minute intervals) -->
49
+ <TimeEditor
50
+ placeholder="Select end time"
51
+ minuteStep={15}
52
+ bind:value={endTime}
53
+ onChange={handleEndTimeChange}
54
+ />
55
+ ```
56
+
57
+ ## Advanced Usage
58
+
59
+ ### Working Hours Setup
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>Working Hours:</label>
84
+ <TimeEditor
85
+ placeholder="Start time"
86
+ minuteStep={30}
87
+ bind:value={workingHours.start}
88
+ onChange={updateWorkingHours('start')}
89
+ />
90
+ <span>to</span>
91
+ <TimeEditor
92
+ placeholder="End time"
93
+ minuteStep={30}
94
+ bind:value={workingHours.end}
95
+ onChange={updateWorkingHours('end')}
96
+ />
97
+ </div>
98
+
99
+ <div class="time-range">
100
+ <label>Break Time:</label>
101
+ <TimeEditor
102
+ placeholder="Start time"
103
+ minuteStep={15}
104
+ bind:value={workingHours.break_start}
105
+ onChange={updateWorkingHours('break_start')}
106
+ />
107
+ <span>to</span>
108
+ <TimeEditor
109
+ placeholder="End time"
110
+ minuteStep={15}
111
+ bind:value={workingHours.break_end}
112
+ onChange={updateWorkingHours('break_end')}
113
+ />
114
+ </div>
115
+ </div>
116
+ ```
117
+
118
+ ## Best Practices
119
+
120
+ ### 1. Set Appropriate Step Size
121
+ ```svelte
122
+ <!-- Meeting time: 15-minute intervals -->
123
+ <TimeEditor minuteStep={15} />
124
+
125
+ <!-- Work shifts: 30-minute intervals -->
126
+ <TimeEditor minuteStep={30} />
127
+
128
+ <!-- Precise time: 1-minute intervals -->
129
+ <TimeEditor minuteStep={1} />
130
+ ```
131
+
132
+ ### 2. Time Range Validation
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 = 'End time must be later than start time';
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 Component
2
+
3
+ Number input component with units, allowing users to select different measurement units.
4
+
5
+ ## Type Definitions
6
+
7
+ ```typescript
8
+ interface UnitOption {
9
+ code: string;
10
+ text: string;
11
+ ratio: number; // Conversion ratio to base unit
12
+ }
13
+ ```
14
+
15
+ ## Properties
16
+
17
+ | Property | Type | Default | Description |
18
+ |----------|------|---------|-------------|
19
+ | `variant` | `'' \| 'plain' \| 'outlined' \| 'filled'` | `''` | Appearance variant |
20
+ | `disabled` | `boolean` | `false` | Whether disabled |
21
+ | `readonly` | `boolean` | `false` | Whether read-only |
22
+ | `compact` | `boolean` | `false` | Whether compact mode |
23
+ | `value` | `number \| null` | `null` | Numeric value |
24
+ | `unit` | `string` | `''` | Currently selected unit code |
25
+ | `units` | `UnitOption[]` | `[]` | Available unit options |
26
+ | `placeholder` | `string` | `''` | Placeholder text |
27
+ | `displayMode` | `DisplayMode` | `DisplayMode.Edit` | Display mode |
28
+ | `precision` | `number \| null` | `null` | Number of decimal places |
29
+ | `style` | `string` | `''` | Custom styles |
30
+ | `onChange` | `OnChangeHandler<{value: number, unit: string}>` | - | Value change callback |
31
+
32
+ ## Usage Examples
33
+
34
+ ```svelte
35
+ <script lang="ts">
36
+ import UnitNumberEditor, { type UnitOption } from '@ticatec/uniface-element/UnitNumberEditor';
37
+
38
+ // Weight unit options
39
+ const weightUnits: UnitOption[] = [
40
+ { code: 'kg', text: 'Kilogram', ratio: 1 },
41
+ { code: 'g', text: 'Gram', ratio: 0.001 },
42
+ { code: 'lb', text: 'Pound', ratio: 0.453592 }
43
+ ];
44
+
45
+ // Distance unit options
46
+ const distanceUnits: UnitOption[] = [
47
+ { code: 'm', text: 'Meter', ratio: 1 },
48
+ { code: 'cm', text: 'Centimeter', ratio: 0.01 },
49
+ { code: 'km', text: 'Kilometer', ratio: 1000 },
50
+ { code: 'in', text: 'Inch', 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(`Weight: ${value} ${unit}`);
67
+ };
68
+
69
+ const handleDistanceChange = ({value, unit}: UnitValue): void => {
70
+ distance = value;
71
+ distanceUnit = unit;
72
+ console.log(`Distance: ${value} ${unit}`);
73
+ };
74
+ </script>
75
+
76
+ <!-- Weight input -->
77
+ <UnitNumberEditor
78
+ placeholder="Enter weight"
79
+ units={weightUnits}
80
+ precision={2}
81
+ bind:value={weight}
82
+ bind:unit={weightUnit}
83
+ onChange={handleWeightChange}
84
+ />
85
+
86
+ <!-- Distance input -->
87
+ <UnitNumberEditor
88
+ placeholder="Enter distance"
89
+ units={distanceUnits}
90
+ precision={2}
91
+ bind:value={distance}
92
+ bind:unit={distanceUnit}
93
+ onChange={handleDistanceChange}
94
+ />
95
+ ```
96
+
97
+ ## Advanced Usage
98
+
99
+ ### Unit Conversion
100
+ ```svelte
101
+ <script lang="ts">
102
+ let inputValue: number | null = null;
103
+ let inputUnit: string = 'kg';
104
+ let baseValue: number | null = null; // Base unit value
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(`Base value: ${baseValue} kg`);
118
+ } else {
119
+ baseValue = null;
120
+ }
121
+ };
122
+ </script>
123
+
124
+ <UnitNumberEditor
125
+ placeholder="Enter weight"
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>Equals: {baseValue.toFixed(3)} kg</p>
135
+ {/if}
136
+ ```
137
+
138
+ ## Best Practices
139
+
140
+ ### 1. Set Reasonable Precision
141
+ ```svelte
142
+ <!-- Weight: 3 decimal places -->
143
+ <UnitNumberEditor units={weightUnits} precision={3} />
144
+
145
+ <!-- Distance: 2 decimal places -->
146
+ <UnitNumberEditor units={distanceUnits} precision={2} />
147
+
148
+ <!-- Temperature: 1 decimal place -->
149
+ <UnitNumberEditor units={temperatureUnits} precision={1} />
150
+ ```
151
+
152
+ ### 2. Provide Common Units
153
+ ```svelte
154
+ <script lang="ts">
155
+ // Sorted by usage frequency
156
+ const lengthUnits: UnitOption[] = [
157
+ { code: 'm', text: 'Meter', ratio: 1 }, // Most common
158
+ { code: 'cm', text: 'Centimeter', ratio: 0.01 }, // Common
159
+ { code: 'mm', text: 'Millimeter', ratio: 0.001 }, // Common
160
+ { code: 'km', text: 'Kilometer', ratio: 1000 }, // Less common
161
+ { code: 'in', text: 'Inch', ratio: 0.0254 } // Special needs
162
+ ];
163
+ </script>
164
+ ```