svelte-tweakpane-ui 1.1.4 → 1.2.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.
Files changed (73) hide show
  1. package/dist/control/Button.svelte.d.ts +3 -2
  2. package/dist/control/ButtonGrid.svelte.d.ts +20 -9
  3. package/dist/control/Checkbox.svelte +3 -1
  4. package/dist/control/Checkbox.svelte.d.ts +28 -7
  5. package/dist/control/Color.svelte +1 -0
  6. package/dist/control/Color.svelte.d.ts +28 -7
  7. package/dist/control/CubicBezier.svelte +36 -11
  8. package/dist/control/CubicBezier.svelte.d.ts +40 -13
  9. package/dist/control/Image.svelte +1 -1
  10. package/dist/control/Image.svelte.d.ts +32 -7
  11. package/dist/control/IntervalSlider.svelte +1 -1
  12. package/dist/control/IntervalSlider.svelte.d.ts +29 -8
  13. package/dist/control/List.svelte +19 -2
  14. package/dist/control/List.svelte.d.ts +34 -9
  15. package/dist/control/Point.svelte +1 -0
  16. package/dist/control/Point.svelte.d.ts +39 -10
  17. package/dist/control/RadioGrid.svelte +4 -2
  18. package/dist/control/RadioGrid.svelte.d.ts +38 -13
  19. package/dist/control/Ring.svelte +1 -1
  20. package/dist/control/Ring.svelte.d.ts +36 -10
  21. package/dist/control/RotationEuler.svelte +1 -0
  22. package/dist/control/RotationEuler.svelte.d.ts +43 -74
  23. package/dist/control/RotationQuaternion.svelte +1 -0
  24. package/dist/control/RotationQuaternion.svelte.d.ts +28 -12
  25. package/dist/control/Slider.svelte +3 -1
  26. package/dist/control/Slider.svelte.d.ts +32 -11
  27. package/dist/control/Text.svelte +7 -9
  28. package/dist/control/Text.svelte.d.ts +28 -7
  29. package/dist/control/Textarea.svelte +21 -7
  30. package/dist/control/Textarea.svelte.d.ts +38 -20
  31. package/dist/control/Wheel.svelte +3 -1
  32. package/dist/control/Wheel.svelte.d.ts +30 -9
  33. package/dist/core/Binding.svelte +39 -7
  34. package/dist/core/Binding.svelte.d.ts +28 -7
  35. package/dist/core/Blade.svelte.d.ts +17 -7
  36. package/dist/core/Pane.svelte +9 -3
  37. package/dist/core/Pane.svelte.d.ts +98 -71
  38. package/dist/core/Separator.svelte.d.ts +12 -6
  39. package/dist/extra/AutoObject.svelte +28 -5
  40. package/dist/extra/AutoObject.svelte.d.ts +17 -3
  41. package/dist/extra/AutoValue.svelte +4 -2
  42. package/dist/extra/AutoValue.svelte.d.ts +29 -9
  43. package/dist/extra/Element.svelte.d.ts +13 -7
  44. package/dist/index.d.ts +29 -12
  45. package/dist/internal/GenericBinding.svelte +1 -1
  46. package/dist/internal/GenericBinding.svelte.d.ts +14 -6
  47. package/dist/internal/GenericBladeFolding.svelte.d.ts +12 -6
  48. package/dist/internal/GenericInput.svelte +1 -1
  49. package/dist/internal/GenericInput.svelte.d.ts +14 -6
  50. package/dist/internal/GenericInputFolding.svelte +1 -1
  51. package/dist/internal/GenericInputFolding.svelte.d.ts +14 -6
  52. package/dist/internal/GenericMonitor.svelte.d.ts +11 -5
  53. package/dist/internal/GenericPane.svelte +21 -21
  54. package/dist/internal/GenericPane.svelte.d.ts +12 -2
  55. package/dist/internal/GenericSlider.svelte +1 -1
  56. package/dist/internal/GenericSlider.svelte.d.ts +15 -7
  57. package/dist/internal/InternalMonitorBoolean.svelte.d.ts +11 -5
  58. package/dist/internal/InternalMonitorNumber.svelte.d.ts +18 -7
  59. package/dist/internal/InternalMonitorString.svelte.d.ts +11 -5
  60. package/dist/internal/InternalPaneDraggable.svelte +18 -12
  61. package/dist/internal/InternalPaneDraggable.svelte.d.ts +13 -4
  62. package/dist/internal/InternalPaneFixed.svelte +3 -3
  63. package/dist/internal/InternalPaneFixed.svelte.d.ts +13 -4
  64. package/dist/internal/InternalPaneInline.svelte +6 -6
  65. package/dist/internal/InternalPaneInline.svelte.d.ts +72 -66
  66. package/dist/monitor/FpsGraph.svelte.d.ts +12 -6
  67. package/dist/monitor/Monitor.svelte.d.ts +45 -21
  68. package/dist/monitor/Profiler.svelte.d.ts +22 -9
  69. package/dist/monitor/WaveformMonitor.svelte.d.ts +11 -5
  70. package/dist/utils.d.ts +15 -0
  71. package/license.txt +1 -1
  72. package/package.json +22 -17
  73. package/readme.md +31 -4
