svelte-tweakpane-ui 1.0.0 → 1.0.2

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 (59) hide show
  1. package/dist/control/ButtonGrid.svelte +6 -7
  2. package/dist/control/ButtonGrid.svelte.d.ts +6 -4
  3. package/dist/control/Checkbox.svelte.d.ts +2 -4
  4. package/dist/control/Color.svelte.d.ts +2 -4
  5. package/dist/control/CubicBezier.svelte +13 -21
  6. package/dist/control/CubicBezier.svelte.d.ts +5 -2
  7. package/dist/control/Image.svelte.d.ts +7 -9
  8. package/dist/control/IntervalSlider.svelte.d.ts +2 -4
  9. package/dist/control/List.svelte +14 -20
  10. package/dist/control/List.svelte.d.ts +3 -5
  11. package/dist/control/Point.svelte.d.ts +29 -31
  12. package/dist/control/RadioGrid.svelte.d.ts +2 -4
  13. package/dist/control/Ring.svelte.d.ts +2 -4
  14. package/dist/control/RotationEuler.svelte.d.ts +66 -4
  15. package/dist/control/RotationQuaternion.svelte.d.ts +2 -4
  16. package/dist/control/Slider.svelte.d.ts +2 -4
  17. package/dist/control/Text.svelte +1 -1
  18. package/dist/control/Text.svelte.d.ts +2 -4
  19. package/dist/control/Textarea.svelte +1 -1
  20. package/dist/control/Textarea.svelte.d.ts +2 -4
  21. package/dist/control/Wheel.svelte.d.ts +2 -4
  22. package/dist/core/Blade.svelte +1 -1
  23. package/dist/core/TabGroup.svelte +3 -5
  24. package/dist/core/TabPage.svelte +2 -2
  25. package/dist/extra/AutoObject.svelte +7 -7
  26. package/dist/extra/AutoValue.svelte.d.ts +6 -4
  27. package/dist/extra/Element.svelte +2 -4
  28. package/dist/extra/Element.svelte.d.ts +30 -23
  29. package/dist/index.js +5 -5
  30. package/dist/internal/ClsPad.svelte +3 -7
  31. package/dist/internal/ClsPad.svelte.d.ts +10 -0
  32. package/dist/internal/GenericBinding.svelte.d.ts +2 -4
  33. package/dist/internal/GenericBladeFolding.svelte +5 -5
  34. package/dist/internal/GenericInput.svelte.d.ts +2 -4
  35. package/dist/internal/GenericInputFolding.svelte +5 -5
  36. package/dist/internal/GenericInputFolding.svelte.d.ts +2 -4
  37. package/dist/internal/GenericMonitor.svelte +1 -1
  38. package/dist/internal/GenericMonitor.svelte.d.ts +2 -4
  39. package/dist/internal/GenericPane.svelte +4 -7
  40. package/dist/internal/GenericSlider.svelte.d.ts +2 -4
  41. package/dist/internal/InternalMonitorBoolean.svelte.d.ts +2 -4
  42. package/dist/internal/InternalMonitorNumber.svelte.d.ts +2 -4
  43. package/dist/internal/InternalMonitorString.svelte.d.ts +2 -4
  44. package/dist/internal/InternalPaneDraggable.svelte +72 -64
  45. package/dist/internal/InternalPaneFixed.svelte +1 -3
  46. package/dist/internal/InternalPaneInline.svelte +3 -3
  47. package/dist/monitor/FpsGraph.svelte +6 -3
  48. package/dist/monitor/FpsGraph.svelte.d.ts +2 -2
  49. package/dist/monitor/Monitor.svelte.d.ts +24 -32
  50. package/dist/monitor/Profiler.svelte +10 -7
  51. package/dist/monitor/Profiler.svelte.d.ts +8 -5
  52. package/dist/monitor/WaveformMonitor.svelte.d.ts +2 -4
  53. package/dist/theme.d.ts +1 -3
  54. package/dist/theme.js +30 -39
  55. package/dist/utils.d.ts +10 -7
  56. package/dist/utils.js +53 -46
  57. package/package.json +26 -43
  58. package/{README.md → readme.md} +10 -3
  59. /package/{LICENSE → license.txt} +0 -0
