svelte-tweakpane-ui 1.0.1 → 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 (53) hide show
  1. package/dist/control/ButtonGrid.svelte +6 -7
  2. package/dist/control/Checkbox.svelte.d.ts +2 -4
  3. package/dist/control/Color.svelte.d.ts +2 -4
  4. package/dist/control/CubicBezier.svelte +1 -1
  5. package/dist/control/CubicBezier.svelte.d.ts +3 -0
  6. package/dist/control/Image.svelte.d.ts +2 -4
  7. package/dist/control/IntervalSlider.svelte.d.ts +2 -4
  8. package/dist/control/List.svelte +7 -13
  9. package/dist/control/List.svelte.d.ts +3 -5
  10. package/dist/control/Point.svelte.d.ts +29 -31
  11. package/dist/control/RadioGrid.svelte.d.ts +2 -4
  12. package/dist/control/Ring.svelte.d.ts +2 -4
  13. package/dist/control/RotationEuler.svelte.d.ts +66 -4
  14. package/dist/control/RotationQuaternion.svelte.d.ts +2 -4
  15. package/dist/control/Slider.svelte.d.ts +2 -4
  16. package/dist/control/Text.svelte.d.ts +2 -4
  17. package/dist/control/Textarea.svelte +1 -1
  18. package/dist/control/Textarea.svelte.d.ts +2 -4
  19. package/dist/control/Wheel.svelte.d.ts +2 -4
  20. package/dist/core/Blade.svelte +1 -1
  21. package/dist/core/TabPage.svelte +2 -2
  22. package/dist/extra/AutoObject.svelte +3 -5
  23. package/dist/extra/AutoValue.svelte.d.ts +6 -4
  24. package/dist/extra/Element.svelte +1 -3
  25. package/dist/index.js +5 -5
  26. package/dist/internal/ClsPad.svelte +2 -6
  27. package/dist/internal/ClsPad.svelte.d.ts +10 -0
  28. package/dist/internal/GenericBinding.svelte.d.ts +2 -4
  29. package/dist/internal/GenericBladeFolding.svelte +1 -1
  30. package/dist/internal/GenericInput.svelte.d.ts +2 -4
  31. package/dist/internal/GenericInputFolding.svelte +2 -2
  32. package/dist/internal/GenericInputFolding.svelte.d.ts +2 -4
  33. package/dist/internal/GenericMonitor.svelte +1 -1
  34. package/dist/internal/GenericMonitor.svelte.d.ts +2 -4
  35. package/dist/internal/GenericPane.svelte +4 -7
  36. package/dist/internal/GenericSlider.svelte.d.ts +2 -4
  37. package/dist/internal/InternalMonitorBoolean.svelte.d.ts +2 -4
  38. package/dist/internal/InternalMonitorNumber.svelte.d.ts +2 -4
  39. package/dist/internal/InternalMonitorString.svelte.d.ts +2 -4
  40. package/dist/internal/InternalPaneDraggable.svelte +19 -16
  41. package/dist/internal/InternalPaneFixed.svelte +1 -3
  42. package/dist/internal/InternalPaneInline.svelte +1 -1
  43. package/dist/monitor/FpsGraph.svelte +2 -2
  44. package/dist/monitor/Monitor.svelte.d.ts +23 -31
  45. package/dist/monitor/Profiler.svelte +2 -2
  46. package/dist/monitor/WaveformMonitor.svelte.d.ts +2 -4
  47. package/dist/theme.d.ts +1 -3
  48. package/dist/theme.js +25 -32
  49. package/dist/utils.d.ts +5 -2
  50. package/dist/utils.js +34 -27
  51. package/package.json +13 -7
  52. /package/{LICENSE → license.txt} +0 -0
  53. /package/{README.md → readme.md} +0 -0
