@bexis2/bexis2-core-ui 0.4.96 → 0.4.97

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.
Files changed (86) hide show
  1. package/README.md +99 -25
  2. package/dist/components/CodeEditor/CodeEditor.svelte +2 -2
  3. package/dist/components/Facets/ShowMore.svelte +4 -6
  4. package/dist/components/File/FileUploader.svelte +6 -3
  5. package/dist/components/Table/Table.svelte +26 -5
  6. package/dist/components/Table/TableContent.svelte +226 -27
  7. package/dist/components/Table/TablePaginationServer.svelte +27 -8
  8. package/dist/components/Table/clientDB.d.ts +22 -0
  9. package/dist/components/Table/clientDB.js +236 -0
  10. package/dist/components/Table/filter.js +5 -1
  11. package/dist/components/Table/tableWorker.d.ts +1 -0
  12. package/dist/components/Table/tableWorker.js +179 -0
  13. package/dist/components/Table/utils.d.ts +1 -2
  14. package/dist/components/Table/utils.js +45 -26
  15. package/dist/components/form/CheckboxKvPList.svelte +15 -15
  16. package/dist/components/form/CheckboxList.svelte +1 -1
  17. package/dist/components/form/DateInput.svelte +12 -1
  18. package/dist/components/form/DatePickerInput.svelte +51 -29
  19. package/dist/components/form/Dropdown.svelte +14 -3
  20. package/dist/components/form/DropdownKvP.svelte +13 -2
  21. package/dist/components/form/InputContainer.svelte +17 -15
  22. package/dist/components/form/MultiSelect.svelte +30 -29
  23. package/dist/components/form/NumberInput.svelte +12 -1
  24. package/dist/components/form/TextArea.svelte +12 -1
  25. package/dist/components/form/TextInput.svelte +12 -1
  26. package/dist/components/page/Alert.svelte +5 -1
  27. package/dist/components/page/BackToTop.svelte +3 -1
  28. package/dist/components/page/Docs.svelte +9 -2
  29. package/dist/components/page/GoToTop.svelte +14 -15
  30. package/dist/components/page/Page.svelte +50 -56
  31. package/dist/components/page/breadcrumb/BreadcrumbDataCaller.js +11 -15
  32. package/dist/components/page/menu/MenuAccountBar.svelte +1 -5
  33. package/dist/components/page/menu/MenuDataCaller.js +1 -1
  34. package/dist/components/page/menu/MenuItem.svelte +9 -7
  35. package/dist/components/page/menu/MenuSublist.svelte +7 -5
  36. package/dist/components/page/menu/SettingsBar.svelte +4 -1
  37. package/dist/components/toggle/Toggle.svelte +9 -9
  38. package/dist/css/core.ui.postcss +1 -2
  39. package/dist/services/Api.js +4 -4
  40. package/dist/services/BaseCaller.js +1 -1
  41. package/package.json +114 -114
  42. package/src/lib/components/CodeEditor/CodeEditor.svelte +4 -4
  43. package/src/lib/components/Facets/Facets.svelte +2 -2
  44. package/src/lib/components/Facets/ShowMore.svelte +4 -6
  45. package/src/lib/components/File/FileUploader.svelte +17 -14
  46. package/src/lib/components/Table/Table.svelte +31 -10
  47. package/src/lib/components/Table/TableContent.svelte +261 -38
  48. package/src/lib/components/Table/TableFilter.svelte +7 -2
  49. package/src/lib/components/Table/TablePagination.svelte +6 -2
  50. package/src/lib/components/Table/TablePaginationServer.svelte +36 -10
  51. package/src/lib/components/Table/clientDB.js +236 -0
  52. package/src/lib/components/Table/filter.ts +27 -23
  53. package/src/lib/components/Table/tableWorker.js +179 -0
  54. package/src/lib/components/Table/utils.ts +75 -56
  55. package/src/lib/components/form/Checkbox.svelte +1 -1
  56. package/src/lib/components/form/CheckboxKvPList.svelte +15 -16
  57. package/src/lib/components/form/CheckboxList.svelte +1 -1
  58. package/src/lib/components/form/DateInput.svelte +13 -2
  59. package/src/lib/components/form/DatePickerInput.svelte +51 -29
  60. package/src/lib/components/form/Dropdown.svelte +14 -3
  61. package/src/lib/components/form/DropdownKvP.svelte +13 -2
  62. package/src/lib/components/form/InputContainer.svelte +18 -17
  63. package/src/lib/components/form/MultiSelect.svelte +30 -29
  64. package/src/lib/components/form/NumberInput.svelte +21 -12
  65. package/src/lib/components/form/TextArea.svelte +13 -2
  66. package/src/lib/components/form/TextInput.svelte +13 -2
  67. package/src/lib/components/page/Alert.svelte +5 -1
  68. package/src/lib/components/page/BackToTop.svelte +3 -1
  69. package/src/lib/components/page/Docs.svelte +9 -2
  70. package/src/lib/components/page/GoToTop.svelte +14 -15
  71. package/src/lib/components/page/Notification.svelte +1 -1
  72. package/src/lib/components/page/Page.svelte +67 -78
  73. package/src/lib/components/page/breadcrumb/Breadcrumb.svelte +2 -3
  74. package/src/lib/components/page/breadcrumb/BreadcrumbDataCaller.js +11 -15
  75. package/src/lib/components/page/menu/MenuAccountBar.svelte +1 -6
  76. package/src/lib/components/page/menu/MenuDataCaller.js +1 -1
  77. package/src/lib/components/page/menu/MenuItem.svelte +10 -8
  78. package/src/lib/components/page/menu/MenuSublist.svelte +35 -41
  79. package/src/lib/components/page/menu/SettingsBar.svelte +5 -2
  80. package/src/lib/components/toggle/Toggle.svelte +28 -30
  81. package/src/lib/css/core.ui.postcss +1 -2
  82. package/src/lib/index.ts +1 -2
  83. package/src/lib/services/Api.ts +21 -20
  84. package/src/lib/services/BaseCaller.js +1 -1
  85. package/src/lib/stores/apiStores.ts +1 -5
  86. package/src/lib/stores/pageStores.ts +0 -2
