svelte-tweakpane-ui 1.5.3 → 1.5.4

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 (103) hide show
  1. package/dist/control/Button.svelte +30 -30
  2. package/dist/control/Button.svelte.d.ts +18 -18
  3. package/dist/control/ButtonGrid.svelte +25 -25
  4. package/dist/control/ButtonGrid.svelte.d.ts +35 -35
  5. package/dist/control/Checkbox.svelte +2 -2
  6. package/dist/control/Checkbox.svelte.d.ts +23 -23
  7. package/dist/control/Color.svelte +34 -34
  8. package/dist/control/Color.svelte.d.ts +40 -40
  9. package/dist/control/CubicBezier.svelte +30 -30
  10. package/dist/control/CubicBezier.svelte.d.ts +47 -47
  11. package/dist/control/File.svelte +20 -20
  12. package/dist/control/File.svelte.d.ts +38 -38
  13. package/dist/control/Image.svelte +22 -22
  14. package/dist/control/Image.svelte.d.ts +31 -31
  15. package/dist/control/IntervalSlider.svelte +24 -24
  16. package/dist/control/IntervalSlider.svelte.d.ts +39 -39
  17. package/dist/control/List.svelte +35 -35
  18. package/dist/control/List.svelte.d.ts +31 -31
  19. package/dist/control/Point.svelte +31 -31
  20. package/dist/control/Point.svelte.d.ts +81 -81
  21. package/dist/control/RadioGrid.svelte +24 -24
  22. package/dist/control/RadioGrid.svelte.d.ts +40 -40
  23. package/dist/control/Ring.svelte +9 -9
  24. package/dist/control/Ring.svelte.d.ts +40 -40
  25. package/dist/control/RotationEuler.svelte +25 -25
  26. package/dist/control/RotationEuler.svelte.d.ts +53 -53
  27. package/dist/control/RotationQuaternion.svelte +24 -24
  28. package/dist/control/RotationQuaternion.svelte.d.ts +47 -47
  29. package/dist/control/Slider.svelte +9 -9
  30. package/dist/control/Slider.svelte.d.ts +32 -32
  31. package/dist/control/Stepper.svelte +16 -16
  32. package/dist/control/Stepper.svelte.d.ts +32 -32
  33. package/dist/control/Text.svelte +13 -13
  34. package/dist/control/Text.svelte.d.ts +26 -26
  35. package/dist/control/Textarea.svelte +34 -34
  36. package/dist/control/Textarea.svelte.d.ts +29 -29
  37. package/dist/control/Wheel.svelte +8 -8
  38. package/dist/control/Wheel.svelte.d.ts +32 -32
  39. package/dist/core/Binding.svelte +60 -60
  40. package/dist/core/Binding.svelte.d.ts +33 -33
  41. package/dist/core/Blade.svelte +30 -30
  42. package/dist/core/Blade.svelte.d.ts +21 -21
  43. package/dist/core/Folder.svelte +34 -34
  44. package/dist/core/Folder.svelte.d.ts +22 -22
  45. package/dist/core/Pane.svelte +17 -17
  46. package/dist/core/Pane.svelte.d.ts +56 -56
  47. package/dist/core/Separator.svelte +5 -5
  48. package/dist/core/Separator.svelte.d.ts +20 -20
  49. package/dist/core/TabGroup.svelte +29 -29
  50. package/dist/core/TabGroup.svelte.d.ts +18 -18
  51. package/dist/core/TabPage.svelte +36 -36
  52. package/dist/core/TabPage.svelte.d.ts +21 -21
  53. package/dist/extra/AutoObject.svelte +20 -20
  54. package/dist/extra/AutoObject.svelte.d.ts +22 -22
  55. package/dist/extra/AutoValue.svelte +3 -3
  56. package/dist/extra/AutoValue.svelte.d.ts +26 -26
  57. package/dist/extra/Element.svelte +10 -10
  58. package/dist/extra/Element.svelte.d.ts +26 -26
  59. package/dist/index.d.ts +48 -48
  60. package/dist/index.js +35 -35
  61. package/dist/internal/ClsPad.svelte +11 -11
  62. package/dist/internal/ClsPad.svelte.d.ts +17 -17
  63. package/dist/internal/GenericBinding.svelte +11 -11
  64. package/dist/internal/GenericBinding.svelte.d.ts +25 -25
  65. package/dist/internal/GenericBladeFolding.svelte +19 -19
  66. package/dist/internal/GenericBladeFolding.svelte.d.ts +20 -20
  67. package/dist/internal/GenericInput.svelte +7 -7
  68. package/dist/internal/GenericInput.svelte.d.ts +27 -27
  69. package/dist/internal/GenericInputFolding.svelte +21 -21
  70. package/dist/internal/GenericInputFolding.svelte.d.ts +32 -32
  71. package/dist/internal/GenericMonitor.svelte +10 -10
  72. package/dist/internal/GenericMonitor.svelte.d.ts +29 -29
  73. package/dist/internal/GenericPane.svelte +48 -48
  74. package/dist/internal/GenericPane.svelte.d.ts +22 -22
  75. package/dist/internal/GenericSlider.svelte +15 -15
  76. package/dist/internal/GenericSlider.svelte.d.ts +29 -29
  77. package/dist/internal/InternalMonitorBoolean.svelte +5 -5
  78. package/dist/internal/InternalMonitorBoolean.svelte.d.ts +31 -31
  79. package/dist/internal/InternalMonitorNumber.svelte +14 -14
  80. package/dist/internal/InternalMonitorNumber.svelte.d.ts +37 -37
  81. package/dist/internal/InternalMonitorString.svelte +9 -9
  82. package/dist/internal/InternalMonitorString.svelte.d.ts +32 -32
  83. package/dist/internal/InternalPaneDraggable.svelte +169 -173
  84. package/dist/internal/InternalPaneDraggable.svelte.d.ts +30 -30
  85. package/dist/internal/InternalPaneFixed.svelte +13 -13
  86. package/dist/internal/InternalPaneFixed.svelte.d.ts +23 -23
  87. package/dist/internal/InternalPaneInline.svelte +14 -14
  88. package/dist/internal/InternalPaneInline.svelte.d.ts +21 -21
  89. package/dist/monitor/FpsGraph.svelte +35 -35
  90. package/dist/monitor/FpsGraph.svelte.d.ts +50 -42
  91. package/dist/monitor/Monitor.svelte +4 -4
  92. package/dist/monitor/Monitor.svelte.d.ts +87 -88
  93. package/dist/monitor/Profiler.svelte +37 -37
  94. package/dist/monitor/Profiler.svelte.d.ts +78 -76
  95. package/dist/monitor/WaveformMonitor.svelte +12 -12
  96. package/dist/monitor/WaveformMonitor.svelte.d.ts +39 -39
  97. package/dist/theme.d.ts +61 -61
  98. package/dist/theme.js +49 -53
  99. package/dist/utils.d.ts +62 -66
  100. package/dist/utils.js +78 -78
  101. package/license.txt +1 -1
  102. package/package.json +100 -115
  103. package/readme.md +1 -1
