vlite3 1.5.12 → 1.5.13

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 (127) hide show
  1. package/README.md +20 -8
  2. package/components/Accordion/AccordionContent.vue.js +2 -2
  3. package/components/CommandPalette/CommandPaletteContent2.vue.js +1 -1
  4. package/components/CommandPalette/{CommandPaletteItem2.vue.js → CommandPaletteItem.vue.js} +1 -1
  5. package/components/Dropdown/DropdownMenu.vue.js +1 -1
  6. package/components/Form/AccordionView2.vue.js +1 -1
  7. package/components/Form/Form.vue.js +2 -2
  8. package/components/NavbarCommandPalette.vue.js +1 -1
  9. package/components/PanZoomViewport/PanZoomViewport.vue.d.ts +7 -7
  10. package/components/PanZoomViewport/PanZoomViewport.vue.js +1 -1
  11. package/components/Tabes/Tabes.vue.js +2 -2
  12. package/docs/README.md +17 -0
  13. package/docs/all-components.md +89 -0
  14. package/docs/component-index.md +313 -0
  15. package/docs/components/accordion.md +52 -0
  16. package/docs/components/alert.md +34 -0
  17. package/docs/components/app-shell.md +371 -0
  18. package/docs/components/async-select.md +264 -0
  19. package/docs/components/attachments-list.md +231 -0
  20. package/docs/components/avatar-group.md +74 -0
  21. package/docs/components/avatar-uploader.md +61 -0
  22. package/docs/components/avatar.md +28 -0
  23. package/docs/components/badge.md +81 -0
  24. package/docs/components/barcode.md +42 -0
  25. package/docs/components/beacon.md +29 -0
  26. package/docs/components/breadcrumb.md +317 -0
  27. package/docs/components/button-group.md +35 -0
  28. package/docs/components/button.md +86 -0
  29. package/docs/components/calendar.md +95 -0
  30. package/docs/components/carousel.md +122 -0
  31. package/docs/components/cart.md +533 -0
  32. package/docs/components/category-manager.md +269 -0
  33. package/docs/components/category-menu.md +251 -0
  34. package/docs/components/charts.md +1456 -0
  35. package/docs/components/chat.md +330 -0
  36. package/docs/components/checkbox.md +31 -0
  37. package/docs/components/chip.md +137 -0
  38. package/docs/components/choice-box.md +40 -0
  39. package/docs/components/clipboard.md +105 -0
  40. package/docs/components/clock.md +70 -0
  41. package/docs/components/color-picker.md +82 -0
  42. package/docs/components/command-palette.md +214 -0
  43. package/docs/components/comment-thread.md +171 -0
  44. package/docs/components/confirmation-modal.md +50 -0
  45. package/docs/components/custom-fields-display.md +94 -0
  46. package/docs/components/custom-fields.md +97 -0
  47. package/docs/components/data-list.md +93 -0
  48. package/docs/components/data-table.md +922 -0
  49. package/docs/components/date-picker.md +58 -0
  50. package/docs/components/date-range-picker.md +24 -0
  51. package/docs/components/date-time.md +104 -0
  52. package/docs/components/dropdown.md +740 -0
  53. package/docs/components/empty.md +100 -0
  54. package/docs/components/export-data.md +320 -0
  55. package/docs/components/file-picker.md +83 -0
  56. package/docs/components/file-preview.md +42 -0
  57. package/docs/components/file-tree.md +144 -0
  58. package/docs/components/footer.md +251 -0
  59. package/docs/components/forms.md +776 -0
  60. package/docs/components/gantt-chart.md +767 -0
  61. package/docs/components/google-login.md +67 -0
  62. package/docs/components/google-map.md +128 -0
  63. package/docs/components/heatmap.md +80 -0
  64. package/docs/components/icon-picker.md +58 -0
  65. package/docs/components/icon.md +176 -0
  66. package/docs/components/image-comparison.md +51 -0
  67. package/docs/components/image-magnifier.md +26 -0
  68. package/docs/components/import-data.md +521 -0
  69. package/docs/components/input.md +58 -0
  70. package/docs/components/invoice.md +339 -0
  71. package/docs/components/kanban.md +302 -0
  72. package/docs/components/label.md +25 -0
  73. package/docs/components/list.md +419 -0
  74. package/docs/components/masonry.md +55 -0
  75. package/docs/components/modal.md +133 -0
  76. package/docs/components/multi-select.md +54 -0
  77. package/docs/components/navbar.md +403 -0
  78. package/docs/components/number-input.md +41 -0
  79. package/docs/components/otp-input.md +68 -0
  80. package/docs/components/pagination.md +83 -0
  81. package/docs/components/pan-zoom-viewport.md +245 -0
  82. package/docs/components/permission-editor.md +322 -0
  83. package/docs/components/persona.md +56 -0
  84. package/docs/components/price.md +106 -0
  85. package/docs/components/pricing-plan.md +68 -0
  86. package/docs/components/progress-bar.md +53 -0
  87. package/docs/components/qr-code.md +59 -0
  88. package/docs/components/rating.md +59 -0
  89. package/docs/components/rich-text-editor.md +210 -0
  90. package/docs/components/scale-generator.md +101 -0
  91. package/docs/components/screen.md +208 -0
  92. package/docs/components/seo-provider.md +189 -0
  93. package/docs/components/side-panel.md +94 -0
  94. package/docs/components/sidebar-menu.md +422 -0
  95. package/docs/components/skeleton.md +115 -0
  96. package/docs/components/slider.md +48 -0
  97. package/docs/components/spinner.md +27 -0
  98. package/docs/components/splitter.md +97 -0
  99. package/docs/components/stats.md +234 -0
  100. package/docs/components/status-chip.md +232 -0
  101. package/docs/components/switch.md +23 -0
  102. package/docs/components/tabs.md +335 -0
  103. package/docs/components/tag-input.md +55 -0
  104. package/docs/components/textarea.md +31 -0
  105. package/docs/components/theme-provider.md +130 -0
  106. package/docs/components/theme-toggle.md +36 -0
  107. package/docs/components/thumbnail-selector.md +186 -0
  108. package/docs/components/timeline.md +225 -0
  109. package/docs/components/toast-notification.md +89 -0
  110. package/docs/components/tooltip.md +31 -0
  111. package/docs/components/workbook.md +102 -0
  112. package/docs/composables/use-theme.md +59 -0
  113. package/docs/getting-started/setup.md +176 -0
  114. package/docs/guides/draggable.md +211 -0
  115. package/docs/guides/internationalization.md +281 -0
  116. package/docs/guides/performance.md +118 -0
  117. package/docs/guides/testing-forms.md +154 -0
  118. package/docs/guides/testing-overlays.md +131 -0
  119. package/docs/guides/theming.md +124 -0
  120. package/docs/utilities/search.md +580 -0
  121. package/docs/utilities/utilities.md +371 -0
  122. package/docs-manifest.json +339 -0
  123. package/package.json +5 -13
  124. package/scripts/generate-docs-manifest.js +207 -0
  125. package/scripts/sync-docs.js +754 -0
  126. package/style.css +1 -1
  127. /package/components/Dropdown/{DropdownMenu2.vue.js → DropdownMenu3.vue.js} +0 -0
