@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,730 @@
1
+ <template>
2
+ <nav
3
+ role="navigation"
4
+ aria-label="pagination"
5
+ :class="`ttdk-pagination ${className || ''}`.trim()"
6
+ :data-size="size || 'md'"
7
+ :style="{
8
+ ...buildUiVars(ui),
9
+ ...(typeof style === 'object' ? style : {}),
10
+ }"
11
+ >
12
+ <template v-if="$slots.default">
13
+ <slot />
14
+ </template>
15
+
16
+ <template v-if="!$slots.default">
17
+ <div class="ttdk-pagination-auto-wrapper">
18
+ <template v-if="getShouldShowLimit()">
19
+ <div
20
+ :class="`ttdk-pagination-limit ${limitClass || ''}`.trim()"
21
+ :style="{
22
+ ...buildUiVars(limitStyle),
23
+ }"
24
+ >
25
+ <template v-if="showLimitLabel !== false">
26
+ <span class="ttdk-pagination-limit-label">{{
27
+ limitLabel || "Baris per halaman:"
28
+ }}</span>
29
+ </template>
30
+
31
+ <template v-if="limitSlot">
32
+ {{ limitSlot }}
33
+ </template>
34
+
35
+ <template v-if="!limitSlot">
36
+ <Selectbox
37
+ :size="size === 'lg' ? 'md' : 'sm'"
38
+ :value="limit || 10"
39
+ :options="getLimitOptions()"
40
+ :onChange="(val) => handleLimitChange(val)"
41
+ :controlStyle="{
42
+ minWidth: '70px',
43
+ width: '76px',
44
+ height:
45
+ size === 'sm' ? '28px' : size === 'lg' ? '44px' : '36px',
46
+ minHeight:
47
+ size === 'sm' ? '28px' : size === 'lg' ? '44px' : '36px',
48
+ padding: '0 8px',
49
+ fontSize: '12px',
50
+ ...buildUiVars(limitSelectStyle),
51
+ }"
52
+ ></Selectbox>
53
+ </template>
54
+ </div>
55
+ </template>
56
+
57
+ <ul
58
+ :class="`ttdk-pagination-content ${contentClass || ''}`.trim()"
59
+ :style="{
60
+ ...buildUiVars(contentStyle),
61
+ }"
62
+ >
63
+ <template v-if="showEdges || Boolean(onFirstPage)">
64
+ <li class="ttdk-pagination-item">
65
+ <button
66
+ type="button"
67
+ aria-label="Go to first page"
68
+ :class="
69
+ `ttdk-pagination-link ttdk-pagination-first ${
70
+ linkClass || ''
71
+ }`.trim()
72
+ "
73
+ :data-size="size || 'md'"
74
+ :data-disabled="!getCanPrev() ? 'true' : 'false'"
75
+ :disabled="!getCanPrev()"
76
+ @click="
77
+ async (event) => {
78
+ if (onFirstPage) {
79
+ onFirstPage();
80
+ } else if (onPageChange) {
81
+ onPageChange(1);
82
+ }
83
+ }
84
+ "
85
+ :style="{
86
+ ...buildUiVars(linkStyle),
87
+ }"
88
+ >
89
+ <template v-if="firstIcon">
90
+ {{ firstIcon }}
91
+ </template>
92
+
93
+ <template v-if="!firstIcon">
94
+ <svg
95
+ class="ttdk-pagination-icon"
96
+ viewBox="0 0 24 24"
97
+ fill="none"
98
+ aria-hidden="true"
99
+ >
100
+ <polyline points="11 17 6 12 11 7"></polyline>
101
+ <polyline points="18 17 13 12 18 7"></polyline>
102
+ </svg>
103
+ </template>
104
+ </button>
105
+ </li>
106
+ </template>
107
+
108
+ <li class="ttdk-pagination-item">
109
+ <button
110
+ type="button"
111
+ aria-label="Go to previous page"
112
+ :class="
113
+ `ttdk-pagination-link ttdk-pagination-prev ${
114
+ linkClass || ''
115
+ }`.trim()
116
+ "
117
+ :data-size="size || 'md'"
118
+ :data-disabled="!getCanPrev() ? 'true' : 'false'"
119
+ :disabled="!getCanPrev()"
120
+ @click="
121
+ async (event) => {
122
+ if (onPrevPage) {
123
+ onPrevPage();
124
+ } else if (onPageChange) {
125
+ onPageChange(Math.max(1, getCurrentPage() - 1));
126
+ }
127
+ }
128
+ "
129
+ :style="{
130
+ ...buildUiVars(linkStyle),
131
+ }"
132
+ >
133
+ <template v-if="prevIcon">
134
+ {{ prevIcon }}
135
+ </template>
136
+
137
+ <template v-if="!prevIcon">
138
+ <svg
139
+ class="ttdk-pagination-icon"
140
+ viewBox="0 0 24 24"
141
+ fill="none"
142
+ aria-hidden="true"
143
+ >
144
+ <polyline points="15 18 9 12 15 6"></polyline>
145
+ </svg>
146
+ </template>
147
+
148
+ <template v-if="!iconOnly">
149
+ <span class="ttdk-pagination-prev-text">{{
150
+ prevText || "Previous"
151
+ }}</span>
152
+ </template>
153
+ </button>
154
+ </li>
155
+ <template v-if="showPageNumbers !== false">
156
+ <template :key="item.key" v-for="(item, index) in getPageRange()">
157
+ <li class="ttdk-pagination-item">
158
+ <template v-if="item.type === 'ellipsis'">
159
+ <span aria-hidden="true" class="ttdk-pagination-ellipsis">
160
+ <template v-if="ellipsisIcon">
161
+ {{ ellipsisIcon }}
162
+ </template>
163
+
164
+ <template v-if="!ellipsisIcon">
165
+ <svg
166
+ class="ttdk-pagination-icon"
167
+ viewBox="0 0 24 24"
168
+ fill="none"
169
+ >
170
+ <circle cx="12" cy="12" r="1"></circle>
171
+ <circle cx="19" cy="12" r="1"></circle>
172
+ <circle cx="5" cy="12" r="1"></circle>
173
+ </svg>
174
+ </template>
175
+
176
+ <span class="ttdk-sr-only">More pages</span></span
177
+ >
178
+ </template>
179
+
180
+ <template v-if="item.type === 'page'">
181
+ <button
182
+ type="button"
183
+ :class="
184
+ `ttdk-pagination-link ${linkClass || ''} ${
185
+ item.value === getCurrentPage()
186
+ ? activeLinkClass || ''
187
+ : ''
188
+ }`.trim()
189
+ "
190
+ :aria-current="
191
+ item.value === getCurrentPage() ? 'page' : undefined
192
+ "
193
+ :data-active="
194
+ item.value === getCurrentPage() ? 'true' : 'false'
195
+ "
196
+ :data-size="size || 'md'"
197
+ @click="
198
+ async (event) => {
199
+ if (onPageChange) {
200
+ onPageChange(Number(item.value));
201
+ }
202
+ }
203
+ "
204
+ :style="{
205
+ ...buildUiVars(linkStyle),
206
+ ...(item.value === getCurrentPage()
207
+ ? buildUiVars(activeLinkStyle)
208
+ : {}),
209
+ }"
210
+ >
211
+ {{ item.value }}
212
+ </button>
213
+ </template>
214
+ </li>
215
+ </template>
216
+ </template>
217
+
218
+ <li class="ttdk-pagination-item">
219
+ <button
220
+ type="button"
221
+ aria-label="Go to next page"
222
+ :class="
223
+ `ttdk-pagination-link ttdk-pagination-next ${
224
+ linkClass || ''
225
+ }`.trim()
226
+ "
227
+ :data-size="size || 'md'"
228
+ :data-disabled="!getCanNext() ? 'true' : 'false'"
229
+ :disabled="!getCanNext()"
230
+ @click="
231
+ async (event) => {
232
+ if (onNextPage) {
233
+ onNextPage();
234
+ } else if (onPageChange) {
235
+ onPageChange(
236
+ Math.min(getTotalPages(), getCurrentPage() + 1)
237
+ );
238
+ }
239
+ }
240
+ "
241
+ :style="{
242
+ ...buildUiVars(linkStyle),
243
+ }"
244
+ >
245
+ <template v-if="!iconOnly">
246
+ <span class="ttdk-pagination-next-text">{{
247
+ nextText || "Next"
248
+ }}</span>
249
+ </template>
250
+
251
+ <template v-if="nextIcon">
252
+ {{ nextIcon }}
253
+ </template>
254
+
255
+ <template v-if="!nextIcon">
256
+ <svg
257
+ class="ttdk-pagination-icon"
258
+ viewBox="0 0 24 24"
259
+ fill="none"
260
+ aria-hidden="true"
261
+ >
262
+ <polyline points="9 18 15 12 9 6"></polyline>
263
+ </svg>
264
+ </template>
265
+ </button>
266
+ </li>
267
+ <template v-if="showEdges || Boolean(onLastPage)">
268
+ <li class="ttdk-pagination-item">
269
+ <button
270
+ type="button"
271
+ aria-label="Go to last page"
272
+ :class="
273
+ `ttdk-pagination-link ttdk-pagination-last ${
274
+ linkClass || ''
275
+ }`.trim()
276
+ "
277
+ :data-size="size || 'md'"
278
+ :data-disabled="!getCanNext() ? 'true' : 'false'"
279
+ :disabled="!getCanNext()"
280
+ @click="
281
+ async (event) => {
282
+ if (onLastPage) {
283
+ onLastPage();
284
+ } else if (onPageChange) {
285
+ onPageChange(getTotalPages());
286
+ }
287
+ }
288
+ "
289
+ :style="{
290
+ ...buildUiVars(linkStyle),
291
+ }"
292
+ >
293
+ <template v-if="lastIcon">
294
+ {{ lastIcon }}
295
+ </template>
296
+
297
+ <template v-if="!lastIcon">
298
+ <svg
299
+ class="ttdk-pagination-icon"
300
+ viewBox="0 0 24 24"
301
+ fill="none"
302
+ aria-hidden="true"
303
+ >
304
+ <polyline points="13 17 18 12 13 7"></polyline>
305
+ <polyline points="6 17 11 12 6 7"></polyline>
306
+ </svg>
307
+ </template>
308
+ </button>
309
+ </li>
310
+ </template>
311
+ </ul>
312
+ </div>
313
+ </template>
314
+ </nav>
315
+ </template>
316
+
317
+ <script setup lang="ts">
318
+ import { getCurrentInstance } from "vue";
319
+ import { buildUiVars, UiProps } from "../../core/types";
320
+ import Selectbox from "../selectbox/selectbox.vue";
321
+
322
+ export type PaginationUiProps = UiProps;
323
+ export interface PaginationPageItem {
324
+ type: "page" | "ellipsis";
325
+ value: number | string;
326
+ key: string;
327
+ }
328
+ export interface PaginationProps {
329
+ /**
330
+ * Nomor halaman saat ini (1-indexed).
331
+ * @default 1
332
+ */
333
+ page?: number;
334
+
335
+ /**
336
+ * Jumlah total halaman maksimum (alias untuk totalPages).
337
+ * @default 1
338
+ */
339
+ maxPages?: number;
340
+
341
+ /**
342
+ * Jumlah total halaman (alias maxPages).
343
+ * @default 1
344
+ */
345
+ totalPages?: number;
346
+
347
+ /**
348
+ * Jumlah baris/item data per halaman (page size).
349
+ * @default 10
350
+ */
351
+ limit?: number;
352
+
353
+ /**
354
+ * Callback saat jumlah baris per halaman diubah via select box.
355
+ */
356
+ onLimitChange?: (limit: number) => void;
357
+
358
+ /**
359
+ * Pilihan angka baris per halaman pada select box.
360
+ * @default [10, 20, 50, 100]
361
+ */
362
+ limitOptions?: number[];
363
+
364
+ /**
365
+ * Menentukan apakah navigasi ke halaman sebelumnya diizinkan (false = tombol Previous dinonaktifkan).
366
+ * @default false
367
+ */
368
+ canPrevPage?: boolean;
369
+
370
+ /**
371
+ * Menentukan apakah navigasi ke halaman berikutnya diizinkan (false = tombol Next dinonaktifkan).
372
+ * @default false
373
+ */
374
+ canNextPage?: boolean;
375
+
376
+ /**
377
+ * Callback saat tombol First Page (halaman pertama) diklik.
378
+ */
379
+ onFirstPage?: () => void;
380
+
381
+ /**
382
+ * Callback saat tombol Previous Page (halaman sebelumnya) diklik.
383
+ */
384
+ onPrevPage?: () => void;
385
+
386
+ /**
387
+ * Callback saat tombol Next Page (halaman selanjutnya) diklik.
388
+ */
389
+ onNextPage?: () => void;
390
+
391
+ /**
392
+ * Callback saat tombol Last Page (halaman terakhir) diklik.
393
+ */
394
+ onLastPage?: () => void;
395
+
396
+ /**
397
+ * Callback saat nomor halaman tertentu diklik.
398
+ */
399
+ onPageChange?: (page: number) => void;
400
+
401
+ /**
402
+ * Jumlah tetangga nomor halaman di samping kiri dan kanan halaman aktif.
403
+ * @default 1
404
+ */
405
+ siblingCount?: number;
406
+
407
+ /**
408
+ * Menampilkan tombol First (<<) dan Last (>>).
409
+ * @default false
410
+ */
411
+ showEdges?: boolean;
412
+
413
+ /**
414
+ * Menampilkan nomor halaman terpaginasi (1, 2, 3...).
415
+ * @default true
416
+ */
417
+ showPageNumbers?: boolean;
418
+
419
+ /**
420
+ * Skala ukuran pagination:
421
+ * - `'sm'`: 28px
422
+ * - `'md'`: 36px (standar)
423
+ * - `'lg'`: 44px
424
+ * @default 'md'
425
+ */
426
+ size?: "sm" | "md" | "lg";
427
+
428
+ /**
429
+ * Inline CSS style object native.
430
+ */
431
+ style?: any;
432
+
433
+ /**
434
+ * Kustomisasi visual granular root kontainer pagination (UiProps).
435
+ */
436
+ ui?: UiProps;
437
+
438
+ /**
439
+ * Style kustom untuk kontainer daftar pagination content (ul.ttdk-pagination-content).
440
+ */
441
+ contentStyle?: UiProps;
442
+
443
+ /**
444
+ * Class CSS kustom untuk kontainer daftar pagination content.
445
+ */
446
+ contentClass?: string;
447
+
448
+ /**
449
+ * Style kustom untuk tombol link nomor halaman / navigasi.
450
+ */
451
+ linkStyle?: UiProps;
452
+
453
+ /**
454
+ * Class CSS kustom untuk tombol link nomor halaman / navigasi.
455
+ */
456
+ linkClass?: string;
457
+
458
+ /**
459
+ * Style kustom untuk tombol nomor halaman saat aktif.
460
+ */
461
+ activeLinkStyle?: UiProps;
462
+
463
+ /**
464
+ * Class CSS kustom untuk tombol nomor halaman saat aktif.
465
+ */
466
+ activeLinkClass?: string;
467
+
468
+ /**
469
+ * Style kustom untuk kontainer baris per halaman (limit).
470
+ */
471
+ limitStyle?: UiProps;
472
+
473
+ /**
474
+ * Class CSS kustom untuk kontainer baris per halaman (limit).
475
+ */
476
+ limitClass?: string;
477
+
478
+ /**
479
+ * Style kustom untuk elemen Selectbox baris per halaman (limit).
480
+ */
481
+ limitSelectStyle?: UiProps;
482
+
483
+ /**
484
+ * Slot kustom untuk menggantikan elemen limit selector bawaan.
485
+ */
486
+ limitSlot?: any;
487
+
488
+ /**
489
+ * Menentukan apakah kontrol baris per halaman (limit selectbox) ditampilkan.
490
+ * Jika tidak disetel, otomatis mengikuti keberadaan callback onLimitChange.
491
+ */
492
+ showLimit?: boolean;
493
+
494
+ /**
495
+ * Menentukan apakah teks label 'Baris per halaman:' ditampilkan di samping selectbox limit.
496
+ * @default true
497
+ */
498
+ showLimitLabel?: boolean;
499
+
500
+ /**
501
+ * Teks label untuk opsi baris per halaman.
502
+ * @default 'Baris per halaman:'
503
+ */
504
+ limitLabel?: string;
505
+
506
+ /**
507
+ * Ikon kustom untuk tombol halaman pertama (first page, menggantikan <<).
508
+ */
509
+ firstIcon?: any;
510
+
511
+ /**
512
+ * Ikon kustom untuk tombol halaman sebelumnya (previous page, menggantikan <).
513
+ */
514
+ prevIcon?: any;
515
+
516
+ /**
517
+ * Ikon kustom untuk tombol halaman selanjutnya (next page, menggantikan >).
518
+ */
519
+ nextIcon?: any;
520
+
521
+ /**
522
+ * Ikon kustom untuk tombol halaman terakhir (last page, menggantikan >>).
523
+ */
524
+ lastIcon?: any;
525
+
526
+ /**
527
+ * Ikon kustom untuk separator elipsis (menggantikan ...).
528
+ */
529
+ ellipsisIcon?: any;
530
+
531
+ /**
532
+ * Label teks tombol Previous.
533
+ * @default 'Previous'
534
+ */
535
+ prevText?: string;
536
+
537
+ /**
538
+ * Label teks tombol Next.
539
+ * @default 'Next'
540
+ */
541
+ nextText?: string;
542
+
543
+ /**
544
+ * Mode hanya menampilkan ikon pada tombol Previous dan Next tanpa teks label.
545
+ * @default false
546
+ */
547
+ iconOnly?: boolean;
548
+
549
+ /**
550
+ * Class CSS kustom.
551
+ */
552
+ className?: string;
553
+
554
+ /**
555
+ * Konten kustom atau subkomponen compound (PaginationContent, PaginationItem, dll).
556
+ */
557
+ children?: any;
558
+ }
559
+
560
+ /**
561
+ * Komponen Pagination navigasi halaman dengan dukungan Compound API (ala Shadcn UI) dan Props-driven mode.
562
+ */
563
+
564
+ const props = withDefaults(defineProps<PaginationProps>(), {
565
+ showPageNumbers: true,
566
+ showLimitLabel: true,
567
+ showEdges: false,
568
+ page: 1,
569
+ limit: 10,
570
+ siblingCount: 1,
571
+ size: "md",
572
+ prevText: "Previous",
573
+ nextText: "Next",
574
+ });
575
+
576
+ function getCurrentPage() {
577
+ return props.page !== undefined ? props.page : 1;
578
+ }
579
+ function getTotalPages() {
580
+ if (props.maxPages !== undefined) return props.maxPages;
581
+ if (props.totalPages !== undefined) return props.totalPages;
582
+ return 1;
583
+ }
584
+ function getCanPrev() {
585
+ const instance = getCurrentInstance();
586
+ const vnodeProps = instance?.vnode?.props || {};
587
+ if ("canPrevPage" in vnodeProps || "can-prev-page" in vnodeProps) {
588
+ return Boolean(props.canPrevPage);
589
+ }
590
+ return getCurrentPage() > 1;
591
+ }
592
+ function getCanNext() {
593
+ const instance = getCurrentInstance();
594
+ const vnodeProps = instance?.vnode?.props || {};
595
+ if ("canNextPage" in vnodeProps || "can-next-page" in vnodeProps) {
596
+ return Boolean(props.canNextPage);
597
+ }
598
+ return getCurrentPage() < getTotalPages();
599
+ }
600
+ function getShouldShowLimit() {
601
+ const instance = getCurrentInstance();
602
+ const vnodeProps = instance?.vnode?.props || {};
603
+ if ("showLimit" in vnodeProps || "show-limit" in vnodeProps) {
604
+ return Boolean(props.showLimit);
605
+ }
606
+ return Boolean(
607
+ props.onLimitChange ||
608
+ vnodeProps.onLimitChange ||
609
+ vnodeProps["onLimit-change"] ||
610
+ vnodeProps["onUpdate:limit"],
611
+ );
612
+ }
613
+ function getLimitOptions() {
614
+ const opts = props.limitOptions || [10, 20, 50, 100];
615
+ return opts.map((opt: number) => ({
616
+ label: String(opt),
617
+ value: opt,
618
+ }));
619
+ }
620
+ function getPageRange() {
621
+ const total = getTotalPages();
622
+ const current = getCurrentPage();
623
+ const sibling = props.siblingCount !== undefined ? props.siblingCount : 1;
624
+ if (total <= 1) {
625
+ return [
626
+ {
627
+ type: "page",
628
+ value: 1,
629
+ key: "page-1",
630
+ },
631
+ ];
632
+ }
633
+ const totalPageNumbers = sibling * 2 + 5;
634
+ if (total <= totalPageNumbers) {
635
+ const pages: PaginationPageItem[] = [];
636
+ for (let i = 1; i <= total; i++) {
637
+ pages.push({
638
+ type: "page",
639
+ value: i,
640
+ key: `page-${i}`,
641
+ });
642
+ }
643
+ return pages;
644
+ }
645
+ const leftSiblingIndex = Math.max(current - sibling, 1);
646
+ const rightSiblingIndex = Math.min(current + sibling, total);
647
+ const shouldShowLeftDots = leftSiblingIndex > 2;
648
+ const shouldShowRightDots = rightSiblingIndex < total - 1;
649
+ if (!shouldShowLeftDots && shouldShowRightDots) {
650
+ const leftItemCount = 3 + 2 * sibling;
651
+ const pages: PaginationPageItem[] = [];
652
+ for (let i = 1; i <= leftItemCount; i++) {
653
+ pages.push({
654
+ type: "page",
655
+ value: i,
656
+ key: `page-${i}`,
657
+ });
658
+ }
659
+ pages.push({
660
+ type: "ellipsis",
661
+ value: "...",
662
+ key: "ellipsis-right",
663
+ });
664
+ pages.push({
665
+ type: "page",
666
+ value: total,
667
+ key: `page-${total}`,
668
+ });
669
+ return pages;
670
+ }
671
+ if (shouldShowLeftDots && !shouldShowRightDots) {
672
+ const rightItemCount = 3 + 2 * sibling;
673
+ const pages: PaginationPageItem[] = [
674
+ {
675
+ type: "page",
676
+ value: 1,
677
+ key: "page-1",
678
+ },
679
+ {
680
+ type: "ellipsis",
681
+ value: "...",
682
+ key: "ellipsis-left",
683
+ },
684
+ ];
685
+ for (let i = total - rightItemCount + 1; i <= total; i++) {
686
+ pages.push({
687
+ type: "page",
688
+ value: i,
689
+ key: `page-${i}`,
690
+ });
691
+ }
692
+ return pages;
693
+ }
694
+ const pages: PaginationPageItem[] = [
695
+ {
696
+ type: "page",
697
+ value: 1,
698
+ key: "page-1",
699
+ },
700
+ {
701
+ type: "ellipsis",
702
+ value: "...",
703
+ key: "ellipsis-left",
704
+ },
705
+ ];
706
+ for (let i = leftSiblingIndex; i <= rightSiblingIndex; i++) {
707
+ pages.push({
708
+ type: "page",
709
+ value: i,
710
+ key: `page-${i}`,
711
+ });
712
+ }
713
+ pages.push({
714
+ type: "ellipsis",
715
+ value: "...",
716
+ key: "ellipsis-right",
717
+ });
718
+ pages.push({
719
+ type: "page",
720
+ value: total,
721
+ key: `page-${total}`,
722
+ });
723
+ return pages;
724
+ }
725
+ function handleLimitChange(val: any) {
726
+ if (props.onLimitChange) {
727
+ props.onLimitChange(Number(val));
728
+ }
729
+ }
730
+ </script>