svelte-tweakpane-ui 1.5.13 → 1.5.15

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,24 +1,7 @@
1
1
  import { SvelteComponent } from 'svelte'
2
2
  export type PanePosition = 'draggable' | 'fixed' | 'inline'
3
3
  declare const __propDef: {
4
- props: {
5
- /**
6
- * Pane mode, one of three options:
7
- * - **'draggable'** *(default)* \
8
- * The pane is draggable and resizable, and may be placed anywhere over the page.
9
- * - **'inline'** \
10
- * The pane appears inline with other content in the normal flow of the document. \
11
- * This is the default mode for components created outside of an explicit `<Pane>`
12
- * component.*
13
- * - **'fixed'** \
14
- * Standard Tweakpane behavior where the pane is shown in a fixed position over the page.
15
- *
16
- * Note that `<Pane>` is a dynamic component, and availability of additional props will
17
- * vary depending on the defined `position` value.
18
- * @default `'draggable'`
19
- */
20
- position?: PanePosition
21
- } & (
4
+ props: (
22
5
  | (Omit<
23
6
  {
24
7
  /**
@@ -432,7 +415,24 @@ declare const __propDef: {
432
415
  */
433
416
  position?: 'draggable' | undefined
434
417
  })
435
- )
418
+ ) & {
419
+ /**
420
+ * Pane mode, one of three options:
421
+ * - **'draggable'** *(default)* \
422
+ * The pane is draggable and resizable, and may be placed anywhere over the page.
423
+ * - **'inline'** \
424
+ * The pane appears inline with other content in the normal flow of the document. \
425
+ * This is the default mode for components created outside of an explicit `<Pane>`
426
+ * component.*
427
+ * - **'fixed'** \
428
+ * Standard Tweakpane behavior where the pane is shown in a fixed position over the page.
429
+ *
430
+ * Note that `<Pane>` is a dynamic component, and availability of additional props will
431
+ * vary depending on the defined `position` value.
432
+ * @default `'draggable'`
433
+ */
434
+ position?: PanePosition
435
+ }
436
436
  events: {
437
437
  [evt: string]: CustomEvent<any>
438
438
  }
@@ -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
- selectedIndex = event.index
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 &&
@@ -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
- selected = true
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/MrFoxPro/solid-tweakpane/blob/master/src/automutable.tsx)
68
- * component in [Dmitriy Nikiforov's](https://github.com/MrFoxPro)
69
- * [solid-tweakpane](https://github.com/MrFoxPro/solid-tweakpane) library.
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 `mode="draggable"` and `storePositionLocally=true` detected. You must explicitly set unique localStoreId property on each component to avoid collisions.',
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.13",
3
+ "version": "1.5.15",
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",
@@ -31,6 +31,7 @@
31
31
  "email": "eric@ericmika.com",
32
32
  "url": "https://ericmika.com"
33
33
  },
34
+ "sideEffects": false,
34
35
  "type": "module",
35
36
  "exports": {
36
37
  ".": {
@@ -201,27 +202,27 @@
201
202
  "tweakpane": "4.0.5"
202
203
  },
203
204
  "devDependencies": {
204
- "@kitschpatrol/shared-config": "^5.12.0",
205
+ "@kitschpatrol/shared-config": "^6.0.2",
205
206
  "@phenomnomnominal/tsquery": "^6.1.4",
206
- "@playwright/test": "^1.57.0",
207
+ "@playwright/test": "^1.58.2",
207
208
  "@stkb/rewrap": "^0.1.0",
208
209
  "@sveltejs/adapter-static": "^3.0.10",
209
- "@sveltejs/kit": "^2.50.0",
210
+ "@sveltejs/kit": "^2.53.4",
210
211
  "@sveltejs/package": "^2.5.7",
211
212
  "@sveltejs/vite-plugin-svelte": "^3.1.2",
212
- "@types/eslint": "^8.56.12",
213
- "@types/node": "^20.19.30",
214
- "bumpp": "^10.4.0",
215
- "glob": "^13.0.0",
216
- "node-addon-api": "^8.5.0",
217
- "node-gyp": "^12.1.0",
213
+ "@types/eslint": "^9.6.1",
214
+ "@types/node": "^20.19.35",
215
+ "bumpp": "^10.4.1",
216
+ "glob": "^13.0.6",
217
+ "node-addon-api": "^8.6.0",
218
+ "node-gyp": "^12.2.0",
218
219
  "postcss-html": "^1.8.1",
219
- "publint": "^0.3.16",
220
+ "publint": "^0.3.18",
220
221
  "read-package-up": "^12.0.0",
221
222
  "svelte": "^4.2.20",
222
- "svelte-check": "^4.3.5",
223
- "svelte-language-server": "^0.17.23",
224
- "svelte2tsx": "^0.7.46",
223
+ "svelte-check": "^4.4.4",
224
+ "svelte-language-server": "^0.17.29",
225
+ "svelte2tsx": "^0.7.51",
225
226
  "ts-morph": "^27.0.2",
226
227
  "tslib": "^2.8.1",
227
228
  "tsx": "^4.21.0",
@@ -232,6 +233,12 @@
232
233
  "peerDependencies": {
233
234
  "svelte": "^4.0.0 || ^5.0.0"
234
235
  },
236
+ "devEngines": {
237
+ "runtime": {
238
+ "name": "node",
239
+ "version": ">=20.19.0"
240
+ }
241
+ },
235
242
  "scripts": {
236
243
  "build": "pnpm run --sequential /^build:/",
237
244
  "build:01-sync": "pnpm run check && pnpm run docs-sync",