hamzus-ui 0.0.194 → 0.0.196
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/index.d.ts +1 -0
- package/index.js +1 -0
- package/package.json +1 -1
- package/src/components/hamzus-ui/Calendar/ActionsBar.svelte +202 -0
- package/src/components/hamzus-ui/Calendar/Content.svelte +175 -0
- package/src/components/hamzus-ui/Calendar/FilterDropdown.svelte +331 -0
- package/src/components/hamzus-ui/Calendar/Root.svelte +166 -0
- package/src/components/hamzus-ui/Calendar/TableLoader.svelte +15 -0
- package/src/components/hamzus-ui/Calendar/index.js +3 -0
- package/src/components/hamzus-ui/TableV2/ActionsBar.svelte +614 -0
- package/src/components/hamzus-ui/TableV2/Content.svelte +209 -0
- package/src/components/hamzus-ui/TableV2/FilterDropdown.svelte +333 -0
- package/src/components/hamzus-ui/TableV2/Header.svelte +421 -0
- package/src/components/hamzus-ui/TableV2/NavigationBar.svelte +10 -0
- package/src/components/hamzus-ui/TableV2/Root.svelte +202 -0
- package/src/components/hamzus-ui/TableV2/TableLoader.svelte +61 -0
- package/src/components/hamzus-ui/TableV2/index.js +5 -0
- package/src/components/hamzus-ui/TableV2/tableCtx.js +22 -0
- package/src/utils/const.js +8 -0
package/index.d.ts
CHANGED
|
@@ -43,6 +43,7 @@ export * as Tabs from "./src/components/hamzus-ui/Tabs"
|
|
|
43
43
|
export { default as Caroussel } from "./src/components/hamzus-ui/Caroussel/Caroussel.svelte"
|
|
44
44
|
export { default as Image } from "./src/components/hamzus-ui/Image/Image.svelte"
|
|
45
45
|
export * as Table from "./src/components/hamzus-ui/Table"
|
|
46
|
+
export * as TableV2 from "./src/components/hamzus-ui/TableV2"
|
|
46
47
|
export * as DataList from "./src/components/hamzus-ui/DataList"
|
|
47
48
|
export { default as Object } from "./src/components/hamzus-ui/Object/Object.svelte"
|
|
48
49
|
export * as ResponsiveTable from "./src/components/hamzus-ui/ResponsiveTable"
|
package/index.js
CHANGED
|
@@ -40,6 +40,7 @@ export * as Tabs from "./src/components/hamzus-ui/Tabs"
|
|
|
40
40
|
export { default as Caroussel } from "./src/components/hamzus-ui/Caroussel/Caroussel.svelte"
|
|
41
41
|
export { default as Image } from "./src/components/hamzus-ui/Image/Image.svelte"
|
|
42
42
|
export * as Table from "./src/components/hamzus-ui/Table"
|
|
43
|
+
export * as TableV2 from "./src/components/hamzus-ui/TableV2"
|
|
43
44
|
export * as DataList from "./src/components/hamzus-ui/DataList"
|
|
44
45
|
export { default as Object } from "./src/components/hamzus-ui/Object/Object.svelte"
|
|
45
46
|
export * as ResponsiveTable from "./src/components/hamzus-ui/ResponsiveTable"
|
package/package.json
CHANGED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
// import
|
|
3
|
+
import Input from '../Input/Input.svelte';
|
|
4
|
+
import Button from '../Button/Button.svelte';
|
|
5
|
+
import * as DropdownMenu from '../DropdownMenu';
|
|
6
|
+
import Checkbox from '../Checkboxes/Checkbox/Checkbox.svelte';
|
|
7
|
+
import IconButton from '../IconButton/IconButton.svelte';
|
|
8
|
+
import { onMount } from 'svelte';
|
|
9
|
+
import * as Tooltip from '../AdvancedTooltip';
|
|
10
|
+
// import FilterDropdown from './FilterDropdown.svelte';
|
|
11
|
+
// props
|
|
12
|
+
export let tableId = null;
|
|
13
|
+
|
|
14
|
+
// local var
|
|
15
|
+
// life cycle
|
|
16
|
+
// function
|
|
17
|
+
function handleRemoveFilter(columnName, position) {
|
|
18
|
+
let foundedColumn = false;
|
|
19
|
+
for (let i = 0; i < ctx.columns.length; i++) {
|
|
20
|
+
const element = ctx.columns[i];
|
|
21
|
+
if (element.name === columnName) {
|
|
22
|
+
if (position === 'after') {
|
|
23
|
+
ctx.columns[i].filterAfter = '';
|
|
24
|
+
// si son filtre befoire n est pas set obn surtpimme le filtrer general
|
|
25
|
+
if (!ctx.columns[i].filterBefore) {
|
|
26
|
+
ctx.columns[i].filter = '';
|
|
27
|
+
delete ctx.filters[columnName];
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
if (position === 'before') {
|
|
31
|
+
ctx.columns[i].filterBefore = '';
|
|
32
|
+
// si son filtre befoire n est pas set obn surtpimme le filtrer general
|
|
33
|
+
|
|
34
|
+
if (!ctx.columns[i].filterAfter) {
|
|
35
|
+
ctx.columns[i].filter = '';
|
|
36
|
+
delete ctx.filters[columnName];
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
if (!position) {
|
|
40
|
+
ctx.columns[i].filter = '';
|
|
41
|
+
delete ctx.filters[columnName];
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
foundedColumn = true;
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
ctx = { ...ctx };
|
|
50
|
+
|
|
51
|
+
if (foundedColumn) {
|
|
52
|
+
// emmetre un event
|
|
53
|
+
document.dispatchEvent(new Event('updateTableResult'));
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
async function handleClickAction(action) {
|
|
58
|
+
if (ctx.selection.length === 0) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const request = await action.function(ctx.selection);
|
|
63
|
+
|
|
64
|
+
if (request) {
|
|
65
|
+
const monEvenement = new CustomEvent('successOperation', {
|
|
66
|
+
detail: {
|
|
67
|
+
message: request.message ?? '',
|
|
68
|
+
type: request.statusCode === 200 ? 'success' : 'error'
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
document.dispatchEvent(monEvenement);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
tableData.update((actualValue) => {
|
|
75
|
+
ctx.selection = [];
|
|
76
|
+
|
|
77
|
+
return actualValue;
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
</script>
|
|
81
|
+
|
|
82
|
+
<div class="actions-bar">
|
|
83
|
+
<slot name="left" />
|
|
84
|
+
<!-- actions -->
|
|
85
|
+
<div class="actions">
|
|
86
|
+
<slot name="actions" />
|
|
87
|
+
</div>
|
|
88
|
+
</div>
|
|
89
|
+
<!-- liste des filtres -->
|
|
90
|
+
<div class="filters {Object.entries(ctx.filters).length > 0 ? 'active' : ''}">
|
|
91
|
+
<!-- <FilterDropdown {ctx}></FilterDropdown> -->
|
|
92
|
+
{#if ctx.filters}
|
|
93
|
+
{#each Object.entries(ctx.filters) as [key, filter]}
|
|
94
|
+
{@const column = ctx.columns.filter((obj) => obj.name === key)[0]}
|
|
95
|
+
|
|
96
|
+
{#if column.searchChoices}
|
|
97
|
+
<Button
|
|
98
|
+
onClick={() => {
|
|
99
|
+
handleRemoveFilter(column.name);
|
|
100
|
+
}}
|
|
101
|
+
style="border-radius:var(--radius-m);padding-left:3px;margin:7px 0 7px 0;"
|
|
102
|
+
variant="outline"
|
|
103
|
+
>
|
|
104
|
+
<h4 class="filter-column">{column.label}</h4>
|
|
105
|
+
<h4>: {column.searchChoices.filter((obj) => obj.value === filter)[0].label}</h4>
|
|
106
|
+
</Button>
|
|
107
|
+
{:else if column.datePicker}
|
|
108
|
+
{#if column.filterAfter}
|
|
109
|
+
<Button
|
|
110
|
+
onClick={() => {
|
|
111
|
+
handleRemoveFilter(column.name, 'after');
|
|
112
|
+
}}
|
|
113
|
+
style="border-radius:var(--radius-m);padding-left:3px;margin:7px 0 7px 0;"
|
|
114
|
+
variant="outline"
|
|
115
|
+
>
|
|
116
|
+
<h4 class="filter-column">{column.label} (à partir du)</h4>
|
|
117
|
+
<h4>: {column.filterAfter}</h4>
|
|
118
|
+
</Button>
|
|
119
|
+
{/if}
|
|
120
|
+
{#if column.filterBefore}
|
|
121
|
+
<Button
|
|
122
|
+
onClick={() => {
|
|
123
|
+
handleRemoveFilter(column.name, 'before');
|
|
124
|
+
}}
|
|
125
|
+
style="border-radius:var(--radius-m);padding-left:3px;margin:7px 0 7px 0;"
|
|
126
|
+
variant="outline"
|
|
127
|
+
>
|
|
128
|
+
<h4 class="filter-column">{column.label} (avant le)</h4>
|
|
129
|
+
<h4>: {column.filterBefore}</h4>
|
|
130
|
+
</Button>
|
|
131
|
+
{/if}
|
|
132
|
+
{:else}
|
|
133
|
+
<Button
|
|
134
|
+
onClick={() => {
|
|
135
|
+
handleRemoveFilter(column.name);
|
|
136
|
+
}}
|
|
137
|
+
style="border-radius:var(--radius-m);padding-left:3px;margin:7px 0 7px 0;"
|
|
138
|
+
variant="outline"
|
|
139
|
+
>
|
|
140
|
+
<h4 class="filter-column">{column.label}</h4>
|
|
141
|
+
<h4>: {filter}</h4>
|
|
142
|
+
</Button>
|
|
143
|
+
{/if}
|
|
144
|
+
{/each}
|
|
145
|
+
{/if}
|
|
146
|
+
</div>
|
|
147
|
+
|
|
148
|
+
<style>
|
|
149
|
+
.actions-bar {
|
|
150
|
+
display: flex;
|
|
151
|
+
align-items: center;
|
|
152
|
+
column-gap: 7px;
|
|
153
|
+
margin: 7px;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
.format {
|
|
157
|
+
display: flex;
|
|
158
|
+
align-items: center;
|
|
159
|
+
column-gap: var(--pad-xs);
|
|
160
|
+
padding: var(--pad-xs);
|
|
161
|
+
border-radius: var(--radius-l);
|
|
162
|
+
border: 1px solid var(--stroke);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
.filters {
|
|
166
|
+
padding: 0px 7px;
|
|
167
|
+
transition:
|
|
168
|
+
max-height 0.4s ease,
|
|
169
|
+
opacity 0.4s ease;
|
|
170
|
+
max-height: 0px;
|
|
171
|
+
display: flex;
|
|
172
|
+
align-items: center;
|
|
173
|
+
column-gap: 7px;
|
|
174
|
+
opacity: 0;
|
|
175
|
+
pointer-events: none;
|
|
176
|
+
overflow: hidden;
|
|
177
|
+
}
|
|
178
|
+
.filters.active {
|
|
179
|
+
max-height: 100px;
|
|
180
|
+
opacity: 1;
|
|
181
|
+
pointer-events: initial;
|
|
182
|
+
transition:
|
|
183
|
+
max-height 0.4s ease,
|
|
184
|
+
opacity 0.4s ease;
|
|
185
|
+
}
|
|
186
|
+
.filters.mobile {
|
|
187
|
+
border-bottom: 1px solid var(--stroke);
|
|
188
|
+
background-color: var(--bg-1);
|
|
189
|
+
}
|
|
190
|
+
.filter-column {
|
|
191
|
+
background-color: var(--bg-2);
|
|
192
|
+
padding: 0px 6px;
|
|
193
|
+
border-radius: var(--radius-s);
|
|
194
|
+
}
|
|
195
|
+
.pagination {
|
|
196
|
+
display: flex;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
.actions {
|
|
200
|
+
margin-left: auto;
|
|
201
|
+
}
|
|
202
|
+
</style>
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
// import
|
|
3
|
+
import Checkbox from '../Checkboxes/Checkbox/Checkbox.svelte';
|
|
4
|
+
import Button from '../Button/Button.svelte';
|
|
5
|
+
// props
|
|
6
|
+
export let ctx = null;
|
|
7
|
+
|
|
8
|
+
// local var
|
|
9
|
+
let extended = {};
|
|
10
|
+
$: numberOfColumn = ctx.columns.length ?? 0;
|
|
11
|
+
// lifeTime component
|
|
12
|
+
|
|
13
|
+
// function
|
|
14
|
+
function handleClick(rowData, avoidClick) {
|
|
15
|
+
if (avoidClick) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
// apeller la fonction onclick de la table et fournir la row
|
|
19
|
+
if (
|
|
20
|
+
ctx.onClick !== undefined &&
|
|
21
|
+
typeof ctx.onClick === 'function'
|
|
22
|
+
) {
|
|
23
|
+
ctx.onClick(rowData);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function handleSelect(row) {
|
|
27
|
+
// verifier si il est deja present
|
|
28
|
+
let isAlreadySelected = false;
|
|
29
|
+
|
|
30
|
+
for (const pushedRow of ctx.selection) {
|
|
31
|
+
if (pushedRow.id === row.id) {
|
|
32
|
+
isAlreadySelected = true;
|
|
33
|
+
break;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
tableData.update((actualValue) => {
|
|
38
|
+
if (isAlreadySelected) {
|
|
39
|
+
actualValue[tableId].selection = actualValue[tableId].selection.filter(
|
|
40
|
+
(item) => item.id !== row.id
|
|
41
|
+
);
|
|
42
|
+
return actualValue;
|
|
43
|
+
}
|
|
44
|
+
actualValue[tableId].selection.push(row);
|
|
45
|
+
return actualValue;
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function handleExtend(index) {
|
|
50
|
+
extended[index] = !(extended[index] ?? false);
|
|
51
|
+
}
|
|
52
|
+
</script>
|
|
53
|
+
|
|
54
|
+
<div class="content">
|
|
55
|
+
{#each ctx.rows as row, rowIndex}
|
|
56
|
+
<div class="row {ctx.actions.length > 0 ? 'selectable' : ''}">
|
|
57
|
+
{#if ctx.actions.length > 0}
|
|
58
|
+
<div
|
|
59
|
+
style="--cell-width:50px"
|
|
60
|
+
class="selector cell {ctx.selection.length > 0 ? 'active' : ''}"
|
|
61
|
+
>
|
|
62
|
+
<Checkbox
|
|
63
|
+
size={24}
|
|
64
|
+
checked={ctx.selection.filter((item) => item.id === row.id).length > 0}
|
|
65
|
+
onChange={() => {
|
|
66
|
+
handleSelect(row);
|
|
67
|
+
}}
|
|
68
|
+
></Checkbox>
|
|
69
|
+
</div>
|
|
70
|
+
{/if}
|
|
71
|
+
{#each Object.keys(row) as cellKey, cellIndex}
|
|
72
|
+
{@const column = ctx.columns.filter((obj) => obj.name === cellKey)[0]}
|
|
73
|
+
|
|
74
|
+
{#if !column.hidden}
|
|
75
|
+
<!-- systeme d'afficher plus pour telephone -->
|
|
76
|
+
<!-- {@const cellIsExtended = extended[rowIndex] ?? false} -->
|
|
77
|
+
{@const cellIsExtended = true}
|
|
78
|
+
|
|
79
|
+
<!-- si le format est mobile que on est a plus de trois cell afficher et que le content est pas extend on affiche pas le reste -->
|
|
80
|
+
{#if numberOfColumn <= 3 || cellIndex < 3 || cellIsExtended}
|
|
81
|
+
<button
|
|
82
|
+
on:click={() => {
|
|
83
|
+
handleClick(row, column.avoidClick ?? false);
|
|
84
|
+
}}
|
|
85
|
+
class="cell"
|
|
86
|
+
style="--cell-width:{column.width ?? column.initialWidth}px;{column.skipLine === true
|
|
87
|
+
? 'white-space:nowrap;'
|
|
88
|
+
: ''}"
|
|
89
|
+
>
|
|
90
|
+
<!-- il se peut que ce soit un composant -->
|
|
91
|
+
{#if row[cellKey] !== undefined}
|
|
92
|
+
{#if typeof row[cellKey] === 'object' && row[cellKey] !== null}
|
|
93
|
+
<svelte:component this={row[cellKey].component} {...row[cellKey].props}
|
|
94
|
+
></svelte:component>
|
|
95
|
+
{:else if row[cellKey] === null}
|
|
96
|
+
<h4>-</h4>
|
|
97
|
+
{:else}
|
|
98
|
+
<h4>{row[cellKey] ?? "-"}</h4>
|
|
99
|
+
{/if}
|
|
100
|
+
{/if}
|
|
101
|
+
</button>
|
|
102
|
+
{/if}
|
|
103
|
+
{/if}
|
|
104
|
+
{/each}
|
|
105
|
+
</div>
|
|
106
|
+
{/each}
|
|
107
|
+
</div>
|
|
108
|
+
|
|
109
|
+
<style>
|
|
110
|
+
.content {
|
|
111
|
+
display: flex;
|
|
112
|
+
flex-direction: column;
|
|
113
|
+
}
|
|
114
|
+
.row {
|
|
115
|
+
all: unset;
|
|
116
|
+
display: flex;
|
|
117
|
+
border-bottom: 1px solid var(--stroke);
|
|
118
|
+
flex-shrink: 0;
|
|
119
|
+
min-width: max-content;
|
|
120
|
+
width: 100%;
|
|
121
|
+
cursor: pointer;
|
|
122
|
+
position: relative;
|
|
123
|
+
}
|
|
124
|
+
.row:hover {
|
|
125
|
+
background-color: var(--bg-2);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
.selector {
|
|
129
|
+
display: flex;
|
|
130
|
+
align-items: center;
|
|
131
|
+
justify-content: center;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
.cell {
|
|
135
|
+
text-align: left;
|
|
136
|
+
width: var(--cell-width);
|
|
137
|
+
padding: var(--pad-m);
|
|
138
|
+
overflow: hidden;
|
|
139
|
+
text-overflow: ellipsis;
|
|
140
|
+
border-right: 1px solid var(--stroke);
|
|
141
|
+
flex-shrink: 0;
|
|
142
|
+
}
|
|
143
|
+
.cell:focus {
|
|
144
|
+
outline: 1px solid var(--accent) !important;
|
|
145
|
+
z-index: 1;
|
|
146
|
+
}
|
|
147
|
+
.cell > h4 {
|
|
148
|
+
overflow: hidden;
|
|
149
|
+
text-overflow: ellipsis;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/* mobile version */
|
|
153
|
+
.mobile{
|
|
154
|
+
width: 100%;
|
|
155
|
+
flex-shrink: 0;
|
|
156
|
+
}
|
|
157
|
+
.mobile .row {
|
|
158
|
+
width: 100%;
|
|
159
|
+
flex-direction: column;
|
|
160
|
+
min-width: unset;
|
|
161
|
+
flex-shrink: 0;
|
|
162
|
+
}
|
|
163
|
+
.mobile .cell {
|
|
164
|
+
width: 100%;
|
|
165
|
+
border-right: 0px;
|
|
166
|
+
display: flex;
|
|
167
|
+
align-items: center;
|
|
168
|
+
column-gap: var(--pad-m);
|
|
169
|
+
justify-content: space-between;
|
|
170
|
+
}
|
|
171
|
+
.mobile .cell:has(:nth-child(2)) > :last-child {
|
|
172
|
+
text-align: right;
|
|
173
|
+
flex-shrink: 0;
|
|
174
|
+
}
|
|
175
|
+
</style>
|