windmill-components 1.82.12 → 1.83.0

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 (104) hide show
  1. package/common.d.ts +2 -2
  2. package/components/ArgInput.svelte +52 -66
  3. package/components/ArgInput.svelte.d.ts +1 -3
  4. package/components/DisplayResult.svelte +17 -17
  5. package/components/Editor.svelte +0 -3
  6. package/components/Editor.svelte.d.ts +0 -1
  7. package/components/FieldHeader.svelte +0 -1
  8. package/components/FieldHeader.svelte.d.ts +0 -4
  9. package/components/FlowBuilder.svelte +1 -0
  10. package/components/FlowStatusViewer.svelte +7 -4
  11. package/components/FlowStatusViewer.svelte.d.ts +1 -0
  12. package/components/FlowViewer.svelte +0 -1
  13. package/components/InputTransformForm.svelte +0 -1
  14. package/components/LightweightArgInput.svelte +1 -9
  15. package/components/LightweightArgInput.svelte.d.ts +1 -3
  16. package/components/SimpleEditor.svelte +0 -1
  17. package/components/SimpleEditor.svelte.d.ts +0 -1
  18. package/components/TemplateEditor.svelte +0 -1
  19. package/components/apps/components/display/AppDisplayComponent.svelte +23 -17
  20. package/components/apps/components/display/AppHtml.svelte +7 -1
  21. package/components/apps/components/display/AppHtml.svelte.d.ts +2 -0
  22. package/components/apps/components/display/PlotlyHtml.svelte +20 -3
  23. package/components/apps/components/display/PlotlyHtml.svelte.d.ts +2 -0
  24. package/components/apps/components/display/table/AppTable.svelte +54 -35
  25. package/components/apps/components/display/table/AppTable.svelte.d.ts +1 -1
  26. package/components/apps/components/display/table/AppTableFooter.svelte +2 -1
  27. package/components/apps/components/display/table/AppTableFooter.svelte.d.ts +1 -0
  28. package/components/apps/components/display/table/tableOptions.js +1 -1
  29. package/components/apps/components/helpers/DebouncedInput.svelte +1 -0
  30. package/components/apps/components/helpers/DebouncedInput.svelte.d.ts +2 -0
  31. package/components/apps/components/helpers/InputValue.svelte +3 -3
  32. package/components/apps/components/helpers/RunnableComponent.svelte +2 -2
  33. package/components/apps/components/helpers/RunnableWrapper.svelte +1 -1
  34. package/components/apps/components/helpers/eval.d.ts +4 -2
  35. package/components/apps/components/helpers/eval.js +6 -4
  36. package/components/apps/components/inputs/AppMultiSelect.svelte +11 -3
  37. package/components/apps/components/inputs/AppMultiSelect.svelte.d.ts +0 -2
  38. package/components/apps/components/inputs/AppSelect.svelte +9 -1
  39. package/components/apps/components/inputs/AppSelect.svelte.d.ts +0 -2
  40. package/components/apps/components/inputs/AppTextInput.svelte +52 -39
  41. package/components/apps/components/inputs/AppTextInput.svelte.d.ts +1 -1
  42. package/components/apps/components/layout/AppContainer.svelte +1 -1
  43. package/components/apps/editor/AppEditor.svelte +31 -4
  44. package/components/apps/editor/AppPreview.svelte +13 -2
  45. package/components/apps/editor/GridEditor.svelte +12 -3
  46. package/components/apps/editor/GridViewer.svelte +2 -2
  47. package/components/apps/editor/GridViewer.svelte.d.ts +1 -1
  48. package/components/apps/editor/SettingsPanel.svelte +1 -1
  49. package/components/apps/editor/SubGridEditor.svelte +3 -2
  50. package/components/apps/editor/appUtils.d.ts +1 -0
  51. package/components/apps/editor/appUtils.js +19 -0
  52. package/components/apps/editor/component/Component.svelte +14 -4
  53. package/components/apps/editor/component/Component.svelte.d.ts +1 -1
  54. package/components/apps/editor/component/components.d.ts +45 -28
  55. package/components/apps/editor/component/components.js +41 -27
  56. package/components/apps/editor/component/sets.js +2 -1
  57. package/components/apps/editor/componentsPanel/CssProperty.svelte +0 -26
  58. package/components/apps/editor/componentsPanel/CssProperty.svelte.d.ts +0 -2
  59. package/components/apps/editor/componentsPanel/CssSettings.svelte +1 -0
  60. package/components/apps/editor/componentsPanel/QuickStyleMenu.svelte +13 -10
  61. package/components/apps/editor/componentsPanel/quickStyleProperties.js +3 -0
  62. package/components/apps/editor/componentsPanel/store.js +4 -4
  63. package/components/apps/editor/contextPanel/ComponentOutput.svelte +2 -26
  64. package/components/apps/editor/contextPanel/ComponentOutput.svelte.d.ts +0 -1
  65. package/components/apps/editor/contextPanel/ComponentOutputViewer.svelte +8 -6
  66. package/components/apps/editor/contextPanel/ContextPanel.svelte +7 -14
  67. package/components/apps/editor/contextPanel/components/BackgroundScriptOutput.svelte +2 -25
  68. package/components/apps/editor/contextPanel/components/OutputHeader.svelte +28 -42
  69. package/components/apps/editor/contextPanel/components/OutputHeader.svelte.d.ts +1 -2
  70. package/components/apps/editor/inlineScriptsPanel/EmptyInlineScript.svelte +2 -7
  71. package/components/apps/editor/inlineScriptsPanel/EmptyInlineScript.svelte.d.ts +1 -1
  72. package/components/apps/editor/inlineScriptsPanel/InlineScriptEditor.svelte +7 -8
  73. package/components/apps/editor/inlineScriptsPanel/InlineScriptEditorPanel.svelte +4 -3
  74. package/components/apps/editor/inlineScriptsPanel/InlineScriptEditorPanel.svelte.d.ts +1 -0
  75. package/components/apps/editor/inlineScriptsPanel/InlineScriptsPanel.svelte +0 -1
  76. package/components/apps/editor/inlineScriptsPanel/InlineScriptsPanelWithTable.svelte +2 -0
  77. package/components/apps/editor/settingsPanel/ArrayStaticInputEditor.svelte +22 -19
  78. package/components/apps/editor/settingsPanel/ComponentPanel.svelte +18 -3
  79. package/components/apps/editor/settingsPanel/GridTab.svelte +1 -2
  80. package/components/apps/editor/settingsPanel/InputsSpecEditor.svelte +2 -1
  81. package/components/apps/editor/settingsPanel/InputsSpecEditor.svelte.d.ts +4 -0
  82. package/components/apps/editor/settingsPanel/InputsSpecsEditor.svelte +1 -0
  83. package/components/apps/editor/settingsPanel/SelectedRunnable.svelte +1 -2
  84. package/components/apps/editor/settingsPanel/StylePanel.svelte +40 -2
  85. package/components/apps/editor/settingsPanel/inputEditor/EvalInputEditor.svelte +5 -1
  86. package/components/apps/editor/settingsPanel/inputEditor/IconSelectInput.svelte +3 -3
  87. package/components/apps/editor/settingsPanel/inputEditor/JsonEditor.svelte +3 -2
  88. package/components/apps/editor/settingsPanel/inputEditor/JsonEditor.svelte.d.ts +4 -1
  89. package/components/apps/editor/settingsPanel/inputEditor/StaticInputEditor.svelte +2 -2
  90. package/components/apps/inputType.d.ts +2 -2
  91. package/components/apps/rx.d.ts +2 -2
  92. package/components/apps/svelte-grid/Grid.svelte +9 -12
  93. package/components/apps/svelte-grid/Grid.svelte.d.ts +1 -6
  94. package/components/apps/svelte-grid/MoveResize.svelte +3 -2
  95. package/components/apps/svelte-grid/MoveResize.svelte.d.ts +1 -8
  96. package/components/apps/types.d.ts +1 -1
  97. package/components/apps/utils.js +3 -0
  98. package/components/flows/map/MapItem.svelte +3 -3
  99. package/components/propertyPicker/ObjectViewer.svelte +0 -3
  100. package/components/scriptEditor/LogPanel.svelte +3 -3
  101. package/infer.js +3 -0
  102. package/package.json +671 -672
  103. package/components/apps/editor/contextPanel/components/MinMaxButton.svelte +0 -25
  104. package/components/apps/editor/contextPanel/components/MinMaxButton.svelte.d.ts +0 -16