@@ -41,13 +41,10 @@ export const getResizeStyles = (
41
41
  ) => {
42
42
  return `
43
43
  min-height: ${rowHeights && rowHeights[+id] ? `${rowHeights[+id].min}px` : 'auto'};
44
- max-height: ${index !== 0 && rowHeights && rowHeights[+id]
45
- ? `${rowHeights[+id].max}px`
46
- : 'auto'
47
- };
44
+ max-height: ${index !== 0 && rowHeights && rowHeights[+id] ? `${rowHeights[+id].max}px` : 'auto'};
48
45
  height: ${rowHeights && rowHeights[+id] ? `${rowHeights[+id].min}px` : 'auto'};
49
46
  `;
50
- }
47
+ };
51
48
  // Function to normalize the filters for back-end
52
49
  export const normalizeFilters = (filters: {
53
50
  [key: string]: { [key in FilterOptionsEnum]?: number | string | Date };
@@ -103,14 +100,12 @@ export const jsonToCsv = (data: string): string => {
103
100
  // Create CSV rows
104
101
  const rows = [
105
102
  headers.join(','), // Header row
106
- ...json.map((row) =>
107
- headers.map(header => escapeCsvCell(row[header])).join(',')
108
- ) // Data rows
103
+ ...json.map((row) => headers.map((header) => escapeCsvCell(row[header])).join(',')) // Data rows
109
104
  ];
110
105
 
111
106
  // Join rows with newlines
112
107
  return rows.join('\n');
113
- }
108
+ };
114
109
  // Resetting the resized columns and/or rows
115
110
  export const resetResize = (
116
111
  headerRows: any,
@@ -162,12 +157,12 @@ export const missingValuesFn = (
162
157
  const foundKey =
163
158
  typeof key === 'number' && key.toString().includes('e')
164
159
  ? Object.keys(missingValues).find((item) => {
165
- return (item as string).toLowerCase() === key.toString().toLowerCase();
166
- })
160
+ return (item as string).toLowerCase() === key.toString().toLowerCase();
161
+ })
167
162
  : typeof key === 'string' && parseInt(key).toString().length !== key.length && new Date(key)
168
163
  ? Object.keys(missingValues).find(
169
- (item) => new Date(item).getTime() === new Date(key).getTime()
170
- )
164
+ (item) => new Date(item).getTime() === new Date(key).getTime()
165
+ )
171
166
  : key in missingValues
