windmill-components 1.82.1 → 1.82.2

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.
@@ -32,6 +32,8 @@ if (controls) {
32
32
  $componentControl[id] = controls;
33
33
  }
34
34
  let runnableComponent;
35
+ let isLoading = false;
36
+ let ownClick = false;
35
37
  let beforeIconComponent;
36
38
  let afterIconComponent;
37
39
  $: resolvedConfig.beforeIcon && handleBeforeIcon();
@@ -47,6 +49,19 @@ async function handleAfterIcon() {
47
49
  }
48
50
  }
49
51
  $: resolvedConfig?.triggerOnAppLoad && runnableComponent?.runComponent();
52
+ $: if (outputs?.loading != undefined) {
53
+ outputs.loading.set(false, true);
54
+ }
55
+ $: outputs?.loading.subscribe({
56
+ id: 'loading-' + id,
57
+ next: (value) => {
58
+ isLoading = value;
59
+ if (ownClick && !value) {
60
+ ownClick = false;
61
+ }
62
+ }
63
+ });
64
+ $: loading = isLoading && ownClick;
50
65
  let errors = {};
51
66
  $: errorsMessage = Object.values(errors)
52
67
  .filter((x) => x != '')
@@ -59,6 +74,7 @@ async function handleClick(event) {
59
74
  if (preclickAction) {
60
75
  await preclickAction();
61
76
  }
77
+ ownClick = true;
62
78
  if (!runnableComponent) {
63
79
  runnableWrapper.onSuccess();
64
80
  }
@@ -66,7 +82,6 @@ async function handleClick(event) {
66
82
  await runnableComponent?.runComponent();
67
83
  }
68
84
  }
69
- let loading = false;
70
85
  </script>
71
86
 
