svelte-tweakpane-ui 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +36 -0
  3. package/dist/control/ButtonGrid.svelte +49 -0
  4. package/dist/control/ButtonGrid.svelte.d.ts +190 -0
  5. package/dist/control/Checkbox.svelte +6 -0
  6. package/dist/control/Checkbox.svelte.d.ts +113 -0
  7. package/dist/control/Color.svelte +79 -0
  8. package/dist/control/Color.svelte.d.ts +177 -0
  9. package/dist/control/CubicBezier.svelte +74 -0
  10. package/dist/control/CubicBezier.svelte.d.ts +204 -0
  11. package/dist/control/Image.svelte +23 -0
  12. package/dist/control/Image.svelte.d.ts +177 -0
  13. package/dist/control/IntervalSlider.svelte +37 -0
  14. package/dist/control/IntervalSlider.svelte.d.ts +196 -0
  15. package/dist/control/List.svelte +69 -0
  16. package/dist/control/List.svelte.d.ts +122 -0
  17. package/dist/control/Point.svelte +100 -0
  18. package/dist/control/Point.svelte.d.ts +374 -0
  19. package/dist/control/RadioGrid.svelte +42 -0
  20. package/dist/control/RadioGrid.svelte.d.ts +231 -0
  21. package/dist/control/Ring.svelte +19 -0
  22. package/dist/control/Ring.svelte.d.ts +220 -0
  23. package/dist/control/RotationEuler.svelte +67 -0
  24. package/dist/control/RotationEuler.svelte.d.ts +273 -0
  25. package/dist/control/RotationQuaternion.svelte +65 -0
  26. package/dist/control/RotationQuaternion.svelte.d.ts +276 -0
  27. package/dist/control/Slider.svelte +6 -0
  28. package/dist/control/Slider.svelte.d.ts +165 -0
  29. package/dist/control/Text.svelte +25 -0
  30. package/dist/control/Text.svelte.d.ts +129 -0
  31. package/dist/control/Textarea.svelte +47 -0
  32. package/dist/control/Textarea.svelte.d.ts +149 -0
  33. package/dist/control/Wheel.svelte +15 -0
  34. package/dist/control/Wheel.svelte.d.ts +186 -0
  35. package/dist/core/Binding.svelte +68 -0
  36. package/dist/core/Binding.svelte.d.ts +116 -0
  37. package/dist/core/Blade.svelte +61 -0
  38. package/dist/core/Blade.svelte.d.ts +90 -0
  39. package/dist/core/Button.svelte +59 -0
  40. package/dist/core/Button.svelte.d.ts +65 -0
  41. package/dist/core/Folder.svelte +69 -0
  42. package/dist/core/Folder.svelte.d.ts +78 -0
  43. package/dist/core/Pane.svelte +51 -0
  44. package/dist/core/Pane.svelte.d.ts +500 -0
  45. package/dist/core/Separator.svelte +14 -0
  46. package/dist/core/Separator.svelte.d.ts +85 -0
  47. package/dist/core/TabGroup.svelte +64 -0
  48. package/dist/core/TabGroup.svelte.d.ts +72 -0
  49. package/dist/core/TabPage.svelte +85 -0
  50. package/dist/core/TabPage.svelte.d.ts +82 -0
  51. package/dist/extra/AutoObject.svelte +46 -0
  52. package/dist/extra/AutoObject.svelte.d.ts +108 -0
  53. package/dist/extra/AutoValue.svelte +11 -0
  54. package/dist/extra/AutoValue.svelte.d.ts +123 -0
  55. package/dist/extra/Element.svelte +53 -0
  56. package/dist/extra/Element.svelte.d.ts +170 -0
  57. package/dist/index.d.ts +94 -0
  58. package/dist/index.js +39 -0
  59. package/dist/internal/ClsPad.svelte +34 -0
  60. package/dist/internal/ClsPad.svelte.d.ts +95 -0
  61. package/dist/internal/GenericBinding.svelte +22 -0
  62. package/dist/internal/GenericBinding.svelte.d.ts +116 -0
  63. package/dist/internal/GenericBladeFolding.svelte +38 -0
  64. package/dist/internal/GenericBladeFolding.svelte.d.ts +95 -0
  65. package/dist/internal/GenericInput.svelte +19 -0
  66. package/dist/internal/GenericInput.svelte.d.ts +116 -0
  67. package/dist/internal/GenericInputFolding.svelte +40 -0
  68. package/dist/internal/GenericInputFolding.svelte.d.ts +140 -0
  69. package/dist/internal/GenericMonitor.svelte +24 -0
  70. package/dist/internal/GenericMonitor.svelte.d.ts +139 -0
  71. package/dist/internal/GenericPane.svelte +100 -0
  72. package/dist/internal/GenericPane.svelte.d.ts +84 -0
  73. package/dist/internal/GenericSlider.svelte +27 -0
  74. package/dist/internal/GenericSlider.svelte.d.ts +146 -0
  75. package/dist/internal/InternalMonitorBoolean.svelte +17 -0
  76. package/dist/internal/InternalMonitorBoolean.svelte.d.ts +154 -0
  77. package/dist/internal/InternalMonitorNumber.svelte +31 -0
  78. package/dist/internal/InternalMonitorNumber.svelte.d.ts +178 -0
  79. package/dist/internal/InternalMonitorString.svelte +23 -0
  80. package/dist/internal/InternalMonitorString.svelte.d.ts +162 -0
  81. package/dist/internal/InternalPaneDraggable.svelte +368 -0
  82. package/dist/internal/InternalPaneDraggable.svelte.d.ts +178 -0
  83. package/dist/internal/InternalPaneFixed.svelte +28 -0
  84. package/dist/internal/InternalPaneFixed.svelte.d.ts +119 -0
  85. package/dist/internal/InternalPaneInline.svelte +29 -0
  86. package/dist/internal/InternalPaneInline.svelte.d.ts +106 -0
  87. package/dist/monitor/FpsGraph.svelte +86 -0
  88. package/dist/monitor/FpsGraph.svelte.d.ts +230 -0
  89. package/dist/monitor/Monitor.svelte +14 -0
  90. package/dist/monitor/Monitor.svelte.d.ts +526 -0
  91. package/dist/monitor/Profiler.svelte +72 -0
  92. package/dist/monitor/Profiler.svelte.d.ts +265 -0
  93. package/dist/monitor/WaveformMonitor.svelte +26 -0
  94. package/dist/monitor/WaveformMonitor.svelte.d.ts +176 -0
  95. package/dist/theme.d.ts +91 -0
  96. package/dist/theme.js +332 -0
  97. package/dist/utils.d.ts +157 -0
  98. package/dist/utils.js +238 -0
  99. package/package.json +280 -0
