@fibrae/semi-ui-svelte 0.9.0 → 0.10.0

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 (169) hide show
  1. package/README.md +8 -4
  2. package/README.zh-CN.md +8 -4
  3. package/dist/components/anchor/interface.d.ts +14 -0
  4. package/dist/components/audio-player/interface.d.ts +5 -0
  5. package/dist/components/auto-complete/interface.d.ts +29 -0
  6. package/dist/components/avatar/interface.d.ts +24 -0
  7. package/dist/components/backtop/interface.d.ts +2 -0
  8. package/dist/components/badge/interface.d.ts +7 -0
  9. package/dist/components/banner/interface.d.ts +7 -0
  10. package/dist/components/breadcrumb/interface.d.ts +10 -0
  11. package/dist/components/button/interface.d.ts +18 -0
  12. package/dist/components/calendar/interface.d.ts +16 -0
  13. package/dist/components/card/interface.d.ts +18 -0
  14. package/dist/components/carousel/interface.d.ts +16 -0
  15. package/dist/components/cascader/cascader.svelte +1 -0
  16. package/dist/components/cascader/interface.d.ts +57 -0
  17. package/dist/components/checkbox/interface.d.ts +19 -0
  18. package/dist/components/code-highlight/interface.d.ts +3 -0
  19. package/dist/components/collapse/interface.d.ts +16 -0
  20. package/dist/components/collapsible/interface.d.ts +10 -0
  21. package/dist/components/color-picker/interface.d.ts +10 -0
  22. package/dist/components/config-provider/interface.d.ts +7 -0
  23. package/dist/components/cropper/interface.d.ts +11 -0
  24. package/dist/components/date-picker/interface.d.ts +47 -0
  25. package/dist/components/descriptions/interface.d.ts +6 -0
  26. package/dist/components/divider/interface.d.ts +4 -0
  27. package/dist/components/dropdown/interface.d.ts +8 -0
  28. package/dist/components/empty/interface.d.ts +7 -0
  29. package/dist/components/feedback/interface.d.ts +16 -0
  30. package/dist/components/float-button/interface.d.ts +14 -0
  31. package/dist/components/form/interface.d.ts +47 -0
  32. package/dist/components/form/label.svelte +2 -2
  33. package/dist/components/grid/interface.d.ts +13 -0
  34. package/dist/components/highlight/interface.d.ts +7 -0
  35. package/dist/components/hot-keys/interface.d.ts +3 -0
  36. package/dist/components/image/interface.d.ts +59 -0
  37. package/dist/components/input/interface.d.ts +67 -0
  38. package/dist/components/input-number/interface.d.ts +24 -0
  39. package/dist/components/json-viewer/interface.d.ts +7 -0
  40. package/dist/components/layout/interface.d.ts +3 -0
  41. package/dist/components/list/interface.d.ts +18 -0
  42. package/dist/components/locale/interface.d.ts +4 -0
  43. package/dist/components/lottie/interface.d.ts +2 -0
  44. package/dist/components/markdown-render/interface.d.ts +5 -0
  45. package/dist/components/modal/interface.d.ts +29 -0
  46. package/dist/components/navigation/interface.d.ts +47 -0
  47. package/dist/components/overflow-list/interface.d.ts +11 -0
  48. package/dist/components/pagination/interface.d.ts +12 -0
  49. package/dist/components/pincode/interface.d.ts +8 -0
  50. package/dist/components/popconfirm/interface.d.ts +12 -0
  51. package/dist/components/popover/interface.d.ts +30 -0
  52. package/dist/components/progress/interface.d.ts +13 -0
  53. package/dist/components/radio/interface.d.ts +22 -0
  54. package/dist/components/rating/interface.d.ts +12 -0
  55. package/dist/components/resizable/interface.d.ts +30 -0
  56. package/dist/components/scroll-list/interface.d.ts +6 -0
  57. package/dist/components/select/interface.d.ts +63 -0
  58. package/dist/components/side-sheet/interface.d.ts +19 -0
  59. package/dist/components/skeleton/interface.d.ts +7 -0
  60. package/dist/components/slider/interface.d.ts +23 -0
  61. package/dist/components/space/interface.d.ts +4 -0
  62. package/dist/components/spin/interface.d.ts +7 -0
  63. package/dist/components/steps/interface.d.ts +9 -0
  64. package/dist/components/switch/interface.d.ts +7 -0
  65. package/dist/components/table/interface.d.ts +48 -0
  66. package/dist/components/tabs/interface.d.ts +29 -0
  67. package/dist/components/tag/interface.d.ts +22 -0
  68. package/dist/components/tag-input/interface.d.ts +29 -0
  69. package/dist/components/time-picker/interface.d.ts +31 -0
  70. package/dist/components/timeline/interface.d.ts +5 -0
  71. package/dist/components/tooltip/interface.d.ts +20 -0
  72. package/dist/components/tooltip/tooltip.svelte +3 -0
  73. package/dist/components/transfer/interface.d.ts +18 -0
  74. package/dist/components/tree/interface.d.ts +45 -0
  75. package/dist/components/tree-select/interface.d.ts +55 -0
  76. package/dist/components/typography/interface.d.ts +33 -0
  77. package/dist/components/upload/interface.d.ts +64 -0
  78. package/dist/components/user-guide/interface.d.ts +15 -0
  79. package/dist/components/video-player/interface.d.ts +22 -0
  80. package/dist/styles.css +1 -1
  81. package/docs/advanced/dark-mode.md +288 -0
  82. package/docs/basic/button.md +605 -0
  83. package/docs/basic/divider.md +103 -0
  84. package/docs/basic/float-button.md +246 -0
  85. package/docs/basic/grid.md +427 -0
  86. package/docs/basic/layout.md +459 -0
  87. package/docs/basic/resizable.md +584 -0
  88. package/docs/basic/space.md +163 -0
  89. package/docs/basic/tokens.md +425 -0
  90. package/docs/basic/typography.md +615 -0
  91. package/docs/changes-from-semi.md +105 -0
  92. package/docs/ecosystem/tailwind.md +210 -0
  93. package/docs/experience/accessibility.md +82 -0
  94. package/docs/experience/content-guidelines.md +819 -0
  95. package/docs/experience/internationalization.md +7 -0
  96. package/docs/feedback/banner.md +198 -0
  97. package/docs/feedback/feedback.md +294 -0
  98. package/docs/feedback/notification.md +401 -0
  99. package/docs/feedback/popconfirm.md +243 -0
  100. package/docs/feedback/progress.md +389 -0
  101. package/docs/feedback/skeleton.md +388 -0
  102. package/docs/feedback/spin.md +172 -0
  103. package/docs/feedback/toast.md +393 -0
  104. package/docs/input/auto-complete.md +399 -0
  105. package/docs/input/cascader.md +1558 -0
  106. package/docs/input/checkbox.md +408 -0
  107. package/docs/input/color-picker.md +175 -0
  108. package/docs/input/date-picker.md +942 -0
  109. package/docs/input/form.md +2550 -0
  110. package/docs/input/input-number.md +451 -0
  111. package/docs/input/input.md +640 -0
  112. package/docs/input/pincode.md +191 -0
  113. package/docs/input/radio.md +337 -0
  114. package/docs/input/rating.md +214 -0
  115. package/docs/input/select.md +1230 -0
  116. package/docs/input/slider.md +347 -0
  117. package/docs/input/switch.md +206 -0
  118. package/docs/input/tag-input.md +465 -0
  119. package/docs/input/time-picker.md +358 -0
  120. package/docs/input/transfer.md +1061 -0
  121. package/docs/input/tree-select.md +1300 -0
  122. package/docs/input/upload.md +1811 -0
  123. package/docs/llms.txt +147 -0
  124. package/docs/navigation/anchor.md +377 -0
  125. package/docs/navigation/backtop.md +100 -0
  126. package/docs/navigation/breadcrumb.md +284 -0
  127. package/docs/navigation/navigation.md +851 -0
  128. package/docs/navigation/pagination.md +217 -0
  129. package/docs/navigation/steps.md +315 -0
  130. package/docs/navigation/tabs.md +754 -0
  131. package/docs/navigation/tree.md +1956 -0
  132. package/docs/other/config-provider.md +599 -0
  133. package/docs/other/locale.md +353 -0
  134. package/docs/plus/audio-player.md +155 -0
  135. package/docs/plus/code-highlight.md +150 -0
  136. package/docs/plus/drag-move.md +214 -0
  137. package/docs/plus/hot-keys.md +174 -0
  138. package/docs/plus/json-viewer.md +392 -0
  139. package/docs/plus/lottie.md +176 -0
  140. package/docs/plus/markdown-render.md +240 -0
  141. package/docs/plus/video-player.md +325 -0
  142. package/docs/show/avatar.md +475 -0
  143. package/docs/show/badge.md +276 -0
  144. package/docs/show/calendar.md +352 -0
  145. package/docs/show/card.md +485 -0
  146. package/docs/show/carousel.md +592 -0
  147. package/docs/show/collapse.md +289 -0
  148. package/docs/show/collapsible.md +216 -0
  149. package/docs/show/cropper.md +285 -0
  150. package/docs/show/descriptions.md +325 -0
  151. package/docs/show/dropdown.md +466 -0
  152. package/docs/show/empty.md +225 -0
  153. package/docs/show/highlight.md +144 -0
  154. package/docs/show/image.md +433 -0
  155. package/docs/show/list.md +927 -0
  156. package/docs/show/modal.md +517 -0
  157. package/docs/show/overflow-list.md +272 -0
  158. package/docs/show/popover.md +534 -0
  159. package/docs/show/scroll-list.md +156 -0
  160. package/docs/show/side-sheet.md +274 -0
  161. package/docs/show/table.md +5437 -0
  162. package/docs/show/tag.md +428 -0
  163. package/docs/show/timeline.md +277 -0
  164. package/docs/show/tooltip.md +442 -0
  165. package/docs/show/user-guide.md +419 -0
  166. package/docs/start/getting-started.md +234 -0
  167. package/docs/start/introduction.md +57 -0
  168. package/docs/start/overview.md +21 -0
  169. package/package.json +5 -4