172
167
  ? key
173
168
  : undefined;
@@ -180,13 +175,13 @@ export const updateTable = async (
180
175
  pageIndex: number,
181
176
  server: ServerConfig | undefined,
182
177
  filters: {
183
- [key: string]: { [key in FilterOptionsEnum]?: number | string | Date }
178
+ [key: string]: { [key in FilterOptionsEnum]?: number | string | Date };
184
179
  },
185
180
  data: Writable<any[]>,
186
181
  serverItems: Writable<number> | undefined,
187
182
  columns: Columns | undefined,
188
183
  dispatch: any,
189
- order: OrderBy[] = [],
184
+ order: OrderBy[] = []
190
185
  ) => {
191
186
  const { baseUrl, entityId, versionId, sendModel = new Send() } = server ?? {};
192
187
 
@@ -202,7 +197,7 @@ export const updateTable = async (
202
197
  // remove %%% from the columns object
203
198
  if (sendModel.order) {
204
199
  sendModel.order.forEach((order) => {
205
- if (order.column.includes("%%%")) {
200
+ if (order.column.includes('%%%')) {
206
201
  const newKey = order.column.replaceAll('%%%', '.');
207
202
  order.column = newKey;
208
203
  }
@@ -228,21 +223,36 @@ export const updateTable = async (
228
223
  }
229
224
 
230
225
  // 1. Get the raw text of the response instead of parsing it automatically
231
- const rawText = await fetchData.text();
232
-
233
- // 2. Parse it with a reviver function that targets large integers
234
- const response: Receive = JSON.parse(rawText, (key, value, context) => {
235
- // If the parser thinks it's a number, but we have the raw source text
236
- if (context && context.source && typeof value === 'number') {
237
- // Check if the number exceeds JavaScript's safe integer limit
238
- if (!Number.isSafeInteger(value)) {
239
- // Return it natively as a JavaScript BigInt (e.g., 9223372036854775806n)
240
- return BigInt(context.source);
241
- }
242
- }
243
- return value;
244
- });
245
- // console.log('Server response', response);
226
+ const rawText = await fetchData.text();
227
+
228
+ // 2. Parse it with a reviver function that targets large integers
229
+ const response: Receive = JSON.parse(rawText, (key, value, context) => {
230
+ // If the parser thinks it's a number, but we have the raw source text
231
+ if (context && context.source && typeof value === 'number') {
232
+ // Check if the number exceeds JavaScript's safe integer limit
233
+ if (!Number.isSafeInteger(value)) {
234
+ // Return it natively as a JavaScript BigInt (e.g., 9223372036854775806n)
235
+ return BigInt(context.source);
236
+ }
237
+ }
238
+ return value;
239
+ });
240
+
241
+ const rawCount = (response as any).count;
242
+ const hasRawCount =
243
+ rawCount !== undefined && rawCount !== null && String(rawCount).trim().length > 0;
244
+ const parsedServerCount = hasRawCount
245
+ ? typeof rawCount === 'number'
246
+ ? rawCount
247
+ : Number(String(rawCount).replace(/[^0-9.-]/g, ''))
248
+ : Number.NaN;
249
+ const hasServerCount = hasRawCount && Number.isFinite(parsedServerCount) && parsedServerCount >= 0;
250
+ const normalizedCount = hasServerCount
251
+ ? parsedServerCount
252
+ : Array.isArray(response.data)
253
+ ? response.data.length
254
+ : 0;
255
+ // console.log('Server response', response);
246
256
 
247
257
  // Format server columns to the client columns
248
258
  if (response.columns !== undefined) {
@@ -255,9 +265,9 @@ const response: Receive = JSON.parse(rawText, (key, value, context) => {
255
265
  //const key = col.key.replaceAll('.' ,'');
256
266
  ///console.log(key, col.column);
257
267
  // set the key to the columns object
258
- col.column = col.column.replaceAll('.', "%%%");
259
- col.key = col.key.replaceAll('.', "%%%");
260
- acc[col.key] = col.column
268
+ col.column = col.column.replaceAll('.', '%%%');
269
+ col.key = col.key.replaceAll('.', '%%%');
270
+ acc[col.key] = col.column;
261
271
  //acc[col.column] = col.column;
262
272
 
263
273
  return acc;
@@ -268,23 +278,24 @@ const response: Receive = JSON.parse(rawText, (key, value, context) => {
268
278
  response.data.forEach((row, index) => {
269
279
  const tmp: { [key: string]: any } = {};
270
280
  Object.keys(row).forEach((key) => {
271
- tmp[clientCols[key.replaceAll('.', "%%%") ]] = row[key]
281
+ tmp[clientCols[key.replaceAll('.', '%%%')]] = row[key];
272
282
  });
273
283
  tmpArr.push(tmp);
274
284
  });
275
- dispatch('fetch', columns);
285
+ dispatch('fetch', {
286
+ columns,
287
+ count: hasServerCount ? parsedServerCount : tmpArr.length
288
+ });
289
+ serverItems?.set(hasServerCount ? parsedServerCount : tmpArr.length);
276
290
  data.set(tmpArr);
277
291
  // console.log('Server data', tmpArr);
278
292
  return data;
279
293
  }
280
294
 
281
- serverItems?.set(response.count);
282
- // console.log('Server data updated');
283
-
284
-
285
- // log the columns object
286
- console.log(response);
287
- return response;
295
+ serverItems?.set(normalizedCount);
296
+ // If backend does not provide column metadata, still render returned rows.
297
+ data.set(response.data ?? []);
298
+ return data;
288
299
  };
289
300
  // Function to convert server data to client data
290
301
  export const convertServerColumns = (
@@ -331,12 +342,12 @@ export const convertServerColumns = (
331
342
  }
332
343
 
333
344
  if (columns && col.column in columns) {
334
- columnsConfig[col.column.replaceAll('.', "%%%")] = {
335
- ...columns[col.column.replaceAll('.', "%%%")],
345
+ columnsConfig[col.column.replaceAll('.', '%%%')] = {
346
+ ...columns[col.column.replaceAll('.', '%%%')],
336
347
  instructions
337
348
  };
338
349
  } else {
339
- columnsConfig[col.column.replaceAll('.', "%%%") ] = {
350
+ columnsConfig[col.column.replaceAll('.', '%%%')] = {
340
351
  instructions
341
352
  };
342
353
  }
@@ -355,6 +366,8 @@ export const getMaxCellHeightInRow = (
355
366
  ) => {
356
367
  if (!tableRef || resizable === 'columns' || resizable === 'none') return;
357
368
 
369
+ const measuredHeights: { [key: number]: { max: number; min: number } } = {};
370
+
358
371
  tableRef.querySelectorAll('tbody tr').forEach((row, index) => {
359
372
  const cells = row.querySelectorAll('td');
360
373
 
@@ -372,17 +385,23 @@ export const getMaxCellHeightInRow = (
372
385
  }
373
386
  });
374
387
 
375
- rowHeights.update((rh) => {
376
- const id = +row.id.split(`${tableId}-row-`)[1];
377
- return {
378
- ...rh,
379
- [id]: {
380
- max: maxHeight - 24,
381
- min: Math.max(minHeight - 24, rowHeight ?? 20)
382
- }
388
+ const id = +row.id.split(`${tableId}-row-`)[1];
389
+ if (Number.isFinite(id)) {
390
+ measuredHeights[id] = {
391
+ max: maxHeight - 24,
392
+ min: Math.max(minHeight - 24, rowHeight ?? 20)
383
393
  };
384
- });
394
+ }
385
395
  });
396
+
397
+ if (Object.keys(measuredHeights).length === 0) {
398
+ return;
399
+ }
400
+
401
+ rowHeights.update((rh) => ({
402
+ ...rh,
403
+ ...measuredHeights
404
+ }));
386
405
  };
387
406
  // Calculates the minimum width of the cells in each column
388
407
  export const getMinCellWidthInColumn = (
@@ -409,4 +428,4 @@ export const getMinCellWidthInColumn = (
409
428
  });
410
429
  return cw;
411
430
  });
412
- };
431
+ };
@@ -9,7 +9,7 @@
9
9
  export let invalid: boolean;
10
10
  export let required: boolean;
11
11
  export let feedback: [];
12
- export let description: string = '';
12
+ export let description: string = '';
13
13
  </script>
14
14
 
15
15
  <InputContainer {label} {feedback} {required} {description}>
@@ -12,23 +12,22 @@
12
12
 
13
13
  let required = false;
14
14
  export let feedback: [];
15
-
16
15
  </script>
17
16
 
18
17
  <InputContainer {id} label={title} {feedback} {required} {help} {description}>
19
- <div class="flex gap-2" class:flex-col={vertical} >
20
- {#each source as item}
21
- <label class="flex items-center space-x-2" for={item.key}>
22
- <input
23
- class="checkbox"
24
- type="checkbox"
25
- bind:group={target}
26
- checked={item.key}
27
- value={item.key}
28
- id={item.key}
29
- />
30
- <p>{item.value}</p>
31
- </label>
32
- {/each}
33
- </div>
18
+ <div class="flex gap-2" class:flex-col={vertical}>
19
+ {#each source as item}
20
+ <label class="flex items-center space-x-2" for={item.key}>
21
+ <input
22
+ class="checkbox"
23
+ type="checkbox"
24
+ bind:group={target}
25
+ checked={item.key}
26
+ value={item.key}
27
+ id={item.key}
28
+ />
29
+ <p>{item.value}</p>
30
+ </label>
31
+ {/each}
32
+ </div>
34
33
  </InputContainer>
@@ -14,7 +14,7 @@
14
14
  <InputContainer label={title} {feedback} {required} {description}>
15
15
  {#each source as item}
16
16
  <label class="flex items-center space-x-2" for={item}>
17
- <input class="checkbox" type="checkbox" bind:group={target} value={item} id={item}/>
17
+ <input class="checkbox" type="checkbox" bind:group={target} value={item} id={item} />
18
18
  <p>{item}</p>
19
19
  </label>
20
20
  {/each}
@@ -10,12 +10,23 @@
10
10
  export let feedback: string[] = [''];
11
11
  export let help = false;
12
12
  export let disabled: boolean = false;
13
- export let description : string = '';
13
+ export let description: string = '';
14
14
  export let showDescription: boolean = false;
15
15
  export let showIcon: boolean = false;
16
16
  </script>
17
17
 
18
- <InputContainer {id} {label} {feedback} {required} {help} {description} {showDescription} {showIcon} on:showDescription on:hideDescription>
18
+ <InputContainer
19
+ {id}
20
+ {label}
21
+ {feedback}
22
+ {required}
23
+ {help}
24
+ {description}
25
+ {showDescription}
26
+ {showIcon}
27
+ on:showDescription
28
+ on:hideDescription
29
+ >
19
30
  <input
20
31
  {id}
21
32
  class="input variant-form-material bg-zinc-50 dark:bg-zinc-700 placeholder:text-gray-400"
@@ -39,33 +39,55 @@
39
39
  }
40
40
  </script>
41
41
 
42
- <InputContainer {id} {label} {feedback} {required} {help} {description} {showDescription} {showIcon} on:showDescription on:hideDescription>
43
- <!-- 1. Wrap everything in a relative container so the icon positions against this boundary -->
44
- <div class="relative w-full">
45
-
46
- <SveltyPicker
47
- {mode}
48
- name={label}
49
- {format}
50
- {displayFormat}
51
- {initialDate}
52
- bind:value
53
- on:input
54
- on:change
55
- {disabled}
56
- {placeholder}
57
- manualInput={true}
58
-
59
- inputClasses="input variant-form-material bg-zinc-50 dark:bg-zinc-700 placeholder:text-gray-400 pr-10 {valid ? 'input-success' : ''} {invalid ? 'input-error' : ''}"
60
- />
61
- {#if mode === 'time'}
62
- <Fa icon={faClock} class="absolute inset-y-2 right-0 flex items-center pr-3 pointer-events-none text-gray-400 dark:text-gray-300" />
63
- {:else if mode === 'date' }
64
- <Fa icon={faCalendar} class="absolute inset-y-2 right-0 flex items-center pr-3 pointer-events-none text-gray-400 dark:text-gray-300" />
65
- {:else if mode === 'datetime'}
66
- <Fa icon={faCalendar} class="absolute inset-y-2 right-5 flex items-center pr-3 pointer-events-none text-gray-400 dark:text-gray-300" />
67
- <Fa icon={faClock} class="absolute inset-y-2 right-0 flex items-center pr-3 pointer-events-none text-gray-400 dark:text-gray-300" />
68
- {/if}
69
- </div>
70
-
42
+ <InputContainer
43
+ {id}
44
+ {label}
45
+ {feedback}
46
+ {required}
47
+ {help}
48
+ {description}
49
+ {showDescription}
50
+ {showIcon}
51
+ on:showDescription
52
+ on:hideDescription
53
+ >
54
+ <!-- 1. Wrap everything in a relative container so the icon positions against this boundary -->
55
+ <div class="relative w-full">
56
+ <SveltyPicker
57
+ {mode}
58
+ name={label}
59
+ {format}
60
+ {displayFormat}
61
+ {initialDate}
62
+ bind:value
63
+ on:input
64
+ on:change
65
+ {disabled}
66
+ {placeholder}
67
+ manualInput={true}
68
+ inputClasses="input variant-form-material bg-zinc-50 dark:bg-zinc-700 placeholder:text-gray-400 pr-10 {valid
69
+ ? 'input-success'
70
+ : ''} {invalid ? 'input-error' : ''}"
71
+ />
72
+ {#if mode === 'time'}
73
+ <Fa
74
+ icon={faClock}
75
+ class="absolute inset-y-2 right-0 flex items-center pr-3 pointer-events-none text-gray-400 dark:text-gray-300"
76
+ />
77
+ {:else if mode === 'date'}
78
+ <Fa
79
+ icon={faCalendar}
80
+ class="absolute inset-y-2 right-0 flex items-center pr-3 pointer-events-none text-gray-400 dark:text-gray-300"
81
+ />
82
+ {:else if mode === 'datetime'}
83
+ <Fa
84
+ icon={faCalendar}
85
+ class="absolute inset-y-2 right-5 flex items-center pr-3 pointer-events-none text-gray-400 dark:text-gray-300"
86
+ />
87
+ <Fa
88
+ icon={faClock}
89
+ class="absolute inset-y-2 right-0 flex items-center pr-3 pointer-events-none text-gray-400 dark:text-gray-300"
90
+ />
91
+ {/if}
92
+ </div>
71
93
  </InputContainer>
@@ -20,16 +20,27 @@
20
20
 
21
21
  function updatedSelectedValue(selection) {
22
22
  if (selection != null) {
23
- selected = selection;
23
+ selected = selection;
24
24
  }
25
25
  }
26
26
 
27
27
  function updatedTarget(value) {
28
- target = value;
28
+ target = value;
29
29
  }
30
30
  </script>
31
31
 
32
- <InputContainer {id} label={title} {feedback} {required} {help} {description} {showDescription} {showIcon} on:showDescription on:hideDescription>
32
+ <InputContainer
33
+ {id}
34
+ label={title}
35
+ {feedback}
36
+ {required}
37
+ {help}
38
+ {description}
39
+ {showDescription}
40
+ {showIcon}
41
+ on:showDescription
42
+ on:hideDescription
43
+ >
33
44
  <select
34
45
  {id}
35
46
  class="select variant-form-material dark:bg-zinc-700 bg-zinc-50 placeholder:text-gray-400"
@@ -11,7 +11,7 @@
11
11
  export let required = false;
12
12
  export let complexTarget = false;
13
13
  export let help = false;
14
- export let description = '';
14
+ export let description = '';
15
15
  export let showDescription = false;
16
16
  export let showIcon = false;
17
17
  $: selected = null;
@@ -38,7 +38,18 @@
38
38
  }
39
39
  </script>
40
40
 
41
- <InputContainer {id} label={title} {feedback} {required} {help} {description} {showDescription} {showIcon} on:showDescription on:hideDescription>
41
+ <InputContainer
42
+ {id}
43
+ label={title}
44
+ {feedback}
45
+ {required}
46
+ {help}
47
+ {description}
48
+ {showDescription}
49
+ {showIcon}
50
+ on:showDescription
51
+ on:hideDescription
52
+ >
42
53
  <select
43
54
  {id}
44
55
  class="select variant-form-material dark:bg-zinc-700 bg-zinc-50 placeholder:text-gray-400"
@@ -9,7 +9,7 @@
9
9
  export let required: boolean;
10
10
  export let feedback: string[];
11
11
  export let help: boolean = false;
12
- export let description : string = '';
12
+ export let description: string = '';
13
13
  export let showDescription: boolean = false;
14
14
  export let showIcon: boolean = false;
15
15
 
@@ -23,7 +23,6 @@
23
23
  // dispatch an event to show the description
24
24
  dispatch('showDescription', { id, description });
25
25
  }
26
-
27
26
  }
28
27
 
29
28
  export function onMouseOut() {
@@ -44,33 +43,35 @@
44
43
  on:focus={onMouseOver}
45
44
  on:mouseout={onMouseOut}
46
45
  on:blur={onMouseOut}
47
- on:focusin={onMouseOver}
48
- on:focusout={onMouseOut}
49
-
46
+ on:focusin={onMouseOver}
47
+ on:focusout={onMouseOut}
50
48
  >
51
- <label class="label w-full flex" for="{id}">
49
+ <label class="label w-full flex" for={id}>
52
50
  <span class="grow"
53
51
  >{label}
54
- {#if required} <span class="text-xs text-red-600">*</span> {/if}
52
+ {#if required}
53
+ <span class="text-xs text-red-600">*</span>
54
+ {/if}
55
55
  </span>
56
56
  {#if description && showIcon}
57
- <button class="badge " on:click={()=>showDescription = !showDescription}><Fa icon={faQuestion} /></button>
57
+ <button class="badge" on:click={() => (showDescription = !showDescription)}
58
+ ><Fa icon={faQuestion} /></button
59
+ >
58
60
  {/if}
59
61
  </label>
60
62
 
61
-
62
63
  {#if description && showDescription}
63
- <div class="card text-sm text-gray-500 p-2 mb-2">{@html description}</div>
64
+ <div class="card text-sm text-gray-500 p-2 mb-2">{@html description}</div>
64
65
  {/if}
65
66
  <slot />
66
67
  <div class="min-h-5">
67
- <span class="text-xs text-error-600 ">
68
- {#if feedback}
69
- <ul>
70
- {#each feedback as message}
71
- <li>{message}</li>
72
- {/each}
73
- </ul>
68
+ <span class="text-xs text-error-600">
69
+ {#if feedback}
70
+ <ul>
71
+ {#each feedback as message}
72
+ <li>{message}</li>
73
+ {/each}
74
+ </ul>
74
75
  {/if}
75
76
  </span>
76
77
  </div>
@@ -32,10 +32,10 @@
32
32
 
33
33
  $: value = '';
34
34
  $: updateTarget(value);
35
- $: target, setValue(target);
35
+ $: (target, setValue(target));
36
36
 
37
37
  let groupBy;
38
- $: groupBy = itemGroup ? (item) => item[itemGroup] : undefined;
38
+ $: groupBy = itemGroup ? (item) => item[itemGroup] : undefined;
39
39
 
40
40
  const dispatch = createEventDispatcher();
41
41
 
@@ -47,8 +47,6 @@
47
47
  return;
48
48
  }
49
49
 
50
-
51
-
52
50
  //console.log('update');
53
51
  //different cases
54
52
  //a) source is complex model is simple return array
@@ -151,28 +149,23 @@
151
149
  if (!isMulti) {
152
150
  //console.log("onmount",complexSource,complexTarget,value,target)
153
151
  if (!complexSource && !complexTarget) {
154
-
155
-
156
- if(groupBy) { // if groupby is set, the value needs to be set as object with label and value, otherwise the select component does not recognize the value
152
+ if (groupBy) {
153
+ // if groupby is set, the value needs to be set as object with label and value, otherwise the select component does not recognize the value
154
+ value = {
155
+ value: t,
156
+ label: t
157
+ };
158
+ } else // if there is no groupby, the value can be set as simple value, otherwise the select component does not recognize the value
159
+ {
160
+ if (t === null || t === undefined || t === '') {
161
+ value = '';
162
+ } else {
157
163
  value = {
158
- value: t,
159
- label: t
160
- };
164
+ value: t,
165
+ label: t
166
+ };
161
167
  }
162
- else // if there is no groupby, the value can be set as simple value, otherwise the select component does not recognize the value
163
- {
164
- if(t === null || t === undefined || t === '') {
165
- value = ''
166
- }
167
- else
168
- {
169
- value = {
170
- value: t,
171
- label: t
172
- };
173
- }
174
- }
175
-
168
+ }
176
169
  }
177
170
 
178
171
  if (complexSource && complexTarget) {
@@ -304,13 +297,22 @@
304
297
  target = '';
305
298
  }
306
299
 
307
- dispatch('clear', e)
308
-
300
+ dispatch('clear', e);
309
301
  }
310
-
311
302
  </script>
312
303
 
313
- <InputContainer {id} label={title} {feedback} {required} {help} {description} {showDescription} {showIcon} on:showDescription on:hideDescription>
304
+ <InputContainer
305
+ {id}
306
+ label={title}
307
+ {feedback}
308
+ {required}
309
+ {help}
310
+ {description}
311
+ {showDescription}
312
+ {showIcon}
313
+ on:showDescription
314
+ on:hideDescription
315
+ >
314
316
  <Select
315
317
  {id}
316
318
  items={source}
@@ -320,7 +322,6 @@
320
322
  multiple={isMulti}
321
323
  bind:value
322
324
  {placeholder}
323
-
324
325
  hasError={invalid}
325
326
  {loading}
326
327
  {clearable}