72
87
  {#each Object.keys(components['buttoncomponent'].initialData.configuration) as key (key)}
@@ -85,7 +100,6 @@ let loading = false;
85
100
  bind:this={runnableWrapper}
86
101
  {recomputeIds}
87
102
  bind:runnableComponent
88
- bind:loading
89
103
  {componentInput}
90
104
  doOnSuccess={resolvedConfig.onSuccess}
91
105
  {id}
@@ -28,8 +28,16 @@ let isLoading = false;
28
28
  $: noInputs =
29
29
  $stateId != undefined &&
30
30
  (componentInput?.type != 'runnable' || Object.keys(componentInput?.fields ?? {}).length == 0);
31
+ $: if (outputs?.loading != undefined) {
32
+ outputs.loading.set(false, true);
33
+ }
34
+ $: outputs?.loading.subscribe({
35
+ id: 'loading-' + id,
36
+ next: (value) => {
37
+ isLoading = value;
38
+ }
39
+ });
31
40
  $: css = concatCustomCss($app.css?.formcomponent, customCss);
32
- let loading = false;
33
41
  </script>
34
42
 
35
43
  {#each Object.keys(components['formcomponent'].initialData.configuration) as key (key)}
@@ -45,7 +53,6 @@ let loading = false;
45
53
  {recomputeIds}
46
54
  {render}
47
55
  bind:runnableComponent
48
- bind:loading
49
56
  {componentInput}
50
57
  {id}
51
58
  doOnSuccess={resolvedConfig.onSuccess}
@@ -25,6 +25,8 @@ let outputs = initOutput($worldStore, id, {
25
25
  });
26
26
  let resolvedConfig = initConfig(components['formbuttoncomponent'].initialData.configuration, configuration);
27
27
  let runnableComponent;
28
+ let isLoading = false;
29
+ let ownClick = false;
28
30
  let errors = {};
29
31
  $: errorsMessage = Object.values(errors)
30
32
  .filter((x) => x != '')
@@ -34,9 +36,18 @@ $: noInputs =
34
36
  $: if (outputs?.loading != undefined) {
35
37
  outputs.loading.set(false, true);
36
38
  }
39
+ $: outputs?.loading.subscribe({
40
+ id: 'loading-' + id,
41
+ next: (value) => {
42
+ isLoading = value;
43
+ if (ownClick && !value) {
44
+ ownClick = false;
45
+ }
46
+ }
47
+ });
48
+ $: loading = isLoading && ownClick;
37
49
  $: css = concatCustomCss($app?.css?.formbuttoncomponent, customCss);
38
50
  let runnableWrapper;
39
- let loading = false;
40
51
  </script>
41
52
 
42
53
  {#each Object.keys(components['formbuttoncomponent'].initialData.configuration) as key (key)}
@@ -27,7 +27,7 @@ $: Plotly &&
27
27
  divEl &&
28
28
  h &&
29
29
  w &&
30
- Plotly.newPlot(divEl, Array.isArray(result) ? result : [result], { width: w, height: h, margin: { l: 50, r: 40, b: 40, t: 40, pad: 4 } }, { responsive: true, displayModeBar: false });
30
+ Plotly.newPlot(divEl, [result], { width: w, height: h, margin: { l: 50, r: 40, b: 40, t: 40, pad: 4 } }, { responsive: true, displayModeBar: false });
31
31
  </script>
32
32
 
33
33
  <div class="w-full h-full" bind:clientHeight={h} bind:clientWidth={w}>
@@ -221,8 +221,7 @@ $componentControl[id] = {
221
221
  on:click={() => toggleRow(row, rowIndex)}
222
222
  >
223
223
  <div class="center-center h-full w-full flex-wrap gap-1 ">
224
- {#each actionButtons as actionButton, actionIndex (actionButton?.id)}
225
- <!-- svelte-ignore a11y-mouse-events-have-key-events -->
224
+ {#each actionButtons as actionButton, actionIndex (actionIndex)}
226
225
  <div
227
226
  on:mouseover|stopPropagation={() => {
228
227
  if (actionButton.id !== $hoverStore) {
@@ -256,15 +255,12 @@ $componentControl[id] = {
256
255
  extraKey={'idx' + rowIndex}
257
256
  {render}
258
257
  noWFull
258
+ {...actionButton}
259
259
  preclickAction={async () => {
260
260
  toggleRow(row, rowIndex)
261
261
  }}
262
- id={actionButton.id}
263
- customCss={actionButton.customCss}
264
- configuration={actionButton.configuration}
265
- recomputeIds={actionButton.recomputeIds}
266
262
  extraQueryParams={{ row: row.original }}
267
- componentInput={actionButton.componentInput}
263
+ bind:componentInput={actionButton.componentInput}
268
264
  controls={{
269
265
  left: () => {
270
266
  if (actionIndex === 0) {
@@ -292,15 +288,12 @@ $componentControl[id] = {
292
288
  extraKey={'idx' + rowIndex}
293
289
  {render}
294
290
  noWFull
295
- id={actionButton.id}
296
- customCss={actionButton.customCss}
297
- configuration={actionButton.configuration}
298
- recomputeIds={actionButton.recomputeIds}
291
+ {...actionButton}
299
292
  preclickAction={async () => {
300
293
  toggleRow(row, rowIndex)
301
294
  }}
302
295
  extraQueryParams={{ row: row.original }}
303
- componentInput={actionButton.componentInput}
296
+ bind:componentInput={actionButton.componentInput}
304
297
  />
305
298
  {/if}
306
299
  </div>
@@ -326,9 +319,9 @@ $componentControl[id] = {
326
319
  <div class="flex flex-col h-full w-full overflow-auto">
327
320
  <Alert title="Parsing issues" type="error" size="xs" class="h-full w-full ">
328
321
  The result should be an array of objects. Received:
329
- <pre class="w-full bg-white p-2 rounded-md whitespace-pre-wrap"
330
- >{JSON.stringify(result, null, 4)}</pre
331
- >
322
+ <pre class="w-full bg-white p-2 rounded-md">
323
+ {JSON.stringify(result, null, 4)}
324
+ </pre>
332
325
  </Alert>
333
326
  </div>
334
327
  {/if}
@@ -27,7 +27,6 @@ export let recomputable = false;
27
27
  export let outputs;
28
28
  export let extraKey = '';
29
29
  export let doNotRecomputeOnInputChanged = false;
30
- export let loading = false;
31
30
  const { worldStore, runnableComponents, workspace, appPath, isEditor, jobs, noBackend, errorByComponent, mode, stateId, state, componentControl } = getContext('AppViewerContext');
32
31
  const dispatch = createEventDispatcher();
33
32
  if (recomputable || autoRefresh) {
@@ -40,7 +39,6 @@ let args = undefined;
40
39
  let testIsLoading = false;
41
40
  let runnableInputValues = {};
42
41
  let executeTimeout = undefined;
43
- $: outputs.loading?.set(loading);
44
42
  function setDebouncedExecute() {
45
43
  executeTimeout && clearTimeout(executeTimeout);
46
44
  executeTimeout = setTimeout(() => {
@@ -105,7 +103,7 @@ function stripSchema(inputs, s) {
105
103
  }
106
104
  async function executeComponent(noToast = false, inlineScriptOverride) {
107
105
  if (runnable?.type === 'runnableByName' && runnable.inlineScript?.language === 'frontend') {
108
- loading = true;
106
+ outputs.loading?.set(true);
109
107
  try {
110
108
  const r = await eval_like(runnable.inlineScript?.content, computeGlobalContext($worldStore, id, {}), false, $state, $mode == 'dnd', $componentControl, $worldStore);
111
109
  await setResult(r);
@@ -114,7 +112,7 @@ async function executeComponent(noToast = false, inlineScriptOverride) {
114
112
  catch (e) {
115
113
  sendUserToast('Error running frontend script: ' + e.message, true);
116
114
  }
117
- loading = false;
115
+ outputs.loading?.set(false);
118
116
  return;
119
117
  }
120
118
  if (noBackend) {
@@ -126,7 +124,7 @@ async function executeComponent(noToast = false, inlineScriptOverride) {
126
124
  if (runnable?.type === 'runnableByName' && !runnable.inlineScript) {
127
125
  return;
128
126
  }
129
- loading = true;
127
+ outputs.loading?.set(true);
130
128
  try {
131
129
  let njob = await testJobLoader?.abstractRun(() => {
132
130
  const nonStaticRunnableInputs = {};
@@ -174,8 +172,7 @@ async function executeComponent(noToast = false, inlineScriptOverride) {
174
172
  }
175
173
  }
176
174
  catch (e) {
177
- setResult({ error: e.body ?? e.message });
178
- loading = false;
175
+ outputs.loading?.set(false);
179
176
  }
180
177
  }
181
178
  export async function runComponent() {
@@ -183,7 +180,7 @@ export async function runComponent() {
183
180
  await executeComponent();
184
181
  }
185
182
  catch (e) {
186
- setResult({ error: e.body ?? e.message });
183
+ console.error(e);
187
184
  }
188
185
  }
189
186
  let lastStartedAt = Date.now();
@@ -259,7 +256,7 @@ async function setResult(res) {
259
256
  setResult(e.detail.result)
260
257
  }
261
258
  }
262
- loading = false
259
+ outputs.loading?.set(false)
263
260
  }}
264
261
  bind:isLoading={testIsLoading}
265
262
  bind:job={testJob}
@@ -25,7 +25,6 @@ declare const __propDef: {
25
25
  };
26
26
  extraKey?: string | undefined;
27
27
  doNotRecomputeOnInputChanged?: boolean | undefined;
28
- loading?: boolean | undefined;
29
28
  runComponent?: (() => Promise<void>) | undefined;
30
29
  };
31
30
  events: {
@@ -8,7 +8,6 @@ export let componentInput;
8
8
  export let id;
9
9
  export let result = undefined;
10
10
  export let initializing = true;
11
- export let loading = false;
12
11
  export let extraQueryParams = {};
13
12
  export let autoRefresh = true;
14
13
  export let runnableComponent = undefined;
@@ -74,7 +73,6 @@ export function onSuccess() {
74
73
  {:else if componentInput.type === 'runnable' && isRunnableDefined(componentInput)}
75
74
  <RunnableComponent
76
75
  {extraKey}
77
- bind:loading
78
76
  bind:this={runnableComponent}
79
77
  fields={componentInput.fields}
80
78
  bind:result
@@ -8,7 +8,6 @@ declare const __propDef: {
8
8
  id: string;
9
9
  result?: any;
10
10
  initializing?: boolean | undefined;
11
- loading?: boolean | undefined;
12
11
  extraQueryParams?: Record<string, any> | undefined;
13
12
  autoRefresh?: boolean | undefined;
14
13
  runnableComponent?: RunnableComponent | undefined;
@@ -143,7 +143,7 @@ $: hasError = componentWithErrors.includes(component.id);
143
143
  customCss={component.customCss}
144
144
  bind:initializing
145
145
  componentInput={component.componentInput}
146
- actionButtons={component.actionButtons}
146
+ bind:actionButtons={component.actionButtons}
147
147
  {render}
148
148
  />
149
149
  {:else if component.type === 'aggridcomponent'}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "windmill-components",
3
- "version": "1.82.1",
3
+ "version": "1.82.2",
4
4
  "devDependencies": {
5
5
  "@playwright/test": "^1.31.1",
6
6
  "@sveltejs/adapter-static": "^1.0.0",