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.
Files changed (99) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +36 -0
  3. package/dist/control/ButtonGrid.svelte +49 -0
  4. package/dist/control/ButtonGrid.svelte.d.ts +190 -0
  5. package/dist/control/Checkbox.svelte +6 -0
  6. package/dist/control/Checkbox.svelte.d.ts +113 -0
  7. package/dist/control/Color.svelte +79 -0
  8. package/dist/control/Color.svelte.d.ts +177 -0
  9. package/dist/control/CubicBezier.svelte +74 -0
  10. package/dist/control/CubicBezier.svelte.d.ts +204 -0
  11. package/dist/control/Image.svelte +23 -0
  12. package/dist/control/Image.svelte.d.ts +177 -0
  13. package/dist/control/IntervalSlider.svelte +37 -0
  14. package/dist/control/IntervalSlider.svelte.d.ts +196 -0
  15. package/dist/control/List.svelte +69 -0
  16. package/dist/control/List.svelte.d.ts +122 -0
  17. package/dist/control/Point.svelte +100 -0
  18. package/dist/control/Point.svelte.d.ts +374 -0
  19. package/dist/control/RadioGrid.svelte +42 -0
  20. package/dist/control/RadioGrid.svelte.d.ts +231 -0
  21. package/dist/control/Ring.svelte +19 -0
  22. package/dist/control/Ring.svelte.d.ts +220 -0
  23. package/dist/control/RotationEuler.svelte +67 -0
  24. package/dist/control/RotationEuler.svelte.d.ts +273 -0
  25. package/dist/control/RotationQuaternion.svelte +65 -0
  26. package/dist/control/RotationQuaternion.svelte.d.ts +276 -0
  27. package/dist/control/Slider.svelte +6 -0
  28. package/dist/control/Slider.svelte.d.ts +165 -0
  29. package/dist/control/Text.svelte +25 -0
  30. package/dist/control/Text.svelte.d.ts +129 -0
  31. package/dist/control/Textarea.svelte +47 -0
  32. package/dist/control/Textarea.svelte.d.ts +149 -0
  33. package/dist/control/Wheel.svelte +15 -0
  34. package/dist/control/Wheel.svelte.d.ts +186 -0
  35. package/dist/core/Binding.svelte +68 -0
  36. package/dist/core/Binding.svelte.d.ts +116 -0
  37. package/dist/core/Blade.svelte +61 -0
  38. package/dist/core/Blade.svelte.d.ts +90 -0
  39. package/dist/core/Button.svelte +59 -0
  40. package/dist/core/Button.svelte.d.ts +65 -0
  41. package/dist/core/Folder.svelte +69 -0
  42. package/dist/core/Folder.svelte.d.ts +78 -0
  43. package/dist/core/Pane.svelte +51 -0
  44. package/dist/core/Pane.svelte.d.ts +500 -0
  45. package/dist/core/Separator.svelte +14 -0
  46. package/dist/core/Separator.svelte.d.ts +85 -0
  47. package/dist/core/TabGroup.svelte +64 -0
  48. package/dist/core/TabGroup.svelte.d.ts +72 -0
  49. package/dist/core/TabPage.svelte +85 -0
  50. package/dist/core/TabPage.svelte.d.ts +82 -0
  51. package/dist/extra/AutoObject.svelte +46 -0
  52. package/dist/extra/AutoObject.svelte.d.ts +108 -0
  53. package/dist/extra/AutoValue.svelte +11 -0
  54. package/dist/extra/AutoValue.svelte.d.ts +123 -0
  55. package/dist/extra/Element.svelte +53 -0
  56. package/dist/extra/Element.svelte.d.ts +170 -0
  57. package/dist/index.d.ts +94 -0
  58. package/dist/index.js +39 -0
  59. package/dist/internal/ClsPad.svelte +34 -0
  60. package/dist/internal/ClsPad.svelte.d.ts +95 -0
  61. package/dist/internal/GenericBinding.svelte +22 -0
  62. package/dist/internal/GenericBinding.svelte.d.ts +116 -0
  63. package/dist/internal/GenericBladeFolding.svelte +38 -0
  64. package/dist/internal/GenericBladeFolding.svelte.d.ts +95 -0
  65. package/dist/internal/GenericInput.svelte +19 -0
  66. package/dist/internal/GenericInput.svelte.d.ts +116 -0
  67. package/dist/internal/GenericInputFolding.svelte +40 -0
  68. package/dist/internal/GenericInputFolding.svelte.d.ts +140 -0
  69. package/dist/internal/GenericMonitor.svelte +24 -0
  70. package/dist/internal/GenericMonitor.svelte.d.ts +139 -0
  71. package/dist/internal/GenericPane.svelte +100 -0
  72. package/dist/internal/GenericPane.svelte.d.ts +84 -0
  73. package/dist/internal/GenericSlider.svelte +27 -0
  74. package/dist/internal/GenericSlider.svelte.d.ts +146 -0
  75. package/dist/internal/InternalMonitorBoolean.svelte +17 -0
  76. package/dist/internal/InternalMonitorBoolean.svelte.d.ts +154 -0
  77. package/dist/internal/InternalMonitorNumber.svelte +31 -0
  78. package/dist/internal/InternalMonitorNumber.svelte.d.ts +178 -0
  79. package/dist/internal/InternalMonitorString.svelte +23 -0
  80. package/dist/internal/InternalMonitorString.svelte.d.ts +162 -0
  81. package/dist/internal/InternalPaneDraggable.svelte +368 -0
  82. package/dist/internal/InternalPaneDraggable.svelte.d.ts +178 -0
  83. package/dist/internal/InternalPaneFixed.svelte +28 -0
  84. package/dist/internal/InternalPaneFixed.svelte.d.ts +119 -0
  85. package/dist/internal/InternalPaneInline.svelte +29 -0
  86. package/dist/internal/InternalPaneInline.svelte.d.ts +106 -0
  87. package/dist/monitor/FpsGraph.svelte +86 -0
  88. package/dist/monitor/FpsGraph.svelte.d.ts +230 -0
  89. package/dist/monitor/Monitor.svelte +14 -0
  90. package/dist/monitor/Monitor.svelte.d.ts +526 -0
  91. package/dist/monitor/Profiler.svelte +72 -0
  92. package/dist/monitor/Profiler.svelte.d.ts +265 -0
  93. package/dist/monitor/WaveformMonitor.svelte +26 -0
  94. package/dist/monitor/WaveformMonitor.svelte.d.ts +176 -0
  95. package/dist/theme.d.ts +91 -0
  96. package/dist/theme.js +332 -0
  97. package/dist/utils.d.ts +157 -0
  98. package/dist/utils.js +238 -0
  99. package/package.json +280 -0
