@gemafajarramadhan/dynamic-ui 1.2.17 → 1.2.18

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/README.md CHANGED
@@ -86,34 +86,43 @@ Library menggunakan sistem konfigurasi terpusat via `setApiConfig()` (atau via V
86
86
 
87
87
  ### Konfigurasi API di Vue 3
88
88
 
89
- Cara paling direkomendasikan: lewatkan config saat `app.use()`.
89
+ Cara paling direkomendasikan: lewatkan config saat `app.use()`, atau gunakan `setApiConfig` secara langsung. Hal ini **sangat penting** agar request API dari komponen (seperti `DCodeAutoComplete`) mem-bypass native `fetch` bawaan dan menggunakan instance HTTP (seperti Axios) milik project host Anda. Dengan begitu, request otomatis melewati interceptor (untuk inject token) dan mengarah ke base URL yang tepat saat di production.
90
90
 
91
91
  ```js
92
92
  // main.js
93
93
  import { createApp } from 'vue'
94
94
  import App from './App.vue'
95
- import DynamicUI from '@gemafajarramadhan/dynamic-ui'
95
+ import DynamicUI, { setApiConfig } from '@gemafajarramadhan/dynamic-ui'
96
96
  import '@gemafajarramadhan/dynamic-ui/style.css'
97
97
 
98
+ // Contoh import instance Axios / useApi dari host project Anda
99
+ import axiosInstance from './plugins/axios'
100
+ // import { useApi } from './composables/useApi'
101
+
98
102
  const app = createApp(App)
99
103
 
100
- app.use(DynamicUI, {
101
- // ✅ Base URL API dari env HOST project
104
+ // OPSI 1: Konfigurasi memanggil fungsi (Bisa dipanggil di luar instalasi plugin)
105
+ setApiConfig({
106
+ // WAJIB: Bypass fetch bawaan, gunakan axios dari project host
107
+ apiClient: async (url, method, data) => {
108
+ return axiosInstance({ url, method, data })
109
+ /* ATAU MENGGUNAKAN useApi bawaan project host
110
+ const { apiUrl } = useApi()
111
+ return apiUrl(url, method || 'GET', data, { disableGlobalLoading: true })
112
+ */
113
+ },
114
+
115
+ // Base URL API dari env HOST project
102
116
  apiBaseUrl: import.meta.env.VITE_API_BASE_URL,
103
-
104
- // Token auth terkini (dipanggil setiap request)
117
+
118
+ // (Opsional jika apiClient sudah memiliki interceptor token)
105
119
  getAuthToken: () => localStorage.getItem('access_token'),
120
+ })
106
121
 
107
- // Atau gunakan custom headers penuh (override Authorization)
108
- // getHeaders: () => ({
109
- // Authorization: `Bearer ${store.getters.token}`,
110
- // 'X-App-ID': 'my-app',
111
- // }),
112
-
113
- // ✅ Callback ketika response 401 (Unauthorized)
114
- onUnauthorized: () => {
115
- router.push('/login')
116
- },
122
+ // OPSI 2: Lewatkan pada saat app.use (Berlaku jika tidak menggunakan setApiConfig di atas)
123
+ app.use(DynamicUI, {
124
+ apiClient: async (url, method, data) => axiosInstance({ url, method, data }),
125
+ apiBaseUrl: import.meta.env.VITE_API_BASE_URL,
117
126
  })
118
127
 
119
128
  app.mount('#app')
@@ -61089,5 +61089,6 @@ export {
61089
61089
  iee as MicroDynamicDatatable,
61090
61090
  oee as MicroDynamicForm,
61091
61091
  He as cn,
61092
- mee as default
61092
+ mee as default,
61093
+ fB as setApiConfig
61093
61094
  };