@@ -6,10 +6,9 @@ declare const __propDef: {
6
6
  first?: boolean | undefined;
7
7
  nested?: boolean | undefined;
8
8
  color?: "blue" | "indigo" | undefined;
9
+ selectable?: boolean | undefined;
9
10
  };
10
11
  events: {
11
- handleClick: CustomEvent<any>;
12
- } & {
13
12
  [evt: string]: CustomEvent<any>;
14
13
  };
15
14
  slots: {
@@ -14,7 +14,7 @@ import { defaultCode } from '../component';
14
14
  import InlineScriptList from '../settingsPanel/mainInput/InlineScriptList.svelte';
15
15
  import WorkspaceScriptList from '../settingsPanel/mainInput/WorkspaceScriptList.svelte';
16
16
  export let name;
17
- export let id;
17
+ export let componentType = undefined;
18
18
  let tab = 'inlinescripts';
19
19
  let filter = '';
20
20
  let picker;
@@ -30,7 +30,6 @@ async function inferInlineScriptSchema(language, content, schema) {
30
30
  return schema;
31
31
  }
32
32
  async function createInlineScriptByLanguage(language, path, subkind = undefined) {
33
- const componentType = $app.grid.find((c) => c.data.id === id)?.data?.type;
34
33
  const content = defaultCode(componentType ?? '', language) ??
35
34
  initialCode(language, Script.kind.SCRIPT, subkind ?? 'flow');
36
35
  return newInlineScript(content, language, path);
@@ -63,9 +62,6 @@ function pickInlineScript(name) {
63
62
  dispatch('new', unusedInlineScript.inlineScript);
64
63
  }
65
64
  const langs = ['deno', 'python3', 'go', 'bash'];
66
- function loadSchemaFromTriggerable(path, arg1) {
67
- throw new Error('Function not implemented.');
68
- }
69
65
  </script>
70
66
 
71
67
  <Drawer bind:this={picker} size="1000px">
@@ -184,8 +180,7 @@ console.log(ctx.email)
184
180
  if (!state.foo) { state.foo = 0 }
185
181
  state.foo += 1
186
182
 
187
- // you can also navigate to another page
188
- //await goto("?foo=bar")
183
+ // you can also navigate (goto), recompute a script (recompute), or set a tab (setTab)
189
184
 
190
185
  return state.foo`,
191
186
  language: 'frontend',
@@ -2,7 +2,7 @@ import { SvelteComponentTyped } from "svelte";
2
2
  declare const __propDef: {
3
3
  props: {
4
4
  name: string;
5
- id: string;
5
+ componentType?: string | undefined;
6
6
  };
7
7
  events: {
8
8
  delete: CustomEvent<any>;
@@ -5,7 +5,7 @@ import InlineScriptEditorDrawer from './InlineScriptEditorDrawer.svelte';
5
5
  import { inferArgs } from '../../../../infer';
6
6
  import Badge from '../../../common/badge/Badge.svelte';
7
7
  import Editor from '../../../Editor.svelte';
8
- import { emptySchema, scriptLangToEditorLang } from '../../../../utils';
8
+ import { emptySchema, isMac, scriptLangToEditorLang } from '../../../../utils';
9
9
  import Popover from '../../../Popover.svelte';
10
10
  import { computeFields } from './utils';
11
11
  import { deepEqual } from 'fast-equals';
@@ -58,7 +58,6 @@ async function loadSchemaAndInputsByName() {
58
58
  }
59
59
  }
60
60
  }
61
- let isMac = navigator.userAgent.indexOf('Mac OS X') !== -1;
62
61
  $: extraLib =
63
62
  inlineScript?.language == 'frontend' && worldStore
64
63
  ? buildExtraLib($worldStore?.outputsById ?? {}, id, false, $state, true)
@@ -149,7 +148,7 @@ function handleRefreshOn(refreshOn) {
149
148
  Format
150
149
 
151
150
  <div class="flex flex-row items-center gap-1">
152
- <Kbd>{isMac ? '⌘' : 'CTRL'}</Kbd>
151
+ <Kbd>{isMac() ? '⌘' : 'CTRL'}</Kbd>
153
152
  <Kbd>S</Kbd>
154
153
  </div>
155
154
  </div>
@@ -171,7 +170,7 @@ function handleRefreshOn(refreshOn) {
171
170
  Run
172
171
 
173
172
  <div class="flex flex-row items-center gap-1">
174
- <Kbd>{isMac ? '⌘' : 'CTRL'}</Kbd>
173
+ <Kbd>{isMac() ? '⌘' : 'CTRL'}</Kbd>
175
174
  <Kbd>
176
175
  <div class="h-4 flex items-center justify-center">
177
176
  <CornerDownLeft size={10} />
@@ -220,15 +219,15 @@ function handleRefreshOn(refreshOn) {
220
219
  {:else}
221
220
  <SimpleEditor
222
221
  bind:this={simpleEditor}
222
+ class="h-full"
223
+ {extraLib}
224
+ bind:code={inlineScript.content}
225
+ lang="javascript"
223
226
  cmdEnterAction={async () => {
224
227
  runLoading = true
225
228
  await $runnableComponents[id]?.cb?.(!transformer ? inlineScript : undefined)
226
229
  runLoading = false
227
230
  }}
228
- class="h-full"
229
- {extraLib}
230
- bind:code={inlineScript.content}
231
- lang="javascript"
232
231
  on:change={() => {
233
232
  $app = $app
234
233
  }}
@@ -14,6 +14,7 @@ import { deepEqual } from 'fast-equals';
14
14
  import { getContext } from 'svelte';
15
15
  export let componentInput;
16
16
  export let defaultUserInput = false;
17
+ export let componentType;
17
18
  export let id;
18
19
  export let transformer;
19
20
  const { app } = getContext('AppViewerContext');
@@ -86,8 +87,8 @@ function deleteInlineScript() {
86
87
  }}
87
88
  />
88
89
  {:else}
89
- <span class="px-2 text-gray-600"
90
- >Selected editor component is a transformer but component has no transformer
90
+ <span class="px-2 text-gray-600">
91
+ Selected editor component is a transformer but component has no transformer
91
92
  </span>
92
93
  {/if}
93
94
  {:else if componentInput && componentInput.type == 'runnable'}
@@ -104,7 +105,7 @@ function deleteInlineScript() {
104
105
  />
105
106
  {:else}
106
107
  <EmptyInlineScript
107
- {id}
108
+ {componentType}
108
109
  name={componentInput.runnable.name}
109
110
  on:delete={deleteInlineScript}
110
111
  on:new={(e) => {
@@ -4,6 +4,7 @@ declare const __propDef: {
4
4
  props: {
5
5
  componentInput: AppInput | undefined;
6
6
  defaultUserInput?: boolean | undefined;
7
+ componentType: string;
7
8
  id: string;
8
9
  transformer: boolean;
9
10
  };
@@ -62,7 +62,6 @@ $: unusedInlineScript = $app?.unusedInlineScripts?.findIndex((k_, index) => `unu
62
62
  />
63
63
  {:else}
64
64
  <EmptyInlineScript
65
- id={`b_${hiddenInlineScript}`}
66
65
  name={$app.hiddenInlineScripts[hiddenInlineScript].name}
67
66
  on:delete={() => deleteBackgroundScript(hiddenInlineScript)}
68
67
  on:new={(e) => {
@@ -9,6 +9,7 @@ export let gridItem;
9
9
  defaultUserInput={gridItem.data?.type == 'formcomponent' ||
10
10
  gridItem?.data?.type == 'formbuttoncomponent'}
11
11
  id={gridItem.data.id}
12
+ componentType={gridItem.data.type}
12
13
  transformer={$selectedComponentInEditor?.endsWith('_transformer')}
13
14
  bind:componentInput={gridItem.data.componentInput}
14
15
  />
@@ -18,6 +19,7 @@ export let gridItem;
18
19
  {#each gridItem.data.actionButtons as actionButton, index (index)}
19
20
  {#if actionButton?.id === $selectedComponentInEditor || actionButton?.id + '_transformer' === $selectedComponentInEditor}
20
21
  <InlineScriptEditorPanel
22
+ componentType={actionButton.type}
21
23
  id={actionButton.id}
22
24
  transformer={$selectedComponentInEditor?.endsWith('_transformer')}
23
25
  bind:componentInput={actionButton.componentInput}
@@ -1,5 +1,5 @@
1
1
  <script>import { Button } from '../../../common';
2
- import { faPlus, faTrashAlt } from '@fortawesome/free-solid-svg-icons';
2
+ import { faPlus } from '@fortawesome/free-solid-svg-icons';
3
3
  import { X } from 'lucide-svelte';
4
4
  import { createEventDispatcher } from 'svelte';
5
5
  import { fade } from 'svelte/transition';
@@ -23,8 +23,8 @@ function addElementByType() {
23
23
  else if (subFieldType === 'object') {
24
24
  value.push({});
25
25
  }
26
- else if (subFieldType === 'labeledresource') {
27
- value.push({ value: '', label: '' });
26
+ else if (subFieldType === 'labeledresource' || subFieldType === 'labeledselect') {
27
+ value.push({ value: 'foo', label: 'bar' });
28
28
  }
29
29
  else if (subFieldType === 'tab-select') {
30
30
  value.push({ id: '', index: 0 });
@@ -49,28 +49,31 @@ function addElementByType() {
49
49
  function deleteElementByType(index) {
50
50
  if (componentInput.value) {
51
51
  componentInput.value.splice(index, 1);
52
+ redraw = redraw + 1;
52
53
  dispatch('deleteArrayItem', { index });
53
- componentInput = componentInput;
54
54
  }
55
55
  }
56
+ let redraw = 0;
56
57
  </script>
57
58
 
58
59
  <div class="flex gap-2 flex-col mt-2">
59
- {#if Array.isArray(componentInput.value)}
60
- {#each componentInput.value as value, index (index)}
61
- <div class="flex flex-row gap-2 items-center relative">
62
- <SubTypeEditor {subFieldType} bind:componentInput bind:value />
63
- <button
64
- transition:fade|local={{ duration: 100 }}
65
- class="z-10 rounded-full p-1 duration-200 hover:bg-gray-200"
66
- aria-label="Remove item"
67
- on:click|preventDefault|stopPropagation={() => deleteElementByType(index)}
68
- >
69
- <X size={14} />
70
- </button>
71
- </div>
72
- {/each}
73
- {/if}
60
+ {#key redraw}
61
+ {#if Array.isArray(componentInput.value)}
62
+ {#each componentInput.value as value, index (index)}
63
+ <div class="flex flex-row gap-2 items-center relative">
64
+ <SubTypeEditor {subFieldType} bind:componentInput bind:value />
65
+ <button
66
+ transition:fade|local={{ duration: 100 }}
67
+ class="z-10 rounded-full p-1 duration-200 hover:bg-gray-200"
68
+ aria-label="Remove item"
69
+ on:click|preventDefault|stopPropagation={() => deleteElementByType(index)}
70
+ >
71
+ <X size={14} />
72
+ </button>
73
+ </div>
74
+ {/each}
75
+ {/if}
76
+ {/key}
74
77
  <Button size="xs" color="light" startIcon={{ icon: faPlus }} on:click={() => addElementByType()}>
75
78
  Add
76
79
  </Button>
@@ -33,13 +33,16 @@ export let noGrid = false;
33
33
  export let duplicateMoveAllowed = true;
34
34
  let editor = undefined;
35
35
  const { app, runnableComponents, selectedComponent, worldStore, focusedGrid, stateId, state, errorByComponent, jobs } = getContext('AppViewerContext');
36
- const { history, ontextfocus } = getContext('AppEditorContext');
36
+ const { history, ontextfocus, movingcomponents } = getContext('AppEditorContext');
37
37
  $: editor && ($ontextfocus = () => editor?.focus());
38
38
  function removeGridElement() {
39
39
  push(history, $app);
40
40
  if (componentSettings?.item.id) {
41
41
  $errorByComponent = clearErrorByComponentId(componentSettings?.item.id, $errorByComponent);
42
42
  $jobs = clearJobsByComponentId(componentSettings?.item.id, $jobs);
43
+ if ($movingcomponents?.includes(componentSettings?.item.id)) {
44
+ $movingcomponents = $movingcomponents.filter((id) => id !== componentSettings?.item.id);
45
+ }
43
46
  }
44
47
  $selectedComponent = undefined;
45
48
  $focusedGrid = undefined;
@@ -63,7 +66,7 @@ $: extraLib =
63
66
  : undefined;
64
67
  function keydown(event) {
65
68
  const { key, metaKey } = event;
66
- if (key === 'Delte' || (key === 'Backspace' && metaKey)) {
69
+ if (key === 'Delete' || (key === 'Backspace' && metaKey)) {
67
70
  removeGridElement();
68
71
  event.stopPropagation();
69
72
  }
@@ -181,6 +184,10 @@ $: componentSettings?.item?.data && ($app = $app);
181
184
  userInputEnabled={false}
182
185
  />
183
186
  </PanelSection>
187
+ {:else}
188
+ <div class="h-full w-full font-bold text-gray-400 text-lg py-10 px-4"
189
+ >{ccomponents[component.type].name} has no configuration</div
190
+ >
184
191
  {/if}
185
192
 
186
193
  {#if componentSettings.item.data.type === 'tabscomponent'}
@@ -204,6 +211,14 @@ $: componentSettings?.item?.data && ($app = $app);
204
211
  {#if Object.keys(ccomponents[component.type].customCss ?? {}).length > 0}
205
212
  <PanelSection title="Styling">
206
213
  <div slot="action">
214
+ <Button
215
+ color="light"
216
+ size="xs"
217
+ variant="border"
218
+ on:click={() => (viewCssOptions = !viewCssOptions)}
219
+ >
220
+ {viewCssOptions ? 'Hide' : 'Show'}
221
+ </Button>
207
222
  <Button
208
223
  color="light"
209
224
  size="xs"
@@ -211,7 +226,7 @@ $: componentSettings?.item?.data && ($app = $app);
211
226
  endIcon={{ icon: faChevronRight }}
212
227
  on:click={() => secondaryMenu.open(StylePanel, { component })}
213
228
  >
214
- Open
229
+ Rich Editor
215
230
  </Button>
216
231
  </div>
217
232
  {#if viewCssOptions}
@@ -1,7 +1,6 @@
1
1
  <script>import Button from '../../../common/button/Button.svelte';
2
2
  import CloseButton from '../../../common/CloseButton.svelte';
3
- import { faPlus, faTrashAlt } from '@fortawesome/free-solid-svg-icons';
4
- import { CrossIcon } from 'lucide-svelte';
3
+ import { faPlus } from '@fortawesome/free-solid-svg-icons';
5
4
  import { getContext } from 'svelte';
6
5
  import { deleteGridItem } from '../appUtils';
7
6
  import PanelSection from './common/PanelSection.svelte';
@@ -23,6 +23,7 @@ export let fieldType;
23
23
  export let subFieldType;
24
24
  export let format;
25
25
  export let selectOptions;
26
+ export let fileUpload = undefined;
26
27
  export let placeholder;
27
28
  const { connectingInput } = getContext('AppViewerContext');
28
29
  $: if (componentInput == undefined) {
@@ -88,7 +89,7 @@ $: if (componentInput == undefined) {
88
89
  <svelte:fragment slot="text">User Input</svelte:fragment>
89
90
  </Popover>
90
91
  {/if}
91
- {#if 'fileUpload' in componentInput}
92
+ {#if fileUpload}
92
93
  <Popover placement="bottom" notClickable disapperTimoout={0}>
93
94
  <ToggleButton
94
95
  position="center"
@@ -16,6 +16,10 @@ declare const __propDef: {
16
16
  subFieldType: InputType | undefined;
17
17
  format: string | undefined;
18
18
  selectOptions: string[] | undefined;
19
+ fileUpload?: {
20
+ accept: string;
21
+ convertTo: string;
22
+ } | undefined;
19
23
  placeholder: string | undefined;
20
24
  };
21
25
  events: {
@@ -41,6 +41,7 @@ export let resourceOnly = false;
41
41
  selectOptions={meta?.['selectOptions']}
42
42
  tooltip={meta?.['tooltip']}
43
43
  onlyStatic={meta?.['onlyStatic']}
44
+ fileUpload={meta?.['fileUpload']}
44
45
  placeholder={meta?.['placeholder']}
45
46
  />
46
47
  {/if}
@@ -1,8 +1,7 @@
1
1
  <script>import Button from '../../../common/button/Button.svelte';
2
2
  import Toggle from '../../../Toggle.svelte';
3
3
  import Tooltip from '../../../Tooltip.svelte';
4
- import { faClose, faEdit } from '@fortawesome/free-solid-svg-icons';
5
- import { includes } from 'lodash';
4
+ import { faClose } from '@fortawesome/free-solid-svg-icons';
6
5
  import { getContext } from 'svelte';
7
6
  import { clearResultAppInput } from '../../utils';
8
7
  import ComponentTriggerList from './triggerLists/ComponentTriggerList.svelte';
@@ -1,11 +1,50 @@
1
- <script>import { getContext } from 'svelte';
1
+ <script>import { Button } from '../../../common';
2
+ import { sendUserToast } from '../../../../utils';
3
+ import { Copy } from 'lucide-svelte';
4
+ import { getContext } from 'svelte';
2
5
  import { ccomponents } from '../component';
3
6
  import CssProperty from '../componentsPanel/CssProperty.svelte';
4
7
  import { quickStyleProperties } from '../componentsPanel/quickStyleProperties';
5
8
  export let component;
6
9
  const { app } = getContext('AppViewerContext');
10
+ function applyToAllInstances() {
11
+ if (component) {
12
+ if (!$app.css) {
13
+ $app.css = {};
14
+ }
15
+ let componentType = component?.type;
16
+ if (!$app.css[componentType]) {
17
+ $app.css[componentType] = {};
18
+ }
19
+ Object.keys(ccomponents[component.type].customCss ?? {}).forEach((name) => {
20
+ if (!$app.css[componentType][name]) {
21
+ $app.css[componentType][name] = {};
22
+ }
23
+ if (component) {
24
+ let nstyle = component.customCss[name];
25
+ if (nstyle.style) {
26
+ $app.css[componentType][name].style = nstyle.style;
27
+ }
28
+ if (nstyle.class) {
29
+ $app.css[componentType][name].class = nstyle.class;
30
+ }
31
+ }
32
+ });
33
+ sendUserToast(`Applied style to all instances of the ${componentType.replace('component', '')} component`);
34
+ }
35
+ }
7
36
  </script>
8
37
 
38
+ <Button
39
+ variant="border"
40
+ color="light"
41
+ size="xs"
42
+ aria-label="Apply to all instances of this component"
43
+ on:click={applyToAllInstances}
44
+ >
45
+ Copy style to global CSS &nbsp;<Copy size={18} />
46
+ </Button>
47
+
9
48
  {#if component && component.customCss !== undefined}
10
49
  {#each Object.keys(ccomponents[component.type].customCss ?? {}) as name}
11
50
  <div class="w-full">
@@ -14,7 +53,6 @@ const { app } = getContext('AppViewerContext');
14
53
  forceStyle={ccomponents[component.type].customCss[name].style !== undefined}
15
54
  forceClass={ccomponents[component.type].customCss[name].class !== undefined}
16
55
  {name}
17
- componentType={component.type}
18
56
  bind:value={component.customCss[name]}
19
57
  on:change={() => app.set($app)}
20
58
  />
@@ -5,7 +5,6 @@ export let componentInput;
5
5
  export let id;
6
6
  export let hasRows = false;
7
7
  const { onchange, worldStore, state } = getContext('AppViewerContext');
8
- $: componentInput && onchange?.();
9
8
  $: extraLib =
10
9
  componentInput?.expr && $worldStore
11
10
  ? buildExtraLib($worldStore?.outputsById ?? {}, id, hasRows, $state, false)
@@ -20,6 +19,11 @@ $: extraLib =
20
19
  shouldBindKey={false}
21
20
  {extraLib}
22
21
  autoHeight
22
+ on:change={() => {
23
+ if (onchange) {
24
+ onchange()
25
+ }
26
+ }}
23
27
  />
24
28
  </div>
25
29
  {/if}
@@ -37,9 +37,9 @@ function formatName(name) {
37
37
  }
38
38
  function select(label) {
39
39
  componentInput.value = label;
40
- if (document.activeElement?.blur) {
41
- ;
42
- document.activeElement.blur();
40
+ const elem = document.activeElement;
41
+ if (elem.blur) {
42
+ elem.blur();
43
43
  }
44
44
  }
45
45
  </script>
@@ -2,9 +2,10 @@
2
2
  export let code;
3
3
  export let value = undefined;
4
4
  export let error = '';
5
+ export let editor = undefined;
5
6
  function parseJson() {
6
7
  try {
7
- value = JSON.parse(code);
8
+ value = JSON.parse(code ?? '');
8
9
  error = '';
9
10
  }
10
11
  catch (e) {
@@ -16,7 +17,7 @@ $: code && parseJson();
16
17
 
17
18
  <div class="flex flex-col w-full">
18
19
  <div class="border border-gray-300 w-full">
19
- <SimpleEditor on:change autoHeight lang="json" bind:code />
20
+ <SimpleEditor on:focus bind:this={editor} on:change autoHeight lang="json" bind:code />
20
21
  </div>
21
22
  {#if error != ''}
22
23
  <span class="text-red-600 text-xs">{error}</span>
@@ -1,11 +1,14 @@
1
1
  import { SvelteComponentTyped } from "svelte";
2
+ import SimpleEditor from '../../../../SimpleEditor.svelte';
2
3
  declare const __propDef: {
3
4
  props: {
4
- code: string;
5
+ code: string | undefined;
5
6
  value?: any;
6
7
  error?: string | undefined;
8
+ editor?: SimpleEditor | undefined;
7
9
  };
8
10
  events: {
11
+ focus: CustomEvent<any>;
9
12
  change: CustomEvent<any>;
10
13
  } & {
11
14
  [evt: string]: CustomEvent<any>;
@@ -21,7 +21,7 @@ $: componentInput && onchange?.();
21
21
  </script>
22
22
 
23
23
  {#if componentInput?.type === 'static'}
24
- {#if fieldType === 'number'}
24
+ {#if fieldType === 'number' || fieldType === 'integer'}
25
25
  <input on:keydown|stopPropagation type="number" bind:value={componentInput.value} />
26
26
  {:else if fieldType === 'textarea'}
27
27
  <textarea on:keydown|stopPropagation bind:value={componentInput.value} />
@@ -75,7 +75,7 @@ $: componentInput && onchange?.();
75
75
  {/if}
76
76
  {:else if fieldType === 'color'}
77
77
  <ColorInput bind:value={componentInput.value} />
78
- {:else if fieldType === 'object'}
78
+ {:else if fieldType === 'object' || fieldType == 'labeledselect'}
79
79
  {#if format?.startsWith('resource-')}
80
80
  <ResourcePicker
81
81
  initialValue={componentInput.value?.split('$res:')[1] || ''}
@@ -1,6 +1,6 @@
1
1
  import type { ReadFileAs } from '../common/fileInput/model';
2
2
  import type { InlineScript } from './types';
3
- export type InputType = 'text' | 'textarea' | 'template' | 'number' | 'boolean' | 'select' | 'icon-select' | 'color' | 'date' | 'time' | 'datetime' | 'object' | 'array' | 'any' | 'labeledresource' | 'tab-select';
3
+ export type InputType = 'integer' | 'text' | 'textarea' | 'template' | 'number' | 'boolean' | 'select' | 'icon-select' | 'color' | 'date' | 'time' | 'datetime' | 'object' | 'array' | 'any' | 'labeledresource' | 'labeledselect' | 'tab-select';
4
4
  export type InputConnection = {
5
5
  componentId: string;
6
6
  path: string;
@@ -81,7 +81,7 @@ export type StaticOptions = {
81
81
  label: string;
82
82
  }[];
83
83
  };
84
- export type AppInput = AppInputSpec<'text', string> | AppInputSpec<'textarea', string> | AppInputSpec<'template', string> | AppInputSpec<'number', number> | AppInputSpec<'boolean', boolean> | AppInputSpec<'date', string> | AppInputSpec<'time', string> | AppInputSpec<'datetime', string> | AppInputSpec<'any', any> | AppInputSpec<'object', Record<string | number, any>> | AppInputSpec<'object', string> | (AppInputSpec<'select', string> & StaticOptions) | AppInputSpec<'icon-select', string> | AppInputSpec<'color', string> | AppInputSpec<'array', string[], 'text'> | AppInputSpec<'array', string[], 'textarea'> | AppInputSpec<'array', number[], 'number'> | AppInputSpec<'array', boolean[], 'boolean'> | AppInputSpec<'array', string[], 'date'> | AppInputSpec<'array', string[], 'time'> | AppInputSpec<'array', string[], 'datetime'> | AppInputSpec<'array', object[], 'object'> | (AppInputSpec<'array', string[], 'select'> & StaticOptions) | AppInputSpec<'array', object[], 'labeledresource'> | AppInputSpec<'labeledresource', object> | AppInputSpec<'array', object[], 'tab-select'>;
84
+ export type AppInput = AppInputSpec<'text', string> | AppInputSpec<'textarea', string> | AppInputSpec<'template', string> | AppInputSpec<'number', number> | AppInputSpec<'boolean', boolean> | AppInputSpec<'date', string> | AppInputSpec<'time', string> | AppInputSpec<'datetime', string> | AppInputSpec<'any', any> | AppInputSpec<'object', Record<string | number, any>> | AppInputSpec<'object', string> | (AppInputSpec<'select', string> & StaticOptions) | AppInputSpec<'icon-select', string> | AppInputSpec<'color', string> | AppInputSpec<'array', string[], 'text'> | AppInputSpec<'array', string[], 'textarea'> | AppInputSpec<'array', number[], 'number'> | AppInputSpec<'array', boolean[], 'boolean'> | AppInputSpec<'array', string[], 'date'> | AppInputSpec<'array', string[], 'time'> | AppInputSpec<'array', string[], 'datetime'> | AppInputSpec<'array', object[], 'object'> | (AppInputSpec<'array', string[], 'select'> & StaticOptions) | AppInputSpec<'array', object[], 'labeledresource'> | AppInputSpec<'array', object[], 'labeledselect'> | AppInputSpec<'labeledselect', object> | AppInputSpec<'labeledresource', object> | AppInputSpec<'array', object[], 'tab-select'>;
85
85
  export type RowAppInput = Extract<AppInput, {
86
86
  type: 'row';
87
87
  }>;
@@ -2,10 +2,10 @@ import type { AppInput } from './inputType';
2
2
  import { type Writable } from 'svelte/store';
3
3
  export interface Subscriber<T> {
4
4
  id?: string;
5
- next(v: T): any;
5
+ next(v: T): void;
6
6
  }
7
7
  export interface Observable<T> {
8
- subscribe(x: Subscriber<T>): any;
8
+ subscribe(x: Subscriber<T>): void;
9
9
  }
10
10
  export interface Output<T> extends Observable<T> {
11
11
  set(x: T, force?: boolean): void;
@@ -13,6 +13,7 @@ export let fastStart = false;
13
13
  export let throttleUpdate = 100;
14
14
  export let throttleResize = 100;
15
15
  export let selectedIds;
16
+ export let allIdsInPath;
16
17
  export let containerWidth = undefined;
17
18
  export let scroller = undefined;
18
19
  export let sensor = 20;
@@ -61,7 +62,6 @@ let sortedItems = [];
61
62
  $: sortedItems = JSON.parse(JSON.stringify(items)).sort((a, b) => a.id.localeCompare(b.id));
62
63
  let initItems = undefined;
63
64
  const updateMatrix = ({ detail }) => {
64
- console.log('updateMatrix', detail);
65
65
  let isPointerUp = detail.isPointerUp;
66
66
  let citems;
67
67
  if (isPointerUp) {
@@ -79,8 +79,12 @@ const updateMatrix = ({ detail }) => {
79
79
  }
80
80
  citems = JSON.parse(JSON.stringify(initItems));
81
81
  }
82
+ let nselectedIds = selectedIds ?? [];
83
+ if (detail.id && !selectedIds?.includes(detail.id)) {
84
+ nselectedIds = [detail.id, ...(selectedIds ?? [])];
85
+ }
82
86
  sortedItems = citems;
83
- for (let id of selectedIds ?? []) {
87
+ for (let id of nselectedIds) {
84
88
  let activeItem = getItemById(id, sortedItems);
85
89
  if (activeItem) {
86
90
  activeItem = {
@@ -93,7 +97,7 @@ const updateMatrix = ({ detail }) => {
93
97
  sortedItems = moveItem(activeItem, sortedItems, getComputedCols, getItemById(id, sortedItems));
94
98
  }
95
99
  }
96
- for (let id of selectedIds ?? []) {
100
+ for (let id of nselectedIds ?? []) {
97
101
  if (detail.activate) {
98
102
  moveResizes?.[id]?.inActivate();
99
103
  }
@@ -139,7 +143,7 @@ export function handleInitMove({ detail }) {
139
143
  bind:shadow={shadows[item.id]}
140
144
  bind:this={moveResizes[item.id]}
141
145
  on:repaint={handleRepaint}
142
- onTop={Boolean(selectedIds?.includes(item.id))}
146
+ onTop={Boolean(allIdsInPath?.includes(item.id))}
143
147
  id={item.id}
144
148
  {xPerPx}
145
149
  {yPerPx}
@@ -156,16 +160,9 @@ export function handleInitMove({ detail }) {
156
160
  {sensor}
157
161
  container={scroller}
158
162
  nativeContainer={container}
159
- let:resizePointerDown
160
- let:movePointerDown
161
163
  >
162
164
  {#if item[getComputedCols]}
163
- <slot
164
- {movePointerDown}
165
- {resizePointerDown}
166
- dataItem={item}
167
- item={item[getComputedCols]}
168
- />
165
+ <slot dataItem={item} item={item[getComputedCols]} />
169
166
  {/if}
170
167
  </MoveResize>
171
168
  {/each}
@@ -10,6 +10,7 @@ declare class __sveltets_Render<T> {
10
10
  throttleUpdate?: number | undefined;
11
11
  throttleResize?: number | undefined;
12
12
  selectedIds: string[] | undefined;
13
+ allIdsInPath: string[] | undefined;
13
14
  containerWidth?: number | undefined;
14
15
  scroller?: HTMLElement | undefined;
15
16
  sensor?: number | undefined;
@@ -30,12 +31,6 @@ declare class __sveltets_Render<T> {
30
31
  };
31
32
  slots(): {
32
33
  default: {
33
- movePointerDown: ({ clientX, clientY, target }: {
34
- clientX: any;
35
- clientY: any;
36
- target: any;
37
- }) => void;
38
- resizePointerDown: (e: any) => void;
39
34
  dataItem: FilledItem<T>;
40
35
  item: Required<import("./types").ItemLayout>;
41
36
  };