@@ -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`
@@ -26,7 +26,7 @@
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);
@@ -34,7 +34,7 @@
34
34
  buttonClass &&
35
35
  expanded !== internalExpanded &&
36
36
  ref.element.querySelectorAll(`.${buttonClass}`).length > 0 &&
37
- ref.element.querySelector(`.${buttonClass}`).click();
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`
@@ -10,8 +10,8 @@
10
10
  import { clamp, getSwatchButton, pickerIsOpen, removeKeys } from '../utils.js';
11
11
  import { onDestroy, onMount } from 'svelte';
12
12
  import { persisted } from 'svelte-local-storage-store';
13
- const TITLEBAR_WINDOW_SHADE_SINGLE_CLICK = true;
14
- const TITLEBAR_WINDOW_SHADE_DOUBLE_CLICK = false;
13
+ const titlebarWindowShadeSingleClick = true;
14
+ const titlebarWindowShadeDoubleClick = false;
15
15
  export let storePositionLocally = true;
16
16
  export let localStoreId = localStoreDefaultId;
17
17
  let positionStore;
@@ -108,7 +108,7 @@
108
108
  if (event.target) {
109
109
  if (width !== void 0 && event.target === widthHandleElement) {
110
110
  width = width < maxAvailablePanelWidth ? maxAvailablePanelWidth : minWidth;
111
- } else if (TITLEBAR_WINDOW_SHADE_DOUBLE_CLICK && event.target === dragBarElement) {
111
+ } else if (titlebarWindowShadeDoubleClick && event.target === dragBarElement) {
112
112
  paneRef.expanded = !paneRef.expanded;
113
113
  }
114
114
  }
@@ -152,7 +152,7 @@
152
152
  event.target.removeEventListener('pointermove', moveListener);
153
153
  event.target.removeEventListener('pointerup', upListener);
154
154
  if (
155
- TITLEBAR_WINDOW_SHADE_SINGLE_CLICK &&
155
+ titlebarWindowShadeSingleClick &&
156
156
  event.target === dragBarElement &&
157
157
  moveDistance < 3 &&
158
158
  userExpandable
@@ -171,17 +171,20 @@
171
171
  console.warn('no pane ref in draggable');
172
172
  }
173
173
  containerElement.addEventListener('touchmove', touchScrollBlocker, { passive: false });
174
- dragBarElement = containerElement.querySelector('.tp-rotv_t');
175
- dragBarElement.addEventListener('click', clickBlocker);
176
- dragBarElement.addEventListener('dblclick', doubleClickListener);
177
- dragBarElement.addEventListener('pointerdown', downListener);
178
- widthHandleElement = dragBarElement.parentElement?.appendChild(document.createElement('div'));
179
- if (widthHandleElement) {
180
- widthHandleElement.className = 'tp-custom-width-handle';
181
- widthHandleElement.textContent = '\u2194';
182
- widthHandleElement.addEventListener('click', clickBlocker);
183
- widthHandleElement.addEventListener('dblclick', doubleClickListener);
184
- widthHandleElement.addEventListener('pointerdown', downListener);
174
+ const dragBarElementCheck = containerElement.querySelector('.tp-rotv_t');
175
+ if (dragBarElementCheck) {
176
+ dragBarElement = dragBarElementCheck;
177
+ dragBarElement.addEventListener('click', clickBlocker);
178
+ dragBarElement.addEventListener('dblclick', doubleClickListener);
179
+ dragBarElement.addEventListener('pointerdown', downListener);
180
+ widthHandleElement = dragBarElement.parentElement?.appendChild(document.createElement('div'));
181
+ if (widthHandleElement) {
182
+ widthHandleElement.className = 'tp-custom-width-handle';
183
+ widthHandleElement.textContent = '\u2194';
184
+ widthHandleElement.addEventListener('click', clickBlocker);
185
+ widthHandleElement.addEventListener('dblclick', doubleClickListener);
186
+ widthHandleElement.addEventListener('pointerdown', downListener);
187
+ }
185
188
  }
186
189
  });
