@poirazis/supercomponents-shared 1.2.13 → 1.2.15

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@poirazis/supercomponents-shared",
3
- "version": "1.2.13",
3
+ "version": "1.2.15",
4
4
  "description": "Shared Svelte components library",
5
5
  "type": "module",
6
6
  "packageManager": "bun@1.0.0",
@@ -48,13 +48,13 @@
48
48
  "zod": "4.3.5"
49
49
  },
50
50
  "devDependencies": {
51
- "@budibase/types": "^3.24.4",
52
- "@sveltejs/package": "^2.3.12",
53
- "@sveltejs/vite-plugin-svelte": "^4.0.1",
54
- "@tsconfig/svelte": "^5.0.4",
55
- "postcss": "^8.4.35",
56
- "sass": "^1.90.2",
57
- "svelte": "^5.46.4",
51
+ "@budibase/types": "^3.29.0",
52
+ "@sveltejs/package": "^2.5.7",
53
+ "@sveltejs/vite-plugin-svelte": "^4.0.4",
54
+ "@tsconfig/svelte": "^5.0.8",
55
+ "postcss": "^8.5.6",
56
+ "sass": "^1.97.3",
57
+ "svelte": "^5.51.3",
58
58
  "typescript": "^5.9.3",
59
59
  "vite": "^5.4.21",
60
60
  "vite-plugin-css-injected-by-js": "^3.5.2"
@@ -61,7 +61,7 @@
61
61
  class:left-label={labelPos == "left"}
62
62
  class:multirow
63
63
  class:tall
64
- style:--height={height}
64
+ style:--field-height={height}
65
65
  style:--max-height={maxHeight}
66
66
  >
67
67
  {#if labelPos}
@@ -106,13 +106,14 @@
106
106
 
107
107
  <style>
108
108
  .super-field {
109
+ flex: 1;
109
110
  min-width: 80px;
110
111
  width: 100%;
111
112
  display: flex;
112
113
  flex-direction: column;
113
114
  align-items: stretch;
114
115
  overflow: hidden;
115
- min-height: var(--height);
116
+ min-height: var(--field-height, 2rem);
116
117
 
117
118
  &.multirow {
118
119
  max-height: var(--height);
@@ -141,7 +142,6 @@
141
142
  }
142
143
 
143
144
  .inline-cells {
144
- flex: auto;
145
145
  display: flex;
146
146
  align-items: stretch;
147
147
  min-height: 2rem;
@@ -135,7 +135,6 @@
135
135
 
136
136
  $: dataSourceStore.set(dataSource);
137
137
  $: filterStore.set(filter);
138
- $: stbSchema.set($stbData?.definition?.schema);
139
138
 
140
139
  // Update columnsStore when columnList changes
141
140
  $: columnsStore.set(columnList || []);
@@ -1193,6 +1192,7 @@
1193
1192
  $stbSelected = [];
1194
1193
  $cachedRows = [];
1195
1194
  $stbVisibleRows = [];
1195
+ $stbSchema = {};
1196
1196
 
1197
1197
  stbData = createFetch($dataSourceStore);
1198
1198
 
@@ -1214,6 +1214,7 @@
1214
1214
  }
1215
1215
 
1216
1216
  $cachedRows = [...fetchState.rows];
1217
+ $stbSchema = fetchState.definition?.schema || {};
1217
1218
  return "Idle";
1218
1219
  }
1219
1220
  },
@@ -1594,6 +1595,8 @@
1594
1595
  // Unlock all columns to allow responsive re-rendering
1595
1596
  columnStates?.forEach(({ state }) => state.unlockWidth());
1596
1597
  }
1598
+
1599
+ $: console.log($stbSchema);
1597
1600
  </script>
1598
1601
 
1599
1602
  <!-- svelte-ignore a11y-click-events-have-key-events -->
@@ -12,6 +12,7 @@
12
12
  const stbMenuID = getContext("stbMenuID");
13
13
  const rowMetadata = getContext("stbRowMetadata");
14
14
  const stbVisibleRows = getContext("stbVisibleRows");
15
+ const data = getContext("data");
15
16
 
16
17
  const stbAPI = getContext("stbAPI");
17
18
 
@@ -69,7 +70,7 @@
69
70
  class:hovered={$stbHovered == visibleRow || $stbMenuID == visibleRow}
70
71
  class:is-editing={$stbEditing == visibleRow}
71
72
  class:disabled={$rowMetadata[visibleRow].disabled}
72
- style:min-height={$rowMetadata[visibleRow].height}
73
+ style:min-height={$rowMetadata[visibleRow].height + "px"}
73
74
  style:padding-right={canScroll && right ? "1.5rem" : "0.5rem"}
74
75
  >
75
76
  <!-- svelte-ignore a11y-click-events-have-key-events -->
@@ -79,7 +80,7 @@
79
80
  >