@@ -0,0 +1,451 @@
1
+ # InputNumber
2
+
3
+ > Through the mouse or keyboard, input the value in the range. Unlike Input, it has a stepper operation area for digital scenes, and it can display more complex content formats when used with Parser.
4
+
5
+ Package: `@fibrae/semi-ui-svelte`. Web page: https://semi-design-next.pages.dev/en-US/svelte/input/input-number/
6
+
7
+ ## When to Use
8
+
9
+ When you need to get a standard value.
10
+
11
+ ## Demos
12
+
13
+ ### How to import
14
+
15
+ ```svelte
16
+ <script lang="ts">
17
+ import { InputNumber } from '@fibrae/semi-ui-svelte';
18
+ </script>
19
+ ```
20
+
21
+ ### Basic Input Box
22
+
23
+ There is no `defaultValue`: a plain `value` is the initial value, `bind:value` reads and writes it, and a function binding `bind:value={() => value, (next) => { ... }}` can refuse or rewrite it.
24
+
25
+ ```svelte
26
+ <script lang="ts">
27
+ import { InputNumber } from '@fibrae/semi-ui-svelte';
28
+ </script>
29
+
30
+ <div style="width: 280px">
31
+ <span id="inputnumber-basic-simple">简单数字输入框</span>
32
+ <InputNumber aria-labelledby="inputnumber-basic-simple" />
33
+ <br />
34
+ <br />
35
+
36
+ <span id="inputnumber-basic-step">设置了步长 step=2 </span>
37
+ <InputNumber aria-labelledby="inputnumber-basic-step" step={2} />
38
+ <br />
39
+ <br />
40
+
41
+ <span id="inputnumber-basic-shift-step">设置 shiftStep=100, 按住 shift 同时点击按钮,可以一次增加/减少100 </span>
42
+ <InputNumber aria-labelledby="inputnumber-basic-shift-step" shiftStep={100} />
43
+ <br />
44
+ <br />
45
+
46
+ <span id="inputnumber-basic-range">设置了上下界 min=1,max=10</span>
47
+ <InputNumber aria-labelledby="inputnumber-basic-range" max={10} min={1} value={1} />
48
+ <br />
49
+ <br />
50
+ </div>
51
+ ```
52
+
53
+ ```svelte
54
+ <script lang="ts">
55
+ import { InputNumber } from '@fibrae/semi-ui-svelte';
56
+ </script>
57
+
58
+ <div style="width: 280px">
59
+ <span id="inputnumber-basic-more-default-value">设置了默认值 value=1 </span>
60
+ <InputNumber aria-labelledby="inputnumber-basic-more-default-value" value={1} />
61
+ <br />
62
+ <br />
63
+
64
+ <span id="inputnumber-basic-more-disabled">禁用 disabled=true</span>
65
+ <InputNumber aria-labelledby="inputnumber-basic-more-disabled" disabled value={2} />
66
+ <br />
67
+ <br />
68
+
69
+ <span id="inputnumber-basic-more-precision">设置了小数位数 precision=2 </span>
70
+ <InputNumber aria-labelledby="inputnumber-basic-more-precision" precision={2} value={1.234} />
71
+ <br />
72
+ <br />
73
+
74
+ <span id="inputnumber-basic-more-inner-buttons">设置了 innerButtons=true </span>
75
+ <InputNumber aria-labelledby="inputnumber-basic-more-inner-buttons" innerButtons style="width: 190px" value={1}>
76
+ {#snippet suffix()}小时{/snippet}
77
+ </InputNumber>
78
+ <br />
79
+ </div>
80
+ ```
81
+
82
+ ### Inner Buttons
83
+
84
+ With `innerButtons`, you can hide the buttons on the right into the interior, which will only be displayed when hover occurs
85
+
86
+ ```svelte
87
+ <script lang="ts">
88
+ import { InputNumber } from '@fibrae/semi-ui-svelte';
89
+ </script>
90
+
91
+ <InputNumber aria-label="Number with inner buttons" innerButtons style="width: 190px" />
92
+ ```
93
+
94
+ The `innerButtons` buttons temporarily replace the content of the `suffix` snippet while hovered or focused, and the original content comes back afterwards.
95
+
96
+ Set `hideButtons` to `true` to hide the buttons completely
97
+
98
+ ```svelte
99
+ <script lang="ts">
100
+ import { InputNumber } from '@fibrae/semi-ui-svelte';
101
+ </script>
102
+
103
+ <InputNumber aria-label="Number without buttons" hideButtons style="width: 190px" />
104
+ ```
105
+
106
+ ### Size
107
+
108
+ ```svelte
109
+ <script lang="ts">
110
+ import { InputNumber } from '@fibrae/semi-ui-svelte';
111
+ </script>
112
+
113
+ <div style="width: 180px">
114
+ <span id="inputnumber-size-default">默认尺寸 size=default</span>
115
+ <InputNumber aria-labelledby="inputnumber-size-default" />
116
+ <br />
117
+ <br />
118
+
119
+ <span id="inputnumber-size-large">大尺寸 size=large</span>
120
+ <InputNumber aria-labelledby="inputnumber-size-large" size="large" />
121
+ <br />
122
+ <br />
123
+
124
+ <span id="inputnumber-size-small">小尺寸 size=small</span>
125
+ <InputNumber aria-labelledby="inputnumber-size-small" size="small" />
126
+ <br />
127
+ </div>
128
+ ```
129
+
130
+ ### Custom Display Format and Resolution
131
+
132
+ > A pair of methods for `formatter` and `parser`, which generally need to be set at the same time, otherwise the value cannot be resolved correctly.
133
+
134
+ > **Behavior change**
135
+ >
136
+ > - **Before the change**: In **controlled** mode (passing `value`, or `modelValue` in Vue), when `value` is a **number**, the initial render might not apply `formatter` to the displayed text. `formatter/parser` could be applied after mount (or on subsequent updates), causing the first paint to differ from later renders.
137
+ > - **After the change**: In controlled mode, when `value` is a **number**, `formatter` is applied on the initial render (and paired with `parser` to derive the internal numeric value), keeping the first paint consistent with later renders. For example, in a percentage formatter/parser setup where `value=1` should display `100`, the first paint will display `100`.
138
+
139
+ ```svelte
140
+ <script lang="ts">
141
+ import { InputNumber } from '@fibrae/semi-ui-svelte';
142
+
143
+ const log = (v: number | string) => {
144
+ console.log(`Changed to: [${typeof v}] ${v}`);
145
+ };
146
+ </script>
147
+
148
+ <div style="width: 180px">
149
+ <span id="inputnumber-formatter-rmb">人民币</span>
150
+ <InputNumber aria-labelledby="inputnumber-formatter-rmb" formatter={(value) => `¥ ${value}`.replace(/\B(?=(\d{3})+(?!\d))/g, ',')} min={0} onChange={log} parser={(value) => value.replace(/¥\s?|(,*)/g, '')} value={1000} />
151
+ <br />
152
+ <br />
153
+
154
+ <span id="inputnumber-formatter-custom">自定义串</span>
155
+ <InputNumber aria-labelledby="inputnumber-formatter-custom" formatter={(value) => String(value).split('').join('-')} onChange={log} parser={(value) => value.replace(/-/g, '')} value={1111} />
156
+ <br />
157
+ </div>
158
+ ```
159
+
160
+ ### Can Only Enter Numbers
161
+
162
+ With formatter and onNumberChange (the `numberChange` event in Vue), a pure digital input box can be implemented.
163
+
164
+ ```svelte
165
+ <script lang="ts">
166
+ import { InputNumber } from '@fibrae/semi-ui-svelte';
167
+ </script>
168
+
169
+ <InputNumber aria-label="Integer" formatter={(value) => `${value}`.replace(/\D/g, '')} max={Number.MAX_SAFE_INTEGER} min={0} onNumberChange={(number) => console.log(number)} />
170
+ ```
171
+
172
+ ### Currency Display
173
+
174
+ In internationalization mode, enable currency={true} (just `currency` in Vue) and the component will automatically display the corresponding currency type according to localeCode. (Note that the component key value needs to be updated after switching the language type) Apart from `zh_CN` and `en_US`, every language in the example is a custom locale pack with only `code` and `currency`; its other text falls back to `en_US`.
175
+
176
+ ```svelte
177
+ <script lang="ts">
178
+ import { InputNumber, LocaleProvider, Select } from '@fibrae/semi-ui-svelte';
179
+ import { en_US, zh_CN, type LocaleInput } from '@fibrae/semi-ui-svelte/locale';
180
+
181
+ const language: Record<string, LocaleInput> = {
182
+ zh_CN,
183
+ en_US,
184
+ en_GB: { code: 'en-GB', currency: 'GBP' },
185
+ ja_JP: { code: 'ja-JP', currency: 'JPY' },
186
+ ko_KR: { code: 'ko-KR', currency: 'KRW' },
187
+ de: { code: 'de', currency: 'EUR' },
188
+ pt_BR: { code: 'pt-BR', currency: 'BRL' },
189
+ };
190
+
191
+ const optionList = [
192
+ { value: 'zh_CN', label: '简体中文' },
193
+ { value: 'en_US', label: '英语(美)' },
194
+ { value: 'en_GB', label: '英语(英)' },
195
+ { value: 'ja_JP', label: '日语' },
196
+ { value: 'ko_KR', label: '韩语' },
197
+ { value: 'de', label: '德语' },
198
+ { value: 'pt_BR', label: '葡萄牙语(巴西)' },
199
+ ];
200
+
201
+ let localeCode = $state('zh_CN');
202
+ </script>
203
+
204
+ <div style="padding-bottom: 20px">
205
+ <Select aria-label="切换语言" onChange={(value) => (localeCode = String(value))} {optionList} style="width: 250px" value={localeCode}>
206
+ {#snippet insetLabel()}切换语言{/snippet}
207
+ </Select>
208
+ </div>
209
+ <LocaleProvider locale={language[localeCode]}>
210
+ {#key localeCode}
211
+ <InputNumber aria-label="金额" currency value={123456.78} />
212
+ {/key}
213
+ </LocaleProvider>
214
+ ```
215
+
216
+ You can also specify the currency to be displayed by manually passing localeCode and currency.
217
+
218
+ ```svelte
219
+ <script lang="ts">
220
+ import { InputNumber } from '@fibrae/semi-ui-svelte';
221
+
222
+ const value = 123456.78;
223
+ </script>
224
+
225
+ <div>
226
+ <div id="inputnumber-currency-locale-cny">🇨🇳 人民币</div>
227
+ <InputNumber aria-labelledby="inputnumber-currency-locale-cny" currency="CNY" localeCode="zh-CN" {value} />
228
+ <br />
229
+ <br />
230
+ <div id="inputnumber-currency-locale-eur">🇪🇺 欧元</div>
231
+ <InputNumber aria-labelledby="inputnumber-currency-locale-eur" currency="EUR" localeCode="de-DE" {value} />
232
+ <br />
233
+ <br />
234
+ <div id="inputnumber-currency-locale-jpy">🇯🇵 日元</div>
235
+ <InputNumber aria-labelledby="inputnumber-currency-locale-jpy" currency="JPY" localeCode="ja-JP" {value} />
236
+ <br />
237
+ <br />
238
+ <div id="inputnumber-currency-locale-vnd">🇻🇳 越南盾</div>
239
+ <InputNumber aria-labelledby="inputnumber-currency-locale-vnd" currency="VND" localeCode="vi-VN" {value} />
240
+ <br />
241
+ <br />
242
+ </div>
243
+ ```
244
+
245
+ Supports three display modes: symbol, code, and name. It is controlled by the currencyDisplay property. The currency symbol is displayed by default. Set showCurrencySymbol to false to hide the display of currency symbol/code/name
246
+
247
+ ```svelte
248
+ <script lang="ts">
249
+ import { InputNumber } from '@fibrae/semi-ui-svelte';
250
+
251
+ const value = 123456.78;
252
+ </script>
253
+
254
+ <div>
255
+ <div id="inputnumber-currency-display-code">🇨🇳 CNY ➕ code</div>
256
+ <InputNumber aria-labelledby="inputnumber-currency-display-code" currency="CNY" currencyDisplay="code" {value} />
257
+ <br />
258
+ <br />
259
+ <div id="inputnumber-currency-display-symbol">🇨🇳 CNY ➕ symbol</div>
260
+ <InputNumber aria-labelledby="inputnumber-currency-display-symbol" currency="CNY" currencyDisplay="symbol" {value} />
261
+ <br />
262
+ <br />
263
+ <div id="inputnumber-currency-display-name">🇨🇳 CNY ➕ name</div>
264
+ <InputNumber aria-labelledby="inputnumber-currency-display-name" currency="CNY" currencyDisplay="name" {value} />
265
+ <br />
266
+ <br />
267
+ </div>
268
+ ```
269
+
270
+ Hide the display of currency symbols/codes/names, and display the currency symbol through the prefix/suffix
271
+
272
+ ```svelte
273
+ <script lang="ts">
274
+ import { InputNumber } from '@fibrae/semi-ui-svelte';
275
+
276
+ const value = 123456.78;
277
+ </script>
278
+
279
+ <div>
280
+ <div id="inputnumber-currency-affix-code">🇨🇳 CNY ➕ code</div>
281
+ <InputNumber aria-labelledby="inputnumber-currency-affix-code" currency="CNY" showCurrencySymbol={false} style="width: 200px" {value}>
282
+ {#snippet prefix()}CNY{/snippet}
283
+ </InputNumber>
284
+ <br />
285
+ <br />
286
+ <div id="inputnumber-currency-affix-symbol">🇨🇳 CNY ➕ symbol</div>
287
+ <InputNumber aria-labelledby="inputnumber-currency-affix-symbol" currency="CNY" showCurrencySymbol={false} style="width: 200px" {value}>
288
+ {#snippet prefix()}¥{/snippet}
289
+ </InputNumber>
290
+ <br />
291
+ <br />
292
+ <div id="inputnumber-currency-affix-name">🇨🇳 CNY ➕ name</div>
293
+ <InputNumber aria-labelledby="inputnumber-currency-affix-name" currency="CNY" showCurrencySymbol={false} style="width: 200px" {value}>
294
+ {#snippet suffix()}人民币{/snippet}
295
+ </InputNumber>
296
+ <br />
297
+ <br />
298
+ </div>
299
+ ```
300
+
301
+ ### Scientific Notation Display
302
+
303
+ When the number is long, you can enable scientific notation display via the `scientificNotation` property. It displays in scientific notation when out of focus, and displays the full number when in focus.
304
+
305
+ ```svelte
306
+ <script lang="ts">
307
+ import { InputNumber } from '@fibrae/semi-ui-svelte';
308
+ </script>
309
+
310
+ <div style="width: 280px">
311
+ <span id="inputnumber-scientific-default">启用科学计数法(默认阈值 15 位)</span>
312
+ <InputNumber aria-labelledby="inputnumber-scientific-default" scientificNotation value={123456789012345} />
313
+ <br />
314
+ <br />
315
+
316
+ <span id="inputnumber-scientific-threshold">自定义阈值(10 位)</span>
317
+ <InputNumber aria-labelledby="inputnumber-scientific-threshold" scientificNotation={{ threshold: 10 }} value={1234567890} />
318
+ <br />
319
+ <br />
320
+
321
+ <span id="inputnumber-scientific-large">超大数字</span>
322
+ <InputNumber aria-labelledby="inputnumber-scientific-large" scientificNotation value={1e16} />
323
+ <br />
324
+ <br />
325
+
326
+ <span id="inputnumber-scientific-decimal">小数场景</span>
327
+ <InputNumber aria-labelledby="inputnumber-scientific-decimal" precision={10} scientificNotation value={0.000000123456789} />
328
+ <br />
329
+ <br />
330
+ </div>
331
+ ```
332
+
333
+ > Scientific notation only affects the display format. The values in `onChange` and `onNumberChange` callbacks (the `change` and `numberChange` events in Vue) are still full numbers. This feature is not supported in currency mode (`currency`).
334
+
335
+ ## API Reference
336
+
337
+ **Props**
338
+
339
+ | Property | Description | Type | Default |
340
+ | - | - | - | - |
341
+ | addonAfter | Snippet of the trailing addon. | `Snippet` | - |
342
+ | addonBefore | Snippet of the leading addon. | `Snippet` | - |
343
+ | autofocus | Focuses the input after mount. | `boolean` | - |
344
+ | borderless | Borderless mode. | `boolean` | - |
345
+ | classNames | Class names of the inner parts, keyed by input (the native input element); values take any class binding and merge with the built-in classes. | `Partial<Record<InputNumberPart, ClassValue>>` | - |
346
+ | clearIcon | Snippet of the custom clear button icon; valid when showClear is true. | `Snippet` | - |
347
+ | composition | Whether to enable composition mode. When enabled, onChange is not called during IME composition and is called once after it ends. | `boolean` | - |
348
+ | currency | Currency, such as CNY, EUR or USD. When true, uses defaultCurrency, or the currency of the locale pack when that is not set; a bare currency attribute equals true. | `boolean \| string` | - |
349
+ | currencyDisplay | How the currency is shown: symbol, code or name. | `'code' \| 'name' \| 'symbol'` | - |
350
+ | defaultCurrency | Currency used when currency is true. Priority: own prop, global default, locale pack. | `string` | - |
351
+ | disabled | Whether disabled. | `boolean` | - |
352
+ | formatter | Format of the displayed value, usually set together with parser. Priority: own prop, global default. | `(value: number \| string) => string` | - |
353
+ | hideButtons | Hides the step buttons; with innerButtons also true, no built-in button is shown either. | `boolean` | `false` |
354
+ | hideSuffix | Hides the suffix while the clear button is shown; by default the two sit side by side. | `boolean` | - |
355
+ | innerButtons | Puts the step buttons inside the input, shown on hover or focus and temporarily replacing the suffix. | `boolean` | `false` |
356
+ | insetLabel | Snippet of the inset label. | `Snippet` | - |
357
+ | insetLabelId | The id of the inset label. | `string` | - |
358
+ | keepFocus | Keeps the input focused when a step button is clicked. | `boolean` | `false` |
359
+ | localeCode | Locale code used for formatting in currency mode, such as zh-CN, en-US or de-DE. Priority: own prop, global default, locale pack of LocaleProvider or ConfigProvider. | `string` | - |
360
+ | max | Maximum value. | `number` | `Infinity` |
361
+ | maximumFractionDigits | Maximum number of fraction digits shown, passed to Intl.NumberFormat. | `number` | - |
362
+ | maxlength | Maximum length of the input text. | `number` | - |
363
+ | min | Minimum value. | `number` | `-Infinity` |
364
+ | minimumFractionDigits | Minimum number of fraction digits shown, passed to Intl.NumberFormat. | `number` | - |
365
+ | minlength | Minimum length of the input text. | `number` | - |
366
+ | onBlur | Called when focus leaves the input and the clear button. The event is the focusout of the Input wrapper. | `(event: FocusEvent) => void` | - |
367
+ | onChange | Called when the value changes. The second argument is the event that caused it: typing, a step button pointerdown, an arrow or Home/End keydown, or blur. Mounting and a new value from the parent do not call it; an out-of-range value is shown as given and is corrected and reported only after a user action. | `(value: number \| string, event: InputNumberChangeEvent) => void` | - |
368
+ | onClear | Called when the clear button is clicked. | `(event: MouseEvent) => void` | - |
369
+ | onCompositionEnd | Called when an IME composition ends. | `(event: CompositionEvent) => void` | - |
370
+ | onCompositionStart | Called when an IME composition starts. | `(event: CompositionEvent) => void` | - |
371
+ | onCompositionUpdate | Called while an IME composition updates. | `(event: CompositionEvent) => void` | - |
372
+ | onDownClick | Called when pressing the decrease button steps the value, once per step while it is held; the arguments are the stepped value and the pointerdown event. | `(value: string, event: PointerEvent) => void` | - |
373
+ | onEnterPress | Called when Enter is pressed in the input. | `(event: KeyboardEvent) => void` | - |
374
+ | onFocus | Called when focus enters the input; moving focus between the input and the clear button does not call it. The event is the focusin of the Input wrapper. | `(event: FocusEvent) => void` | - |
375
+ | onInput | Callback for the native input event. | `(event: Event) => void` | - |
376
+ | onKeyDown | Called when a key is pressed in the input. | `(event: KeyboardEvent) => void` | - |
377
+ | onKeyUp | Called when a key is released in the input. | `(event: KeyboardEvent) => void` | - |
378
+ | onNumberChange | Called when the number changes; the event argument is as in onChange. | `(value: number, event: InputNumberChangeEvent) => void` | - |
379
+ | onUpClick | Called when pressing the increase button steps the value, once per step while it is held; the arguments are the stepped value and the pointerdown event. | `(value: string, event: PointerEvent) => void` | - |
380
+ | parser | Converts the text from formatter back to a number string; used together with formatter. Priority: own prop, global default. | `(value: string) => string` | - |
381
+ | placeholder | Placeholder text. | `string \| number` | - |
382
+ | precision | Numerical precision, the number of fraction digits kept. | `number` | - |
383
+ | prefix | Snippet of the prefix content. | `Snippet` | - |
384
+ | pressInterval | Interval in milliseconds between repeats while a step button is held. | `number` | `250` |
385
+ | pressTimeout | Delay in milliseconds before repeating starts while a step button is held. | `number` | `250` |
386
+ | preventScroll | Whether focusing stops the browser from scrolling the document to the input; applies to focus calls inside the component. | `boolean` | - |
387
+ | readonly | Whether read-only. | `boolean` | - |
388
+ | readOnly | Native `readonly`: blocks typing only and keeps the clear button; `readonly` also hides the clear button. | `boolean` | - |
389
+ | scientificNotation | Shows scientific notation when blurred and the full number when focused. Pass `{ threshold }` to configure the threshold, 15 significant digits by default. Not supported in currency mode. | `boolean \| ScientificNotationConfig` | - |
390
+ | shiftStep | Step of each change while Shift is held; may be a decimal. | `number` | `10` |
391
+ | showClear | Whether to show the clear button. | `boolean` | - |
392
+ | showCurrencySymbol | Whether to show the currency symbol, code or name; only in currency mode. | `boolean` | `true` |
393
+ | size | Input size: default, small or large. | `InputSize` | - |
394
+ | step | Step of each change; may be a decimal. | `number` | `1` |
395
+ | styles | Style strings of the inner parts, keyed like classNames. | `Partial<Record<InputNumberPart, string>>` | - |
396
+ | suffix | Snippet of the suffix content; replaced while the innerButtons buttons are shown. | `Snippet` | - |
397
+ | validateStatus | Validation status: default, error, warning or success. | `ValidateStatus` | - |
398
+ | value | Current value; bind it with `bind:value`. A partial or invalid text is a string and a cleared input is ''. `bind:value={get, set}` makes it fully controlled; a plain `value` is the initial value. | `number \| string` | - |
399
+
400
+ **Methods**
401
+
402
+ | Method | Description | Type |
403
+ | - | - | - |
404
+ | blur | Removes focus. | `() => void` |
405
+ | focus | Focuses the input; preventScroll prop applies when options.preventScroll is not given. | `(options?: FocusOptions) => void` |
406
+ | getInput | Returns the native input element; null after unmount. | `() => any` |
407
+ | getNativeElement | Returns the root element of the component; null after unmount. | `() => HTMLDivElement \| undefined` |
408
+ | select | Selects all the text in the input. | `() => void` |
409
+ | setSelectionRange | Sets the selection, with the parameters of the native setSelectionRange. | `(start: number \| null, end: number \| null, direction?: 'backward' \| 'forward' \| 'none') => void` |
410
+
411
+ `class` and `style` (a string) land on the outer `.semi-input-number`; other undeclared attributes (`id`, `name`, `tabindex`, `title`, `aria-*`, `data-*`, `role`) land on the native input. `prefix`, `suffix`, `insetLabel`, `clearIcon`, `addonBefore` and `addonAfter` are snippets. Inside an InputGroup it follows the group's `size` and `disabled`.
412
+
413
+ ## Methods
414
+
415
+ Call `focus(options)`, `blur()`, `select()`, `setSelectionRange()`, `getInput()` and `getNativeElement()` on the instance obtained with `bind:this`; see Methods above. `focus()` without arguments follows the `preventScroll` prop.
416
+
417
+ ## Accessibility
418
+
419
+ Guideline: <https://www.w3.org/WAI/ARIA/apg/patterns/spinbutton/>
420
+
421
+ ### ARIA
422
+
423
+ - InputNumber has `spinbutton` role
424
+ - spinbutton uses `aria-valuenow` for current value, `aria-valuemax` for acceptable maximum value, and `aria-valuemin` for acceptable minimum value
425
+ - When InputNumber is used in Form, the value of the input box's `aria-labelledby` reference is Field label
426
+
427
+ ### Keyboard and Focus
428
+
429
+ - InputNumber can get focus, keyboard users can use `Tab` and `Shift + Tab` to switch focus (Increase and decrease buttons are not focusable)
430
+ - Keyboard users can press up key ⬆️ or down key ⬇️ and the input value will increase or decrease by `step` (default is 1)
431
+ - Hold down Shift + Up ⬆️ or Down ⬇️ , the input value will increase or decrease by `shiftStep` (default is 10)
432
+ - Home jumps to the value of `min` and End to `max`, when that bound is set; without it the key moves the caret as usual
433
+ - When the value is already at a bound and a key leaves it unchanged, `onChange` is not called (the `change` event in Vue)
434
+
435
+ ## Design Tokens
436
+
437
+ The design token table of this component is on the web page: <https://semi-design-next.pages.dev/en-US/svelte/input/input-number/>
438
+
439
+ ## Changes from Semi Design
440
+
441
+ From the project release notes (written in Chinese). Your knowledge of Semi Design does not cover these.
442
+
443
+ - 破坏性:删除 `inputStyle`,改用 `classNames.input`、`styles.input`,落在内部原生 input。
444
+ - 破坏性:ref 改为 `InputNumberHandle`(形状同 `InputHandle`)。`localeCode` 与 `currency={true}` 的货币优先级为「自身属性 > 全局 `overrideDefaultProps.InputNumber` > 语言包」。
445
+ - 挂载和 `value` 变化从不触发 `onChange`、`onNumberChange`,FormInputNumber 不再在挂载时被标为 touched。
446
+ - `min`、`max` 之外的受控值与 `defaultValue` 按原样显示,只在用户输入、失焦、步进、清除时校正并通知一次。
447
+ - 值超过 `max` 时向上、低于 `min` 时向下的步进被拒绝,按钮不可用,按钮与方向键都不改值;朝范围内步进落回边界,离边界不足一个 `step` 时落在边界上。
448
+ - 破坏性(类型):`onChange`、`onNumberChange` 的事件参数改为必填的 `InputNumberChangeEvent`,不再有 `null`;`onUpClick`、`onDownClick` 为 `PointerEvent<HTMLSpanElement>`,`onFocus`、`onBlur` 为 `FocusEvent<HTMLDivElement>`。
449
+ - 开启 `scientificNotation` 时失焦格式化不触发 `onChange`;货币模式下 `parser` 收到字符串。
450
+ - Svelte:`value` 可绑定,没有 `defaultValue`;回调为 `onChange`、`onNumberChange`、`onUpClick`、`onDownClick`、`onFocus`、`onBlur`、`onKeyDown`。
451
+ - Svelte:`prefix`、`suffix`、`insetLabel`、`clearIcon`、`addonBefore`、`addonAfter` 是 snippet;实例方法经 `bind:this` 调用:`focus(options)`、`blur`、`select`、`setSelectionRange`、`getInput()`、`getNativeElement()`;未声明属性落到原生 input,`class`、`style` 落到 `.semi-input-number` 外层;放在 InputGroup 里时跟随分组的 `size`、`disabled`。