187
190
  onDestroy(() => {
@@ -280,9 +283,9 @@
280
283
  <svelte:window on:resize={setDocumentSize} />
281
284
 
282
285
  <div
283
- bind:this={containerElement}
284
286
  bind:clientHeight={containerHeight}
285
287
  bind:clientWidth={containerWidth}
288
+ bind:this={containerElement}
286
289
  on:focus|capture={() => {
287
290
  zIndexLocal = ++zIndexGlobal;
288
291
  }}
@@ -8,9 +8,7 @@
8
8
  export let title = 'Tweakpane';
9
9
  let paneRef;
10
10
  let paneContainer;
11
- $: paneRef !== void 0 &&
12
- paneRef.element.parentElement &&
13
- (paneContainer = paneRef.element.parentElement);
11
+ $: paneRef?.element.parentElement && (paneContainer = paneRef.element.parentElement);
14
12
  $: paneContainer !== void 0 &&
15
13
  x !== void 0 &&
16
14
  (paneContainer.style.setProperty('right', 'unset'),
@@ -7,7 +7,7 @@
7
7
  export let theme = {
8
8
  baseBorderRadius: '0px',
9
9
  baseShadowColor: 'hsla(0, 0%, 0%, 0)'
10
- // bladeBorderRadius: '0px'
10
+ // BladeBorderRadius: '0px'
11
11
  };
12
12
  let paneRef;
13
13
  let containerElement;
@@ -46,13 +46,13 @@
46
46
  function startObservingMeasuredFpsValue() {
47
47
  stopObservingMeasuredFpsValue();
48
48
  const targetNode = fpsBlade.controller.valueController.view.valueElement;
49
- if (!targetNode || !targetNode.innerHTML) return;
49
+ if (!targetNode?.innerHTML) return;
50
50
  observer = new MutationObserver((mutations) => {
51
51
  for (const mutation of mutations) {
52
52
  if (mutation.type === 'characterData' || mutation.type === 'childList') {
53
53
  const fpsText = mutation.target.textContent;
54
54
  if (fpsText !== null) {
55
- const fps = Number.parseInt(fpsText);
55
+ const fps = Number.parseInt(fpsText, 10);
56
56
  !Number.isNaN(fps) && dispatch('change', fps);
57
57
  }
58
58
  }
@@ -7,11 +7,9 @@ declare class __sveltets_Render<W extends number | string | boolean | unknown> {
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]: W;
12
- };
10
+ object: import('@tweakpane/core').Bindable & Record<string, W>;
13
11
  /** The key for the value in the target `object` that the control should manipulate. */
14
- key: string | number;
12
+ key: string;
15
13
  /**
16
14
  * Prevent interactivity and gray out the control.
17
15
  * @default `false`
@@ -38,10 +36,10 @@ declare class __sveltets_Render<W extends number | string | boolean | unknown> {
38
36
  | (W extends string
39
37
  ? import('tweakpane').StringMonitorParams
40
38
  : W extends boolean
41
- ? import('tweakpane').BooleanMonitorParams
42
- : W extends number
43
- ? import('tweakpane').NumberMonitorParams
44
- : import('@tweakpane/core').BaseMonitorParams)
39
+ ? import('tweakpane').BooleanMonitorParams
40
+ : W extends number
41
+ ? import('tweakpane').NumberMonitorParams
42
+ : import('@tweakpane/core').BaseMonitorParams)
45
43
  | undefined;
46
44
  /**
47
45
  * Custom color scheme.
@@ -113,11 +111,9 @@ declare class __sveltets_Render<W extends number | string | boolean | unknown> {
113
111
  * The binding's target object with values to manipulate.
114
112
  * @bindable
115
113
  */
116
- object: import('@tweakpane/core').Bindable & {
117
- [x: string]: string;
118
- };
114
+ object: import('@tweakpane/core').Bindable & Record<string, string>;
119
115
  /** The key for the value in the target `object` that the control should manipulate. */
120
- key: string | number;
116
+ key: string;
121
117
  /**
122
118
  * Prevent interactivity and gray out the control.
123
119
  * @default `false`
@@ -202,7 +198,7 @@ declare class __sveltets_Render<W extends number | string | boolean | unknown> {
202
198
  rows?: number | undefined;
203
199
  },
204
200
  'options' | 'ref' | 'plugin' | 'interval'
205
- > & {
201
+ > & {
206
202
  /**
207
203
  * A value to monitor.
208
204
  * @bindable
@@ -213,20 +209,18 @@ declare class __sveltets_Render<W extends number | string | boolean | unknown> {
213
209
  * @default `false`
214
210
  */
215
211
  multiline?: boolean | undefined;
216
- }
212
+ }
217
213
  : W extends boolean
218
- ? Omit<
214
+ ? Omit<
219
215
  Omit<
220
216
  {
221
217
  /**
222
218
  * The binding's target object with values to manipulate.
223
219
  * @bindable
224
220
  */
225
- object: import('@tweakpane/core').Bindable & {
226
- [x: string]: boolean;
227
- };
221
+ object: import('@tweakpane/core').Bindable & Record<string, boolean>;
228
222
  /** The key for the value in the target `object` that the control should manipulate. */
229
- key: string | number;
223
+ key: string;
230
224
  /**
231
225
  * Prevent interactivity and gray out the control.
232
226
  * @default `false`
@@ -311,26 +305,24 @@ declare class __sveltets_Render<W extends number | string | boolean | unknown> {
311
305
  rows?: number | undefined;
312
306
  },
313
307
  'options' | 'ref' | 'plugin' | 'interval'
314
- > & {
308
+ > & {
315
309
  /**
316
310
  * A value to monitor.
317
311
  * @bindable
318
312
  */
319
313
  value: boolean;
320
- }
321
- : W extends number
322
- ? Omit<
314
+ }
315
+ : W extends number
316
+ ? Omit<
323
317
  Omit<
324
318
  {
325
319
  /**
326
320
  * The binding's target object with values to manipulate.
327
321
  * @bindable
328
322
  */
329
- object: import('@tweakpane/core').Bindable & {
330
- [x: string]: number;
331
- };
323
+ object: import('@tweakpane/core').Bindable & Record<string, number>;
332
324
  /** The key for the value in the target `object` that the control should manipulate. */
333
- key: string | number;
325
+ key: string;
334
326
  /**
335
327
  * Prevent interactivity and gray out the control.
336
328
  * @default `false`
@@ -415,7 +407,7 @@ declare class __sveltets_Render<W extends number | string | boolean | unknown> {
415
407
  rows?: number | undefined;
416
408
  },
417
409
  'options' | 'ref' | 'plugin'
418
- > & {
410
+ > & {
419
411
  /**
420
412
  * A value to monitor.
421
413
  * @bindable
@@ -442,14 +434,14 @@ declare class __sveltets_Render<W extends number | string | boolean | unknown> {
442
434
  * @default `false`
443
435
  */
444
436
  graph?: boolean | undefined;
445
- }
446
- : {
437
+ }
438
+ : {
447
439
  /**
448
440
  * A value to monitor.
449
441
  * @bindable
450
442
  * */
451
443
  value: string | number | boolean;
452
- });
444
+ });
453
445
  events(): {} & {
454
446
  [evt: string]: CustomEvent<any>;
455
447
  };
