@a-vision-software/vue-input-components 1.3.24 → 1.3.26

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.
@@ -1,12 +1,12 @@
1
1
  export interface CheckboxOption {
2
- id: string
3
- label: string
2
+ id: string | boolean
3
+ label?: string | null
4
4
  disabled?: boolean
5
5
  }
6
6
 
7
7
  export interface CheckboxProps {
8
- options: CheckboxOption[]
9
- modelValue: string | string[]
8
+ options?: CheckboxOption[]
9
+ modelValue: string | string[] | boolean
10
10
  multiple?: boolean
11
11
  disabled?: boolean
12
12
  width?: string
@@ -29,3 +29,7 @@ export interface CheckboxProps {
29
29
  columns?: number
30
30
  presentation?: 'default' | 'minimal'
31
31
  }
32
+
33
+ export interface ListCheckboxProps extends CheckboxProps {
34
+ onCheckboxClick: (row: any, itemKey: string) => void
35
+ }
@@ -8,3 +8,4 @@ export * from './action'
8
8
  export * from './navigation'
9
9
  export * from './dropdown'
10
10
  export * from './checkbox'
11
+ export * from './list'
package/src/types/list.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import { ListActionProps } from './action'
2
+
1
3
  export type ListPresentation = 'default' | 'minimal'
2
4
 
3
5
  export type ListDataType = 'text' | 'number' | 'date' | 'action' | 'checkbox' | 'icon'
@@ -5,18 +7,13 @@ export type ListDataType = 'text' | 'number' | 'date' | 'action' | 'checkbox' |
5
7
  export interface ListColumn {
6
8
  key: string
7
9
  label: string
8
- type: ListDataType
10
+ type?: 'text' | 'number' | 'date' | 'action' | 'checkbox' | 'icon'
11
+ align?: 'left' | 'center' | 'right'
9
12
  sortable?: boolean
10
13
  filterable?: boolean
11
14
  width?: string
12
- align?: 'left' | 'center' | 'right'
13
- }
14
-
15
- export interface ListAction {
16
- label: string
17
- icon?: string
18
- onClick: () => void
19
- disabled?: boolean
15
+ minWidth?: string
16
+ maxWidth?: string
20
17
  }
21
18
 
22
19
  export interface ListFilter {
@@ -27,17 +24,20 @@ export interface ListFilter {
27
24
  export interface ListProps {
28
25
  columns: ListColumn[]
29
26
  data: any[]
30
- presentation?: ListPresentation
31
- filter?: ListFilter
32
- actions?: ListAction[]
27
+ actions?: ListActionProps[]
28
+ filter?: {
29
+ placeholder?: string
30
+ }
33
31
  loading?: boolean
34
32
  emptyMessage?: string
33
+ presentation?: 'default' | 'minimal'
34
+ width?: string
35
35
  }
36
36
 
37
37
  export interface ListEmits {
38
38
  (e: 'update:filter', value: string): void
39
- (e: 'sort', column: ListColumn, direction: 'asc' | 'desc'): void
40
39
  (e: 'row-click', row: any, index: number): void
40
+ (e: 'row-dblclick', row: any, index: number): void
41
41
  }
42
42
 
43
43
  export interface ListComponent {
@@ -45,3 +45,8 @@ export interface ListComponent {
45
45
  blur: () => void
46
46
  clearFilter: () => void
47
47
  }
48
+
49
+ export interface ListIconProps {
50
+ icon: string
51
+ color?: string
52
+ }
@@ -39,8 +39,18 @@
39
39
  <span class="dashboard__description">Single and multiple selection checkboxes</span>
40
40
  </router-link>
41
41
  <router-link to="/list" class="dashboard__item">
42
- <FontAwesomeIcon :icon="['fas', 'list']" class="dashboard__icon" />
42
+ <div class="dashboard__icon-wrapper">
43
+ <font-awesome-icon icon="list" class="dashboard__icon" />
44
+ </div>
43
45
  <span class="dashboard__label">List</span>
46
+ <span class="dashboard__description">Configurable data lists with sorting and filtering</span>
47
+ </router-link>
48
+ <router-link to="/action" class="dashboard__item">
49
+ <div class="dashboard__icon-wrapper">
50
+ <font-awesome-icon icon="bolt" class="dashboard__icon" />
51
+ </div>
52
+ <span class="dashboard__label">Action</span>
53
+ <span class="dashboard__description">Interactive buttons and links with various styles</span>
44
54
  </router-link>
45
55
  </div>
46
56
  </div>
@@ -54,37 +64,37 @@
54
64
  .dashboard {
55
65
  max-width: 1200px;
56
66
  margin: 0 auto;
57
- padding: 3rem 2rem;
67
+ padding: 2rem 1.5rem;
58
68
  }
59
69
 
60
70
  .dashboard h1 {
61
71
  text-align: center;
62
- margin-bottom: 1rem;
72
+ margin-bottom: 0.75rem;
63
73
  color: #2d3748;
64
- font-size: 2.5rem;
74
+ font-size: 2rem;
65
75
  font-weight: 700;
66
76
  }
67
77
 
68
78
  .dashboard__subtitle {
69
79
  text-align: center;
70
80
  color: #718096;
71
- font-size: 1.1rem;
72
- margin-bottom: 3rem;
81
+ font-size: 1rem;
82
+ margin-bottom: 2rem;
73
83
  }
74
84
 
75
85
  .dashboard__grid {
76
86
  display: grid;
77
- grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
78
- gap: 2rem;
87
+ grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
88
+ gap: 1.5rem;
79
89
  }
80
90
 
81
91
  .dashboard__item {
82
92
  display: flex;
83
93
  flex-direction: column;
84
94
  align-items: center;
85
- padding: 2rem;
95
+ padding: 1.5rem;
86
96
  background-color: #ffffff;
87
- border-radius: 1rem;
97
+ border-radius: 0.75rem;
88
98
  text-decoration: none;
89
99
  color: #2d3748;
90
100
  transition: all 0.3s ease;
@@ -93,37 +103,37 @@
93
103
  }
94
104
 
95
105
  .dashboard__item:hover {
96
- transform: translateY(-4px);
97
- box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
106
+ transform: translateY(-3px);
107
+ box-shadow: 0 8px 12px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
98
108
  border-color: #4a90e2;
99
109
  }
100
110
 
101
111
  .dashboard__icon-wrapper {
102
- width: 64px;
103
- height: 64px;
112
+ width: 48px;
113
+ height: 48px;
104
114
  display: flex;
105
115
  align-items: center;
106
116
  justify-content: center;
107
117
  background-color: #ebf8ff;
108
118
  border-radius: 50%;
109
- margin-bottom: 1.5rem;
119
+ margin-bottom: 1rem;
110
120
  }
111
121
 
112
122
  .dashboard__icon {
113
- font-size: 2rem;
123
+ font-size: 1.5rem;
114
124
  color: #4a90e2;
115
125
  }
116
126
 
117
127
  .dashboard__label {
118
- font-size: 1.25rem;
128
+ font-size: 1.1rem;
119
129
  font-weight: 600;
120
130
  margin-bottom: 0.5rem;
121
131
  }
122
132
 
123
133
  .dashboard__description {
124
- font-size: 0.9rem;
134
+ font-size: 0.85rem;
125
135
  color: #718096;
126
136
  text-align: center;
127
- line-height: 1.5;
137
+ line-height: 1.4;
128
138
  }
129
139
  </style>
@@ -1,19 +1,25 @@
1
1
  <template>
2
2
  <div class="list-test">
3
- <h1>List Component Test</h1>
3
+ <div class="list-test__header">
4
+ <router-link to="/" class="list-test__back">
5
+ <font-awesome-icon :icon="['fas', 'arrow-left']" />
6
+ <span>Back to Dashboard</span>
7
+ </router-link>
8
+ <h1>List Component Test</h1>
9
+ </div>
4
10
 
5
11
  <!-- Default Presentation -->
6
12
  <section class="list-test__section">
7
13
  <h2>Default Presentation</h2>
8
- <List :columns="columns" :data="data" :filter="{ placeholder: 'Search users...' }" :actions="actions"
9
- @update:filter="handleFilter" @sort="handleSort" @row-click="handleRowClick" />
14
+ <List :actions="listActions" :columns="columns" :data="data" :filter="{ placeholder: 'Search users...' }"
15
+ @row-click="handleRowClick" @row-dblclick="handleRowDblClick" />
10
16
  </section>
11
17
 
12
18
  <!-- Minimal Presentation -->
13
19
  <section class="list-test__section">
14
20
  <h2>Minimal Presentation</h2>
15
- <List :columns="columns" :data="data" presentation="minimal" :filter="{ placeholder: 'Search users...' }"
16
- @update:filter="handleFilter" @sort="handleSort" @row-click="handleRowClick" />
21
+ <List :actions="listActions" :columns="columns" :data="data" presentation="minimal" width="50em"
22
+ :filter="{ placeholder: 'Search users...' }" @row-click="handleRowClick" @row-dblclick="handleRowDblClick" />
17
23
  </section>
18
24
 
19
25
  <!-- Loading State -->
@@ -32,10 +38,73 @@
32
38
 
33
39
  <script setup lang="ts">
34
40
  import { ref } from 'vue'
35
- import { List } from '@/components/List'
36
- import type { ListColumn, ListAction } from '../types/list'
41
+ import List from '@/components/List.vue'
42
+ import type { ListColumn, ListActionProps, ListCheckboxProps, ListIconProps } from '@/types'
43
+
44
+ const autosaveActive = (info: any) => {
45
+ console.log('Autosave active', info)
46
+ }
47
+
48
+ const listActionClick = (row: any, action: ListActionProps) => {
49
+ if (!row && action) {
50
+ console.log('List action clicked:', row, action)
51
+ }
52
+ }
53
+
54
+ const selectClick = (row: any, itemKey: string) => {
55
+ if (row && itemKey) {
56
+ console.log('Select clicked:', row, itemKey)
57
+ }
58
+ }
59
+
60
+ const rowActionClick = (row: any, action: ListActionProps) => {
61
+ if (row && action) {
62
+ console.log('Action clicked:', row, action)
63
+ }
64
+ }
65
+
66
+ const handleRowClick = (row: any, index: number) => {
67
+ console.log('Row clicked:', row, index)
68
+ if (row?.select) {
69
+ row.select.modelValue = !row.select.modelValue
70
+ } else {
71
+ row.selected = !row.selected
72
+ }
73
+ }
74
+
75
+ const handleRowDblClick = (row: any, index: number) => {
76
+ console.log('Row double-clicked:', row, index)
77
+ }
78
+
79
+ const listActions = ref<ListActionProps[]>([
80
+ {
81
+ id: 'new-user',
82
+ label: 'New user',
83
+ icon: 'add',
84
+ color: 'var(--primary-color)',
85
+ onActionClick: listActionClick
86
+ }
87
+ ])
37
88
 
38
89
  const columns: ListColumn[] = [
90
+ {
91
+ key: 'select',
92
+ label: '',
93
+ type: 'checkbox',
94
+ sortable: false,
95
+ filterable: false,
96
+ align: 'center',
97
+ width: '4rem'
98
+ },
99
+ {
100
+ key: 'status',
101
+ label: 'Status',
102
+ type: 'icon',
103
+ sortable: false,
104
+ filterable: false,
105
+ align: 'center',
106
+ width: '4rem'
107
+ },
39
108
  {
40
109
  key: 'name',
41
110
  label: 'Name',
@@ -54,82 +123,270 @@ const columns: ListColumn[] = [
54
123
  key: 'joined',
55
124
  label: 'Joined',
56
125
  type: 'date',
57
- sortable: true
126
+ sortable: true,
127
+ width: '6rem'
58
128
  },
59
129
  {
60
130
  key: 'active',
61
131
  label: 'Active',
62
132
  type: 'checkbox',
63
- align: 'center'
133
+ align: 'center',
134
+ width: '4rem'
64
135
  },
65
136
  {
66
137
  key: 'actions',
67
138
  label: 'Actions',
68
139
  type: 'action',
69
- align: 'right'
140
+ align: 'right',
141
+ width: '12rem'
70
142
  }
71
143
  ]
72
144
 
73
145
  const data = ref([
74
146
  {
147
+ selected: false,
148
+ select: <ListCheckboxProps>{
149
+ modelValue: false,
150
+ disabled: false,
151
+ onCheckboxClick: selectClick
152
+ },
153
+ status: <ListIconProps>{
154
+ icon: 'star',
155
+ color: 'lightgray',
156
+ },
75
157
  name: 'John Doe',
76
158
  email: 'john@example.com',
77
159
  joined: '2023-01-15',
78
160
  active: {
79
161
  modelValue: true,
80
- disabled: false
162
+ disabled: false,
163
+ autosave: autosaveActive,
164
+ onCheckboxClick: selectClick
81
165
  },
82
- actions: {
83
- label: 'Edit',
84
- icon: 'edit',
85
- onClick: () => console.log('Edit John')
86
- }
166
+ actions: <ListActionProps[]>[
167
+ {
168
+ id: 'edit',
169
+ label: 'Edit',
170
+ icon: 'edit',
171
+ onActionClick: rowActionClick
172
+ },
173
+ {
174
+ id: 'delete',
175
+ label: 'Delete',
176
+ icon: 'trash',
177
+ color: 'var(--danger-color)',
178
+ onActionClick: rowActionClick
179
+ }
180
+ ]
87
181
  },
88
182
  {
183
+ selected: false,
184
+ select: <ListCheckboxProps>{
185
+ modelValue: false,
186
+ disabled: false,
187
+ onCheckboxClick: selectClick
188
+ },
189
+ status: <ListIconProps>{
190
+ icon: 'star',
191
+ color: 'gold',
192
+ },
89
193
  name: 'Jane Smith',
90
194
  email: 'jane@example.com',
91
195
  joined: '2023-02-20',
92
- active: {
196
+ active: <ListCheckboxProps>{
93
197
  modelValue: false,
198
+ disabled: false,
199
+ autosave: autosaveActive
200
+ },
201
+ actions: <ListActionProps[]>[
202
+ {
203
+ id: 'edit',
204
+ label: 'Edit',
205
+ icon: 'edit',
206
+ onActionClick: rowActionClick
207
+ },
208
+ {
209
+ id: 'delete',
210
+ label: 'Delete',
211
+ icon: 'trash',
212
+ onActionClick: rowActionClick
213
+ }
214
+ ]
215
+ },
216
+ {
217
+ select: <ListCheckboxProps>{
218
+ modelValue: false,
219
+ disabled: false,
220
+ onCheckboxClick: selectClick
221
+ },
222
+ name: 'Alice Johnson',
223
+ email: 'alice@example.com',
224
+ joined: '2024-01-10',
225
+ active: <ListCheckboxProps>{
226
+ modelValue: true,
94
227
  disabled: false
95
228
  },
96
- actions: {
97
- label: 'Edit',
98
- icon: 'edit',
99
- onClick: () => console.log('Edit Jane')
100
- }
101
- }
102
- ])
103
-
104
- const actions: ListAction[] = [
229
+ actions: <ListActionProps[]>[
230
+ {
231
+ id: 'edit',
232
+ label: 'Edit',
233
+ icon: 'edit',
234
+ onActionClick: rowActionClick
235
+ },
236
+ {
237
+ id: 'delete',
238
+ label: 'Delete',
239
+ icon: 'trash',
240
+ disabled: true,
241
+ onActionClick: rowActionClick
242
+ }
243
+ ]
244
+ },
245
+ {
246
+ name: 'Bob Wilson',
247
+ email: 'bob@example.com',
248
+ joined: '2023-11-05',
249
+ active: <ListCheckboxProps>{
250
+ modelValue: true,
251
+ disabled: true
252
+ },
253
+ actions: <ListActionProps[]>[
254
+ {
255
+ id: 'view',
256
+ label: 'View',
257
+ icon: 'eye',
258
+ onActionClick: rowActionClick
259
+ }
260
+ ]
261
+ },
262
+ {
263
+ select: <ListCheckboxProps>{
264
+ modelValue: false,
265
+ disabled: false,
266
+ onCheckboxClick: selectClick
267
+ },
268
+ name: 'Carol Brown',
269
+ email: 'carol@example.com',
270
+ joined: '2023-08-30',
271
+ active: <ListCheckboxProps>{
272
+ modelValue: false,
273
+ disabled: false
274
+ },
275
+ actions: <ListActionProps[]>[
276
+ {
277
+ id: 'edit',
278
+ label: 'Edit',
279
+ icon: 'edit',
280
+ onActionClick: rowActionClick
281
+ },
282
+ {
283
+ id: 'delete',
284
+ label: 'Delete',
285
+ icon: 'trash',
286
+ onActionClick: rowActionClick
287
+ }
288
+ ]
289
+ },
105
290
  {
106
- label: 'Add User',
107
- icon: 'plus',
108
- onClick: () => console.log('Add user')
291
+ select: <ListCheckboxProps>{
292
+ modelValue: false,
293
+ disabled: false,
294
+ onCheckboxClick: selectClick
295
+ },
296
+ name: 'David Miller',
297
+ email: 'david@example.com',
298
+ joined: '2024-02-01',
299
+ active: <ListCheckboxProps>{
300
+ modelValue: true,
301
+ disabled: false
302
+ },
303
+ actions: <ListActionProps[]>[
304
+ {
305
+ id: 'edit',
306
+ label: 'Edit',
307
+ icon: 'edit',
308
+ onActionClick: rowActionClick
309
+ },
310
+ {
311
+ id: 'delete',
312
+ label: 'Delete',
313
+ icon: 'trash',
314
+ onActionClick: rowActionClick
315
+ }
316
+ ]
317
+ },
318
+ {
319
+ select: <ListCheckboxProps>{
320
+ modelValue: false,
321
+ disabled: false,
322
+ onCheckboxClick: selectClick
323
+ },
324
+ name: 'Eva Garcia',
325
+ email: 'eva@example.com',
326
+ joined: '2023-05-15',
327
+ active: {
328
+ modelValue: true,
329
+ disabled: false
330
+ },
331
+ actions: <ListActionProps[]>[
332
+ {
333
+ id: 'view',
334
+ label: 'View',
335
+ icon: 'eye',
336
+ onActionClick: rowActionClick
337
+ }
338
+ ]
109
339
  },
110
340
  {
111
- label: 'Export',
112
- icon: 'download',
113
- onClick: () => console.log('Export')
341
+ select: <ListCheckboxProps>{
342
+ modelValue: false,
343
+ disabled: false,
344
+ onCheckboxClick: selectClick
345
+ },
346
+ name: 'Frank Lee',
347
+ email: 'frank@example.com',
348
+ joined: '2023-12-20',
349
+ active: {
350
+ modelValue: false,
351
+ disabled: true
352
+ },
353
+ actions: <ListActionProps[]>[
354
+ {
355
+ id: 'view',
356
+ label: 'View',
357
+ icon: 'eye',
358
+ onActionClick: rowActionClick
359
+ }
360
+ ]
114
361
  }
115
- ]
362
+ ])
116
363
 
117
- const handleFilter = (value: string) => {
118
- console.log('Filter:', value)
364
+ </script>
365
+
366
+ <style scoped>
367
+ .list-test {
368
+ padding: 2rem;
119
369
  }
120
370
 
121
- const handleSort = (column: ListColumn, direction: 'asc' | 'desc') => {
122
- console.log('Sort:', column.key, direction)
371
+ .list-test__header {
372
+ display: flex;
373
+ align-items: center;
374
+ gap: 2rem;
375
+ margin-bottom: 2rem;
123
376
  }
124
377
 
125
- const handleRowClick = (row: any, index: number) => {
126
- console.log('Row clicked:', row, index)
378
+ .list-test__back {
379
+ display: flex;
380
+ align-items: center;
381
+ gap: 0.5rem;
382
+ color: var(--text-secondary);
383
+ text-decoration: none;
384
+ font-weight: 500;
385
+ transition: color 0.2s;
127
386
  }
128
- </script>
129
387
 
130
- <style scoped>
131
- .list-test {
132
- padding: 2rem;
388
+ .list-test__back:hover {
389
+ color: var(--primary);
133
390
  }
134
391
 
135
392
  .list-test__section {