package/dist/theme.d.ts CHANGED
@@ -1,89 +1,89 @@
1
- import type { Simplify } from './utils';
2
- import { type RgbaColorObject, type RgbColorObject } from '@tweakpane/core';
3
- export type ThemeColorValue = Simplify<RgbaColorObject | RgbColorObject | string>;
4
- export type Theme = CustomThemeKeys & ThemeKeys;
1
+ import type { Simplify } from './utils'
2
+ import { type RgbaColorObject, type RgbColorObject } from '@tweakpane/core'
3
+ export type ThemeColorValue = Simplify<RgbaColorObject | RgbColorObject | string>
4
+ export type Theme = CustomThemeKeys & ThemeKeys
5
5
  type ThemeKeys = {
6
- baseBackgroundColor?: ThemeColorValue;
7
- baseBorderRadius?: string;
8
- baseFontFamily?: string;
9
- baseShadowColor?: ThemeColorValue;
10
- bladeBorderRadius?: string;
11
- bladeHorizontalPadding?: string;
12
- bladeValueWidth?: string;
13
- buttonBackgroundColor?: ThemeColorValue;
14
- buttonBackgroundColorActive?: ThemeColorValue;
15
- buttonBackgroundColorFocus?: ThemeColorValue;
16
- buttonBackgroundColorHover?: ThemeColorValue;
17
- buttonForegroundColor?: ThemeColorValue;
18
- containerBackgroundColor?: ThemeColorValue;
19
- containerBackgroundColorActive?: ThemeColorValue;
20
- containerBackgroundColorFocus?: ThemeColorValue;
21
- containerBackgroundColorHover?: ThemeColorValue;
22
- containerForegroundColor?: ThemeColorValue;
23
- containerHorizontalPadding?: string;
24
- containerUnitSize?: string;
25
- containerUnitSpacing?: string;
26
- containerVerticalPadding?: string;
27
- grooveForegroundColor?: ThemeColorValue;
28
- inputBackgroundColor?: ThemeColorValue;
29
- inputBackgroundColorActive?: ThemeColorValue;
30
- inputBackgroundColorFocus?: ThemeColorValue;
31
- inputBackgroundColorHover?: ThemeColorValue;
32
- inputForegroundColor?: ThemeColorValue;
33
- labelForegroundColor?: ThemeColorValue;
34
- monitorBackgroundColor?: ThemeColorValue;
35
- monitorForegroundColor?: ThemeColorValue;
36
- pluginImageDraggingColor?: ThemeColorValue;
37
- };
38
- type CustomThemeKeys = Record<string, ThemeColorValue>;
39
- export declare const keys: Record<string, string>;
6
+ baseBackgroundColor?: ThemeColorValue
7
+ baseBorderRadius?: string
8
+ baseFontFamily?: string
9
+ baseShadowColor?: ThemeColorValue
10
+ bladeBorderRadius?: string
11
+ bladeHorizontalPadding?: string
12
+ bladeValueWidth?: string
13
+ buttonBackgroundColor?: ThemeColorValue
14
+ buttonBackgroundColorActive?: ThemeColorValue
15
+ buttonBackgroundColorFocus?: ThemeColorValue
16
+ buttonBackgroundColorHover?: ThemeColorValue
17
+ buttonForegroundColor?: ThemeColorValue
18
+ containerBackgroundColor?: ThemeColorValue
19
+ containerBackgroundColorActive?: ThemeColorValue
20
+ containerBackgroundColorFocus?: ThemeColorValue
21
+ containerBackgroundColorHover?: ThemeColorValue
22
+ containerForegroundColor?: ThemeColorValue
23
+ containerHorizontalPadding?: string
24
+ containerUnitSize?: string
25
+ containerUnitSpacing?: string
26
+ containerVerticalPadding?: string
27
+ grooveForegroundColor?: ThemeColorValue
28
+ inputBackgroundColor?: ThemeColorValue
29
+ inputBackgroundColorActive?: ThemeColorValue
30
+ inputBackgroundColorFocus?: ThemeColorValue
31
+ inputBackgroundColorHover?: ThemeColorValue
32
+ inputForegroundColor?: ThemeColorValue
33
+ labelForegroundColor?: ThemeColorValue
34
+ monitorBackgroundColor?: ThemeColorValue
35
+ monitorForegroundColor?: ThemeColorValue
36
+ pluginImageDraggingColor?: ThemeColorValue
37
+ }
38
+ type CustomThemeKeys = Record<string, ThemeColorValue>
39
+ export declare const keys: Record<string, string>
40
40
  export declare const presets: {
41
41
  /** Dark blue theme. */
42
- iceberg: Theme;
42
+ iceberg: Theme
43
43
  /** Extra dark theme. */
44
- jetblack: Theme;
44
+ jetblack: Theme
45
45
  /** Standard Tweakpane light theme. */
46
- light: Theme;
46
+ light: Theme
47
47
  /** Light theme with CRT vibes. */
48
- retro: Theme;
48
+ retro: Theme
49
49
  /** Standard Tweakpane dark theme. This is the default theme. */
50
- standard: Theme;
50
+ standard: Theme
51
51
  /** Dark translucent theme. */
52
- translucent: Theme;
52
+ translucent: Theme
53
53
  /** Red theme. */
54
- vivid: Theme;
55
- };
54
+ vivid: Theme
55
+ }
56
56
  /**
57
57
  * Used during SSR to calculate metrics Returns CSS string.
58
58
  */
