svelte-tweakpane-ui 1.5.13 → 1.5.14
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.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script>
|
|
2
2
|
import { BROWSER } from 'esm-env'
|
|
3
|
-
import { getContext, onDestroy, onMount, setContext } from 'svelte'
|
|
3
|
+
import { getContext, onDestroy, onMount, setContext, tick } from 'svelte'
|
|
4
4
|
import { writable } from 'svelte/store'
|
|
5
5
|
import ClsPad from '../internal/ClsPad.svelte'
|
|
6
6
|
import InternalPaneInline from '../internal/InternalPaneInline.svelte'
|
|
@@ -13,17 +13,25 @@
|
|
|
13
13
|
setContext('tabGroupStore', tabGroupStore)
|
|
14
14
|
const tabIndexStore = writable()
|
|
15
15
|
setContext('tabIndexStore', tabIndexStore)
|
|
16
|
+
setContext('initialSelectedIndex', selectedIndex)
|
|
17
|
+
const tabGroupInitialized = writable(false)
|
|
16
18
|
const userCreatedPane = getContext('userCreatedPane')
|
|
17
19
|
let indexElement
|
|
18
|
-
onMount(() => {
|
|
20
|
+
onMount(async () => {
|
|
19
21
|
$tabIndexStore = userCreatedPane ? getElementIndex(indexElement) : 0
|
|
22
|
+
await tick()
|
|
23
|
+
setSelectedIndex(selectedIndex)
|
|
24
|
+
$tabGroupInitialized = true
|
|
20
25
|
})
|
|
21
26
|
onDestroy(() => {
|
|
22
27
|
$tabGroupStore?.dispose()
|
|
23
28
|
})
|
|
24
29
|
function setUpListeners(t) {
|
|
25
30
|
t?.on('select', (event) => {
|
|
26
|
-
|
|
31
|
+
const isInDocument = indexElement?.isConnected ?? false
|
|
32
|
+
if ($tabGroupInitialized && isInDocument && event.index >= 0) {
|
|
33
|
+
selectedIndex = event.index
|
|
34
|
+
}
|
|
27
35
|
})
|
|
28
36
|
}
|
|
29
37
|
function setSelectedIndex(index) {
|
|
@@ -31,7 +39,7 @@
|
|
|
31
39
|
if (tabPageApi && !tabPageApi.selected) tabPageApi.selected = true
|
|
32
40
|
}
|
|
33
41
|
$: setUpListeners($tabGroupStore)
|
|
34
|
-
$: setSelectedIndex(selectedIndex)
|
|
42
|
+
$: $tabGroupStore && setSelectedIndex(selectedIndex)
|
|
35
43
|
$: $tabGroupStore && ($tabGroupStore.disabled = disabled)
|
|
36
44
|
$: theme &&
|
|
37
45
|
$parentStore &&
|
package/dist/core/TabPage.svelte
CHANGED
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
const tabGroupStore = getContext('tabGroupStore')
|
|
14
14
|
const tabIndexStore = getContext('tabIndexStore')
|
|
15
15
|
const userCreatedPane = getContext('userCreatedPane')
|
|
16
|
+
const initialSelectedIndex = getContext('initialSelectedIndex')
|
|
16
17
|
const parentStore = getContext('parentStore')
|
|
17
18
|
const tabPageStore = writable()
|
|
18
19
|
setContext('parentStore', tabPageStore)
|
|
@@ -31,9 +32,14 @@
|
|
|
31
32
|
pages: [{ title }],
|
|
32
33
|
})
|
|
33
34
|
$tabPageStore = $tabGroupStore.pages[0]
|
|
34
|
-
|
|
35
|
+
if (index === initialSelectedIndex) {
|
|
36
|
+
selected = true
|
|
37
|
+
}
|
|
35
38
|
} else if (!$tabPageStore && $tabGroupStore) {
|
|
36
39
|
$tabPageStore = $tabGroupStore.addPage({ index, title })
|
|
40
|
+
if (index === initialSelectedIndex) {
|
|
41
|
+
selected = true
|
|
42
|
+
}
|
|
37
43
|
}
|
|
38
44
|
$tabGroupStore?.on('select', () => {
|
|
39
45
|
$tabPageStore && (selected = $tabPageStore.selected)
|
|
@@ -64,9 +64,9 @@ export type AutoObjectSlots = typeof __propDef.slots
|
|
|
64
64
|
* position="inline">`.
|
|
65
65
|
*
|
|
66
66
|
* `<AutoObject>` was inspired by the
|
|
67
|
-
* [`<TWPAutoMutable>`](https://github.com/
|
|
68
|
-
* component in [Dmitriy Nikiforov's](https://github.com/
|
|
69
|
-
* [solid-tweakpane](https://github.com/
|
|
67
|
+
* [`<TWPAutoMutable>`](https://github.com/0x241F31/solid-tweakpane/blob/master/src/automutable.tsx)
|
|
68
|
+
* component in [Dmitriy Nikiforov's](https://github.com/0x241F31)
|
|
69
|
+
* [solid-tweakpane](https://github.com/0x241F31/solid-tweakpane) library.
|
|
70
70
|
*
|
|
71
71
|
* Plugin component behavior is not available in `<AutoObject>`.
|
|
72
72
|
*
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
if (localStoreId !== void 0) {
|
|
53
53
|
if (localStoreIds.includes(localStoreId)) {
|
|
54
54
|
console.warn(
|
|
55
|
-
'Multiple instances of <Pane> with `
|
|
55
|
+
'Multiple instances of <Pane> with `position="draggable"` and `storePositionLocally=true` detected. You must explicitly set unique localStoreId property on each component to avoid collisions.',
|
|
56
56
|
)
|
|
57
57
|
}
|
|
58
58
|
localStoreIds.push(localStoreId)
|
|
@@ -106,6 +106,8 @@
|
|
|
106
106
|
let startOffsetX = 0
|
|
107
107
|
let startOffsetY = 0
|
|
108
108
|
let moveDistance = 0
|
|
109
|
+
let startScrollX = 0
|
|
110
|
+
let startScrollY = 0
|
|
109
111
|
const doubleClickListener = (event) => {
|
|
110
112
|
event.stopPropagation()
|
|
111
113
|
if (event.target) {
|
|
@@ -125,6 +127,8 @@
|
|
|
125
127
|
const dragStartListener = (event) => {
|
|
126
128
|
if (x !== void 0 && y !== void 0 && event.button === 0 && event.target instanceof HTMLElement) {
|
|
127
129
|
moveDistance = 0
|
|
130
|
+
startScrollY = window.scrollY
|
|
131
|
+
startScrollX = window.scrollX
|
|
128
132
|
initialDragEvent = event
|
|
129
133
|
removeDragStartListeners()
|
|
130
134
|
addDragMoveAndEndListeners()
|
|
@@ -148,8 +152,8 @@
|
|
|
148
152
|
) {
|
|
149
153
|
if (event.target === dragBarElement) {
|
|
150
154
|
moveDistance += Math.hypot(event.movementX, event.movementY)
|
|
151
|
-
x = event.pageX + startOffsetX
|
|
152
|
-
y = event.pageY + startOffsetY
|
|
155
|
+
x = event.pageX + startOffsetX - (window.scrollX - startScrollX)
|
|
156
|
+
y = event.pageY + startOffsetY - (window.scrollY - startScrollY)
|
|
153
157
|
} else if (event.target === widthHandleElement) {
|
|
154
158
|
width = clamp(event.pageX + startOffsetX + startWidth - x, minWidth, maxAvailablePanelWidth)
|
|
155
159
|
}
|
|
@@ -179,6 +183,8 @@
|
|
|
179
183
|
if (event.target === dragBarElement) {
|
|
180
184
|
dragBarElement.style.removeProperty('cursor')
|
|
181
185
|
}
|
|
186
|
+
startScrollY = 0
|
|
187
|
+
startScrollX = 0
|
|
182
188
|
containerElement.style.removeProperty('transition')
|
|
183
189
|
if (
|
|
184
190
|
event.type === 'pointerup' &&
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "svelte-tweakpane-ui",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.14",
|
|
4
4
|
"description": "A Svelte component library wrapping UI elements from Tweakpane, plus some additional functionality for convenience and flexibility.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"components",
|
|
@@ -201,12 +201,12 @@
|
|
|
201
201
|
"tweakpane": "4.0.5"
|
|
202
202
|
},
|
|
203
203
|
"devDependencies": {
|
|
204
|
-
"@kitschpatrol/shared-config": "^5.
|
|
204
|
+
"@kitschpatrol/shared-config": "^5.13.0",
|
|
205
205
|
"@phenomnomnominal/tsquery": "^6.1.4",
|
|
206
|
-
"@playwright/test": "^1.
|
|
206
|
+
"@playwright/test": "^1.58.1",
|
|
207
207
|
"@stkb/rewrap": "^0.1.0",
|
|
208
208
|
"@sveltejs/adapter-static": "^3.0.10",
|
|
209
|
-
"@sveltejs/kit": "^2.50.
|
|
209
|
+
"@sveltejs/kit": "^2.50.2",
|
|
210
210
|
"@sveltejs/package": "^2.5.7",
|
|
211
211
|
"@sveltejs/vite-plugin-svelte": "^3.1.2",
|
|
212
212
|
"@types/eslint": "^8.56.12",
|
|
@@ -214,14 +214,14 @@
|
|
|
214
214
|
"bumpp": "^10.4.0",
|
|
215
215
|
"glob": "^13.0.0",
|
|
216
216
|
"node-addon-api": "^8.5.0",
|
|
217
|
-
"node-gyp": "^12.
|
|
217
|
+
"node-gyp": "^12.2.0",
|
|
218
218
|
"postcss-html": "^1.8.1",
|
|
219
|
-
"publint": "^0.3.
|
|
219
|
+
"publint": "^0.3.17",
|
|
220
220
|
"read-package-up": "^12.0.0",
|
|
221
221
|
"svelte": "^4.2.20",
|
|
222
|
-
"svelte-check": "^4.3.
|
|
223
|
-
"svelte-language-server": "^0.17.
|
|
224
|
-
"svelte2tsx": "^0.7.
|
|
222
|
+
"svelte-check": "^4.3.6",
|
|
223
|
+
"svelte-language-server": "^0.17.25",
|
|
224
|
+
"svelte2tsx": "^0.7.47",
|
|
225
225
|
"ts-morph": "^27.0.2",
|
|
226
226
|
"tslib": "^2.8.1",
|
|
227
227
|
"tsx": "^4.21.0",
|