@@ -0,0 +1,74 @@
1
+ <script context="module"></script>
2
+
3
+ <script>
4
+ import * as pluginModule from '@tweakpane/plugin-essentials';
5
+ import { CubicBezier } from '@tweakpane/plugin-essentials';
6
+ import ClsPad from '../internal/ClsPad.svelte';
7
+ import GenericBladeFolding from '../internal/GenericBladeFolding.svelte';
8
+ import { fillWith } from '../utils';
9
+ import { BROWSER } from 'esm-env';
10
+ export let value;
11
+ export let label = void 0;
12
+ export let expanded = void 0;
13
+ let options;
14
+ let cubicBezierBlade;
15
+ const buttonClass = 'tp-cbzv_b';
16
+ function getValue() {
17
+ if (Array.isArray(value)) {
18
+ return value;
19
+ } else {
20
+ return [value.x1, value.y1, value.x2, value.y2];
21
+ }
22
+ }
23
+ function setValue() {
24
+ if (Array.isArray(value)) {
25
+ cubicBezierBlade.value = new CubicBezier(value[0], value[1], value[2], value[3]);
26
+ } else {
27
+ cubicBezierBlade.value = new CubicBezier(value.x1, value.y1, value.x2, value.y2);
28
+ }
29
+ }
30
+ function addEvent() {
31
+ cubicBezierBlade.on('change', (ev) => {
32
+ if (Array.isArray(value)) {
33
+ value = [ev.value.x1, ev.value.y1, ev.value.x2, ev.value.y2];
34
+ } else {
35
+ value = {
36
+ x1: ev.value.x1,
37
+ y1: ev.value.y1,
38
+ x2: ev.value.x2,
39
+ y2: ev.value.y2
40
+ };
41
+ }
42
+ });
43
+ }
44
+ $: options = {
45
+ value: getValue(),
46
+ label,
47
+ view: 'cubicbezier'
48
+ };
49
+ $: cubicBezierBlade && addEvent();
50
+ $: value, cubicBezierBlade && setValue();
51
+ </script>
52
+
53
+ <GenericBladeFolding
54
+ bind:expanded
55
+ bind:ref={cubicBezierBlade}
56
+ {buttonClass}
57
+ {options}
58
+ plugin={pluginModule}
59
+ {...$$restProps}
60
+ />
61
+ {#if !BROWSER}
62
+ <ClsPad keysAdd={fillWith('containerUnitSize', 1)} theme={$$props.theme} />
63
+ {#if expanded && $$props.picker === 'inline'}
64
+ <ClsPad keysAdd={fillWith('containerUnitSize', 6)} theme={$$props.theme} />
65
+ <ClsPad keysAdd={fillWith('containerUnitSpacing', 2)} theme={$$props.theme} />
66
+ {/if}
67
+ {/if}
68
+
69
+ <style>
70
+ /* Fix overflow bug from the plugin TODO PR */
71
+ :global(div.tp-cbzv:not(tp-cbzv-expanded) div.tp-cbzv_p) {
72
+ overflow: hidden !important;
73
+ }
74
+ </style>
@@ -0,0 +1,204 @@
1
+ import { SvelteComponent } from 'svelte';
2
+ import type { Simplify } from '../utils';
3
+ export type CubicBezierValueObject = {
4
+ x1: number;
5
+ y1: number;
6
+ x2: number;
7
+ y2: number;
8
+ };
9
+ export type CubicBezierValueTuple = [x1: number, y1: number, x2: number, y2: number];
10
+ export type CubicBezierValue = Simplify<CubicBezierValueObject | CubicBezierValueTuple>;
11
+ import type { CubicBezierApi as CubicBezierRef } from '@tweakpane/plugin-essentials';
12
+ import type { CubicBezierBladeParams as CubicBezierOptions } from '@tweakpane/plugin-essentials/dist/types/cubic-bezier/plugin.d.ts';
13
+ declare const __propDef: {
14
+ props: Omit<
15
+ {
16
+ /**
17
+ * Blade configuration exposing Tweakpane's internal
18
+ * [`BladeParams`](https://tweakpane.github.io/docs/api/interfaces/BaseBladeParams.html).
19
+ *
20
+ */
21
+ options: CubicBezierOptions;
22
+ /**
23
+ * Prevent interactivity and gray out the control.
24
+ * @default `false`
25
+ */
26
+ disabled?: boolean | undefined;
27
+ /**
28
+ * Custom color scheme.
29
+ * @default `undefined` \
30
+ * Inherits default Tweakpane theme equivalent to `ThemeUtils.presets.standard`, or the theme
31
+ * set with `setGlobalDefaultTheme()`.
32
+ */
33
+ theme?: import('..').Theme | undefined;
34
+ /**
35
+ * Reference to internal Tweakpane
36
+ * [`BladeApi`](https://tweakpane.github.io/docs/api/classes/BladeApi.html) for this blade.
37
+ *
38
+ * This is primarily for internal use, when implementing convenience components wrapping Blade's
39
+ * functionality.
40
+ * @bindable
41
+ * @readonly
42
+ */
43
+ ref?: CubicBezierRef | undefined;
44
+ /**
45
+ * Imported Tweakpane `TpPluginBundle` (Aliased as `Plugin`) module to register before creating
46
+ * the blade.
47
+ *
48
+ * This is primarily for internal use, when implementing convenience components wrapping Blade's
49
+ * functionality in combination with a Tweakpane plugin.
50
+ * @default `undefined`
51
+ */
52
+ plugin?: import('tweakpane').TpPluginBundle | undefined;
53
+ } & {
54
+ /**
55
+ * DOM class name of the button used to expand and collapse the blade's picker.
56
+ * @default `undefined`
57
+ */
58
+ buttonClass?: string | undefined;
59
+ /**
60
+ * Expand or collapse the blade's picker.
61
+ * @default `true`
62
+ * @bindable
63
+ */
64
+ expanded?: boolean | undefined;
65
+ /**
66
+ * The style of value "picker" to use in the blade.
67
+ * @default `'popup'`
68
+ */
69
+ picker?: 'inline' | 'popup' | undefined;
70
+ /**
71
+ * Allow users to interactively expand / contract the value picker by clicking its icon.
72
+ *
73
+ * Most useful when `picker` is `inline`.
74
+ * @default `true`
75
+ */
76
+ userExpandable?: boolean | undefined;
77
+ },
78
+ 'options' | 'ref' | 'plugin' | 'buttonClass'
79
+ > & {
80
+ /**
81
+ * The cubic bezier value to control.
82
+ *
83
+ * Object value type is a convenience added by _Svelte Tweakpane UI_, and is not part of the
84
+ * original `@tweakpane/plugin-essentials` API.
85
+ * @bindable
86
+ */
87
+ value: CubicBezierValue;
88
+ /**
89
+ * Text displayed next to the control.
90
+ * @default `undefined`
91
+ * */
92
+ label?: string | undefined;
93
+ };
94
+ events: {
95
+ [evt: string]: CustomEvent<any>;
96
+ };
97
+ slots: {};
98
+ };
99
+ export type CubicBezierProps = typeof __propDef.props;
100
+ export type CubicBezierEvents = typeof __propDef.events;
101
+ export type CubicBezierSlots = typeof __propDef.slots;
102
+ /**
103
+ * A control for editing a bezier curve. Ideal for tweaking animation easing values.
104
+ *
105
+ * Integrates the [Cubic Bezier](https://github.com/tweakpane/plugin-essentials#cubic-bezier) control
106
+ * from Tweakpane-creator [Hiroki Kokubun's](https://cocopon.me) [Essentials
107
+ * plugin](https://github.com/tweakpane/plugin-essentials).
108
+ *
109
+ * _Svelte Tweakpane UI_ extends the original implementation to by supporting tuple values in addition
110
+ * to object values.
111
+ *
112
+ * A utility function `Utils.cubicBezierToEaseFunction()` is also provided to easily convert a cubic
113
+ * bezier value to an easing function compatible with Svelte's built-in
114
+ * [motion](https://svelte.dev/docs/svelte-motion),
115
+ * [transition](https://svelte.dev/docs/svelte-transition), and
116
+ * [animate](https://svelte.dev/docs/svelte-animate) modules.
117
+ *
118
+ * Usage outside of a `<Pane>` component will implicitly wrap the cubic bezier control in `<Pane
119
+ * position='inline'>`.
120
+ *
121
+ * _Note: A memory leak has been observed in situations when the `value` prop is written frequently
122
+ * from outside the component. See [issue
123
+ * #18](https://github.com/tweakpane/plugin-essentials/issues/18) on the Plugin Essentials repo for
124
+ * updates. Consider managing the lifecycle of this component with care until this issue is resolved._
125
+ *
126
+ * @example
127
+ * ```svelte
128
+ * <script lang="ts">
129
+ * import {
130
+ * CubicBezier,
131
+ * type CubicBezierValue,
132
+ * RadioGrid,
133
+ * Slider,
134
+ * Utils
135
+ * } from 'svelte-tweakpane-ui';
136
+ * import { tweened } from 'svelte/motion';
137
+ *
138
+ * // could also be a tuple
139
+ * let value: CubicBezierValue = { x1: 0.25, y1: 0.1, x2: 0.25, y2: 1.0 };
140
+ * let duration = 1000;
141
+ * let moods = ['Set', 'Rise'];
142
+ * let mood: string = moods[0];
143
+ *
144
+ * const positionTween = tweened(0);
145
+ *
146
+ * function lerp(value: number, low: number, high: number): number {
147
+ * return (1 - value) * low + value * high;
148
+ * }
149
+ *
150
+ * $: positionTween.set(mood === 'Set' ? 0 : 1, {
151
+ * duration,
152
+ * easing: Utils.cubicBezierToEaseFunction(value)
153
+ * });
154
+ *
155
+ * $: celestialHeight = lerp($positionTween, 20, 80);
156
+ * $: twilightAmount = lerp($positionTween, 20, -80);
157
+ * </script>
158
+ *
159
+ * <CubicBezier bind:value expanded={true} picker="inline" />
160
+ * <Slider
161
+ * bind:value={duration}
162
+ * min={0}
163
+ * max={10000}
164
+ * format={(v) => `${(v / 1000).toFixed(1)}`}
165
+ * label="Duration (Seconds)"
166
+ * />
167
+ * <RadioGrid bind:value={mood} values={['Rise', 'Set']} />
168
+ *
169
+ * <div class="demo" style:--a="{twilightAmount}%">
170
+ * <div class="celestial-object" style:--t="{celestialHeight}%" />
171
+ * </div>
172
+ *
173
+ * <style>
174
+ * .demo {
175
+ * position: relative;
176
+ * overflow: hidden;
177
+ * aspect-ratio: 1;
178
+ * width: 100%;
179
+ * background: linear-gradient(to top, orange var(--a), magenta 100%);
180
+ * }
181
+ *
182
+ * .celestial-object {
183
+ * position: absolute;
184
+ * bottom: var(--t);
185
+ * left: 50%;
186
+ * transform-origin: center;
187
+ * transform: translate(-50%, 50%);
188
+ * aspect-ratio: 1;
189
+ * width: 20%;
190
+ * background-color: yellow;
191
+ * border-radius: 50%;
192
+ * }
193
+ * </style>
194
+ * ```
195
+ *
196
+ * @sourceLink
197
+ * [CubicBezier.svelte](https://github.com/kitschpatrol/svelte-tweakpane-ui/blob/main/src/lib/control/CubicBezier.svelte)
198
+ */
199
+ export default class CubicBezier extends SvelteComponent<
200
+ CubicBezierProps,
201
+ CubicBezierEvents,
202
+ CubicBezierSlots
203
+ > {}
204
+ export {};
@@ -0,0 +1,23 @@
1
+ <script context="module"></script>
2
+
3
+ <script>
4
+ import * as pluginModule from '@kitschpatrol/tweakpane-image-plugin';
5
+ import ClsPad from '../internal/ClsPad.svelte';
6
+ import GenericInput from '../internal/GenericInput.svelte';
7
+ import { fillWith } from '../utils';
8
+ import { BROWSER } from 'esm-env';
9
+ export let value = 'placeholder';
10
+ export let fit = void 0;
11
+ export let extensions = void 0;
12
+ let options;
13
+ $: options = {
14
+ extensions,
15
+ imageFit: fit,
16
+ view: 'input-image'
17
+ };
18
+ </script>
19
+
20
+ <GenericInput bind:value {options} plugin={pluginModule} {...$$restProps} />
21
+ {#if !BROWSER}
22
+ <ClsPad keysAdd={fillWith('containerVerticalPadding', 2)} theme={$$props.theme} />
23
+ {/if}
@@ -0,0 +1,177 @@
1
+ import { SvelteComponent } from 'svelte';
2
+ export type ImageValue = 'placeholder' | File | HTMLImageElement | string | undefined;
3
+ declare const __propDef: {
4
+ props: Omit<
5
+ Omit<
6
+ {
7
+ /**
8
+ * The binding's target object with values to manipulate.
9
+ * @bindable
10
+ */
11
+ object: import('@tweakpane/core').Bindable & {
12
+ [x: string]: ImageValue;
13
+ };
14
+ /** The key for the value in the target `object` that the control should manipulate. */
15
+ key: string | number;
16
+ /**
17
+ * Prevent interactivity and gray out the control.
18
+ * @default `false`
19
+ */
20
+ disabled?: boolean | undefined;
21
+ /**
22
+ * Text displayed next to control.
23
+ * @default `undefined`
24
+ */
25
+ label?: string | undefined;
26
+ /**
27
+ * Tweakpane's internal options object.
28
+ *
29
+ * See [`BindingParams`](https://tweakpane.github.io/docs/api/types/BindingParams.html).
30
+ *
31
+ * Valid types are contingent on the type of the value `key` points to in `object`.
32
+ *
33
+ * This is intended internal use, when implementing convenience components wrapping Binding's
34
+ * functionality. Options of interest are instead exposed as top-level props in _Svelte
35
+ * Tweakpane UI_.
36
+ * @default `undefined`
37
+ */
38
+ options?: import('@tweakpane/core').BaseInputParams | undefined;
39
+ /**
40
+ * Custom color scheme.
41
+ *
42
+ * @default `undefined` \
43
+ * Inherits default Tweakpane theme equivalent to `ThemeUtils.presets.standard`, or the theme
44
+ * set with `setGlobalDefaultTheme()`.
45
+ */
46
+ theme?: import('..').Theme | undefined;
47
+ /**
48
+ * Reference to internal Tweakpane
49
+ * [`BindingApi`](https://tweakpane.github.io/docs/api/classes/_internal_.BindingApi.html) for
50
+ * this control.
51
+ *
52
+ * This is primarily for internal use, when implementing convenience components wrapping
53
+ * Binding's functionality.
54
+ * @bindable
55
+ * @readonly
56
+ */
57
+ ref?: import('../internal/GenericInput.svelte').GenericInputRef | undefined;
58
+ /**
59
+ * Imported Tweakpane `TpPluginBundle` (aliased as `Plugin`) module to automatically register in
60
+ * the binding's containing `<Pane>`.
61
+ *
62
+ * This is primarily for internal use, when implementing convenience components wrapping
63
+ * Binding's functionality in combination with a Tweakpane plugin.
64
+ * @default `undefined`
65
+ */
66
+ plugin?: import('tweakpane').TpPluginBundle | undefined;
67
+ },
68
+ 'object' | 'key'
69
+ > & {
70
+ /**
71
+ * Image data
72
+ * @default `'placeholder'`
73
+ * @bindable
74
+ */
75
+ value: ImageValue;
76
+ },
77
+ 'ref' | 'plugin' | 'value'
78
+ > & {
79
+ /**
80
+ * Image data
81
+ * @default `'placeholder'`
82
+ * @bindable
83
+ */
84
+ value?: ImageValue;
85
+ /**
86
+ * Array of image extension types to accept.
87
+ * @default `['.jpg', '.png', '.gif']`
88
+ */
89
+ extensions?: string[] | undefined;
90
+ /**
91
+ * How to display the image in the preview pane.
92
+ *
93
+ * Renamed from `imageFit` in `tweakpane-image-plugin` for concision.
94
+ * @default `'cover'`
95
+ */
96
+ fit?: 'contain' | 'cover' | undefined;
97
+ };
98
+ events: {
99
+ [evt: string]: CustomEvent<any>;
100
+ };
101
+ slots: {};
102
+ };
103
+ export type ImageProps = typeof __propDef.props;
104
+ export type ImageEvents = typeof __propDef.events;
105
+ export type ImageSlots = typeof __propDef.slots;
106
+ /**
107
+ * An image input control.
108
+ *
109
+ * Integrates the [tweakpane-image-plugin](https://github.com/metehus/tweakpane-image-plugin),
110
+ * incorporating work by [Florian Morel](http://ayamflow.fr), [Matheus
111
+ * Dias](https://www.linkedin.com/in/matheusdbs/), [Palash Bansal](https://github.com/repalash), and
112
+ * others.
113
+ *
114
+ * Note that _Svelte Tweakpane UI_ embeds a
115
+ * [fork](https://github.com/kitschpatrol/tweakpane-image-plugin) of the plugin with support for
116
+ * Tweakpane 4. The dependency will be updated to point to the source repository if / when the open
117
+ * [pull request](https://github.com/metehus/tweakpane-image-plugin/pull/1) with Tweakpane 4 support is
118
+ * merged.
119
+ *
120
+ * Usage outside of a `<Pane>` component will implicitly wrap the image control in `<Pane
121
+ * position='inline'>`.
122
+ *
123
+ * @example
124
+ * ```svelte
125
+ * <script lang="ts">
126
+ * import { Button, Image } from 'svelte-tweakpane-ui';
127
+ *
128
+ * let src = 'placeholder';
129
+ * let kittenIndex = 1;
130
+ * </script>
131
+ *
132
+ * <Image bind:value={src} fit="contain" label="Image" />
133
+ * <Button
134
+ * on:click={() => {
135
+ * src = `https://placekitten.com/1024/1024?image=${kittenIndex}`;
136
+ * kittenIndex = (kittenIndex % 16) + 1;
137
+ * }}
138
+ * label="Random Placeholder"
139
+ * title="Load Kitten"
140
+ * />
141
+ *
142
+ * <div class="demo">
143
+ * {#if src === 'placeholder'}
144
+ * <p>Tap “No Image” above to load an image from disk.</p>
145
+ * {:else}
146
+ * <img alt="" {src} />
147
+ * {/if}
148
+ * </div>
149
+ *
150
+ * <style>
151
+ * div.demo {
152
+ * display: flex;
153
+ * align-items: center;
154
+ * justify-content: center;
155
+ * aspect-ratio: 1;
156
+ * width: 100%;
157
+ * background: linear-gradient(magenta, orange);
158
+ * }
159
+ *
160
+ * div.demo > img {
161
+ * max-width: 80%;
162
+ * max-height: 80%;
163
+ * }
164
+ *
165
+ * div.demo > p {
166
+ * max-width: 50%;
167
+ * color: white;
168
+ * text-align: center;
169
+ * }
170
+ * </style>
171
+ * ```
172
+ *
173
+ * @sourceLink
174
+ * [Image.svelte](https://github.com/kitschpatrol/svelte-tweakpane-ui/blob/main/src/lib/control/Image.svelte)
175
+ */
176
+ export default class Image extends SvelteComponent<ImageProps, ImageEvents, ImageSlots> {}
177
+ export {};
@@ -0,0 +1,37 @@
1
+ <script context="module"></script>
2
+
3
+ <script>
4
+ import * as pluginModule from '@tweakpane/plugin-essentials';
5
+ import GenericSlider from '../internal/GenericSlider.svelte';
6
+ export let value;
7
+ export let meanValue = void 0;
8
+ let internalValue;
9
+ function updateInternalValue() {
10
+ if (Array.isArray(value)) {
11
+ const [min, max] = value;
12
+ internalValue = { min, max };
13
+ } else {
14
+ internalValue = value;
15
+ }
16
+ }
17
+ function updateValue() {
18
+ if (Array.isArray(value)) {
19
+ const { min, max } = internalValue;
20
+ value = [min, max];
21
+ } else {
22
+ value = internalValue;
23
+ }
24
+ }
25
+ function updateValueFromMean() {
26
+ if (meanValue !== void 0) {
27
+ const r = internalValue.max - internalValue.min;
28
+ internalValue = { min: meanValue - r / 2, max: meanValue + r / 2 };
29
+ }
30
+ }
31
+ $: value, updateInternalValue();
32
+ $: internalValue, updateValue();
33
+ $: meanValue = (internalValue.min + internalValue.max) / 2;
34
+ $: meanValue, updateValueFromMean();
35
+ </script>
36
+
37
+ <GenericSlider bind:value={internalValue} plugin={pluginModule} {...$$restProps} />