59
- export declare function getValueOrFallback(theme: Theme | undefined, key: keyof ThemeKeys): string;
60
- export declare function applyTheme(element: HTMLElement, theme: Theme | undefined): void;
59
+ export declare function getValueOrFallback(theme: Theme | undefined, key: keyof ThemeKeys): string
60
+ export declare function applyTheme(element: HTMLElement, theme: Theme | undefined): void
61
61
  /**
62
62
  * Sets a default theme for all Tweakpane components on the page. Useful if you have a light / dark
63
63
  * mode toggle.
64
64
  */
65
- export declare function setGlobalDefaultTheme(theme: Theme | undefined): void;
65
+ export declare function setGlobalDefaultTheme(theme: Theme | undefined): void
66
66
  declare const _default: {
67
67
  /**
68
68
  * A collection of default theme color schemes, matching those provided in the Tweakpane
69
69
  * [Panebuilder presets](https://tweakpane.github.io/docs/theming/#builder).
70
- * */
70
+ */
71
71
  presets: {
72
72
  /** Dark blue theme. */
73
- iceberg: Theme;
73
+ iceberg: Theme
74
74
  /** Extra dark theme. */
75
- jetblack: Theme;
75
+ jetblack: Theme
76
76
  /** Standard Tweakpane light theme. */
77
- light: Theme;
77
+ light: Theme
78
78
  /** Light theme with CRT vibes. */
79
- retro: Theme;
79
+ retro: Theme
80
80
  /** Standard Tweakpane dark theme. This is the default theme. */
81
- standard: Theme;
81
+ standard: Theme
82
82
  /** Dark translucent theme. */
83
- translucent: Theme;
83
+ translucent: Theme
84
84
  /** Red theme. */
85
- vivid: Theme;
86
- };
87
- setGlobalDefaultTheme: typeof setGlobalDefaultTheme;
88
- };
89
- export default _default;
85
+ vivid: Theme
86
+ }
87
+ setGlobalDefaultTheme: typeof setGlobalDefaultTheme
88
+ }
89
+ export default _default
package/dist/theme.js CHANGED
@@ -1,4 +1,4 @@
1
- import { getWindowDocument, isRgbaColorObject, isRgbColorObject } from '@tweakpane/core';
1
+ import { getWindowDocument, isRgbaColorObject, isRgbColorObject } from '@tweakpane/core'
2
2
  // Standard Tweakpane themes from https://tweakpane.github.io/docs/theming/#builder Must be kept in