@@ -11,7 +11,7 @@
11
11
  profilerBlade?.measure(name, functionToMeasure);
12
12
  }
13
13
  async function _measureAsync(name, functionToMeasure) {
14
- profilerBlade?.measureAsync(name, functionToMeasure);
14
+ await profilerBlade?.measureAsync(name, functionToMeasure);
15
15
  }
16
16
  export let label = void 0;
17
17
  export let bufferSize = void 0;
@@ -33,7 +33,7 @@
33
33
  function startObservingMeasuredValue() {
34
34
  stopObservingMeasuredValue();
35
35
  const targetNode = profilerBlade.controller.view.valueElement;
36
- if (!targetNode || !targetNode.innerHTML) return;
36
+ if (!targetNode?.innerHTML) return;
37
37
  observer = new MutationObserver((mutations) => {
38
38
  for (const mutation of mutations) {
39
39
  if (mutation.type === 'characterData' || mutation.type === 'childList') {
@@ -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]: WaveformMonitorValue;
14
- };
12
+ object: import('@tweakpane/core').Bindable & Record<string, WaveformMonitorValue>;
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`
package/dist/theme.d.ts CHANGED
@@ -35,9 +35,7 @@ type ThemeKeys = {
35
35
  monitorForegroundColor?: ThemeColorValue;
36
36
  pluginImageDraggingColor?: ThemeColorValue;
37
37
  };
38
- type CustomThemeKeys = {
39
- [key: string]: ThemeColorValue;
40
- };
38
+ type CustomThemeKeys = Record<string, ThemeColorValue>;
41
39
  export declare const keys: Record<string, string>;
42
40
  export declare const presets: {
43
41
  /** Dark blue theme. */
package/dist/theme.js CHANGED
@@ -33,12 +33,12 @@ const standard = {
33
33
  monitorBackgroundColor: 'rgba(0, 0, 0, 0.2)',
34
34
  monitorForegroundColor: 'rgba(187, 188, 196, 0.7)',
35
35
  pluginImageDraggingColor: 'hsla(230, 100%, 66%, 1)'
36
- // pluginThumbnailListHeight: '400px', pluginThumbnailListThumbSize: '20px',
36
+ // PluginThumbnailListHeight: '400px', pluginThumbnailListThumbSize: '20px',
37
37
  // pluginThumbnailListWidth: '200px'
38
38
  };
39
- export const keys = Object.keys(standard).reduce((accumulator, key) => {
40
- accumulator[key] = key;
41
- return accumulator;
39
+ export const keys = Object.keys(standard).reduce((acc, key) => {
40
+ acc[key] = key;
41
+ return acc;
42
42
  }, {});
43
43
  const light = {
44
44
  baseBackgroundColor: 'hsla(230, 5%, 90%, 1.00)',
@@ -239,34 +239,33 @@ const keyToCssVariableMap = new Map([
239
239
  function stringToCssValue(v) {
240
240
  if (v === undefined) {
241
241
  return undefined;
242
- } else if (typeof v === 'string') {
242
+ }
243
+ if (typeof v === 'string') {
243
244
  return v;
244
- } else if (isRgbaColorObject(v)) {
245
+ }
246
+ if (isRgbaColorObject(v)) {
245
247
  return `rgba(${v.r}, ${v.g}, ${v.b}, ${v.a})`;
246
- } else if (isRgbColorObject(v)) {
248
+ }
249
+ if (isRgbColorObject(v)) {
247
250
  return `rgb(${v.r}, ${v.g}, ${v.b})`;
248
- } else {
249
- throw new Error(`Unknown CSS theme value object: ${v}`);
250
251
  }
251
252
  }
252
253
  function expandVariableKey(name) {
253
- // pass explicit variables through
254
+ // Pass explicit variables through
254
255
  if (name.startsWith('--tp-')) {
255
256
  return name;
256
- } else {
257
- const variableName = keyToCssVariableMap.get(name);
258
- if (variableName) {
259
- return variableName;
260
- } else {
261
- throw new Error(`Unknown Tweakpane CSS theme map variable key: "${name}"`);
262
- }
263
257
  }
258
+ const variableName = keyToCssVariableMap.get(name);
259
+ if (variableName) {
260
+ return variableName;
261
+ }
262
+ throw new Error(`Unknown Tweakpane CSS theme map variable key: "${name}"`);
264
263
  }
265
264
  /**
266
265
  * Used during SSR to calculate metrics Returns CSS string.
267
266
  */
268
267
  export function getValueOrFallback(theme, key) {
269
- return theme === undefined || theme[key] === undefined
268
+ return theme?.[key] === undefined
270
269
  ? stringToCssValue(standard[key])
271
270
  : stringToCssValue(theme[key]);
272
271
  }
@@ -276,7 +275,6 @@ export function applyTheme(element, theme) {
276
275
  for (const k of Object.keys(standard)) {
277
276
  const key = expandVariableKey(k);
278
277
  if (element.style.getPropertyValue(key).length > 0) {
279
- // console.log(`Unsetting via undefined theme ${key}`);
280
278
  element.style.removeProperty(key);
281
279
  }
282
280
  }
@@ -284,27 +282,22 @@ export function applyTheme(element, theme) {
284
282
  for (const [k, v] of Object.entries(theme)) {
285
283
  const key = expandVariableKey(k);
286
284
  const value = stringToCssValue(v);
287
- // console.log(`Inspecting ${key}: ${value}`);
288
- // only set the variable if it deviates from the standard theme or the root theme (set
285
+ // Only set the variable if it deviates from the standard theme or the root theme (set
289
286
  // by setGlobalDefaultTheme).... but if theme is explicitly standard and not undefined,
290
287
  // then apply it anyway so that any global theme is overridden TODO normalize color
291
288
  // representation for comparison? TODO tests for this logic
292
289
  const standardValue = standard[k] || undefined;
293
290
  const rootValue = rootDocument.style.getPropertyValue(key) || undefined;
294
- const isDeviationFromRoot = (rootValue && value !== rootValue) || false;
295
- const isDeviationFromStandard = (standardValue && value !== standardValue) || false;
291
+ const isDeviationFromRoot = (rootValue && value !== rootValue) ?? false;
292
+ const isDeviationFromStandard = (standardValue && value !== standardValue) ?? false;
296
293
  if (
297
294
  theme !== undefined &&
298
295
  value !== undefined &&
299
296
  (isDeviationFromRoot || (!rootValue && isDeviationFromStandard))
300
297
  ) {
301
- // console.log(`Setting ${key} to ${value}`);
302
298
  element.style.setProperty(key, value);
303
- } else {
304
- if (element.style.getPropertyValue(key).length > 0) {
305
- // console.log(`Unsetting ${key}`);
306
- element.style.removeProperty(key);
307
- }
299
+ } else if (element.style.getPropertyValue(key).length > 0) {
300
+ element.style.removeProperty(key);
308
301
  }
309
302
  }
310
303
  }
@@ -314,12 +307,12 @@ export function applyTheme(element, theme) {
314
307
  * mode toggle.
315
308
  */
316
309
  export function setGlobalDefaultTheme(theme) {
317
- // wait for dom ready... better outside?
318
- if (typeof window !== 'undefined' && window.document) {
310
+ // Wait for dom ready... better outside?
311
+ if (window?.document) {
319
312
  applyTheme(getWindowDocument().documentElement, theme);
320
313
  }
321
314
  }
322
- // library exports
315
+ // Library exports
323
316
  export default {
324
317
  /**
325
318
  * A collection of default theme color schemes, matching those provided in the Tweakpane
package/dist/utils.d.ts CHANGED
@@ -8,7 +8,7 @@ export type SimplifyDeep<Type> = Type extends Theme
8
8
  ? Type
9
9
  : {
10
10
  [TypeKey in keyof Type]: SimplifyDeep<Type[TypeKey]>;
11
- };
11
+ };
12
12
  export type HasKey<U, V extends PropertyKey> = V extends keyof U ? U[V] : unknown;
13
13
  import type { Bindable, BladeApi, BladeController, TpPluginBundle, View } from '@tweakpane/core';
14
14
  export type BindingObject = Bindable;
@@ -71,7 +71,10 @@ export declare function enforceReadonly(
71
71
  export declare function isRootPane(container: Container): boolean;
72
72
  export declare function clamp(value: number, min: number, max: number): number;
73
73
  export declare function getElementIndex(element: HTMLElement): number;
74
- export declare function removeKeys<T extends object>(object: T, ...keys: string[]): T;
74
+ export declare function removeKeys<T extends Record<string, unknown>>(
75
+ object: T,
76
+ ...keys: string[]
77
+ ): T;
75
78
  export declare function updateCollapsibility(
76
79
  isUserExpandableEnabled: boolean,
77
80
  element: HTMLElement,