@@ -0,0 +1,276 @@
1
+ import { SvelteComponent } from 'svelte';
2
+ import type { PointDimensionParams } from '@tweakpane/core';
3
+ import type { Simplify } from '../utils';
4
+ export type RotationQuaternionOptions = Simplify<PointDimensionParams>;
5
+ export type RotationQuaternionValueObject = {
6
+ x: number;
7
+ y: number;
8
+ z: number;
9
+ w: number;
10
+ };
11
+ export type RotationQuaternionValueTuple = [x: number, y: number, z: number, w: number];
12
+ export type RotationQuaternionValue = Simplify<
13
+ RotationQuaternionValueObject | RotationQuaternionValueTuple
14
+ >;
15
+ import type { RotationInputPluginQuaternionParams as RotationQuaternionOptionsInternal } from '@0b5vr/tweakpane-plugin-rotation/dist/types/RotationInputPluginQuaternionParams';
16
+ declare const __propDef: {
17
+ props: Omit<
18
+ Omit<
19
+ {
20
+ /**
21
+ * The binding's target object with values to manipulate.
22
+ * @bindable
23
+ */
24
+ object: import('@tweakpane/core').Bindable & {
25
+ [x: string]: RotationQuaternionValue;
26
+ };
27
+ /** The key for the value in the target `object` that the control should manipulate. */
28
+ key: string | number;
29
+ /**
30
+ * Prevent interactivity and gray out the control.
31
+ * @default `false`
32
+ */
33
+ disabled?: boolean | undefined;
34
+ /**
35
+ * Text displayed next to control.
36
+ * @default `undefined`
37
+ */
38
+ label?: string | undefined;
39
+ /**
40
+ * Tweakpane's internal options object.
41
+ *
42
+ * See [`BindingParams`](https://tweakpane.github.io/docs/api/types/BindingParams.html).
43
+ *
44
+ * Valid types are contingent on the type of the value `key` points to in `object`.
45
+ *
46
+ * This is intended internal use, when implementing convenience components wrapping Binding's
47
+ * functionality. Options of interest are instead exposed as top-level props in _Svelte
48
+ * Tweakpane UI_.
49
+ * @default `undefined`
50
+ */
51
+ options?: RotationQuaternionOptionsInternal | undefined;
52
+ /**
53
+ * Custom color scheme.
54
+ *
55
+ * @default `undefined` \
56
+ * Inherits default Tweakpane theme equivalent to `ThemeUtils.presets.standard`, or the theme
57
+ * set with `setGlobalDefaultTheme()`.
58
+ */
59
+ theme?: import('..').Theme | undefined;
60
+ /**
61
+ * Reference to internal Tweakpane
62
+ * [`BindingApi`](https://tweakpane.github.io/docs/api/classes/_internal_.BindingApi.html) for
63
+ * this control.
64
+ *
65
+ * This is primarily for internal use, when implementing convenience components wrapping
66
+ * Binding's functionality.
67
+ * @bindable
68
+ * @readonly
69
+ */
70
+ ref?: import('../internal/GenericInput.svelte').GenericInputRef | undefined;
71
+ /**
72
+ * Imported Tweakpane `TpPluginBundle` (aliased as `Plugin`) module to automatically register in
73
+ * the binding's containing `<Pane>`.
74
+ *
75
+ * This is primarily for internal use, when implementing convenience components wrapping
76
+ * Binding's functionality in combination with a Tweakpane plugin.
77
+ * @default `undefined`
78
+ */
79
+ plugin?: import('@tweakpane/core').TpPluginBundle | undefined;
80
+ },
81
+ 'object' | 'key'
82
+ > & {
83
+ /**
84
+ * The quaternion value to control.
85
+ *
86
+ * Tuple values are a convenience added by _Svelte Tweakpane UI_, and is not part of the
87
+ * original TweakpaneRotationPlugin API.
88
+ * @bindable
89
+ */
90
+ value: RotationQuaternionValue;
91
+ } & {
92
+ /**
93
+ * DOM class name of the button used to expand and collapse the input's picker.
94
+ * @default `undefined`
95
+ */
96
+ buttonClass?: string | undefined;
97
+ /**
98
+ * Expand or collapse the input's picker.
99
+ * @default `false`
100
+ * @bindable
101
+ */
102
+ expanded?: boolean | undefined;
103
+ /**
104
+ * The style of value "picker" to use in the input.
105
+ * @default `'popup'`
106
+ */
107
+ picker?: 'inline' | 'popup' | undefined;
108
+ /**
109
+ * Allow users to interactively expand / contract the picker.
110
+ * @default `true`
111
+ */
112
+ userExpandable?: boolean | undefined;
113
+ },
114
+ 'options' | 'ref' | 'plugin' | 'buttonClass'
115
+ > & {
116
+ /**
117
+ * The quaternion value to control.
118
+ *
119
+ * Tuple values are a convenience added by _Svelte Tweakpane UI_, and is not part of the
120
+ * original TweakpaneRotationPlugin API.
121
+ * @bindable
122
+ * */
123
+ value: RotationQuaternionValue;
124
+ /**
125
+ * Input parameters specific to the X dimension.
126
+ *
127
+ * Renamed from `x` in TweakpaneRotationPlugin API to clarify that it is an object of
128
+ * options, not a value.
129
+ * @default `undefined`
130
+ * */
131
+ optionsX?:
132
+ | {
133
+ format?: import('@tweakpane/core').Formatter<number> | undefined;
134
+ keyScale?: number | undefined;
135
+ max?: number | undefined;
136
+ min?: number | undefined;
137
+ pointerScale?: number | undefined;
138
+ step?: number | undefined;
139
+ }
140
+ | undefined;
141
+ /**
142
+ * Input parameters specific to the Y dimension.
143
+ *
144
+ * Renamed from `y` in TweakpaneRotationPlugin API to clarify that it is an object of
145
+ * options, not a value.
146
+ * @default `undefined`
147
+ * */
148
+ optionsY?:
149
+ | {
150
+ format?: import('@tweakpane/core').Formatter<number> | undefined;
151
+ keyScale?: number | undefined;
152
+ max?: number | undefined;
153
+ min?: number | undefined;
154
+ pointerScale?: number | undefined;
155
+ step?: number | undefined;
156
+ }
157
+ | undefined;
158
+ /**
159
+ * Input parameters specific to the Z dimension.
160
+ *
161
+ * Renamed from `z` in TweakpaneRotationPlugin API to clarify that it is an object of
162
+ * options, not a value.
163
+ * @default `undefined`
164
+ * */
165
+ optionsZ?:
166
+ | {
167
+ format?: import('@tweakpane/core').Formatter<number> | undefined;
168
+ keyScale?: number | undefined;
169
+ max?: number | undefined;
170
+ min?: number | undefined;
171
+ pointerScale?: number | undefined;
172
+ step?: number | undefined;
173
+ }
174
+ | undefined;
175
+ /**
176
+ * Input parameters specific to the W dimension.
177
+ *
178
+ * Renamed from `w` in TweakpaneRotationPlugin API to clarify that it is an object of
179
+ * options, not a value.
180
+ * @default `undefined`
181
+ * */
182
+ optionsW?:
183
+ | {
184
+ format?: import('@tweakpane/core').Formatter<number> | undefined;
185
+ keyScale?: number | undefined;
186
+ max?: number | undefined;
187
+ min?: number | undefined;
188
+ pointerScale?: number | undefined;
189
+ step?: number | undefined;
190
+ }
191
+ | undefined;
192
+ };
193
+ events: {
194
+ [evt: string]: CustomEvent<any>;
195
+ };
196
+ slots: {};
197
+ };
198
+ export type RotationQuaternionProps = typeof __propDef.props;
199
+ export type RotationQuaternionEvents = typeof __propDef.events;
200
+ export type RotationQuaternionSlots = typeof __propDef.slots;
201
+ /**
202
+ * Integrates the [quaternion
203
+ * rotation](https://github.com/0b5vr/tweakpane-plugin-rotation/blob/dev/src/RotationInputPluginQuaternion.ts)
204
+ * control from [0b5vr's](https://0b5vr.com)
205
+ * [tweakpane-plugin-rotation](https://github.com/0b5vr/tweakpane-plugin-rotation).
206
+ *
207
+ * _Svelte Tweakpane UI_ extends the original API to support tuple values in addition to object values.
208
+ * (Useful when working with frameworks like [three.js](https://threejs.org) /
209
+ * [threlte](https://threlte.xyz).)
210
+ *
211
+ * A utility function `Utils.quaternionToCssTransform()` is also provided to easily convert a euler
212
+ * rotation value object or tuple into a CSS transform string.
213
+ *
214
+ * See also <RotationEuler> if you're not into the whole `w` thing.
215
+ *
216
+ * Usage outside of a `<Pane>` component will implicitly wrap the profiler in `<Pane
217
+ * position='inline'>`.
218
+ *
219
+ *
220
+ *
221
+ *
222
+ *
223
+ *
224
+ * @example
225
+ * ```svelte
226
+ * <script lang="ts">
227
+ * import {
228
+ * Button,
229
+ * RotationQuaternion,
230
+ * type RotationQuaternionValue,
231
+ * Utils
232
+ * } from 'svelte-tweakpane-ui';
233
+ *
234
+ * // Value could also be an object
235
+ * // e.g. {x: 0, y: 0, z: 0, w: 0}
236
+ * let value: RotationQuaternionValue = [0, 0, 0, 0];
237
+ *
238
+ * $: transform = Utils.quaternionToCssTransform(value);
239
+ * $: valueRows = Array.isArray(value)
240
+ * ? value.map((v) => `${v >= 0 ? '+' : ''}${v.toFixed(6)}`).join('\n')
241
+ * : '';
242
+ * </script>
243
+ *
244
+ * <RotationQuaternion
245
+ * bind:value
246
+ * expanded={true}
247
+ * label="CSS Rotation"
248
+ * picker={'inline'}
249
+ * />
250
+ * <Button on:click={() => (value = [0, 0, 0, 0])} title="Reset" />
251
+ *
252
+ * <div class="billboard" style:transform>
253
+ * <pre>{valueRows}</pre>
254
+ * </div>
255
+ *
256
+ * <style>
257
+ * div.billboard {
258
+ * display: flex;
259
+ * align-items: center;
260
+ * justify-content: center;
261
+ * aspect-ratio: 1;
262
+ * width: 100%;
263
+ * background: linear-gradient(45deg, magenta, orange);
264
+ * }
265
+ * </style>
266
+ * ```
267
+ *
268
+ * @sourceLink
269
+ * [RotationQuaternion.svelte](https://github.com/kitschpatrol/svelte-tweakpane-ui/blob/main/src/lib/control/RotationQuaternion.svelte)
270
+ */
271
+ export default class RotationQuaternion extends SvelteComponent<
272
+ RotationQuaternionProps,
273
+ RotationQuaternionEvents,
274
+ RotationQuaternionSlots
275
+ > {}
276
+ export {};
@@ -0,0 +1,6 @@
1
+ <script>
2
+ import GenericSlider from '../internal/GenericSlider.svelte';
3
+ export let value;
4
+ </script>
5
+
6
+ <GenericSlider bind:value {...$$restProps} />
@@ -0,0 +1,165 @@
1
+ import { SvelteComponent } from 'svelte';
2
+ declare const __propDef: {
3
+ props: Omit<
4
+ Omit<
5
+ {
6
+ /**
7
+ * The binding's target object with values to manipulate.
8
+ * @bindable
9
+ */
10
+ object: import('@tweakpane/core').Bindable & {
11
+ [x: string]: number;
12
+ };
13
+ /** The key for the value in the target `object` that the control should manipulate. */
14
+ key: string | number;
15
+ /**
16
+ * Prevent interactivity and gray out the control.
17
+ * @default `false`
18
+ */
19
+ disabled?: boolean | undefined;
20
+ /**
21
+ * Text displayed next to control.
22
+ * @default `undefined`
23
+ */
24
+ label?: string | undefined;
25
+ /**
26
+ * Tweakpane's internal options object.
27
+ *
28
+ * See [`BindingParams`](https://tweakpane.github.io/docs/api/types/BindingParams.html).
29
+ *
30
+ * Valid types are contingent on the type of the value `key` points to in `object`.
31
+ *
32
+ * This is intended internal use, when implementing convenience components wrapping Binding's
33
+ * functionality. Options of interest are instead exposed as top-level props in _Svelte
34
+ * Tweakpane UI_.
35
+ * @default `undefined`
36
+ */
37
+ options?: import('tweakpane').NumberInputParams | undefined;
38
+ /**
39
+ * Custom color scheme.
40
+ *
41
+ * @default `undefined` \
42
+ * Inherits default Tweakpane theme equivalent to `ThemeUtils.presets.standard`, or the theme
43
+ * set with `setGlobalDefaultTheme()`.
44
+ */
45
+ theme?: import('..').Theme | undefined;
46
+ /**
47
+ * Reference to internal Tweakpane
48
+ * [`BindingApi`](https://tweakpane.github.io/docs/api/classes/_internal_.BindingApi.html) for
49
+ * this control.
50
+ *
51
+ * This is primarily for internal use, when implementing convenience components wrapping
52
+ * Binding's functionality.
53
+ * @bindable
54
+ * @readonly
55
+ */
56
+ ref?: import('tweakpane').SliderInputBindingApi | undefined;
57
+ /**
58
+ * Imported Tweakpane `TpPluginBundle` (aliased as `Plugin`) module to automatically register in
59
+ * the binding's containing `<Pane>`.
60
+ *
61
+ * This is primarily for internal use, when implementing convenience components wrapping
62
+ * Binding's functionality in combination with a Tweakpane plugin.
63
+ * @default `undefined`
64
+ */
65
+ plugin?: import('tweakpane').TpPluginBundle | undefined;
66
+ },
67
+ 'object' | 'key'
68
+ > & {
69
+ /**
70
+ * A `number` value to control.
71
+ * @bindable .
72
+ */
73
+ value: number;
74
+ } & {
75
+ /**
76
+ * Minimum value.
77
+ *
78
+ * Specifying both a `min` and a `max` prop turns the control into a slider.
79
+ * @default `undefined`
80
+ */
81
+ min?: number | undefined;
82
+ /**
83
+ * Maximum value.
84
+ *
85
+ * Specifying both a `min` and a `max` prop turns the control into a slider.
86
+ * @default `undefined`
87
+ */
88
+ max?: number | undefined;
89
+ /**
90
+ * A function to customize the point value's formatting (e.g. rounding, etc.).
91
+ * @default `undefined` \
92
+ * Normal `.toString()` formatting.
93
+ */
94
+ format?: ((value: number) => string) | undefined;
95
+ /**
96
+ * The unit scale for key-based input for all dimensions (e.g. the up and down arrow keys).
97
+ * @default `1` \
98
+ * Or `stepValue` if defined.
99
+ */
100
+ keyScale?: number | undefined;
101
+ /**
102
+ * The unit scale for pointer-based input for all dimensions.
103
+ * @default `undefined` \
104
+ * [Dynamic based on magnitude of
105
+ * `value`](https://github.com/cocopon/tweakpane/blob/66dfbea04bfe9b7f031673c955ceda1f92356e75/packages/core/src/common/number/util.ts#L54).
106
+ */
107
+ pointerScale?: number | undefined;
108
+ /**
109
+ * The minimum step interval.
110
+ * @default `undefined` \
111
+ * No step constraint.
112
+ */
113
+ step?: number | undefined;
114
+ },
115
+ 'options' | 'ref' | 'plugin'
116
+ > & {
117
+ /**
118
+ * A `number` value to control.
119
+ * @bindable.
120
+ * */
121
+ value: number;
122
+ };
123
+ events: {
124
+ [evt: string]: CustomEvent<any>;
125
+ };
126
+ slots: {};
127
+ };
128
+ export type SliderProps = typeof __propDef.props;
129
+ export type SliderEvents = typeof __propDef.events;
130
+ export type SliderSlots = typeof __propDef.slots;
131
+ /**
132
+ * A slider component providing fine-grained control over numerical values.
133
+ *
134
+ * Wraps Tweakpane's [number bindings](https://tweakpane.github.io/docs/input-bindings/#number).
135
+ *
136
+ * Note that if `min` and `max` props are not defined, no linear slider widget will be provided and a
137
+ * input field with a draggable handle will be used instead.
138
+ *
139
+ * Usage outside of a `<Pane>` component will implicitly wrap the slider in `<Pane position='inline'>`.
140
+ *
141
+ * See the `<Interval>` component for a multi-handle range-defining slider.
142
+ *
143
+ * @example
144
+ * ```svelte
145
+ * <script lang="ts">
146
+ * import { Slider } from 'svelte-tweakpane-ui';
147
+ *
148
+ * let value = 0;
149
+ * </script>
150
+ *
151
+ * <Slider
152
+ * bind:value
153
+ * min={-1}
154
+ * max={1}
155
+ * format={(v) => v.toFixed(2)}
156
+ * label="Let it Slide"
157
+ * />
158
+ * <pre>Value: {value}</pre>
159
+ * ```
160
+ *
161
+ * @sourceLink
162
+ * [Slider.svelte](https://github.com/kitschpatrol/svelte-tweakpane-ui/blob/main/src/lib/control/Slider.svelte)
163
+ */
164
+ export default class Slider extends SvelteComponent<SliderProps, SliderEvents, SliderSlots> {}
165
+ export {};
@@ -0,0 +1,25 @@
1
+ <script>
2
+ import GenericInput from '../internal/GenericInput.svelte';
3
+ import { onDestroy } from 'svelte';
4
+ export let value;
5
+ export let live = true;
6
+ let ref;
7
+ onDestroy(() => {
8
+ updateListeners(live ?? true, true);
9
+ });
10
+ function onInput(event) {
11
+ if (event.target) {
12
+ value = event.target.value;
13
+ }
14
+ }
15
+ function updateListeners(live2, destroy = false) {
16
+ let input = ref?.controller.valueController.view.element.getElementsByTagName('input')[0];
17
+ if (input) {
18
+ input.removeEventListener('input', onInput);
19
+ !destroy && live2 && input.addEventListener('input', onInput);
20
+ }
21
+ }
22
+ $: ref && live !== void 0 && updateListeners(live);
23
+ </script>
24
+
25
+ <GenericInput bind:value bind:ref {...$$restProps} />
@@ -0,0 +1,129 @@
1
+ import { SvelteComponent } from 'svelte';
2
+ import { type GenericInputRef } from '../internal/GenericInput.svelte';
3
+ declare const __propDef: {
4
+ props: Omit<
5
+ Omit<
6
+ {
7
+ /**
8
+ * The binding's target object with values to manipulate.
9
+ * @bindable
10
+ */
11
+ object: import('@tweakpane/core').Bindable & {
12
+ [x: string]: string;
13
+ };
14
+ /** The key for the value in the target `object` that the control should manipulate. */
15
+ key: string | number;
16
+ /**
17
+ * Prevent interactivity and gray out the control.
18
+ * @default `false`
19
+ */
20
+ disabled?: boolean | undefined;
21
+ /**
22
+ * Text displayed next to control.
23
+ * @default `undefined`
24
+ */
25
+ label?: string | undefined;
26
+ /**
27
+ * Tweakpane's internal options object.
28
+ *
29
+ * See [`BindingParams`](https://tweakpane.github.io/docs/api/types/BindingParams.html).
30
+ *
31
+ * Valid types are contingent on the type of the value `key` points to in `object`.
32
+ *
33
+ * This is intended internal use, when implementing convenience components wrapping Binding's
34
+ * functionality. Options of interest are instead exposed as top-level props in _Svelte
35
+ * Tweakpane UI_.
36
+ * @default `undefined`
37
+ */
38
+ options?: import('@tweakpane/core').BaseInputParams | undefined;
39
+ /**
40
+ * Custom color scheme.
41
+ *
42
+ * @default `undefined` \
43
+ * Inherits default Tweakpane theme equivalent to `ThemeUtils.presets.standard`, or the theme
44
+ * set with `setGlobalDefaultTheme()`.
45
+ */
46
+ theme?: import('..').Theme | undefined;
47
+ /**
48
+ * Reference to internal Tweakpane
49
+ * [`BindingApi`](https://tweakpane.github.io/docs/api/classes/_internal_.BindingApi.html) for
50
+ * this control.
51
+ *
52
+ * This is primarily for internal use, when implementing convenience components wrapping
53
+ * Binding's functionality.
54
+ * @bindable
55
+ * @readonly
56
+ */
57
+ ref?: GenericInputRef | undefined;
58
+ /**
59
+ * Imported Tweakpane `TpPluginBundle` (aliased as `Plugin`) module to automatically register in
60
+ * the binding's containing `<Pane>`.
61
+ *
62
+ * This is primarily for internal use, when implementing convenience components wrapping
63
+ * Binding's functionality in combination with a Tweakpane plugin.
64
+ * @default `undefined`
65
+ */
66
+ plugin?: import('tweakpane').TpPluginBundle | undefined;
67
+ },
68
+ 'object' | 'key'
69
+ > & {
70
+ /**
71
+ * A `string` value to control.
72
+ * @bindable
73
+ */
74
+ value: string;
75
+ },
76
+ 'options' | 'ref' | 'plugin'
77
+ > & {
78
+ /**
79
+ * A `string` value to control.
80
+ * @bindable
81
+ * */
82
+ value: string;
83
+ /**
84
+ * Whether to provide live updates to the bound `value` on every keystroke.
85
+ *
86
+ * To match expectations around reactive components, the default here diverges from the
87
+ * vanilla JS Tweakpane behavior, which only updates on blur.
88
+ * @default `true`
89
+ * */
90
+ live?: boolean | undefined;
91
+ };
92
+ events: {
93
+ [evt: string]: CustomEvent<any>;
94
+ };
95
+ slots: {};
96
+ };
97
+ export type TextProps = typeof __propDef.props;
98
+ export type TextEvents = typeof __propDef.events;
99
+ export type TextSlots = typeof __propDef.slots;
100
+ /**
101
+ * A text field, in the spirit of the HTML `<input type="text">` element.
102
+ *
103
+ * Wraps Tweakpane's [string binding](https://tweakpane.github.io/docs/input-bindings/#string).
104
+ *
105
+ * Extends the vanilla JS Tweakpane API to update the bound value on every keystroke. (If you prefer
106
+ * Tweakpane's default behavior of only updating on blur, set `live={false}`.)
107
+ *
108
+ * See `<TextArea>` for a multi-line input variation.
109
+ *
110
+ * Usage outside of a `<Pane>` component will implicitly wrap the text field in `<Pane
111
+ * position='inline'>`.
112
+ *
113
+ * @example
114
+ * ```svelte
115
+ * <script lang="ts">
116
+ * import { Text } from 'svelte-tweakpane-ui';
117
+ *
118
+ * let text = 'Cosmic Manifold';
119
+ * </script>
120
+ *
121
+ * <Text bind:value={text} label="The Message" />
122
+ * <pre>Message: {text}</pre>
123
+ * ```
124
+ *
125
+ * @sourceLink
126
+ * [Text.svelte](https://github.com/kitschpatrol/svelte-tweakpane-ui/blob/main/src/lib/control/Text.svelte)
127
+ */
128
+ export default class Text extends SvelteComponent<TextProps, TextEvents, TextSlots> {}
129
+ export {};
@@ -0,0 +1,47 @@
1
+ <script>
2
+ import * as pluginModule from '@kitschpatrol/tweakpane-textarea-plugin';
3
+ import GenericInput from '../internal/GenericInput.svelte';
4
+ import { BROWSER } from 'esm-env';
5
+ import { onDestroy } from 'svelte';
6
+ export let value;
7
+ export let live = true;
8
+ export let rows = void 0;
9
+ export let placeholder = void 0;
10
+ let _value = value;
11
+ let ref;
12
+ let options;
13
+ onDestroy(() => {
14
+ updateListeners(live ?? true, true);
15
+ });
16
+ function onBlur(event) {
17
+ console.log('onblur');
18
+ value = event.target.value;
19
+ }
20
+ function onInput(event) {
21
+ console.log('input');
22
+ value = event.target.value;
23
+ }
24
+ function updateListeners(live2, destroy = false) {
25
+ var input = ref?.controller.valueController.view.element.getElementsByTagName('textarea')[0];
26
+ if (input) {
27
+ input.removeEventListener('blur', onBlur);
28
+ input.removeEventListener('input', onInput);
29
+ !destroy && live2 && input.addEventListener('input', onInput);
30
+ !destroy && !live2 && input.addEventListener('blur', onBlur);
31
+ }
32
+ }
33
+ $: _value = value;
34
+ $: ref && live !== void 0 && updateListeners(live);
35
+ $: options = {
36
+ placeholder,
37
+ rows,
38
+ view: 'textarea'
39
+ };
40
+ </script>
41
+
42
+ <GenericInput value={_value} bind:ref {options} plugin={pluginModule} {...$$restProps} />
43
+ {#if !BROWSER}
44
+ <!-- TODO magic numbers -->
45
+ <div style:background="red" style:height={`calc(${16 * (rows ?? 3)}px - 14px)`} />
46
+ <!-- <ClsPad keysAdd={fillWith('containerUnitSize', 1)} theme={$$props.theme} /> -->
47
+ {/if}