svelte-tweakpane-ui 1.0.0 → 1.0.1
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/README.md +10 -3
- package/dist/control/ButtonGrid.svelte +4 -4
- package/dist/control/ButtonGrid.svelte.d.ts +6 -4
- package/dist/control/CubicBezier.svelte +13 -21
- package/dist/control/CubicBezier.svelte.d.ts +2 -2
- package/dist/control/Image.svelte.d.ts +5 -5
- package/dist/control/List.svelte +7 -7
- package/dist/control/Text.svelte +1 -1
- package/dist/control/Textarea.svelte +1 -1
- package/dist/core/TabGroup.svelte +3 -5
- package/dist/extra/AutoObject.svelte +5 -3
- package/dist/extra/Element.svelte +1 -1
- package/dist/extra/Element.svelte.d.ts +30 -23
- package/dist/internal/ClsPad.svelte +5 -5
- package/dist/internal/GenericBladeFolding.svelte +4 -4
- package/dist/internal/GenericInputFolding.svelte +4 -4
- package/dist/internal/InternalPaneDraggable.svelte +57 -52
- package/dist/internal/InternalPaneInline.svelte +2 -2
- package/dist/monitor/FpsGraph.svelte +5 -2
- package/dist/monitor/FpsGraph.svelte.d.ts +2 -2
- package/dist/monitor/Monitor.svelte.d.ts +1 -1
- package/dist/monitor/Profiler.svelte +9 -6
- package/dist/monitor/Profiler.svelte.d.ts +8 -5
- package/dist/theme.js +15 -17
- package/dist/utils.d.ts +6 -6
- package/dist/utils.js +20 -20
- package/package.json +16 -39
package/README.md
CHANGED
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
# svelte-tweakpane-ui
|
|
2
2
|
|
|
3
|
+
[](https://npmjs.com/package/svelte-tweakpane-ui)
|
|
4
|
+
[](https://kitschpatrol.com/svelte-tweakpane-ui)
|
|
5
|
+
|
|
3
6
|
## Overview
|
|
4
7
|
|
|
5
|
-
🎛️ **_Svelte Tweakpane UI_** wraps user-interface elements from the excellent [Tweakpane](https://cocopon.github.io/tweakpane/) library in a collection of 31 idiomatic, reactive, type-safe, carefully-crafted [Svelte](https://svelte.dev) components.
|
|
8
|
+
🎛️ **_Svelte Tweakpane UI_** wraps user-interface elements from the excellent [Tweakpane](https://cocopon.github.io/tweakpane/) library in a collection of 31 idiomatic, reactive, type-safe, carefully-crafted, and obsessively-documented [Svelte](https://svelte.dev) components.
|
|
6
9
|
|
|
7
|
-
The library makes it easy to quickly and declaratively add knobs and dials to your projects using components that feel like they
|
|
10
|
+
The library makes it easy to quickly and declaratively add knobs and dials to your projects using components that feel like they were made for Svelte. It also augments Tweakpane with a few [extra features](https://kitschpatrol.com/svelte-tweakpane-ui/docs/features) for your convenience and enjoyment.
|
|
8
11
|
|
|
9
12
|
[The components](https://kitschpatrol.com/svelte-tweakpane-ui/docs#components) should be useful for integrating controls and value monitoring in parametrically driven artworks or simulations.
|
|
10
13
|
|
|
14
|
+
## Demo
|
|
15
|
+
|
|
16
|
+

|
|
17
|
+
|
|
11
18
|
## Documentation
|
|
12
19
|
|
|
13
20
|
**_Please see the documentation site for much more information:_**
|
|
@@ -28,7 +35,7 @@ npm install svelte-tweakpane-ui
|
|
|
28
35
|
import { Button } from 'svelte-tweakpane-ui';
|
|
29
36
|
</script>
|
|
30
37
|
|
|
31
|
-
<Button on:click={() => alert('
|
|
38
|
+
<Button on:click={() => alert('🎛️')} />
|
|
32
39
|
```
|
|
33
40
|
|
|
34
41
|
---
|
|
@@ -33,11 +33,11 @@
|
|
|
33
33
|
view: 'buttongrid'
|
|
34
34
|
};
|
|
35
35
|
$: gridBlade &&
|
|
36
|
-
gridBlade.on('click', (
|
|
36
|
+
gridBlade.on('click', (event) => {
|
|
37
37
|
dispatch('click', {
|
|
38
|
-
cell: { x:
|
|
39
|
-
index:
|
|
40
|
-
label:
|
|
38
|
+
cell: { x: event.index[0], y: event.index[1] },
|
|
39
|
+
index: event.index[1] * gridDimensions.columns + event.index[0],
|
|
40
|
+
label: event.cell.title
|
|
41
41
|
});
|
|
42
42
|
});
|
|
43
43
|
</script>
|
|
@@ -128,7 +128,9 @@ export type ButtonGridSlots = typeof __propDef.slots;
|
|
|
128
128
|
* } from 'svelte-tweakpane-ui';
|
|
129
129
|
*
|
|
130
130
|
* const keyboard = [
|
|
131
|
-
* ...Array.from({ length: 26 }, (_,
|
|
131
|
+
* ...Array.from({ length: 26 }, (_, index) =>
|
|
132
|
+
* String.fromCodePoint(65 + index)
|
|
133
|
+
* ),
|
|
132
134
|
* ',',
|
|
133
135
|
* '.',
|
|
134
136
|
* '!',
|
|
@@ -137,11 +139,11 @@ export type ButtonGridSlots = typeof __propDef.slots;
|
|
|
137
139
|
*
|
|
138
140
|
* let textBuffer = '';
|
|
139
141
|
*
|
|
140
|
-
* function handleClick(
|
|
142
|
+
* function handleClick(event: ButtonGridClickEvent) {
|
|
141
143
|
* textBuffer =
|
|
142
|
-
*
|
|
144
|
+
* event.detail.label === '⌫'
|
|
143
145
|
* ? textBuffer.slice(0, -1)
|
|
144
|
-
* : textBuffer +
|
|
146
|
+
* : textBuffer + event.detail.label;
|
|
145
147
|
* }
|
|
146
148
|
* </script>
|
|
147
149
|
*
|
|
@@ -14,31 +14,23 @@
|
|
|
14
14
|
let cubicBezierBlade;
|
|
15
15
|
const buttonClass = 'tp-cbzv_b';
|
|
16
16
|
function getValue() {
|
|
17
|
-
|
|
18
|
-
return value;
|
|
19
|
-
} else {
|
|
20
|
-
return [value.x1, value.y1, value.x2, value.y2];
|
|
21
|
-
}
|
|
17
|
+
return Array.isArray(value) ? value : [value.x1, value.y1, value.x2, value.y2];
|
|
22
18
|
}
|
|
23
19
|
function setValue() {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
cubicBezierBlade.value = new CubicBezier(value.x1, value.y1, value.x2, value.y2);
|
|
28
|
-
}
|
|
20
|
+
cubicBezierBlade.value = Array.isArray(value)
|
|
21
|
+
? new CubicBezier(value[0], value[1], value[2], value[3])
|
|
22
|
+
: new CubicBezier(value.x1, value.y1, value.x2, value.y2);
|
|
29
23
|
}
|
|
30
24
|
function addEvent() {
|
|
31
|
-
cubicBezierBlade.on('change', (
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
};
|
|
41
|
-
}
|
|
25
|
+
cubicBezierBlade.on('change', (event) => {
|
|
26
|
+
value = Array.isArray(value)
|
|
27
|
+
? [event.value.x1, event.value.y1, event.value.x2, event.value.y2]
|
|
28
|
+
: {
|
|
29
|
+
x1: event.value.x1,
|
|
30
|
+
y1: event.value.y1,
|
|
31
|
+
x2: event.value.x2,
|
|
32
|
+
y2: event.value.y2
|
|
33
|
+
};
|
|
42
34
|
});
|
|
43
35
|
}
|
|
44
36
|
$: options = {
|
|
@@ -136,7 +136,7 @@ export type CubicBezierSlots = typeof __propDef.slots;
|
|
|
136
136
|
* import { tweened } from 'svelte/motion';
|
|
137
137
|
*
|
|
138
138
|
* // could also be a tuple
|
|
139
|
-
* let value: CubicBezierValue = { x1: 0.25, y1: 0.1, x2: 0.25, y2: 1
|
|
139
|
+
* let value: CubicBezierValue = { x1: 0.25, y1: 0.1, x2: 0.25, y2: 1 };
|
|
140
140
|
* let duration = 1000;
|
|
141
141
|
* let moods = ['Set', 'Rise'];
|
|
142
142
|
* let mood: string = moods[0];
|
|
@@ -160,7 +160,7 @@ export type CubicBezierSlots = typeof __propDef.slots;
|
|
|
160
160
|
* <Slider
|
|
161
161
|
* bind:value={duration}
|
|
162
162
|
* min={0}
|
|
163
|
-
* max={
|
|
163
|
+
* max={10_000}
|
|
164
164
|
* format={(v) => `${(v / 1000).toFixed(1)}`}
|
|
165
165
|
* label="Duration (Seconds)"
|
|
166
166
|
* />
|
|
@@ -125,14 +125,14 @@ export type ImageSlots = typeof __propDef.slots;
|
|
|
125
125
|
* <script lang="ts">
|
|
126
126
|
* import { Button, Image } from 'svelte-tweakpane-ui';
|
|
127
127
|
*
|
|
128
|
-
* let
|
|
128
|
+
* let source = 'placeholder';
|
|
129
129
|
* let kittenIndex = 1;
|
|
130
130
|
* </script>
|
|
131
131
|
*
|
|
132
|
-
* <Image bind:value={
|
|
132
|
+
* <Image bind:value={source} fit="contain" label="Image" />
|
|
133
133
|
* <Button
|
|
134
134
|
* on:click={() => {
|
|
135
|
-
*
|
|
135
|
+
* source = `https://placekitten.com/1024/1024?image=${kittenIndex}`;
|
|
136
136
|
* kittenIndex = (kittenIndex % 16) + 1;
|
|
137
137
|
* }}
|
|
138
138
|
* label="Random Placeholder"
|
|
@@ -140,10 +140,10 @@ export type ImageSlots = typeof __propDef.slots;
|
|
|
140
140
|
* />
|
|
141
141
|
*
|
|
142
142
|
* <div class="demo">
|
|
143
|
-
* {#if
|
|
143
|
+
* {#if source === 'placeholder'}
|
|
144
144
|
* <p>Tap “No Image” above to load an image from disk.</p>
|
|
145
145
|
* {:else}
|
|
146
|
-
* <img alt="" {
|
|
146
|
+
* <img alt="" src={source} />
|
|
147
147
|
* {/if}
|
|
148
148
|
* </div>
|
|
149
149
|
*
|
package/dist/control/List.svelte
CHANGED
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
let listBlade;
|
|
11
11
|
let bladeOptions;
|
|
12
12
|
function addEvent() {
|
|
13
|
-
listBlade.on('change', (
|
|
14
|
-
value =
|
|
13
|
+
listBlade.on('change', (event) => {
|
|
14
|
+
value = event.value;
|
|
15
15
|
});
|
|
16
16
|
}
|
|
17
17
|
function getInitialValue() {
|
|
@@ -28,16 +28,16 @@
|
|
|
28
28
|
return value;
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
|
-
function isArrayStyleListOptions(
|
|
31
|
+
function isArrayStyleListOptions(object) {
|
|
32
32
|
return (
|
|
33
|
-
Array.isArray(
|
|
34
|
-
|
|
33
|
+
Array.isArray(object) &&
|
|
34
|
+
object.every(
|
|
35
35
|
(item) => typeof item === 'object' && item !== null && 'text' in item && 'value' in item
|
|
36
36
|
)
|
|
37
37
|
);
|
|
38
38
|
}
|
|
39
|
-
function isObjectStyleListOptions(
|
|
40
|
-
return typeof
|
|
39
|
+
function isObjectStyleListOptions(object) {
|
|
40
|
+
return typeof object === 'object' && object !== null && !Array.isArray(object);
|
|
41
41
|
}
|
|
42
42
|
function getInternalOptions(options2) {
|
|
43
43
|
if (isArrayStyleListOptions(options2)) {
|
package/dist/control/Text.svelte
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
function updateListeners(live2, destroy = false) {
|
|
16
|
-
let input = ref?.controller.valueController.view.element.
|
|
16
|
+
let input = ref?.controller.valueController.view.element.querySelector('input');
|
|
17
17
|
if (input) {
|
|
18
18
|
input.removeEventListener('input', onInput);
|
|
19
19
|
!destroy && live2 && input.addEventListener('input', onInput);
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
value = event.target.value;
|
|
23
23
|
}
|
|
24
24
|
function updateListeners(live2, destroy = false) {
|
|
25
|
-
var input = ref?.controller.valueController.view.element.
|
|
25
|
+
var input = ref?.controller.valueController.view.element.querySelector('textarea');
|
|
26
26
|
if (input) {
|
|
27
27
|
input.removeEventListener('blur', onBlur);
|
|
28
28
|
input.removeEventListener('input', onInput);
|
|
@@ -22,15 +22,13 @@
|
|
|
22
22
|
$tabGroupStore?.dispose();
|
|
23
23
|
});
|
|
24
24
|
function setUpListeners(t) {
|
|
25
|
-
t?.on('select', (
|
|
26
|
-
selectedIndex =
|
|
25
|
+
t?.on('select', (event) => {
|
|
26
|
+
selectedIndex = event.index;
|
|
27
27
|
});
|
|
28
28
|
}
|
|
29
29
|
function setSelectedIndex(index) {
|
|
30
30
|
const tabPageApi = $tabGroupStore?.pages.at(index);
|
|
31
|
-
if (tabPageApi)
|
|
32
|
-
if (!tabPageApi.selected) tabPageApi.selected = true;
|
|
33
|
-
}
|
|
31
|
+
if (tabPageApi && !tabPageApi.selected) tabPageApi.selected = true;
|
|
34
32
|
}
|
|
35
33
|
$: BROWSER && setUpListeners($tabGroupStore);
|
|
36
34
|
$: BROWSER && setSelectedIndex(selectedIndex);
|
|
@@ -12,13 +12,15 @@
|
|
|
12
12
|
export let prettyLabels = true;
|
|
13
13
|
export let object;
|
|
14
14
|
const parentStore = getContext('parentStore');
|
|
15
|
-
function isPointObject(
|
|
16
|
-
return
|
|
15
|
+
function isPointObject(testObject) {
|
|
16
|
+
return (
|
|
17
|
+
Point2d.isObject(testObject) || Point3d.isObject(testObject) || Point4d.isObject(testObject)
|
|
18
|
+
);
|
|
17
19
|
}
|
|
18
20
|
function prettify(value, active = true) {
|
|
19
21
|
if (!active) return value;
|
|
20
22
|
return value
|
|
21
|
-
.replace(/([
|
|
23
|
+
.replace(/([\da-z])([A-Z])/g, '$1 $2')
|
|
22
24
|
.replace(/[_-]+/g, ' ')
|
|
23
25
|
.toLowerCase()
|
|
24
26
|
.replace(/\b[a-z]/g, (letter) => {
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
<div
|
|
28
28
|
class="element-container"
|
|
29
29
|
style:height={BROWSER ? null : `${maxHeight}px`}
|
|
30
|
-
style:max-height={maxHeight
|
|
30
|
+
style:max-height={maxHeight === undefined ? null : `${maxHeight}px`}
|
|
31
31
|
style:overflow={BROWSER ? null : 'hidden'}
|
|
32
32
|
>
|
|
33
33
|
<div class:reset={resetStyle}>
|
|
@@ -44,20 +44,22 @@ declare const __propDef: {
|
|
|
44
44
|
'options' | 'disabled' | 'ref' | 'plugin'
|
|
45
45
|
> & {
|
|
46
46
|
/**
|
|
47
|
-
* Maximum height of the element block, in pixels. By default, the element
|
|
48
|
-
* vertically to fit its contents, but clip any horizontal
|
|
47
|
+
* Maximum height of the element block, in pixels. By default, the element
|
|
48
|
+
* block will expand vertically to fit its contents, but clip any horizontal
|
|
49
|
+
* excess.
|
|
49
50
|
*
|
|
50
|
-
* If a max height is set, it is used as the component height during SSR. If
|
|
51
|
-
* element content is less than the max, you will see CLS. If it
|
|
52
|
-
* are rendered... but keep in mind that style and
|
|
53
|
-
* client render could result in CLS.
|
|
51
|
+
* If a max height is set, it is used as the component height during SSR. If
|
|
52
|
+
* the actual element content is less than the max, you will see CLS. If it
|
|
53
|
+
* is not set, the contents are rendered... but keep in mind that style and
|
|
54
|
+
* other contextual changes during the client render could result in CLS.
|
|
54
55
|
* @default `undefined` \
|
|
55
56
|
* No max height.
|
|
56
57
|
*/
|
|
57
58
|
maxHeight?: number | undefined;
|
|
58
59
|
/**
|
|
59
|
-
* Whether to reset the CSS of the element block to its default values.
|
|
60
|
-
* of Tweakpane's CSS styles. Note that this uses a
|
|
60
|
+
* Whether to reset the CSS of the element block to its default values.
|
|
61
|
+
* Avoids inheritance of Tweakpane's CSS styles. Note that this uses a
|
|
62
|
+
* simple `all: initial;` rule.
|
|
61
63
|
* @default `true`
|
|
62
64
|
*/
|
|
63
65
|
resetStyle?: boolean | undefined;
|
|
@@ -78,25 +80,30 @@ export type ElementSlots = typeof __propDef.slots;
|
|
|
78
80
|
/**
|
|
79
81
|
* A component for embedding arbitrary HTML elements into a pane.
|
|
80
82
|
*
|
|
81
|
-
* Any children wrapped in this component will be rendered into the pane. Any
|
|
82
|
-
* pane in the horizontal axis will be clipped.
|
|
83
|
+
* Any children wrapped in this component will be rendered into the pane. Any
|
|
84
|
+
* content larger than the pane in the horizontal axis will be clipped.
|
|
83
85
|
*
|
|
84
|
-
* Useful for quickly prototyping UIs, or adding content to a pane that's not
|
|
85
|
-
* built-in components.
|
|
86
|
+
* Useful for quickly prototyping UIs, or adding content to a pane that's not
|
|
87
|
+
* easily represented by the built-in components.
|
|
86
88
|
*
|
|
87
|
-
*
|
|
88
|
-
* otherwise, but it's recommended to abstract new functionality for reuse by extending one of the
|
|
89
|
-
* internal component types in 'svelte-tweakpane-ui', or better yet by creating a new [Tweakpane
|
|
90
|
-
* Plugin](https://github.com/tweakpane/plugin-template).
|
|
89
|
+
* This component does not have a direct analog in the vanilla Tweakpane universe.
|
|
91
90
|
*
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
-
*
|
|
95
|
-
*
|
|
96
|
-
*
|
|
91
|
+
* Think of `<Element>` as an escape hatch for getting something into the pane that
|
|
92
|
+
* you couldn't otherwise. Generally, it's recommended to abstract new
|
|
93
|
+
* functionality for reuse by extending one of the internal component types in
|
|
94
|
+
* 'svelte-tweakpane-ui', or better yet by creating a new [Tweakpane
|
|
95
|
+
* Plugin](https://github.com/tweakpane/plugin-template) — but sometimes you just
|
|
96
|
+
* need to get something into the pane quickly.
|
|
97
97
|
*
|
|
98
|
-
*
|
|
99
|
-
*
|
|
98
|
+
* In many cases, this component should not be necessary because _Svelte Tweakpane
|
|
99
|
+
* UI_ already makes it easy to combine tweakpane components with other inline
|
|
100
|
+
* elements simply by using stand-alone components or a `<Pane position='inline'>`
|
|
101
|
+
* component. `<Element>` should generally be the most useful when you're using
|
|
102
|
+
* `<Pane position='draggable'>` or `<Pane position='fixed'>` and you want a custom
|
|
103
|
+
* element embedded in the pane.
|
|
104
|
+
*
|
|
105
|
+
* Usage outside of a `<Pane>` component doesn't make a ton of sense, but in such a
|
|
106
|
+
* case the `<Element>` will be implicitly wrapped in `<Pane position='inline'>`.
|
|
100
107
|
*
|
|
101
108
|
* @example
|
|
102
109
|
* ```svelte
|
|
@@ -10,15 +10,15 @@
|
|
|
10
10
|
return '#' + Math.floor(Math.random() * 16777215).toString(16);
|
|
11
11
|
}
|
|
12
12
|
function getPixelValue(s) {
|
|
13
|
-
return parseFloat(s.replace('px', ''));
|
|
13
|
+
return Number.parseFloat(s.replace('px', ''));
|
|
14
14
|
}
|
|
15
15
|
function getTotal(add, sub, extra2 = 0) {
|
|
16
16
|
return (
|
|
17
|
-
add.reduce((
|
|
18
|
-
return (
|
|
17
|
+
add.reduce((accumulator, key) => {
|
|
18
|
+
return (accumulator += getPixelValue(getValueOrFallback(theme, key)));
|
|
19
19
|
}, 0) -
|
|
20
|
-
sub.reduce((
|
|
21
|
-
return (
|
|
20
|
+
sub.reduce((accumulator, key) => {
|
|
21
|
+
return (accumulator += getPixelValue(getValueOrFallback(theme, key)));
|
|
22
22
|
}, 0) +
|
|
23
23
|
extra2
|
|
24
24
|
);
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
let internalExpanded = initialExpanded;
|
|
15
15
|
$: if (!gotBlade && ref) {
|
|
16
16
|
gotBlade = true;
|
|
17
|
-
ref.controller?.valueController?.foldable_?.value('expanded').emitter.on('change', (
|
|
18
|
-
internalExpanded =
|
|
17
|
+
ref.controller?.valueController?.foldable_?.value('expanded').emitter.on('change', (event) => {
|
|
18
|
+
internalExpanded = event.rawValue;
|
|
19
19
|
expanded = internalExpanded;
|
|
20
20
|
});
|
|
21
21
|
}
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
$: ref &&
|
|
32
32
|
buttonClass !== void 0 &&
|
|
33
33
|
expanded !== internalExpanded &&
|
|
34
|
-
ref.element.
|
|
35
|
-
ref.element.
|
|
34
|
+
ref.element.querySelectorAll(`.${buttonClass}`).length > 0 &&
|
|
35
|
+
ref.element.querySelector(`.${buttonClass}`).click();
|
|
36
36
|
</script>
|
|
37
37
|
|
|
38
38
|
<Blade bind:ref {options} {...$$restProps} />
|
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
let internalExpanded = initialExpanded;
|
|
19
19
|
$: if (!gotBinding && ref) {
|
|
20
20
|
gotBinding = true;
|
|
21
|
-
ref.controller?.valueController?.foldable_?.value('expanded').emitter.on('change', (
|
|
22
|
-
internalExpanded =
|
|
21
|
+
ref.controller?.valueController?.foldable_?.value('expanded').emitter.on('change', (event) => {
|
|
22
|
+
internalExpanded = event.rawValue;
|
|
23
23
|
expanded = internalExpanded;
|
|
24
24
|
});
|
|
25
25
|
}
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
$: ref &&
|
|
34
34
|
buttonClass &&
|
|
35
35
|
expanded !== internalExpanded &&
|
|
36
|
-
ref.element.
|
|
37
|
-
ref.element.
|
|
36
|
+
ref.element.querySelectorAll(`.${buttonClass}`).length > 0 &&
|
|
37
|
+
ref.element.querySelector(`.${buttonClass}`).click();
|
|
38
38
|
</script>
|
|
39
39
|
|
|
40
40
|
<GenericInput bind:value bind:ref options={optionsInternal} {...$$restProps} />
|
|
@@ -88,93 +88,97 @@
|
|
|
88
88
|
const dy = documentHeight - documentHeightPrevious;
|
|
89
89
|
const centerPercentX = (x + width / 2) / documentWidth;
|
|
90
90
|
const centerPercentY = (y + containerHeightScaled / 2) / documentHeight;
|
|
91
|
-
if (!isNaN(dx) && centerPercentX >= 0.5) {
|
|
91
|
+
if (!Number.isNaN(dx) && centerPercentX >= 0.5) {
|
|
92
92
|
x += dx;
|
|
93
93
|
}
|
|
94
|
-
if (!isNaN(dy) && centerPercentY >= 0.5) {
|
|
94
|
+
if (!Number.isNaN(dy) && centerPercentY >= 0.5) {
|
|
95
95
|
y += dy;
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
|
-
const clickBlocker = (
|
|
100
|
-
|
|
99
|
+
const clickBlocker = (event) => {
|
|
100
|
+
event.stopPropagation();
|
|
101
101
|
};
|
|
102
102
|
let startWidth = 0;
|
|
103
103
|
let startOffsetX = 0;
|
|
104
104
|
let startOffsetY = 0;
|
|
105
105
|
let moveDistance = 0;
|
|
106
|
-
const doubleClickListener = (
|
|
107
|
-
|
|
108
|
-
if (
|
|
109
|
-
if (width !== void 0 &&
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
} else {
|
|
113
|
-
width = minWidth;
|
|
114
|
-
}
|
|
115
|
-
} else if (TITLEBAR_WINDOW_SHADE_DOUBLE_CLICK && e.target === dragBarElement) {
|
|
106
|
+
const doubleClickListener = (event) => {
|
|
107
|
+
event.stopPropagation();
|
|
108
|
+
if (event.target) {
|
|
109
|
+
if (width !== void 0 && event.target === widthHandleElement) {
|
|
110
|
+
width = width < maxAvailablePanelWidth ? maxAvailablePanelWidth : minWidth;
|
|
111
|
+
} else if (TITLEBAR_WINDOW_SHADE_DOUBLE_CLICK && event.target === dragBarElement) {
|
|
116
112
|
paneRef.expanded = !paneRef.expanded;
|
|
117
113
|
}
|
|
118
114
|
}
|
|
119
115
|
};
|
|
120
|
-
const downListener = (
|
|
121
|
-
if (x !== void 0 && y !== void 0 &&
|
|
116
|
+
const downListener = (event) => {
|
|
117
|
+
if (x !== void 0 && y !== void 0 && event.button === 0 && event.target instanceof HTMLElement) {
|
|
122
118
|
moveDistance = 0;
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
119
|
+
event.target.setPointerCapture(event.pointerId);
|
|
120
|
+
event.target.addEventListener('pointermove', moveListener);
|
|
121
|
+
event.target.addEventListener('pointerup', upListener);
|
|
126
122
|
startWidth = width ?? 0;
|
|
127
|
-
startOffsetX = x -
|
|
128
|
-
startOffsetY = y -
|
|
123
|
+
startOffsetX = x - event.pageX;
|
|
124
|
+
startOffsetY = y - event.pageY;
|
|
129
125
|
}
|
|
130
126
|
};
|
|
131
|
-
const moveListener = (
|
|
127
|
+
const moveListener = (event) => {
|
|
132
128
|
if (
|
|
133
|
-
|
|
129
|
+
event.target instanceof HTMLElement &&
|
|
134
130
|
width !== void 0 &&
|
|
135
131
|
minWidth !== void 0 &&
|
|
136
132
|
x !== void 0 &&
|
|
137
133
|
y !== void 0
|
|
138
134
|
) {
|
|
139
|
-
if (
|
|
140
|
-
moveDistance += Math.
|
|
141
|
-
x =
|
|
142
|
-
y =
|
|
143
|
-
} else if (
|
|
144
|
-
width = clamp(
|
|
135
|
+
if (event.target === dragBarElement) {
|
|
136
|
+
moveDistance += Math.hypot(event.movementX, event.movementY);
|
|
137
|
+
x = event.pageX + startOffsetX;
|
|
138
|
+
y = event.pageY + startOffsetY;
|
|
139
|
+
} else if (event.target === widthHandleElement) {
|
|
140
|
+
width = clamp(
|
|
141
|
+
event.pageX + startOffsetX + startWidth - x,
|
|
142
|
+
minWidth,
|
|
143
|
+
maxAvailablePanelWidth
|
|
144
|
+
);
|
|
145
145
|
}
|
|
146
146
|
}
|
|
147
147
|
};
|
|
148
|
-
const upListener = (
|
|
149
|
-
|
|
150
|
-
if (
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
if (
|
|
155
|
-
|
|
156
|
-
|
|
148
|
+
const upListener = (event) => {
|
|
149
|
+
event.stopImmediatePropagation();
|
|
150
|
+
if (event.target instanceof HTMLElement) {
|
|
151
|
+
event.target.releasePointerCapture(event.pointerId);
|
|
152
|
+
event.target.removeEventListener('pointermove', moveListener);
|
|
153
|
+
event.target.removeEventListener('pointerup', upListener);
|
|
154
|
+
if (
|
|
155
|
+
TITLEBAR_WINDOW_SHADE_SINGLE_CLICK &&
|
|
156
|
+
event.target === dragBarElement &&
|
|
157
|
+
moveDistance < 3 &&
|
|
158
|
+
userExpandable
|
|
159
|
+
)
|
|
160
|
+
paneRef.expanded = !paneRef.expanded;
|
|
157
161
|
}
|
|
158
162
|
};
|
|
159
|
-
const touchScrollBlocker = (
|
|
160
|
-
|
|
163
|
+
const touchScrollBlocker = (event) => {
|
|
164
|
+
event.preventDefault();
|
|
161
165
|
};
|
|
162
166
|
onMount(() => {
|
|
163
167
|
setDocumentSize();
|
|
164
168
|
if (paneRef) {
|
|
165
|
-
containerElement.
|
|
169
|
+
containerElement.append(paneRef.element);
|
|
166
170
|
} else {
|
|
167
171
|
console.warn('no pane ref in draggable');
|
|
168
172
|
}
|
|
169
173
|
containerElement.addEventListener('touchmove', touchScrollBlocker, { passive: false });
|
|
170
|
-
dragBarElement = containerElement.
|
|
174
|
+
dragBarElement = containerElement.querySelector('.tp-rotv_t');
|
|
171
175
|
dragBarElement.addEventListener('click', clickBlocker);
|
|
172
176
|
dragBarElement.addEventListener('dblclick', doubleClickListener);
|
|
173
177
|
dragBarElement.addEventListener('pointerdown', downListener);
|
|
174
178
|
widthHandleElement = dragBarElement.parentElement?.appendChild(document.createElement('div'));
|
|
175
179
|
if (widthHandleElement) {
|
|
176
180
|
widthHandleElement.className = 'tp-custom-width-handle';
|
|
177
|
-
widthHandleElement.
|
|
181
|
+
widthHandleElement.textContent = '\u2194';
|
|
178
182
|
widthHandleElement.addEventListener('click', clickBlocker);
|
|
179
183
|
widthHandleElement.addEventListener('dblclick', doubleClickListener);
|
|
180
184
|
widthHandleElement.addEventListener('pointerdown', downListener);
|
|
@@ -204,18 +208,13 @@
|
|
|
204
208
|
});
|
|
205
209
|
function updateResizability(isResizable) {
|
|
206
210
|
if (widthHandleElement) {
|
|
207
|
-
|
|
208
|
-
widthHandleElement.style.display = 'block';
|
|
209
|
-
} else {
|
|
210
|
-
widthHandleElement.style.display = 'none';
|
|
211
|
-
}
|
|
211
|
+
widthHandleElement.style.display = isResizable ? 'block' : 'none';
|
|
212
212
|
}
|
|
213
213
|
}
|
|
214
214
|
$: paneRef && resizable && updateResizability(resizable);
|
|
215
215
|
function recursiveCollapse(children, maxToCollapse = Number.MAX_SAFE_INTEGER) {
|
|
216
|
-
console.log(maxToCollapse);
|
|
217
216
|
if (maxToCollapse > 0) {
|
|
218
|
-
|
|
217
|
+
for (const child of children) {
|
|
219
218
|
if ('expanded' in child) {
|
|
220
219
|
if (child.expanded) {
|
|
221
220
|
maxToCollapse--;
|
|
@@ -231,7 +230,7 @@
|
|
|
231
230
|
swatchButton.click();
|
|
232
231
|
}
|
|
233
232
|
}
|
|
234
|
-
}
|
|
233
|
+
}
|
|
235
234
|
}
|
|
236
235
|
}
|
|
237
236
|
$: if (
|
|
@@ -270,7 +269,8 @@
|
|
|
270
269
|
containerHeightScaled = containerHeight;
|
|
271
270
|
} else {
|
|
272
271
|
const style = window.getComputedStyle(containerElement);
|
|
273
|
-
const vPadding =
|
|
272
|
+
const vPadding =
|
|
273
|
+
Number.parseFloat(style.paddingTop) + Number.parseFloat(style.paddingBottom);
|
|
274
274
|
containerHeightScaled = (containerHeight - vPadding) * scale + vPadding;
|
|
275
275
|
}
|
|
276
276
|
}
|
|
@@ -323,6 +323,11 @@ draggable-container"
|
|
|
323
323
|
/* stylelint-disable-next-line selector-class-pattern */
|
|
324
324
|
div.draggable-container :global(div.tp-rotv_t) {
|
|
325
325
|
cursor: grab;
|
|
326
|
+
overflow: hidden;
|
|
327
|
+
/* Ensure draggable hit zone does not collapse if title is missing */
|
|
328
|
+
/* Fixes #1 */
|
|
329
|
+
height: 100%;
|
|
330
|
+
text-overflow: ellipsis;
|
|
326
331
|
}
|
|
327
332
|
|
|
328
333
|
div.draggable-container.not-collapsable :global(div.tp-rotv_t) {
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
onMount(() => {
|
|
15
15
|
if (paneRef) {
|
|
16
16
|
const fixedContainer = paneRef.element.parentElement;
|
|
17
|
-
containerElement.
|
|
17
|
+
containerElement.append(paneRef.element);
|
|
18
18
|
fixedContainer?.remove();
|
|
19
19
|
} else {
|
|
20
20
|
console.warn('paneRef is undefined');
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
});
|
|
23
23
|
</script>
|
|
24
24
|
|
|
25
|
-
<div bind:this={containerElement} style:width={width
|
|
25
|
+
<div bind:this={containerElement} style:width={width === undefined ? null : `${width}px`}>
|
|
26
26
|
<GenericPane bind:expanded bind:paneRef {theme} {...removeKeys($$restProps, 'position')}>
|
|
27
27
|
<slot />
|
|
28
28
|
</GenericPane>
|
|
@@ -50,8 +50,11 @@
|
|
|
50
50
|
observer = new MutationObserver((mutations) => {
|
|
51
51
|
for (const mutation of mutations) {
|
|
52
52
|
if (mutation.type === 'characterData' || mutation.type === 'childList') {
|
|
53
|
-
const
|
|
54
|
-
|
|
53
|
+
const fpsText = mutation.target.textContent;
|
|
54
|
+
if (fpsText !== null) {
|
|
55
|
+
const fps = Number.parseInt(fpsText);
|
|
56
|
+
!Number.isNaN(fps) && dispatch('change', fps);
|
|
57
|
+
}
|
|
55
58
|
}
|
|
56
59
|
}
|
|
57
60
|
});
|
|
@@ -181,8 +181,8 @@ export type FpsGraphSlots = typeof __propDef.slots;
|
|
|
181
181
|
* <Slider bind:value={rotationSpeed} label="Rotation Speed" />
|
|
182
182
|
*
|
|
183
183
|
* <div class="demo">
|
|
184
|
-
* {#each Array.from({ length: gridSize }, (_,
|
|
185
|
-
* {#each Array.from({ length: gridSize }, (_,
|
|
184
|
+
* {#each Array.from({ length: gridSize }, (_, index) => index) as x}
|
|
185
|
+
* {#each Array.from({ length: gridSize }, (_, index) => index) as y}
|
|
186
186
|
* <div
|
|
187
187
|
* class="box"
|
|
188
188
|
* style:left="{(x / gridSize) * 100}%"
|
|
@@ -501,7 +501,7 @@ export type MonitorSlots<W extends number | string | boolean | unknown> = Return
|
|
|
501
501
|
*
|
|
502
502
|
* setInterval(() => {
|
|
503
503
|
* booleanToMonitor = !booleanToMonitor;
|
|
504
|
-
* stringToMonitor = stringToMonitor.
|
|
504
|
+
* stringToMonitor = [...stringToMonitor].reverse().join('');
|
|
505
505
|
* }, 1000);
|
|
506
506
|
* </script>
|
|
507
507
|
*
|
|
@@ -7,11 +7,11 @@
|
|
|
7
7
|
import { fillWith } from '../utils';
|
|
8
8
|
import { BROWSER } from 'esm-env';
|
|
9
9
|
import { createEventDispatcher, onDestroy } from 'svelte';
|
|
10
|
-
function _measure(name,
|
|
11
|
-
profilerBlade?.measure(name,
|
|
10
|
+
function _measure(name, functionToMeasure) {
|
|
11
|
+
profilerBlade?.measure(name, functionToMeasure);
|
|
12
12
|
}
|
|
13
|
-
async function _measureAsync(name,
|
|
14
|
-
profilerBlade?.measureAsync(name,
|
|
13
|
+
async function _measureAsync(name, functionToMeasure) {
|
|
14
|
+
profilerBlade?.measureAsync(name, functionToMeasure);
|
|
15
15
|
}
|
|
16
16
|
export let label = void 0;
|
|
17
17
|
export let bufferSize = void 0;
|
|
@@ -37,8 +37,11 @@
|
|
|
37
37
|
observer = new MutationObserver((mutations) => {
|
|
38
38
|
for (const mutation of mutations) {
|
|
39
39
|
if (mutation.type === 'characterData' || mutation.type === 'childList') {
|
|
40
|
-
const
|
|
41
|
-
|
|
40
|
+
const fpsText = mutation.target.textContent;
|
|
41
|
+
if (fpsText !== null) {
|
|
42
|
+
const delta = Number.parseFloat(fpsText);
|
|
43
|
+
!Number.isNaN(delta) && dispatch('change', delta);
|
|
44
|
+
}
|
|
42
45
|
}
|
|
43
46
|
}
|
|
44
47
|
});
|
|
@@ -3,8 +3,11 @@ import type { ProfilerBladeMeasureHandler } from '@0b5vr/tweakpane-plugin-profil
|
|
|
3
3
|
import type { Simplify } from '../utils';
|
|
4
4
|
export type ProfilerCalcMode = 'frame' | 'mean' | 'median';
|
|
5
5
|
export type ProfilerChangeEvent = CustomEvent<number>;
|
|
6
|
-
export type ProfilerMeasure = (name: string,
|
|
7
|
-
export type ProfilerMeasureAsync = (
|
|
6
|
+
export type ProfilerMeasure = (name: string, functionToMeasure: () => void) => void;
|
|
7
|
+
export type ProfilerMeasureAsync = (
|
|
8
|
+
name: string,
|
|
9
|
+
functionToMeasure: () => Promise<void>
|
|
10
|
+
) => Promise<void>;
|
|
8
11
|
export type ProfilerMeasureHandler = Simplify<ProfilerBladeMeasureHandler>;
|
|
9
12
|
import type { ProfilerBladeApi as ProfilerRef } from '@0b5vr/tweakpane-plugin-profiler/dist/types/ProfilerBladeApi.js';
|
|
10
13
|
import type { ProfilerBladePluginParams as ProfilerOptions } from '@0b5vr/tweakpane-plugin-profiler/dist/types/ProfilerBladePluginParams.js';
|
|
@@ -201,10 +204,10 @@ export type ProfilerSlots = typeof __propDef.slots;
|
|
|
201
204
|
* let loopExponent = 1;
|
|
202
205
|
*
|
|
203
206
|
* // helper to test Math functions
|
|
204
|
-
* function hardWork(
|
|
205
|
-
* measure(
|
|
207
|
+
* function hardWork(function_: (n: number) => number, exponent: number): void {
|
|
208
|
+
* measure(function_.name, () => {
|
|
206
209
|
* for (let sum = 0; sum < Number('1e' + exponent); sum++) {
|
|
207
|
-
*
|
|
210
|
+
* function_(sum);
|
|
208
211
|
* }
|
|
209
212
|
* });
|
|
210
213
|
* }
|
package/dist/theme.js
CHANGED
|
@@ -36,9 +36,9 @@ const standard = {
|
|
|
36
36
|
// pluginThumbnailListHeight: '400px', pluginThumbnailListThumbSize: '20px',
|
|
37
37
|
// pluginThumbnailListWidth: '200px'
|
|
38
38
|
};
|
|
39
|
-
export const keys = Object.keys(standard).reduce((
|
|
40
|
-
|
|
41
|
-
return
|
|
39
|
+
export const keys = Object.keys(standard).reduce((accumulator, key) => {
|
|
40
|
+
accumulator[key] = key;
|
|
41
|
+
return accumulator;
|
|
42
42
|
}, {});
|
|
43
43
|
const light = {
|
|
44
44
|
baseBackgroundColor: 'hsla(230, 5%, 90%, 1.00)',
|
|
@@ -254,9 +254,9 @@ function expandVariableKey(name) {
|
|
|
254
254
|
if (name.startsWith('--tp-')) {
|
|
255
255
|
return name;
|
|
256
256
|
} else {
|
|
257
|
-
const
|
|
258
|
-
if (
|
|
259
|
-
return
|
|
257
|
+
const variableName = keyToCssVariableMap.get(name);
|
|
258
|
+
if (variableName) {
|
|
259
|
+
return variableName;
|
|
260
260
|
} else {
|
|
261
261
|
throw new Error(`Unknown Tweakpane CSS theme map variable key: "${name}"`);
|
|
262
262
|
}
|
|
@@ -266,24 +266,22 @@ function expandVariableKey(name) {
|
|
|
266
266
|
* Used during SSR to calculate metrics Returns CSS string.
|
|
267
267
|
*/
|
|
268
268
|
export function getValueOrFallback(theme, key) {
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
return stringToCssValue(theme[key]);
|
|
273
|
-
}
|
|
269
|
+
return theme === undefined || theme[key] === undefined
|
|
270
|
+
? stringToCssValue(standard[key])
|
|
271
|
+
: stringToCssValue(theme[key]);
|
|
274
272
|
}
|
|
275
273
|
export function applyTheme(element, theme) {
|
|
276
|
-
const
|
|
274
|
+
const rootDocument = getWindowDocument().documentElement;
|
|
277
275
|
if (theme === undefined) {
|
|
278
|
-
Object.keys(standard)
|
|
276
|
+
for (const k of Object.keys(standard)) {
|
|
279
277
|
const key = expandVariableKey(k);
|
|
280
278
|
if (element.style.getPropertyValue(key).length > 0) {
|
|
281
279
|
// console.log(`Unsetting via undefined theme ${key}`);
|
|
282
280
|
element.style.removeProperty(key);
|
|
283
281
|
}
|
|
284
|
-
}
|
|
282
|
+
}
|
|
285
283
|
} else {
|
|
286
|
-
|
|
284
|
+
for (const [k, v] of Object.entries(theme)) {
|
|
287
285
|
const key = expandVariableKey(k);
|
|
288
286
|
const value = stringToCssValue(v);
|
|
289
287
|
// console.log(`Inspecting ${key}: ${value}`);
|
|
@@ -292,7 +290,7 @@ export function applyTheme(element, theme) {
|
|
|
292
290
|
// then apply it anyway so that any global theme is overridden TODO normalize color
|
|
293
291
|
// representation for comparison? TODO tests for this logic
|
|
294
292
|
const standardValue = standard[k] || undefined;
|
|
295
|
-
const rootValue =
|
|
293
|
+
const rootValue = rootDocument.style.getPropertyValue(key) || undefined;
|
|
296
294
|
const isDeviationFromRoot = (rootValue && value !== rootValue) || false;
|
|
297
295
|
const isDeviationFromStandard = (standardValue && value !== standardValue) || false;
|
|
298
296
|
if (
|
|
@@ -308,7 +306,7 @@ export function applyTheme(element, theme) {
|
|
|
308
306
|
element.style.removeProperty(key);
|
|
309
307
|
}
|
|
310
308
|
}
|
|
311
|
-
}
|
|
309
|
+
}
|
|
312
310
|
}
|
|
313
311
|
}
|
|
314
312
|
/**
|
package/dist/utils.d.ts
CHANGED
|
@@ -65,13 +65,13 @@ export declare function enforceReadonly(
|
|
|
65
65
|
internal: unknown,
|
|
66
66
|
external: unknown,
|
|
67
67
|
componentName?: string,
|
|
68
|
-
|
|
68
|
+
propertyName?: string,
|
|
69
69
|
allowAssignmentToUndefined?: boolean
|
|
70
70
|
): void;
|
|
71
71
|
export declare function isRootPane(container: Container): boolean;
|
|
72
72
|
export declare function clamp(value: number, min: number, max: number): number;
|
|
73
73
|
export declare function getElementIndex(element: HTMLElement): number;
|
|
74
|
-
export declare function removeKeys<T extends object>(
|
|
74
|
+
export declare function removeKeys<T extends object>(object: T, ...keys: string[]): T;
|
|
75
75
|
export declare function updateCollapsibility(
|
|
76
76
|
isUserExpandableEnabled: boolean,
|
|
77
77
|
element: HTMLElement,
|
|
@@ -103,19 +103,19 @@ export declare function tupleToObject<
|
|
|
103
103
|
}
|
|
104
104
|
>(tuple: number[], keys: T[]): O;
|
|
105
105
|
export declare function objectToTuple<T extends string, O extends Record<T, number>>(
|
|
106
|
-
|
|
106
|
+
object: O,
|
|
107
107
|
keys: [T]
|
|
108
108
|
): [number];
|
|
109
109
|
export declare function objectToTuple<T extends string, O extends Record<T, number>>(
|
|
110
|
-
|
|
110
|
+
object: O,
|
|
111
111
|
keys: [T, T]
|
|
112
112
|
): [number, number];
|
|
113
113
|
export declare function objectToTuple<T extends string, O extends Record<T, number>>(
|
|
114
|
-
|
|
114
|
+
object: O,
|
|
115
115
|
keys: [T, T, T]
|
|
116
116
|
): [number, number, number];
|
|
117
117
|
export declare function objectToTuple<T extends string, O extends Record<T, number>>(
|
|
118
|
-
|
|
118
|
+
object: O,
|
|
119
119
|
keys: [T, T, T, T]
|
|
120
120
|
): [number, number, number, number];
|
|
121
121
|
export declare function pickerIsOpen(blade: BladeApi<BladeController<View>>): boolean;
|
package/dist/utils.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
/**
|
|
4
4
|
* For CLS SSR calculation
|
|
5
5
|
*/
|
|
6
|
-
export function rowsForMonitor(buffer
|
|
6
|
+
export function rowsForMonitor(buffer, rows, graph) {
|
|
7
7
|
if (graph) {
|
|
8
8
|
return Math.max(rows ?? 3, 3);
|
|
9
9
|
} else if (buffer === undefined && rows === undefined) {
|
|
@@ -23,7 +23,7 @@ export function rowsForMonitor(buffer = undefined, rows = undefined, graph = und
|
|
|
23
23
|
* Fills an array of length `quantity` with a `value`
|
|
24
24
|
*/
|
|
25
25
|
export function fillWith(value, quantity) {
|
|
26
|
-
return
|
|
26
|
+
return Array.from({ length: quantity }, () => value);
|
|
27
27
|
}
|
|
28
28
|
/**
|
|
29
29
|
* There's no way to enforce readonly properties in Svelte components, so this is a workaround. See
|
|
@@ -52,7 +52,7 @@ export function enforceReadonly(
|
|
|
52
52
|
internal,
|
|
53
53
|
external,
|
|
54
54
|
componentName,
|
|
55
|
-
|
|
55
|
+
propertyName,
|
|
56
56
|
allowAssignmentToUndefined
|
|
57
57
|
) {
|
|
58
58
|
allowAssignmentToUndefined ??= false;
|
|
@@ -63,9 +63,9 @@ export function enforceReadonly(
|
|
|
63
63
|
)
|
|
64
64
|
) {
|
|
65
65
|
const componentString = componentName ? `<${componentName}> ` : '';
|
|
66
|
-
const
|
|
66
|
+
const propertyString = propertyName ? `property "${propertyName}" ` : '';
|
|
67
67
|
console.error(
|
|
68
|
-
`Svelte component ${componentString}property ${
|
|
68
|
+
`Svelte component ${componentString}property ${propertyString}is intended for readonly use.\nAssigning\n"${external}"\nto\n"${internal}"\nis not allowed.`
|
|
69
69
|
);
|
|
70
70
|
}
|
|
71
71
|
}
|
|
@@ -85,25 +85,25 @@ export function getElementIndex(element) {
|
|
|
85
85
|
return index;
|
|
86
86
|
}
|
|
87
87
|
// doesn't create a new object, only works with string keys
|
|
88
|
-
export function removeKeys(
|
|
89
|
-
|
|
90
|
-
if (key in
|
|
91
|
-
delete
|
|
88
|
+
export function removeKeys(object, ...keys) {
|
|
89
|
+
for (const key of keys) {
|
|
90
|
+
if (key in object) {
|
|
91
|
+
delete object[key];
|
|
92
92
|
}
|
|
93
|
-
}
|
|
94
|
-
return
|
|
93
|
+
}
|
|
94
|
+
return object;
|
|
95
95
|
}
|
|
96
|
-
function clickBlocker(
|
|
96
|
+
function clickBlocker(event) {
|
|
97
97
|
// only block user clicks, not programmatic ones
|
|
98
|
-
console.log(
|
|
99
|
-
if (
|
|
98
|
+
console.log(event.detail);
|
|
99
|
+
if (event.isTrusted) event.stopPropagation();
|
|
100
100
|
}
|
|
101
101
|
// used by folder and pane TODO rewrite to use getSwatchButton etc.
|
|
102
102
|
export function updateCollapsibility(isUserExpandableEnabled, element, titleBarClass, iconClass) {
|
|
103
103
|
if (element) {
|
|
104
|
-
const titleBarElement = element.
|
|
104
|
+
const titleBarElement = element.querySelector(`.${titleBarClass}`);
|
|
105
105
|
if (titleBarElement !== undefined) {
|
|
106
|
-
const iconElement = iconClass ? element.
|
|
106
|
+
const iconElement = iconClass ? element.querySelector(`.${iconClass}`) : undefined;
|
|
107
107
|
if (isUserExpandableEnabled) {
|
|
108
108
|
titleBarElement.removeEventListener('click', clickBlocker, { capture: true });
|
|
109
109
|
titleBarElement.style.cursor = 'pointer';
|
|
@@ -152,14 +152,14 @@ export function getGridDimensions(itemCount, maxColumns, maxRows) {
|
|
|
152
152
|
}
|
|
153
153
|
export function tupleToObject(tuple, keys) {
|
|
154
154
|
const result = {};
|
|
155
|
-
keys.
|
|
155
|
+
for (const [index, key] of keys.entries()) {
|
|
156
156
|
// Assert that the assignment is safe
|
|
157
157
|
result[key] = tuple[index];
|
|
158
|
-
}
|
|
158
|
+
}
|
|
159
159
|
return result;
|
|
160
160
|
}
|
|
161
|
-
export function objectToTuple(
|
|
162
|
-
return keys.map((key) =>
|
|
161
|
+
export function objectToTuple(object, keys) {
|
|
162
|
+
return keys.map((key) => object[key]);
|
|
163
163
|
}
|
|
164
164
|
// tweakpane helpers
|
|
165
165
|
export function pickerIsOpen(blade) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "svelte-tweakpane-ui",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -191,51 +191,35 @@
|
|
|
191
191
|
"@tweakpane/plugin-camerakit": "^0.3.0",
|
|
192
192
|
"@tweakpane/plugin-essentials": "^0.2.0",
|
|
193
193
|
"esm-env": "^1.0.0",
|
|
194
|
-
"nanoid": "^5.0.
|
|
194
|
+
"nanoid": "^5.0.4",
|
|
195
195
|
"svelte-local-storage-store": "^0.6.4",
|
|
196
196
|
"tweakpane": "^4.0.1",
|
|
197
197
|
"tweakpane-plugin-waveform": "^1.0.0"
|
|
198
198
|
},
|
|
199
199
|
"devDependencies": {
|
|
200
|
+
"@kitschpatrol/shared-config": "^2.0.1",
|
|
200
201
|
"@phenomnomnominal/tsquery": "^6.1.3",
|
|
201
202
|
"@stkb/rewrap": "^0.1.0",
|
|
202
203
|
"@sveltejs/adapter-static": "^2.0.3",
|
|
203
|
-
"@sveltejs/kit": "^1.27.
|
|
204
|
+
"@sveltejs/kit": "^1.27.7",
|
|
204
205
|
"@sveltejs/package": "^2.2.3",
|
|
205
206
|
"@types/eslint": "^8.44.8",
|
|
206
207
|
"@types/fs-extra": "^11.0.4",
|
|
207
|
-
"@types/node": "^20.10.
|
|
208
|
-
"@typescript-eslint/eslint-plugin": "^6.13.1",
|
|
209
|
-
"@typescript-eslint/parser": "^6.13.1",
|
|
210
|
-
"cspell": "^8.1.0",
|
|
211
|
-
"eslint": "^8.55.0",
|
|
212
|
-
"eslint-config-prettier": "^9.0.0",
|
|
213
|
-
"eslint-plugin-perfectionist": "^2.5.0",
|
|
214
|
-
"eslint-plugin-svelte": "^2.35.1",
|
|
208
|
+
"@types/node": "^20.10.4",
|
|
215
209
|
"fs-extra": "^11.2.0",
|
|
216
210
|
"glob": "^10.3.10",
|
|
217
|
-
"markdownlint": "^0.32.1",
|
|
218
|
-
"markdownlint-cli": "^0.37.0",
|
|
219
211
|
"npm-run-all": "^4.1.5",
|
|
220
212
|
"postcss-html": "^1.5.0",
|
|
221
|
-
"prettier": "^3.1.0",
|
|
222
|
-
"prettier-plugin-astro": "^0.12.2",
|
|
223
|
-
"prettier-plugin-pkg": "^0.18.0",
|
|
224
|
-
"prettier-plugin-svelte": "^3.1.2",
|
|
225
213
|
"publint": "^0.2.6",
|
|
226
|
-
"stylelint": "^15.11.0",
|
|
227
|
-
"stylelint-config-clean-order": "^5.2.0",
|
|
228
|
-
"stylelint-config-html": "^1.1.0",
|
|
229
|
-
"stylelint-config-standard": "^34.0.0",
|
|
230
214
|
"svelte": "^4.2.8",
|
|
231
215
|
"svelte-check": "^3.6.2",
|
|
232
216
|
"svelte-language-server": "^0.16.1",
|
|
233
217
|
"svelte2tsx": "^0.6.27",
|
|
234
|
-
"ts-morph": "^
|
|
218
|
+
"ts-morph": "^21.0.1",
|
|
235
219
|
"tslib": "^2.6.2",
|
|
236
|
-
"tsx": "^4.6.
|
|
237
|
-
"typescript": "^5.3.
|
|
238
|
-
"vite": "^4.5.
|
|
220
|
+
"tsx": "^4.6.2",
|
|
221
|
+
"typescript": "^5.3.3",
|
|
222
|
+
"vite": "^4.5.1",
|
|
239
223
|
"yaml": "^2.3.4"
|
|
240
224
|
},
|
|
241
225
|
"scripts": {
|
|
@@ -246,9 +230,9 @@
|
|
|
246
230
|
"build:04-format": "pnpm run format",
|
|
247
231
|
"build:05-package": "svelte-package && publint",
|
|
248
232
|
"build:06-heal-dts-comments": "tsx ./scripts/heal-dts-comments.ts",
|
|
249
|
-
"build:07-strip-component-
|
|
233
|
+
"build:07-strip-component-documentation": "tsx ./scripts/strip-component-documentation.ts",
|
|
250
234
|
"build:08-format-library": "prettier --ignore-path --plugin prettier-plugin-svelte --write ./dist",
|
|
251
|
-
"build:09-doc-data": "tsx ./scripts/generate-
|
|
235
|
+
"build:09-doc-data": "tsx ./scripts/generate-documentation-data.ts",
|
|
252
236
|
"build:10-examples-to-kit": "tsx ./scripts/generate-kit-examples.ts",
|
|
253
237
|
"build:11-examples-to-docs": "tsx ./scripts/generate-example-components.ts",
|
|
254
238
|
"build:12-acknowledgments-data": "mkdir -p ./docs/src/content/acknowledgments && pnpm licenses list --json > ./docs/src/content/acknowledgments/acknowledgments-lib.json",
|
|
@@ -260,21 +244,14 @@
|
|
|
260
244
|
"docs-dev": "pnpm -C ./docs run dev",
|
|
261
245
|
"docs-preview": "pnpm -C ./docs run preview",
|
|
262
246
|
"format": "run-s --print-label format:*",
|
|
263
|
-
"format:1-
|
|
264
|
-
"format:2-
|
|
265
|
-
"format:3-rewrap": "rewrap -i --column 100 `find src \\( -name '*.svelte' -o -name '*.ts' -o -name '*.html' \\) -type f | grep -v src/examples`",
|
|
266
|
-
"format:4-prettier": "prettier --plugin=prettier-plugin-svelte --plugin=prettier-plugin-astro --write .",
|
|
267
|
-
"format:5-embedded": "tsx ./scripts/format-embedded-code.ts",
|
|
247
|
+
"format:1-shared": "shared-config --fix",
|
|
248
|
+
"format:2-embedded": "tsx ./scripts/format-embedded-code.ts",
|
|
268
249
|
"kit-build": "pnpm run kit-examples && vite build",
|
|
269
250
|
"kit-dev": " pnpm run kit-examples && vite dev",
|
|
270
251
|
"kit-examples": "tsx ./scripts/generate-kit-examples.ts",
|
|
271
252
|
"kit-preview": "vite preview",
|
|
272
|
-
"lint": "
|
|
273
|
-
"
|
|
274
|
-
"
|
|
275
|
-
"lint:prettier": "prettier --plugin=prettier-plugin-svelte --plugin=prettier-plugin-astro --check .",
|
|
276
|
-
"lint:spelling": "cspell --quiet .",
|
|
277
|
-
"lint:stylelint": "stylelint './src/**/*.{css,svelte,html}'",
|
|
278
|
-
"lint:typescript": "tsc --noEmit"
|
|
253
|
+
"lint": "shared-config --check",
|
|
254
|
+
"rewrap": "rewrap -i --column 100 `find src \\( -name '*.svelte' -o -name '*.ts' -o -name '*.html' \\) -type f | grep -v src/examples`",
|
|
255
|
+
"type-check": "tsc --noEmit"
|
|
279
256
|
}
|
|
280
257
|
}
|