@@ -1,6 +1,7 @@
1
1
  import { SvelteComponent } from 'svelte';
2
2
  import type { PointDimensionParams } from '@tweakpane/core';
3
3
  import type { Simplify } from '../utils';
4
+ import type { ValueChangeEvent } from '../utils.js';
4
5
  export type RotationQuaternionOptions = Simplify<PointDimensionParams>;
5
6
  export type RotationQuaternionValueObject = {
6
7
  x: number;
@@ -12,6 +13,7 @@ export type RotationQuaternionValueTuple = [x: number, y: number, z: number, w:
12
13
  export type RotationQuaternionValue = Simplify<
13
14
  RotationQuaternionValueObject | RotationQuaternionValueTuple
14
15
  >;
16
+ export type RotationQuaternionChangeEvent = ValueChangeEvent<RotationQuaternionValue>;
15
17
  import type { RotationInputPluginQuaternionParams as RotationQuaternionOptionsInternal } from '@0b5vr/tweakpane-plugin-rotation/dist/types/RotationInputPluginQuaternionParams';
16
18
  declare const __propDef: {
17
19
  props: Omit<
@@ -60,18 +62,24 @@ declare const __propDef: {
60
62
  * [`BindingApi`](https://tweakpane.github.io/docs/api/classes/_internal_.BindingApi.html) for
61
63
  * this control.
62
64
  *
63
- * This is primarily for internal use, when implementing convenience components wrapping
64
- * Binding's functionality.
65
+ * This property is exposed for advanced use cases only, such as when implementing convenience
66
+ * components wrapping `<Binding>`'s functionality.
67
+ *
68
+ * Direct manipulation of Tweakpane's internals can break _Svelte Tweakpane UI_ abstractions.
69
+ *
65
70
  * @bindable
66
71
  * @readonly
67
72
  */
68
73
  ref?: import('../internal/GenericInput.svelte').GenericInputRef | undefined;
69
74
  /**
70
75
  * Imported Tweakpane `TpPluginBundle` (aliased as `Plugin`) module to automatically register in
71
- * the binding's containing `<Pane>`.
76
+ * the `<Binding>`'s containing `<Pane>`.
77
+ *
78
+ * This property is exposed for advanced use cases only, such as when implementing convenience
79
+ * components wrapping `<Binding>`'s functionality in combination with a Tweakpane plugin.
80
+ *
81
+ * Direct manipulation of Tweakpane's internals can break _Svelte Tweakpane UI_ abstractions.
72
82
  *
73
- * This is primarily for internal use, when implementing convenience components wrapping
74
- * Binding's functionality in combination with a Tweakpane plugin.
75
83
  * @default `undefined`
76
84
  */
77
85
  plugin?: import('@tweakpane/core').TpPluginBundle | undefined;
@@ -188,10 +196,21 @@ declare const __propDef: {
188
196
  }
189
197
  | undefined;
190
198
  };
199
+ slots: {};
191
200
  events: {
192
- [evt: string]: CustomEvent<any>;
201
+ /**
202
+ * Fires when `value` changes.
203
+ *
204
+ * _This event is provided for advanced use cases. It's usually preferred to bind to the `value` prop instead._
205
+ *
206
+ * The `event.details` payload includes a copy of the value and an `origin` field to distinguish between user-interactive changes (`internal`)
207
+ * and changes resulting from programmatic manipulation of the `value` (`external`).
208
+ *
209
+ * @extends ValueChangeEvent
210
+ * @event
211
+ * */
212
+ change: RotationQuaternionChangeEvent;
193
213
  };
194
- slots: {};
195
214
  };
196
215
  export type RotationQuaternionProps = typeof __propDef.props;
197
216
  export type RotationQuaternionEvents = typeof __propDef.events;
@@ -211,14 +230,11 @@ export type RotationQuaternionSlots = typeof __propDef.slots;
211
230
  *
212
231
  * See also <RotationEuler> if you're not into the whole `w` thing.
213
232
  *
233
+ * @emits {RotationQuaternionChangeEvent} change - When `value` changes. (This event is provided for advanced use cases. Prefer binding to `value`.)
234
+ *
214
235
  * Usage outside of a `<Pane>` component will implicitly wrap the profiler in `<Pane
215
236
  * position='inline'>`.
216
237
  *
217
- *
218
- *
219
- *
220
- *
221
- *
222
238
  * @example
223
239
  * ```svelte
224
240
  * <script lang="ts">
@@ -1,6 +1,8 @@
1
+ <script context="module"></script>
2
+
1
3
  <script>
2
4
  import GenericSlider from '../internal/GenericSlider.svelte';
3
5
  export let value;
4
6
  </script>
5
7
 
6
- <GenericSlider bind:value {...$$restProps} />
8
+ <GenericSlider bind:value on:change {...$$restProps} />
@@ -1,4 +1,6 @@
1
1
  import { SvelteComponent } from 'svelte';
2
+ import type { ValueChangeEvent } from '../utils.js';
3
+ export type SliderChangeEvent = ValueChangeEvent<number>;
2
4
  declare const __propDef: {
3
5
  props: Omit<
4
6
  Omit<
@@ -46,18 +48,24 @@ declare const __propDef: {
46
48
  * [`BindingApi`](https://tweakpane.github.io/docs/api/classes/_internal_.BindingApi.html) for
47
49
  * this control.
48
50
  *
49
- * This is primarily for internal use, when implementing convenience components wrapping
50
- * Binding's functionality.
51
+ * This property is exposed for advanced use cases only, such as when implementing convenience
52
+ * components wrapping `<Binding>`'s functionality.
53
+ *
54
+ * Direct manipulation of Tweakpane's internals can break _Svelte Tweakpane UI_ abstractions.
55
+ *
51
56
  * @bindable
52
57
  * @readonly
53
58
  */
54
59
  ref?: import('tweakpane').SliderInputBindingApi | undefined;
55
60
  /**
56
61
  * Imported Tweakpane `TpPluginBundle` (aliased as `Plugin`) module to automatically register in
57
- * the binding's containing `<Pane>`.
62
+ * the `<Binding>`'s containing `<Pane>`.
63
+ *
64
+ * This property is exposed for advanced use cases only, such as when implementing convenience
65
+ * components wrapping `<Binding>`'s functionality in combination with a Tweakpane plugin.
66
+ *
67
+ * Direct manipulation of Tweakpane's internals can break _Svelte Tweakpane UI_ abstractions.
58
68
  *
59
- * This is primarily for internal use, when implementing convenience components wrapping
60
- * Binding's functionality in combination with a Tweakpane plugin.
61
69
  * @default `undefined`
62
70
  */
63
71
  plugin?: import('tweakpane').TpPluginBundle | undefined;
@@ -85,7 +93,7 @@ declare const __propDef: {
85
93
  */
86
94
  max?: number | undefined;
87
95
  /**
88
- * A function to customize the point value's formatting (e.g. rounding, etc.).
96
+ * A function to customize the point value's string representation (e.g. rounding, etc.).
89
97
  * @default `undefined` \
90
98
  * Normal `.toString()` formatting.
91
99
  */
@@ -118,26 +126,39 @@ declare const __propDef: {
118
126
  * */
119
127
  value: number;
120
128
  };
129
+ slots: {};
121
130
  events: {
122
- [evt: string]: CustomEvent<any>;
131
+ /**
132
+ * Fires when `value` changes.
133
+ *
134
+ * _This event is provided for advanced use cases. It's usually preferred to bind to the `value` prop instead._
135
+ *
136
+ * The `event.details` payload includes a copy of the value and an `origin` field to distinguish between user-interactive changes (`internal`)
137
+ * and changes resulting from programmatic manipulation of the `value` (`external`).
138
+ *
139
+ * @extends ValueChangeEvent
140
+ * @event
141
+ * */
142
+ change: SliderChangeEvent;
123
143
  };
124
- slots: {};
125
144
  };
126
145
  export type SliderProps = typeof __propDef.props;
127
146
  export type SliderEvents = typeof __propDef.events;
128
147
  export type SliderSlots = typeof __propDef.slots;
129
148
  /**
130
- * A slider component providing fine-grained control over numerical values.
149
+ * A slider component providing fine-grained control over numeric values.
131
150
  *
132
151
  * Wraps Tweakpane's [number bindings](https://tweakpane.github.io/docs/input-bindings/#number).
133
152
  *
134
153
  * Note that if `min` and `max` props are not defined, no linear slider widget will be provided and a
135
154
  * input field with a draggable handle will be used instead.
136
155
  *
137
- * Usage outside of a `<Pane>` component will implicitly wrap the slider in `<Pane position='inline'>`.
138
- *
139
156
  * See the `<Interval>` component for a multi-handle range-defining slider.
140
157
  *
158
+ * @emits {SliderChangeEvent} change - When `value` changes. (This event is provided for advanced use cases. Prefer binding to `value`.)
159
+ *
160
+ * Usage outside of a `<Pane>` component will implicitly wrap the slider in `<Pane position='inline'>`.
161
+ *
141
162
  * @example
142
163
  * ```svelte
143
164
  * <script lang="ts">
@@ -1,3 +1,5 @@
1
+ <script context="module"></script>
2
+
1
3
  <script>
2
4
  import GenericInput from '../internal/GenericInput.svelte';
3
5
  import { onDestroy } from 'svelte';
@@ -8,18 +10,14 @@
8
10
  updateListeners(live ?? true, true);
9
11
  });
10
12
  function onInput(event) {
11
- if (event.target) {
12
- value = event.target.value;
13
- }
13
+ event.target?.dispatchEvent(new Event('change'));
14
14
  }
15
15
  function updateListeners(live2, destroy = false) {
16
- let input = ref?.controller.valueController.view.element.querySelector('input');
17
- if (input) {
18
- input.removeEventListener('input', onInput);
19
- !destroy && live2 && input.addEventListener('input', onInput);
20
- }
16
+ const input = ref?.controller.valueController.view.element.querySelector('input');
17
+ input?.removeEventListener('input', onInput);
18
+ !destroy && live2 && input?.addEventListener('input', onInput);
21
19
  }
22
20
  $: ref && live !== void 0 && updateListeners(live);
23
21
  </script>
24
22
 
25
- <GenericInput bind:value bind:ref {...$$restProps} />
23
+ <GenericInput bind:value bind:ref on:change {...$$restProps} />
@@ -1,4 +1,6 @@
1
1
  import { SvelteComponent } from 'svelte';
2
+ import type { ValueChangeEvent } from '../utils.js';
3
+ export type TextChangeEvent = ValueChangeEvent<string>;
2
4
  import { type GenericInputRef } from '../internal/GenericInput.svelte';
3
5
  declare const __propDef: {
4
6
  props: Omit<
@@ -47,18 +49,24 @@ declare const __propDef: {
47
49
  * [`BindingApi`](https://tweakpane.github.io/docs/api/classes/_internal_.BindingApi.html) for
48
50
  * this control.
49
51
  *
50
- * This is primarily for internal use, when implementing convenience components wrapping
51
- * Binding's functionality.
52
+ * This property is exposed for advanced use cases only, such as when implementing convenience
53
+ * components wrapping `<Binding>`'s functionality.
54
+ *
55
+ * Direct manipulation of Tweakpane's internals can break _Svelte Tweakpane UI_ abstractions.
56
+ *
52
57
  * @bindable
53
58
  * @readonly
54
59
  */
55
60
  ref?: GenericInputRef | undefined;
56
61
  /**
57
62
  * Imported Tweakpane `TpPluginBundle` (aliased as `Plugin`) module to automatically register in
58
- * the binding's containing `<Pane>`.
63
+ * the `<Binding>`'s containing `<Pane>`.
64
+ *
65
+ * This property is exposed for advanced use cases only, such as when implementing convenience
66
+ * components wrapping `<Binding>`'s functionality in combination with a Tweakpane plugin.
67
+ *
68
+ * Direct manipulation of Tweakpane's internals can break _Svelte Tweakpane UI_ abstractions.
59
69
  *
60
- * This is primarily for internal use, when implementing convenience components wrapping
61
- * Binding's functionality in combination with a Tweakpane plugin.
62
70
  * @default `undefined`
63
71
  */
64
72
  plugin?: import('tweakpane').TpPluginBundle | undefined;
@@ -87,10 +95,21 @@ declare const __propDef: {
87
95
  * */
88
96
  live?: boolean | undefined;
89
97
  };
98
+ slots: {};
90
99
  events: {
91
- [evt: string]: CustomEvent<any>;
100
+ /**
101
+ * Fires when `value` changes.
102
+ *
103
+ * _This event is provided for advanced use cases. It's usually preferred to bind to the `value` prop instead._
104
+ *
105
+ * The `event.details` payload includes a copy of the value and an `origin` field to distinguish between user-interactive changes (`internal`)
106
+ * and changes resulting from programmatic manipulation of the `value` (`external`).
107
+ *
108
+ * @extends ValueChangeEvent
109
+ * @event
110
+ * */
111
+ change: TextChangeEvent;
92
112
  };
93
- slots: {};
94
113
  };
95
114
  export type TextProps = typeof __propDef.props;
96
115
  export type TextEvents = typeof __propDef.events;
@@ -105,6 +124,8 @@ export type TextSlots = typeof __propDef.slots;
105
124
  *
106
125
  * See `<TextArea>` for a multi-line input variation.
107
126
  *
127
+ * @emits {TextChangeEvent} change - When `value` changes. (This event is provided for advanced use cases. Prefer binding to `value`.)
128
+ *
108
129
  * Usage outside of a `<Pane>` component will implicitly wrap the text field in `<Pane
109
130
  * position='inline'>`.
110
131
  *
@@ -1,12 +1,16 @@
1
+ <script context="module"></script>
2
+
1
3
  <script>
2
- import * as pluginModule from '@kitschpatrol/tweakpane-textarea-plugin';
4
+ import * as pluginModule from '@pangenerator/tweakpane-textarea-plugin';
3
5
  import GenericInput from '../internal/GenericInput.svelte';
6
+ import {} from '../utils.js';
4
7
  import { BROWSER } from 'esm-env';
5
- import { onDestroy } from 'svelte';
8
+ import { createEventDispatcher, onDestroy } from 'svelte';
6
9
  export let value;
7
10
  export let live = true;
8
11
  export let rows = void 0;
9
12
  export let placeholder = void 0;
13
+ const dispatch = createEventDispatcher();
10
14
  let _value = value;
11
15
  let ref;
12
16
  let options;
@@ -15,17 +19,26 @@
15
19
  });
16
20
  function onBlur(event) {
17
21
  value = event.target.value;
22
+ lastText = value;
23
+ dispatch('change', { value, origin: 'internal' });
18
24
  }
19
25
  function onInput(event) {
20
26
  value = event.target.value;
27
+ lastText = value;
28
+ dispatch('change', { value, origin: 'internal' });
21
29
  }
22
30
  function updateListeners(live2, destroy = false) {
23
31
  const input = ref?.controller.valueController.view.element.querySelector('textarea');
24
- if (input) {
25
- input.removeEventListener('blur', onBlur);
26
- input.removeEventListener('input', onInput);
27
- !destroy && live2 && input.addEventListener('input', onInput);
28
- !destroy && !live2 && input.addEventListener('blur', onBlur);
32
+ input?.removeEventListener('blur', onBlur);
33
+ input?.removeEventListener('input', onInput);
34
+ !destroy && live2 && input?.addEventListener('input', onInput);
35
+ !destroy && !live2 && input?.addEventListener('blur', onBlur);
36
+ }
37
+ let lastText = value;
38
+ function onBoundValueChange(text) {
39
+ if (text !== lastText) {
40
+ dispatch('change', { value: text, origin: 'external' });
41
+ lastText = text;
29
42
  }
30
43
  }
31
44
  $: _value = value;
@@ -35,6 +48,7 @@
35
48
  rows,
36
49
  view: 'textarea'
37
50
  };
51
+ $: ref && onBoundValueChange(_value);
38
52
  </script>
39
53
 
40
54
  <GenericInput value={_value} bind:ref {options} plugin={pluginModule} {...$$restProps} />
@@ -1,5 +1,7 @@
1
1
  import { SvelteComponent } from 'svelte';
2
- import type { TextareaPluginInputParams } from '@kitschpatrol/tweakpane-textarea-plugin/dist/types/plugin.js';
2
+ import type { ValueChangeEvent } from '../utils.js';
3
+ export type TextareaChangeEvent = ValueChangeEvent<string>;
4
+ import type { TextareaPluginInputParams } from '@pangenerator/tweakpane-textarea-plugin/dist/types/plugin.js';
3
5
  import { type GenericInputRef } from '../internal/GenericInput.svelte';
4
6
  declare const __propDef: {
5
7
  props: Omit<
@@ -48,18 +50,24 @@ declare const __propDef: {
48
50
  * [`BindingApi`](https://tweakpane.github.io/docs/api/classes/_internal_.BindingApi.html) for
49
51
  * this control.
50
52
  *
51
- * This is primarily for internal use, when implementing convenience components wrapping
52
- * Binding's functionality.
53
+ * This property is exposed for advanced use cases only, such as when implementing convenience
54
+ * components wrapping `<Binding>`'s functionality.
55
+ *
56
+ * Direct manipulation of Tweakpane's internals can break _Svelte Tweakpane UI_ abstractions.
57
+ *
53
58
  * @bindable
54
59
  * @readonly
55
60
  */
56
61
  ref?: GenericInputRef | undefined;
57
62
  /**
58
63
  * Imported Tweakpane `TpPluginBundle` (aliased as `Plugin`) module to automatically register in
59
- * the binding's containing `<Pane>`.
64
+ * the `<Binding>`'s containing `<Pane>`.
65
+ *
66
+ * This property is exposed for advanced use cases only, such as when implementing convenience
67
+ * components wrapping `<Binding>`'s functionality in combination with a Tweakpane plugin.
68
+ *
69
+ * Direct manipulation of Tweakpane's internals can break _Svelte Tweakpane UI_ abstractions.
60
70
  *
61
- * This is primarily for internal use, when implementing convenience components wrapping
62
- * Binding's functionality in combination with a Tweakpane plugin.
63
71
  * @default `undefined`
64
72
  */
65
73
  plugin?: import('tweakpane').TpPluginBundle | undefined;
@@ -97,32 +105,42 @@ declare const __propDef: {
97
105
  */
98
106
  rows?: number | undefined;
99
107
  };
108
+ slots: {};
100
109
  events: {
101
- [evt: string]: CustomEvent<any>;
110
+ /**
111
+ * Fires when `value` changes.
112
+ *
113
+ * _This event is provided for advanced use cases. It's usually preferred to bind to the `value` prop instead._
114
+ *
115
+ * The `event.details` payload includes a copy of the value and an `origin` field to distinguish between user-interactive changes (`internal`)
116
+ * and changes resulting from programmatic manipulation of the `value` (`external`).
117
+ *
118
+ * @extends ValueChangeEvent
119
+ * @event
120
+ * */
121
+ change: TextareaChangeEvent;
102
122
  };
103
- slots: {};
104
123
  };
105
124
  export type TextareaProps = typeof __propDef.props;
106
125
  export type TextareaEvents = typeof __propDef.events;
107
126
  export type TextareaSlots = typeof __propDef.slots;
108
127
  /**
109
- * A multi-line text input field, in the spirit of the HTML `<textarea>` element.
128
+ * A multi-line text input field, in the spirit of the HTML `<textarea>`
129
+ * element.
110
130
  *
111
131
  * Integrates the
112
- * [tweakpane-textarea-plugin](https://github.com/panGenerator/tweakpane-textarea-plugin) by [Krzysztof
113
- * Goliński](http://www.golinski.org) and [Jakub Koźniewski](https://pangenerator.com).
132
+ * [tweakpane-textarea-plugin](https://github.com/panGenerator/tweakpane-textarea-plugin)
133
+ * by [Krzysztof Goliński](http://www.golinski.org) and [Jakub
134
+ * Koźniewski](https://pangenerator.com).
114
135
  *
115
- * Extends the underlying implementation with the `live` property to match the behavior of the `<Text>`
116
- * component.
136
+ * Extends the underlying implementation with the `live` property to match the
137
+ * behavior of the `<Text>` component.
117
138
  *
118
- * Note that _Svelte Tweakpane UI_ embeds a
119
- * [fork](https://github.com/kitschpatrol/tweakpane-textarea-plugin) of the plugin with support for
120
- * Tweakpane 4. The dependency will be updated to point to the source repository if / when the open
121
- * [pull request](https://github.com/panGenerator/tweakpane-textarea-plugin/pull/4) with Tweakpane 4
122
- * support is merged.
139
+ * @emits {TextareaChangeEvent} change - When `value` changes. (This event is
140
+ * provided for advanced use cases. Prefer binding to `value`.)
123
141
  *
124
- * Usage outside of a `<Pane>` component will implicitly wrap the text area in `<Pane
125
- * position='inline'>`.
142
+ * Usage outside of a `<Pane>` component will implicitly wrap the text area in
143
+ * `<Pane position='inline'>`.
126
144
  *
127
145
  * @example
128
146
  * ```svelte
@@ -1,3 +1,5 @@
1
+ <script context="module"></script>
2
+
1
3
  <script>
2
4
  import * as pluginModule from '@tweakpane/plugin-camerakit';
3
5
  import GenericSlider from '../internal/GenericSlider.svelte';
@@ -12,4 +14,4 @@
12
14
  };
13
15
  </script>
14
16
 
15
- <GenericSlider bind:value {options} plugin={pluginModule} {...$$restProps} />
17
+ <GenericSlider bind:value on:change {options} plugin={pluginModule} {...$$restProps} />
@@ -1,4 +1,6 @@
1
1
  import { SvelteComponent } from 'svelte';
2
+ import type { ValueChangeEvent } from '../utils.js';
3
+ export type WheelChangeEvent = ValueChangeEvent<number>;
2
4
  declare const __propDef: {
3
5
  props: Omit<
4
6
  Omit<
@@ -46,18 +48,24 @@ declare const __propDef: {
46
48
  * [`BindingApi`](https://tweakpane.github.io/docs/api/classes/_internal_.BindingApi.html) for
47
49
  * this control.
48
50
  *
49
- * This is primarily for internal use, when implementing convenience components wrapping
50
- * Binding's functionality.
51
+ * This property is exposed for advanced use cases only, such as when implementing convenience
52
+ * components wrapping `<Binding>`'s functionality.
53
+ *
54
+ * Direct manipulation of Tweakpane's internals can break _Svelte Tweakpane UI_ abstractions.
55
+ *
51
56
  * @bindable
52
57
  * @readonly
53
58
  */
54
59
  ref?: import('tweakpane').SliderInputBindingApi | undefined;
55
60
  /**
56
61
  * Imported Tweakpane `TpPluginBundle` (aliased as `Plugin`) module to automatically register in
57
- * the binding's containing `<Pane>`.
62
+ * the `<Binding>`'s containing `<Pane>`.
63
+ *
64
+ * This property is exposed for advanced use cases only, such as when implementing convenience
65
+ * components wrapping `<Binding>`'s functionality in combination with a Tweakpane plugin.
66
+ *
67
+ * Direct manipulation of Tweakpane's internals can break _Svelte Tweakpane UI_ abstractions.
58
68
  *
59
- * This is primarily for internal use, when implementing convenience components wrapping
60
- * Binding's functionality in combination with a Tweakpane plugin.
61
69
  * @default `undefined`
62
70
  */
63
71
  plugin?: import('tweakpane').TpPluginBundle | undefined;
@@ -85,7 +93,7 @@ declare const __propDef: {
85
93
  */
86
94
  max?: number | undefined;
87
95
  /**
88
- * A function to customize the point value's formatting (e.g. rounding, etc.).
96
+ * A function to customize the point value's string representation (e.g. rounding, etc.).
89
97
  * @default `undefined` \
90
98
  * Normal `.toString()` formatting.
91
99
  */
@@ -124,16 +132,27 @@ declare const __propDef: {
124
132
  */
125
133
  amount?: number | undefined;
126
134
  /**
127
- * When `true`, expand the width of the wheel control at the expense of the numerical input
135
+ * When `true`, expand the width of the wheel control at the expense of the numeric input
128
136
  * field.
129
137
  * @default `false`
130
138
  * */
131
139
  wide?: boolean | undefined;
132
140
  };
141
+ slots: {};
133
142
  events: {
134
- [evt: string]: CustomEvent<any>;
143
+ /**
144
+ * Fires when `value` changes.
145
+ *
146
+ * _This event is provided for advanced use cases. It's usually preferred to bind to the `value` prop instead._
147
+ *
148
+ * The `event.details` payload includes a copy of the value and an `origin` field to distinguish between user-interactive changes (`internal`)
149
+ * and changes resulting from programmatic manipulation of the `value` (`external`).
150
+ *
151
+ * @extends ValueChangeEvent
152
+ * @event
153
+ * */
154
+ change: WheelChangeEvent;
135
155
  };
136
- slots: {};
137
156
  };
138
157
  export type WheelProps = typeof __propDef.props;
139
158
  export type WheelEvents = typeof __propDef.events;
@@ -147,6 +166,8 @@ export type WheelSlots = typeof __propDef.slots;
147
166
  * control from Tweakpane-creator [Hiroki Kokubun's](https://cocopon.me) [Camerakit
148
167
  * plugin](https://github.com/tweakpane/plugin-camerakit).
149
168
  *
169
+ * @emits {WheelChangeEvent} change - When `value` changes. (This event is provided for advanced use cases. Prefer binding to `value`.)
170
+ *
150
171
  * Usage outside of a `<Pane>` component will implicitly wrap the wheel in `<Pane position='inline'>`.
151
172
  *
152
173
  * @example
@@ -5,7 +5,9 @@
5
5
  import InternalPaneInline from '../internal/InternalPaneInline.svelte';
6
6
  import { enforceReadonly, getElementIndex, isRootPane } from '../utils.js';
7
7
  import { BROWSER, DEV } from 'esm-env';
8
- import { getContext, onDestroy, onMount } from 'svelte';
8
+ import copy from 'fast-copy';
9
+ import { shallowEqual } from 'fast-equals';
10
+ import { createEventDispatcher, getContext, onDestroy, onMount } from 'svelte';
9
11
  export let object;
10
12
  export let key;
11
13
  export let disabled = false;
@@ -30,11 +32,10 @@
30
32
  label,
31
33
  ...options,
32
34
  disabled
35
+ // Why last?
33
36
  });
34
37
  ref = _ref;
35
- _ref.on('change', () => {
36
- object = object;
37
- });
38
+ _ref.on('change', onTweakpaneChange);
38
39
  }
39
40
  onMount(() => {
40
41
  index = indexElement ? getElementIndex(indexElement) : 0;
@@ -42,13 +43,35 @@
42
43
  onDestroy(() => {
43
44
  _ref?.dispose();
44
45
  });
46
+ const dispatch = createEventDispatcher();
47
+ let lastValue = copy(object[key]);
48
+ let internalChange = false;
49
+ function onBoundValueChange(object2) {
50
+ if (!shallowEqual(object2[key], lastValue)) {
51
+ lastValue = copy(object2[key]);
52
+ dispatch('change', {
53
+ value: copy(object2[key]),
54
+ origin: internalChange ? 'internal' : 'external'
55
+ });
56
+ if (!internalChange && _ref) {
57
+ _ref.off('change', onTweakpaneChange);
58
+ _ref.refresh();
59
+ _ref.on('change', onTweakpaneChange);
60
+ }
61
+ }
62
+ internalChange = false;
63
+ }
64
+ function onTweakpaneChange() {
65
+ internalChange = true;
66
+ object = object;
67
+ }
45
68
  $: DEV && enforceReadonly(_ref, ref, 'Binding', 'ref', true);
46
69
  $: options, $parentStore !== void 0 && index !== void 0 && create();
47
- $: object, _ref !== void 0 && _ref.refresh();
48
70
  $: _ref !== void 0 && (_ref.disabled = disabled);
49
71
  $: _ref !== void 0 && (_ref.label = label);
72
+ $: $parentStore !== void 0 && onBoundValueChange(object);
50
73
  $: theme &&
51
- $parentStore &&
74
+ $parentStore !== void 0 &&
52
75
  (userCreatedPane || !isRootPane($parentStore)) &&
53
76
  console.warn(
54
77
  'Set theme on the <Pane> component, not on its children! (Check nested <Binding> components for a theme prop.)'
@@ -63,6 +86,15 @@
63
86
  {/if}
64
87
  {:else}
65
88
  <InternalPaneInline {theme} userCreatedPane={false}>
66
- <svelte:self bind:disabled bind:key bind:label bind:object bind:options bind:plugin bind:ref />
89
+ <svelte:self
90
+ bind:disabled
91
+ bind:key
92
+ bind:label
93
+ bind:object
94
+ bind:options
95
+ bind:plugin
96
+ bind:ref
97
+ on:change
98
+ />
67
99
  </InternalPaneInline>
68
100
  {/if}