intelliwaketssveltekitv25 0.2.5 → 0.2.7

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.
@@ -9,6 +9,7 @@ export interface IArrayColumn<T extends Record<string, any>> {
9
9
  hideOnColumn?: string;
10
10
  hideOnFunction?: (rowData: any | null | undefined) => boolean;
11
11
  toNumberFormat?: TNumberStringOptions;
12
+ justify?: 'left' | 'center' | 'right';
12
13
  TSFormat?: string;
13
14
  sumInFooter?: boolean;
14
15
  doNotSort?: boolean;
@@ -25,6 +26,7 @@ export type IArrayStructure<T extends Record<string, any>> = {
25
26
  defaultSortAscending?: boolean;
26
27
  minColSize?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
27
28
  rowClick?: (rowData: any) => void;
29
+ emptyMessage?: string | false;
28
30
  hidden?: boolean;
29
31
  };
30
32
  export type TClassNames = {
@@ -39,3 +41,4 @@ export declare function SumsInFooter<T extends Record<string, any>>(arrayData: T
39
41
  export declare function StructuredArray<T extends Record<string, any>>(arrayData: T[] | null, arrayStructure: IArrayStructure<T>): any[];
40
42
  export declare function ScreenFormatValue<T extends Record<string, any>>(value: any | null | undefined, column: IArrayColumn<T>): any | null | undefined;
41
43
  export declare function ColumnClassRight<T extends Record<string, any>>(column: IArrayColumn<T>): boolean;
44
+ export declare function ColumnClassCenter<T extends Record<string, any>>(column: IArrayColumn<T>): boolean;
@@ -69,6 +69,9 @@ export function ScreenFormatValue(value, column) {
69
69
  }
70
70
  }
71
71
  export function ColumnClassRight(column) {
72
- return column.toNumberFormat !== undefined ||
73
- column.TSFormat !== undefined;
72
+ return column.justify === 'right' || (!column.justify && (column.toNumberFormat !== undefined ||
73
+ column.TSFormat !== undefined));
74
+ }
75
+ export function ColumnClassCenter(column) {
76
+ return column.justify === 'center';
74
77
  }
@@ -1,6 +1,7 @@
1
1
  <script lang="ts" generics="T extends Record<string, any>">
2
2
 
3
3
  import {
4
+ ColumnClassCenter,
4
5
  ColumnClassRight,
5
6
  ComputeValue,
6
7
  type IArrayStructure,
@@ -77,31 +78,42 @@
77
78
  </tr>
78
79
  </thead>
79
80
  <tbody>
80
- {#each sortedArrayStructure as row, idx (idx)}
81
- <tr class:cursor-pointer={!!arrayStructure.rowClick}
82
- class:hover:bg-slate-50={!!arrayStructure.rowClick}
83
- onclick={() => {
81
+ {#if !sortedArrayStructure.length}
82
+ {#if arrayStructure.emptyMessage !== false}
83
+ <tr>
84
+ <td colspan={validColumns.length} class="text-center text-slate-400 italic">
85
+ {arrayStructure.emptyMessage ?? 'No data available'}
86
+ </td>
87
+ </tr>
88
+ {/if}
89
+ {:else}
90
+ {#each sortedArrayStructure as row, idx (idx)}
91
+ <tr class:cursor-pointer={!!arrayStructure.rowClick}
92
+ class:hover:bg-slate-50={!!arrayStructure.rowClick}
93
+ onclick={() => {
84
94
  if (!!arrayStructure.rowClick) arrayStructure.rowClick(row)
85
95
  }}>
86
- {#each validColumns as column, idx (idx)}
87
- {@const computedValue = ComputeValue(row[column.fieldName], column, row)}
88
- {@const formattedValue = ScreenFormatValue(computedValue, column)}
89
- {#if !hideCosts || !column.isACost}
90
- <td class="text-ellipsis overflow-hidden {!column.size ? '' : ` td-${column.size}`}"
91
- class:text-right={ColumnClassRight(column)}
92
- title={!!formattedValue && formattedValue.toString().length > 10 ? formattedValue : undefined}
93
- onclick={e => {
96
+ {#each validColumns as column, idx (idx)}
97
+ {@const computedValue = ComputeValue(row[column.fieldName], column, row)}
98
+ {@const formattedValue = ScreenFormatValue(computedValue, column)}
99
+ {#if !hideCosts || !column.isACost}
100
+ <td class="text-ellipsis overflow-hidden {!column.size ? '' : ` td-${column.size}`}"
101
+ class:text-right={ColumnClassRight(column)}
102
+ class:text-center={ColumnClassCenter(column)}
103
+ title={!!formattedValue && formattedValue.toString().length > 10 ? formattedValue : undefined}
104
+ onclick={e => {
94
105
  if (!!column.onclick) {
95
106
  e.stopPropagation()
96
107
  column.onclick(row, e)
97
108
  }
98
109
  }}>
99
- {formattedValue}
100
- </td>
101
- {/if}
102
- {/each}
103
- </tr>
104
- {/each}
110
+ {formattedValue}
111
+ </td>
112
+ {/if}
113
+ {/each}
114
+ </tr>
115
+ {/each}
116
+ {/if}
105
117
  </tbody>
106
118
  {#if ObjectKeys(sumsInFooter).length}
107
119
  <tfoot>
@@ -110,6 +122,7 @@
110
122
  {#if !hideCosts || !column.isACost}
111
123
  <th class="text-ellipsis overflow-hidden {!column.size ? '' : ` td-${column.size}`}"
112
124
  class:text-right={ColumnClassRight(column)}
125
+ class:text-center={ColumnClassCenter(column)}
113
126
  title={
114
127
  !!ScreenFormatValue(sumsInFooter[column.fieldName], column) &&
115
128
  ScreenFormatValue(sumsInFooter[column.fieldName], column).length > 10
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "intelliwaketssveltekitv25",
3
- "version": "0.2.5",
3
+ "version": "0.2.7",
4
4
  "exports": {
5
5
  ".": {
6
6
  "types": "./dist/index.d.ts",