80
81
  {#if rowMenu && inlineButtons?.length}
81
82
  {#each inlineButtons as { conditions, disabledTemplate, onClick, disabled, ...rest }}
82
- {#if stbAPI.shouldShowButton(conditions || [], stbAPI.enrichContext($stbData?.rows?.[visibleRow]))}
83
+ {#if stbAPI.shouldShowButton(conditions || [], stbAPI.enrichContext($data[visibleRow]))}
83
84
  <SuperButton
84
85
  {...rest}
85
86
  disabled={disabled ||
@@ -87,7 +88,7 @@
87
88
  $rowMetadata[visibleRow].disabled ||
88
89
  stbAPI.shouldDisableButton(
89
90
  disabledTemplate,
90
- stbAPI.enrichContext($stbData?.rows?.[visibleRow]),
91
+ stbAPI.enrichContext($data[visibleRow]),
91
92
  )}
92
93
  onClick={() => {
93
94
  stbAPI.executeRowButtonAction(visibleRow, onClick);
@@ -82,7 +82,7 @@
82
82
  class:selected
83
83
  class:hovered={$stbHovered == visibleRow || $stbMenuID == visibleRow}
84
84
  class:disabled={$stbRowMetadata[visibleRow]?.disabled}
85
- style:height={$stbRowMetadata[visibleRow]?.height}
85
+ style:height={$stbRowMetadata[visibleRow]?.height + "px"}
86
86
  on:mouseenter={() => ($stbHovered = visibleRow)}
87
87
  on:mouseleave={() => ($stbHovered = null)}
88
88
  >
@@ -1,6 +1,8 @@
1
1
  <script>
2
2
  import { getContext, createEventDispatcher, onMount, tick } from "svelte";
3
3
  import SuperPopover from "../SuperPopover/SuperPopover.svelte";
4
+ import "./CellCommon.css";
5
+
4
6
  import fsm from "svelte-fsm";
5
7
 
6
8
  const dispatch = createEventDispatcher();
@@ -82,8 +84,7 @@
82
84
  },
83
85
  Loading: {
84
86
  _enter() {
85
- if (cellOptions.optionsSource != "data" || $fetch?.loaded)
86
- this.goTo.debounce(15, cellOptions.initialState || "View");
87
+ if (cellOptions.optionsSource != "data") return "View";
87
88
  },
88
89
  _exit() {
89
90
  if (cellOptions.optionsSource == "custom") this.loadCustomOptions();
@@ -475,7 +476,7 @@
475
476
  $: query = QueryUtils.buildQuery(cellOptions.filter);
476
477
  $: inputSelect = controlType == "inputSelect";
477
478
 
478
- $: if (cellOptions.optionsSource == "data")
479
+ $: if (optionsSource == "data")
479
480
  fetch?.update?.({
480
481
  query,
481
482
  sortColumn: cellOptions.sortColumn,
@@ -27,13 +27,14 @@
27
27
  let picker;
28
28
  let inactive = true;
29
29
  let allSelected = false;
30
+ let fetch;
30
31
 
31
32
  const colors = derivedMemo(options, ($options) => {
32
33
  let obj = {};
33
34
  if (cellOptions.optionsSource == "custom") return obj;
34
35
  $options.forEach(
35
36
  (option, index) =>
36
- (obj[option] = optionColors[option] ?? colorsArray[index % 14])
37
+ (obj[option] = optionColors[option] ?? colorsArray[index % 14]),
37
38
  );
38
39
  return obj;
39
40
  });
@@ -57,7 +58,7 @@
57
58
  ];
58
59
 
59
60
  let originalValue = JSON.stringify(
60
- Array.isArray(value) ? value : value ? [value] : []
61
+ Array.isArray(value) ? value : value ? [value] : [],
61
62
  );
62
63
 
63
64
  $: ({
@@ -79,10 +80,6 @@
79
80
  // Handle Options from Data Source
80
81
  const dataSourceStore = memo(cellOptions?.datasource ?? {});
81
82
  $: dataSourceStore.set(cellOptions.datasource);
82
- $: fetch =
83
- optionsSource == "data"
84
- ? createFetch($dataSourceStore)
85
- : memo({ loaded: true });
86
83
  $: fullSelection =
87
84
  filteredOptions.length == localValue.length && filteredOptions.length > 0;
88
85
 
@@ -94,7 +91,7 @@
94
91
  valueColumn,
95
92
  iconColumn,
96
93
  colorColumn,
97
- $dataSourceStore
94
+ $dataSourceStore,
98
95
  );
99
96
 
100
97
  $: cellState.syncFetch($fetch);
@@ -107,6 +104,19 @@
107
104
  $: isButtons = controlType == "buttons";
108
105
  $: allSelected = filteredOptions.length == localValue.length;
109
106
 
107
+ const createFetch = (datasource) => {
108
+ return fetchData({
109
+ API,
110
+ datasource,
111
+ options: {
112
+ query: QueryUtils.buildQuery(cellOptions.filter),
113
+ sortColumn: cellOptions.sortColumn,
114
+ sortOrder: cellOptions.sortOrder,
115
+ limit: cellOptions.limit || 1000,
116
+ },
117
+ });
118
+ };
119
+
110
120
  export let cellState = fsm("Loading", {
111
121
  "*": {
112
122
  goTo(state) {
@@ -147,18 +157,23 @@
147
157
  },
148
158
  Loading: {
149
159
  _enter() {
150
- if (cellOptions.optionsSource != "data" || $fetch?.loaded)
160
+ if (cellOptions.optionsSource != "data")
151
161
  this.goTo.debounce(10, cellOptions.initialState || "View");
162
+ else {
163
+ fetch = createFetch($dataSourceStore);
164
+ }
152
165
  },
153
166
  _exit() {
154
167
  if (optionsSource == "custom") this.loadCustomOptions();
155
- else if (optionsSource == "data") this.loadDataOptions($fetch?.rows);
156
168
  else this.loadSchemaOptions();
157
169
 
158
170
  filteredOptions = $options;
159
171
  },
160
- syncFetch() {
161
- if ($fetch?.loaded) {
172
+ syncFetch(fetch) {
173
+ console.log("syncFetch", fetch.loaded);
174
+ if (fetch.loaded) {
175
+ this.loadDataOptions(fetch.rows);
176
+ console.log("loaded options from data", $options);
162
177
  return cellOptions.initialState || "View";
163
178
  }
164
179
  },
@@ -174,7 +189,7 @@
174
189
  Editing: {
175
190
  _enter() {
176
191
  originalValue = JSON.stringify(
177
- Array.isArray(value) ? value : value ? [value] : []
192
+ Array.isArray(value) ? value : value ? [value] : [],
178
193
  );
179
194
 
180
195
  dispatch("enteredit");
@@ -284,7 +299,7 @@
284
299
  filterOptions(e) {
285
300
  if (e && e.target.value != "") {
286
301
  filteredOptions = $options.filter((x) =>
287
- x?.startsWith(e.target.value)
302
+ x?.startsWith(e.target.value),
288
303
  );
289
304
  } else filteredOptions = $options;
290
305
  },
@@ -332,19 +347,6 @@
332
347
  },
333
348
  });
334
349
 
335
- const createFetch = (datasource) => {
336
- return fetchData({
337
- API,
338
- datasource,
339
- options: {
340
- query: QueryUtils.buildQuery(cellOptions.filter),
341
- sortColumn: cellOptions.sortColumn,
342
- sortOrder: cellOptions.sortOrder,
343
- limit: cellOptions.limit || 1000,
344
- },
345
- });
346
- };
347
-
348
350
  onMount(() => {
349
351
  if (autofocus)
350
352
  setTimeout(() => {
@@ -447,6 +449,8 @@
447
449
  {/each}
448
450
  </div>
449
451
  {/if}
452
+
453
+ View
450
454
  {:else if controlType == "switch"}
451
455
  <div
452
456
  class="radios"
@@ -498,6 +502,8 @@
498
502
  {/each}
499
503
  </div>
500
504
  {/if}
505
+
506
+ {$cellState}
501
507
  </div>
502
508
 
503
509
  <!-- svelte-ignore a11y-no-static-element-interactions -->
@@ -382,7 +382,7 @@
382
382
  {#if $columnOptionsStore.showHeader && $columnOptionsStore.canResize}
383
383
  <div
384
384
  class="grabber"
385
- style:height={$columnOptionsStore.headerHeight - 16}
385
+ style:height={$columnOptionsStore.headerHeight - 16 + "px"}
386
386
  on:mousedown={columnState.startResizing}
387
387
  on:dblclick={columnState.resetSize}
388
388
  on:mouseenter={() => (considerResizing = true)}
@@ -25,7 +25,7 @@
25
25
 
26
26
  // Get Row overrides from metadata or fallback to column settings
27
27
  $: color = $rowMetadata[index]?.color;
28
- $: height = $rowMetadata[index]?.height;
28
+ $: height = $rowMetadata[index]?.height + "px";
29
29
  $: bgcolor = $rowMetadata[index]?.bgcolor;
30
30
 
31
31
  $: id = row?.[idField] ?? index;
@@ -88,6 +88,8 @@
88
88
  const onContextMenu = (e) => {
89
89
  stbAPI.showContextMenu(index, e.__root);
90
90
  };
91
+
92
+ $: console.log(height);
91
93
  </script>
92
94
 
93
95
  <!-- svelte-ignore a11y-click-events-have-key-events -->
@@ -100,7 +102,7 @@
100
102
  class:isEditing
101
103
  class:disabled
102
104
  class:isLast
103
- style:height
105
+ style:min-height={height}
104
106
  style:color
105
107
  style:background-color={bgcolor}
106
108
  style:justify-content={$columnSettings.align}