@gemafajarramadhan/dynamic-ui 1.0.3 → 1.0.4

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.
package/dist/index.d.ts CHANGED
@@ -1,5 +1,45 @@
1
1
  declare module '@gemafajarramadhan/dynamic-ui' {
2
- import type { DefineComponent, Plugin } from 'vue'
2
+ import type { DefineComponent, Plugin, App } from 'vue'
3
+
4
+ // ─── API Configuration ────────────────────────────────────────────────────────
5
+
6
+ /**
7
+ * Konfigurasi API untuk komponen DCode yang melakukan HTTP request.
8
+ * Di-set via: app.use(DynamicUI, config) atau setApiConfig(config)
9
+ */
10
+ export interface DynamicUIApiConfig {
11
+ /** Base URL untuk semua request API. Contoh: 'https://api.example.com' */
12
+ apiBaseUrl?: string
13
+ /**
14
+ * Fungsi untuk mendapatkan token auth terkini.
15
+ * Dipanggil setiap kali ada request, sehingga mendukung token refresh.
16
+ * @example () => localStorage.getItem('access_token')
17
+ * @example () => store.getters['auth/token']
18
+ */
19
+ getAuthToken?: () => string | null | undefined
20
+ /**
21
+ * Fungsi untuk menyediakan custom HTTP headers.
22
+ * Jika disediakan, akan di-merge dengan default headers.
23
+ * @example () => ({ Authorization: `Bearer ${store.state.token}`, 'X-Tenant': 'abc' })
24
+ */
25
+ getHeaders?: () => Record<string, string>
26
+ /**
27
+ * Callback yang dipanggil ketika response HTTP 401 diterima.
28
+ * Berguna untuk trigger logout atau redirect ke halaman login.
29
+ * @example () => router.push('/login')
30
+ */
31
+ onUnauthorized?: () => void
32
+ }
33
+
34
+ /**
35
+ * Set konfigurasi API secara manual (tanpa app.use).
36
+ * Berguna untuk setup di luar Vue app (misal: sebelum createApp).
37
+ *
38
+ * @example
39
+ * import { setApiConfig } from '@gemafajarramadhan/dynamic-ui'
40
+ * setApiConfig({ apiBaseUrl: 'https://api.example.com' })
41
+ */
42
+ export function setApiConfig(config: DynamicUIApiConfig): void
3
43
 
4
44
  // ─── Base Components ─────────────────────────────────────────────────────────
5
45
 
@@ -266,6 +306,22 @@ declare module '@gemafajarramadhan/dynamic-ui' {
266
306
 
267
307
  // ─── Vue Plugin ──────────────────────────────────────────────────────────────
268
308
 
269
- declare const DynamicUI: Plugin
309
+ /**
310
+ * Vue Plugin - install semua DCode components secara global.
311
+ *
312
+ * @example
313
+ * import DynamicUI from '@gemafajarramadhan/dynamic-ui'
314
+ * import '@gemafajarramadhan/dynamic-ui/style.css'
315
+ *
316
+ * app.use(DynamicUI, {
317
+ * apiBaseUrl: 'https://api.example.com',
318
+ * getAuthToken: () => localStorage.getItem('access_token'),
319
+ * getHeaders: () => ({ Authorization: `Bearer ${store.state.token}` }),
320
+ * onUnauthorized: () => router.push('/login'),
321
+ * })
322
+ */
323
+ declare const DynamicUI: {
324
+ install(app: App, options?: DynamicUIApiConfig): void
325
+ }
270
326
  export default DynamicUI
271
327
  }