@bexis2/bexis2-core-ui 0.4.5 → 0.4.6

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/README.md CHANGED
@@ -1,4 +1,10 @@
1
1
  # bexis-core-ui
2
+ ## 0.4.6
3
+ - table
4
+ - Adds config for enabling and disabling Search field on Table.
5
+ - Adds action dispatcher as prop for the renderComponent.
6
+ - Adds unique IDs for Search reset and submit buttons.
7
+
2
8
  ## 0.4.5
3
9
  - table
4
10
  - adds searching for missing values in the filters #744
@@ -49,6 +49,8 @@ let {
49
49
  // Default page size - number of rows to display per page
50
50
  toggle = false,
51
51
  // Whether to display the fitToScreen toggle
52
+ search = true,
53
+ // Whether to display the search input
52
54
  pageSizes = [5, 10, 15, 20],
53
55
  // Page sizes to display in the pagination component
54
56
  fitToScreen = true,
@@ -138,7 +140,7 @@ const tableColumns = [
138
140
  accessor,
139
141
  // Render the cell with the provided component, or use the toStringFn if provided, or just use the value
140
142
  cell: ({ value, row }) => {
141
- return renderComponent ? createRender(renderComponent, { value, row }) : toStringFn ? toStringFn(value) : value;
143
+ return renderComponent ? createRender(renderComponent, { value, row, dispatchFn: actionDispatcher }) : toStringFn ? toStringFn(value) : value;
142
144
  },
143
145
  plugins: {
144
146
  // Sorting config
@@ -271,7 +273,6 @@ const updateTable = async () => {
271
273
  }
272
274
  const response = await fetchData.json();
273
275
  if (response.columns !== void 0) {
274
- console.log(response);
275
276
  columns = convertServerColumns(response.columns, columns);
276
277
  const clientCols = response.columns.reduce((acc, col) => {
277
278
  acc[col.key] = col.column;
@@ -312,7 +313,7 @@ $:
312
313
  {#if $data.length > 0 || (columns && Object.keys(columns).length > 0)}
313
314
  <div class="table-container">
314
315
  <!-- Enable the search filter if table is not empty -->
315
- {#if !serverSide}
316
+ {#if !serverSide && search}
316
317
  <form
317
318
  class="flex gap-2"
318
319
  on:submit|preventDefault={() => {
@@ -329,6 +330,7 @@ $:
329
330
  id="{tableId}-search"
330
331
  /><button
331
332
  type="reset"
333
+ id="{tableId}-searchReset"
332
334
  class="absolute right-3 items-center"
333
335
  on:click|preventDefault={() => {
334
336
  searchValue = '';
@@ -339,6 +341,7 @@ $:
339
341
  </div>
340
342
  <button
341
343
  type="submit"
344
+ id="{tableId}-searchSubmit"
342
345
  class="btn variant-filled-primary"
343
346
  on:click|preventDefault={() => {
344
347
  $filterValue = searchValue;
@@ -348,7 +351,7 @@ $:
348
351
  </form>
349
352
  {/if}
350
353
 
351
- <div class="flex justify-between items-center py-2 w-full">
354
+ <div class="flex justify-between items-center w-full {search && 'py-2'}">
352
355
  <div>
353
356
  <!-- Enable the fitToScreen toggle if toggle === true -->
354
357
  {#if toggle}
@@ -18,7 +18,9 @@ $values.forEach((item) => {
18
18
  if (item) {
19
19
  type = typeof (toFilterableValueFn ? toFilterableValueFn(item) : item);
20
20
  if (type === "object") {
21
- if (item instanceof Date) {
21
+ if (toFilterableValueFn && toFilterableValueFn(item) instanceof Date) {
22
+ isDate = true;
23
+ } else if (item instanceof Date) {
22
24
  isDate = true;
23
25
  }
24
26
  }
@@ -85,6 +85,7 @@ export interface TableConfig<T> {
85
85
  data: Writable<T[]>;
86
86
  resizable?: 'none' | 'rows' | 'columns' | 'both';
87
87
  toggle?: boolean;
88
+ search?: boolean;
88
89
  fitToScreen?: boolean;
89
90
  height?: null | number;
90
91
  rowHeight?: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bexis2/bexis2-core-ui",
3
- "version": "0.4.5",
3
+ "version": "0.4.6",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "dev": "vite dev",
@@ -25,6 +25,7 @@
25
25
  "@skeletonlabs/tw-plugin": "^0.3.1",
26
26
  "@sveltejs/adapter-auto": "^3.2.0",
27
27
  "@sveltejs/adapter-static": "^3.0.1",
28
+ "@sveltejs/package": "^2.3.1",
28
29
  "@tailwindcss/forms": "^0.5.7",
29
30
  "@tailwindcss/typography": "^0.5.12",
30
31
  "@types/node": "^20.12.5",
@@ -39,7 +40,6 @@
39
40
  "raw-loader": "^4.0.2",
40
41
  "svelte": "^4.2.12",
41
42
  "svelte-check": "^3.6.9",
42
- "@sveltejs/package": "^2.3.1",
43
43
  "tailwindcss": "^3.4.3",
44
44
  "tslib": "^2.6.2",
45
45
  "typescript": "^5.4.4",
@@ -69,6 +69,8 @@
69
69
  "@fortawesome/fontawesome-svg-core": "^6.5.2",
70
70
  "@fortawesome/free-regular-svg-icons": "^6.5.2",
71
71
  "@fortawesome/free-solid-svg-icons": "^6.5.2",
72
+ "@sveltejs/kit": "^2.5.5",
73
+ "@sveltejs/vite-plugin-svelte": "^3.1.0",
72
74
  "axios": "^1.6.8",
73
75
  "codemirror": "^6.0.1",
74
76
  "dateformat": "^5.0.3",
@@ -83,7 +85,6 @@
83
85
  "svelte-file-dropzone": "^2.0.7",
84
86
  "svelte-headless-table": "^0.18.2",
85
87
  "svelte-select": "5.8.3",
86
- "@sveltejs/kit": "^2.5.5",
87
88
  "vest": "^5.2.12"
88
89
  },
89
90
  "author": "David Schöne",
@@ -50,6 +50,7 @@
50
50
  optionsComponent, // Custom component to render in the last column
51
51
  defaultPageSize = 10, // Default page size - number of rows to display per page
52
52
  toggle = false, // Whether to display the fitToScreen toggle
53
+ search = true, // Whether to display the search input
53
54
  pageSizes = [5, 10, 15, 20], // Page sizes to display in the pagination component
54
55
  fitToScreen = true, // Whether to fit the table to the screen,
55
56
  exportable = false, // Whether to display the export button and enable export functionality
@@ -154,7 +155,7 @@
154
155
  // Render the cell with the provided component, or use the toStringFn if provided, or just use the value
155
156
  cell: ({ value, row }) => {
156
157
  return renderComponent
157
- ? createRender(renderComponent, { value, row })
158
+ ? createRender(renderComponent, { value, row, dispatchFn: actionDispatcher })
158
159
  : toStringFn
159
160
  ? toStringFn(value)
160
161
  : value;
@@ -319,8 +320,6 @@
319
320
 
320
321
  // Format server columns to the client columns
321
322
  if (response.columns !== undefined) {
322
- console.log(response);
323
-
324
323
  columns = convertServerColumns(response.columns, columns);
325
324
 
326
325
  const clientCols = response.columns.reduce((acc, col) => {
@@ -369,7 +368,7 @@
369
368
  {#if $data.length > 0 || (columns && Object.keys(columns).length > 0)}
370
369
  <div class="table-container">
371
370
  <!-- Enable the search filter if table is not empty -->
372
- {#if !serverSide}
371
+ {#if !serverSide && search}
373
372
  <form
374
373
  class="flex gap-2"
375
374
  on:submit|preventDefault={() => {
@@ -386,6 +385,7 @@
386
385
  id="{tableId}-search"
387
386
  /><button
388
387
  type="reset"
388
+ id="{tableId}-searchReset"
389
389
  class="absolute right-3 items-center"
390
390
  on:click|preventDefault={() => {
391
391
  searchValue = '';
@@ -396,6 +396,7 @@
396
396
  </div>
397
397
  <button
398
398
  type="submit"
399
+ id="{tableId}-searchSubmit"
399
400
  class="btn variant-filled-primary"
400
401
  on:click|preventDefault={() => {
401
402
  $filterValue = searchValue;
@@ -405,7 +406,7 @@
405
406
  </form>
406
407
  {/if}
407
408
 
408
- <div class="flex justify-between items-center py-2 w-full">
409
+ <div class="flex justify-between items-center w-full {search && 'py-2'}">
409
410
  <div>
410
411
  <!-- Enable the fitToScreen toggle if toggle === true -->
411
412
  {#if toggle}
@@ -30,7 +30,9 @@
30
30
  type = typeof (toFilterableValueFn ? toFilterableValueFn(item) : item);
31
31
 
32
32
  if (type === 'object') {
33
- if (item instanceof Date) {
33
+ if (toFilterableValueFn && toFilterableValueFn(item) instanceof Date) {
34
+ isDate = true;
35
+ } else if (item instanceof Date) {
34
36
  isDate = true;
35
37
  }
36
38
  }
@@ -110,6 +110,7 @@ export interface TableConfig<T> {
110
110
  data: Writable<T[]>;
111
111
  resizable?: 'none' | 'rows' | 'columns' | 'both'; // none by default
112
112
  toggle?: boolean; // false by default
113
+ search?: boolean; // true by default
113
114
  fitToScreen?: boolean; // true by default
114
115
  height?: null | number; // null by default
115
116
  rowHeight?: number; // auto by default