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,162 @@
1
+ import { SvelteComponent } from 'svelte';
2
+ import type { StringMonitorParams } from '@tweakpane/core';
3
+ export type InternalMonitorStringOptions = StringMonitorParams;
4
+ declare const __propDef: {
5
+ props: Omit<
6
+ Omit<
7
+ {
8
+ /**
9
+ * The binding's target object with values to manipulate.
10
+ * @bindable
11
+ */
12
+ object: import('@tweakpane/core').Bindable & {
13
+ [x: string]: string;
14
+ };
15
+ /** The key for the value in the target `object` that the control should manipulate. */
16
+ key: string | number;
17
+ /**
18
+ * Prevent interactivity and gray out the control.
19
+ * @default `false`
20
+ */
21
+ disabled?: boolean | undefined;
22
+ /**
23
+ * Text displayed next to control.
24
+ * @default `undefined`
25
+ */
26
+ label?: string | undefined;
27
+ /**
28
+ * Tweakpane's internal options object.
29
+ *
30
+ * See [`BindingParams`](https://tweakpane.github.io/docs/api/types/BindingParams.html).
31
+ *
32
+ * Valid types are contingent on the type of the value `key` points to in `object`.
33
+ *
34
+ * This is intended internal use, when implementing convenience components wrapping Binding's
35
+ * functionality. Options of interest are instead exposed as top-level props in _Svelte
36
+ * Tweakpane UI_.
37
+ * @default `undefined`
38
+ */
39
+ options?: StringMonitorParams | undefined;
40
+ /**
41
+ * Custom color scheme.
42
+ *
43
+ * @default `undefined` \
44
+ * Inherits default Tweakpane theme equivalent to `ThemeUtils.presets.standard`, or the theme
45
+ * set with `setGlobalDefaultTheme()`.
46
+ */
47
+ theme?: import('..').Theme | undefined;
48
+ /**
49
+ * Reference to internal Tweakpane
50
+ * [`BindingApi`](https://tweakpane.github.io/docs/api/classes/_internal_.BindingApi.html) for
51
+ * this control.
52
+ *
53
+ * This is primarily for internal use, when implementing convenience components wrapping
54
+ * Binding's functionality.
55
+ * @bindable
56
+ * @readonly
57
+ */
58
+ ref?: import('./GenericMonitor.svelte').GenericMonitorRef | undefined;
59
+ /**
60
+ * Imported Tweakpane `TpPluginBundle` (aliased as `Plugin`) module to automatically register in
61
+ * the binding's containing `<Pane>`.
62
+ *
63
+ * This is primarily for internal use, when implementing convenience components wrapping
64
+ * Binding's functionality in combination with a Tweakpane plugin.
65
+ * @default `undefined`
66
+ */
67
+ plugin?: import('@tweakpane/core').TpPluginBundle | undefined;
68
+ },
69
+ 'object' | 'key'
70
+ > & {
71
+ /**
72
+ * A `string` value to monitor.
73
+ */
74
+ value: string;
75
+ } & {
76
+ /**
77
+ * Number of past states to retain.
78
+ * @default `1` \
79
+ * Or `64` if value is `number` and `graph` is `true`.
80
+ */
81
+ bufferSize?: number | undefined;
82
+ /**
83
+ * Time between value samples in milliseconds.
84
+ *
85
+ * Useful when `graph` is true. Defaults to reactive value updates only (`interval={0}`).
86
+ * @default `0`
87
+ */
88
+ interval?: number | undefined;
89
+ /**
90
+ * Number of visible rows of state history.
91
+ *
92
+ * If `bufferSize` is larger, then the value window will scroll once state history exceeds
93
+ * row count.
94
+ * @default `1` \
95
+ * Or `3` if value is `string` and `multiline` is `true`.
96
+ */
97
+ rows?: number | undefined;
98
+ },
99
+ 'options' | 'ref' | 'plugin' | 'interval'
100
+ > & {
101
+ /**
102
+ * A `string` value to monitor.
103
+ * */
104
+ value: string;
105
+ /**
106
+ * Display multiline strings.
107
+ * @default `false`
108
+ * */
109
+ multiline?: boolean | undefined;
110
+ };
111
+ events: {
112
+ [evt: string]: CustomEvent<any>;
113
+ };
114
+ slots: {};
115
+ };
116
+ export type InternalMonitorStringProps = typeof __propDef.props;
117
+ export type InternalMonitorStringEvents = typeof __propDef.events;
118
+ export type InternalMonitorStringSlots = typeof __propDef.slots;
119
+ /**
120
+ * This component is for internal use only.
121
+ *
122
+ * Documentation retained in case of a return to the non-dynamic component approach.
123
+ *
124
+ * Wraps the Tweakpane [monitor binding](https://tweakpane.github.io/docs/monitor-bindings/)
125
+ * functionality for string values.
126
+ *
127
+ * Technically, any unbound value on a normal _Svelte Tweakpane UI_ component effectively acts as a
128
+ * monitor, but additional monitor-specific components are provided to expose additional view options
129
+ * (e.g. `multiline`).
130
+ *
131
+ * Note that `interval` is not exposed because updates are driven by reactive changes in the `value`.
132
+ *
133
+ * Usage outside of a `<Pane>` component will implicitly wrap the monitor in a `<Pane
134
+ * position='inline'>` component.
135
+ *
136
+ * @example
137
+ * ```svelte
138
+ * <script lang="ts">
139
+ * import { InternalMonitorString } from 'svelte-tweakpane-ui';
140
+ *
141
+ * let stringToMonitor = 'bla\n\bla\nbla';
142
+ *
143
+ * setInterval(() => {
144
+ * stringToMonitor = stringToMonitor
145
+ * .split('\n')
146
+ * .map(() => Math.round(Math.random() * 100).toString())
147
+ * .join('\n');
148
+ * }, 100);
149
+ * </script>
150
+ *
151
+ * <InternalMonitorString value={stringToMonitor} multiline={true} />
152
+ * ```
153
+ *
154
+ * @sourceLink
155
+ * [InternalMonitorString.svelte](https://github.com/kitschpatrol/svelte-tweakpane-ui/blob/main/src/lib/internal/InternalMonitorString.svelte)
156
+ */
157
+ export default class InternalMonitorString extends SvelteComponent<
158
+ InternalMonitorStringProps,
159
+ InternalMonitorStringEvents,
160
+ InternalMonitorStringSlots
161
+ > {}
162
+ export {};
@@ -0,0 +1,368 @@
1
+ <script context="module">
2
+ const localStorePrefix = 'svelte-tweakpane-ui-draggable-position-';
3
+ const localStoreDefaultId = '1';
4
+ const localStoreIds = [];
5
+ let zIndexGlobal = 1e3;
6
+ </script>
7
+
8
+ <script>
9
+ import GenericPane from './GenericPane.svelte';
10
+ import { clamp, getSwatchButton, pickerIsOpen, removeKeys } from '../utils.js';
11
+ import { onDestroy, onMount } from 'svelte';
12
+ import { persisted } from 'svelte-local-storage-store';
13
+ const TITLEBAR_WINDOW_SHADE_SINGLE_CLICK = true;
14
+ const TITLEBAR_WINDOW_SHADE_DOUBLE_CLICK = false;
15
+ export let storePositionLocally = true;
16
+ export let localStoreId = localStoreDefaultId;
17
+ let positionStore;
18
+ if (storePositionLocally) {
19
+ positionStore = persisted(`${localStorePrefix}${localStoreId}`, {
20
+ x: 0,
21
+ y: 0,
22
+ expanded: true,
23
+ width: 350
24
+ });
25
+ }
26
+ export let expanded = $positionStore?.expanded ?? true;
27
+ export let collapseChildrenToFit = false;
28
+ export let x = $positionStore?.x ?? 0;
29
+ export let y = $positionStore?.y ?? 0;
30
+ export let width = $positionStore?.width ?? 256;
31
+ export let resizable = true;
32
+ export let userExpandable = true;
33
+ export let minWidth = 200;
34
+ export let maxWidth = 600;
35
+ export let title = 'Tweakpane';
36
+ export let scale = 1;
37
+ export let padding = '0';
38
+ let paneRef;
39
+ let containerElement;
40
+ let dragBarElement;
41
+ let widthHandleElement;
42
+ let containerHeight;
43
+ let containerHeightScaled;
44
+ let containerWidth;
45
+ let documentWidth;
46
+ let documentHeight;
47
+ let zIndexLocal = zIndexGlobal;
48
+ function addStorageId() {
49
+ if (localStoreId !== void 0) {
50
+ if (localStoreIds.includes(localStoreId)) {
51
+ console.warn(
52
+ 'Multiple instances of <Pane> with `mode="draggable"` and `storePositionLocally=true` detected. You must explicitly set unique localStoreId property on each component to avoid collisions.'
53
+ );
54
+ }
55
+ localStoreIds.push(localStoreId);
56
+ }
57
+ }
58
+ function removeStorageId() {
59
+ if (localStoreId) {
60
+ localStoreIds.splice(localStoreIds.indexOf(localStoreId), 1);
61
+ localStorage.removeItem(`${localStorePrefix}${localStoreId}`);
62
+ }
63
+ }
64
+ function updateLocalStoreId(id) {
65
+ if (
66
+ id !== void 0 &&
67
+ positionStore !== void 0 &&
68
+ expanded !== void 0 &&
69
+ width !== void 0 &&
70
+ x !== void 0 &&
71
+ y !== void 0
72
+ ) {
73
+ positionStore = persisted(`${localStorePrefix}${localStoreId}`, {
74
+ x,
75
+ y,
76
+ expanded,
77
+ width
78
+ });
79
+ }
80
+ }
81
+ function setDocumentSize() {
82
+ if (x !== void 0 && y !== void 0 && width !== void 0) {
83
+ const documentWidthPrevious = documentWidth;
84
+ const documentHeightPrevious = documentHeight;
85
+ documentWidth = document.documentElement.clientWidth;
86
+ documentHeight = document.documentElement.clientHeight;
87
+ const dx = documentWidth - documentWidthPrevious;
88
+ const dy = documentHeight - documentHeightPrevious;
89
+ const centerPercentX = (x + width / 2) / documentWidth;
90
+ const centerPercentY = (y + containerHeightScaled / 2) / documentHeight;
91
+ if (!isNaN(dx) && centerPercentX >= 0.5) {
92
+ x += dx;
93
+ }
94
+ if (!isNaN(dy) && centerPercentY >= 0.5) {
95
+ y += dy;
96
+ }
97
+ }
98
+ }
99
+ const clickBlocker = (e) => {
100
+ e.stopPropagation();
101
+ };
102
+ let startWidth = 0;
103
+ let startOffsetX = 0;
104
+ let startOffsetY = 0;
105
+ let moveDistance = 0;
106
+ const doubleClickListener = (e) => {
107
+ e.stopPropagation();
108
+ if (e.target) {
109
+ if (width !== void 0 && e.target === widthHandleElement) {
110
+ if (width < maxAvailablePanelWidth) {
111
+ width = maxAvailablePanelWidth;
112
+ } else {
113
+ width = minWidth;
114
+ }
115
+ } else if (TITLEBAR_WINDOW_SHADE_DOUBLE_CLICK && e.target === dragBarElement) {
116
+ paneRef.expanded = !paneRef.expanded;
117
+ }
118
+ }
119
+ };
120
+ const downListener = (e) => {
121
+ if (x !== void 0 && y !== void 0 && e.button === 0 && e.target instanceof HTMLElement) {
122
+ moveDistance = 0;
123
+ e.target.setPointerCapture(e.pointerId);
124
+ e.target.addEventListener('pointermove', moveListener);
125
+ e.target.addEventListener('pointerup', upListener);
126
+ startWidth = width ?? 0;
127
+ startOffsetX = x - e.pageX;
128
+ startOffsetY = y - e.pageY;
129
+ }
130
+ };
131
+ const moveListener = (e) => {
132
+ if (
133
+ e.target instanceof HTMLElement &&
134
+ width !== void 0 &&
135
+ minWidth !== void 0 &&
136
+ x !== void 0 &&
137
+ y !== void 0
138
+ ) {
139
+ if (e.target === dragBarElement) {
140
+ moveDistance += Math.sqrt(e.movementX * e.movementX + e.movementY * e.movementY);
141
+ x = e.pageX + startOffsetX;
142
+ y = e.pageY + startOffsetY;
143
+ } else if (e.target === widthHandleElement) {
144
+ width = clamp(e.pageX + startOffsetX + startWidth - x, minWidth, maxAvailablePanelWidth);
145
+ }
146
+ }
147
+ };
148
+ const upListener = (e) => {
149
+ e.stopImmediatePropagation();
150
+ if (e.target instanceof HTMLElement) {
151
+ e.target.releasePointerCapture(e.pointerId);
152
+ e.target.removeEventListener('pointermove', moveListener);
153
+ e.target.removeEventListener('pointerup', upListener);
154
+ if (TITLEBAR_WINDOW_SHADE_SINGLE_CLICK && e.target === dragBarElement) {
155
+ if (moveDistance < 3 && userExpandable) paneRef.expanded = !paneRef.expanded;
156
+ }
157
+ }
158
+ };
159
+ const touchScrollBlocker = (e) => {
160
+ e.preventDefault();
161
+ };
162
+ onMount(() => {
163
+ setDocumentSize();
164
+ if (paneRef) {
165
+ containerElement.appendChild(paneRef.element);
166
+ } else {
167
+ console.warn('no pane ref in draggable');
168
+ }
169
+ containerElement.addEventListener('touchmove', touchScrollBlocker, { passive: false });
170
+ dragBarElement = containerElement.getElementsByClassName('tp-rotv_t')[0];
171
+ dragBarElement.addEventListener('click', clickBlocker);
172
+ dragBarElement.addEventListener('dblclick', doubleClickListener);
173
+ dragBarElement.addEventListener('pointerdown', downListener);
174
+ widthHandleElement = dragBarElement.parentElement?.appendChild(document.createElement('div'));
175
+ if (widthHandleElement) {
176
+ widthHandleElement.className = 'tp-custom-width-handle';
177
+ widthHandleElement.innerText = '\u2194';
178
+ widthHandleElement.addEventListener('click', clickBlocker);
179
+ widthHandleElement.addEventListener('dblclick', doubleClickListener);
180
+ widthHandleElement.addEventListener('pointerdown', downListener);
181
+ }
182
+ });
183
+ onDestroy(() => {
184
+ if (dragBarElement) {
185
+ dragBarElement.removeEventListener('click', clickBlocker);
186
+ dragBarElement.removeEventListener('dblclick', doubleClickListener);
187
+ dragBarElement.removeEventListener('pointerdown', downListener);
188
+ dragBarElement.removeEventListener('pointermove', moveListener);
189
+ dragBarElement.removeEventListener('pointerup', upListener);
190
+ }
191
+ if (widthHandleElement) {
192
+ widthHandleElement.removeEventListener('click', clickBlocker);
193
+ widthHandleElement.removeEventListener('dblclick', doubleClickListener);
194
+ widthHandleElement.removeEventListener('pointerdown', downListener);
195
+ widthHandleElement.removeEventListener('pointermove', moveListener);
196
+ widthHandleElement.removeEventListener('pointerup', upListener);
197
+ }
198
+ if (containerElement) {
199
+ containerElement.removeEventListener('touchmove', touchScrollBlocker);
200
+ }
201
+ if (localStoreId !== void 0) {
202
+ localStoreIds.splice(localStoreIds.indexOf(localStoreId), 1);
203
+ }
204
+ });
205
+ function updateResizability(isResizable) {
206
+ if (widthHandleElement) {
207
+ if (isResizable) {
208
+ widthHandleElement.style.display = 'block';
209
+ } else {
210
+ widthHandleElement.style.display = 'none';
211
+ }
212
+ }
213
+ }
214
+ $: paneRef && resizable && updateResizability(resizable);
215
+ function recursiveCollapse(children, maxToCollapse = Number.MAX_SAFE_INTEGER) {
216
+ console.log(maxToCollapse);
217
+ if (maxToCollapse > 0) {
218
+ children.forEach((child) => {
219
+ if ('expanded' in child) {
220
+ if (child.expanded) {
221
+ maxToCollapse--;
222
+ child.expanded = false;
223
+ }
224
+ if ('children' in child) {
225
+ recursiveCollapse(child.children, maxToCollapse);
226
+ }
227
+ } else {
228
+ const swatchButton = getSwatchButton(child);
229
+ if (swatchButton && pickerIsOpen(child)) {
230
+ maxToCollapse--;
231
+ swatchButton.click();
232
+ }
233
+ }
234
+ });
235
+ }
236
+ }
237
+ $: if (
238
+ containerHeightScaled !== void 0 &&
239
+ documentWidth !== void 0 &&
240
+ documentHeight !== void 0 &&
241
+ x !== void 0 &&
242
+ y !== void 0 &&
243
+ width !== void 0 &&
244
+ minWidth !== void 0 &&
245
+ maxWidth !== void 0
246
+ ) {
247
+ if (collapseChildrenToFit && containerHeightScaled > documentHeight) {
248
+ recursiveCollapse(paneRef.children);
249
+ }
250
+ x = clamp(x, 0, Math.max(0, documentWidth - containerWidth));
251
+ y = clamp(y, 0, Math.max(0, documentHeight - containerHeightScaled));
252
+ if (documentWidth < containerWidth) {
253
+ width = Math.max(minWidth, Math.min(maxWidth, documentWidth));
254
+ }
255
+ }
256
+ $: maxAvailablePanelWidth = Math.min(maxWidth ?? 600, documentWidth - (x ?? 0));
257
+ $: localStoreId, storePositionLocally && addStorageId();
258
+ $: localStoreId, !storePositionLocally && removeStorageId();
259
+ $: localStoreId !== `${localStorePrefix}${localStoreId}` && updateLocalStoreId(localStoreId);
260
+ $: storePositionLocally &&
261
+ localStoreId !== void 0 &&
262
+ x !== void 0 &&
263
+ y !== void 0 &&
264
+ width !== void 0 &&
265
+ expanded !== void 0 &&
266
+ positionStore?.set({ x, y, expanded, width });
267
+ $: {
268
+ if (containerElement) {
269
+ if (scale === void 0 || scale === 1) {
270
+ containerHeightScaled = containerHeight;
271
+ } else {
272
+ const style = window.getComputedStyle(containerElement);
273
+ const vPadding = parseFloat(style.paddingTop) + parseFloat(style.paddingBottom);
274
+ containerHeightScaled = (containerHeight - vPadding) * scale + vPadding;
275
+ }
276
+ }
277
+ }
278
+ </script>
279
+
280
+ <svelte:window on:resize={setDocumentSize} />
281
+
282
+ <div
283
+ bind:this={containerElement}
284
+ bind:clientHeight={containerHeight}
285
+ bind:clientWidth={containerWidth}
286
+ on:focus|capture={() => {
287
+ zIndexLocal = ++zIndexGlobal;
288
+ }}
289
+ on:pointerdown|capture={() => {
290
+ zIndexLocal = ++zIndexGlobal;
291
+ }}
292
+ class="svelte-tweakpane-ui
293
+ draggable-container"
294
+ class:not-collapsable={!userExpandable}
295
+ class:not-resizable={!resizable}
296
+ style:left="{x}px"
297
+ style:padding
298
+ style:top="{y}px"
299
+ style:width="{width}px"
300
+ style:z-index={zIndexLocal}
301
+ >
302
+ <GenericPane bind:expanded bind:paneRef {scale} {title} {...removeKeys($$restProps, 'position')}>
303
+ <slot />
304
+ </GenericPane>
305
+ </div>
306
+
307
+ <style>
308
+ div.draggable-container {
309
+ position: fixed;
310
+ z-index: auto;
311
+ padding: 20px;
312
+ /* 0.2s matches Tweakpane's internal animation duration */
313
+ transition: width 0.2s ease;
314
+ }
315
+
316
+ div.draggable-container:active {
317
+ /* prevent animation during direct manipulation */
318
+ transition: width 0s ease;
319
+ /* alternate less specific approach */
320
+ /* transition: none; */
321
+ }
322
+
323
+ /* stylelint-disable-next-line selector-class-pattern */
324
+ div.draggable-container :global(div.tp-rotv_t) {
325
+ cursor: grab;
326
+ }
327
+
328
+ div.draggable-container.not-collapsable :global(div.tp-rotv_t) {
329
+ /* TODO remove the magic numbers */
330
+ /* Expand the drag bar to fill the missing window shade icon space */
331
+ margin-left: -28px;
332
+ padding-left: 28px;
333
+ }
334
+
335
+ div.draggable-container.not-resizable :global(div.tp-rotv_t) {
336
+ /* TODO remove the magic numbers */
337
+ /* Expand the drag bar to fill the missing width drag icon space */
338
+ margin-right: -28px;
339
+ padding-right: 28px;
340
+ }
341
+
342
+ div.draggable-container :global(div.tp-lblv_l) {
343
+ white-space: nowrap;
344
+ }
345
+
346
+ div.draggable-container :global(div.tp-rotv_t:active) {
347
+ cursor: grabbing;
348
+ }
349
+
350
+ div.draggable-container :global(div.tp-rotv_m) {
351
+ right: unset;
352
+ left: 0;
353
+ /* inflate the icon into a better hit zone */
354
+ margin: auto calc((var(--cnt-usz) + (var(--cnt-hp)) - 6px) / 2);
355
+ }
356
+
357
+ div.draggable-container :global(div.tp-custom-width-handle) {
358
+ cursor: col-resize;
359
+ position: absolute;
360
+ top: 0;
361
+ right: 0;
362
+ aspect-ratio: 1;
363
+ height: 100%;
364
+ font-size: 1.5em;
365
+ color: var(--tp-container-fg);
366
+ opacity: 0.5;
367
+ }
368
+ </style>
@@ -0,0 +1,178 @@
1
+ import { SvelteComponent } from 'svelte';
2
+ import type { Pane as TpPane } from 'tweakpane';
3
+ declare const __propDef: {
4
+ props: Omit<
5
+ {
6
+ /**
7
+ * Text in the pane's title bar.
8
+ * @default `Tweakpane` \
9
+ * Unless `position='inline'`, in which case the default is `undefined` and no title bar is
10
+ * shown.
11
+ */
12
+ title?: string | undefined;
13
+ /**
14
+ * Allow users to interactively expand / contract the pane by clicking its title bar.
15
+ *
16
+ * Hides the collapse button from the title bar when `false`.
17
+ * @default `true`
18
+ */
19
+ userExpandable?: boolean | undefined;
20
+ /**
21
+ * Expand or collapse the pane into its title bar.
22
+ * @default `true`
23
+ * @bindable
24
+ */
25
+ expanded?: boolean | undefined;
26
+ /**
27
+ * Custom color scheme.
28
+ *
29
+ * Applies to all child components, but note that setting a different `theme` on a child
30
+ * component's prop will **not** override the parent pane's theme.
31
+ *
32
+ * Note that `<Pane position="inline' ...>` squares off rounded corners by default to better
33
+ * integrate with surrounding content.
34
+ *
35
+ * Simply pass a custom or default theme like `ThemeUtils.presets.standard` if you want rounded
36
+ * corners on an `inline` pane.
37
+ *
38
+ * See also the `setGlobalDefaultTheme()` for a way to set a custom default theme for all panes
39
+ * on the page.
40
+ * @default `undefined` \
41
+ * Inherits default Tweakpane theme equivalent to `ThemeUtils.presets.standard`, or the theme
42
+ * set with `setGlobalDefaultTheme()`.
43
+ */
44
+ theme?: import('..').Theme | undefined;
45
+ /**
46
+ * Scales the pane's elements by a factor of `scale` to make it easier to see.
47
+ *
48
+ * Holds the width of the pane constant, so the pane will grow taller as it is scaled and will
49
+ * continue to respect position- and size-related props. If you need more breathing room, set
50
+ * the `width` property on the pane.
51
+ *
52
+ * Note that the scaling prop is only available on `<Pane>`, not on stand-alone (implicitly
53
+ * wrapped) inline elements.
54
+ *
55
+ * Negative values are ignored.
56
+ * @default `1`
57
+ */
58
+ scale?: number | undefined;
59
+ /** Internal use only. */
60
+ userCreatedPane?: boolean | undefined;
61
+ /**
62
+ * Internal use only.
63
+ * @readonly
64
+ */
65
+ paneRef?: TpPane | undefined;
66
+ },
67
+ 'userCreatedPane' | 'paneRef'
68
+ > & {
69
+ /**
70
+ * Horizontal position of the pane relative to the left edge of the window, in pixels.
71
+ *
72
+ * Not to be confused with the `position` prop which defines _how_, not _where_, the pane is
73
+ * positioned on the page. (So-named because of its similarity to CSS `position` property.)
74
+ *
75
+ * By default, this position is saved to local storage for persistence across page loads.
76
+ * @default `0`
77
+ * @bindable
78
+ * */
79
+ x?: number | undefined;
80
+ /**
81
+ * Vertical position of the pane relative to the top of the window, in pixels.
82
+ *
83
+ * Not to be confused with the `position` prop which defines _how_, not _where_, the pane is
84
+ * positioned on the page. (So-named because of its similarity to CSS `position` property.)
85
+ *
86
+ * By default, this position is saved to local storage for persistence across page loads.
87
+ * @default `0`
88
+ * @bindable
89
+ * */
90
+ y?: number | undefined;
91
+ /**
92
+ * Minimum pane width in pixels.
93
+ * @default `200`
94
+ * */
95
+ minWidth?: number | undefined;
96
+ /**
97
+ * Maximum pane width in pixels.
98
+ * @default `600`
99
+ * */
100
+ maxWidth?: number | undefined;
101
+ /**
102
+ * Automatically collapse open panels when the available window size is less than the height
103
+ * of the pane.
104
+ *
105
+ * @default `false`
106
+ * */
107
+ collapseChildrenToFit?: boolean | undefined;
108
+ /**
109
+ * Identifier to be used if multiple `<Pane position='draggable'>` components with
110
+ * `storePositionLocally` set to true are used on the same page.
111
+ * @default `'1'`
112
+ */
113
+ localStoreId?: string | undefined;
114
+ /**
115
+ * CSS [padding property string](https://developer.mozilla.org/en-US/docs/Web/CSS/padding)
116
+ * to apply to the draggable pane container to prevent it from being dragged all the way to
117
+ * the edge of the window.
118
+ *
119
+ * Useful for keeping the pane away from of menu bars, etc.
120
+ * @default `'0'`
121
+ */
122
+ padding?: string | undefined;
123
+ /**
124
+ * Allow the user to resize the width of the pane by dragging the right corner of the title
125
+ * bar.
126
+ * @default `true`
127
+ * */
128
+ resizable?: boolean | undefined;
129
+ /**
130
+ * Store the pane's position and width when the user changes it interactively.
131
+ *
132
+ * Set the `localStoreId` prop if you have multiple draggable panes on the same page with
133
+ * `storePositionLocally` set to `true`.
134
+ * @default `true`
135
+ * */
136
+ storePositionLocally?: boolean | undefined;
137
+ /**
138
+ * Width of the pane, in pixels.
139
+ *
140
+ * Setting explicitly via a passed prop will override saved user-specified width.
141
+ *
142
+ * Use this prop to set a starting width, or to monitor changes in the the pane's width when
143
+ * a user resizes it.
144
+ *
145
+ * Note that height is not exposed because it is determined dynamically by the pane's
146
+ * contents and state of its foldable elements.
147
+ *
148
+ * By default, the width value is saved to local storage for persistence across page loads.
149
+ * @default `256`
150
+ * @bindable
151
+ * */
152
+ width?: number | undefined;
153
+ };
154
+ events: {
155
+ [evt: string]: CustomEvent<any>;
156
+ };
157
+ slots: {
158
+ /**
159
+ * Any Tweakpane component, except another `<Pane>`.
160
+ */
161
+ default: {};
162
+ };
163
+ };
164
+ export type InternalPaneDraggableProps = typeof __propDef.props;
165
+ export type InternalPaneDraggableEvents = typeof __propDef.events;
166
+ export type InternalPaneDraggableSlots = typeof __propDef.slots;
167
+ /**
168
+ * This component is for internal use only.
169
+ *
170
+ * @sourceLink
171
+ * [InternalPaneDraggable.svelte](https://github.com/kitschpatrol/svelte-tweakpane-ui/blob/main/src/lib/internal/InternalPaneDraggable.svelte)
172
+ */
173
+ export default class InternalPaneDraggable extends SvelteComponent<
174
+ InternalPaneDraggableProps,
175
+ InternalPaneDraggableEvents,
176
+ InternalPaneDraggableSlots
177
+ > {}
178
+ export {};