3
3
  // sync with TP...
4
4
  const standard = {
@@ -32,14 +32,15 @@ const standard = {
32
32
  labelForegroundColor: 'rgba(187, 188, 196, 0.7)',
33
33
  monitorBackgroundColor: 'rgba(0, 0, 0, 0.2)',
34
34
  monitorForegroundColor: 'rgba(187, 188, 196, 0.7)',
35
- pluginImageDraggingColor: 'hsla(230, 100%, 66%, 1)'
35
+ pluginImageDraggingColor: 'hsla(230, 100%, 66%, 1)',
36
36
  // PluginThumbnailListHeight: '400px', pluginThumbnailListThumbSize: '20px',
37
37
  // pluginThumbnailListWidth: '200px'
38
- };
38
+ }
39
+ // eslint-disable-next-line unicorn/no-array-reduce
39
40
  export const keys = Object.keys(standard).reduce((acc, key) => {
40
- acc[key] = key;
41
- return acc;
42
- }, {});
41
+ acc[key] = key
42
+ return acc
43
+ }, {})
43
44
  const light = {
44
45
  baseBackgroundColor: 'hsla(230, 5%, 90%, 1.00)',
45
46
  baseShadowColor: 'hsla(0, 0%, 0%, 0.10)',
@@ -61,8 +62,8 @@ const light = {
61
62
  inputForegroundColor: 'hsla(230, 10%, 30%, 1.00)',
62
63
  labelForegroundColor: 'hsla(230, 10%, 30%, 0.70)',
63
64
  monitorBackgroundColor: 'hsla(230, 15%, 30%, 0.10)',
64
- monitorForegroundColor: 'hsla(230, 10%, 30%, 0.50)'
65
- };
65
+ monitorForegroundColor: 'hsla(230, 10%, 30%, 0.50)',
66
+ }
66
67
  const iceberg = {
67
68
  baseBackgroundColor: 'hsla(230, 20%, 11%, 1.00)',
68
69
  baseShadowColor: 'hsla(0, 0%, 0%, 0.20)',
@@ -84,8 +85,8 @@ const iceberg = {
84
85
  inputForegroundColor: 'hsla(230, 10%, 80%, 1.00)',
85
86
  labelForegroundColor: 'hsla(230, 12%, 48%, 1.00)',
86
87
  monitorBackgroundColor: 'hsla(230, 20%, 8%, 1.00)',
87
- monitorForegroundColor: 'hsla(230, 12%, 48%, 1.00)'
88
- };
88
+ monitorForegroundColor: 'hsla(230, 12%, 48%, 1.00)',
89
+ }
89
90
  const jetblack = {
90
91
  baseBackgroundColor: 'hsla(0, 0%, 0%, 1.00)',
91
92
  baseShadowColor: 'hsla(0, 0%, 0%, 0.2)',
@@ -107,8 +108,8 @@ const jetblack = {
107
108
  inputForegroundColor: 'hsla(0, 0%, 70%, 1.00)',
108
109
  labelForegroundColor: 'hsla(0, 0%, 50%, 1.00)',
109
110
  monitorBackgroundColor: 'hsla(0, 0%, 8%, 1.00)',
110
- monitorForegroundColor: 'hsla(0, 0%, 48%, 1.00)'
111
- };
111
+ monitorForegroundColor: 'hsla(0, 0%, 48%, 1.00)',
112
+ }
112
113
  const retro = {
113
114
  baseBackgroundColor: 'hsla(40, 3%, 90%, 1.00)',
114
115
  baseShadowColor: 'hsla(0, 0%, 0%, 0.30)',
@@ -130,8 +131,8 @@ const retro = {
130
131
  inputForegroundColor: 'hsla(120, 40%, 60%, 1.00)',
131
132
  labelForegroundColor: 'hsla(40, 3%, 50%, 1.00)',
132
133
  monitorBackgroundColor: 'hsla(120, 3%, 20%, 1.00)',
133
- monitorForegroundColor: 'hsla(120, 40%, 60%, 0.80)'
134
- };
134
+ monitorForegroundColor: 'hsla(120, 40%, 60%, 0.80)',
135
+ }
135
136
  const translucent = {
136
137
  baseBackgroundColor: 'hsla(0, 0%, 10%, 0.80)',
137
138
  baseShadowColor: 'hsla(0, 0%, 0%, 0.20)',
@@ -153,8 +154,8 @@ const translucent = {
153
154
  inputForegroundColor: 'hsla(0, 0%, 100%, 0.50)',
154
155
  labelForegroundColor: 'hsla(0, 0%, 100%, 0.50)',
155
156
  monitorBackgroundColor: 'hsla(0, 0%, 0%, 0.30)',
156
- monitorForegroundColor: 'hsla(0, 0%, 100%, 0.30)'
157
- };
157
+ monitorForegroundColor: 'hsla(0, 0%, 100%, 0.30)',
158
+ }
158
159
  const vivid = {
159
160
  baseBackgroundColor: 'hsla(0, 80%, 40%, 1)',
160
161
  baseShadowColor: 'hsla(0, 0%, 0%, 0.2)',
@@ -176,8 +177,8 @@ const vivid = {
176
177
  inputForegroundColor: 'hsla(0, 0%, 100%, 0.9)',
177
178
  labelForegroundColor: 'hsla(0, 0%, 100%, 0.9)',
178
179
  monitorBackgroundColor: 'hsla(0, 0%, 0%, 0.5)',
179
- monitorForegroundColor: 'hsla(0, 0%, 100%, 0.5)'
180
- };
180
+ monitorForegroundColor: 'hsla(0, 0%, 100%, 0.5)',
181
+ }
181
182
  export const presets = {
182
183
  /** Dark blue theme. */
183
184
  iceberg,
@@ -192,8 +193,8 @@ export const presets = {
192
193
  /** Dark translucent theme. */
193
194
  translucent,
194
195
  /** Red theme. */
195
- vivid
196
- };
196
+ vivid,
197
+ }
197
198
  // More humane theme names... Note that the shorthand variables don't work
