do-ui-design-system 1.1.13 → 1.1.14

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,9 +1,28 @@
1
1
  .do-pagination {
2
2
  display: flex;
3
+ gap: 0.5rem;
3
4
 
4
5
  .do-pagination__nav {
5
6
  display: flex;
6
- align-items: center;
7
+ align-items: stretch;
7
8
  gap: 0.2rem;
9
+
10
+ .do-pagination__nav__back {
11
+ transform: rotate(90deg);
12
+ }
13
+
14
+ .do-pagination__nav__next {
15
+ transform: rotate(-90deg);
16
+ }
17
+ }
18
+
19
+ .do-pagination__size {
20
+ display: flex;
21
+ gap: 0.5rem;
22
+ align-items: center;
23
+
24
+ select {
25
+ height: 100%;
26
+ }
8
27
  }
9
28
  }
@@ -1,15 +1,22 @@
1
1
  .do-table {
2
2
  .do-table__header {
3
+ display: flex;
4
+ align-items: center;
5
+ justify-content: space-between;
6
+ margin-bottom: 1rem;
7
+
3
8
  .do-table__header__tags {
4
9
  display: flex;
5
10
  align-items: center;
6
11
  gap: 0.5rem;
7
- margin-bottom: 1rem;
8
12
  }
9
13
  }
10
14
 
11
15
  .do-table__content {
12
-
16
+ border-radius: 12px;
17
+ overflow: hidden;
18
+ background: var(--do-table-bg);
19
+ font-size: 1rem;
13
20
  width: 100%;
14
21
  border-collapse: collapse;
15
22
 
@@ -84,6 +91,16 @@
84
91
  }
85
92
  }
86
93
 
94
+ .do-table__content__th-filter {
95
+ padding: 0.2rem 0.5rem;
96
+ max-width: 90%;
97
+ }
98
+
99
+ .do-table__content__th-action {
100
+ padding: 0.2rem 0.5rem;
101
+ max-width: 1rem;
102
+ }
103
+
87
104
  td {
88
105
  padding: 0.75rem 1rem;
89
106
  color: inherit;
@@ -126,13 +143,4 @@
126
143
  font-weight: 500;
127
144
  }
128
145
  }
129
- }
130
-
131
- .do-table-card {
132
- border: 1px solid var(--do-bg-secondary);
133
- border-radius: 12px;
134
- overflow: hidden;
135
- background: var(--do-table-bg);
136
- font-size: 1rem;
137
- padding: 0.75rem 1rem;
138
146
  }
@@ -16,7 +16,11 @@
16
16
 
17
17
  let { pagination, goToPage, pageSizeChange }: Props = $props();
18
18
 
