windmill-components 1.75.0 → 1.77.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.
- package/components/DisplayResult.svelte +1 -1
- package/components/Dropdown.svelte +14 -4
- package/components/FlowGraphViewer.svelte +1 -1
- package/components/FolderUsageInfo.svelte +16 -6
- package/components/FolderUsageInfo.svelte.d.ts +2 -0
- package/components/PageHeader.svelte +1 -1
- package/components/Path.svelte +22 -3
- package/components/ScriptBuilder.svelte +122 -122
- package/components/SettingSection.svelte +44 -0
- package/components/SettingSection.svelte.d.ts +21 -0
- package/components/Tooltip.svelte +3 -1
- package/components/WhitelistIp.svelte +1 -3
- package/components/apps/components/buttons/AppButton.svelte +11 -5
- package/components/apps/components/buttons/AppButton.svelte.d.ts +1 -0
- package/components/apps/components/buttons/AppForm.svelte +3 -7
- package/components/apps/components/buttons/AppFormButton.svelte +2 -6
- package/components/apps/components/display/table/AppAggridTable.svelte +4 -1
- package/components/apps/components/display/table/AppTable.svelte +4 -1
- package/components/apps/components/helpers/HiddenComponent.svelte +3 -0
- package/components/apps/components/helpers/HiddenComponent.svelte.d.ts +1 -0
- package/components/apps/components/helpers/InputValue.svelte +26 -43
- package/components/apps/components/helpers/InputValue.svelte.d.ts +4 -3
- package/components/apps/components/helpers/RefreshButton.svelte +2 -3
- package/components/apps/components/helpers/RunnableComponent.svelte +61 -34
- package/components/apps/components/helpers/RunnableComponent.svelte.d.ts +2 -0
- package/components/apps/components/helpers/RunnableWrapper.svelte +2 -0
- package/components/apps/components/helpers/RunnableWrapper.svelte.d.ts +1 -0
- package/components/apps/components/helpers/eval.d.ts +5 -0
- package/components/apps/components/helpers/eval.js +57 -0
- package/components/apps/components/layout/AppContainer.svelte +1 -6
- package/components/apps/components/layout/AppDrawer.svelte +0 -3
- package/components/apps/components/layout/AppSplitpanes.svelte +1 -6
- package/components/apps/components/layout/AppTabs.svelte +64 -33
- package/components/apps/components/layout/AppTabs.svelte.d.ts +1 -0
- package/components/apps/editor/AppEditor.svelte +136 -131
- package/components/apps/editor/AppEditorHeader.svelte +43 -35
- package/components/apps/editor/AppPreview.svelte +3 -2
- package/components/apps/editor/ComponentHeader.svelte +3 -1
- package/components/apps/editor/ComponentHeader.svelte.d.ts +1 -0
- package/components/apps/editor/GridEditor.svelte +53 -51
- package/components/apps/editor/RecomputeAllComponents.svelte +7 -1
- package/components/apps/editor/SettingsPanel.svelte +23 -10
- package/components/apps/editor/SubGridEditor.svelte +56 -52
- package/components/apps/editor/SubGridEditor.svelte.d.ts +3 -4
- package/components/apps/editor/appUtils.d.ts +12 -3
- package/components/apps/editor/appUtils.js +111 -37
- package/components/apps/editor/component/Component.svelte +4 -9
- package/components/apps/editor/component/ComponentNavigation.svelte +91 -46
- package/components/apps/editor/component/components.d.ts +1 -1
- package/components/apps/editor/component/components.js +24 -43
- package/components/apps/editor/componentsPanel/componentStaticValues.d.ts +1 -0
- package/components/apps/editor/componentsPanel/componentStaticValues.js +1 -0
- package/components/apps/editor/contextPanel/ComponentOutput.svelte +77 -0
- package/components/apps/editor/contextPanel/ComponentOutput.svelte.d.ts +21 -0
- package/components/apps/editor/contextPanel/ComponentOutputViewer.svelte +9 -5
- package/components/apps/editor/contextPanel/ContextPanel.svelte +80 -136
- package/components/apps/editor/contextPanel/SubGridOutput.svelte +71 -0
- package/components/apps/editor/contextPanel/SubGridOutput.svelte.d.ts +19 -0
- package/components/apps/editor/contextPanel/components/BackgroundScriptOutput.svelte +38 -0
- package/components/apps/editor/contextPanel/components/BackgroundScriptOutput.svelte.d.ts +19 -0
- package/components/apps/editor/contextPanel/components/BackgroundScriptsOutput.svelte +10 -0
- package/components/apps/editor/contextPanel/components/BackgroundScriptsOutput.svelte.d.ts +16 -0
- package/components/apps/editor/contextPanel/components/MinMaxButton.svelte +25 -0
- package/components/apps/editor/contextPanel/components/MinMaxButton.svelte.d.ts +16 -0
- package/components/apps/editor/contextPanel/components/OutputHeader.svelte +78 -0
- package/components/apps/editor/contextPanel/components/OutputHeader.svelte.d.ts +26 -0
- package/components/apps/editor/contextPanel/components/TableActionOutput.svelte +19 -0
- package/components/apps/editor/contextPanel/components/TableActionOutput.svelte.d.ts +18 -0
- package/components/apps/editor/contextPanel/components/TableActionsOutput.svelte +14 -0
- package/components/apps/editor/contextPanel/components/TableActionsOutput.svelte.d.ts +18 -0
- package/components/apps/editor/inlineScriptsPanel/EmptyInlineScript.svelte +53 -21
- package/components/apps/editor/inlineScriptsPanel/InlineScriptEditor.svelte +69 -43
- package/components/apps/editor/inlineScriptsPanel/InlineScriptEditorDrawer.svelte +1 -1
- package/components/apps/editor/settingsPanel/ArrayStaticInputEditor.svelte.d.ts +2 -2
- package/components/apps/editor/settingsPanel/ComponentPanel.svelte +32 -31
- package/components/apps/editor/settingsPanel/GridTab.svelte +4 -12
- package/components/apps/editor/settingsPanel/Recompute.svelte +1 -0
- package/components/apps/editor/settingsPanel/SelectedRunnable.svelte +6 -0
- package/components/apps/editor/settingsPanel/TableActions.svelte +2 -1
- package/components/apps/editor/settingsPanel/inputEditor/ConnectedInputEditor.svelte +2 -8
- package/components/apps/editor/settingsPanel/inputEditor/EvalInputEditor.svelte +2 -2
- package/components/apps/editor/settingsPanel/inputEditor/IconSelectInput.svelte +58 -46
- package/components/apps/editor/settingsPanel/inputEditor/JsonEditor.svelte +1 -1
- package/components/apps/editor/settingsPanel/inputEditor/JsonEditor.svelte.d.ts +2 -0
- package/components/apps/rx.d.ts +6 -4
- package/components/apps/rx.js +34 -14
- package/components/apps/svelte-grid/Grid.svelte +171 -0
- package/components/apps/svelte-grid/Grid.svelte.d.ts +47 -0
- package/components/apps/svelte-grid/LICENSE +23 -0
- package/components/apps/svelte-grid/MoveResize.svelte +328 -0
- package/components/apps/svelte-grid/MoveResize.svelte.d.ts +46 -0
- package/components/apps/svelte-grid/types.d.ts +25 -0
- package/components/apps/svelte-grid/utils/container.d.ts +1 -0
- package/components/apps/svelte-grid/utils/container.js +4 -0
- package/components/apps/svelte-grid/utils/helper.d.ts +14 -0
- package/components/apps/svelte-grid/utils/helper.js +36 -0
- package/components/apps/svelte-grid/utils/item.d.ts +14 -0
- package/components/apps/svelte-grid/utils/item.js +192 -0
- package/components/apps/svelte-grid/utils/matrix.d.ts +6 -0
- package/components/apps/svelte-grid/utils/matrix.js +53 -0
- package/components/apps/svelte-grid/utils/other.d.ts +3 -0
- package/components/apps/svelte-grid/utils/other.js +30 -0
- package/components/apps/types.d.ts +10 -7
- package/components/apps/utils.d.ts +1 -1
- package/components/apps/utils.js +13 -7
- package/components/common/CloseButton.svelte +18 -0
- package/components/common/CloseButton.svelte.d.ts +27 -0
- package/components/common/badge/Badge.svelte +6 -1
- package/components/common/badge/Badge.svelte.d.ts +1 -0
- package/components/common/drawer/DrawerContent.svelte +2 -6
- package/components/common/languageIcons/JavaScript.svelte +11 -0
- package/components/common/languageIcons/JavaScript.svelte.d.ts +25 -0
- package/components/common/languageIcons/LanguageIcon.svelte +3 -1
- package/components/common/languageIcons/LanguageIcon.svelte.d.ts +1 -1
- package/components/common/menu/Menu.svelte +1 -1
- package/components/common/popup/Popup.svelte +2 -1
- package/components/common/popup/Popup.svelte.d.ts +9 -0
- package/components/common/table/AppRow.svelte +1 -4
- package/components/common/table/FlowRow.svelte +1 -4
- package/components/common/table/ScriptRow.svelte +1 -4
- package/components/common/tabs/Tab.svelte +1 -0
- package/components/common/tabs/Tab.svelte.d.ts +2 -0
- package/components/flows/pickers/FlowScriptPicker.svelte.d.ts +1 -1
- package/components/graph/FlowGraph.svelte +1 -1
- package/components/sidebar/SidebarContent.svelte +2 -2
- package/consts.js +1 -1
- package/history.js +8 -1
- package/package.json +21 -27
- package/utils.js +0 -1
- package/components/apps/editor/settingsPanel/MoveToOtherGrid.svelte +0 -92
- package/components/apps/editor/settingsPanel/MoveToOtherGrid.svelte.d.ts +0 -18
- package/components/graph/svelvet/d3/controllers/README.md +0 -3
- package/components/graph/svelvet/d3/controllers/d3Old.d.ts +0 -1
- package/components/graph/svelvet/d3/controllers/d3Old.js +0 -43
- package/components/graph/svelvet/docs/CHANGELOG.md +0 -145
- package/components/graph/svelvet/docs/DESIGN_PATTERNS.md +0 -44
- package/components/graph/svelvet/docs/DOCUMENTATION.md +0 -5
- package/components/graph/svelvet/docs/README.md +0 -34
- package/components/graph/svelvet/docs/TODO.md +0 -14
- package/components/graph/svelvet/docs/Tutorials.md +0 -25
- package/components/graph/svelvet/docs/images/css-background-after.png +0 -0
- package/components/graph/svelvet/docs/images/css-background-before.png +0 -0
- package/components/graph/svelvet/docs/images/custom-edges-after.png +0 -0
- package/components/graph/svelvet/docs/images/custom-edges-before.png +0 -0
- package/components/graph/svelvet/docs/images/custom-nodes-after.png +0 -0
- package/components/graph/svelvet/docs/images/custom-nodes-before.png +0 -0
- package/components/graph/svelvet/docs/images/custom-svelte-components-after.png +0 -0
- package/components/graph/svelvet/docs/images/custom-svelte-components-before.png +0 -0
- package/components/graph/svelvet/docs/images/html-docs-after.png +0 -0
- package/components/graph/svelvet/docs/images/html-docs-before.png +0 -0
- package/components/graph/svelvet/docs/images/minimap-after.png +0 -0
- package/components/graph/svelvet/docs/images/minimap-before.png +0 -0
- package/components/graph/svelvet/docs/images/node-classes-after.png +0 -0
- package/components/graph/svelvet/docs/images/node-classes-before.png +0 -0
- package/components/graph/svelvet/docs/images/node-create-after.png +0 -0
- package/components/graph/svelvet/docs/images/node-create-before.png +0 -0
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
<script>import { getContext, afterUpdate
|
|
2
|
-
import Grid from '@windmill-labs/svelte-grid';
|
|
1
|
+
<script>import { getContext, afterUpdate } from 'svelte';
|
|
3
2
|
import { classNames } from '../../../utils';
|
|
4
3
|
import { columnConfiguration, disableDrag, enableDrag, isFixed, toggleFixed } from '../gridUtils';
|
|
5
4
|
import { twMerge } from 'tailwind-merge';
|
|
@@ -9,6 +8,8 @@ import Component from './component/Component.svelte';
|
|
|
9
8
|
import { deepEqual } from 'fast-equals';
|
|
10
9
|
import { push } from '../../../history';
|
|
11
10
|
import { expandGriditem, findGridItem } from './appUtils';
|
|
11
|
+
import Grid from '../svelte-grid/Grid.svelte';
|
|
12
|
+
import { settableOutput } from '../rx';
|
|
12
13
|
export let policy;
|
|
13
14
|
const { selectedComponent, app, mode, connectingInput, staticOutputs, runnableComponents, summary, focusedGrid, parentWidth, breakpoint } = getContext('AppViewerContext');
|
|
14
15
|
const { history } = getContext('AppEditorContext');
|
|
@@ -129,61 +130,61 @@ afterUpdate(() => {
|
|
|
129
130
|
<Grid
|
|
130
131
|
onTopId={$selectedComponent}
|
|
131
132
|
fillSpace={false}
|
|
132
|
-
|
|
133
|
+
items={$app.grid}
|
|
134
|
+
on:redraw={(e) => {
|
|
135
|
+
$app.grid = e.detail
|
|
136
|
+
}}
|
|
133
137
|
let:dataItem
|
|
134
138
|
rowHeight={36}
|
|
135
139
|
cols={columnConfiguration}
|
|
136
140
|
fastStart={true}
|
|
137
141
|
gap={[4, 2]}
|
|
138
142
|
>
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
{
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
</div>
|
|
185
|
-
{/if}
|
|
186
|
-
{/each}
|
|
143
|
+
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
|
144
|
+
{#if $connectingInput.opened}
|
|
145
|
+
<div
|
|
146
|
+
on:pointerenter={() => ($connectingInput.hoveredComponent = dataItem.id)}
|
|
147
|
+
on:pointerleave={() => ($connectingInput.hoveredComponent = undefined)}
|
|
148
|
+
class="absolute w-full h-full bg-black border-2 bg-opacity-25 z-20 flex justify-center items-center"
|
|
149
|
+
/>
|
|
150
|
+
<div
|
|
151
|
+
style="transform: translate(-50%, -50%);"
|
|
152
|
+
class="absolute w-fit justify-center bg-indigo-500/90 left-[50%] top-[50%] z-50 px-6 rounded border text-white py-2 text-5xl center-center"
|
|
153
|
+
>
|
|
154
|
+
{dataItem.data.id}
|
|
155
|
+
</div>
|
|
156
|
+
{/if}
|
|
157
|
+
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
|
158
|
+
<div
|
|
159
|
+
on:click|stopPropagation
|
|
160
|
+
on:pointerdown={() => selectComponent(dataItem.data.id)}
|
|
161
|
+
class={classNames(
|
|
162
|
+
'h-full w-full center-center',
|
|
163
|
+
$selectedComponent === dataItem.data.id ? 'active-grid-item' : ''
|
|
164
|
+
)}
|
|
165
|
+
>
|
|
166
|
+
<Component
|
|
167
|
+
render={true}
|
|
168
|
+
{pointerdown}
|
|
169
|
+
component={dataItem.data}
|
|
170
|
+
selected={$selectedComponent === dataItem.data.id}
|
|
171
|
+
locked={isFixed(dataItem)}
|
|
172
|
+
on:delete={() => removeGridElement(dataItem.data)}
|
|
173
|
+
on:lock={() => {
|
|
174
|
+
const gridItem = findGridItem($app, dataItem.data.id)
|
|
175
|
+
if (gridItem) {
|
|
176
|
+
toggleFixed(gridItem)
|
|
177
|
+
}
|
|
178
|
+
$app = $app
|
|
179
|
+
}}
|
|
180
|
+
on:expand={() => {
|
|
181
|
+
push(history, $app)
|
|
182
|
+
$selectedComponent = dataItem.data.id
|
|
183
|
+
expandGriditem($app.grid, dataItem, $breakpoint)
|
|
184
|
+
$app = $app
|
|
185
|
+
}}
|
|
186
|
+
/>
|
|
187
|
+
</div>
|
|
187
188
|
</Grid>
|
|
188
189
|
</div>
|
|
189
190
|
</div>
|
|
@@ -197,6 +198,7 @@ afterUpdate(() => {
|
|
|
197
198
|
inlineScript={script.inlineScript}
|
|
198
199
|
name={script.name}
|
|
199
200
|
fields={script.fields}
|
|
201
|
+
autoRefresh={script.autoRefresh ?? false}
|
|
200
202
|
bind:staticOutputs={$staticOutputs[`bg_${index}`]}
|
|
201
203
|
/>
|
|
202
204
|
{/if}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { ChevronDown, RefreshCw } from 'lucide-svelte';
|
|
3
3
|
import { getContext, onMount } from 'svelte';
|
|
4
4
|
import Button from '../../common/button/Button.svelte';
|
|
5
|
-
const { runnableComponents } = getContext('AppViewerContext');
|
|
5
|
+
const { runnableComponents, app } = getContext('AppViewerContext');
|
|
6
6
|
let loading = false;
|
|
7
7
|
let timeout = undefined;
|
|
8
8
|
let interval = undefined;
|
|
@@ -29,6 +29,12 @@ function setInter(inter) {
|
|
|
29
29
|
function refresh() {
|
|
30
30
|
loading = true;
|
|
31
31
|
Promise.all(Object.keys($runnableComponents).map((id) => {
|
|
32
|
+
if (id.startsWith('bg_')) {
|
|
33
|
+
let index = parseInt(id.split('_')[1]);
|
|
34
|
+
if (!$app.hiddenInlineScripts[index]?.autoRefresh) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
32
38
|
return $runnableComponents?.[id]?.();
|
|
33
39
|
})).finally(() => {
|
|
34
40
|
loading = false;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
<script>import
|
|
1
|
+
<script>import Toggle from '../../Toggle.svelte';
|
|
2
|
+
import { getContext } from 'svelte';
|
|
2
3
|
import GridPanel from './GridPanel.svelte';
|
|
3
4
|
import PanelSection from './settingsPanel/common/PanelSection.svelte';
|
|
4
5
|
import InputsSpecsEditor from './settingsPanel/InputsSpecsEditor.svelte';
|
|
@@ -17,15 +18,27 @@ const { selectedComponent, app, stateId } = getContext('AppViewerContext');
|
|
|
17
18
|
|
|
18
19
|
{#each $app?.hiddenInlineScripts ?? [] as script, index (script.name)}
|
|
19
20
|
{#if $selectedComponent === `bg_${index}`}
|
|
20
|
-
<
|
|
21
|
-
{
|
|
22
|
-
<
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
bind:inputSpecs={script.fields}
|
|
26
|
-
userInputEnabled={false}
|
|
21
|
+
<div class="min-h-full flex flex-col divide-y">
|
|
22
|
+
<PanelSection title={`Configuration`}>
|
|
23
|
+
<Toggle
|
|
24
|
+
bind:checked={script.autoRefresh}
|
|
25
|
+
options={{ right: 'Run on start and app refresh' }}
|
|
27
26
|
/>
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
</PanelSection>
|
|
28
|
+
|
|
29
|
+
{#if Object.keys(script.fields).length > 0}
|
|
30
|
+
<PanelSection title={`Inputs`}>
|
|
31
|
+
{#key $stateId}
|
|
32
|
+
<InputsSpecsEditor
|
|
33
|
+
id={`bg_${index}`}
|
|
34
|
+
shouldCapitalize={false}
|
|
35
|
+
bind:inputSpecs={script.fields}
|
|
36
|
+
userInputEnabled={false}
|
|
37
|
+
/>
|
|
38
|
+
{/key}
|
|
39
|
+
</PanelSection>
|
|
40
|
+
{/if}
|
|
41
|
+
<div class="grow shrink" />
|
|
42
|
+
</div>
|
|
30
43
|
{/if}
|
|
31
44
|
{/each}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
<script>import { classNames } from '../../../utils';
|
|
2
2
|
import { createEventDispatcher, getContext } from 'svelte';
|
|
3
|
-
import Grid from '@windmill-labs/svelte-grid';
|
|
4
3
|
import { twMerge } from 'tailwind-merge';
|
|
5
4
|
import { columnConfiguration, isFixed, toggleFixed } from '../gridUtils';
|
|
6
5
|
import Component from './component/Component.svelte';
|
|
7
6
|
import { expandGriditem, findGridItem } from './appUtils';
|
|
8
7
|
import { push } from '../../../history';
|
|
8
|
+
import Grid from '../svelte-grid/Grid.svelte';
|
|
9
9
|
export let containerHeight;
|
|
10
|
+
export let containerWidth = undefined;
|
|
10
11
|
let classes = '';
|
|
11
12
|
export { classes as class };
|
|
12
13
|
export let style = '';
|
|
@@ -46,18 +47,21 @@ function selectComponent(id) {
|
|
|
46
47
|
*/
|
|
47
48
|
}
|
|
48
49
|
}
|
|
49
|
-
function lock(
|
|
50
|
-
let fComponent = findGridItem($app,
|
|
50
|
+
function lock(dataItem) {
|
|
51
|
+
let fComponent = findGridItem($app, dataItem.data.id);
|
|
51
52
|
if (fComponent) {
|
|
52
53
|
fComponent = toggleFixed(fComponent);
|
|
53
54
|
}
|
|
55
|
+
$app = $app;
|
|
54
56
|
}
|
|
55
57
|
// @ts-ignore
|
|
56
58
|
let container;
|
|
57
59
|
</script>
|
|
58
60
|
|
|
59
61
|
<div
|
|
60
|
-
class="relative w-full subgrid {visible
|
|
62
|
+
class="translate-x-0 translate-y-0 relative w-full subgrid {visible
|
|
63
|
+
? 'visible'
|
|
64
|
+
: 'invisible h-0 overflow-hidden'} "
|
|
61
65
|
bind:this={container}
|
|
62
66
|
>
|
|
63
67
|
<div
|
|
@@ -74,7 +78,10 @@ let container;
|
|
|
74
78
|
>
|
|
75
79
|
<div class={highlight && $mode !== 'preview' ? 'border-gray-400 border border-dashed' : ''}>
|
|
76
80
|
<Grid
|
|
77
|
-
|
|
81
|
+
items={subGrid}
|
|
82
|
+
on:redraw={(e) => {
|
|
83
|
+
subGrid = e.detail
|
|
84
|
+
}}
|
|
78
85
|
let:dataItem
|
|
79
86
|
rowHeight={36}
|
|
80
87
|
cols={columnConfiguration}
|
|
@@ -82,57 +89,54 @@ let container;
|
|
|
82
89
|
gap={[4, 2]}
|
|
83
90
|
scroller={container}
|
|
84
91
|
parentWidth={$parentWidth - 17}
|
|
92
|
+
{containerWidth}
|
|
85
93
|
>
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
{
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
</div>
|
|
101
|
-
{/if}
|
|
94
|
+
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
|
95
|
+
{#if $connectingInput.opened}
|
|
96
|
+
<div
|
|
97
|
+
on:pointerenter={() => ($connectingInput.hoveredComponent = dataItem.data.id)}
|
|
98
|
+
on:pointerleave={() => ($connectingInput.hoveredComponent = undefined)}
|
|
99
|
+
class="absolute w-full h-full bg-black border-2 bg-opacity-25 z-20 flex justify-center items-center"
|
|
100
|
+
/>
|
|
101
|
+
<div
|
|
102
|
+
style="transform: translate(-50%, -50%);"
|
|
103
|
+
class="absolute w-fit justify-center bg-indigo-500/90 left-[50%] top-[50%] z-50 px-6 rounded border text-white py-2 text-5xl center-center"
|
|
104
|
+
>
|
|
105
|
+
{dataItem.data.id}
|
|
106
|
+
</div>
|
|
107
|
+
{/if}
|
|
102
108
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
109
|
+
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
|
110
|
+
<div
|
|
111
|
+
on:pointerdown={() => selectComponent(dataItem.data.id)}
|
|
112
|
+
class={classNames(
|
|
113
|
+
'h-full w-full center-center',
|
|
114
|
+
$selectedComponent === dataItem.data.id ? 'active-grid-item' : '',
|
|
115
|
+
dataItem.data.card ? 'border border-gray-100' : '',
|
|
116
|
+
'top-0'
|
|
117
|
+
)}
|
|
118
|
+
>
|
|
119
|
+
<Component
|
|
120
|
+
render={visible}
|
|
121
|
+
{pointerdown}
|
|
122
|
+
component={dataItem.data}
|
|
123
|
+
selected={$selectedComponent === dataItem.data.id}
|
|
124
|
+
locked={isFixed(dataItem)}
|
|
125
|
+
on:lock={() => lock(dataItem)}
|
|
126
|
+
on:expand={() => {
|
|
127
|
+
const parentGridItem = findGridItem($app, id)
|
|
122
128
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
129
|
+
if (!parentGridItem) {
|
|
130
|
+
return
|
|
131
|
+
}
|
|
132
|
+
$selectedComponent = dataItem.data.id
|
|
133
|
+
push(history, $app)
|
|
126
134
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
/>
|
|
133
|
-
</div>
|
|
134
|
-
{/if}
|
|
135
|
-
{/each}
|
|
135
|
+
expandGriditem(subGrid, dataItem, $breakpoint, parentGridItem)
|
|
136
|
+
$app = $app
|
|
137
|
+
}}
|
|
138
|
+
/>
|
|
139
|
+
</div>
|
|
136
140
|
</Grid>
|
|
137
141
|
</div>
|
|
138
142
|
</div>
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
import type { GridItem } from '../types';
|
|
2
3
|
declare const __propDef: {
|
|
3
4
|
props: {
|
|
4
5
|
containerHeight: number;
|
|
6
|
+
containerWidth?: number | undefined;
|
|
5
7
|
class?: string | undefined;
|
|
6
8
|
style?: string | undefined;
|
|
7
9
|
noPadding?: boolean | undefined;
|
|
8
10
|
noYPadding?: boolean | undefined;
|
|
9
|
-
subGrid?:
|
|
10
|
-
data: import("./component").AppComponent;
|
|
11
|
-
id: string;
|
|
12
|
-
}>[] | undefined;
|
|
11
|
+
subGrid?: GridItem[] | undefined;
|
|
13
12
|
visible?: boolean | undefined;
|
|
14
13
|
id: string;
|
|
15
14
|
shouldHighlight?: boolean | undefined;
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import type { App, EditorBreakpoint, FocusedGrid, GridItem } from '../types';
|
|
1
|
+
import type { App, ConnectingInput, EditorBreakpoint, FocusedGrid, GridItem } from '../types';
|
|
2
2
|
import { type AppComponent } from './component';
|
|
3
|
-
|
|
3
|
+
import type { Output, World } from '../rx';
|
|
4
|
+
export declare function findGridItemParentGrid(app: App, id: string): string | undefined;
|
|
5
|
+
export declare function isIdInsideGriditem(app: App, gridItem: GridItem, id: string | undefined): boolean;
|
|
4
6
|
export declare function findGridItem(app: App, id: string): GridItem | undefined;
|
|
5
7
|
export declare function getNextGridItemId(app: App): string;
|
|
6
8
|
export declare function createNewGridItem(grid: GridItem[], id: string, data: AppComponent): GridItem;
|
|
9
|
+
export declare function getGridItems(app: App, focusedGrid: FocusedGrid | undefined): GridItem[];
|
|
7
10
|
export declare function insertNewGridItem(app: App, data: AppComponent, focusedGrid: FocusedGrid | undefined, keepId?: boolean): string;
|
|
8
11
|
export declare function getAllSubgridsAndComponentIds(app: App, component: AppComponent): [string[], string[]];
|
|
9
12
|
export declare function deleteGridItem(app: App, component: AppComponent, parent: string | undefined, shouldKeepSubGrid: boolean): string[];
|
|
10
|
-
export declare function duplicateGridItem(app: App, parent: string | undefined, id: string): string | undefined;
|
|
11
13
|
type AvailableSpace = {
|
|
12
14
|
left: number;
|
|
13
15
|
right: number;
|
|
@@ -15,5 +17,12 @@ type AvailableSpace = {
|
|
|
15
17
|
bottom: number;
|
|
16
18
|
};
|
|
17
19
|
export declare function findAvailableSpace(grid: GridItem[], gridItem: GridItem, editorBreakpoint: EditorBreakpoint, parentGridItem?: GridItem | undefined): AvailableSpace | undefined;
|
|
20
|
+
type Outputtable<Type> = {
|
|
21
|
+
-readonly [Property in keyof Type]: Output<Type[Property]>;
|
|
22
|
+
};
|
|
23
|
+
export declare function initOutput<I extends Record<string, any>>(world: World | undefined, id: string, init: I): Outputtable<I>;
|
|
18
24
|
export declare function expandGriditem(grid: GridItem[], gridComponent: GridItem, $breakpoint: EditorBreakpoint, parentGridItem?: GridItem | undefined): void;
|
|
25
|
+
export declare function sortGridItemsPosition(gridItems: GridItem[], breakpoint: EditorBreakpoint): GridItem[];
|
|
26
|
+
export declare function connectInput(connectingInput: ConnectingInput, componentId: string, path: string): ConnectingInput;
|
|
27
|
+
export declare function recursivelyFilterKeyInJSON(json: object, search: string, extraSearch?: string | undefined): object;
|
|
19
28
|
export {};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { getNextId } from '../../flows/flowStateUtils';
|
|
2
2
|
import { getRecommendedDimensionsByComponent } from './component';
|
|
3
|
-
import gridHelp from '@windmill-labs/svelte-grid/src/utils/helper';
|
|
4
3
|
import { gridColumns } from '../gridUtils';
|
|
5
4
|
import { allItems } from '../utils';
|
|
5
|
+
import gridHelp from '../svelte-grid/utils/helper';
|
|
6
6
|
function findGridItemById(root, subGrids, id) {
|
|
7
7
|
for (const gridItem of allItems(root, subGrids)) {
|
|
8
8
|
if (gridItem.id === id) {
|
|
@@ -11,7 +11,7 @@ function findGridItemById(root, subGrids, id) {
|
|
|
11
11
|
}
|
|
12
12
|
return undefined;
|
|
13
13
|
}
|
|
14
|
-
export function
|
|
14
|
+
export function findGridItemParentGrid(app, id) {
|
|
15
15
|
const gridItem = app.grid.find((x) => x.id === id);
|
|
16
16
|
if (gridItem) {
|
|
17
17
|
return undefined;
|
|
@@ -21,11 +21,20 @@ export function findGridItemParentId(app, id) {
|
|
|
21
21
|
const subGrid = app.subgrids[key];
|
|
22
22
|
const gridItem = subGrid.find((x) => x.id === id);
|
|
23
23
|
if (gridItem) {
|
|
24
|
-
return key
|
|
24
|
+
return key;
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
|
+
export function isIdInsideGriditem(app, gridItem, id) {
|
|
30
|
+
const path = [];
|
|
31
|
+
let currentId = id;
|
|
32
|
+
while (currentId) {
|
|
33
|
+
path.push(currentId);
|
|
34
|
+
currentId = findGridItemParentGrid(app, currentId)?.split('-')[0];
|
|
35
|
+
}
|
|
36
|
+
return path.includes(gridItem.id);
|
|
37
|
+
}
|
|
29
38
|
export function findGridItem(app, id) {
|
|
30
39
|
return findGridItemById(app.grid, app.subgrids, id);
|
|
31
40
|
}
|
|
@@ -36,21 +45,20 @@ export function getNextGridItemId(app) {
|
|
|
36
45
|
return id;
|
|
37
46
|
}
|
|
38
47
|
export function createNewGridItem(grid, id, data) {
|
|
39
|
-
const appComponent = data;
|
|
40
|
-
appComponent.id = id;
|
|
41
48
|
const newComponent = {
|
|
42
49
|
resizable: true,
|
|
43
50
|
draggable: true,
|
|
44
51
|
x: 0,
|
|
45
52
|
y: 0
|
|
46
53
|
};
|
|
47
|
-
let newData = JSON.parse(JSON.stringify(
|
|
54
|
+
let newData = JSON.parse(JSON.stringify(data));
|
|
55
|
+
newData.id = id;
|
|
48
56
|
const newItem = {
|
|
49
57
|
data: newData,
|
|
50
58
|
id: id
|
|
51
59
|
};
|
|
52
60
|
gridColumns.forEach((column) => {
|
|
53
|
-
const rec = getRecommendedDimensionsByComponent(
|
|
61
|
+
const rec = getRecommendedDimensionsByComponent(newData.type, column);
|
|
54
62
|
newItem[column] = {
|
|
55
63
|
...newComponent,
|
|
56
64
|
min: { w: 1, h: 1 },
|
|
@@ -66,21 +74,20 @@ export function createNewGridItem(grid, id, data) {
|
|
|
66
74
|
});
|
|
67
75
|
return newItem;
|
|
68
76
|
}
|
|
69
|
-
export function
|
|
70
|
-
const id = keepId ? data.id : getNextGridItemId(app);
|
|
71
|
-
if (!app.subgrids) {
|
|
72
|
-
app.subgrids = {};
|
|
73
|
-
}
|
|
77
|
+
export function getGridItems(app, focusedGrid) {
|
|
74
78
|
if (!focusedGrid) {
|
|
75
|
-
|
|
76
|
-
app.grid.push(newItem);
|
|
79
|
+
return app.grid;
|
|
77
80
|
}
|
|
78
81
|
else {
|
|
79
82
|
const { parentComponentId, subGridIndex } = focusedGrid;
|
|
80
83
|
const key = `${parentComponentId}-${subGridIndex ?? 0}`;
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
+
return app?.subgrids?.[key] ?? [];
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
export function insertNewGridItem(app, data, focusedGrid, keepId) {
|
|
88
|
+
const id = keepId ? data.id : getNextGridItemId(app);
|
|
89
|
+
if (!app.subgrids) {
|
|
90
|
+
app.subgrids = {};
|
|
84
91
|
}
|
|
85
92
|
// We only want to set subgrids when we are not moving
|
|
86
93
|
if (!keepId) {
|
|
@@ -88,6 +95,15 @@ export function insertNewGridItem(app, data, focusedGrid, keepId) {
|
|
|
88
95
|
app.subgrids[`${id}-${i}`] = [];
|
|
89
96
|
}
|
|
90
97
|
}
|
|
98
|
+
const key = focusedGrid
|
|
99
|
+
? `${focusedGrid?.parentComponentId}-${focusedGrid?.subGridIndex ?? 0}`
|
|
100
|
+
: undefined;
|
|
101
|
+
let grid = focusedGrid ? app.subgrids[key] : app.grid;
|
|
102
|
+
const newItem = createNewGridItem(grid, id, data);
|
|
103
|
+
grid.push(newItem);
|
|
104
|
+
if (focusedGrid) {
|
|
105
|
+
app.subgrids[key] = grid;
|
|
106
|
+
}
|
|
91
107
|
return id;
|
|
92
108
|
}
|
|
93
109
|
export function getAllSubgridsAndComponentIds(app, component) {
|
|
@@ -131,24 +147,10 @@ export function deleteGridItem(app, component, parent, shouldKeepSubGrid) {
|
|
|
131
147
|
}
|
|
132
148
|
return components;
|
|
133
149
|
}
|
|
134
|
-
export function duplicateGridItem(app, parent, id) {
|
|
135
|
-
const gridItem = findGridItem(app, id);
|
|
136
|
-
if (gridItem) {
|
|
137
|
-
const newId = getNextGridItemId(app);
|
|
138
|
-
const newItem = JSON.parse(JSON.stringify(gridItem));
|
|
139
|
-
newItem.id = newId;
|
|
140
|
-
newItem.data.id = newId;
|
|
141
|
-
let focusedGrid = parent
|
|
142
|
-
? { parentComponentId: parent.split('-')[0], subGridIndex: Number(parent.split('-')[1]) }
|
|
143
|
-
: undefined;
|
|
144
|
-
return insertNewGridItem(app, newItem.data, focusedGrid);
|
|
145
|
-
}
|
|
146
|
-
return undefined;
|
|
147
|
-
}
|
|
148
150
|
export function findAvailableSpace(grid, gridItem, editorBreakpoint, parentGridItem = undefined) {
|
|
149
151
|
if (gridItem) {
|
|
150
152
|
const breakpoint = editorBreakpoint === 'sm' ? 3 : 12;
|
|
151
|
-
const maxHeight = parentGridItem ? parentGridItem[breakpoint].h - 1 :
|
|
153
|
+
const maxHeight = parentGridItem ? parentGridItem[breakpoint].h - 1 : 16;
|
|
152
154
|
const maxWidth = 12;
|
|
153
155
|
const availableSpace = {
|
|
154
156
|
left: 0,
|
|
@@ -226,6 +228,20 @@ function isOverlapping(item1, item2) {
|
|
|
226
228
|
item1.y < item2.y + item2.h &&
|
|
227
229
|
item1.y + item1.h > item2.y);
|
|
228
230
|
}
|
|
231
|
+
export function initOutput(world, id, init) {
|
|
232
|
+
if (!world) {
|
|
233
|
+
return {};
|
|
234
|
+
}
|
|
235
|
+
const output = world.outputsById[id];
|
|
236
|
+
if (init) {
|
|
237
|
+
for (const key in init) {
|
|
238
|
+
if (output && output[key] && output[key].peak() == undefined) {
|
|
239
|
+
output[key].set(init[key]);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
return output;
|
|
244
|
+
}
|
|
229
245
|
export function expandGriditem(grid, gridComponent, $breakpoint, parentGridItem = undefined) {
|
|
230
246
|
const availableSpace = findAvailableSpace(grid, gridComponent, $breakpoint, parentGridItem);
|
|
231
247
|
if (!availableSpace) {
|
|
@@ -233,9 +249,67 @@ export function expandGriditem(grid, gridComponent, $breakpoint, parentGridItem
|
|
|
233
249
|
}
|
|
234
250
|
const { left, right, top, bottom } = availableSpace;
|
|
235
251
|
const width = $breakpoint === 'sm' ? 3 : 12;
|
|
236
|
-
const
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
252
|
+
const item = gridComponent[width];
|
|
253
|
+
item.x = item.x - left;
|
|
254
|
+
item.y = item.y - top;
|
|
255
|
+
item.w = item.w + left + right;
|
|
256
|
+
item.h = item.h + top + bottom;
|
|
257
|
+
}
|
|
258
|
+
export function sortGridItemsPosition(gridItems, breakpoint) {
|
|
259
|
+
return gridItems.sort((a, b) => {
|
|
260
|
+
const width = breakpoint === 'lg' ? 12 : 3;
|
|
261
|
+
const aX = a[width].x;
|
|
262
|
+
const aY = a[width].y;
|
|
263
|
+
const bX = b[width].x;
|
|
264
|
+
const bY = b[width].y;
|
|
265
|
+
if (aY < bY) {
|
|
266
|
+
return -1;
|
|
267
|
+
}
|
|
268
|
+
else if (aY > bY) {
|
|
269
|
+
return 1;
|
|
270
|
+
}
|
|
271
|
+
else {
|
|
272
|
+
if (aX < bX) {
|
|
273
|
+
return -1;
|
|
274
|
+
}
|
|
275
|
+
else if (aX > bX) {
|
|
276
|
+
return 1;
|
|
277
|
+
}
|
|
278
|
+
else {
|
|
279
|
+
return 0;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
export function connectInput(connectingInput, componentId, path) {
|
|
285
|
+
if (connectingInput) {
|
|
286
|
+
connectingInput = {
|
|
287
|
+
opened: false,
|
|
288
|
+
input: {
|
|
289
|
+
connection: {
|
|
290
|
+
componentId,
|
|
291
|
+
path
|
|
292
|
+
},
|
|
293
|
+
type: 'connected'
|
|
294
|
+
},
|
|
295
|
+
hoveredComponent: undefined
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
return connectingInput;
|
|
299
|
+
}
|
|
300
|
+
export function recursivelyFilterKeyInJSON(json, search, extraSearch) {
|
|
301
|
+
let filteredJSON = {};
|
|
302
|
+
Object.keys(json).forEach((key) => {
|
|
303
|
+
if (key.toLowerCase().includes(search.toLowerCase()) ||
|
|
304
|
+
extraSearch?.toLowerCase().includes(search.toLowerCase())) {
|
|
305
|
+
filteredJSON[key] = json[key];
|
|
306
|
+
}
|
|
307
|
+
else if (typeof json[key] === 'object') {
|
|
308
|
+
const res = recursivelyFilterKeyInJSON(json[key], search, extraSearch);
|
|
309
|
+
if (Object.keys(res).length !== 0) {
|
|
310
|
+
filteredJSON[key] = res;
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
});
|
|
314
|
+
return filteredJSON;
|
|
241
315
|
}
|