@ttdk-design-system/library-vue 0.0.0-stage → 1.0.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 (232) hide show
  1. package/AI_GUIDE.md +6518 -0
  2. package/llms.txt +6518 -0
  3. package/package.json +1096 -4
  4. package/src/core/index.ts +2 -0
  5. package/src/core/tailwind-preset.cjs +62 -0
  6. package/src/core/tailwind-preset.ts +85 -0
  7. package/src/core/theme/tokens.css +663 -0
  8. package/src/core/types.ts +836 -0
  9. package/src/index.ts +17 -0
  10. package/src/tailwind-preset.cjs +62 -0
  11. package/src/tailwind-preset.ts +85 -0
  12. package/src/types.ts +1 -0
  13. package/src/web/accordion/AI_GUIDE.md +149 -0
  14. package/src/web/accordion/accordion.css +1 -0
  15. package/src/web/accordion/accordion.vue +432 -0
  16. package/src/web/accordion/accordion.vue.d.ts +227 -0
  17. package/src/web/accordion/index.ts +3 -0
  18. package/src/web/accordion/manifest.json +351 -0
  19. package/src/web/alert/AI_GUIDE.md +139 -0
  20. package/src/web/alert/alert.css +1 -0
  21. package/src/web/alert/alert.vue +290 -0
  22. package/src/web/alert/alert.vue.d.ts +154 -0
  23. package/src/web/alert/index.ts +3 -0
  24. package/src/web/alert/manifest.json +240 -0
  25. package/src/web/avatar/AI_GUIDE.md +118 -0
  26. package/src/web/avatar/avatar.css +1 -0
  27. package/src/web/avatar/avatar.vue +217 -0
  28. package/src/web/avatar/avatar.vue.d.ts +135 -0
  29. package/src/web/avatar/index.ts +3 -0
  30. package/src/web/avatar/manifest.json +195 -0
  31. package/src/web/badge/AI_GUIDE.md +94 -0
  32. package/src/web/badge/badge.css +1 -0
  33. package/src/web/badge/badge.vue +135 -0
  34. package/src/web/badge/badge.vue.d.ts +108 -0
  35. package/src/web/badge/index.ts +3 -0
  36. package/src/web/badge/manifest.json +141 -0
  37. package/src/web/banner/AI_GUIDE.md +130 -0
  38. package/src/web/banner/banner.css +1 -0
  39. package/src/web/banner/banner.vue +303 -0
  40. package/src/web/banner/banner.vue.d.ts +162 -0
  41. package/src/web/banner/index.ts +3 -0
  42. package/src/web/banner/manifest.json +240 -0
  43. package/src/web/breadcrumb/AI_GUIDE.md +120 -0
  44. package/src/web/breadcrumb/breadcrumb.css +1 -0
  45. package/src/web/breadcrumb/breadcrumb.vue +313 -0
  46. package/src/web/breadcrumb/breadcrumb.vue.d.ts +139 -0
  47. package/src/web/breadcrumb/index.ts +3 -0
  48. package/src/web/breadcrumb/manifest.json +225 -0
  49. package/src/web/button/AI_GUIDE.md +121 -0
  50. package/src/web/button/button.css +1 -0
  51. package/src/web/button/button.vue +283 -0
  52. package/src/web/button/button.vue.d.ts +147 -0
  53. package/src/web/button/index.ts +3 -0
  54. package/src/web/button/manifest.json +177 -0
  55. package/src/web/calendar/AI_GUIDE.md +151 -0
  56. package/src/web/calendar/calendar.css +1 -0
  57. package/src/web/calendar/calendar.vue +1536 -0
  58. package/src/web/calendar/calendar.vue.d.ts +261 -0
  59. package/src/web/calendar/index.ts +3 -0
  60. package/src/web/calendar/manifest.json +470 -0
  61. package/src/web/card/AI_GUIDE.md +133 -0
  62. package/src/web/card/card.css +1 -0
  63. package/src/web/card/card.vue +423 -0
  64. package/src/web/card/card.vue.d.ts +232 -0
  65. package/src/web/card/index.ts +3 -0
  66. package/src/web/card/manifest.json +357 -0
  67. package/src/web/checkbox/AI_GUIDE.md +146 -0
  68. package/src/web/checkbox/checkbox.css +1 -0
  69. package/src/web/checkbox/checkbox.vue +304 -0
  70. package/src/web/checkbox/checkbox.vue.d.ts +189 -0
  71. package/src/web/checkbox/index.ts +3 -0
  72. package/src/web/checkbox/manifest.json +294 -0
  73. package/src/web/chip/AI_GUIDE.md +186 -0
  74. package/src/web/chip/chip.css +1 -0
  75. package/src/web/chip/chip.vue +220 -0
  76. package/src/web/chip/chip.vue.d.ts +140 -0
  77. package/src/web/chip/index.ts +3 -0
  78. package/src/web/chip/manifest.json +186 -0
  79. package/src/web/dropdown/AI_GUIDE.md +167 -0
  80. package/src/web/dropdown/dropdown.css +1 -0
  81. package/src/web/dropdown/dropdown.vue +1257 -0
  82. package/src/web/dropdown/dropdown.vue.d.ts +381 -0
  83. package/src/web/dropdown/index.ts +3 -0
  84. package/src/web/dropdown/manifest.json +576 -0
  85. package/src/web/flex/AI_GUIDE.md +113 -0
  86. package/src/web/flex/flex-item.vue +94 -0
  87. package/src/web/flex/flex-item.vue.d.ts +84 -0
  88. package/src/web/flex/flex.css +1 -0
  89. package/src/web/flex/flex.vue +103 -0
  90. package/src/web/flex/flex.vue.d.ts +92 -0
  91. package/src/web/flex/index.ts +5 -0
  92. package/src/web/flex/manifest.json +162 -0
  93. package/src/web/form/index.ts +7 -0
  94. package/src/web/grid/AI_GUIDE.md +112 -0
  95. package/src/web/grid/grid-item.vue +109 -0
  96. package/src/web/grid/grid-item.vue.d.ts +99 -0
  97. package/src/web/grid/grid.css +1 -0
  98. package/src/web/grid/grid.vue +94 -0
  99. package/src/web/grid/grid.vue.d.ts +84 -0
  100. package/src/web/grid/index.ts +5 -0
  101. package/src/web/grid/manifest.json +153 -0
  102. package/src/web/index.ts +86 -0
  103. package/src/web/input/AI_GUIDE.md +159 -0
  104. package/src/web/input/index.ts +3 -0
  105. package/src/web/input/input.css +1 -0
  106. package/src/web/input/input.vue +521 -0
  107. package/src/web/input/input.vue.d.ts +274 -0
  108. package/src/web/input/manifest.json +465 -0
  109. package/src/web/input-number/AI_GUIDE.md +164 -0
  110. package/src/web/input-number/index.ts +3 -0
  111. package/src/web/input-number/input-number.css +1 -0
  112. package/src/web/input-number/input-number.vue +1153 -0
  113. package/src/web/input-number/input-number.vue.d.ts +343 -0
  114. package/src/web/input-number/manifest.json +575 -0
  115. package/src/web/modal/AI_GUIDE.md +171 -0
  116. package/src/web/modal/index.ts +3 -0
  117. package/src/web/modal/manifest.json +375 -0
  118. package/src/web/modal/modal.css +1 -0
  119. package/src/web/modal/modal.vue +344 -0
  120. package/src/web/modal/modal.vue.d.ts +64 -0
  121. package/src/web/pagination/AI_GUIDE.md +148 -0
  122. package/src/web/pagination/index.ts +21 -0
  123. package/src/web/pagination/manifest.json +432 -0
  124. package/src/web/pagination/pagination-content.vue +42 -0
  125. package/src/web/pagination/pagination-content.vue.d.ts +28 -0
  126. package/src/web/pagination/pagination-ellipsis.vue +55 -0
  127. package/src/web/pagination/pagination-ellipsis.vue.d.ts +28 -0
  128. package/src/web/pagination/pagination-first.vue +161 -0
  129. package/src/web/pagination/pagination-first.vue.d.ts +67 -0
  130. package/src/web/pagination/pagination-item.vue +42 -0
  131. package/src/web/pagination/pagination-item.vue.d.ts +28 -0
  132. package/src/web/pagination/pagination-last.vue +161 -0
  133. package/src/web/pagination/pagination-last.vue.d.ts +67 -0
  134. package/src/web/pagination/pagination-link.vue +118 -0
  135. package/src/web/pagination/pagination-link.vue.d.ts +61 -0
  136. package/src/web/pagination/pagination-next.vue +160 -0
  137. package/src/web/pagination/pagination-next.vue.d.ts +68 -0
  138. package/src/web/pagination/pagination-previous.vue +160 -0
  139. package/src/web/pagination/pagination-previous.vue.d.ts +68 -0
  140. package/src/web/pagination/pagination.css +1 -0
  141. package/src/web/pagination/pagination.vue +730 -0
  142. package/src/web/pagination/pagination.vue.d.ts +247 -0
  143. package/src/web/popover/AI_GUIDE.md +163 -0
  144. package/src/web/popover/index.ts +3 -0
  145. package/src/web/popover/manifest.json +396 -0
  146. package/src/web/popover/popover.css +1 -0
  147. package/src/web/popover/popover.vue +579 -0
  148. package/src/web/popover/popover.vue.d.ts +83 -0
  149. package/src/web/radio/AI_GUIDE.md +155 -0
  150. package/src/web/radio/index.ts +3 -0
  151. package/src/web/radio/manifest.json +294 -0
  152. package/src/web/radio/radio.css +1 -0
  153. package/src/web/radio/radio.vue +288 -0
  154. package/src/web/radio/radio.vue.d.ts +182 -0
  155. package/src/web/selectbox/AI_GUIDE.md +216 -0
  156. package/src/web/selectbox/index.ts +3 -0
  157. package/src/web/selectbox/manifest.json +477 -0
  158. package/src/web/selectbox/selectbox.css +1 -0
  159. package/src/web/selectbox/selectbox.vue +1024 -0
  160. package/src/web/selectbox/selectbox.vue.d.ts +300 -0
  161. package/src/web/sonner/AI_GUIDE.md +98 -0
  162. package/src/web/sonner/index.ts +114 -0
  163. package/src/web/sonner/manifest.json +132 -0
  164. package/src/web/sonner/sonner.css +1 -0
  165. package/src/web/sonner/sonner.vue +180 -0
  166. package/src/web/sonner/sonner.vue.d.ts +113 -0
  167. package/src/web/table/AI_GUIDE.md +145 -0
  168. package/src/web/table/index.ts +34 -0
  169. package/src/web/table/manifest.json +168 -0
  170. package/src/web/table/table-body.vue +42 -0
  171. package/src/web/table/table-body.vue.d.ts +28 -0
  172. package/src/web/table/table-caption.vue +42 -0
  173. package/src/web/table/table-caption.vue.d.ts +28 -0
  174. package/src/web/table/table-cell.vue +71 -0
  175. package/src/web/table/table-cell.vue.d.ts +49 -0
  176. package/src/web/table/table-empty.vue +105 -0
  177. package/src/web/table/table-empty.vue.d.ts +57 -0
  178. package/src/web/table/table-footer.vue +42 -0
  179. package/src/web/table/table-footer.vue.d.ts +28 -0
  180. package/src/web/table/table-head.vue +78 -0
  181. package/src/web/table/table-head.vue.d.ts +50 -0
  182. package/src/web/table/table-header.vue +42 -0
  183. package/src/web/table/table-header.vue.d.ts +28 -0
  184. package/src/web/table/table-row.vue +70 -0
  185. package/src/web/table/table-row.vue.d.ts +44 -0
  186. package/src/web/table/table.css +1 -0
  187. package/src/web/table/table.vue +298 -0
  188. package/src/web/table/table.vue.d.ts +119 -0
  189. package/src/web/tabs/AI_GUIDE.md +150 -0
  190. package/src/web/tabs/index.ts +2 -0
  191. package/src/web/tabs/manifest.json +315 -0
  192. package/src/web/tabs/tabs.css +1 -0
  193. package/src/web/tabs/tabs.vue +164 -0
  194. package/src/web/tabs/tabs.vue.d.ts +60 -0
  195. package/src/web/text/AI_GUIDE.md +129 -0
  196. package/src/web/text/index.ts +2 -0
  197. package/src/web/text/manifest.json +195 -0
  198. package/src/web/text/text.css +1 -0
  199. package/src/web/text/text.vue +195 -0
  200. package/src/web/text/text.vue.d.ts +161 -0
  201. package/src/web/textarea/AI_GUIDE.md +141 -0
  202. package/src/web/textarea/index.ts +3 -0
  203. package/src/web/textarea/manifest.json +438 -0
  204. package/src/web/textarea/textarea.css +1 -0
  205. package/src/web/textarea/textarea.vue +458 -0
  206. package/src/web/textarea/textarea.vue.d.ts +265 -0
  207. package/src/web/tooltip/AI_GUIDE.md +110 -0
  208. package/src/web/tooltip/index.ts +3 -0
  209. package/src/web/tooltip/manifest.json +222 -0
  210. package/src/web/tooltip/tooltip.css +1 -0
  211. package/src/web/tooltip/tooltip.vue +417 -0
  212. package/src/web/tooltip/tooltip.vue.d.ts +150 -0
  213. package/src/webview/bottomsheet/AI_GUIDE.md +141 -0
  214. package/src/webview/bottomsheet/bottomsheet.css +1 -0
  215. package/src/webview/bottomsheet/bottomsheet.vue +441 -0
  216. package/src/webview/bottomsheet/bottomsheet.vue.d.ts +178 -0
  217. package/src/webview/bottomsheet/index.ts +4 -0
  218. package/src/webview/bottomsheet/manifest.json +377 -0
  219. package/src/webview/button/AI_GUIDE.md +79 -0
  220. package/src/webview/button/button-ios.css +1 -0
  221. package/src/webview/button/button-ios.vue +138 -0
  222. package/src/webview/button/button-ios.vue.d.ts +102 -0
  223. package/src/webview/button/button-material.css +1 -0
  224. package/src/webview/button/button-material.vue +138 -0
  225. package/src/webview/button/button-material.vue.d.ts +102 -0
  226. package/src/webview/button/index.ts +7 -0
  227. package/src/webview/button/manifest.json +148 -0
  228. package/src/webview/index.ts +7 -0
  229. package/tailwind-preset.cjs +62 -0
  230. package/tailwind-preset.js +62 -0
  231. package/ttdk-manifest.json +10188 -0
  232. package/README.md +0 -3