19
- const getPaginationPages = (current: number, total: number, maxPages: number = 5) => {
19
+ const getPaginationPages = (
20
+ current: number,
21
+ total: number,
22
+ maxPages: number = pagination.pageSize
23
+ ) => {
20
24
  if (total <= maxPages) {
21
25
  return Array.from({ length: total }, (_, i) => i + 1);
22
26
  }
@@ -52,9 +56,12 @@
52
56
  </script>
53
57
 
54
58
  <div class="do-pagination">
55
- <label>
59
+ <label class="do-pagination__size">
56
60
  Mostrar:
57
- <select bind:value={pagination.pageSize} onchange={() => pageSizeChange(pagination.pageSize)}>
61
+ <select
62
+ bind:value={pagination.pageSize}
63
+ onchange={() => pageSizeChange(pagination.pageSize || 5)}
64
+ >
58
65
  <option value={5}>5</option>
59
66
  <option value={10}>10</option>
60
67
  <option value={25}>25</option>
@@ -66,7 +73,7 @@
66
73
  <div class="do-pagination__nav">
67
74
  <IconButton
68
75
  iconName="icon-chevron-down"
69
- iCustomClass="rotate-90"
76
+ iCustomClass="do-pagination__nav__back"
70
77
  disabled={pagination.currentPage === 1}
71
78
  onClick={() => goToPage(pagination.currentPage - 1)}
72
79
  ariaLabel="página anterior"
@@ -91,7 +98,7 @@
91
98
 
92
99
  <IconButton
93
100
  iconName="icon-chevron-down"
94
- iCustomClass="-rotate-90"
101
+ iCustomClass="do-pagination__nav__next"
95
102
  disabled={pagination.currentPage === pagination.totalPages}
96
103
  onClick={() => goToPage(pagination.currentPage + 1)}
97
104
  ariaLabel="página siguiente"
@@ -1 +1 @@
1
- {"version":3,"file":"Pagination.svelte.d.ts","sourceRoot":"","sources":["../../../src/lib/molecules/Pagination/Pagination.svelte.ts"],"names":[],"mappings":"AAMC,KAAK,eAAe,GAAG;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF,KAAK,KAAK,GAAG;IACZ,UAAU,EAAE,eAAe,CAAC;IAC5B,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACjC,cAAc,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CACvC,CAAC;AA6EH,QAAA,MAAM,UAAU,2CAAwC,CAAC;AACzD,KAAK,UAAU,GAAG,UAAU,CAAC,OAAO,UAAU,CAAC,CAAC;AAChD,eAAe,UAAU,CAAC"}
1
+ {"version":3,"file":"Pagination.svelte.d.ts","sourceRoot":"","sources":["../../../src/lib/molecules/Pagination/Pagination.svelte.ts"],"names":[],"mappings":"AAMC,KAAK,eAAe,GAAG;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF,KAAK,KAAK,GAAG;IACZ,UAAU,EAAE,eAAe,CAAC;IAC5B,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACjC,cAAc,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CACvC,CAAC;AAiFH,QAAA,MAAM,UAAU,2CAAwC,CAAC;AACzD,KAAK,UAAU,GAAG,UAAU,CAAC,OAAO,UAAU,CAAC,CAAC;AAChD,eAAe,UAAU,CAAC"}
@@ -1,9 +1,30 @@
1
1
  <script lang="ts">
2
2
  import { Button, Chip, Icon } from '../../atoms/index.js';
3
+ import type { IconNames } from '../../do-theme/index.ts';
4
+ import IconButton from '../../molecules/IconButton/IconButton.svelte';
3
5
  import Pagination from '../../molecules/Pagination/Pagination.svelte';
4
6
 
5
7
  type SortDirection = 'asc' | 'desc' | null;
6
8
 
9
+ type TagConfig<T> = {
10
+ column: keyof T;
11
+ label: string;
12
+ };
13
+
14
+ export type HeaderAction = {
15
+ icon: IconNames;
16
+ label: string;
17
+ onClick: () => void;
18
+ };
19
+
20
+ export type ActionColumnDef<T> = {
21
+ key: string;
22
+ icon: IconNames;
23
+ label?: string;
24
+ showHeader?: boolean;
25
+ onClick: (row: T) => void;
26
+ };
27
+
7
28
  export type ColumnDef<T> = {
8
29
  key: keyof T;
9
30
  label: string;
@@ -12,8 +33,11 @@
12
33
  type Props<T extends { id: string | number }> = {
13
34
  data: T[];
14
35
  columns: ColumnDef<T>[];
15
- tagColumn?: keyof T;
36
+ actionColumns?: ActionColumnDef<T>[];
37
+ tagConfig?: TagConfig<T>;
16
38
  idKey?: keyof T;
39
+ headerActions?: HeaderAction[];
40
+ pageSize?: number;
17
41
  showCheckbox?: boolean;
18
42
  onSelectionChange?: (ids: (string | number)[]) => void;
19
43
  };
@@ -21,8 +45,11 @@
21
45
  let {
22
46
  data = [],
23
47
  columns = [],
24
- tagColumn,
48
+ actionColumns = [],
49
+ tagConfig,
25
50
  idKey = 'id',
51
+ headerActions = [],
52
+ pageSize = 5,
26
53
  showCheckbox = true,
27
54
  onSelectionChange
28
55
  }: Props<any> = $props();
@@ -33,8 +60,8 @@
33
60
  let columnFilters: Record<string, string> = $state({});
34
61
 
35
62
  const tagOptions = $derived(() => {
36
- if (!tagColumn) return [];
37
- return [...new Set(data.map((row) => String(row[tagColumn])))];
63
+ if (!tagConfig?.column) return [];
64
+ return [...new Set(data.map((row) => String(row[tagConfig?.column])))];
38
65
  });
39
66
 
40
67
  let activeTags: Set<string> = $state(new Set());
@@ -47,7 +74,7 @@
47
74
 
48
75
  const filtered = $derived(() => {
49
76
  return data.filter((row) => {
50
- const passesTag = activeTags.size === 0 || activeTags.has(String(row[tagColumn!]));
77
+ const passesTag = activeTags.size === 0 || activeTags.has(String(row[tagConfig?.column!]));
51
78
 
52
79
  const passesColumns = columns.every((col) => {
53
80
  const filterVal = columnFilters[String(col.key)];
@@ -124,7 +151,7 @@
124
151
 
125
152
  let pagination = $state({
126
153
  totalPages: 10,
127
- pageSize: 5,
154
+ pageSize: 25,
128
155
  currentPage: 1,
129
156
  loading: false
130
157
  });
@@ -137,6 +164,12 @@
137
164
  pagination.pageSize = size;
138
165
  pagination.currentPage = 1;
139
166
  };
167
+
168
+ const clearTags = () => {
169
+ activeTags = new Set();
170
+ };
171
+
172
+ let columnName = columns.find((c) => c.key === tagConfig?.column)?.label;
140
173
  </script>
141
174
 
142
175
  <!-- @component
@@ -156,13 +189,23 @@
156
189
  - `onSelectionChange`: () => void
157
190
  -->
158
191
 
159
- <div class="do-table do-table-card">
160
- {#if tagColumn}
161
- <section class="do-table__header">
192
+ <div class="do-table">
193
+ <section class="do-table__header">
194
+ {#if tagConfig?.column}
162
195
  <div class="do-table__header__tags">
163
- <h5>
164
- {columns.find((t) => tagColumn === t.key)?.label}:
165
- </h5>
196
+ {#if tagConfig.label}
197
+ <Button
198
+ label={tagConfig?.label}
199
+ ariaLabel="Ver todos"
200
+ rounded
201
+ variant={activeTags.size === 0 ? 'do-btn-accent' : 'do-btn-primary'}
202
+ onClick={clearTags}
203
+ />
204
+ {:else}
205
+ <p>
206
+ {columnName}:
207
+ </p>
208
+ {/if}
166
209
  {#each tagOptions() as value}
167
210
  <Button
168
211
  label={value}
@@ -173,8 +216,23 @@
173
216
  />
174
217
  {/each}
175
218
  </div>
176
- </section>
177
- {/if}
219
+ {/if}
220
+
221
+ {#if headerActions.length}
222
+ <div class="do-table__actions">
223
+ {#each headerActions as action}
224
+ <IconButton
225
+ iconName={action.icon}
226
+ ariaLabel={action.label}
227
+ label={action.label}
228
+ variant="do-btn-accent"
229
+ title="descargar"
230
+ onClick={action.onClick}
231
+ />
232
+ {/each}
233
+ </div>
234
+ {/if}
235
+ </section>
178
236
 
179
237
  <section class="do-table-wrapper">
180
238
  <table class="do-table__content">
@@ -211,12 +269,17 @@
211
269
  {/if}
212
270
  </th>
213
271
  {/each}
272
+ {#each actionColumns as col}
273
+ <th class="do-table__content__th">
274
+ {col.showHeader !== false ? (col.label ?? '') : ''}
275
+ </th>
276
+ {/each}
214
277
  </tr>
215
278
 
216
279
  <!--filtros x columna -->
217
280
  <tr class="do-table__content__filters">
218
281
  {#if showCheckbox}
219
- <th class="col-check"></th>
282
+ <th class=""></th>
220
283
  {/if}
221
284
  {#each columns as col}
222
285
  <th class="do-table__content__th-filter">
@@ -243,7 +306,7 @@
243
306
  {@const isSelected = selected.has(row[idKey])}
244
307
  <tr class="do-row" class:selected={isSelected}>
245
308
  {#if showCheckbox}
246
- <td class="col-check">
309
+ <td class="">
247
310
  <input
248
311
  type="checkbox"
249
312
  class="do-checkbox"
@@ -255,6 +318,18 @@
255
318
  {#each columns as col}
256
319
  <td>{row[col.key]}</td>
257
320
  {/each}
321
+
322
+ {#each actionColumns as col}
323
+ <td class="do-table__content__th-action">
324
+ <IconButton
325
+ iconName={col.icon}
326
+ ariaLabel="ver capa"
327
+ title={col.label}
328
+ square
329
+ onClick={() => col.onClick(row)}
330
+ />
331
+ </td>
332
+ {/each}
258
333
  </tr>
259
334
  {/each}
260
335
  </tbody>
@@ -1,3 +1,20 @@
1
+ import type { IconNames } from '../../do-theme/index.ts';
2
+ type TagConfig<T> = {
3
+ column: keyof T;
4
+ label: string;
5
+ };
6
+ export type HeaderAction = {
7
+ icon: IconNames;
8
+ label: string;
9
+ onClick: () => void;
10
+ };
11
+ export type ActionColumnDef<T> = {
12
+ key: string;
13
+ icon: IconNames;
14
+ label?: string;
15
+ showHeader?: boolean;
16
+ onClick: (row: T) => void;
17
+ };
1
18
  export type ColumnDef<T> = {
2
19
  key: keyof T;
3
20
  label: string;
@@ -7,8 +24,11 @@ type Props<T extends {
7
24
  }> = {
8
25
  data: T[];
9
26
  columns: ColumnDef<T>[];
10
- tagColumn?: keyof T;
27
+ actionColumns?: ActionColumnDef<T>[];
28
+ tagConfig?: TagConfig<T>;
11
29
  idKey?: keyof T;
30
+ headerActions?: HeaderAction[];
31
+ pageSize?: number;
12
32
  showCheckbox?: boolean;
13
33
  onSelectionChange?: (ids: (string | number)[]) => void;
14
34
  };
@@ -1 +1 @@
1
- {"version":3,"file":"TableBasic.svelte.d.ts","sourceRoot":"","sources":["../../../src/lib/organisms/TableBasic/TableBasic.svelte.ts"],"names":[],"mappings":"AASC,MAAM,MAAM,SAAS,CAAC,CAAC,IAAI;IAC1B,GAAG,EAAE,MAAM,CAAC,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,KAAK,KAAK,CAAC,CAAC,SAAS;IAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,IAAI;IAC/C,IAAI,EAAE,CAAC,EAAE,CAAC;IACV,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC,CAAC;IAChB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,iBAAiB,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,KAAK,IAAI,CAAC;CACvD,CAAC;AAyOH;;;;;;;;;;;;;;;GAeG;AACH,QAAA,MAAM,UAAU,gDAAwC,CAAC;AACzD,KAAK,UAAU,GAAG,UAAU,CAAC,OAAO,UAAU,CAAC,CAAC;AAChD,eAAe,UAAU,CAAC"}
1
+ {"version":3,"file":"TableBasic.svelte.d.ts","sourceRoot":"","sources":["../../../src/lib/organisms/TableBasic/TableBasic.svelte.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAOvD,KAAK,SAAS,CAAC,CAAC,IAAI;IACnB,MAAM,EAAE,MAAM,CAAC,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IAC1B,IAAI,EAAE,SAAS,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,IAAI,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,eAAe,CAAC,CAAC,IAAI;IAChC,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,SAAS,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,OAAO,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,IAAI,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,SAAS,CAAC,CAAC,IAAI;IAC1B,GAAG,EAAE,MAAM,CAAC,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,KAAK,KAAK,CAAC,CAAC,SAAS;IAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,IAAI;IAC/C,IAAI,EAAE,CAAC,EAAE,CAAC;IACV,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC;IACxB,aAAa,CAAC,EAAE,eAAe,CAAC,CAAC,CAAC,EAAE,CAAC;IACrC,SAAS,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC,CAAC;IAChB,aAAa,CAAC,EAAE,YAAY,EAAE,CAAC;IAC/B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,iBAAiB,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,KAAK,IAAI,CAAC;CACvD,CAAC;AA8QH;;;;;;;;;;;;;;;GAeG;AACH,QAAA,MAAM,UAAU,gDAAwC,CAAC;AACzD,KAAK,UAAU,GAAG,UAAU,CAAC,OAAO,UAAU,CAAC,CAAC;AAChD,eAAe,UAAU,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "do-ui-design-system",
3
- "version": "1.1.13",
3
+ "version": "1.1.14",
4
4
  "description": "Design system en Svelte + CSS + Storybook",
5
5
  "author": "Data Observatory",
6
6
  "license": "MIT",