198
199
  const keyToCssVariableMap = new Map([
199
200
  // Tweakpane
@@ -228,76 +229,70 @@ const keyToCssVariableMap = new Map([
228
229
  ['monitorBackgroundColor', '--tp-monitor-background-color'],
229
230
  ['monitorForegroundColor', '--tp-monitor-foreground-color'],
230
231
  // Plugins
231
- ['pluginImageDraggingColor', '--tp-plugin-image-dragging-color']
232
+ ['pluginImageDraggingColor', '--tp-plugin-image-dragging-color'],
232
233
  // ['pluginThumbnailListHeight', '--tp-plugin-thumbnail-list-height'],
233
234
  // ['pluginThumbnailListThumbSize', '--tp-plugin-thumbnail-list-thumb-size'],
234
235
  // ['pluginThumbnailListWidth', '--tp-plugin-thumbnail-list-width']
235
- ]);
236
+ ])
236
237
  // Just do it dynamically instead of the map? function transformToCustomProperty(str: string):
237
238
  // string { return '--tp-' + str.replace(/([a-zA-Z])(?=[A-Z])/g, '$1-').toLowerCase();
238
239
  // }
239
240
  function stringToCssValue(v) {
240
241
  if (v === undefined) {
241
- return undefined;
242
+ return undefined
242
243
  }
243
244
  if (typeof v === 'string') {
244
- return v;
245
+ return v
245
246
  }
246
247
  if (isRgbaColorObject(v)) {
247
- return `rgba(${v.r}, ${v.g}, ${v.b}, ${v.a})`;
248
+ return `rgba(${v.r}, ${v.g}, ${v.b}, ${v.a})`
248
249
  }
249
250
  if (isRgbColorObject(v)) {
250
- return `rgb(${v.r}, ${v.g}, ${v.b})`;
251
+ return `rgb(${v.r}, ${v.g}, ${v.b})`
251
252
  }
252
253
  }
253
254
  function expandVariableKey(name) {
254
255
  // Pass explicit variables through
255
256
  if (name.startsWith('--tp-')) {
256
- return name;
257
+ return name
257
258
  }
258
- const variableName = keyToCssVariableMap.get(name);
259
+ const variableName = keyToCssVariableMap.get(name)
259
260
  if (variableName) {
260
- return variableName;
261
+ return variableName
261
262
  }
262
- throw new Error(`Unknown Tweakpane CSS theme map variable key: "${name}"`);
263
+ throw new Error(`Unknown Tweakpane CSS theme map variable key: "${name}"`)
263
264
  }