@@ -12,18 +12,18 @@
12
12
  export let prettyLabels = true;
13
13
  export let object;
14
14
  const parentStore = getContext('parentStore');
15
- function isPointObject(obj) {
16
- return Point2d.isObject(obj) || Point3d.isObject(obj) || Point4d.isObject(obj);
15
+ function isPointObject(testObject) {
16
+ return (
17
+ Point2d.isObject(testObject) || Point3d.isObject(testObject) || Point4d.isObject(testObject)
18
+ );
17
19
  }
18
20
  function prettify(value, active = true) {
19
21
  if (!active) return value;
20
22
  return value
21
- .replace(/([a-z0-9])([A-Z])/g, '$1 $2')
22
- .replace(/[_-]+/g, ' ')
23
+ .replaceAll(/([\da-z])([A-Z])/g, '$1 $2')
24
+ .replaceAll(/[_-]+/g, ' ')
23
25
  .toLowerCase()
24
- .replace(/\b[a-z]/g, (letter) => {
25
- return letter.toUpperCase();
26
- });
26
+ .replaceAll(/\b[a-z]/g, (letter) => letter.toUpperCase());
27
27
  }
28
28
  </script>
29
29
 
@@ -7,11 +7,10 @@ declare const __propDef: {
7
7
  * The binding's target object with values to manipulate.
8
8
  * @bindable
9
9
  */
10
- object: import('@tweakpane/core').Bindable & {
11
- [x: string]: string | number | boolean | object;
12
- };
10
+ object: import('@tweakpane/core').Bindable &
11
+ Record<string, string | number | boolean | object>;
13
12
  /** The key for the value in the target `object` that the control should manipulate. */
14
- key: string | number;
13
+ key: string;
15
14
  /**
16
15
  * Prevent interactivity and gray out the control.
17
16
  * @default `false`
@@ -114,6 +113,9 @@ export type AutoValueSlots = typeof __propDef.slots;
114
113
  * <AutoValue bind:value={point} label="Point" />
115
114
  * <AutoValue bind:value={text} label="Text" />
116
115
  * ```
116
+ *
117
+ * @sourceLink
118
+ * [AutoValue.svelte](https://github.com/kitschpatrol/svelte-tweakpane-ui/blob/main/src/lib/extra/AutoValue.svelte)
117
119
  */
118
120
  export default class AutoValue extends SvelteComponent<
119
121
  AutoValueProps,
@@ -9,9 +9,7 @@
9
9
  };
10
10
  let ref;
11
11
  let sourceDiv;
12
- $: if (ref && ref.element) {
13
- ref.element.replaceChildren(sourceDiv);
14
- }
12
+ $: ref?.element.replaceChildren(sourceDiv);
15
13
  </script>
16
14
 
17
15
  {#if BROWSER}
@@ -27,7 +25,7 @@
27
25
  <div
28
26
  class="element-container"
29
27
  style:height={BROWSER ? null : `${maxHeight}px`}
30
- style:max-height={maxHeight !== undefined ? `${maxHeight}px` : null}
28
+ style:max-height={maxHeight === undefined ? null : `${maxHeight}px`}
31
29
  style:overflow={BROWSER ? null : 'hidden'}
32
30
  >
33
31
  <div class:reset={resetStyle}>
@@ -44,20 +44,22 @@ declare const __propDef: {
44
44
  'options' | 'disabled' | 'ref' | 'plugin'
45
45
  > & {
46
46
  /**
47
- * Maximum height of the element block, in pixels. By default, the element block will expand
48
- * vertically to fit its contents, but clip any horizontal excess.
47
+ * Maximum height of the element block, in pixels. By default, the element
48
+ * block will expand vertically to fit its contents, but clip any horizontal
49
+ * excess.
49
50
  *
50
- * If a max height is set, it is used as the component height during SSR. If the actual
51
- * element content is less than the max, you will see CLS. If it is not set, the contents
52
- * are rendered... but keep in mind that style and other contextual changes during the
53
- * client render could result in CLS.
51
+ * If a max height is set, it is used as the component height during SSR. If
52
+ * the actual element content is less than the max, you will see CLS. If it
53
+ * is not set, the contents are rendered... but keep in mind that style and
54
+ * other contextual changes during the client render could result in CLS.
54
55
  * @default `undefined` \
55
56
  * No max height.
56
57
  */
57
58
  maxHeight?: number | undefined;
58
59
  /**
59
- * Whether to reset the CSS of the element block to its default values. Avoids inheritance
60
- * of Tweakpane's CSS styles. Note that this uses a simple `all: initial;` rule.
60
+ * Whether to reset the CSS of the element block to its default values.
61
+ * Avoids inheritance of Tweakpane's CSS styles. Note that this uses a
62
+ * simple `all: initial;` rule.
61
63
  * @default `true`
62
64
  */
63
65
  resetStyle?: boolean | undefined;
@@ -78,25 +80,30 @@ export type ElementSlots = typeof __propDef.slots;
78
80
  /**
79
81
  * A component for embedding arbitrary HTML elements into a pane.
80
82
  *
81
- * Any children wrapped in this component will be rendered into the pane. Any content larger than the
82
- * pane in the horizontal axis will be clipped.
83
+ * Any children wrapped in this component will be rendered into the pane. Any
84
+ * content larger than the pane in the horizontal axis will be clipped.
83
85
  *
84
- * Useful for quickly prototyping UIs, or adding content to a pane that's not easily represented by the
85
- * built-in components.
86
+ * Useful for quickly prototyping UIs, or adding content to a pane that's not
87
+ * easily represented by the built-in components.
86
88
  *
87
- * Think of this component as an escape hatch for getting something into the pane that you couldn't
88
- * otherwise, but it's recommended to abstract new functionality for reuse by extending one of the
89
- * internal component types in 'svelte-tweakpane-ui', or better yet by creating a new [Tweakpane
90
- * Plugin](https://github.com/tweakpane/plugin-template).
89
+ * This component does not have a direct analog in the vanilla Tweakpane universe.
91
90
  *
92
- * In many cases, this component should not be necessary because _Svelte Tweakpane UI_ already makes it
93
- * easy to combine tweakpane components with other inline elements simply by not using a wrapping
94
- * `<Pane>` component. It should generally be the most useful when you're using `<Pane
95
- * position='draggable'>` or `<Pane position='fixed'>` and you want a custom element embedded in the
96
- * pane.
91
+ * Think of `<Element>` as an escape hatch for getting something into the pane that
92
+ * you couldn't otherwise. Generally, it's recommended to abstract new
93
+ * functionality for reuse by extending one of the internal component types in
94
+ * 'svelte-tweakpane-ui', or better yet by creating a new [Tweakpane
95
+ * Plugin](https://github.com/tweakpane/plugin-template) — but sometimes you just
96
+ * need to get something into the pane quickly.
97
97
  *
98
- * Usage outside of a `<Pane>` component doesn't make a ton of sense, but in such a case the
99
- * `<Element>` will be implicitly wrapped in `<Pane position='inline'>`.
98
+ * In many cases, this component should not be necessary because _Svelte Tweakpane
99
+ * UI_ already makes it easy to combine tweakpane components with other inline
100
+ * elements simply by using stand-alone components or a `<Pane position='inline'>`
101
+ * component. `<Element>` should generally be the most useful when you're using
102
+ * `<Pane position='draggable'>` or `<Pane position='fixed'>` and you want a custom
103
+ * element embedded in the pane.
104
+ *
105
+ * Usage outside of a `<Pane>` component doesn't make a ton of sense, but in such a
106
+ * case the `<Element>` will be implicitly wrapped in `<Pane position='inline'>`.
100
107
  *
101
108
  * @example
102
109
  * ```svelte
package/dist/index.js CHANGED
@@ -1,16 +1,16 @@
1
- // components
1
+ // Components
2
2
  // essentials (1st party plugins)
3
3
  export { default as ButtonGrid } from './control/ButtonGrid.svelte';
4
4
  export { default as Checkbox } from './control/Checkbox.svelte';
5
5
  export { default as Color } from './control/Color.svelte';
6
6
  export { default as CubicBezier } from './control/CubicBezier.svelte';
7
- // additional plugins (3rd party / community)
7
+ // Additional plugins (3rd party / community)
8
8
  export { default as Image } from './control/Image.svelte';
9
9
  export { default as IntervalSlider } from './control/IntervalSlider.svelte';
10
10
  export { default as List } from './control/List.svelte';
11
11
  export { default as Point } from './control/Point.svelte';
12
12
  export { default as RadioGrid } from './control/RadioGrid.svelte';
13
- // camerakit (1st party plugins)
13
+ // Camerakit (1st party plugins)
14
14
  export { default as Ring } from './control/Ring.svelte';
15
15
  export { default as RotationEuler } from './control/RotationEuler.svelte';
16
16
  export { default as RotationQuaternion } from './control/RotationQuaternion.svelte';
@@ -18,7 +18,7 @@ export { default as Slider } from './control/Slider.svelte';
18
18
  export { default as Text } from './control/Text.svelte';
19
19
  export { default as Textarea } from './control/Textarea.svelte';
20
20
  export { default as Wheel } from './control/Wheel.svelte';
21
- // core (tweakpane building blocks)
21
+ // Core (tweakpane building blocks)
22
22
  export { default as Binding } from './core/Binding.svelte';
23
23
  export { default as Blade } from './core/Blade.svelte';
24
24
  export { default as Button } from './core/Button.svelte';
@@ -27,7 +27,7 @@ export { default as Pane } from './core/Pane.svelte';
27
27
  export { default as Separator } from './core/Separator.svelte';
28
28
  export { default as TabGroup } from './core/TabGroup.svelte';
29
29
  export { default as TabPage } from './core/TabPage.svelte';
30
- // extra (svelte convenience components)
30
+ // Extra (svelte convenience components)
31
31
  export { default as AutoObject } from './extra/AutoObject.svelte';
32
32
  export { default as AutoValue } from './extra/AutoValue.svelte';
33
33
  export { default as Element } from './extra/Element.svelte';
@@ -10,16 +10,12 @@
10
10
  return '#' + Math.floor(Math.random() * 16777215).toString(16);
11
11
  }
12
12
  function getPixelValue(s) {
13
- return parseFloat(s.replace('px', ''));
13
+ return Number.parseFloat(s.replace('px', ''));
14
14
  }
15
15
  function getTotal(add, sub, extra2 = 0) {
16
16
  return (
17
- add.reduce((acc, key) => {
18
- return (acc += getPixelValue(getValueOrFallback(theme, key)));
19
- }, 0) -
20
- sub.reduce((acc, key) => {
21
- return (acc += getPixelValue(getValueOrFallback(theme, key)));
22
- }, 0) +
17
+ add.reduce((acc, key) => (acc += getPixelValue(getValueOrFallback(theme, key))), 0) -
18
+ sub.reduce((acc, key) => (acc += getPixelValue(getValueOrFallback(theme, key))), 0) +
23
19
  extra2
24
20
  );
25
21
  }
@@ -91,5 +91,15 @@ declare const __propDef: {
91
91
  export type ClsPadProps = typeof __propDef.props;
92
92
  export type ClsPadEvents = typeof __propDef.events;
93
93
  export type ClsPadSlots = typeof __propDef.slots;
94
+ /**
95
+ * This component is for internal use only.
96
+ *
97
+ * It's a utility to assist in estimating the rendered height of Tweakpane components for use during prerendering in an attempt to minimize layout shift upon hydration.
98
+ *
99
+ * The associated SSR / prerendering CLS prevention feature is experimental.
100
+ *
101
+ * @sourceLink
102
+ * [ClsPad.svelte](https://github.com/kitschpatrol/svelte-tweakpane-ui/blob/main/src/lib/internal/ClsPad.svelte)
103
+ */
94
104
  export default class ClsPad extends SvelteComponent<ClsPadProps, ClsPadEvents, ClsPadSlots> {}
95
105
  export {};
@@ -11,11 +11,9 @@ declare class __sveltets_Render<
11
11
  * The binding's target object with values to manipulate.
12
12
  * @bindable
13
13
  */
14
- object: import('@tweakpane/core').Bindable & {
15
- [x: string]: T;
16
- };
14
+ object: import('@tweakpane/core').Bindable & Record<string, T>;
17
15
  /** The key for the value in the target `object` that the control should manipulate. */
18
- key: string | number;
16
+ key: string;
19
17
  /**
20
18
  * Prevent interactivity and gray out the control.
21
19
  * @default `false`
@@ -14,15 +14,15 @@
14
14
  let internalExpanded = initialExpanded;
15
15
  $: if (!gotBlade && ref) {
16
16
  gotBlade = true;
17
- ref.controller?.valueController?.foldable_?.value('expanded').emitter.on('change', (e) => {
18
- internalExpanded = e.rawValue;
17
+ ref.controller?.valueController?.foldable_?.value('expanded').emitter.on('change', (event) => {
18
+ internalExpanded = event.rawValue;
19
19
  expanded = internalExpanded;
20
20
  });
21
21
  }
22
22
  $: options = {
23
23
  ...options,
24
24
  expanded: initialExpanded,
25
- // only set once
25
+ // Only set once
26
26
  picker
27
27
  };
28
28
  $: ref &&
@@ -31,8 +31,8 @@
31
31
  $: ref &&
32
32
  buttonClass !== void 0 &&
33
33
  expanded !== internalExpanded &&
34
- ref.element.getElementsByClassName(buttonClass).length > 0 &&
35
- ref.element.getElementsByClassName(buttonClass)[0].click();
34
+ ref.element.querySelectorAll(`.${buttonClass}`).length > 0 &&
35
+ ref.element.querySelector(`.${buttonClass}`).click();
36
36
  </script>
37
37
 
38
38
  <Blade bind:ref {options} {...$$restProps} />
@@ -13,11 +13,9 @@ declare class __sveltets_Render<
13
13
  * The binding's target object with values to manipulate.
14
14
  * @bindable
15
15
  */
16
- object: import('@tweakpane/core').Bindable & {
17
- [x: string]: T;
18
- };
16
+ object: import('@tweakpane/core').Bindable & Record<string, T>;
19
17
  /** The key for the value in the target `object` that the control should manipulate. */
20
- key: string | number;
18
+ key: string;
21
19
  /**
22
20
  * Prevent interactivity and gray out the control.
23
21
  * @default `false`
@@ -18,23 +18,23 @@
18
18
  let internalExpanded = initialExpanded;
19
19
  $: if (!gotBinding && ref) {
20
20
  gotBinding = true;
21
- ref.controller?.valueController?.foldable_?.value('expanded').emitter.on('change', (e) => {
22
- internalExpanded = e.rawValue;
21
+ ref.controller?.valueController?.foldable_?.value('expanded').emitter.on('change', (event) => {
22
+ internalExpanded = event.rawValue;
23
23
  expanded = internalExpanded;
24
24
  });
25
25
  }
26
26
  $: optionsInternal = {
27
27
  ...options,
28
28
  expanded: initialExpanded,
29
- // only set once
29
+ // Only set once
30
30
  picker
31
31
  };
32
32
  $: ref && buttonClass && updateCollapsibility(userExpandable ?? true, ref.element, buttonClass);
33
33
  $: ref &&
34
34
  buttonClass &&
35
35
  expanded !== internalExpanded &&
36
- ref.element.getElementsByClassName(buttonClass).length > 0 &&
37
- ref.element.getElementsByClassName(buttonClass)[0].click();
36
+ ref.element.querySelectorAll(`.${buttonClass}`).length > 0 &&
37
+ ref.element.querySelector(`.${buttonClass}`)?.click();
38
38
  </script>
39
39
 
40
40
  <GenericInput bind:value bind:ref options={optionsInternal} {...$$restProps} />
@@ -15,11 +15,9 @@ declare class __sveltets_Render<
15
15
  * The binding's target object with values to manipulate.
16
16
  * @bindable
17
17
  */
18
- object: import('@tweakpane/core').Bindable & {
19
- [x: string]: T;
20
- };
18
+ object: import('@tweakpane/core').Bindable & Record<string, T>;
21
19
  /** The key for the value in the target `object` that the control should manipulate. */
22
- key: string | number;
20
+ key: string;
23
21
  /**
24
22
  * Prevent interactivity and gray out the control.
25
23
  * @default `false`
@@ -14,7 +14,7 @@
14
14
  $: optionsInternal = {
15
15
  bufferSize,
16
16
  interval: interval ?? 0,
17
- // zero confirmed as never updating (not same interface as setInterval())
17
+ // Zero confirmed as never updating (not same interface as setInterval())
18
18
  rows,
19
19
  ...options,
20
20
  readonly: true
@@ -13,11 +13,9 @@ declare class __sveltets_Render<
13
13
  * The binding's target object with values to manipulate.
14
14
  * @bindable
15
15
  */
16
- object: import('@tweakpane/core').Bindable & {
17
- [x: string]: T;
18
- };
16
+ object: import('@tweakpane/core').Bindable & Record<string, T>;
19
17
  /** The key for the value in the target `object` that the control should manipulate. */
20
- key: string | number;
18
+ key: string;
21
19
  /**
22
20
  * Prevent interactivity and gray out the control.
23
21
  * @default `false`
@@ -18,13 +18,10 @@
18
18
  let pluginsRegistered = [];
19
19
  const registerPlugin = (plugin) => {
20
20
  if (paneRef === void 0) {
21
- console.warn('`paneRef is undefined, failed to register plugin "${plugin.id}"');
22
- } else {
23
- if (pluginsRegistered.includes(plugin.id)) {
24
- } else {
25
- paneRef?.registerPlugin(plugin);
26
- pluginsRegistered.push(plugin.id);
27
- }
21
+ console.warn(`paneRef is undefined, failed to register plugin "${plugin.id}"`);
22
+ } else if (!pluginsRegistered.includes(plugin.id)) {
23
+ paneRef?.registerPlugin(plugin);
24
+ pluginsRegistered.push(plugin.id);
28
25
  }
29
26
  };
30
27
  setContext('registerPlugin', registerPlugin);
@@ -9,11 +9,9 @@ declare class __sveltets_Render<T extends number | IntervalSliderValue> {
9
9
  * The binding's target object with values to manipulate.
10
10
  * @bindable
11
11
  */
12
- object: import('@tweakpane/core').Bindable & {
13
- [x: string]: T;
14
- };
12
+ object: import('@tweakpane/core').Bindable & Record<string, T>;
15
13
  /** The key for the value in the target `object` that the control should manipulate. */
16
- key: string | number;
14
+ key: string;
17
15
  /**
18
16
  * Prevent interactivity and gray out the control.
19
17
  * @default `false`
@@ -9,11 +9,9 @@ declare const __propDef: {
9
9
  * The binding's target object with values to manipulate.
10
10
  * @bindable
11
11
  */
12
- object: import('@tweakpane/core').Bindable & {
13
- [x: string]: boolean;
14
- };
12
+ object: import('@tweakpane/core').Bindable & Record<string, boolean>;
15
13
  /** The key for the value in the target `object` that the control should manipulate. */
16
- key: string | number;
14
+ key: string;
17
15
  /**
18
16
  * Prevent interactivity and gray out the control.
19
17
  * @default `false`
@@ -9,11 +9,9 @@ declare const __propDef: {
9
9
  * The binding's target object with values to manipulate.
10
10
  * @bindable
11
11
  */
12
- object: import('@tweakpane/core').Bindable & {
13
- [x: string]: number;
14
- };
12
+ object: import('@tweakpane/core').Bindable & Record<string, number>;
15
13
  /** The key for the value in the target `object` that the control should manipulate. */
16
- key: string | number;
14
+ key: string;
17
15
  /**
18
16
  * Prevent interactivity and gray out the control.
19
17
  * @default `false`
@@ -9,11 +9,9 @@ declare const __propDef: {
9
9
  * The binding's target object with values to manipulate.
10
10
  * @bindable
11
11
  */
12
- object: import('@tweakpane/core').Bindable & {
13
- [x: string]: string;
14
- };
12
+ object: import('@tweakpane/core').Bindable & Record<string, string>;
15
13
  /** The key for the value in the target `object` that the control should manipulate. */
16
- key: string | number;
14
+ key: string;
17
15
  /**
18
16
  * Prevent interactivity and gray out the control.
19
17
  * @default `false`