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.
- package/LICENSE +21 -0
- package/README.md +36 -0
- package/dist/control/ButtonGrid.svelte +49 -0
- package/dist/control/ButtonGrid.svelte.d.ts +190 -0
- package/dist/control/Checkbox.svelte +6 -0
- package/dist/control/Checkbox.svelte.d.ts +113 -0
- package/dist/control/Color.svelte +79 -0
- package/dist/control/Color.svelte.d.ts +177 -0
- package/dist/control/CubicBezier.svelte +74 -0
- package/dist/control/CubicBezier.svelte.d.ts +204 -0
- package/dist/control/Image.svelte +23 -0
- package/dist/control/Image.svelte.d.ts +177 -0
- package/dist/control/IntervalSlider.svelte +37 -0
- package/dist/control/IntervalSlider.svelte.d.ts +196 -0
- package/dist/control/List.svelte +69 -0
- package/dist/control/List.svelte.d.ts +122 -0
- package/dist/control/Point.svelte +100 -0
- package/dist/control/Point.svelte.d.ts +374 -0
- package/dist/control/RadioGrid.svelte +42 -0
- package/dist/control/RadioGrid.svelte.d.ts +231 -0
- package/dist/control/Ring.svelte +19 -0
- package/dist/control/Ring.svelte.d.ts +220 -0
- package/dist/control/RotationEuler.svelte +67 -0
- package/dist/control/RotationEuler.svelte.d.ts +273 -0
- package/dist/control/RotationQuaternion.svelte +65 -0
- package/dist/control/RotationQuaternion.svelte.d.ts +276 -0
- package/dist/control/Slider.svelte +6 -0
- package/dist/control/Slider.svelte.d.ts +165 -0
- package/dist/control/Text.svelte +25 -0
- package/dist/control/Text.svelte.d.ts +129 -0
- package/dist/control/Textarea.svelte +47 -0
- package/dist/control/Textarea.svelte.d.ts +149 -0
- package/dist/control/Wheel.svelte +15 -0
- package/dist/control/Wheel.svelte.d.ts +186 -0
- package/dist/core/Binding.svelte +68 -0
- package/dist/core/Binding.svelte.d.ts +116 -0
- package/dist/core/Blade.svelte +61 -0
- package/dist/core/Blade.svelte.d.ts +90 -0
- package/dist/core/Button.svelte +59 -0
- package/dist/core/Button.svelte.d.ts +65 -0
- package/dist/core/Folder.svelte +69 -0
- package/dist/core/Folder.svelte.d.ts +78 -0
- package/dist/core/Pane.svelte +51 -0
- package/dist/core/Pane.svelte.d.ts +500 -0
- package/dist/core/Separator.svelte +14 -0
- package/dist/core/Separator.svelte.d.ts +85 -0
- package/dist/core/TabGroup.svelte +64 -0
- package/dist/core/TabGroup.svelte.d.ts +72 -0
- package/dist/core/TabPage.svelte +85 -0
- package/dist/core/TabPage.svelte.d.ts +82 -0
- package/dist/extra/AutoObject.svelte +46 -0
- package/dist/extra/AutoObject.svelte.d.ts +108 -0
- package/dist/extra/AutoValue.svelte +11 -0
- package/dist/extra/AutoValue.svelte.d.ts +123 -0
- package/dist/extra/Element.svelte +53 -0
- package/dist/extra/Element.svelte.d.ts +170 -0
- package/dist/index.d.ts +94 -0
- package/dist/index.js +39 -0
- package/dist/internal/ClsPad.svelte +34 -0
- package/dist/internal/ClsPad.svelte.d.ts +95 -0
- package/dist/internal/GenericBinding.svelte +22 -0
- package/dist/internal/GenericBinding.svelte.d.ts +116 -0
- package/dist/internal/GenericBladeFolding.svelte +38 -0
- package/dist/internal/GenericBladeFolding.svelte.d.ts +95 -0
- package/dist/internal/GenericInput.svelte +19 -0
- package/dist/internal/GenericInput.svelte.d.ts +116 -0
- package/dist/internal/GenericInputFolding.svelte +40 -0
- package/dist/internal/GenericInputFolding.svelte.d.ts +140 -0
- package/dist/internal/GenericMonitor.svelte +24 -0
- package/dist/internal/GenericMonitor.svelte.d.ts +139 -0
- package/dist/internal/GenericPane.svelte +100 -0
- package/dist/internal/GenericPane.svelte.d.ts +84 -0
- package/dist/internal/GenericSlider.svelte +27 -0
- package/dist/internal/GenericSlider.svelte.d.ts +146 -0
- package/dist/internal/InternalMonitorBoolean.svelte +17 -0
- package/dist/internal/InternalMonitorBoolean.svelte.d.ts +154 -0
- package/dist/internal/InternalMonitorNumber.svelte +31 -0
- package/dist/internal/InternalMonitorNumber.svelte.d.ts +178 -0
- package/dist/internal/InternalMonitorString.svelte +23 -0
- package/dist/internal/InternalMonitorString.svelte.d.ts +162 -0
- package/dist/internal/InternalPaneDraggable.svelte +368 -0
- package/dist/internal/InternalPaneDraggable.svelte.d.ts +178 -0
- package/dist/internal/InternalPaneFixed.svelte +28 -0
- package/dist/internal/InternalPaneFixed.svelte.d.ts +119 -0
- package/dist/internal/InternalPaneInline.svelte +29 -0
- package/dist/internal/InternalPaneInline.svelte.d.ts +106 -0
- package/dist/monitor/FpsGraph.svelte +86 -0
- package/dist/monitor/FpsGraph.svelte.d.ts +230 -0
- package/dist/monitor/Monitor.svelte +14 -0
- package/dist/monitor/Monitor.svelte.d.ts +526 -0
- package/dist/monitor/Profiler.svelte +72 -0
- package/dist/monitor/Profiler.svelte.d.ts +265 -0
- package/dist/monitor/WaveformMonitor.svelte +26 -0
- package/dist/monitor/WaveformMonitor.svelte.d.ts +176 -0
- package/dist/theme.d.ts +91 -0
- package/dist/theme.js +332 -0
- package/dist/utils.d.ts +157 -0
- package/dist/utils.js +238 -0
- package/package.json +280 -0
package/dist/theme.js
ADDED
|
@@ -0,0 +1,332 @@
|
|
|
1
|
+
import { getWindowDocument, isRgbColorObject, isRgbaColorObject } from '@tweakpane/core';
|
|
2
|
+
// Standard Tweakpane themes from https://tweakpane.github.io/docs/theming/#builder Must be kept in
|
|
3
|
+
// sync with TP...
|
|
4
|
+
const standard = {
|
|
5
|
+
baseBackgroundColor: 'hsl(230, 7%, 17%)',
|
|
6
|
+
baseBorderRadius: '6px',
|
|
7
|
+
baseFontFamily: 'Roboto Mono, Source Code Pro, Menlo, Courier, monospace',
|
|
8
|
+
baseShadowColor: 'rgba(0, 0, 0, 0.2)',
|
|
9
|
+
bladeBorderRadius: '2px',
|
|
10
|
+
bladeHorizontalPadding: '4px',
|
|
11
|
+
bladeValueWidth: '160px',
|
|
12
|
+
buttonBackgroundColor: 'hsl(230, 7%, 70%)',
|
|
13
|
+
buttonBackgroundColorActive: '#d6d7db',
|
|
14
|
+
buttonBackgroundColorFocus: '#c8cad0',
|
|
15
|
+
buttonBackgroundColorHover: '#bbbcc4',
|
|
16
|
+
buttonForegroundColor: 'hsl(230, 7%, 17%)',
|
|
17
|
+
containerBackgroundColor: 'rgba(187, 188, 196, 0.1)',
|
|
18
|
+
containerBackgroundColorActive: 'rgba(187, 188, 196, 0.25)',
|
|
19
|
+
containerBackgroundColorFocus: 'rgba(187, 188, 196, 0.2)',
|
|
20
|
+
containerBackgroundColorHover: 'rgba(187, 188, 196, 0.15)',
|
|
21
|
+
containerForegroundColor: 'hsl(230, 7%, 75%)',
|
|
22
|
+
containerHorizontalPadding: '4px',
|
|
23
|
+
containerUnitSize: '20px',
|
|
24
|
+
containerUnitSpacing: '4px',
|
|
25
|
+
containerVerticalPadding: '4px',
|
|
26
|
+
grooveForegroundColor: 'rgba(187, 188, 196, 0.1)',
|
|
27
|
+
inputBackgroundColor: 'rgba(187, 188, 196, 0.1)',
|
|
28
|
+
inputBackgroundColorActive: 'rgba(187, 188, 196, 0.25)',
|
|
29
|
+
inputBackgroundColorFocus: 'rgba(187, 188, 196, 0.2)',
|
|
30
|
+
inputBackgroundColorHover: 'rgba(187, 188, 196, 0.15)',
|
|
31
|
+
inputForegroundColor: 'hsl(230, 7%, 75%)',
|
|
32
|
+
labelForegroundColor: 'rgba(187, 188, 196, 0.7)',
|
|
33
|
+
monitorBackgroundColor: 'rgba(0, 0, 0, 0.2)',
|
|
34
|
+
monitorForegroundColor: 'rgba(187, 188, 196, 0.7)',
|
|
35
|
+
pluginImageDraggingColor: 'hsla(230, 100%, 66%, 1)'
|
|
36
|
+
// pluginThumbnailListHeight: '400px', pluginThumbnailListThumbSize: '20px',
|
|
37
|
+
// pluginThumbnailListWidth: '200px'
|
|
38
|
+
};
|
|
39
|
+
export const keys = Object.keys(standard).reduce((acc, key) => {
|
|
40
|
+
acc[key] = key;
|
|
41
|
+
return acc;
|
|
42
|
+
}, {});
|
|
43
|
+
const light = {
|
|
44
|
+
baseBackgroundColor: 'hsla(230, 5%, 90%, 1.00)',
|
|
45
|
+
baseShadowColor: 'hsla(0, 0%, 0%, 0.10)',
|
|
46
|
+
buttonBackgroundColor: 'hsla(230, 7%, 75%, 1.00)',
|
|
47
|
+
buttonBackgroundColorActive: 'hsla(230, 7%, 60%, 1.00)',
|
|
48
|
+
buttonBackgroundColorFocus: 'hsla(230, 7%, 65%, 1.00)',
|
|
49
|
+
buttonBackgroundColorHover: 'hsla(230, 7%, 70%, 1.00)',
|
|
50
|
+
buttonForegroundColor: 'hsla(230, 10%, 30%, 1.00)',
|
|
51
|
+
containerBackgroundColor: 'hsla(230, 15%, 30%, 0.20)',
|
|
52
|
+
containerBackgroundColorActive: 'hsla(230, 15%, 30%, 0.32)',
|
|
53
|
+
containerBackgroundColorFocus: 'hsla(230, 15%, 30%, 0.28)',
|
|
54
|
+
containerBackgroundColorHover: 'hsla(230, 15%, 30%, 0.24)',
|
|
55
|
+
containerForegroundColor: 'hsla(230, 10%, 30%, 1.00)',
|
|
56
|
+
grooveForegroundColor: 'hsla(230, 15%, 30%, 0.10)',
|
|
57
|
+
inputBackgroundColor: 'hsla(230, 15%, 30%, 0.10)',
|
|
58
|
+
inputBackgroundColorActive: 'hsla(230, 15%, 30%, 0.22)',
|
|
59
|
+
inputBackgroundColorFocus: 'hsla(230, 15%, 30%, 0.18)',
|
|
60
|
+
inputBackgroundColorHover: 'hsla(230, 15%, 30%, 0.14)',
|
|
61
|
+
inputForegroundColor: 'hsla(230, 10%, 30%, 1.00)',
|
|
62
|
+
labelForegroundColor: 'hsla(230, 10%, 30%, 0.70)',
|
|
63
|
+
monitorBackgroundColor: 'hsla(230, 15%, 30%, 0.10)',
|
|
64
|
+
monitorForegroundColor: 'hsla(230, 10%, 30%, 0.50)'
|
|
65
|
+
};
|
|
66
|
+
const iceberg = {
|
|
67
|
+
baseBackgroundColor: 'hsla(230, 20%, 11%, 1.00)',
|
|
68
|
+
baseShadowColor: 'hsla(0, 0%, 0%, 0.20)',
|
|
69
|
+
buttonBackgroundColor: 'hsla(230, 10%, 80%, 1.00)',
|
|
70
|
+
buttonBackgroundColorActive: 'hsla(230, 10%, 95%, 1.00)',
|
|
71
|
+
buttonBackgroundColorFocus: 'hsla(230, 10%, 90%, 1.00)',
|
|
72
|
+
buttonBackgroundColorHover: 'hsla(230, 10%, 85%, 1.00)',
|
|
73
|
+
buttonForegroundColor: 'hsla(230, 20%, 11%, 1.00)',
|
|
74
|
+
containerBackgroundColor: 'hsla(230, 25%, 16%, 1.00)',
|
|
75
|
+
containerBackgroundColorActive: 'hsla(230, 25%, 31%, 1.00)',
|
|
76
|
+
containerBackgroundColorFocus: 'hsla(230, 25%, 26%, 1.00)',
|
|
77
|
+
containerBackgroundColorHover: 'hsla(230, 25%, 21%, 1.00)',
|
|
78
|
+
containerForegroundColor: 'hsla(230, 10%, 80%, 1.00)',
|
|
79
|
+
grooveForegroundColor: 'hsla(230, 20%, 8%, 1.00)',
|
|
80
|
+
inputBackgroundColor: 'hsla(230, 20%, 8%, 1.00)',
|
|
81
|
+
inputBackgroundColorActive: 'hsla(230, 28%, 23%, 1.00)',
|
|
82
|
+
inputBackgroundColorFocus: 'hsla(230, 28%, 18%, 1.00)',
|
|
83
|
+
inputBackgroundColorHover: 'hsla(230, 20%, 13%, 1.00)',
|
|
84
|
+
inputForegroundColor: 'hsla(230, 10%, 80%, 1.00)',
|
|
85
|
+
labelForegroundColor: 'hsla(230, 12%, 48%, 1.00)',
|
|
86
|
+
monitorBackgroundColor: 'hsla(230, 20%, 8%, 1.00)',
|
|
87
|
+
monitorForegroundColor: 'hsla(230, 12%, 48%, 1.00)'
|
|
88
|
+
};
|
|
89
|
+
const jetblack = {
|
|
90
|
+
baseBackgroundColor: 'hsla(0, 0%, 0%, 1.00)',
|
|
91
|
+
baseShadowColor: 'hsla(0, 0%, 0%, 0.2)',
|
|
92
|
+
buttonBackgroundColor: 'hsla(0, 0%, 70%, 1.00)',
|
|
93
|
+
buttonBackgroundColorActive: 'hsla(0, 0%, 85%, 1.00)',
|
|
94
|
+
buttonBackgroundColorFocus: 'hsla(0, 0%, 80%, 1.00)',
|
|
95
|
+
buttonBackgroundColorHover: 'hsla(0, 0%, 75%, 1.00)',
|
|
96
|
+
buttonForegroundColor: 'hsla(0, 0%, 0%, 1.00)',
|
|
97
|
+
containerBackgroundColor: 'hsla(0, 0%, 10%, 1.00)',
|
|
98
|
+
containerBackgroundColorActive: 'hsla(0, 0%, 25%, 1.00)',
|
|
99
|
+
containerBackgroundColorFocus: 'hsla(0, 0%, 20%, 1.00)',
|
|
100
|
+
containerBackgroundColorHover: 'hsla(0, 0%, 15%, 1.00)',
|
|
101
|
+
containerForegroundColor: 'hsla(0, 0%, 50%, 1.00)',
|
|
102
|
+
grooveForegroundColor: 'hsla(0, 0%, 10%, 1.00)',
|
|
103
|
+
inputBackgroundColor: 'hsla(0, 0%, 10%, 1.00)',
|
|
104
|
+
inputBackgroundColorActive: 'hsla(0, 0%, 25%, 1.00)',
|
|
105
|
+
inputBackgroundColorFocus: 'hsla(0, 0%, 20%, 1.00)',
|
|
106
|
+
inputBackgroundColorHover: 'hsla(0, 0%, 15%, 1.00)',
|
|
107
|
+
inputForegroundColor: 'hsla(0, 0%, 70%, 1.00)',
|
|
108
|
+
labelForegroundColor: 'hsla(0, 0%, 50%, 1.00)',
|
|
109
|
+
monitorBackgroundColor: 'hsla(0, 0%, 8%, 1.00)',
|
|
110
|
+
monitorForegroundColor: 'hsla(0, 0%, 48%, 1.00)'
|
|
111
|
+
};
|
|
112
|
+
const retro = {
|
|
113
|
+
baseBackgroundColor: 'hsla(40, 3%, 90%, 1.00)',
|
|
114
|
+
baseShadowColor: 'hsla(0, 0%, 0%, 0.30)',
|
|
115
|
+
buttonBackgroundColor: 'hsla(40, 3%, 70%, 1.00)',
|
|
116
|
+
buttonBackgroundColorActive: 'hsla(40, 3%, 55%, 1.00)',
|
|
117
|
+
buttonBackgroundColorFocus: 'hsla(40, 3%, 60%, 1.00)',
|
|
118
|
+
buttonBackgroundColorHover: 'hsla(40, 3%, 65%, 1.00)',
|
|
119
|
+
buttonForegroundColor: 'hsla(40, 3%, 20%, 1.00)',
|
|
120
|
+
containerBackgroundColor: 'hsla(40, 3%, 70%, 1.00)',
|
|
121
|
+
containerBackgroundColorActive: 'hsla(40, 3%, 55%, 1.00)',
|
|
122
|
+
containerBackgroundColorFocus: 'hsla(40, 3%, 60%, 1.00)',
|
|
123
|
+
containerBackgroundColorHover: 'hsla(40, 3%, 65%, 1.00)',
|
|
124
|
+
containerForegroundColor: 'hsla(40, 3%, 20%, 1.00)',
|
|
125
|
+
grooveForegroundColor: 'hsla(40, 3%, 40%, 1.00)',
|
|
126
|
+
inputBackgroundColor: 'hsla(120, 3%, 20%, 1.00)',
|
|
127
|
+
inputBackgroundColorActive: 'hsla(120, 3%, 35%, 1.00)',
|
|
128
|
+
inputBackgroundColorFocus: 'hsla(120, 3%, 30%, 1.00)',
|
|
129
|
+
inputBackgroundColorHover: 'hsla(120, 3%, 25%, 1.00)',
|
|
130
|
+
inputForegroundColor: 'hsla(120, 40%, 60%, 1.00)',
|
|
131
|
+
labelForegroundColor: 'hsla(40, 3%, 50%, 1.00)',
|
|
132
|
+
monitorBackgroundColor: 'hsla(120, 3%, 20%, 1.00)',
|
|
133
|
+
monitorForegroundColor: 'hsla(120, 40%, 60%, 0.80)'
|
|
134
|
+
};
|
|
135
|
+
const translucent = {
|
|
136
|
+
baseBackgroundColor: 'hsla(0, 0%, 10%, 0.80)',
|
|
137
|
+
baseShadowColor: 'hsla(0, 0%, 0%, 0.20)',
|
|
138
|
+
buttonBackgroundColor: 'hsla(0, 0%, 80%, 1.00)',
|
|
139
|
+
buttonBackgroundColorActive: 'hsla(0, 0%, 100%, 1.00)',
|
|
140
|
+
buttonBackgroundColorFocus: 'hsla(0, 0%, 95%, 1.00)',
|
|
141
|
+
buttonBackgroundColorHover: 'hsla(0, 0%, 85%, 1.00)',
|
|
142
|
+
buttonForegroundColor: 'hsla(0, 0%, 0%, 0.80)',
|
|
143
|
+
containerBackgroundColor: 'hsla(0, 0%, 0%, 0.30)',
|
|
144
|
+
containerBackgroundColorActive: 'hsla(0, 0%, 0%, 0.60)',
|
|
145
|
+
containerBackgroundColorFocus: 'hsla(0, 0%, 0%, 0.50)',
|
|
146
|
+
containerBackgroundColorHover: 'hsla(0, 0%, 0%, 0.40)',
|
|
147
|
+
containerForegroundColor: 'hsla(0, 0%, 100%, 0.50)',
|
|
148
|
+
grooveForegroundColor: 'hsla(0, 0%, 0%, 0.20)',
|
|
149
|
+
inputBackgroundColor: 'hsla(0, 0%, 0%, 0.30)',
|
|
150
|
+
inputBackgroundColorActive: 'hsla(0, 0%, 0%, 0.60)',
|
|
151
|
+
inputBackgroundColorFocus: 'hsla(0, 0%, 0%, 0.50)',
|
|
152
|
+
inputBackgroundColorHover: 'hsla(0, 0%, 0%, 0.40)',
|
|
153
|
+
inputForegroundColor: 'hsla(0, 0%, 100%, 0.50)',
|
|
154
|
+
labelForegroundColor: 'hsla(0, 0%, 100%, 0.50)',
|
|
155
|
+
monitorBackgroundColor: 'hsla(0, 0%, 0%, 0.30)',
|
|
156
|
+
monitorForegroundColor: 'hsla(0, 0%, 100%, 0.30)'
|
|
157
|
+
};
|
|
158
|
+
const vivid = {
|
|
159
|
+
baseBackgroundColor: 'hsla(0, 80%, 40%, 1)',
|
|
160
|
+
baseShadowColor: 'hsla(0, 0%, 0%, 0.2)',
|
|
161
|
+
buttonBackgroundColor: 'hsla(0, 0%, 100%, 1)',
|
|
162
|
+
buttonBackgroundColorActive: 'hsla(0, 0%, 85%, 1)',
|
|
163
|
+
buttonBackgroundColorFocus: 'hsla(0, 0%, 90%, 1)',
|
|
164
|
+
buttonBackgroundColorHover: 'hsla(0, 0%, 95%, 1)',
|
|
165
|
+
buttonForegroundColor: 'hsla(230, 20%, 11%, 1)',
|
|
166
|
+
containerBackgroundColor: 'hsla(0, 0%, 0%, 0.2)',
|
|
167
|
+
containerBackgroundColorActive: 'hsla(0, 0%, 0%, 0.35)',
|
|
168
|
+
containerBackgroundColorFocus: 'hsla(0, 0%, 0%, 0.3)',
|
|
169
|
+
containerBackgroundColorHover: 'hsla(0, 0%, 0%, 0.25)',
|
|
170
|
+
containerForegroundColor: 'hsla(0, 0%, 100%, 0.9)',
|
|
171
|
+
grooveForegroundColor: 'hsla(0, 0%, 0%, 0.5)',
|
|
172
|
+
inputBackgroundColor: 'hsla(0, 0%, 0%, 0.5)',
|
|
173
|
+
inputBackgroundColorActive: 'hsla(0, 0%, 0%, 0.65)',
|
|
174
|
+
inputBackgroundColorFocus: 'hsla(0, 0%, 0%, 0.60)',
|
|
175
|
+
inputBackgroundColorHover: 'hsla(0, 0%, 0%, 0.55)',
|
|
176
|
+
inputForegroundColor: 'hsla(0, 0%, 100%, 0.9)',
|
|
177
|
+
labelForegroundColor: 'hsla(0, 0%, 100%, 0.9)',
|
|
178
|
+
monitorBackgroundColor: 'hsla(0, 0%, 0%, 0.5)',
|
|
179
|
+
monitorForegroundColor: 'hsla(0, 0%, 100%, 0.5)'
|
|
180
|
+
};
|
|
181
|
+
export const presets = {
|
|
182
|
+
/** Dark blue theme. */
|
|
183
|
+
iceberg,
|
|
184
|
+
/** Extra dark theme. */
|
|
185
|
+
jetblack,
|
|
186
|
+
/** Standard Tweakpane light theme. */
|
|
187
|
+
light,
|
|
188
|
+
/** Light theme with CRT vibes. */
|
|
189
|
+
retro,
|
|
190
|
+
/** Standard Tweakpane dark theme. This is the default theme. */
|
|
191
|
+
standard,
|
|
192
|
+
/** Dark translucent theme. */
|
|
193
|
+
translucent,
|
|
194
|
+
/** Red theme. */
|
|
195
|
+
vivid
|
|
196
|
+
};
|
|
197
|
+
// More humane theme names... Note that the shorthand variables don't work
|
|
198
|
+
const keyToCssVariableMap = new Map([
|
|
199
|
+
// Tweakpane
|
|
200
|
+
['baseBackgroundColor', '--tp-base-background-color'],
|
|
201
|
+
['baseBorderRadius', '--tp-base-border-radius'],
|
|
202
|
+
['baseFontFamily', '--tp-base-font-family'],
|
|
203
|
+
['baseShadowColor', '--tp-base-shadow-color'],
|
|
204
|
+
['bladeBorderRadius', '--tp-blade-border-radius'],
|
|
205
|
+
['bladeHorizontalPadding', '--tp-blade-horizontal-padding'],
|
|
206
|
+
['bladeValueWidth', '--tp-blade-value-width'],
|
|
207
|
+
['buttonBackgroundColor', '--tp-button-background-color'],
|
|
208
|
+
['buttonBackgroundColorActive', '--tp-button-background-color-active'],
|
|
209
|
+
['buttonBackgroundColorFocus', '--tp-button-background-color-focus'],
|
|
210
|
+
['buttonBackgroundColorHover', '--tp-button-background-color-hover'],
|
|
211
|
+
['buttonForegroundColor', '--tp-button-foreground-color'],
|
|
212
|
+
['containerBackgroundColor', '--tp-container-background-color'],
|
|
213
|
+
['containerBackgroundColorActive', '--tp-container-background-color-active'],
|
|
214
|
+
['containerBackgroundColorFocus', '--tp-container-background-color-focus'],
|
|
215
|
+
['containerBackgroundColorHover', '--tp-container-background-color-hover'],
|
|
216
|
+
['containerForegroundColor', '--tp-container-foreground-color'],
|
|
217
|
+
['containerHorizontalPadding', '--tp-container-horizontal-padding'],
|
|
218
|
+
['containerUnitSize', '--tp-container-unit-size'],
|
|
219
|
+
['containerUnitSpacing', '--tp-container-unit-spacing'],
|
|
220
|
+
['containerVerticalPadding', '--tp-container-vertical-padding'],
|
|
221
|
+
['grooveForegroundColor', '--tp-groove-foreground-color'],
|
|
222
|
+
['inputBackgroundColor', '--tp-input-background-color'],
|
|
223
|
+
['inputBackgroundColorActive', '--tp-input-background-color-active'],
|
|
224
|
+
['inputBackgroundColorFocus', '--tp-input-background-color-focus'],
|
|
225
|
+
['inputBackgroundColorHover', '--tp-input-background-color-hover'],
|
|
226
|
+
['inputForegroundColor', '--tp-input-foreground-color'],
|
|
227
|
+
['labelForegroundColor', '--tp-label-foreground-color'],
|
|
228
|
+
['monitorBackgroundColor', '--tp-monitor-background-color'],
|
|
229
|
+
['monitorForegroundColor', '--tp-monitor-foreground-color'],
|
|
230
|
+
// Plugins
|
|
231
|
+
['pluginImageDraggingColor', '--tp-plugin-image-dragging-color']
|
|
232
|
+
// ['pluginThumbnailListHeight', '--tp-plugin-thumbnail-list-height'],
|
|
233
|
+
// ['pluginThumbnailListThumbSize', '--tp-plugin-thumbnail-list-thumb-size'],
|
|
234
|
+
// ['pluginThumbnailListWidth', '--tp-plugin-thumbnail-list-width']
|
|
235
|
+
]);
|
|
236
|
+
// Just do it dynamically instead of the map? function transformToCustomProperty(str: string):
|
|
237
|
+
// string { return '--tp-' + str.replace(/([a-zA-Z])(?=[A-Z])/g, '$1-').toLowerCase();
|
|
238
|
+
// }
|
|
239
|
+
function stringToCssValue(v) {
|
|
240
|
+
if (v === undefined) {
|
|
241
|
+
return undefined;
|
|
242
|
+
} else if (typeof v === 'string') {
|
|
243
|
+
return v;
|
|
244
|
+
} else if (isRgbaColorObject(v)) {
|
|
245
|
+
return `rgba(${v.r}, ${v.g}, ${v.b}, ${v.a})`;
|
|
246
|
+
} else if (isRgbColorObject(v)) {
|
|
247
|
+
return `rgb(${v.r}, ${v.g}, ${v.b})`;
|
|
248
|
+
} else {
|
|
249
|
+
throw new Error(`Unknown CSS theme value object: ${v}`);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
function expandVariableKey(name) {
|
|
253
|
+
// pass explicit variables through
|
|
254
|
+
if (name.startsWith('--tp-')) {
|
|
255
|
+
return name;
|
|
256
|
+
} else {
|
|
257
|
+
const varName = keyToCssVariableMap.get(name);
|
|
258
|
+
if (varName) {
|
|
259
|
+
return varName;
|
|
260
|
+
} else {
|
|
261
|
+
throw new Error(`Unknown Tweakpane CSS theme map variable key: "${name}"`);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Used during SSR to calculate metrics Returns CSS string.
|
|
267
|
+
*/
|
|
268
|
+
export function getValueOrFallback(theme, key) {
|
|
269
|
+
if (theme === undefined || theme[key] === undefined) {
|
|
270
|
+
return stringToCssValue(standard[key]);
|
|
271
|
+
} else {
|
|
272
|
+
return stringToCssValue(theme[key]);
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
export function applyTheme(element, theme) {
|
|
276
|
+
const rootDoc = getWindowDocument().documentElement;
|
|
277
|
+
if (theme === undefined) {
|
|
278
|
+
Object.keys(standard).forEach((k) => {
|
|
279
|
+
const key = expandVariableKey(k);
|
|
280
|
+
if (element.style.getPropertyValue(key).length > 0) {
|
|
281
|
+
// console.log(`Unsetting via undefined theme ${key}`);
|
|
282
|
+
element.style.removeProperty(key);
|
|
283
|
+
}
|
|
284
|
+
});
|
|
285
|
+
} else {
|
|
286
|
+
Object.entries(theme).forEach(([k, v]) => {
|
|
287
|
+
const key = expandVariableKey(k);
|
|
288
|
+
const value = stringToCssValue(v);
|
|
289
|
+
// console.log(`Inspecting ${key}: ${value}`);
|
|
290
|
+
// only set the variable if it deviates from the standard theme or the root theme (set
|
|
291
|
+
// by setGlobalDefaultTheme).... but if theme is explicitly standard and not undefined,
|
|
292
|
+
// then apply it anyway so that any global theme is overridden TODO normalize color
|
|
293
|
+
// representation for comparison? TODO tests for this logic
|
|
294
|
+
const standardValue = standard[k] || undefined;
|
|
295
|
+
const rootValue = rootDoc.style.getPropertyValue(key) || undefined;
|
|
296
|
+
const isDeviationFromRoot = (rootValue && value !== rootValue) || false;
|
|
297
|
+
const isDeviationFromStandard = (standardValue && value !== standardValue) || false;
|
|
298
|
+
if (
|
|
299
|
+
theme !== undefined &&
|
|
300
|
+
value !== undefined &&
|
|
301
|
+
(isDeviationFromRoot || (!rootValue && isDeviationFromStandard))
|
|
302
|
+
) {
|
|
303
|
+
// console.log(`Setting ${key} to ${value}`);
|
|
304
|
+
element.style.setProperty(key, value);
|
|
305
|
+
} else {
|
|
306
|
+
if (element.style.getPropertyValue(key).length > 0) {
|
|
307
|
+
// console.log(`Unsetting ${key}`);
|
|
308
|
+
element.style.removeProperty(key);
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* Sets a default theme for all Tweakpane components on the page. Useful if you have a light / dark
|
|
316
|
+
* mode toggle.
|
|
317
|
+
*/
|
|
318
|
+
export function setGlobalDefaultTheme(theme) {
|
|
319
|
+
// wait for dom ready... better outside?
|
|
320
|
+
if (typeof window !== 'undefined' && window.document) {
|
|
321
|
+
applyTheme(getWindowDocument().documentElement, theme);
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
// library exports
|
|
325
|
+
export default {
|
|
326
|
+
/**
|
|
327
|
+
* A collection of default theme color schemes, matching those provided in the Tweakpane
|
|
328
|
+
* [Panebuilder presets](https://tweakpane.github.io/docs/theming/#builder).
|
|
329
|
+
* */
|
|
330
|
+
presets,
|
|
331
|
+
setGlobalDefaultTheme
|
|
332
|
+
};
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
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>;
|
|
7
|
+
export type SimplifyDeep<Type> = Type extends Theme
|
|
8
|
+
? Type
|
|
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;
|
|
16
|
+
/**
|
|
17
|
+
* Needed to conveniently use $$Events as the single source of truth for component events Performs
|
|
18
|
+
* the transformation necessary (extracting detail types) to pass the $$Events type into
|
|
19
|
+
* createEventDispatcher(). See
|
|
20
|
+
* [documentation](https://svelte.dev/docs/typescript#script-lang-ts-events).
|
|
21
|
+
*
|
|
22
|
+
* An alternative would be to use a custom dispatcher, like [Threlte
|
|
23
|
+
* does])https://github.com/threlte/threlte/blob/main/packages/core/src/lib/lib/createRawEventDispatcher.ts_.
|
|
24
|
+
*
|
|
25
|
+
*/
|
|
26
|
+
export type UnwrapCustomEvents<T> = {
|
|
27
|
+
[P in keyof T]: T[P] extends CustomEvent<infer detail> ? detail : never;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* For CLS SSR calculation
|
|
31
|
+
*/
|
|
32
|
+
export declare function rowsForMonitor(
|
|
33
|
+
buffer?: number | undefined,
|
|
34
|
+
rows?: number | undefined,
|
|
35
|
+
graph?: boolean | undefined
|
|
36
|
+
): number;
|
|
37
|
+
/**
|
|
38
|
+
* Fills an array of length `quantity` with a `value`
|
|
39
|
+
*/
|
|
40
|
+
export declare function fillWith<T>(value: T, quantity: number): T[];
|
|
41
|
+
/**
|
|
42
|
+
* There's no way to enforce readonly properties in Svelte components, so this is a workaround. See
|
|
43
|
+
* [general approach](https://github.com/sveltejs/svelte/issues/7712#issuecomment-1642470141) and
|
|
44
|
+
* [runtime error approach](https://github.com/sveltejs/svelte/issues/7712#issuecomment-1642817764)
|
|
45
|
+
*
|
|
46
|
+
* Generally:
|
|
47
|
+
* ```svelte
|
|
48
|
+
* <script>
|
|
49
|
+
* export let value = "foo"
|
|
50
|
+
* let _value;
|
|
51
|
+
* // if you want to set init value from outside
|
|
52
|
+
* // uncomment this line:
|
|
53
|
+
* // _value = value;
|
|
54
|
+
* $: value = _value;
|
|
55
|
+
* $: enforceReadonly(_value, value, "value");
|
|
56
|
+
* </script>
|
|
57
|
+
*
|
|
58
|
+
* <input bind:value={_value} />
|
|
59
|
+
*
|
|
60
|
+
* This is not perfect and there are some edge cases it doesn't catch because we have to
|
|
61
|
+
* allow assignment to undefined in some internal cases (via the `allowAssignmentToUndefined` flag).
|
|
62
|
+
*
|
|
63
|
+
*/
|
|
64
|
+
export declare function enforceReadonly(
|
|
65
|
+
internal: unknown,
|
|
66
|
+
external: unknown,
|
|
67
|
+
componentName?: string,
|
|
68
|
+
propName?: string,
|
|
69
|
+
allowAssignmentToUndefined?: boolean
|
|
70
|
+
): void;
|
|
71
|
+
export declare function isRootPane(container: Container): boolean;
|
|
72
|
+
export declare function clamp(value: number, min: number, max: number): number;
|
|
73
|
+
export declare function getElementIndex(element: HTMLElement): number;
|
|
74
|
+
export declare function removeKeys<T extends object>(obj: T, ...keys: string[]): T;
|
|
75
|
+
export declare function updateCollapsibility(
|
|
76
|
+
isUserExpandableEnabled: boolean,
|
|
77
|
+
element: HTMLElement,
|
|
78
|
+
titleBarClass: string,
|
|
79
|
+
iconClass?: string
|
|
80
|
+
): void;
|
|
81
|
+
/**
|
|
82
|
+
* Infers grid dimensions for a given number of items, respecting optional maximums for rows and
|
|
83
|
+
* columns.
|
|
84
|
+
*
|
|
85
|
+
* If no constraints are provided, it creates the most square grid possible.
|
|
86
|
+
*
|
|
87
|
+
* If a single constraint is provided, it lets the undefined axis grow / shrink as needed.
|
|
88
|
+
*
|
|
89
|
+
* If both constraints are provided, values may be clipped.
|
|
90
|
+
*/
|
|
91
|
+
export declare function getGridDimensions(
|
|
92
|
+
itemCount: number,
|
|
93
|
+
maxColumns?: number,
|
|
94
|
+
maxRows?: number
|
|
95
|
+
): {
|
|
96
|
+
columns: number;
|
|
97
|
+
rows: number;
|
|
98
|
+
};
|
|
99
|
+
export declare function tupleToObject<
|
|
100
|
+
T extends string,
|
|
101
|
+
O extends {
|
|
102
|
+
[K in T]: number;
|
|
103
|
+
}
|
|
104
|
+
>(tuple: number[], keys: T[]): O;
|
|
105
|
+
export declare function objectToTuple<T extends string, O extends Record<T, number>>(
|
|
106
|
+
obj: O,
|
|
107
|
+
keys: [T]
|
|
108
|
+
): [number];
|
|
109
|
+
export declare function objectToTuple<T extends string, O extends Record<T, number>>(
|
|
110
|
+
obj: O,
|
|
111
|
+
keys: [T, T]
|
|
112
|
+
): [number, number];
|
|
113
|
+
export declare function objectToTuple<T extends string, O extends Record<T, number>>(
|
|
114
|
+
obj: O,
|
|
115
|
+
keys: [T, T, T]
|
|
116
|
+
): [number, number, number];
|
|
117
|
+
export declare function objectToTuple<T extends string, O extends Record<T, number>>(
|
|
118
|
+
obj: O,
|
|
119
|
+
keys: [T, T, T, T]
|
|
120
|
+
): [number, number, number, number];
|
|
121
|
+
export declare function pickerIsOpen(blade: BladeApi<BladeController<View>>): boolean;
|
|
122
|
+
export declare function getSwatchButton(
|
|
123
|
+
blade: BladeApi<BladeController<View>>
|
|
124
|
+
): HTMLButtonElement | undefined;
|
|
125
|
+
import type { CubicBezierValue } from './control/CubicBezier.svelte';
|
|
126
|
+
import type { RotationEulerUnit, RotationEulerValue } from './control/RotationEuler.svelte';
|
|
127
|
+
import type { RotationQuaternionValue } from './control/RotationQuaternion.svelte';
|
|
128
|
+
declare function quaternionToCssTransform(quaternion: RotationQuaternionValue): string;
|
|
129
|
+
declare function eulerToCssTransform(
|
|
130
|
+
rotation: RotationEulerValue,
|
|
131
|
+
units?: RotationEulerUnit
|
|
132
|
+
): string;
|
|
133
|
+
declare function cubicBezierToEaseFunction(cubicBezier: CubicBezierValue): (t: number) => number;
|
|
134
|
+
declare const _default: {
|
|
135
|
+
/**
|
|
136
|
+
* Convenience function for creating easing functions ready for Svelte's tween and animation
|
|
137
|
+
* systems
|
|
138
|
+
* @param cubicBezier - `CubicBezierValue`, probably from a `<CubicBezier>` component
|
|
139
|
+
* @returns Tween function
|
|
140
|
+
*/
|
|
141
|
+
cubicBezierToEaseFunction: typeof cubicBezierToEaseFunction;
|
|
142
|
+
/**
|
|
143
|
+
* Convenience function for creating CSS-ready euler rotation transforms
|
|
144
|
+
* @param rotation - `RotationEulerValue`, probably from a `<RotationEuler>` component
|
|
145
|
+
* @param quaternion
|
|
146
|
+
* @returns CSS rotateX/Y/Z string ready to be passed into a CSS transform
|
|
147
|
+
*/
|
|
148
|
+
eulerToCssTransform: typeof eulerToCssTransform;
|
|
149
|
+
/**
|
|
150
|
+
* Convenience function for creating CSS-ready quaternion rotation transforms
|
|
151
|
+
* @param rotation - RotationQuaternionValue, probably from a <RotationQuaternionValue>
|
|
152
|
+
* component
|
|
153
|
+
* @returns CSS matrix3d string ready to be passed into a CSS transform
|
|
154
|
+
*/
|
|
155
|
+
quaternionToCssTransform: typeof quaternionToCssTransform;
|
|
156
|
+
};
|
|
157
|
+
export default _default;
|