svelte-tweakpane-ui 1.0.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/LICENSE +21 -0
- package/README.md +36 -0
- package/dist/control/ButtonGrid.svelte +49 -0
- package/dist/control/ButtonGrid.svelte.d.ts +190 -0
- package/dist/control/Checkbox.svelte +6 -0
- package/dist/control/Checkbox.svelte.d.ts +113 -0
- package/dist/control/Color.svelte +79 -0
- package/dist/control/Color.svelte.d.ts +177 -0
- package/dist/control/CubicBezier.svelte +74 -0
- package/dist/control/CubicBezier.svelte.d.ts +204 -0
- package/dist/control/Image.svelte +23 -0
- package/dist/control/Image.svelte.d.ts +177 -0
- package/dist/control/IntervalSlider.svelte +37 -0
- package/dist/control/IntervalSlider.svelte.d.ts +196 -0
- package/dist/control/List.svelte +69 -0
- package/dist/control/List.svelte.d.ts +122 -0
- package/dist/control/Point.svelte +100 -0
- package/dist/control/Point.svelte.d.ts +374 -0
- package/dist/control/RadioGrid.svelte +42 -0
- package/dist/control/RadioGrid.svelte.d.ts +231 -0
- package/dist/control/Ring.svelte +19 -0
- package/dist/control/Ring.svelte.d.ts +220 -0
- package/dist/control/RotationEuler.svelte +67 -0
- package/dist/control/RotationEuler.svelte.d.ts +273 -0
- package/dist/control/RotationQuaternion.svelte +65 -0
- package/dist/control/RotationQuaternion.svelte.d.ts +276 -0
- package/dist/control/Slider.svelte +6 -0
- package/dist/control/Slider.svelte.d.ts +165 -0
- package/dist/control/Text.svelte +25 -0
- package/dist/control/Text.svelte.d.ts +129 -0
- package/dist/control/Textarea.svelte +47 -0
- package/dist/control/Textarea.svelte.d.ts +149 -0
- package/dist/control/Wheel.svelte +15 -0
- package/dist/control/Wheel.svelte.d.ts +186 -0
- package/dist/core/Binding.svelte +68 -0
- package/dist/core/Binding.svelte.d.ts +116 -0
- package/dist/core/Blade.svelte +61 -0
- package/dist/core/Blade.svelte.d.ts +90 -0
- package/dist/core/Button.svelte +59 -0
- package/dist/core/Button.svelte.d.ts +65 -0
- package/dist/core/Folder.svelte +69 -0
- package/dist/core/Folder.svelte.d.ts +78 -0
- package/dist/core/Pane.svelte +51 -0
- package/dist/core/Pane.svelte.d.ts +500 -0
- package/dist/core/Separator.svelte +14 -0
- package/dist/core/Separator.svelte.d.ts +85 -0
- package/dist/core/TabGroup.svelte +64 -0
- package/dist/core/TabGroup.svelte.d.ts +72 -0
- package/dist/core/TabPage.svelte +85 -0
- package/dist/core/TabPage.svelte.d.ts +82 -0
- package/dist/extra/AutoObject.svelte +46 -0
- package/dist/extra/AutoObject.svelte.d.ts +108 -0
- package/dist/extra/AutoValue.svelte +11 -0
- package/dist/extra/AutoValue.svelte.d.ts +123 -0
- package/dist/extra/Element.svelte +53 -0
- package/dist/extra/Element.svelte.d.ts +170 -0
- package/dist/index.d.ts +94 -0
- package/dist/index.js +39 -0
- package/dist/internal/ClsPad.svelte +34 -0
- package/dist/internal/ClsPad.svelte.d.ts +95 -0
- package/dist/internal/GenericBinding.svelte +22 -0
- package/dist/internal/GenericBinding.svelte.d.ts +116 -0
- package/dist/internal/GenericBladeFolding.svelte +38 -0
- package/dist/internal/GenericBladeFolding.svelte.d.ts +95 -0
- package/dist/internal/GenericInput.svelte +19 -0
- package/dist/internal/GenericInput.svelte.d.ts +116 -0
- package/dist/internal/GenericInputFolding.svelte +40 -0
- package/dist/internal/GenericInputFolding.svelte.d.ts +140 -0
- package/dist/internal/GenericMonitor.svelte +24 -0
- package/dist/internal/GenericMonitor.svelte.d.ts +139 -0
- package/dist/internal/GenericPane.svelte +100 -0
- package/dist/internal/GenericPane.svelte.d.ts +84 -0
- package/dist/internal/GenericSlider.svelte +27 -0
- package/dist/internal/GenericSlider.svelte.d.ts +146 -0
- package/dist/internal/InternalMonitorBoolean.svelte +17 -0
- package/dist/internal/InternalMonitorBoolean.svelte.d.ts +154 -0
- package/dist/internal/InternalMonitorNumber.svelte +31 -0
- package/dist/internal/InternalMonitorNumber.svelte.d.ts +178 -0
- package/dist/internal/InternalMonitorString.svelte +23 -0
- package/dist/internal/InternalMonitorString.svelte.d.ts +162 -0
- package/dist/internal/InternalPaneDraggable.svelte +368 -0
- package/dist/internal/InternalPaneDraggable.svelte.d.ts +178 -0
- package/dist/internal/InternalPaneFixed.svelte +28 -0
- package/dist/internal/InternalPaneFixed.svelte.d.ts +119 -0
- package/dist/internal/InternalPaneInline.svelte +29 -0
- package/dist/internal/InternalPaneInline.svelte.d.ts +106 -0
- package/dist/monitor/FpsGraph.svelte +86 -0
- package/dist/monitor/FpsGraph.svelte.d.ts +230 -0
- package/dist/monitor/Monitor.svelte +14 -0
- package/dist/monitor/Monitor.svelte.d.ts +526 -0
- package/dist/monitor/Profiler.svelte +72 -0
- package/dist/monitor/Profiler.svelte.d.ts +265 -0
- package/dist/monitor/WaveformMonitor.svelte +26 -0
- package/dist/monitor/WaveformMonitor.svelte.d.ts +176 -0
- package/dist/theme.d.ts +91 -0
- package/dist/theme.js +332 -0
- package/dist/utils.d.ts +157 -0
- package/dist/utils.js +238 -0
- package/package.json +280 -0
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { SvelteComponent } from 'svelte';
|
|
2
|
+
import type { Theme } from '../theme.js';
|
|
3
|
+
declare const __propDef: {
|
|
4
|
+
props: {
|
|
5
|
+
/**
|
|
6
|
+
* Prevent interactivity and gray out the control.
|
|
7
|
+
* @default `false`
|
|
8
|
+
* */ disabled?: boolean | undefined;
|
|
9
|
+
/**
|
|
10
|
+
* Active page index.
|
|
11
|
+
*
|
|
12
|
+
* Note that SSR will always render the first page height, regardless of the initial active
|
|
13
|
+
* index.
|
|
14
|
+
* @default `0`
|
|
15
|
+
* @bindable
|
|
16
|
+
* */ selectedIndex?: number | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* Custom color scheme.
|
|
19
|
+
* @default `undefined` \
|
|
20
|
+
* Inherits default Tweakpane theme equivalent to `ThemeUtils.presets.standard`, or the theme
|
|
21
|
+
* set with `setGlobalDefaultTheme()`.
|
|
22
|
+
* */ theme?: Theme | undefined;
|
|
23
|
+
};
|
|
24
|
+
events: {
|
|
25
|
+
[evt: string]: CustomEvent<any>;
|
|
26
|
+
};
|
|
27
|
+
slots: {
|
|
28
|
+
/**
|
|
29
|
+
* A `<TabPage>` component.
|
|
30
|
+
*/
|
|
31
|
+
default: {};
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
export type TabGroupProps = typeof __propDef.props;
|
|
35
|
+
export type TabGroupEvents = typeof __propDef.events;
|
|
36
|
+
export type TabGroupSlots = typeof __propDef.slots;
|
|
37
|
+
/**
|
|
38
|
+
* Contains a collection of `<TabPage>` components to be presented as a tabs.
|
|
39
|
+
*
|
|
40
|
+
* Wrapper around Tweakpane's [`addTab`](https://tweakpane.github.io/docs/ui-components/#tab) method.
|
|
41
|
+
*
|
|
42
|
+
* The name of this concept within the underlying vanilla JS Tweakpane API is `tab`, but it has been
|
|
43
|
+
* changed to `TabGroup` in _Svelte Tweakpane UI_ to clarify it's relationship to the `<TabPage>`
|
|
44
|
+
* component.
|
|
45
|
+
*
|
|
46
|
+
* Usage outside of a `<Pane>` component will implicitly wrap the tab in `<Pane position='inline'>`.
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```svelte
|
|
50
|
+
* <script lang="ts">
|
|
51
|
+
* import { Button, TabGroup, TabPage } from 'svelte-tweakpane-ui';
|
|
52
|
+
* </script>
|
|
53
|
+
*
|
|
54
|
+
* <TabGroup>
|
|
55
|
+
* <TabPage title="A">
|
|
56
|
+
* <Button on:click={() => alert('A...')} title="Button A" />
|
|
57
|
+
* </TabPage>
|
|
58
|
+
* <TabPage title="B">
|
|
59
|
+
* <Button on:click={() => alert('B...')} title="Button B" />
|
|
60
|
+
* </TabPage>
|
|
61
|
+
* </TabGroup>
|
|
62
|
+
* ```
|
|
63
|
+
*
|
|
64
|
+
* @sourceLink
|
|
65
|
+
* [TabGroup.svelte](https://github.com/kitschpatrol/svelte-tweakpane-ui/blob/main/src/lib/core/TabGroup.svelte)
|
|
66
|
+
*/
|
|
67
|
+
export default class TabGroup extends SvelteComponent<
|
|
68
|
+
TabGroupProps,
|
|
69
|
+
TabGroupEvents,
|
|
70
|
+
TabGroupSlots
|
|
71
|
+
> {}
|
|
72
|
+
export {};
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import TabGroup from './TabGroup.svelte';
|
|
3
|
+
import ClsPad from '../internal/ClsPad.svelte';
|
|
4
|
+
import InternalPaneInline from '../internal/InternalPaneInline.svelte';
|
|
5
|
+
import { getElementIndex, isRootPane } from '../utils.js';
|
|
6
|
+
import { BROWSER } from 'esm-env';
|
|
7
|
+
import { getContext, onDestroy, onMount, setContext } from 'svelte';
|
|
8
|
+
import { writable } from 'svelte/store';
|
|
9
|
+
export let title = 'Tab Page';
|
|
10
|
+
export let disabled = false;
|
|
11
|
+
export let selected = false;
|
|
12
|
+
export let theme = void 0;
|
|
13
|
+
const tabGroupStore = getContext('tabGroupStore');
|
|
14
|
+
const tabIndexStore = getContext('tabIndexStore');
|
|
15
|
+
const userCreatedPane = getContext('userCreatedPane');
|
|
16
|
+
const parentStore = getContext('parentStore');
|
|
17
|
+
const tabPageStore = writable();
|
|
18
|
+
setContext('parentStore', tabPageStore);
|
|
19
|
+
let indexElement;
|
|
20
|
+
let index;
|
|
21
|
+
onMount(() => {
|
|
22
|
+
index = indexElement ? getElementIndex(indexElement) : 0;
|
|
23
|
+
});
|
|
24
|
+
function create() {
|
|
25
|
+
if (!$tabGroupStore) {
|
|
26
|
+
$tabGroupStore = $parentStore.addTab({
|
|
27
|
+
// tabs MUST be created with at least one page how to handle tabs with no children?
|
|
28
|
+
disabled: false,
|
|
29
|
+
index: $tabIndexStore,
|
|
30
|
+
// could be cleaner to have children create the tab as needed?
|
|
31
|
+
pages: [{ title }]
|
|
32
|
+
});
|
|
33
|
+
$tabPageStore = $tabGroupStore.pages[0];
|
|
34
|
+
selected = true;
|
|
35
|
+
} else if (!$tabPageStore && $tabGroupStore) {
|
|
36
|
+
$tabPageStore = $tabGroupStore.addPage({ index, title });
|
|
37
|
+
}
|
|
38
|
+
$tabGroupStore?.on('select', () => {
|
|
39
|
+
$tabPageStore && (selected = $tabPageStore.selected);
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
onDestroy(() => {
|
|
43
|
+
$tabPageStore?.dispose();
|
|
44
|
+
});
|
|
45
|
+
$: index !== void 0 && $parentStore && $tabIndexStore !== void 0 && create();
|
|
46
|
+
$: $tabPageStore && ($tabPageStore.title = title);
|
|
47
|
+
$: $tabPageStore && ($tabPageStore.disabled = disabled);
|
|
48
|
+
$: $tabPageStore && ($tabPageStore.selected = selected);
|
|
49
|
+
$: theme &&
|
|
50
|
+
$parentStore &&
|
|
51
|
+
(userCreatedPane || !isRootPane($parentStore)) &&
|
|
52
|
+
console.warn(
|
|
53
|
+
'Set theme on the <Pane> component, not on its children! (Check nested <TabPage> components for a theme prop.)'
|
|
54
|
+
);
|
|
55
|
+
</script>
|
|
56
|
+
|
|
57
|
+
{#if parentStore && tabIndexStore !== undefined}
|
|
58
|
+
{#if BROWSER}
|
|
59
|
+
<div bind:this={indexElement} style="display: none;">
|
|
60
|
+
<slot />
|
|
61
|
+
</div>
|
|
62
|
+
{:else}
|
|
63
|
+
<div class="ssr-tab-page">
|
|
64
|
+
<!-- Tab bar -->
|
|
65
|
+
<ClsPad keysAdd={['containerUnitSize']} {theme} />
|
|
66
|
+
<slot />
|
|
67
|
+
</div>
|
|
68
|
+
{/if}
|
|
69
|
+
{:else}
|
|
70
|
+
<InternalPaneInline {theme} userCreatedPane={false}>
|
|
71
|
+
<TabGroup>
|
|
72
|
+
<svelte:self {disabled} {selected} {theme} {title}>
|
|
73
|
+
<slot />
|
|
74
|
+
</svelte:self>
|
|
75
|
+
</TabGroup>
|
|
76
|
+
</InternalPaneInline>
|
|
77
|
+
{/if}
|
|
78
|
+
|
|
79
|
+
<style>
|
|
80
|
+
/* Measure only the first (most likely active) tab */
|
|
81
|
+
div.ssr-tab-page:not(:first-child) {
|
|
82
|
+
overflow: hidden;
|
|
83
|
+
display: none;
|
|
84
|
+
}
|
|
85
|
+
</style>
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { SvelteComponent } from 'svelte';
|
|
2
|
+
import type { Theme } from '../theme.js';
|
|
3
|
+
declare const __propDef: {
|
|
4
|
+
props: {
|
|
5
|
+
/**
|
|
6
|
+
* Text in the tab.
|
|
7
|
+
* @default `'Tab Page'`
|
|
8
|
+
* */ title?: string | undefined;
|
|
9
|
+
/**
|
|
10
|
+
* Prevent interactivity and gray out the control.
|
|
11
|
+
* @default `false`
|
|
12
|
+
* */ disabled?: boolean | undefined;
|
|
13
|
+
/**
|
|
14
|
+
* Sets the page is the active tab.
|
|
15
|
+
*
|
|
16
|
+
* When bound it will indicate whether the tab is active.
|
|
17
|
+
* @default `false`
|
|
18
|
+
* @bindable
|
|
19
|
+
* */ selected?: boolean | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* Custom color scheme.
|
|
22
|
+
* @default `undefined` \
|
|
23
|
+
* Inherits default Tweakpane theme equivalent to `ThemeUtils.presets.standard`, or the theme
|
|
24
|
+
* set with `setGlobalDefaultTheme()`.)
|
|
25
|
+
* */ theme?: Theme | undefined;
|
|
26
|
+
};
|
|
27
|
+
events: {
|
|
28
|
+
[evt: string]: CustomEvent<any>;
|
|
29
|
+
};
|
|
30
|
+
slots: {
|
|
31
|
+
/**
|
|
32
|
+
* Any Tweakpane component, except a `<Pane>`.
|
|
33
|
+
*/
|
|
34
|
+
default: {};
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
export type TabPageProps = typeof __propDef.props;
|
|
38
|
+
export type TabPageEvents = typeof __propDef.events;
|
|
39
|
+
export type TabPageSlots = typeof __propDef.slots;
|
|
40
|
+
/**
|
|
41
|
+
* Contains a collection of Tweakpane controls to be presented as a single group inside a `<TabGroup>`
|
|
42
|
+
* component.
|
|
43
|
+
*
|
|
44
|
+
* Provides `page` values to Tweakpane's
|
|
45
|
+
* [`addTab`](https://tweakpane.github.io/docs/ui-components/#tab) method.
|
|
46
|
+
*
|
|
47
|
+
* The name of this concept within the underlying vanilla JS Tweakpane API is `page`, but it has been
|
|
48
|
+
* changed to `TabPage` in _Svelte Tweakpane UI_ for clarity its relationship to the `<TabGroup>`
|
|
49
|
+
* component.
|
|
50
|
+
*
|
|
51
|
+
* Usage outside of a `<TabGroup>` component wouldn't make much sense, but in such cases the
|
|
52
|
+
* `<TabPage>` will be implicitly wrapped in a `<TabGroup>` and `<Pane position='inline'>`.
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```svelte
|
|
56
|
+
* <script lang="ts">
|
|
57
|
+
* import { Button, TabGroup, TabPage } from 'svelte-tweakpane-ui';
|
|
58
|
+
*
|
|
59
|
+
* let countA = 0;
|
|
60
|
+
* let countB = 0;
|
|
61
|
+
* </script>
|
|
62
|
+
*
|
|
63
|
+
* <TabGroup>
|
|
64
|
+
* <TabPage title="A">
|
|
65
|
+
* <Button on:click={() => countA++} title="Button A" />
|
|
66
|
+
* </TabPage>
|
|
67
|
+
* <TabPage title="B">
|
|
68
|
+
* <Button on:click={() => countB++} title="Button B" />
|
|
69
|
+
* </TabPage>
|
|
70
|
+
* </TabGroup>
|
|
71
|
+
*
|
|
72
|
+
* <pre>
|
|
73
|
+
* Count A: {countA}
|
|
74
|
+
* Count B: {countB}
|
|
75
|
+
* </pre>
|
|
76
|
+
* ```
|
|
77
|
+
*
|
|
78
|
+
* @sourceLink
|
|
79
|
+
* [TabPage.svelte](https://github.com/kitschpatrol/svelte-tweakpane-ui/blob/main/src/lib/core/TabPage.svelte)
|
|
80
|
+
*/
|
|
81
|
+
export default class TabPage extends SvelteComponent<TabPageProps, TabPageEvents, TabPageSlots> {}
|
|
82
|
+
export {};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { isColorObject } from '@tweakpane/core';
|
|
3
|
+
import { Point2d } from '@tweakpane/core/dist/input-binding/point-2d/model/point-2d.js';
|
|
4
|
+
import { Point3d } from '@tweakpane/core/dist/input-binding/point-3d/model/point-3d.js';
|
|
5
|
+
import { Point4d } from '@tweakpane/core/dist/input-binding/point-4d/model/point-4d.js';
|
|
6
|
+
import Text from '../control/Text.svelte';
|
|
7
|
+
import Binding from '../core/Binding.svelte';
|
|
8
|
+
import Folder from '../core/Folder.svelte';
|
|
9
|
+
import InternalPaneInline from '../internal/InternalPaneInline.svelte';
|
|
10
|
+
import { getContext } from 'svelte';
|
|
11
|
+
export let theme = void 0;
|
|
12
|
+
export let prettyLabels = true;
|
|
13
|
+
export let object;
|
|
14
|
+
const parentStore = getContext('parentStore');
|
|
15
|
+
function isPointObject(obj) {
|
|
16
|
+
return Point2d.isObject(obj) || Point3d.isObject(obj) || Point4d.isObject(obj);
|
|
17
|
+
}
|
|
18
|
+
function prettify(value, active = true) {
|
|
19
|
+
if (!active) return value;
|
|
20
|
+
return value
|
|
21
|
+
.replace(/([a-z0-9])([A-Z])/g, '$1 $2')
|
|
22
|
+
.replace(/[_-]+/g, ' ')
|
|
23
|
+
.toLowerCase()
|
|
24
|
+
.replace(/\b[a-z]/g, (letter) => {
|
|
25
|
+
return letter.toUpperCase();
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
</script>
|
|
29
|
+
|
|
30
|
+
{#if parentStore}
|
|
31
|
+
{#each Object.keys(object) as key (key)}
|
|
32
|
+
{#if object[key].constructor === Object && !isColorObject(object[key]) && !isPointObject(object[key])}
|
|
33
|
+
<Folder title={prettify(key, prettyLabels)}>
|
|
34
|
+
<svelte:self bind:object={object[key]} bind:prettyLabels />
|
|
35
|
+
</Folder>
|
|
36
|
+
{:else if typeof object[key] === 'string'}
|
|
37
|
+
<Text bind:value={object[key]} label={prettify(key, prettyLabels)} />
|
|
38
|
+
{:else}
|
|
39
|
+
<Binding bind:object {key} label={prettify(key, prettyLabels)} />
|
|
40
|
+
{/if}
|
|
41
|
+
{/each}
|
|
42
|
+
{:else}
|
|
43
|
+
<InternalPaneInline {theme} userCreatedPane={false}>
|
|
44
|
+
<svelte:self bind:object bind:prettyLabels />
|
|
45
|
+
</InternalPaneInline>
|
|
46
|
+
{/if}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { SvelteComponent } from 'svelte';
|
|
2
|
+
import type { Theme } from '../theme.js';
|
|
3
|
+
import type { BindingObject } from '../utils.js';
|
|
4
|
+
declare const __propDef: {
|
|
5
|
+
props: {
|
|
6
|
+
/**
|
|
7
|
+
* Custom color scheme.
|
|
8
|
+
* @default `undefined` \
|
|
9
|
+
* Inherits default Tweakpane theme equivalent to `ThemeUtils.presets.standard`, or the theme
|
|
10
|
+
* set with `setGlobalDefaultTheme()`.
|
|
11
|
+
* */ theme?: Theme | undefined;
|
|
12
|
+
/**
|
|
13
|
+
* Transforms keys into more pleasant control labels (e.g. capitalization and spaces in lieu of
|
|
14
|
+
* camelCase, kebab-case, etc.)
|
|
15
|
+
* @default `true`
|
|
16
|
+
* */ prettyLabels?: boolean | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* Object to create an automatic set of Tweakpane controls for.
|
|
19
|
+
*
|
|
20
|
+
* Keys will be used as labels, and a (reasonably) appropriate Tweakpane control will be used
|
|
21
|
+
* for each value's type.
|
|
22
|
+
* @bindable
|
|
23
|
+
* */ object: BindingObject;
|
|
24
|
+
};
|
|
25
|
+
events: {
|
|
26
|
+
[evt: string]: CustomEvent<any>;
|
|
27
|
+
};
|
|
28
|
+
slots: {};
|
|
29
|
+
};
|
|
30
|
+
export type AutoObjectProps = typeof __propDef.props;
|
|
31
|
+
export type AutoObjectEvents = typeof __propDef.events;
|
|
32
|
+
export type AutoObjectSlots = typeof __propDef.slots;
|
|
33
|
+
/**
|
|
34
|
+
* Rapid-development component which automatically creates a set of Tweakpane controls for an arbitrary
|
|
35
|
+
* object.
|
|
36
|
+
*
|
|
37
|
+
* Object keys will be used as labels, and a (reasonably) appropriate Tweakpane control will be used
|
|
38
|
+
* for each value's type.
|
|
39
|
+
*
|
|
40
|
+
* Values are generally mapped to controls according to the logic outlined in the [Tweakpane input
|
|
41
|
+
* binding documentation](https://tweakpane.github.io/docs/input-bindings/).
|
|
42
|
+
*
|
|
43
|
+
* This component is intended for quick tests where you want "best guess" non-customizable controls for
|
|
44
|
+
* an entire object, without considering the ideal component for each value.
|
|
45
|
+
*
|
|
46
|
+
* See `<AutoValue>` for a variation that works directly on a stand-alone value that isn't wrapped in
|
|
47
|
+
* an object.
|
|
48
|
+
*
|
|
49
|
+
* Records within the object will wrap their contents in a `<Folder>` component. Value objects in the
|
|
50
|
+
* shape of color or point objects will show a more specialized control.
|
|
51
|
+
*
|
|
52
|
+
* Usage outside of a `<Pane>` component will implicitly wrap the component in `<Pane
|
|
53
|
+
* position='inline'>`.
|
|
54
|
+
*
|
|
55
|
+
* `<AutoObject>` was inspired by the
|
|
56
|
+
* [`<TWPAutoMutable>`](https://github.com/MrFoxPro/solid-tweakpane/blob/master/src/automutable.tsx)
|
|
57
|
+
* component in [Dmitriy Nikiforov's](https://github.com/MrFoxPro)
|
|
58
|
+
* [solid-tweakpane](https://github.com/MrFoxPro/solid-tweakpane) library.
|
|
59
|
+
*
|
|
60
|
+
* Plugin component behavior is not available in `<AutoObject>`.
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```svelte
|
|
64
|
+
* <script lang="ts">
|
|
65
|
+
* import { AutoObject } from 'svelte-tweakpane-ui';
|
|
66
|
+
*
|
|
67
|
+
* let object = {
|
|
68
|
+
* // Creates a <Checkbox>
|
|
69
|
+
* someBoolean: true,
|
|
70
|
+
* // Creates a <Color> picker
|
|
71
|
+
* someColor: {
|
|
72
|
+
* r: 255,
|
|
73
|
+
* g: 0,
|
|
74
|
+
*
|
|
75
|
+
* b: 55
|
|
76
|
+
* },
|
|
77
|
+
* // Wraps children in a <Folder>
|
|
78
|
+
* someFolder: {
|
|
79
|
+
* b: 2,
|
|
80
|
+
* a: 1,
|
|
81
|
+
* c: 3
|
|
82
|
+
* },
|
|
83
|
+
* // Creates a <Slider>
|
|
84
|
+
* someNumber: 1,
|
|
85
|
+
* // creates a <Point>
|
|
86
|
+
* somePoint: {
|
|
87
|
+
* x: 1,
|
|
88
|
+
* y: 2
|
|
89
|
+
* },
|
|
90
|
+
* // Creates a <Text>
|
|
91
|
+
* someString: 'test'
|
|
92
|
+
* };
|
|
93
|
+
* </script>
|
|
94
|
+
*
|
|
95
|
+
* <AutoObject bind:object />
|
|
96
|
+
*
|
|
97
|
+
* <pre>{JSON.stringify(object, null, 2)}</pre>
|
|
98
|
+
* ```
|
|
99
|
+
*
|
|
100
|
+
* @sourceLink
|
|
101
|
+
* [AutoObject.svelte](https://github.com/kitschpatrol/svelte-tweakpane-ui/blob/main/src/lib/extra/AutoObject.svelte)
|
|
102
|
+
*/
|
|
103
|
+
export default class AutoObject extends SvelteComponent<
|
|
104
|
+
AutoObjectProps,
|
|
105
|
+
AutoObjectEvents,
|
|
106
|
+
AutoObjectSlots
|
|
107
|
+
> {}
|
|
108
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import Text from '../control/Text.svelte';
|
|
3
|
+
import GenericBinding from '../internal/GenericBinding.svelte';
|
|
4
|
+
export let value;
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
{#if typeof value === 'string'}
|
|
8
|
+
<Text bind:value {...$$restProps} />
|
|
9
|
+
{:else}
|
|
10
|
+
<GenericBinding bind:value {...$$restProps} />
|
|
11
|
+
{/if}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { SvelteComponent } from 'svelte';
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: Omit<
|
|
4
|
+
Omit<
|
|
5
|
+
{
|
|
6
|
+
/**
|
|
7
|
+
* The binding's target object with values to manipulate.
|
|
8
|
+
* @bindable
|
|
9
|
+
*/
|
|
10
|
+
object: import('@tweakpane/core').Bindable & {
|
|
11
|
+
[x: string]: string | number | boolean | object;
|
|
12
|
+
};
|
|
13
|
+
/** The key for the value in the target `object` that the control should manipulate. */
|
|
14
|
+
key: string | number;
|
|
15
|
+
/**
|
|
16
|
+
* Prevent interactivity and gray out the control.
|
|
17
|
+
* @default `false`
|
|
18
|
+
*/
|
|
19
|
+
disabled?: boolean | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* Text displayed next to control.
|
|
22
|
+
* @default `undefined`
|
|
23
|
+
*/
|
|
24
|
+
label?: string | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* Tweakpane's internal options object.
|
|
27
|
+
*
|
|
28
|
+
* See [`BindingParams`](https://tweakpane.github.io/docs/api/types/BindingParams.html).
|
|
29
|
+
*
|
|
30
|
+
* Valid types are contingent on the type of the value `key` points to in `object`.
|
|
31
|
+
*
|
|
32
|
+
* This is intended internal use, when implementing convenience components wrapping Binding's
|
|
33
|
+
* functionality. Options of interest are instead exposed as top-level props in _Svelte
|
|
34
|
+
* Tweakpane UI_.
|
|
35
|
+
* @default `undefined`
|
|
36
|
+
*/
|
|
37
|
+
options?: import('tweakpane').BindingParams | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* Custom color scheme.
|
|
40
|
+
*
|
|
41
|
+
* @default `undefined` \
|
|
42
|
+
* Inherits default Tweakpane theme equivalent to `ThemeUtils.presets.standard`, or the theme
|
|
43
|
+
* set with `setGlobalDefaultTheme()`.
|
|
44
|
+
*/
|
|
45
|
+
theme?: import('..').Theme | undefined;
|
|
46
|
+
/**
|
|
47
|
+
* Reference to internal Tweakpane
|
|
48
|
+
* [`BindingApi`](https://tweakpane.github.io/docs/api/classes/_internal_.BindingApi.html) for
|
|
49
|
+
* this control.
|
|
50
|
+
*
|
|
51
|
+
* This is primarily for internal use, when implementing convenience components wrapping
|
|
52
|
+
* Binding's functionality.
|
|
53
|
+
* @bindable
|
|
54
|
+
* @readonly
|
|
55
|
+
*/
|
|
56
|
+
ref?: import('..').BindingRef | undefined;
|
|
57
|
+
/**
|
|
58
|
+
* Imported Tweakpane `TpPluginBundle` (aliased as `Plugin`) module to automatically register in
|
|
59
|
+
* the binding's containing `<Pane>`.
|
|
60
|
+
*
|
|
61
|
+
* This is primarily for internal use, when implementing convenience components wrapping
|
|
62
|
+
* Binding's functionality in combination with a Tweakpane plugin.
|
|
63
|
+
* @default `undefined`
|
|
64
|
+
*/
|
|
65
|
+
plugin?: import('tweakpane').TpPluginBundle | undefined;
|
|
66
|
+
},
|
|
67
|
+
'object' | 'key'
|
|
68
|
+
> & {
|
|
69
|
+
/**
|
|
70
|
+
* The value to control.
|
|
71
|
+
* @bindable
|
|
72
|
+
*/
|
|
73
|
+
value: string | number | boolean | object;
|
|
74
|
+
},
|
|
75
|
+
'options' | 'ref' | 'plugin'
|
|
76
|
+
>;
|
|
77
|
+
events: {
|
|
78
|
+
[evt: string]: CustomEvent<any>;
|
|
79
|
+
};
|
|
80
|
+
slots: {};
|
|
81
|
+
};
|
|
82
|
+
export type AutoValueProps = typeof __propDef.props;
|
|
83
|
+
export type AutoValueEvents = typeof __propDef.events;
|
|
84
|
+
export type AutoValueSlots = typeof __propDef.slots;
|
|
85
|
+
/**
|
|
86
|
+
* Rapid-development component which automatically creates a Tweakpane control for an arbitrary value.
|
|
87
|
+
*
|
|
88
|
+
* A (reasonably) appropriate Tweakpane control will be used for the value type.
|
|
89
|
+
*
|
|
90
|
+
* This component is intended for quick tests where you don't want to fuss with component selection or
|
|
91
|
+
* customization.
|
|
92
|
+
*
|
|
93
|
+
* See `<AutoObject>` for a variation that works directly on a stand-alone value that isn't wrapped in
|
|
94
|
+
* an object.
|
|
95
|
+
*
|
|
96
|
+
* The value is generally mapped to controls according to the logic outlined in the [Tweakpane input
|
|
97
|
+
* binding documentation](https://tweakpane.github.io/docs/input-bindings/).
|
|
98
|
+
*
|
|
99
|
+
* Plugin component behavior is not available in `<AutoValue>`.
|
|
100
|
+
*
|
|
101
|
+
* @example
|
|
102
|
+
* ```svelte
|
|
103
|
+
* <script lang="ts">
|
|
104
|
+
* import { AutoValue } from 'svelte-tweakpane-ui';
|
|
105
|
+
*
|
|
106
|
+
* let number = 0;
|
|
107
|
+
* let color = '#ff00ff';
|
|
108
|
+
* let point = { x: 0, y: 0 };
|
|
109
|
+
* let text = 'Cosmic manifold';
|
|
110
|
+
* </script>
|
|
111
|
+
*
|
|
112
|
+
* <AutoValue bind:value={number} label="Number" />
|
|
113
|
+
* <AutoValue bind:value={color} label="Color" />
|
|
114
|
+
* <AutoValue bind:value={point} label="Point" />
|
|
115
|
+
* <AutoValue bind:value={text} label="Text" />
|
|
116
|
+
* ```
|
|
117
|
+
*/
|
|
118
|
+
export default class AutoValue extends SvelteComponent<
|
|
119
|
+
AutoValueProps,
|
|
120
|
+
AutoValueEvents,
|
|
121
|
+
AutoValueSlots
|
|
122
|
+
> {}
|
|
123
|
+
export {};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import Blade from '../core/Blade.svelte';
|
|
3
|
+
import ClsPad from '../internal/ClsPad.svelte';
|
|
4
|
+
import { BROWSER } from 'esm-env';
|
|
5
|
+
export let maxHeight = void 0;
|
|
6
|
+
export let resetStyle = true;
|
|
7
|
+
const options = {
|
|
8
|
+
view: 'separator'
|
|
9
|
+
};
|
|
10
|
+
let ref;
|
|
11
|
+
let sourceDiv;
|
|
12
|
+
$: if (ref && ref.element) {
|
|
13
|
+
ref.element.replaceChildren(sourceDiv);
|
|
14
|
+
}
|
|
15
|
+
</script>
|
|
16
|
+
|
|
17
|
+
{#if BROWSER}
|
|
18
|
+
<Blade bind:ref {options} {...$$restProps} />
|
|
19
|
+
{:else}
|
|
20
|
+
<ClsPad
|
|
21
|
+
keysAdd={['containerVerticalPadding', 'containerVerticalPadding']}
|
|
22
|
+
theme={$$props.theme}
|
|
23
|
+
/>
|
|
24
|
+
{/if}
|
|
25
|
+
|
|
26
|
+
<div bind:this={sourceDiv} class="element">
|
|
27
|
+
<div
|
|
28
|
+
class="element-container"
|
|
29
|
+
style:height={BROWSER ? null : `${maxHeight}px`}
|
|
30
|
+
style:max-height={maxHeight !== undefined ? `${maxHeight}px` : null}
|
|
31
|
+
style:overflow={BROWSER ? null : 'hidden'}
|
|
32
|
+
>
|
|
33
|
+
<div class:reset={resetStyle}>
|
|
34
|
+
<slot />
|
|
35
|
+
</div>
|
|
36
|
+
</div>
|
|
37
|
+
</div>
|
|
38
|
+
|
|
39
|
+
<style>
|
|
40
|
+
div.element {
|
|
41
|
+
padding-right: var(--cnt-hp);
|
|
42
|
+
padding-left: var(--cnt-hp);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
div.element-container {
|
|
46
|
+
overflow: hidden;
|
|
47
|
+
border-radius: var(--bld-br);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
div.reset {
|
|
51
|
+
all: initial;
|
|
52
|
+
}
|
|
53
|
+
</style>
|