264
265
  /**
265
266
  * Used during SSR to calculate metrics Returns CSS string.
266
267
  */
267
268
  export function getValueOrFallback(theme, key) {
268
- return theme?.[key] === undefined
269
- ? stringToCssValue(standard[key])
270
- : stringToCssValue(theme[key]);
269
+ return theme?.[key] === undefined ? stringToCssValue(standard[key]) : stringToCssValue(theme[key])
271
270
  }
272
271
  export function applyTheme(element, theme) {
273
- const rootDocument = getWindowDocument().documentElement;
272
+ const rootDocument = getWindowDocument().documentElement
274
273
  if (theme === undefined) {
275
274
  for (const k of Object.keys(standard)) {
276
- const key = expandVariableKey(k);
275
+ const key = expandVariableKey(k)
277
276
  if (element.style.getPropertyValue(key).length > 0) {
278
- element.style.removeProperty(key);
277
+ element.style.removeProperty(key)
279
278
  }
280
279
  }
281
280
  } else {
282
281
  for (const [k, v] of Object.entries(theme)) {
283
- const key = expandVariableKey(k);
284
- const value = stringToCssValue(v);
282
+ const key = expandVariableKey(k)
283
+ const value = stringToCssValue(v)
285
284
  // Only set the variable if it deviates from the standard theme or the root theme (set
286
285
  // by setGlobalDefaultTheme).... but if theme is explicitly standard and not undefined,
287
286
  // then apply it anyway so that any global theme is overridden TODO normalize color
288
287
  // representation for comparison? TODO tests for this logic
289
- const standardValue = standard[k] || undefined;
290
- const rootValue = rootDocument.style.getPropertyValue(key) || undefined;
291
- const isDeviationFromRoot = (rootValue && value !== rootValue) ?? false;
292
- const isDeviationFromStandard = (standardValue && value !== standardValue) ?? false;
293
- if (
294
- theme !== undefined &&
295
- value !== undefined &&
296
- (isDeviationFromRoot || (!rootValue && isDeviationFromStandard))
297
- ) {
298
- element.style.setProperty(key, value);
288
+ const standardValue = standard[k] || undefined
289
+ const rootValue = rootDocument.style.getPropertyValue(key) || undefined
290
+ const isDeviationFromRoot = (rootValue && value !== rootValue) ?? false
291
+ const isDeviationFromStandard = (standardValue && value !== standardValue) ?? false
292
+ if (value !== undefined && (isDeviationFromRoot || (!rootValue && isDeviationFromStandard))) {
293
+ element.style.setProperty(key, value)
299
294
  } else if (element.style.getPropertyValue(key).length > 0) {
300
- element.style.removeProperty(key);
295
+ element.style.removeProperty(key)
301
296
  }
302
297
  }
303
298
  }
@@ -308,8 +303,9 @@ export function applyTheme(element, theme) {
308
303
  */
309
304
  export function setGlobalDefaultTheme(theme) {
310
305
  // Wait for dom ready... better outside?
306
+ // eslint-disable-next-line unicorn/prefer-global-this, ts/no-unnecessary-condition
311
307
  if (window?.document) {
312
- applyTheme(getWindowDocument().documentElement, theme);
308
+ applyTheme(getWindowDocument().documentElement, theme)
313
309
  }
314
310
  }
315
311
  // Library exports
@@ -317,7 +313,7 @@ export default {
317
313
  /**
318
314
  * A collection of default theme color schemes, matching those provided in the Tweakpane
319
315
  * [Panebuilder presets](https://tweakpane.github.io/docs/theming/#builder).
320
- * */
316
+ */
321
317
  presets,
322
- setGlobalDefaultTheme
323
- };
318
+ setGlobalDefaultTheme,
319
+ }
package/dist/utils.d.ts CHANGED
@@ -1,33 +1,33 @@
1
- import type { Theme } from './theme';
2
- import type { FolderApi, Pane, TabPageApi } from 'tweakpane';
3
- export type Container = FolderApi | Pane | TabPageApi;
4
- export type Simplify<T> = {
5
- [KeyType in keyof T]: T[KeyType];
6
- } & NonNullable<unknown>;
1
+ import type { Theme } from './theme'
2
+ import type { FolderApi, Pane, TabPageApi } from 'tweakpane'
3
+ export type Container = FolderApi | Pane | TabPageApi
4
+ export type Simplify<T> = NonNullable<unknown> & {
5
+ [KeyType in keyof T]: T[KeyType]
6
+ }
7
7
  export type SimplifyDeep<Type> = Type extends Theme
8
8
  ? Type
9
9
  : {
10
- [TypeKey in keyof Type]: SimplifyDeep<Type[TypeKey]>;
11
- };
12
- export type HasKey<U, V extends PropertyKey> = V extends keyof U ? U[V] : unknown;
13
- import type { Bindable, BladeApi, BladeController, TpPluginBundle, View } from '@tweakpane/core';
14
- export type BindingObject = Bindable;
15
- export type Plugin = TpPluginBundle;
10
+ [TypeKey in keyof Type]: SimplifyDeep<Type[TypeKey]>
11
+ }
12
+ export type HasKey<U, V extends PropertyKey> = V extends keyof U ? U[V] : unknown
13
+ import type { Bindable, BladeApi, BladeController, TpPluginBundle, View } from '@tweakpane/core'
14
+ export type BindingObject = Bindable
15
+ export type Plugin = TpPluginBundle
16
16
  /**
17
17
  * The base event type for value change notification events emitted by various controls.
18
18
  */
19
19
  export type ValueChangeEvent<V> = CustomEvent<{
20
- /**
21
- * A copy of the value at the time of the event.
22
- */
23
- value: V;
24
20
  /**
25
21
  * The origin of the event.
26
22
  * Changes resulting from the user's direct manipulation of the control will are marked as `internal`.
27
23
  * Changes resulting from manipulation of the bound value from _outside_ the component are marked as `external`.
28
24
  */
29
- origin: 'external' | 'internal';
30
- }>;
25
+ origin: 'external' | 'internal'
26
+ /**
27
+ * A copy of the value at the time of the event.
28
+ */
29
+ value: V
30
+ }>
31
31
  /**
32
32
  * Needed to conveniently use $$Events as the single source of truth for component events Performs
33
33
  * the transformation necessary (extracting detail types) to pass the $$Events type into
@@ -39,20 +39,16 @@ export type ValueChangeEvent<V> = CustomEvent<{
39
39
  *
40
40
  */