@@ -0,0 +1,1153 @@
1
+ <template>
2
+ <div
3
+ :class="`ttdk-form-item ${className || ''}`.trim()"
4
+ :data-disabled="disabled"
5
+ :data-error="Boolean(error || errorMessage)"
6
+ :data-size="size || 'md'"
7
+ :data-block="block ? 'true' : undefined"
8
+ :style="{
9
+ ...buildUiVars(ui),
10
+ ...(ui || {}),
11
+ ...(typeof style === 'object' ? style : {}),
12
+ }"
13
+ >
14
+ <template v-if="label">
15
+ <label
16
+ :class="`ttdk-form-label ${labelClass || ''}`.trim()"
17
+ :for="id"
18
+ :style="{
19
+ ...buildUiVars(labelStyle),
20
+ ...(labelStyle || {}),
21
+ }"
22
+ ><span>{{ label }}</span>
23
+ <template v-if="required">
24
+ <span class="ttdk-form-required" aria-hidden="true"> * </span>
25
+ </template>
26
+
27
+ <template v-if="optional">
28
+ <span class="ttdk-form-optional">{{
29
+ optionalText || "(Opsional)"
30
+ }}</span>
31
+ </template>
32
+ </label>
33
+ </template>
34
+
35
+ <template v-if="helperText && helperTextPosition === 'top'">
36
+ <div
37
+ :class="`ttdk-form-helper-text ${helperTextClass || ''}`.trim()"
38
+ :style="{
39
+ ...buildUiVars(helperTextStyle),
40
+ ...(helperTextStyle || {}),
41
+ }"
42
+ >
43
+ {{ helperText }}
44
+ </div>
45
+ </template>
46
+
47
+ <div
48
+ :class="
49
+ `ttdk-input-wrapper ttdk-input-number-wrapper ${
50
+ wrapperClass || ''
51
+ }`.trim()
52
+ "
53
+ :data-filled="Boolean(String(getRawValue()) !== '')"
54
+ :data-error="Boolean(error || errorMessage)"
55
+ :data-disabled="Boolean(disabled)"
56
+ :data-size="size || 'md'"
57
+ :data-rounded="rounded || 'md'"
58
+ :data-split="
59
+ shouldShowControls() && controlsPosition === 'split'
60
+ ? 'true'
61
+ : undefined
62
+ "
63
+ :style="{
64
+ ...buildUiVars(wrapperStyle),
65
+ ...(wrapperStyle || {}),
66
+ }"
67
+ >
68
+ <template v-if="shouldShowControls() && controlsPosition === 'split'">
69
+ <button
70
+ type="button"
71
+ aria-label="Kurangi nilai"
72
+ class="ttdk-input-number-split-btn ttdk-input-number-split-down"
73
+ :tabIndex="-1"
74
+ :disabled="!canDecrement()"
75
+ :data-disabled="!canDecrement() ? 'true' : 'false'"
76
+ @click="async (event) => stepDown()"
77
+ ></button>
78
+ </template>
79
+
80
+ <template v-if="addonLeft">
81
+ <div class="ttdk-input-addon ttdk-input-addon-left">
82
+ {{ addonLeft }}
83
+ </div>
84
+ </template>
85
+
86
+ <div class="ttdk-input-inner">
87
+ <template v-if="iconLeft">
88
+ <span
89
+ class="ttdk-input-icon ttdk-input-icon-left"
90
+ aria-hidden="true"
91
+ >{{ iconLeft }}</span
92
+ >
93
+ </template>
94
+
95
+ <input
96
+ ref="inputRef"
97
+ :class="
98
+ `ttdk-input-control ttdk-input-number-control ${
99
+ inputClass || ''
100
+ }`.trim()
101
+ "
102
+ :type="getInputType()"
103
+ :inputMode="getInputMode()"
104
+ :name="name"
105
+ :id="id"
106
+ :value="getDisplayValue()"
107
+ :placeholder="placeholder"
108
+ :disabled="disabled"
109
+ :readOnly="readOnly"
110
+ :required="required"
111
+ :autocomplete="autoComplete"
112
+ :maxLength="maxLength"
113
+ :minLength="minLength"
114
+ :min="min"
115
+ :max="max"
116
+ :step="step !== undefined ? step : 1"
117
+ :aria-invalid="Boolean(error || errorMessage)"
118
+ :style="{
119
+ ...buildUiVars(inputStyle),
120
+ ...(inputStyle || {}),
121
+ }"
122
+ @change="async (e) => handleChange(e)"
123
+ @input="async (e) => handleInput(e)"
124
+ @blur="async (e) => handleBlur(e)"
125
+ @focus="async (e) => onFocus && onFocus(e)"
126
+ @copy="async (e) => handleCopy(e)"
127
+ @cut="async (e) => handleCut(e)"
128
+ @keydown="async (e) => handleKeyDown(e)"
129
+ @keyup="async (e) => onKeyUp && onKeyUp(e)"
130
+ />
131
+ <template v-if="loading">
132
+ <span
133
+ class="ttdk-input-icon ttdk-input-icon-right ttdk-input-spinner"
134
+ aria-hidden="true"
135
+ ><svg viewBox="0 0 24 24">
136
+ <line
137
+ x1="12"
138
+ y1="2.5"
139
+ x2="12"
140
+ y2="6.5"
141
+ opacity="0.175"
142
+ transform="rotate(0 12 12)"
143
+ ></line>
144
+ <line
145
+ x1="12"
146
+ y1="2.5"
147
+ x2="12"
148
+ y2="6.5"
149
+ opacity="0.25"
150
+ transform="rotate(30 12 12)"
151
+ ></line>
152
+ <line
153
+ x1="12"
154
+ y1="2.5"
155
+ x2="12"
156
+ y2="6.5"
157
+ opacity="0.325"
158
+ transform="rotate(60 12 12)"
159
+ ></line>
160
+ <line
161
+ x1="12"
162
+ y1="2.5"
163
+ x2="12"
164
+ y2="6.5"
165
+ opacity="0.4"
166
+ transform="rotate(90 12 12)"
167
+ ></line>
168
+ <line
169
+ x1="12"
170
+ y1="2.5"
171
+ x2="12"
172
+ y2="6.5"
173
+ opacity="0.475"
174
+ transform="rotate(120 12 12)"
175
+ ></line>
176
+ <line
177
+ x1="12"
178
+ y1="2.5"
179
+ x2="12"
180
+ y2="6.5"
181
+ opacity="0.55"
182
+ transform="rotate(150 12 12)"
183
+ ></line>
184
+ <line
185
+ x1="12"
186
+ y1="2.5"
187
+ x2="12"
188
+ y2="6.5"
189
+ opacity="0.625"
190
+ transform="rotate(180 12 12)"
191
+ ></line>
192
+ <line
193
+ x1="12"
194
+ y1="2.5"
195
+ x2="12"
196
+ y2="6.5"
197
+ opacity="0.7"
198
+ transform="rotate(210 12 12)"
199
+ ></line>
200
+ <line
201
+ x1="12"
202
+ y1="2.5"
203
+ x2="12"
204
+ y2="6.5"
205
+ opacity="0.775"
206
+ transform="rotate(240 12 12)"
207
+ ></line>
208
+ <line
209
+ x1="12"
210
+ y1="2.5"
211
+ x2="12"
212
+ y2="6.5"
213
+ opacity="0.85"
214
+ transform="rotate(270 12 12)"
215
+ ></line>
216
+ <line
217
+ x1="12"
218
+ y1="2.5"
219
+ x2="12"
220
+ y2="6.5"
221
+ opacity="0.925"
222
+ transform="rotate(300 12 12)"
223
+ ></line>
224
+ <line
225
+ x1="12"
226
+ y1="2.5"
227
+ x2="12"
228
+ y2="6.5"
229
+ opacity="1"
230
+ transform="rotate(330 12 12)"
231
+ ></line></svg
232
+ ></span>
233
+ </template>
234
+
235
+ <template v-if="!loading && iconRight">
236
+ <span
237
+ class="ttdk-input-icon ttdk-input-icon-right"
238
+ aria-hidden="true"
239
+ >{{ iconRight }}</span
240
+ >
241
+ </template>
242
+
243
+ <template v-if="shouldShowControls() && controlsPosition !== 'split'">
244
+ <div
245
+ :class="`ttdk-input-number-stepper ${controlsClass || ''}`.trim()"
246
+ :style="{
247
+ ...buildUiVars(controlsStyle),
248
+ ...(controlsStyle || {}),
249
+ }"
250
+ >
251
+ <button
252
+ type="button"
253
+ aria-label="Tingkatkan nilai"
254
+ class="ttdk-input-number-btn ttdk-input-number-btn-up"
255
+ :tabIndex="-1"
256
+ :disabled="!canIncrement()"
257
+ :data-disabled="!canIncrement() ? 'true' : 'false'"
258
+ @click="async (event) => stepUp()"
259
+ ></button
260
+ ><button
261
+ type="button"
262
+ aria-label="Kurangi nilai"
263
+ class="ttdk-input-number-btn ttdk-input-number-btn-down"
264
+ :tabIndex="-1"
265
+ :disabled="!canDecrement()"
266
+ :data-disabled="!canDecrement() ? 'true' : 'false'"
267
+ @click="async (event) => stepDown()"
268
+ ></button>
269
+ </div>
270
+ </template>
271
+ </div>
272
+ <template v-if="addonRight">
273
+ <div class="ttdk-input-addon ttdk-input-addon-right">
274
+ {{ addonRight }}
275
+ </div>
276
+ </template>
277
+
278
+ <template v-if="shouldShowControls() && controlsPosition === 'split'">
279
+ <button
280
+ type="button"
281
+ aria-label="Tingkatkan nilai"
282
+ class="ttdk-input-number-split-btn ttdk-input-number-split-up"
283
+ :tabIndex="-1"
284
+ :disabled="!canIncrement()"
285
+ :data-disabled="!canIncrement() ? 'true' : 'false'"
286
+ @click="async (event) => stepUp()"
287
+ ></button>
288
+ </template>
289
+ </div>
290
+ <template v-if="helperText && helperTextPosition !== 'top'">
291
+ <div
292
+ :class="`ttdk-form-helper-text ${helperTextClass || ''}`.trim()"
293
+ :style="{
294
+ ...buildUiVars(helperTextStyle),
295
+ ...(helperTextStyle || {}),
296
+ }"
297
+ >
298
+ {{ helperText }}
299
+ </div>
300
+ </template>
301
+
302
+ <template v-if="errorMessage && (error || errorMessage)">
303
+ <div
304
+ role="alert"
305
+ :class="`ttdk-form-error-msg ${errorMessageClass || ''}`.trim()"
306
+ :style="{
307
+ ...buildUiVars(errorMessageStyle),
308
+ ...(errorMessageStyle || {}),
309
+ }"
310
+ >
311
+ <span>{{ errorMessage }}</span>
312
+ </div>
313
+ </template>
314
+ </div>
315
+ </template>
316
+
317
+ <script setup lang="ts">
318
+ import { ref } from "vue";
319
+
320
+ import { buildUiVars, UiProps } from "../../core/types";
321
+
322
+ export type InputNumberUiProps = UiProps;
323
+ export interface InputNumberProps {
324
+ /**
325
+ * Teks label judul field yang ditampilkan di atas input (14px Semibold, #141313).
326
+ */
327
+ label?: string;
328
+
329
+ /**
330
+ * Style kustom untuk elemen label judul field (UiProps).
331
+ */
332
+ labelStyle?: UiProps;
333
+
334
+ /**
335
+ * Class CSS kustom untuk elemen label judul field.
336
+ */
337
+ labelClass?: string;
338
+
339
+ /**
340
+ * Style kustom untuk elemen kontainer input wrapper (UiProps).
341
+ */
342
+ wrapperStyle?: UiProps;
343
+
344
+ /**
345
+ * Class CSS kustom untuk elemen kontainer input wrapper.
346
+ */
347
+ wrapperClass?: string;
348
+
349
+ /**
350
+ * Style kustom untuk elemen input control HTML (UiProps).
351
+ */
352
+ inputStyle?: UiProps;
353
+
354
+ /**
355
+ * Class CSS kustom untuk elemen input control HTML.
356
+ */
357
+ inputClass?: string;
358
+
359
+ /**
360
+ * Style kustom untuk elemen stepper kontrol tombol (UiProps).
361
+ */
362
+ controlsStyle?: UiProps;
363
+
364
+ /**
365
+ * Class CSS kustom untuk elemen stepper kontrol tombol.
366
+ */
367
+ controlsClass?: string;
368
+
369
+ /**
370
+ * Style kustom untuk elemen pesan error validasi (UiProps).
371
+ */
372
+ errorMessageStyle?: UiProps;
373
+
374
+ /**
375
+ * Class CSS kustom untuk elemen pesan error validasi.
376
+ */
377
+ errorMessageClass?: string;
378
+
379
+ /**
380
+ * Style kustom untuk elemen helper text (UiProps).
381
+ */
382
+ helperTextStyle?: UiProps;
383
+
384
+ /**
385
+ * Class CSS kustom untuk elemen helper text.
386
+ */
387
+ helperTextClass?: string;
388
+
389
+ /**
390
+ * Menandai field sebagai opsi opsional dengan menambahkan teks '(Opsional)' (12px Regular, #9698A2).
391
+ */
392
+ optional?: boolean;
393
+
394
+ /**
395
+ * Kustomisasi teks keterangan opsional.
396
+ * @default '(Opsional)'
397
+ */
398
+ optionalText?: string;
399
+
400
+ /**
401
+ * Nilai teks placeholder saat input kosong (#9698A2).
402
+ */
403
+ placeholder?: string;
404
+
405
+ /**
406
+ * Nilai terkontrol (controlled value) pada input number.
407
+ */
408
+ value?: number | string;
409
+
410
+ /**
411
+ * Nilai awal tidak terkontrol (uncontrolled initial value).
412
+ */
413
+ defaultValue?: number | string;
414
+
415
+ /**
416
+ * Nama form field HTML untuk integrasi formulir.
417
+ */
418
+ name?: string;
419
+
420
+ /**
421
+ * Identifier unik elemen input.
422
+ */
423
+ id?: string;
424
+
425
+ /**
426
+ * Status apakah input sedang dalam kondisi error / tidak valid.
427
+ * @default false
428
+ */
429
+ error?: boolean;
430
+
431
+ /**
432
+ * Pesan teks penjelasan kesalahan validasi di bawah field.
433
+ */
434
+ errorMessage?: string;
435
+
436
+ /**
437
+ * Teks petunjuk atau keterangan bantuan di bawah field (12px Regular, #3C4245).
438
+ */
439
+ helperText?: string;
440
+
441
+ /**
442
+ * Posisi teks helper
443
+ */
444
+ helperTextPosition?: "top" | "bottom";
445
+
446
+ /**
447
+ * Skala ukuran input field.
448
+ * - `'sm'`: 38px
449
+ * - `'md'`: 48px (standar)
450
+ * - `'lg'`: 56px
451
+ * @default 'md'
452
+ */
453
+ size?: "sm" | "md" | "lg";
454
+
455
+ /**
456
+ * Bentuk sudut kelengkungan input.
457
+ * - `'none'`: 0px
458
+ * - `'sm'`: 4px
459
+ * - `'md'`: 8px (standar desain)
460
+ * - `'lg'`: 12px
461
+ * - `'full'`: 9999px (kapsul)
462
+ * @default 'md'
463
+ */
464
+ rounded?: "none" | "sm" | "md" | "lg" | "full";
465
+
466
+ /**
467
+ * Menjadikan lebar field input memenuhi kontainer penuh (full-width 100%).
468
+ * @default false
469
+ */
470
+ block?: boolean;
471
+
472
+ /**
473
+ * Status apakah field dinonaktifkan (disabled).
474
+ * @default false
475
+ */
476
+ disabled?: boolean;
477
+
478
+ /**
479
+ * Status apakah field bersifat hanya-baca (readonly).
480
+ * @default false
481
+ */
482
+ readOnly?: boolean;
483
+
484
+ /**
485
+ * Menandai field sebagai input wajib diisi (menampilkan tanda bintang merah *).
486
+ * @default false
487
+ */
488
+ required?: boolean;
489
+
490
+ /**
491
+ * Ikon di sebelah kiri dalam input (ukuran 20-24px, misal: Hash, Calculator, Currency).
492
+ */
493
+ iconLeft?: any;
494
+
495
+ /**
496
+ * Ikon di sebelah kanan dalam input (ukuran 20-24px).
497
+ */
498
+ iconRight?: any;
499
+
500
+ /**
501
+ * Addon / teks prefix di sebelah kiri luar input (misal: 'Rp', '+62').
502
+ */
503
+ addonLeft?: string | any;
504
+
505
+ /**
506
+ * Addon / teks suffix di sebelah kanan luar input (misal: 'kg', 'pcs', '%').
507
+ */
508
+ addonRight?: string | any;
509
+
510
+ /**
511
+ * Konfigurasi atribut autocomplete HTML.
512
+ */
513
+ autoComplete?: string;
514
+
515
+ /**
516
+ * Nilai minimum yang diizinkan untuk input number.
517
+ */
518
+ min?: number;
519
+
520
+ /**
521
+ * Nilai maksimum yang diizinkan untuk input number.
522
+ */
523
+ max?: number;
524
+
525
+ /**
526
+ * Nilai selisih kenaikan atau penurunan setiap kali stepper ditekan.
527
+ * @default 1
528
+ */
529
+ step?: number;
530
+
531
+ /**
532
+ * Jumlah angka di belakang koma (presisi desimal).
533
+ */
534
+ precision?: number;
535
+
536
+ /**
537
+ * Mengaktifkan format pemisah ribuan otomatis dengan titik '.' (contoh: 1.000 atau 10.000).
538
+ * Nilai yang diteruskan ke callback form (onChange / onValueChange) tetap berupa number murni standar (contoh: 1000).
539
+ * @default false
540
+ */
541
+ thousandSeparator?: boolean;
542
+
543
+ /**
544
+ * Mengizinkan tanda eksponensial ilmiah 'e' / 'E'.
545
+ * @default false
546
+ */
547
+ allowExponential?: boolean;
548
+
549
+ /**
550
+ * Tipe input HTML. Secara default 'text' dengan inputMode 'numeric'/'decimal' agar mendukung formatting dan pembatasan karakter tanpa bug bawaan browser.
551
+ * @default 'text'
552
+ */
553
+ type?: string;
554
+
555
+ /**
556
+ * Menampilkan tombol stepper panah kontrol atas/bawah.
557
+ * @default true
558
+ */
559
+ controls?: boolean;
560
+
561
+ /**
562
+ * Menghilangkan tombol kontrol increment dan decrement sehingga tampil seperti input teks biasa.
563
+ * @default false
564
+ */
565
+ withoutButton?: boolean;
566
+
567
+ /**
568
+ * Posisi letak tombol kontrol stepper:
569
+ * - `'right'`: tombol stepper ditumpuk di sisi kanan (standar)
570
+ * - `'split'`: tombol minus di sisi kiri dan tombol plus di sisi kanan (mode counter)
571
+ * @default 'right'
572
+ */
573
+ controlsPosition?: "right" | "split";
574
+
575
+ /**
576
+ * Batas maksimum panjang karakter.
577
+ */
578
+ maxLength?: number;
579
+
580
+ /**
581
+ * Batas minimum panjang karakter.
582
+ */
583
+ minLength?: number;
584
+
585
+ /**
586
+ * Inline CSS style object native.
587
+ */
588
+ style?: any;
589
+
590
+ /**
591
+ * Kustomisasi visual granular root / form-item (UiProps).
592
+ */
593
+ ui?: UiProps;
594
+
595
+ /**
596
+ * Callback event saat nilai input berubah (SyntheticEvent standar HTML).
597
+ */
598
+ onChange?: (event: any) => void;
599
+
600
+ /**
601
+ * Callback event saat nilai numerik angka berubah.
602
+ */
603
+ onValueChange?: (value: number | undefined) => void;
604
+
605
+ /**
606
+ * Callback event saat pengguna mengetik (input event).
607
+ */
608
+ onInput?: (event: any) => void;
609
+
610
+ /**
611
+ * Callback event saat field input kehilangan fokus.
612
+ */
613
+ onBlur?: (event: any) => void;
614
+
615
+ /**
616
+ * Callback event saat field input mendapatkan fokus.
617
+ */
618
+ onFocus?: (event: any) => void;
619
+
620
+ /**
621
+ * Ref instance elemen input HTML untuk akses kontrol DOM langsung (focus, blur, select).
622
+ */
623
+ inputRef?: any;
624
+
625
+ /**
626
+ * Class CSS kustom.
627
+ */
628
+ className?: string;
629
+
630
+ /**
631
+ * Callback event tombol keyboard ditekan.
632
+ */
633
+ onKeyDown?: (event: any) => void;
634
+
635
+ /**
636
+ * Callback event tombol keyboard dilepaskan.
637
+ */
638
+ onKeyUp?: (event: any) => void;
639
+
640
+ /**
641
+ * Callback event saat teks di-copy.
642
+ */
643
+ onCopy?: (event: any) => void;
644
+
645
+ /**
646
+ * Callback event saat teks di-cut.
647
+ */
648
+ onCut?: (event: any) => void;
649
+
650
+ /**
651
+ * Menampilkan spinner dan menonaktifkan interaksi field sementara menunggu proses async.
652
+ * @default false
653
+ */
654
+ loading?: boolean;
655
+ }
656
+
657
+ /**
658
+ * Komponen InputNumber TTDK sesuai spesifikasi Anatomy Desain Form & Input:
659
+ * 1. Field title / label (14px Semibold, #141313)
660
+ * 2. (Opsional) label (12px Regular, #9698A2)
661
+ * 3. Border radius 8px default (rounded)
662
+ * 4. Stepper controls (+/- spin buttons) dengan mode right-stacked atau split-counter
663
+ * 5. Input control numerik terproteksi min, max, step, & precision
664
+ * 6. Additional information / Helper text & error message
665
+ */
666
+
667
+ const props = withDefaults(defineProps<InputNumberProps>(), {
668
+ controls: true,
669
+ });
670
+ const innerValue = ref(
671
+ props.value !== undefined
672
+ ? props.value
673
+ : props.defaultValue !== undefined
674
+ ? props.defaultValue
675
+ : ""
676
+ );
677
+
678
+ function shouldShowControls() {
679
+ if (props.withoutButton) {
680
+ return false;
681
+ }
682
+ return props.controls !== false;
683
+ }
684
+ function getStep() {
685
+ return props.step !== undefined ? props.step : 1;
686
+ }
687
+ function getPrecision() {
688
+ if (props.precision !== undefined) {
689
+ return props.precision;
690
+ }
691
+ if (props.step !== undefined) {
692
+ const stepVal = props.step;
693
+ const stepStr = String(stepVal);
694
+ const dotIdx = stepStr.indexOf(".");
695
+ return dotIdx === -1 ? 0 : stepStr.length - dotIdx - 1;
696
+ }
697
+ return -1;
698
+ }
699
+ function getThousandSep() {
700
+ return props.thousandSeparator ? "." : "";
701
+ }
702
+ function getInputType() {
703
+ if (props.type) return props.type;
704
+ return "text";
705
+ }
706
+ function getInputMode() {
707
+ return getPrecision() === 0 ? "numeric" : "decimal";
708
+ }
709
+ function parseToRawNumber(displayVal: any) {
710
+ if (displayVal === undefined || displayVal === null || displayVal === "") {
711
+ return "";
712
+ }
713
+ if (typeof displayVal === "number") {
714
+ return String(displayVal);
715
+ }
716
+ let s = String(displayVal).trim();
717
+ if (s === "-" || s === "") return s;
718
+ let isNegative = false;
719
+ if (s.startsWith("-")) {
720
+ isNegative = true;
721
+ s = s.slice(1);
722
+ }
723
+
724
+ // Hapus titik pemisah ribuan
725
+ s = s.replace(/\./g, "");
726
+
727
+ // Ubah koma desimal menjadi titik desimal standar
728
+ s = s.replace(/,/g, ".");
729
+
730
+ // Hapus karakter selain digit dan titik
731
+ s = s.replace(/[^0-9.]/g, "");
732
+
733
+ // Pastikan maksimal 1 titik desimal
734
+ const dotIndex = s.indexOf(".");
735
+ if (dotIndex !== -1) {
736
+ s = s.slice(0, dotIndex + 1) + s.slice(dotIndex + 1).replace(/\./g, "");
737
+ }
738
+ return (isNegative ? "-" : "") + s;
739
+ }
740
+ function formatValue(rawVal: any) {
741
+ if (rawVal === undefined || rawVal === null || rawVal === "") {
742
+ return "";
743
+ }
744
+ const strVal = String(rawVal);
745
+ if (strVal === "-") return "-";
746
+ const thSep = getThousandSep();
747
+ let isNegative = false;
748
+ let clean = strVal;
749
+ if (clean.startsWith("-")) {
750
+ isNegative = true;
751
+ clean = clean.slice(1);
752
+ }
753
+
754
+ // Pisahkan bagian integer dan desimal
755
+ let intPart = clean;
756
+ let decPart = "";
757
+ let hasDecimal = false;
758
+ if (clean.includes(".")) {
759
+ hasDecimal = true;
760
+ const parts = clean.split(".");
761
+ intPart = parts[0];
762
+ decPart = parts.slice(1).join("");
763
+ } else if (clean.includes(",")) {
764
+ hasDecimal = true;
765
+ const parts = clean.split(",");
766
+ intPart = parts[0];
767
+ decPart = parts.slice(1).join("");
768
+ }
769
+
770
+ // Format ribuan pada integer part dengan titik jika thousandSeparator aktif
771
+ const formattedInt = thSep
772
+ ? intPart.replace(/\B(?=(\d{3})+(?!\d))/g, thSep)
773
+ : intPart;
774
+ let result =
775
+ (isNegative ? "-" : "") + (formattedInt || (hasDecimal ? "0" : ""));
776
+ if (hasDecimal) {
777
+ result += "," + decPart;
778
+ }
779
+ return result;
780
+ }
781
+ function getRawValue() {
782
+ // 1. Controlled mode: jika prop value diberikan ke komponen
783
+ if (props.value !== undefined) {
784
+ // Jika user sedang mengetik tanda minus murni ('-'), pertahankan!
785
+ if (innerValue.value === "-") {
786
+ return "-";
787
+ }
788
+ if (
789
+ props.value === undefined ||
790
+ props.value === null ||
791
+ props.value === ""
792
+ ) {
793
+ return "";
794
+ }
795
+ // Pertahankan tanda minus atau titik desimal saat sedang diketik (misal '12,' atau '12,0' atau '-')
796
+ if (
797
+ typeof innerValue.value === "string" &&
798
+ (innerValue.value.includes(".") ||
799
+ innerValue.value.includes(",") ||
800
+ innerValue.value === "-")
801
+ ) {
802
+ const innerNum = Number(parseToRawNumber(innerValue.value));
803
+ const propNum = Number(props.value);
804
+ if (innerNum === propNum) {
805
+ return innerValue.value;
806
+ }
807
+ }
808
+ return props.value;
809
+ }
810
+ // 2. Uncontrolled mode: gunakan state.innerValue
811
+ return innerValue.value !== undefined && innerValue.value !== null
812
+ ? innerValue.value
813
+ : "";
814
+ }
815
+ function getDisplayValue() {
816
+ const raw = getRawValue();
817
+ if (raw === undefined || raw === null || raw === "") return "";
818
+ if (raw === "-") return "-";
819
+ return formatValue(raw);
820
+ }
821
+ function getCurrentNumber() {
822
+ const raw = getRawValue();
823
+ if (raw === undefined || raw === null || raw === "") return undefined;
824
+ const parsed = parseToRawNumber(raw);
825
+ if (parsed === "" || parsed === "-") return undefined;
826
+ const num = Number(parsed);
827
+ return isNaN(num) ? undefined : num;
828
+ }
829
+ function canIncrement() {
830
+ if (props.disabled || props.readOnly || props.loading) return false;
831
+ const num = getCurrentNumber();
832
+ if (props.max !== undefined && num !== undefined) {
833
+ return num < props.max;
834
+ }
835
+ return true;
836
+ }
837
+ function canDecrement() {
838
+ if (props.disabled || props.readOnly || props.loading) return false;
839
+ const num = getCurrentNumber();
840
+ if (props.min !== undefined && num !== undefined) {
841
+ return num > props.min;
842
+ }
843
+ return true;
844
+ }
845
+ function clamp(val: number) {
846
+ let result = val;
847
+ if (props.min !== undefined && result < props.min) {
848
+ result = props.min;
849
+ }
850
+ if (props.max !== undefined && result > props.max) {
851
+ result = props.max;
852
+ }
853
+ const prec = getPrecision();
854
+ if (prec > 0) {
855
+ const factor = Math.pow(10, prec);
856
+ result = Math.round(result * factor) / factor;
857
+ } else if (prec === 0 && props.precision === 0) {
858
+ result = Math.round(result);
859
+ }
860
+ return result;
861
+ }
862
+ function emitValue(nextVal: number | string) {
863
+ innerValue.value = nextVal;
864
+ const rawParsed =
865
+ typeof nextVal === "string" ? parseToRawNumber(nextVal) : nextVal;
866
+ const numVal =
867
+ typeof rawParsed === "number"
868
+ ? rawParsed
869
+ : rawParsed === "" || rawParsed === "-"
870
+ ? undefined
871
+ : Number(rawParsed);
872
+ const safeNumVal = numVal !== undefined && isNaN(numVal) ? undefined : numVal;
873
+ if (props.onValueChange) {
874
+ props.onValueChange(safeNumVal);
875
+ }
876
+ if (props.onChange) {
877
+ const syntheticEvent = {
878
+ target: {
879
+ value: rawParsed,
880
+ valueAsNumber: safeNumVal,
881
+ name: props.name,
882
+ id: props.id,
883
+ },
884
+ currentTarget: {
885
+ value: rawParsed,
886
+ valueAsNumber: safeNumVal,
887
+ },
888
+ type: "change",
889
+ value: rawParsed,
890
+ };
891
+ props.onChange(syntheticEvent);
892
+ }
893
+ }
894
+ function stepUp() {
895
+ if (!canIncrement()) return;
896
+ const current = getCurrentNumber();
897
+ const step = getStep();
898
+ const base =
899
+ current !== undefined ? current : props.min !== undefined ? props.min : 0;
900
+ const next = clamp(base + step);
901
+ emitValue(next);
902
+ }
903
+ function stepDown() {
904
+ if (!canDecrement()) return;
905
+ const current = getCurrentNumber();
906
+ const step = getStep();
907
+ const base =
908
+ current !== undefined ? current : props.min !== undefined ? props.min : 0;
909
+ const next = clamp(base - step);
910
+ emitValue(next);
911
+ }
912
+ function handleInput(e: any) {
913
+ const input = e.target;
914
+ const inputValue = input ? input.value : "";
915
+ const raw = parseToRawNumber(inputValue);
916
+ if (getThousandSep()) {
917
+ const cursorPos = (input && input.selectionEnd) || inputValue.length;
918
+ let validCharsBeforeCursor = 0;
919
+ for (let i = 0; i < cursorPos; i++) {
920
+ const ch = inputValue[i];
921
+ if (/\d/.test(ch) || ch === "-" || ch === ",") {
922
+ validCharsBeforeCursor++;
923
+ }
924
+ }
925
+ const formatted = formatValue(raw);
926
+ innerValue.value = raw;
927
+ emitValue(raw);
928
+ if (input && typeof input.setSelectionRange === "function") {
929
+ let newCursorPos = 0;
930
+ let count = 0;
931
+ for (let i = 0; i < formatted.length; i++) {
932
+ const ch = formatted[i];
933
+ if (/\d/.test(ch) || ch === "-" || ch === ",") {
934
+ count++;
935
+ }
936
+ if (count >= validCharsBeforeCursor) {
937
+ newCursorPos = i + 1;
938
+ break;
939
+ }
940
+ }
941
+ if (count < validCharsBeforeCursor) {
942
+ newCursorPos = formatted.length;
943
+ }
944
+ input.value = formatted;
945
+ try {
946
+ input.setSelectionRange(newCursorPos, newCursorPos);
947
+ } catch (err) {
948
+ // ignore
949
+ }
950
+ }
951
+ } else {
952
+ innerValue.value = raw;
953
+ emitValue(raw);
954
+ }
955
+ if (props.onInput) {
956
+ props.onInput(e);
957
+ }
958
+ }
959
+ function handleChange(e: any) {
960
+ handleInput(e);
961
+ }
962
+ function handleBlur(e: any) {
963
+ const current = getCurrentNumber();
964
+ if (current !== undefined) {
965
+ const clamped = clamp(current);
966
+ if (clamped !== current) {
967
+ emitValue(clamped);
968
+ }
969
+ }
970
+ if (props.onBlur) {
971
+ props.onBlur(e);
972
+ }
973
+ }
974
+ function handleCopy(e: any) {
975
+ const input = e.target;
976
+ if (!input) return;
977
+ const start = input.selectionStart;
978
+ const end = input.selectionEnd;
979
+ if (start === null || end === null || start === end) return;
980
+ const selectedText = input.value.substring(start, end);
981
+ if (!selectedText) return;
982
+
983
+ // Hilangkan titik separator ribuan, desimal koma dipertahankan
984
+ const cleanText = selectedText.replace(/\./g, "");
985
+ if (e.clipboardData) {
986
+ e.clipboardData.setData("text/plain", cleanText);
987
+ e.preventDefault();
988
+ }
989
+ if (props.onCopy) {
990
+ props.onCopy(e);
991
+ }
992
+ }
993
+ function handleCut(e: any) {
994
+ if (props.disabled || props.readOnly) {
995
+ e.preventDefault();
996
+ return;
997
+ }
998
+ const input = e.target;
999
+ if (!input) return;
1000
+ const start = input.selectionStart;
1001
+ const end = input.selectionEnd;
1002
+ if (start === null || end === null || start === end) return;
1003
+ const selectedText = input.value.substring(start, end);
1004
+ if (!selectedText) return;
1005
+
1006
+ // Hilangkan titik separator ribuan, desimal koma dipertahankan
1007
+ const cleanText = selectedText.replace(/\./g, "");
1008
+ if (e.clipboardData) {
1009
+ e.clipboardData.setData("text/plain", cleanText);
1010
+ e.preventDefault();
1011
+ }
1012
+ const val = input.value || "";
1013
+ const nextVal = val.slice(0, start) + val.slice(end);
1014
+ const raw = parseToRawNumber(nextVal);
1015
+ innerValue.value = raw;
1016
+ emitValue(raw);
1017
+ const formatted = formatValue(raw);
1018
+ input.value = formatted;
1019
+ try {
1020
+ input.setSelectionRange(start, start);
1021
+ } catch (err) {
1022
+ // ignore
1023
+ }
1024
+ if (props.onCut) {
1025
+ props.onCut(e);
1026
+ }
1027
+ }
1028
+ function handleKeyDown(e: any) {
1029
+ // 1. Izinkan navigasi, editing, copy-paste, dan shortcut keyboard
1030
+ if (
1031
+ e.key === "Backspace" ||
1032
+ e.key === "Delete" ||
1033
+ e.key === "Tab" ||
1034
+ e.key === "Escape" ||
1035
+ e.key === "Enter" ||
1036
+ e.key === "ArrowLeft" ||
1037
+ e.key === "ArrowRight" ||
1038
+ e.key === "Home" ||
1039
+ e.key === "End" ||
1040
+ e.key === "PageUp" ||
1041
+ e.key === "PageDown" ||
1042
+ e.ctrlKey ||
1043
+ e.metaKey ||
1044
+ e.altKey ||
1045
+ e.key.length > 1
1046
+ ) {
1047
+ if (props.onKeyDown) {
1048
+ props.onKeyDown(e);
1049
+ }
1050
+ return;
1051
+ }
1052
+
1053
+ // 2. Stepper Up / Down via panah keyboard
1054
+ if (e.key === "ArrowUp") {
1055
+ e.preventDefault();
1056
+ stepUp();
1057
+ if (props.onKeyDown) props.onKeyDown(e);
1058
+ return;
1059
+ }
1060
+ if (e.key === "ArrowDown") {
1061
+ e.preventDefault();
1062
+ stepDown();
1063
+ if (props.onKeyDown) props.onKeyDown(e);
1064
+ return;
1065
+ }
1066
+
1067
+ // 3. Karakter Eksponensial ('e', 'E')
1068
+ if (e.key === "e" || e.key === "E") {
1069
+ if (!props.allowExponential) {
1070
+ e.preventDefault();
1071
+ return;
1072
+ }
1073
+ }
1074
+
1075
+ // 4. Blokir tanda plus '+'
1076
+ if (e.key === "+") {
1077
+ e.preventDefault();
1078
+ return;
1079
+ }
1080
+
1081
+ // 5. Pembatasan tanda minus '-'
1082
+ if (e.key === "-") {
1083
+ // Jika nilai minimum >= 0, dilarang tanda minus
1084
+ if (props.min !== undefined && props.min >= 0) {
1085
+ e.preventDefault();
1086
+ return;
1087
+ }
1088
+ const input = e.target;
1089
+ const val = input ? input.value : "";
1090
+
1091
+ // Jika sudah ada tanda minus di depan, toggle/hapus tanda minus
1092
+ if (val.startsWith("-")) {
1093
+ e.preventDefault();
1094
+ const positiveVal = val.slice(1);
1095
+ const raw = parseToRawNumber(positiveVal);
1096
+ innerValue.value = raw;
1097
+ emitValue(raw);
1098
+ return;
1099
+ }
1100
+
1101
+ // Jika ada teks dan kursor tidak di posisi 0, jadikan negatif (tambahkan '-' di depan)
1102
+ if (
1103
+ val &&
1104
+ input &&
1105
+ (input.selectionStart === null || input.selectionStart > 0)
1106
+ ) {
1107
+ e.preventDefault();
1108
+ const negativeVal = "-" + val;
1109
+ const raw = parseToRawNumber(negativeVal);
1110
+ innerValue.value = raw;
1111
+ emitValue(raw);
1112
+ return;
1113
+ }
1114
+ if (props.onKeyDown) props.onKeyDown(e);
1115
+ return;
1116
+ }
1117
+
1118
+ // 6. Pemisah desimal (koma ',')
1119
+ if (e.key === ",") {
1120
+ // Hanya tolak jika developer secara eksplisit menyetel precision={0}
1121
+ if (props.precision === 0) {
1122
+ e.preventDefault();
1123
+ return;
1124
+ }
1125
+ const input = e.target;
1126
+ const val = input ? input.value : "";
1127
+
1128
+ // Hanya izinkan 1 koma desimal
1129
+ if (val.includes(",")) {
1130
+ e.preventDefault();
1131
+ return;
1132
+ }
1133
+ if (props.onKeyDown) props.onKeyDown(e);
1134
+ return;
1135
+ }
1136
+
1137
+ // 6b. Pemisah ribuan (titik '.')
1138
+ if (e.key === ".") {
1139
+ // Titik sebagai pemisah ribuan diizinkan
1140
+ if (props.onKeyDown) props.onKeyDown(e);
1141
+ return;
1142
+ }
1143
+
1144
+ // 7. Jika bukan digit 0-9, blokir karakter lainnya (termasuk aritmatika *, /, %, =, dll.)
1145
+ if (!/^[0-9]$/.test(e.key)) {
1146
+ e.preventDefault();
1147
+ return;
1148
+ }
1149
+ if (props.onKeyDown) {
1150
+ props.onKeyDown(e);
1151
+ }
1152
+ }
1153
+ </script>