@@ -0,0 +1,521 @@
1
+ # ImportData
2
+
3
+ **Import:** `import { ImportData } from 'vlite3'`
4
+
5
+ ### Description
6
+
7
+ `ImportData` is a production-ready, multi-step CSV/TSV wizard component for Vue 3. It facilitates complex, user-friendly bulk imports by guiding the user through file upload, header mapping, validation, conflict resolution settings, and real-time batch processing with robust progress indicators and failure reporting.
8
+
9
+ The component is highly optimized for performance and works seamlessly both as an inline trigger or integrated into larger UI shells like `Screen`.
10
+
11
+ ---
12
+
13
+ ## High-Level Wizard Flow
14
+
15
+ The import experience is split into a **4-step wizard**:
16
+
17
+ ```mermaid
18
+ graph TD
19
+ A[Step 1: Upload] --> B[Step 2: Mapping]
20
+ B --> C[Step 3: Options]
21
+ C --> D[Step 4: Import]
22
+ ```
23
+
24
+ 1. **Upload** — Drag & drop a `.csv` file, click to browse, or paste raw tabular data (e.g. copied from Excel/CSV/TSV). Delimiters (commas, semicolons, tabs) are auto-detected.
25
+ 2. **Mapping** — Align detected CSV headers with system fields. Auto-mapping normalizes headers to `camelCase` and performs case-insensitive matching. The user can manually map fields, ignore columns, and view real-time data previews.
26
+ 3. **Options** — Set conflict resolution strategies. Define how to handle rows matching existing database records (e.g., skip, update/replace, or duplicate) and how to handle entirely new records.
27
+ 4. **Import** — Displays a live circular progress tracker during sequential batch processing. Once finished, shows a comprehensive performance breakdown (created, updated, skipped, failed) along with collapsible error logs for any failed rows.
28
+
29
+ ---
30
+
31
+ ## Props
32
+
33
+ | Prop | Type | Default | Description |
34
+ | :--- | :--- | :------ | :---------- |
35
+ | `fields` | `ImportField[]` | _(required)_ | Definitions of the system fields to map CSV columns to. See `ImportField` type below. |
36
+ | `processBatch` | `(payload: ImportBatchPayload) => Promise<ImportBatchResult>` | _(required)_ | Async callback called for each batch of rows. Receives processed, mapped data and import options. Must return a result summary object. |
37
+ | `title` | `string` | `'Import Data'` | Title displayed in the modal header and default trigger button. |
38
+ | `titleI18n` | `string` | — | i18n key for the modal title. Takes priority over `title` when set. |
39
+ | `buttonText` | `string` | `'Import'` | Label for the default trigger button. |
40
+ | `buttonIcon` | `string` | `'lucide:upload'` | Iconify icon ID for the default trigger button. |
41
+ | `batchSize` | `number` | `200` | Number of rows processed per `processBatch` call. Adjust to match API rate limits. |
42
+ | `onComplete` | `() => void` | — | Callback invoked after all batches complete. Maps to the `@complete` event. |
43
+ | `show` | `boolean` | `false` | Controls the modal's visibility externally. Enables dual-mode control (direct or parent-controlled). |
44
+
45
+ ---
46
+
47
+ ## TypeScript Definitions
48
+
49
+ All interfaces are exported from the component package:
50
+
51
+ ```ts
52
+ export interface ImportField {
53
+ field: string // System field key / property name in your data model.
54
+ title: string // Human-readable label shown in the mapping table column.
55
+ required?: boolean // If true, the field MUST be mapped or a validation error is shown.
56
+ matchings?: string[] // Alternative CSV header names that auto-map to this field.
57
+ expectedType?: 'string' | 'number' | 'boolean' | 'array' | 'object'
58
+ defaultValue?: any // Value used when the CSV cell is empty/null/undefined.
59
+ onMatch?: (value: any) => any // Transform function applied to each matched value after type coercion.
60
+ }
61
+
62
+ export interface ImportOptions {
63
+ existing: 'add' | 'replace' | 'skip'
64
+ // 'add' — Create a duplicate record even if a match is found.
65
+ // 'replace' — Overwrite (update) the matching record with imported data.
66
+ // 'skip' — Ignore the row if a matching record already exists.
67
+
68
+ new: 'create' | 'skip'
69
+ // 'create' — Create a new record for rows with no existing match.
70
+ // 'skip' — Ignore the row if no existing match is found.
71
+ }
72
+
73
+ export interface ImportBatchPayload {
74
+ data: any[] // Batch of fully mapped and transformed row objects.
75
+ options: ImportOptions // User-selected conflict resolution options from Step 3.
76
+ }
77
+
78
+ export interface ImportBatchResult {
79
+ processed: number // Total rows processed in this batch.
80
+ created: number // Rows that resulted in a new record being created.
81
+ updated: number // Rows that resulted in an existing record being updated.
82
+ skipped: number // Rows that were intentionally skipped.
83
+ failed: number // Rows that encountered an error during processing.
84
+ errors: {
85
+ record: string // Row identifier (usually the 1-based row index as a string).
86
+ message: string // Human-readable error description.
87
+ }[]
88
+ }
89
+
90
+ export interface ImportProgress {
91
+ total: number
92
+ processed: number
93
+ created: number
94
+ updated: number
95
+ skipped: number
96
+ failed: number
97
+ percentage: number
98
+ errors: { record: string; message: string }[]
99
+ }
100
+ ```
101
+
102
+ ---
103
+
104
+ ## Deep Dive: Data Transformation Pipeline
105
+
106
+ Before `processBatch` is called, the raw text rows are organized and converted into system-compatible payloads. Understanding this sequence is vital when configuring fields:
107
+
108
+ ```mermaid
109
+ flowchart TD
110
+ Raw[Raw CSV/Pasted String Row] --> Key[1. Key Remapping]
111
+ Key --> Nest[2. Dot-Notation Object Expansion]
112
+ Nest --> Def[3. Empty Cell & Default Injection]
113
+ Def --> Coer[4. Expected Type Coercion]
114
+ Coer --> Match[5. Custom onMatch Transform]
115
+ Match --> Final[System-Ready Payload Object]
116
+ ```
117
+
118
+ ### 1. Key Remapping
119
+ The CSV column header is matched to the correct `field` key based on the user mapping config.
120
+
121
+ ### 2. Dot-Notation Object Expansion
122
+ If the system field contains dots (e.g., `'address.city'`), the component dynamically constructs nested JavaScript objects.
123
+ * **Input row:** `{'City': 'New York'}` mapped to `address.city`
124
+ * **Intermediate structure:** `{ address: { city: 'New York' } }`
125
+
126
+ ### 3. Default Value Injection
127
+ If a CSV cell is missing or resolves to an empty string (`undefined`, `null`, or `''`), and the field defines a `defaultValue`, it is injected:
128
+ * E.g., `{ role: '' }` with `defaultValue: 'User'` becomes `{ role: 'User' }`.
129
+
130
+ ### 4. Expected Type Coercion
131
+ If `expectedType` is provided, values undergo primitive conversion:
132
+ * `'number'`: Converts via `Number(val) || 0`.
133
+ * `'boolean'`: Evaluated via `Boolean(val && val.toString().toLowerCase() !== 'false' && val !== '0')`.
134
+ * > [!NOTE]
135
+ > For `'string'`, `'array'`, and `'object'` types, no automatic conversion is performed. You should handle these structures using the `onMatch` transform.
136
+
137
+ ### 5. Custom `onMatch` Transform
138
+ If a field has an `onMatch` function defined, it executes last. It receives the coerced/default value and returns the final transformed value.
139
+
140
+ ---
141
+
142
+ ## Validation & Mapping Safeguards
143
+
144
+ When moving from **Step 2 (Mapping)** to **Step 3 (Options)**, the component runs validation. If checks fail, an alert details the errors and stops wizard progression.
145
+
146
+ ### 1. Required Fields Mapping Check
147
+ Any field in the `fields` array containing `required: true` **must** be actively mapped to a CSV column. If missing, a validation error is thrown (e.g., `Required field "First Name" is not mapped.`).
148
+
149
+ ### 2. Duplicate Mapping Check
150
+ A single system field cannot be mapped to multiple CSV columns simultaneously. Doing so triggers a mapping error (e.g., `Field "email" is mapped to multiple headers: Email, Primary Email.`).
151
+
152
+ ### 3. Ignored Columns
153
+ Checking the **Ignore** box on a row in Step 2 excludes that column from the data pipeline completely. The column's value will not be present in the final data objects passed to the API.
154
+
155
+ ---
156
+
157
+ ## Conflict Resolution Options (Step 3)
158
+
159
+ The wizard lets users specify how to resolve conflicts before running the import. The choices are packaged inside the `ImportOptions` object and passed to your API inside the batch payload:
160
+
161
+ ### `existing` Options (Records that already exist in your system)
162
+ * **`replace` (Update):** Overwrite existing fields with the imported data.
163
+ * **`add` (Add New):** Create a duplicate record in the system anyway.
164
+ * **`skip`:** Leave the existing record untouched.
165
+
166
+ ### `new` Options (Records with no match in your system)
167
+ * **`create` (Create New):** Create a completely new record.
168
+ * **`skip`:** Ignore the row if it does not already exist.
169
+
170
+ > [!TIP]
171
+ > The exact logic for detecting whether a record is "existing" or "new" (e.g., matching by email or unique ID) must be implemented inside your `processBatch` callback, as the component has no direct database access.
172
+
173
+ ---
174
+
175
+ ## Performance & Optimization Design
176
+
177
+ ### Avoiding Reactivity Bottlenecks
178
+ Processing massive spreadsheets with thousands of rows in Vue can cause UI lag due to Vue's deep dependency tracking. To counter this, `ImportData` declares heavy data structures (`importData`, `csvFile`, `headers`, `preview`) as **`shallowRef`** instead of `ref`. This bypasses deep proxying and ensures the UI remains extremely smooth and the memory footprint remains low.
179
+
180
+ ### Sequential Chunking (`batchSize`)
181
+ Dividing a large import of 10,000 rows into standard HTTP requests prevents browser and API bottlenecks. The component slices data into chunks of `batchSize` (default `200`) and calls `processBatch` sequentially.
182
+
183
+ ### Progress Simulation
184
+ To prevent the user interface from appearing frozen during slow server transactions, the circular progress indicator simulates progress using an interval. It will smoothly transition values but caps progress at `99%` until the final backend batch completes, at which point it jumps to `100%` and transitions to the complete state.
185
+
186
+ ---
187
+
188
+ ## Error Handling & Failure Details Log
189
+
190
+ If any row fails inside a batch, the `processBatch` callback must return an `errors` array in `ImportBatchResult`:
191
+
192
+ ```json
193
+ {
194
+ "processed": 100,
195
+ "created": 95,
196
+ "updated": 2,
197
+ "skipped": 2,
198
+ "failed": 1,
199
+ "errors": [
200
+ { "record": "14", "message": "Invalid phone number format." }
201
+ ]
202
+ }
203
+ ```
204
+
205
+ On completion, if `failed > 0`:
206
+ 1. A warning notification appears stating the number of failures.
207
+ 2. A warning badge is displayed at the bottom of the success card.
208
+ 3. A collapsible list ("View Error Details") is made available. Clicking it displays a list mapping specific rows to their corresponding failure messages (e.g., `Row 14: Invalid phone number format.`).
209
+
210
+ ---
211
+
212
+ ## Reactivity & Modal Resets
213
+
214
+ The wizard state is fully encapsulated and auto-resets when the modal is dismissed. Closing the modal by clicking outside, using the Close/Done buttons, or pressing the `Esc` key calls the `resetState` routine.
215
+ * Reset parameters: current step goes back to `1`, `importData` array is cleared, uploaded files are set to `null`, mappings are emptied, progress metrics are zeroed.
216
+ * This ensures that opening the importer a second time provides a completely fresh slate.
217
+
218
+ ---
219
+
220
+ ## Slots
221
+
222
+ | Slot | Description |
223
+ | :--- | :---------- |
224
+ | `trigger` | Replaces the default trigger button. Useful for custom styling. When using the external `show` control, this slot is not needed. |
225
+
226
+ ---
227
+
228
+ ## Events
229
+
230
+ | Event | Payload | Description |
231
+ | :---- | :------ | :---------- |
232
+ | `@update:show` | `boolean` | Emitted when the modal is opened or closed. Facilitates `v-model:show` synchronization with parent states. |
233
+ | `@complete` | _(none)_ | Emitted after all batches have finished processing. Equivalent to the `onComplete` prop function. |
234
+
235
+ ---
236
+
237
+ ## Translation Keys Reference (i18n)
238
+
239
+ The component utilizes the `$t()` utility for internationalization. All translation keys, default English fallbacks, and parameter structures are outlined below.
240
+
241
+ ### Screen Keys
242
+
243
+ These translation keys apply when using `ImportData` inside the unified `Screen` component:
244
+
245
+ | Key | Default Fallback |
246
+ | :-------------------------------- | :-------------------------------------------------------- |
247
+ | `vlite.screen.deleteSelected` | `'Delete Selected'` |
248
+ | `vlite.screen.listView` | `'List View'` |
249
+ | `vlite.screen.tableView` | `'Table View'` |
250
+ | `vlite.screen.refresh` | `'Refresh'` |
251
+ | `vlite.screen.searchPlaceholder` | `'Search...'` |
252
+ | `vlite.screen.confirmDeleteTitle` | `'Confirm Deletion'` |
253
+ | `vlite.screen.confirmDeleteDesc` | `'Are you sure you want to delete the selected item(s)?'` |
254
+ | `vlite.screen.confirmDeleteBtn` | `'Delete'` |
255
+ | `vlite.screen.cancelBtn` | `'Cancel'` |
256
+ | `vlite.screen.missingView` | `'Please provide a :list or :table component.'` |
257
+ | `vlite.screen.addNew` | `'Add New'` |
258
+ | `vlite.screen.filters` | `'Filters'` |
259
+ | `vlite.screen.filter` | `'Filter'` |
260
+ | `vlite.screen.applyFilters` | `'Apply Filters'` |
261
+ | `vlite.screen.exportData` | `'Export Data'` |
262
+ | `vlite.screen.importData` | `'Import Data'` |
263
+ | `vlite.screen.moreOptions` | `'More Options'` |
264
+
265
+ ### ExportData Keys
266
+
267
+ Used for exporting dataset selections:
268
+
269
+ | Key | Default Fallback |
270
+ | :------------------------------ | :------------------------------------------ |
271
+ | `vlite.exportData.selectFormat` | `'Select Export Format'` |
272
+ | `vlite.exportData.success` | `'Data exported successfully as {format}'` |
273
+ | `vlite.exportData.error` | `'An error occurred while exporting data.'` |
274
+ | `vlite.exportData.noData` | `'No data available to export.'` |
275
+
276
+ ### ImportData Keys
277
+
278
+ Directly used inside `ImportData.vue` and its step views:
279
+
280
+ | Key | Default Fallback |
281
+ | :---------------------------------- | :--------------------------------------------------------- |
282
+ | `vlite.importData.stepUpload` | `'Upload'` |
283
+ | `vlite.importData.stepMapping` | `'Mapping'` |
284
+ | `vlite.importData.stepOptions` | `'Options'` |
285
+ | `vlite.importData.stepImport` | `'Import'` |
286
+ | `vlite.importData.btnBack` | `'Back'` |
287
+ | `vlite.importData.btnNext` | `'Next'` |
288
+ | `vlite.importData.btnStart` | `'Start Import'` |
289
+ | `vlite.importData.btnDone` | `'Done'` |
290
+ | `vlite.importData.uploadData` | `'Upload Data'` |
291
+ | `vlite.importData.dragDrop` | `'Drag & drop a file here or click to browse'` |
292
+ | `vlite.importData.csvOnlyHint` | `'Only CSV files are supported'` |
293
+ | `vlite.importData.pasteData` | `'Or paste CSV/Excel data'` |
294
+ | `vlite.importData.process` | `'Process Data'` |
295
+ | `vlite.importData.pastePlaceholder` | `'id, name, email\n1, John Doe, john@example.com'` |
296
+ | `vlite.importData.assignFields` | `'Assign Fields'` |
297
+ | `vlite.importData.assignDesc` | `'Match your CSV columns to the correct system fields.'` |
298
+ | `vlite.importData.csvHeader` | `'CSV Header'` |
299
+ | `vlite.importData.fieldMapping` | `'System Field'` |
300
+ | `vlite.importData.preview` | `'Data Preview'` |
301
+ | `vlite.importData.noHeaders` | `'No headers mapped. Data will not be imported properly.'` |
302
+ | `vlite.importData.options` | `'Import Options'` |
303
+ | `vlite.importData.matchFound` | `'When a match is found'` |
304
+ | `vlite.importData.matchFoundDesc` | `'Determine how to handle records that already exist.'` |
305
+ | `vlite.importData.noMatch` | `'When no match is found'` |
306
+ | `vlite.importData.noMatchDesc` | `'Determine how to handle completely new records.'` |
307
+ | `vlite.importData.optAddTitle` | `'Add New'` |
308
+ | `vlite.importData.optAddDesc` | `'Creates a duplicate record instead of overwriting.'` |
309
+ | `vlite.importData.optReplaceTitle` | `'Update'` |
310
+ | `vlite.importData.optReplaceDesc` | `'Overwrites existing fields with the imported data.'` |
311
+ | `vlite.importData.optSkipTitle` | `'Skip'` |
312
+ | `vlite.importData.optSkipDesc` | `'Leaves existing records completely untouched.'` |
313
+ | `vlite.importData.optCreateTitle` | `'Create New'` |
314
+ | `vlite.importData.optCreateDesc` | `'Creates a completely new record in the system.'` |
315
+ | `vlite.importData.optSkipNewTitle` | `'Skip'` |
316
+ | `vlite.importData.optSkipNewDesc` | `'Ignores the row if it does not already exist.'` |
317
+ | `vlite.importData.processing` | `'Processing Data...'` |
318
+ | `vlite.importData.doNotClose` | `'Please do not close this window.'` |
319
+ | `vlite.importData.complete` | `'Import Complete'` |
320
+ | `vlite.importData.successCount` | `'Successfully processed {total} records.'` |
321
+ | `vlite.importData.total` | `'Total'` |
322
+ | `vlite.importData.created` | `'Created'` |
323
+ | `vlite.importData.updated` | `'Updated'` |
324
+ | `vlite.importData.skipped` | `'Skipped'` |
325
+ | `vlite.importData.failedCount` | `'{count} records failed to import'` |
326
+ | `vlite.importData.viewErrors` | `'View Error Details'` |
327
+ | `vlite.importData.hideErrors` | `'Hide Error Details'` |
328
+ | `vlite.importData.row` | `'Row'` |
329
+ | `vlite.importData.csvOnly` | `'Please upload a CSV file'` |
330
+ | `vlite.importData.emptyCsv` | `'The CSV file is empty.'` |
331
+ | `vlite.importData.parseError` | `'Failed to parse CSV: '` |
332
+ | `vlite.importData.processError` | `'Error processing CSV data'` |
333
+ | `vlite.importData.success` | `'Data imported successfully.'` |
334
+ | `vlite.importData.partial` | `'Import completed with some errors.'` |
335
+ | `vlite.importData.error` | `'A critical error occurred during import.'` |
336
+
337
+ ---
338
+
339
+ ## Usage Examples
340
+
341
+ ### 1. Standard Importer
342
+
343
+ ```vue
344
+ <script setup lang="ts">
345
+ import { ImportData, type ImportField, type ImportBatchPayload, type ImportBatchResult } from 'vlite3'
346
+
347
+ const fields: ImportField[] = [
348
+ {
349
+ field: 'firstName',
350
+ title: 'First Name',
351
+ required: true,
352
+ matchings: ['name', 'fname', 'first name'],
353
+ },
354
+ {
355
+ field: 'lastName',
356
+ title: 'Last Name',
357
+ matchings: ['lname', 'surname', 'last name'],
358
+ },
359
+ {
360
+ field: 'email',
361
+ title: 'Email Address',
362
+ required: true,
363
+ matchings: ['mail', 'email address'],
364
+ },
365
+ {
366
+ field: 'role',
367
+ title: 'User Role',
368
+ expectedType: 'string',
369
+ defaultValue: 'User',
370
+ },
371
+ {
372
+ field: 'address.city',
373
+ title: 'City',
374
+ matchings: ['city', 'location'],
375
+ },
376
+ ]
377
+
378
+ const handleBatch = async (payload: ImportBatchPayload): Promise<ImportBatchResult> => {
379
+ // Send batch payload containing mapped data and import options to your API
380
+ const result = await myApi.importUsers(payload.data, payload.options)
381
+ return {
382
+ processed: payload.data.length,
383
+ created: result.created,
384
+ updated: result.updated,
385
+ skipped: result.skipped,
386
+ failed: result.failed,
387
+ errors: result.errors || [],
388
+ }
389
+ }
390
+ </script>
391
+
392
+ <template>
393
+ <ImportData
394
+ title="Import Users"
395
+ button-text="Import CSV"
396
+ button-icon="lucide:upload-cloud"
397
+ :fields="fields"
398
+ :batch-size="100"
399
+ :process-batch="handleBatch"
400
+ :on-complete="fetchUsers" />
401
+ </template>
402
+ ```
403
+
404
+ ---
405
+
406
+ ### 2. Custom Trigger Button
407
+
408
+ Use the `#trigger` slot to replace the default styled button with a custom button.
409
+
410
+ ```vue
411
+ <template>
412
+ <ImportData :fields="fields" :process-batch="handleBatch">
413
+ <template #trigger>
414
+ <Button variant="secondary" icon="lucide:file-up"> Bulk Import </Button>
415
+ </template>
416
+ </ImportData>
417
+ </template>
418
+ ```
419
+
420
+ ---
421
+
422
+ ### 3. Externally Controlled via `v-model:show`
423
+
424
+ Use this method when you want to control the importer's visibility from outside the component (e.g., matching options in a dropdown on the screen).
425
+
426
+ ```vue
427
+ <script setup lang="ts">
428
+ import { ref } from 'vue'
429
+ import { ImportData } from 'vlite3'
430
+
431
+ const showImport = ref(false)
432
+ </script>
433
+
434
+ <template>
435
+ <Button @click="showImport = true" icon="lucide:upload">Open Importer</Button>
436
+
437
+ <ImportData
438
+ v-model:show="showImport"
439
+ title="Import Products"
440
+ :fields="productFields"
441
+ :process-batch="handleBatch"
442
+ @complete="refetchProducts" />
443
+ </template>
444
+ ```
445
+
446
+ ---
447
+
448
+ ### 4. With `onMatch` Transform and `expectedType`
449
+
450
+ Perform custom sanitation and cleanups on values before processing.
451
+
452
+ ```vue
453
+ <script setup lang="ts">
454
+ import type { ImportField } from 'vlite3'
455
+
456
+ const fields: ImportField[] = [
457
+ {
458
+ field: 'isActive',
459
+ title: 'Active Status',
460
+ expectedType: 'boolean',
461
+ // Normalize CSV values like 'yes', 'true', 'active', or '1' to boolean true
462
+ onMatch: (val) => {
463
+ const v = String(val).toLowerCase().trim()
464
+ return v === 'yes' || v === 'true' || v === '1' || v === 'active'
465
+ },
466
+ },
467
+ {
468
+ field: 'price',
469
+ title: 'Price',
470
+ expectedType: 'number',
471
+ defaultValue: 0,
472
+ // Strip out currency symbols and parse string to float
473
+ onMatch: (val) => parseFloat(String(val).replace(/[^0-9.]/g, '')) || 0,
474
+ },
475
+ ]
476
+ </script>
477
+ ```
478
+
479
+ ---
480
+
481
+ ### 5. Simulating a Backend `processBatch`
482
+
483
+ Use this mockup pattern to test behavior and formatting flows locally without database writes:
484
+
485
+ ```vue
486
+ <script setup lang="ts">
487
+ import type { ImportBatchPayload, ImportBatchResult } from 'vlite3'
488
+
489
+ const simulateBatch = async ({ data, options }: ImportBatchPayload): Promise<ImportBatchResult> => {
490
+ await new Promise((resolve) => setTimeout(resolve, 800)) // Simulate network latency
491
+
492
+ let created = 0
493
+ let updated = 0
494
+ let skipped = 0
495
+ let failed = 0
496
+ const errors = []
497
+
498
+ data.forEach((row, i) => {
499
+ if (!row.email) {
500
+ failed++
501
+ errors.push({ record: String(i + 1), message: 'Missing required field: email' })
502
+ } else if (options.existing === 'skip' && i % 5 === 0) {
503
+ skipped++
504
+ } else if (options.existing === 'replace' && i % 4 === 0) {
505
+ updated++
506
+ } else {
507
+ created++
508
+ }
509
+ })
510
+
511
+ return {
512
+ processed: data.length,
513
+ created,
514
+ updated,
515
+ skipped,
516
+ failed,
517
+ errors
518
+ }
519
+ }
520
+ </script>
521
+ ```
@@ -0,0 +1,58 @@
1
+ # Input
2
+
3
+ **Import:** `import { Input } from 'vlite3'`
4
+
5
+ ### Props
6
+
7
+ | Prop | Type | Default | Description |
8
+ | :---------------- | :----------------------------------------------------- | :-------- | :--------------------------------------- |
9
+ | `modelValue` | `string \| number` | `''` | Binding (`v-model`) |
10
+ | `type` | `InputType` | `text` | Native input type (text, password, etc.) |
11
+ | `label` | `string` | — | Label text |
12
+ | `labelI18n` | `string` | — | I18n key for the label |
13
+ | `placeholder` | `string` | — | Input placeholder |
14
+ | `placeholderI18n` | `string` | — | I18n key for the placeholder |
15
+ | `disabled` | `boolean` | `false` | Disable input |
16
+ | `error` | `string` | — | Error message / state |
17
+ | `variant` | `'solid' \| 'outline' \| 'outline-b' \| 'transparent'` | `outline` | Visual style |
18
+ | `size` | `'sm' \| 'md' \| 'lg'` | `md` | Dimensions |
19
+ | `rounded` | `InputRounded` | `md` | Border radius |
20
+ | `icon` | `string` | — | Leading icon (Iconify ID) |
21
+ | `iconRight` | `string` | — | Trailing icon (Iconify ID) |
22
+ | `loading` | `boolean` | `false` | Show spinner |
23
+ | `showClearButton` | `boolean` | `true` | Show clear 'x' when value exists |
24
+ | `autofocus` | `boolean` | `false` | Automatically focus on mount |
25
+ | `lazy` | `boolean` | `false` | Update v-model lazily |
26
+ | `rows` | `number` | `3` | Number of rows (for textarea type) |
27
+ | `addonLeft` | `string` | — | Text addon on the left (control strip is always LTR) |
28
+ | `addonRight` | `string` | — | Text addon on the right (control strip is always LTR) |
29
+ | `addonLeftClass` | `string` | — | Custom class for left addon wrapper |
30
+ | `addonRightClass` | `string` | — | Custom class for right addon wrapper |
31
+ | `labelPosition` | `'top' \| 'left' \| 'right'` | `top` | Label placement |
32
+ | `class` | `string` | — | Custom wrapper class |
33
+ | `inputClass` | `string` | — | Custom input element class |
34
+
35
+ ### Events
36
+
37
+ - `@update:modelValue`: Emitted on input
38
+ - `@change`: Emitted on blur/change
39
+ - `@focus`
40
+ - `@blur`
41
+ - `@click:icon`: Click on left icon
42
+ - `@click:icon-right`: Click on right icon
43
+
44
+ ### Usage
45
+
46
+ ```vue
47
+ <Input v-model="username" label="Username" placeholder="Enter username" icon="lucide:user" />
48
+
49
+ <Input v-model="password" label="Password" type="password" variant="filled" />
50
+
51
+ <Input v-model="price" label="Price" addon-left="$" addon-right=".00" type="number" />
52
+ ```
53
+
54
+ #### RTL
55
+
56
+ The label follows page direction. The addon control strip is a **`dir="ltr"` island**: `addonLeft` stays on the left and `addonRight` on the right (URLs, currency, protocols, copy actions). Joined corners use logical radii (`rounded-s` / `rounded-e`) which match physical left/right inside that island. Nested Dropdowns with `direction="auto"` pick up the island `dir` so labels like `https://` do not reverse.
57
+
58
+ The text field itself (typed value, **placeholder**, leading/trailing icons, clear/password controls, and logical padding) follows page direction via a nested `.input-field-chrome` island, so Arabic/Hebrew placeholders and icons mirror correctly even when addons stay LTR.