@makolabs/ripple 0.0.1-dev.63 → 0.0.1-dev.65

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.
@@ -2,6 +2,7 @@
2
2
  import { onMount } from 'svelte';
3
3
  import { Button, Table, Color, Size } from '../index.js';
4
4
  import type { TableColumn } from '../index.js';
5
+ import { formatDate } from '../utils/dateUtils.js';
5
6
  import type {
6
7
  StorageAdapter,
7
8
  FileItem,
@@ -57,31 +58,6 @@
57
58
  return `${parseFloat((bytes / Math.pow(k, i)).toFixed(2))} ${sizes[i]}`;
58
59
  }
59
60
 
60
- // Format a date to a specific format
61
- function formatDate(date: Date | string | number, formatStr = 'DD.MM.YYYY HH:mm'): string {
62
- const d = new Date(date);
63
-
64
- if (isNaN(d.getTime())) {
65
- return 'Invalid Date';
66
- }
67
-
68
- // Simple format implementation for common patterns
69
- const day = d.getDate().toString().padStart(2, '0');
70
- const month = (d.getMonth() + 1).toString().padStart(2, '0');
71
- const year = d.getFullYear();
72
- const hours = d.getHours().toString().padStart(2, '0');
73
- const minutes = d.getMinutes().toString().padStart(2, '0');
74
- const seconds = d.getSeconds().toString().padStart(2, '0');
75
-
76
- return formatStr
77
- .replace('DD', day)
78
- .replace('MM', month)
79
- .replace('YYYY', year.toString())
80
- .replace('HH', hours)
81
- .replace('mm', minutes)
82
- .replace('ss', seconds);
83
- }
84
-
85
61
  // Function that determines if a batch action should be shown
86
62
  function isBatchActionAllowed(action: FileAction): action is FileActionBatch {
87
63
  if (isFetchingRecursively) return false;
@@ -298,7 +274,7 @@
298
274
  if (sortState.column === 'default' && sortState.direction === 'default') {
299
275
  // Sort folders alphabetically (A-Z)
300
276
  const sortedFolders = [...folders].sort((a, b) => a.name.localeCompare(b.name));
301
-
277
+
302
278
  // Sort files by date (newest first)
303
279
  const sortedFiles = [...files].sort((a, b) => {
304
280
  // Use createdAt if available, otherwise fallback to lastModified
@@ -306,7 +282,7 @@
306
282
  const bTime = b.createdAt ? b.createdAt.getTime() : b.lastModified.getTime();
307
283
  return bTime - aTime; // Descending order (newest first)
308
284
  });
309
-
285
+
310
286
  // Return folders first, then files
311
287
  return [...sortedFolders, ...sortedFiles];
312
288
  }
@@ -634,13 +610,30 @@
634
610
  {#snippet NameCell(file: FileItem)}
635
611
  <div class="flex items-center gap-2">
636
612
  {#if file.isFolder}
637
- <svg class="text-amber-500" width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
638
- <path d="M10 4H4C2.89543 4 2 4.89543 2 6V18C2 19.1046 2.89543 20 4 20H20C21.1046 20 22 19.1046 22 18V8C22 6.89543 21.1046 6 20 6H12L10 4Z" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
613
+ <svg
614
+ xmlns="http://www.w3.org/2000/svg"
615
+ width="16"
616
+ height="16"
617
+ viewBox="0 0 24 24"
618
+ class="text-amber-500"
619
+ >
620
+ <path
621
+ fill="currentColor"
622
+ d="M3.5 6.25V8h4.629a.75.75 0 0 0 .53-.22l1.53-1.53l-1.53-1.53a.75.75 0 0 0-.53-.22H5.25A1.75 1.75 0 0 0 3.5 6.25m-1.5 0A3.25 3.25 0 0 1 5.25 3h2.879a2.25 2.25 0 0 1 1.59.659L11.562 5.5h7.189A3.25 3.25 0 0 1 22 8.75v9A3.25 3.25 0 0 1 18.75 21H5.25A3.25 3.25 0 0 1 2 17.75zM3.5 9.5v8.25c0 .966.784 1.75 1.75 1.75h13.5a1.75 1.75 0 0 0 1.75-1.75v-9A1.75 1.75 0 0 0 18.75 7h-7.19L9.72 8.841a2.25 2.25 0 0 1-1.591.659z"
623
+ />
639
624
  </svg>
640
625
  {:else}
641
- <svg class="text-blue-500" width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
642
- <path d="M14 2H6C4.89543 2 4 2.89543 4 4V20C4 21.1046 4.89543 22 6 22H18C19.1046 22 20 21.1046 20 20V8L14 2Z" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
643
- <path d="M14 2V8H20" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
626
+ <svg
627
+ xmlns="http://www.w3.org/2000/svg"
628
+ width="16"
629
+ height="16"
630
+ viewBox="0 0 24 24"
631
+ class="text-blue-500"
632
+ >
633
+ <path
634
+ fill="currentColor"
635
+ d="M6 2a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9.828a2 2 0 0 0-.586-1.414l-5.828-5.828A2 2 0 0 0 12.172 2zm-.5 2a.5.5 0 0 1 .5-.5h6V8a2 2 0 0 0 2 2h4.5v10a.5.5 0 0 1-.5.5H6a.5.5 0 0 1-.5-.5zm11.88 4.5H14a.5.5 0 0 1-.5-.5V4.62z"
636
+ />
644
637
  </svg>
645
638
  {/if}
646
639
  <span class="font-medium">{file.name}</span>
@@ -827,4 +820,4 @@
827
820
  navToFileFolder
828
821
  })}
829
822
  {/if}
830
- </div>
823
+ </div>
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Format a date to a specific format
3
+ * @param date - Date to format
4
+ * @param format - Format string (default: 'YYYY-MM-DD')
5
+ * @returns Formatted date string
6
+ */
7
+ export declare function formatDate(date: Date | string | number, formatStr?: string): string;
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Format a date to a specific format
3
+ * @param date - Date to format
4
+ * @param format - Format string (default: 'YYYY-MM-DD')
5
+ * @returns Formatted date string
6
+ */
7
+ export function formatDate(date, formatStr = 'DD.MM.YYYY HH:mm') {
8
+ const d = new Date(date);
9
+ if (isNaN(d.getTime())) {
10
+ return 'Invalid Date';
11
+ }
12
+ // Simple format implementation for common patterns
13
+ const day = d.getDate().toString().padStart(2, '0');
14
+ const month = (d.getMonth() + 1).toString().padStart(2, '0');
15
+ const year = d.getFullYear();
16
+ const hours = d.getHours().toString().padStart(2, '0');
17
+ const minutes = d.getMinutes().toString().padStart(2, '0');
18
+ const seconds = d.getSeconds().toString().padStart(2, '0');
19
+ return formatStr
20
+ .replace('DD', day)
21
+ .replace('MM', month)
22
+ .replace('YYYY', year.toString())
23
+ .replace('HH', hours)
24
+ .replace('mm', minutes)
25
+ .replace('ss', seconds);
26
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@makolabs/ripple",
3
- "version": "0.0.1-dev.63",
3
+ "version": "0.0.1-dev.65",
4
4
  "description": "Simple Svelte 5 powered component library ✨",
5
5
  "repository": {
6
6
  "type": "git",