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,149 @@
1
+ import { SvelteComponent } from 'svelte';
2
+ import type { TextareaPluginInputParams } from '@kitschpatrol/tweakpane-textarea-plugin/dist/types/plugin.js';
3
+ import { type GenericInputRef } from '../internal/GenericInput.svelte';
4
+ declare const __propDef: {
5
+ props: Omit<
6
+ Omit<
7
+ {
8
+ /**
9
+ * The binding's target object with values to manipulate.
10
+ * @bindable
11
+ */
12
+ object: import('@tweakpane/core').Bindable & {
13
+ [x: string]: string;
14
+ };
15
+ /** The key for the value in the target `object` that the control should manipulate. */
16
+ key: string | number;
17
+ /**
18
+ * Prevent interactivity and gray out the control.
19
+ * @default `false`
20
+ */
21
+ disabled?: boolean | undefined;
22
+ /**
23
+ * Text displayed next to control.
24
+ * @default `undefined`
25
+ */
26
+ label?: string | undefined;
27
+ /**
28
+ * Tweakpane's internal options object.
29
+ *
30
+ * See [`BindingParams`](https://tweakpane.github.io/docs/api/types/BindingParams.html).
31
+ *
32
+ * Valid types are contingent on the type of the value `key` points to in `object`.
33
+ *
34
+ * This is intended internal use, when implementing convenience components wrapping Binding's
35
+ * functionality. Options of interest are instead exposed as top-level props in _Svelte
36
+ * Tweakpane UI_.
37
+ * @default `undefined`
38
+ */
39
+ options?: TextareaPluginInputParams | undefined;
40
+ /**
41
+ * Custom color scheme.
42
+ *
43
+ * @default `undefined` \
44
+ * Inherits default Tweakpane theme equivalent to `ThemeUtils.presets.standard`, or the theme
45
+ * set with `setGlobalDefaultTheme()`.
46
+ */
47
+ theme?: import('..').Theme | undefined;
48
+ /**
49
+ * Reference to internal Tweakpane
50
+ * [`BindingApi`](https://tweakpane.github.io/docs/api/classes/_internal_.BindingApi.html) for
51
+ * this control.
52
+ *
53
+ * This is primarily for internal use, when implementing convenience components wrapping
54
+ * Binding's functionality.
55
+ * @bindable
56
+ * @readonly
57
+ */
58
+ ref?: GenericInputRef | undefined;
59
+ /**
60
+ * Imported Tweakpane `TpPluginBundle` (aliased as `Plugin`) module to automatically register in
61
+ * the binding's containing `<Pane>`.
62
+ *
63
+ * This is primarily for internal use, when implementing convenience components wrapping
64
+ * Binding's functionality in combination with a Tweakpane plugin.
65
+ * @default `undefined`
66
+ */
67
+ plugin?: import('tweakpane').TpPluginBundle | undefined;
68
+ },
69
+ 'object' | 'key'
70
+ > & {
71
+ /**
72
+ * A `string` value to control.
73
+ * @bindable
74
+ */
75
+ value: string;
76
+ },
77
+ 'options' | 'ref' | 'plugin'
78
+ > & {
79
+ /**
80
+ * A `string` value to control.
81
+ * @bindable
82
+ * */
83
+ value: string;
84
+ /**
85
+ * Whether to provide live updates to the bound `value` on every keystroke.
86
+ * @default `true`
87
+ * */
88
+ live?: boolean | undefined;
89
+ /**
90
+ * Placeholder text to display when the `value` is empty.
91
+ * @default `'Enter text here'`
92
+ */
93
+ placeholder?: string | undefined;
94
+ /**
95
+ * The number of lines of text to display.
96
+ *
97
+ * If lines of input exceed this value, then the text area will scroll.
98
+ * @default `3`
99
+ */
100
+ rows?: number | undefined;
101
+ };
102
+ events: {
103
+ [evt: string]: CustomEvent<any>;
104
+ };
105
+ slots: {};
106
+ };
107
+ export type TextareaProps = typeof __propDef.props;
108
+ export type TextareaEvents = typeof __propDef.events;
109
+ export type TextareaSlots = typeof __propDef.slots;
110
+ /**
111
+ * A multi-line text input field, in the spirit of the HTML `<textarea>` element.
112
+ *
113
+ * Integrates the
114
+ * [tweakpane-textarea-plugin](https://github.com/panGenerator/tweakpane-textarea-plugin) by [Krzysztof
115
+ * Goliński](http://www.golinski.org) and [Jakub Koźniewski](https://pangenerator.com).
116
+ *
117
+ * Extends the underlying implementation with the `live` property to match the behavior of the `<Text>`
118
+ * component.
119
+ *
120
+ * Note that _Svelte Tweakpane UI_ embeds a
121
+ * [fork](https://github.com/kitschpatrol/tweakpane-textarea-plugin) of the plugin with support for
122
+ * Tweakpane 4. The dependency will be updated to point to the source repository if / when the open
123
+ * [pull request](https://github.com/panGenerator/tweakpane-textarea-plugin/pull/4) with Tweakpane 4
124
+ * support is merged.
125
+ *
126
+ * Usage outside of a `<Pane>` component will implicitly wrap the text area in `<Pane
127
+ * position='inline'>`.
128
+ *
129
+ * @example
130
+ * ```svelte
131
+ * <script lang="ts">
132
+ * import { Textarea } from 'svelte-tweakpane-ui';
133
+ *
134
+ * let text = '';
135
+ * </script>
136
+ *
137
+ * <Textarea bind:value={text} placeholder="The void" rows={8} />
138
+ * <pre>{text}</pre>
139
+ * ```
140
+ *
141
+ * @sourceLink
142
+ * [Textarea.svelte](https://github.com/kitschpatrol/svelte-tweakpane-ui/blob/main/src/lib/control/Textarea.svelte)
143
+ */
144
+ export default class Textarea extends SvelteComponent<
145
+ TextareaProps,
146
+ TextareaEvents,
147
+ TextareaSlots
148
+ > {}
149
+ export {};
@@ -0,0 +1,15 @@
1
+ <script>
2
+ import * as pluginModule from '@tweakpane/plugin-camerakit';
3
+ import GenericSlider from '../internal/GenericSlider.svelte';
4
+ export let value;
5
+ export let amount = void 0;
6
+ export let wide = void 0;
7
+ let options;
8
+ $: options = {
9
+ amount,
10
+ view: 'camerawheel',
11
+ wide
12
+ };
13
+ </script>
14
+
15
+ <GenericSlider bind:value {options} plugin={pluginModule} {...$$restProps} />
@@ -0,0 +1,186 @@
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
+ * When `true`, expand the width of the wheel control at the expense of the numerical input
83
+ * field.
84
+ * @default `false`
85
+ * */;
86
+ /**
87
+ * Maximum value.
88
+ *
89
+ * Specifying both a `min` and a `max` prop turns the control into a slider.
90
+ * @default `undefined`
91
+ */
92
+ max?: number | undefined;
93
+ /**
94
+ * A function to customize the point value's formatting (e.g. rounding, etc.).
95
+ * @default `undefined` \
96
+ * Normal `.toString()` formatting.
97
+ */
98
+ format?: ((value: number) => string) | undefined;
99
+ /**
100
+ * The unit scale for key-based input for all dimensions (e.g. the up and down arrow keys).
101
+ * @default `1` \
102
+ * Or `stepValue` if defined.
103
+ */
104
+ keyScale?: number | undefined;
105
+ /**
106
+ * The unit scale for pointer-based input for all dimensions.
107
+ * @default `undefined` \
108
+ * [Dynamic based on magnitude of
109
+ * `value`](https://github.com/cocopon/tweakpane/blob/66dfbea04bfe9b7f031673c955ceda1f92356e75/packages/core/src/common/number/util.ts#L54).
110
+ */
111
+ pointerScale?: number | undefined;
112
+ /**
113
+ * The minimum step interval.
114
+ * @default `undefined` \
115
+ * No step constraint.
116
+ */
117
+ step?: number | undefined;
118
+ },
119
+ 'options' | 'ref' | 'plugin'
120
+ > & {
121
+ /**
122
+ * A `number` value to control.
123
+ * @bindable
124
+ * */
125
+ value: number;
126
+ /** The amount of the value to change per pixel of movement.
127
+ * @default `undefined` \
128
+ * [Dynamic based on magnitude of
129
+ * `value`](https://github.com/cocopon/tweakpane/blob/66dfbea04bfe9b7f031673c955ceda1f92356e75/packages/core/src/common/number/util.ts#L54).
130
+ */
131
+ amount?: number | undefined;
132
+ /**
133
+ * When `true`, expand the width of the wheel control at the expense of the numerical input
134
+ * field.
135
+ * @default `false`
136
+ * */
137
+ wide?: boolean | undefined;
138
+ };
139
+ events: {
140
+ [evt: string]: CustomEvent<any>;
141
+ };
142
+ slots: {};
143
+ };
144
+ export type WheelProps = typeof __propDef.props;
145
+ export type WheelEvents = typeof __propDef.events;
146
+ export type WheelSlots = typeof __propDef.slots;
147
+ /**
148
+ * A control evoking a dial on a proper camera body.
149
+ *
150
+ * Similar in functionality to a `<Slider>`.
151
+ *
152
+ * Integrates the [Wheel](https://github.com/tweakpane/plugin-camerakit/blob/main/src/plugin-wheel.ts)
153
+ * control from Tweakpane-creator [Hiroki Kokubun's](https://cocopon.me) [Camerakit
154
+ * plugin](https://github.com/tweakpane/plugin-camerakit).
155
+ *
156
+ * Usage outside of a `<Pane>` component will implicitly wrap the wheel in `<Pane position='inline'>`.
157
+ *
158
+ * @example
159
+ * ```svelte
160
+ * <script lang="ts">
161
+ * import { Wheel } from 'svelte-tweakpane-ui';
162
+ *
163
+ * let angle = 45;
164
+ * </script>
165
+ *
166
+ * <Wheel
167
+ * bind:value={angle}
168
+ * format={(v) => `${(Math.abs(v) % 360).toFixed(0)}°`}
169
+ * />
170
+ *
171
+ * <div class="demo" style:--a="{angle}deg" />
172
+ *
173
+ * <style>
174
+ * div.demo {
175
+ * aspect-ratio: 1;
176
+ * width: 100%;
177
+ * background: linear-gradient(var(--a), magenta, orange);
178
+ * }
179
+ * </style>
180
+ * ```
181
+ *
182
+ * @sourceLink
183
+ * [Wheel.svelte](https://github.com/kitschpatrol/svelte-tweakpane-ui/blob/main/src/lib/control/Wheel.svelte)
184
+ */
185
+ export default class Wheel extends SvelteComponent<WheelProps, WheelEvents, WheelSlots> {}
186
+ export {};
@@ -0,0 +1,68 @@
1
+ <script context="module"></script>
2
+
3
+ <script generics="T extends BindingObject, U extends BindingOptions, V extends BindingRef">
4
+ import ClsPad from '../internal/ClsPad.svelte';
5
+ import InternalPaneInline from '../internal/InternalPaneInline.svelte';
6
+ import { enforceReadonly, getElementIndex, isRootPane } from '../utils.js';
7
+ import { BROWSER, DEV } from 'esm-env';
8
+ import { getContext, onDestroy, onMount } from 'svelte';
9
+ export let object;
10
+ export let key;
11
+ export let disabled = false;
12
+ export let label = void 0;
13
+ export let options = void 0;
14
+ export let theme = void 0;
15
+ export let ref = void 0;
16
+ export let plugin = void 0;
17
+ const registerPlugin = getContext('registerPlugin');
18
+ const parentStore = getContext('parentStore');
19
+ const userCreatedPane = getContext('userCreatedPane');
20
+ let _ref;
21
+ let indexElement;
22
+ let index;
23
+ function create() {
24
+ if (_ref) _ref.dispose();
25
+ if (plugin !== void 0) {
26
+ registerPlugin(plugin);
27
+ }
28
+ _ref = $parentStore.addBinding(object, key, {
29
+ index,
30
+ label,
31
+ ...options,
32
+ disabled
33
+ });
34
+ ref = _ref;
35
+ _ref.on('change', () => {
36
+ object = object;
37
+ });
38
+ }
39
+ onMount(() => {
40
+ index = indexElement ? getElementIndex(indexElement) : 0;
41
+ });
42
+ onDestroy(() => {
43
+ _ref?.dispose();
44
+ });
45
+ $: DEV && enforceReadonly(_ref, ref, 'Binding', 'ref', true);
46
+ $: options, $parentStore !== void 0 && index !== void 0 && create();
47
+ $: object, _ref !== void 0 && _ref.refresh();
48
+ $: _ref !== void 0 && (_ref.disabled = disabled);
49
+ $: _ref !== void 0 && (_ref.label = label);
50
+ $: theme &&
51
+ $parentStore &&
52
+ (userCreatedPane || !isRootPane($parentStore)) &&
53
+ console.warn(
54
+ 'Set theme on the <Pane> component, not on its children! (Check nested <Binding> components for a theme prop.)'
55
+ );
56
+ </script>
57
+
58
+ {#if parentStore}
59
+ {#if BROWSER}
60
+ <div bind:this={indexElement} style="display: none;" />
61
+ {:else}
62
+ <ClsPad keysAdd={['containerVerticalPadding', 'containerUnitSize']} {theme} />
63
+ {/if}
64
+ {:else}
65
+ <InternalPaneInline {theme} userCreatedPane={false}>
66
+ <svelte:self bind:disabled bind:key bind:label bind:object bind:options bind:plugin bind:ref />
67
+ </InternalPaneInline>
68
+ {/if}
@@ -0,0 +1,116 @@
1
+ import { SvelteComponent } from 'svelte';
2
+ import type { BindingApi, BindingParams } from '@tweakpane/core';
3
+ import type { BindingObject } from '../utils';
4
+ export type BindingOptions = BindingParams;
5
+ export type BindingRef = BindingApi;
6
+ import type { Theme } from '../theme.js';
7
+ declare class __sveltets_Render<
8
+ T extends BindingObject,
9
+ U extends BindingOptions,
10
+ V extends BindingRef
11
+ > {
12
+ props(): {
13
+ /**
14
+ * The binding's target object with values to manipulate.
15
+ * @bindable
16
+ * */ object: T;
17
+ /** The key for the value in the target `object` that the control should manipulate. */ key: keyof T;
18
+ /**
19
+ * Prevent interactivity and gray out the control.
20
+ * @default `false`
21
+ * */ disabled?: boolean | undefined;
22
+ /**
23
+ * Text displayed next to control.
24
+ * @default `undefined`
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
+ * */ options?: U | 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
+ * */ theme?: Theme | undefined;
45
+ /**
46
+ * Reference to internal Tweakpane
47
+ * [`BindingApi`](https://tweakpane.github.io/docs/api/classes/_internal_.BindingApi.html) for
48
+ * this control.
49
+ *
50
+ * This is primarily for internal use, when implementing convenience components wrapping
51
+ * Binding's functionality.
52
+ * @bindable
53
+ * @readonly
54
+ * */ ref?: V | undefined;
55
+ /**
56
+ * Imported Tweakpane `TpPluginBundle` (aliased as `Plugin`) module to automatically register in
57
+ * the binding's containing `<Pane>`.
58
+ *
59
+ * This is primarily for internal use, when implementing convenience components wrapping
60
+ * Binding's functionality in combination with a Tweakpane plugin.
61
+ * @default `undefined`
62
+ * */ plugin?: import('@tweakpane/core').TpPluginBundle | undefined;
63
+ };
64
+ events(): {} & {
65
+ [evt: string]: CustomEvent<any>;
66
+ };
67
+ slots(): {};
68
+ }
69
+ export type BindingProps<
70
+ T extends BindingObject,
71
+ U extends BindingOptions,
72
+ V extends BindingRef
73
+ > = ReturnType<__sveltets_Render<T, U, V>['props']>;
74
+ export type BindingEvents<
75
+ T extends BindingObject,
76
+ U extends BindingOptions,
77
+ V extends BindingRef
78
+ > = ReturnType<__sveltets_Render<T, U, V>['events']>;
79
+ export type BindingSlots<
80
+ T extends BindingObject,
81
+ U extends BindingOptions,
82
+ V extends BindingRef
83
+ > = ReturnType<__sveltets_Render<T, U, V>['slots']>;
84
+ /**
85
+ * Wraps the Tweakpane [`addBinding`](https://tweakpane.github.io/docs/input-bindings/) method.
86
+ *
87
+ * Important: This component is provided for consistency with Tweakpane's API, but is not recommended
88
+ * for general use in _Svelte Tweakpane UI_ because more helpful abstractions are available.
89
+ *
90
+ * Please consider convenience components like `<Slider>`, `<Color>`, etc. etc. before using this
91
+ * component directly.
92
+ *
93
+ * Usage outside of a `<Pane>` component will implicitly wrap the component in `<Pane
94
+ * position='inline'>`.
95
+ *
96
+ * @example
97
+ * ```svelte
98
+ * <script lang="ts">
99
+ * import { Binding, type BindingObject } from 'svelte-tweakpane-ui';
100
+ *
101
+ * let object: BindingObject = { r: 0 };
102
+ * </script>
103
+ *
104
+ * <Binding bind:object key={'r'} label="Reticulation" />
105
+ * <pre>Value: {object.r}</pre>
106
+ * ```
107
+ *
108
+ * @sourceLink
109
+ * [Binding.svelte](https://github.com/kitschpatrol/svelte-tweakpane-ui/blob/main/src/lib/core/Binding.svelte)
110
+ */
111
+ export default class Binding<
112
+ T extends BindingObject,
113
+ U extends BindingOptions,
114
+ V extends BindingRef
115
+ > extends SvelteComponent<BindingProps<T, U, V>, BindingEvents<T, U, V>, BindingSlots<T, U, V>> {}
116
+ export {};
@@ -0,0 +1,61 @@
1
+ <script context="module"></script>
2
+
3
+ <script generics="U extends BladeOptions, V extends BladeRef">
4
+ import ClsPad from '../internal/ClsPad.svelte';
5
+ import InternalPaneInline from '../internal/InternalPaneInline.svelte';
6
+ import { enforceReadonly, getElementIndex, isRootPane } from '../utils.js';
7
+ import { BROWSER, DEV } from 'esm-env';
8
+ import { getContext, onDestroy, onMount } from 'svelte';
9
+ export let options;
10
+ export let disabled = false;
11
+ export let theme = void 0;
12
+ export let ref = void 0;
13
+ export let plugin = void 0;
14
+ const registerPlugin = getContext('registerPlugin');
15
+ const parentStore = getContext('parentStore');
16
+ const userCreatedPane = getContext('userCreatedPane');
17
+ let indexElement;
18
+ let index;
19
+ let _ref;
20
+ function create() {
21
+ if (_ref) _ref.dispose();
22
+ if (plugin !== void 0) {
23
+ registerPlugin(plugin);
24
+ }
25
+ _ref = $parentStore.addBlade({
26
+ index,
27
+ ...options,
28
+ disabled
29
+ // why last?
30
+ });
31
+ ref = _ref;
32
+ }
33
+ onMount(() => {
34
+ index = indexElement ? getElementIndex(indexElement) : 0;
35
+ });
36
+ onDestroy(() => {
37
+ _ref?.dispose();
38
+ });
39
+ $: DEV && BROWSER && enforceReadonly(_ref, ref, 'Blade', 'ref', true);
40
+ $: options, BROWSER && $parentStore && index !== void 0 && create();
41
+ $: BROWSER && _ref && (_ref.disabled = disabled);
42
+ $: BROWSER &&
43
+ theme &&
44
+ $parentStore &&
45
+ (userCreatedPane || !isRootPane($parentStore)) &&
46
+ console.warn(
47
+ 'Set theme on the <Pane> component, not on its children! (Check nested <Blade> components for a theme prop.)'
48
+ );
49
+ </script>
50
+
51
+ {#if parentStore}
52
+ {#if BROWSER}
53
+ <div bind:this={indexElement} style="display: none;" />
54
+ {:else}
55
+ <ClsPad keysAdd={['containerVerticalPadding']} {theme} />
56
+ {/if}
57
+ {:else}
58
+ <InternalPaneInline {theme} userCreatedPane={false}>
59
+ <svelte:self bind:disabled bind:options bind:plugin bind:ref />
60
+ </InternalPaneInline>
61
+ {/if}
@@ -0,0 +1,90 @@
1
+ import { SvelteComponent } from 'svelte';
2
+ import type { BaseBladeParams, BladeApi } from 'tweakpane';
3
+ export type BladeRef = BladeApi;
4
+ export type BladeOptions = BaseBladeParams;
5
+ export type { Plugin } from '../utils.js';
6
+ import type { Theme } from '../theme.js';
7
+ declare class __sveltets_Render<U extends BladeOptions, V extends BladeRef> {
8
+ props(): {
9
+ /**
10
+ * Blade configuration exposing Tweakpane's internal
11
+ * [`BladeParams`](https://tweakpane.github.io/docs/api/interfaces/BaseBladeParams.html).
12
+ *
13
+ * */ options: U;
14
+ /**
15
+ * Prevent interactivity and gray out the control.
16
+ * @default `false`
17
+ * */ disabled?: boolean | undefined;
18
+ /**
19
+ * Custom color scheme.
20
+ * @default `undefined` \
21
+ * Inherits default Tweakpane theme equivalent to `ThemeUtils.presets.standard`, or the theme
22
+ * set with `setGlobalDefaultTheme()`.
23
+ * */ theme?: Theme | undefined;
24
+ /**
25
+ * Reference to internal Tweakpane
26
+ * [`BladeApi`](https://tweakpane.github.io/docs/api/classes/BladeApi.html) for this blade.
27
+ *
28
+ * This is primarily for internal use, when implementing convenience components wrapping Blade's
29
+ * functionality.
30
+ * @bindable
31
+ * @readonly
32
+ * */ ref?: V | undefined;
33
+ /**
34
+ * Imported Tweakpane `TpPluginBundle` (Aliased as `Plugin`) module to register before creating
35
+ * the blade.
36
+ *
37
+ * This is primarily for internal use, when implementing convenience components wrapping Blade's
38
+ * functionality in combination with a Tweakpane plugin.
39
+ * @default `undefined`
40
+ * */ plugin?: import('tweakpane').TpPluginBundle | undefined;
41
+ };
42
+ events(): {} & {
43
+ [evt: string]: CustomEvent<any>;
44
+ };
45
+ slots(): {};
46
+ }
47
+ export type BladeProps<U extends BladeOptions, V extends BladeRef> = ReturnType<
48
+ __sveltets_Render<U, V>['props']
49
+ >;
50
+ export type BladeEvents<U extends BladeOptions, V extends BladeRef> = ReturnType<
51
+ __sveltets_Render<U, V>['events']
52
+ >;
53
+ export type BladeSlots<U extends BladeOptions, V extends BladeRef> = ReturnType<
54
+ __sveltets_Render<U, V>['slots']
55
+ >;
56
+ /**
57
+ * Wraps the Tweakpane [`addBlade`](https://tweakpane.github.io/docs/blades/) method.
58
+ *
59
+ * Important: This component is provided for consistency with Tweakpane's API, but is not recommended
60
+ * for general use in _Svelte Tweakpane UI_ because more helpful abstractions are available.
61
+ *
62
+ * Please consider convenience components like `<Separator>`, etc. before using this component
63
+ * directly.
64
+ *
65
+ * Usage outside of a `<Pane>` component will implicitly wrap the component in `<Pane
66
+ * position='inline'>`.
67
+ *
68
+ * Tweakpane's vanilla JS API offers Blades as as a way to create unbound components, but in Svelte the
69
+ * same is achieved by simply not binding the component's value.
70
+ *
71
+ * In the example, a `<Separator>` component would be preferred over `<Blade>`, and would obviate the
72
+ * need for the options param.
73
+ *
74
+ * @example
75
+ * ```svelte
76
+ * <script lang="ts">
77
+ * import { Blade } from 'svelte-tweakpane-ui';
78
+ * </script>
79
+ *
80
+ * <Blade options={{ view: 'separator' }} />
81
+ * ```
82
+ *
83
+ * @sourceLink
84
+ * [Blade.svelte](https://github.com/kitschpatrol/svelte-tweakpane-ui/blob/main/src/lib/core/Blade.svelte)
85
+ */
86
+ export default class Blade<U extends BladeOptions, V extends BladeRef> extends SvelteComponent<
87
+ BladeProps<U, V>,
88
+ BladeEvents<U, V>,
89
+ BladeSlots<U, V>
90
+ > {}