mountain-ui 1.0.152 → 1.0.154

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mountain-ui",
3
3
  "private": false,
4
- "version": "1.0.152",
4
+ "version": "1.0.154",
5
5
  "description": "A comprehensive UI component library for ERP systems with field types, entities, and registry management built with Svelte",
6
6
  "type": "module",
7
7
  "module": "index.js",
@@ -76,7 +76,7 @@
76
76
  "vitest-browser-svelte": "^2.1.1"
77
77
  },
78
78
  "dependencies": {
79
- "hamzus-ui": "^0.0.267"
79
+ "hamzus-ui": "^0.0.268"
80
80
  },
81
81
  "engines": {
82
82
  "node": ">=18.0.0"
@@ -21,11 +21,13 @@
21
21
 
22
22
  let table = $state([createLine()]);
23
23
 
24
+ let isHidden = $state(false);
25
+
24
26
  onMount(() => {
25
27
  if (value === null) return;
26
28
 
27
29
  const decodedValue = JSON.parse(value);
28
- console.log(decodedValue);
30
+ console.log(decodedValue);
29
31
 
30
32
  let newLines = [];
31
33
 
@@ -152,29 +154,52 @@ console.log(decodedValue);
152
154
  calc.calculate(table[lineIndex].ctx);
153
155
  }
154
156
  }
157
+
158
+ function handleToggleVisibility() {
159
+ isHidden = !isHidden;
160
+ }
155
161
  </script>
156
162
 
157
163
  <div class="table">
158
164
  <div class="title">
159
165
  <Label {label} {required} {secret} {unique}></Label>
166
+
167
+ <div class="right">
168
+ <Button onClick={handleAddLine}>
169
+ <h5>ajouter une rangée</h5>
170
+ </Button>
171
+ <IconButton size="24px" variant="ghost" onClick={handleToggleVisibility}>
172
+ <svg
173
+ width="24"
174
+ height="24"
175
+ viewBox="0 0 24 24"
176
+ fill="none"
177
+ xmlns="http://www.w3.org/2000/svg"
178
+ >
179
+ <path
180
+ d="M11.9995 16.8001C11.2995 16.8001 10.5995 16.5301 10.0695 16.0001L3.54953 9.48014C3.25953 9.19014 3.25953 8.71014 3.54953 8.42014C3.83953 8.13014 4.31953 8.13014 4.60953 8.42014L11.1295 14.9401C11.6095 15.4201 12.3895 15.4201 12.8695 14.9401L19.3895 8.42014C19.6795 8.13014 20.1595 8.13014 20.4495 8.42014C20.7395 8.71014 20.7395 9.19014 20.4495 9.48014L13.9295 16.0001C13.3995 16.5301 12.6995 16.8001 11.9995 16.8001Z"
181
+ fill="#292D32"
182
+ />
183
+ </svg>
184
+ </IconButton>
185
+ </div>
160
186
  </div>
161
- <ResponsiveTable.Root let:ctx>
162
- <ResponsiveTable.Header>
163
- {#if columns.length > 0}
187
+ <div class="table-container" style="--column-number:{columns.length};" class:hidden={isHidden}>
188
+ {#if columns.length > 0 && columns.find(c=>(c.name??false) !== false)}
189
+ <div class="header">
164
190
  {#each columns as column, columnIndex}
165
- <ResponsiveTable.HeaderCell align="left" label={column.name ?? '-'} {ctx}>
191
+ <div class="header-cell">
166
192
  <h6>{columns[columnIndex].name ?? ''}</h6>
167
- <!-- {column.columnIndex} -->
168
- </ResponsiveTable.HeaderCell>
193
+ </div>
169
194
  {/each}
170
- {/if}
171
- </ResponsiveTable.Header>
172
- <ResponsiveTable.Body>
195
+ </div>
196
+ {/if}
197
+ <div class="body">
173
198
  {#if $entity}
174
199
  {#each table as line, lineIndex (line.id)}
175
- <ResponsiveTable.Line>
200
+ <div class="line">
176
201
  {#each columns as column, columnIndex}
177
- <ResponsiveTable.Cell {ctx}>
202
+ <div class="cell">
178
203
  {#each column.rows as row, rowIndex}
179
204
  <FieldInput
180
205
  compact
@@ -199,7 +224,7 @@ console.log(decodedValue);
199
224
  {#if columnIndex + 1 === columns.length}
200
225
  <div class="delete">
201
226
  <IconButton
202
- avoidRipple
227
+ avoidRipple
203
228
  variant="destructive"
204
229
  onClick={() => {
205
230
  handleDeleteLine(lineIndex);
@@ -236,33 +261,131 @@ console.log(decodedValue);
236
261
  </IconButton>
237
262
  </div>
238
263
  {/if}
239
- </ResponsiveTable.Cell>
264
+ </div>
240
265
  {/each}
241
- </ResponsiveTable.Line>
266
+ </div>
242
267
  {/each}
243
268
  {/if}
244
- </ResponsiveTable.Body>
245
- </ResponsiveTable.Root>
246
- <div class="title">
247
- <Button onClick={handleAddLine}>
248
- <h5>ajouter une rangée</h5>
249
- </Button>
250
- <Label label="/{label}" {required} {secret} {unique}></Label>
269
+ </div>
270
+ <!-- <ResponsiveTable.Root let:ctx>
271
+ {#if columns.length > 0}
272
+ <ResponsiveTable.Header>
273
+ {#each columns as column, columnIndex}
274
+ <ResponsiveTable.HeaderCell align="left" label={column.name ?? '-'} {ctx}>
275
+ <h6>{columns[columnIndex].name ?? ''}</h6>
276
+
277
+ </ResponsiveTable.HeaderCell>
278
+ {/each}
279
+ </ResponsiveTable.Header>
280
+ {/if}
281
+ <ResponsiveTable.Body>
282
+ {#if $entity}
283
+ {#each table as line, lineIndex (line.id)}
284
+ <ResponsiveTable.Line>
285
+ {#each columns as column, columnIndex}
286
+ <ResponsiveTable.Cell {ctx}>
287
+ {#each column.rows as row, rowIndex}
288
+ <FieldInput
289
+ compact
290
+ detailsCtx={table[lineIndex].detailsCtx}
291
+ ctx={table[lineIndex].ctx}
292
+ onChangeDetails={(value) => {
293
+ handleChangeDetails(lineIndex, row.fieldId, value);
294
+ }}
295
+ onChange={(value) => {
296
+ handleChange(lineIndex, row.fieldId, value);
297
+ }}
298
+ changeCtx={(fieldId, value) => {
299
+ handleChange(lineIndex, fieldId, value);
300
+ }}
301
+ id={row.fieldId}
302
+ value={table[lineIndex].ctx?.[row.fieldId] ?? null}
303
+ registerCalculation={(config) => {
304
+ handleRegisterCalculation(lineIndex, config);
305
+ }}
306
+ ></FieldInput>
307
+ {/each}
308
+ {#if columnIndex + 1 === columns.length}
309
+ <div class="delete">
310
+ <IconButton
311
+ avoidRipple
312
+ variant="destructive"
313
+ onClick={() => {
314
+ handleDeleteLine(lineIndex);
315
+ }}
316
+ >
317
+ <svg
318
+ width="24"
319
+ height="24"
320
+ viewBox="0 0 24 24"
321
+ fill="none"
322
+ xmlns="http://www.w3.org/2000/svg"
323
+ >
324
+ <path
325
+ d="M20.9997 6.72998C20.9797 6.72998 20.9497 6.72998 20.9197 6.72998C15.6297 6.19998 10.3497 5.99998 5.11967 6.52998L3.07967 6.72998C2.65967 6.76998 2.28967 6.46998 2.24967 6.04998C2.20967 5.62998 2.50967 5.26998 2.91967 5.22998L4.95967 5.02998C10.2797 4.48998 15.6697 4.69998 21.0697 5.22998C21.4797 5.26998 21.7797 5.63998 21.7397 6.04998C21.7097 6.43998 21.3797 6.72998 20.9997 6.72998Z"
326
+ fill="#292D32"
327
+ />
328
+ <path
329
+ d="M8.50074 5.72C8.46074 5.72 8.42074 5.72 8.37074 5.71C7.97074 5.64 7.69074 5.25 7.76074 4.85L7.98074 3.54C8.14074 2.58 8.36074 1.25 10.6907 1.25H13.3107C15.6507 1.25 15.8707 2.63 16.0207 3.55L16.2407 4.85C16.3107 5.26 16.0307 5.65 15.6307 5.71C15.2207 5.78 14.8307 5.5 14.7707 5.1L14.5507 3.8C14.4107 2.93 14.3807 2.76 13.3207 2.76H10.7007C9.64074 2.76 9.62074 2.9 9.47074 3.79L9.24074 5.09C9.18074 5.46 8.86074 5.72 8.50074 5.72Z"
330
+ fill="#292D32"
331
+ />
332
+ <path
333
+ d="M15.2104 22.7501H8.79039C5.30039 22.7501 5.16039 20.8201 5.05039 19.2601L4.40039 9.19007C4.37039 8.78007 4.69039 8.42008 5.10039 8.39008C5.52039 8.37008 5.87039 8.68008 5.90039 9.09008L6.55039 19.1601C6.66039 20.6801 6.70039 21.2501 8.79039 21.2501H15.2104C17.3104 21.2501 17.3504 20.6801 17.4504 19.1601L18.1004 9.09008C18.1304 8.68008 18.4904 8.37008 18.9004 8.39008C19.3104 8.42008 19.6304 8.77007 19.6004 9.19007L18.9504 19.2601C18.8404 20.8201 18.7004 22.7501 15.2104 22.7501Z"
334
+ fill="#292D32"
335
+ />
336
+ <path
337
+ d="M13.6601 17.25H10.3301C9.92008 17.25 9.58008 16.91 9.58008 16.5C9.58008 16.09 9.92008 15.75 10.3301 15.75H13.6601C14.0701 15.75 14.4101 16.09 14.4101 16.5C14.4101 16.91 14.0701 17.25 13.6601 17.25Z"
338
+ fill="#292D32"
339
+ />
340
+ <path
341
+ d="M14.5 13.25H9.5C9.09 13.25 8.75 12.91 8.75 12.5C8.75 12.09 9.09 11.75 9.5 11.75H14.5C14.91 11.75 15.25 12.09 15.25 12.5C15.25 12.91 14.91 13.25 14.5 13.25Z"
342
+ fill="#292D32"
343
+ />
344
+ </svg>
345
+ </IconButton>
346
+ </div>
347
+ {/if}
348
+ </ResponsiveTable.Cell>
349
+ {/each}
350
+ </ResponsiveTable.Line>
351
+ {/each}
352
+ {/if}
353
+ </ResponsiveTable.Body>
354
+ </ResponsiveTable.Root> -->
251
355
  </div>
252
356
  </div>
253
357
 
254
358
  <style>
359
+ .table {
360
+ width: 100%;
361
+ height: fit-content;
362
+ border-radius: 0 var(--radius-m) var(--radius-m) 0;
363
+ overflow: clip;
364
+ border: 1px solid var(--stroke);
365
+ border-left: 3px solid var(--accent);
366
+ }
367
+
255
368
  .title {
256
369
  display: flex;
257
370
  align-items: center;
258
- justify-content: space-between;
259
- padding: var(--pad-m);
371
+ justify-content: space-between;
372
+ padding: var(--pad-m);
260
373
  width: 100%;
261
374
  }
262
- .title:last-child {
263
- border-top: 1px solid var(--bg-blur);
264
- }
265
- :global(.table-container .line:has( > .cell > .delete .button:hover)) {
375
+ .title {
376
+ border-bottom: 1px solid var(--bg-blur);
377
+ position: sticky;
378
+ top: 45px;
379
+ background-color: var(--bg-1);
380
+ }
381
+
382
+ .right {
383
+ display: flex;
384
+ align-items: center;
385
+ column-gap: var(--pad-m);
386
+ }
387
+
388
+ :global(.table-container .line:has(> .cell > .delete .button:hover)) {
266
389
  background-color: var(--red-b);
267
390
  }
268
391
 
@@ -276,12 +399,32 @@ console.log(decodedValue);
276
399
  padding: var(--pad-s);
277
400
  }
278
401
 
279
- .table {
280
- width: 100%;
281
- height: fit-content;
282
- border-radius: var(--radius-m);
283
- overflow: clip;
284
- border: 1px solid var(--stroke);
285
- padding: var(--pad-s);
402
+ .table-container.hidden {
403
+ display: none;
404
+ overflow: hidden;
405
+ }
406
+
407
+ .header {
408
+ display: grid;
409
+ grid-template-columns: repeat(var(--column-number), 1fr);
410
+ background-color: var(--bg-blur);
411
+ padding: var(--pad-m);
412
+ }
413
+
414
+ .body {
415
+ display: flex;
416
+ flex-direction: column;
417
+ padding: var(--pad-xs);
286
418
  }
419
+
420
+ .line {
421
+ display: grid;
422
+ grid-template-columns: repeat(var(--column-number), 1fr);
423
+ border-bottom: 1px solid var(--stroke);
424
+ padding-top: var(--pad-xs);
425
+ }
426
+ .line:last-child {
427
+ border-bottom: initial;
428
+ }
429
+
287
430
  </style>