41
41
  export type UnwrapCustomEvents<T> = {
42
- [P in keyof T]: T[P] extends CustomEvent<infer detail> ? detail : never;
43
- };
42
+ [P in keyof T]: T[P] extends CustomEvent<infer detail> ? detail : never
43
+ }
44
44
  /**
45
45
  * For CLS SSR calculation
46
46
  */
47
- export declare function rowsForMonitor(
48
- buffer?: number | undefined,
49
- rows?: number | undefined,
50
- graph?: boolean | undefined
51
- ): number;
47
+ export declare function rowsForMonitor(buffer?: number, rows?: number, graph?: boolean): number
52
48
  /**
53
49
  * Fills an array of length `quantity` with a `value`
54
50
  */
55
- export declare function fillWith<T>(value: T, quantity: number): T[];
51
+ export declare function fillWith<T>(value: T, quantity: number): T[]
56
52
  /**
57
53
  * There's no way to enforce readonly properties in Svelte components, so this is a workaround. See
58
54
  * [general approach](https://github.com/sveltejs/svelte/issues/7712#issuecomment-1642470141) and
@@ -81,21 +77,21 @@ export declare function enforceReadonly(
81
77
  external: unknown,
82
78
  componentName?: string,
83
79
  propertyName?: string,
84
- allowAssignmentToUndefined?: boolean
85
- ): void;
86
- export declare function isRootPane(container: Container): boolean;
87
- export declare function clamp(value: number, min: number, max: number): number;
88
- export declare function getElementIndex(element: HTMLElement): number;
80
+ allowAssignmentToUndefined?: boolean,
81
+ ): void
82
+ export declare function isRootPane(container: Container): boolean
83
+ export declare function clamp(value: number, min: number, max: number): number
84
+ export declare function getElementIndex(element: HTMLElement): number
89
85
  export declare function removeKeys<T extends Record<string, unknown>>(
90
86
  object: T,
91
87
  ...keys: string[]
92
- ): T;
88
+ ): T
93
89
  export declare function updateCollapsibility(
94
90
  isUserExpandableEnabled: boolean,
95
- element: HTMLElement,
91
+ element: HTMLElement | undefined,
96
92
  titleBarClass: string,
97
- iconClass?: string
98
- ): void;
93
+ iconClass?: string,
94
+ ): void
99
95
  /**
100
96
  * Infers grid dimensions for a given number of items, respecting optional maximums for rows and
101
97
  * columns.
@@ -109,46 +105,46 @@ export declare function updateCollapsibility(
109
105
  export declare function getGridDimensions(
110
106
  itemCount: number,
111
107
  maxColumns?: number,
112
- maxRows?: number
108
+ maxRows?: number,
113
109
  ): {
114
- columns: number;
115
- rows: number;
116
- };
110
+ columns: number
111
+ rows: number
112
+ }
117
113
  export declare function tupleToObject<
118
114
  T extends string,
119
115
  O extends {
120
- [K in T]: number;
121
- }
122
- >(tuple: number[], keys: T[]): O;
116
+ [K in T]: number
117
+ },
118
+ >(tuple: number[], keys: T[]): O
123
119
  export declare function objectToTuple<T extends string, O extends Record<T, number>>(
124
120
  object: O,
125
- keys: [T]
126
- ): [number];
121
+ keys: [T],
122
+ ): [number]
127
123
  export declare function objectToTuple<T extends string, O extends Record<T, number>>(
128
124
  object: O,
129
- keys: [T, T]
130
- ): [number, number];
125
+ keys: [T, T],
126
+ ): [number, number]
131
127
  export declare function objectToTuple<T extends string, O extends Record<T, number>>(
132
128
  object: O,
133
- keys: [T, T, T]
134
- ): [number, number, number];
129
+ keys: [T, T, T],
130
+ ): [number, number, number]
135
131
  export declare function objectToTuple<T extends string, O extends Record<T, number>>(
136
132
  object: O,
137
- keys: [T, T, T, T]
138
- ): [number, number, number, number];
139
- export declare function pickerIsOpen(blade: BladeApi<BladeController<View>>): boolean;
133
+ keys: [T, T, T, T],
134
+ ): [number, number, number, number]
135
+ export declare function pickerIsOpen(blade: BladeApi<BladeController<View>>): boolean
140
136
  export declare function getSwatchButton(
141
- blade: BladeApi<BladeController<View>>
142
- ): HTMLButtonElement | undefined;
143
- import type { CubicBezierValue } from './control/CubicBezier.svelte';
144
- import type { RotationEulerUnit, RotationEulerValue } from './control/RotationEuler.svelte';
145
- import type { RotationQuaternionValue } from './control/RotationQuaternion.svelte';
146
- declare function quaternionToCssTransform(quaternion: RotationQuaternionValue): string;
137
+ blade: BladeApi<BladeController<View>>,
138
+ ): HTMLButtonElement | undefined
139
+ import type { CubicBezierValue } from './control/CubicBezier.svelte'
140
+ import type { RotationEulerUnit, RotationEulerValue } from './control/RotationEuler.svelte'
141
+ import type { RotationQuaternionValue } from './control/RotationQuaternion.svelte'
142
+ declare function quaternionToCssTransform(quaternion: RotationQuaternionValue): string
147
143
  declare function eulerToCssTransform(
148
144
  rotation: RotationEulerValue,
149
- units?: RotationEulerUnit
150
- ): string;
151
- declare function cubicBezierToEaseFunction(cubicBezier: CubicBezierValue): (t: number) => number;
145
+ units?: RotationEulerUnit,
146
+ ): string
147
+ declare function cubicBezierToEaseFunction(cubicBezier: CubicBezierValue): (t: number) => number
152
148
  declare const _default: {
153
149
  /**
154
150
  * Convenience function for creating easing functions ready for Svelte's tween and animation
@@ -156,20 +152,20 @@ declare const _default: {
156
152
  * @param cubicBezier - `CubicBezierValue`, probably from a `<CubicBezier>` component
157
153
  * @returns Tween function
158
154
  */
159
- cubicBezierToEaseFunction: typeof cubicBezierToEaseFunction;
155
+ cubicBezierToEaseFunction: typeof cubicBezierToEaseFunction
160
156
  /**
161
157
  * Convenience function for creating CSS-ready euler rotation transforms
162
158
  * @param rotation - `RotationEulerValue`, probably from a `<RotationEuler>` component
163
159
  * @param quaternion
164
- * @returns CSS rotateX/Y/Z string ready to be passed into a CSS transform
160
+ * @returns CSS rotate X/Y/Z string ready to be passed into a CSS transform
165
161
  */
166
- eulerToCssTransform: typeof eulerToCssTransform;
162
+ eulerToCssTransform: typeof eulerToCssTransform
167
163
  /**
168
164
  * Convenience function for creating CSS-ready quaternion rotation transforms
169
165
  * @param rotation - RotationQuaternionValue, probably from a <RotationQuaternionValue>
170
166
  * component
171
167
  * @returns CSS matrix3d string ready to be passed into a CSS transform
172
168
  */
173
- quaternionToCssTransform: typeof quaternionToCssTransform;
174
- };
175
- export default _default;
169
+ quaternionToCssTransform: typeof quaternionToCssTransform
170
+ }
171
+ export default _default