dialkit 0.2.2 → 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/README.md +12 -0
- package/dist/index.cjs +474 -141
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +35 -5
- package/dist/index.d.ts +35 -5
- package/dist/index.js +446 -115
- package/dist/index.js.map +1 -1
- package/dist/solid/index.cjs +2569 -0
- package/dist/solid/index.cjs.map +1 -0
- package/dist/solid/index.d.cts +225 -0
- package/dist/solid/index.d.ts +225 -0
- package/dist/solid/index.js +2530 -0
- package/dist/solid/index.js.map +1 -0
- package/dist/styles.css +7 -1
- package/package.json +31 -9
|
@@ -0,0 +1,2569 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/solid/index.ts
|
|
21
|
+
var solid_exports = {};
|
|
22
|
+
__export(solid_exports, {
|
|
23
|
+
ButtonGroup: () => ButtonGroup,
|
|
24
|
+
ColorControl: () => ColorControl,
|
|
25
|
+
DialRoot: () => DialRoot,
|
|
26
|
+
DialStore: () => DialStore,
|
|
27
|
+
Folder: () => Folder,
|
|
28
|
+
PresetManager: () => PresetManager,
|
|
29
|
+
SelectControl: () => SelectControl,
|
|
30
|
+
Slider: () => Slider,
|
|
31
|
+
SpringControl: () => SpringControl,
|
|
32
|
+
SpringVisualization: () => SpringVisualization,
|
|
33
|
+
TextControl: () => TextControl,
|
|
34
|
+
Toggle: () => Toggle,
|
|
35
|
+
createDialKit: () => createDialKit
|
|
36
|
+
});
|
|
37
|
+
module.exports = __toCommonJS(solid_exports);
|
|
38
|
+
|
|
39
|
+
// src/solid/createDialKit.ts
|
|
40
|
+
var import_solid_js = require("solid-js");
|
|
41
|
+
|
|
42
|
+
// src/store/DialStore.ts
|
|
43
|
+
var EMPTY_VALUES = Object.freeze({});
|
|
44
|
+
var DialStoreClass = class {
|
|
45
|
+
constructor() {
|
|
46
|
+
this.panels = /* @__PURE__ */ new Map();
|
|
47
|
+
this.listeners = /* @__PURE__ */ new Map();
|
|
48
|
+
this.globalListeners = /* @__PURE__ */ new Set();
|
|
49
|
+
this.snapshots = /* @__PURE__ */ new Map();
|
|
50
|
+
this.actionListeners = /* @__PURE__ */ new Map();
|
|
51
|
+
this.presets = /* @__PURE__ */ new Map();
|
|
52
|
+
this.activePreset = /* @__PURE__ */ new Map();
|
|
53
|
+
this.baseValues = /* @__PURE__ */ new Map();
|
|
54
|
+
}
|
|
55
|
+
registerPanel(id, name, config) {
|
|
56
|
+
const controls = this.parseConfig(config, "");
|
|
57
|
+
const values = this.flattenValues(config, "");
|
|
58
|
+
this.initTransitionModes(config, "", values);
|
|
59
|
+
this.panels.set(id, { id, name, controls, values });
|
|
60
|
+
this.snapshots.set(id, { ...values });
|
|
61
|
+
this.baseValues.set(id, { ...values });
|
|
62
|
+
this.notifyGlobal();
|
|
63
|
+
}
|
|
64
|
+
updatePanel(id, name, config) {
|
|
65
|
+
const existing = this.panels.get(id);
|
|
66
|
+
if (!existing) {
|
|
67
|
+
this.registerPanel(id, name, config);
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
const controls = this.parseConfig(config, "");
|
|
71
|
+
const controlsByPath = this.mapControlsByPath(controls);
|
|
72
|
+
const defaultValues = this.flattenValues(config, "");
|
|
73
|
+
const nextValues = {};
|
|
74
|
+
for (const [path, defaultValue] of Object.entries(defaultValues)) {
|
|
75
|
+
nextValues[path] = this.normalizePreservedValue(
|
|
76
|
+
existing.values[path],
|
|
77
|
+
defaultValue,
|
|
78
|
+
controlsByPath.get(path)
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
this.initTransitionModes(config, "", nextValues);
|
|
82
|
+
for (const [path, mode] of Object.entries(existing.values)) {
|
|
83
|
+
if (!path.endsWith(".__mode")) {
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
const transitionPath = path.slice(0, -"__mode".length - 1);
|
|
87
|
+
const transitionControl = controlsByPath.get(transitionPath);
|
|
88
|
+
if (transitionControl?.type === "transition") {
|
|
89
|
+
nextValues[path] = mode;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
const nextPanel = { id, name, controls, values: nextValues };
|
|
93
|
+
this.panels.set(id, nextPanel);
|
|
94
|
+
this.snapshots.set(id, { ...nextValues });
|
|
95
|
+
const previousBaseValues = this.baseValues.get(id) ?? {};
|
|
96
|
+
const nextBaseValues = {};
|
|
97
|
+
for (const [path, defaultValue] of Object.entries(defaultValues)) {
|
|
98
|
+
nextBaseValues[path] = this.normalizePreservedValue(
|
|
99
|
+
previousBaseValues[path],
|
|
100
|
+
defaultValue,
|
|
101
|
+
controlsByPath.get(path)
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
for (const [path, value] of Object.entries(nextValues)) {
|
|
105
|
+
if (path.endsWith(".__mode")) {
|
|
106
|
+
nextBaseValues[path] = value;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
this.baseValues.set(id, nextBaseValues);
|
|
110
|
+
this.notify(id);
|
|
111
|
+
this.notifyGlobal();
|
|
112
|
+
}
|
|
113
|
+
unregisterPanel(id) {
|
|
114
|
+
this.panels.delete(id);
|
|
115
|
+
this.listeners.delete(id);
|
|
116
|
+
this.snapshots.delete(id);
|
|
117
|
+
this.actionListeners.delete(id);
|
|
118
|
+
this.baseValues.delete(id);
|
|
119
|
+
this.notifyGlobal();
|
|
120
|
+
}
|
|
121
|
+
updateValue(panelId, path, value) {
|
|
122
|
+
const panel = this.panels.get(panelId);
|
|
123
|
+
if (!panel) return;
|
|
124
|
+
panel.values[path] = value;
|
|
125
|
+
const activeId = this.activePreset.get(panelId);
|
|
126
|
+
if (activeId) {
|
|
127
|
+
const presets = this.presets.get(panelId) ?? [];
|
|
128
|
+
const preset = presets.find((p) => p.id === activeId);
|
|
129
|
+
if (preset) preset.values[path] = value;
|
|
130
|
+
} else {
|
|
131
|
+
const base = this.baseValues.get(panelId);
|
|
132
|
+
if (base) base[path] = value;
|
|
133
|
+
}
|
|
134
|
+
this.snapshots.set(panelId, { ...panel.values });
|
|
135
|
+
this.notify(panelId);
|
|
136
|
+
}
|
|
137
|
+
updateSpringMode(panelId, path, mode) {
|
|
138
|
+
this.updateTransitionMode(panelId, path, mode);
|
|
139
|
+
}
|
|
140
|
+
getSpringMode(panelId, path) {
|
|
141
|
+
const mode = this.getTransitionMode(panelId, path);
|
|
142
|
+
if (mode === "easing") return "simple";
|
|
143
|
+
return mode;
|
|
144
|
+
}
|
|
145
|
+
updateTransitionMode(panelId, path, mode) {
|
|
146
|
+
const panel = this.panels.get(panelId);
|
|
147
|
+
if (!panel) return;
|
|
148
|
+
panel.values[`${path}.__mode`] = mode;
|
|
149
|
+
this.snapshots.set(panelId, { ...panel.values });
|
|
150
|
+
this.notify(panelId);
|
|
151
|
+
}
|
|
152
|
+
getTransitionMode(panelId, path) {
|
|
153
|
+
const panel = this.panels.get(panelId);
|
|
154
|
+
if (!panel) return "simple";
|
|
155
|
+
return panel.values[`${path}.__mode`] || "simple";
|
|
156
|
+
}
|
|
157
|
+
getValue(panelId, path) {
|
|
158
|
+
const panel = this.panels.get(panelId);
|
|
159
|
+
return panel?.values[path];
|
|
160
|
+
}
|
|
161
|
+
getValues(panelId) {
|
|
162
|
+
return this.snapshots.get(panelId) ?? EMPTY_VALUES;
|
|
163
|
+
}
|
|
164
|
+
getPanels() {
|
|
165
|
+
return Array.from(this.panels.values());
|
|
166
|
+
}
|
|
167
|
+
getPanel(id) {
|
|
168
|
+
return this.panels.get(id);
|
|
169
|
+
}
|
|
170
|
+
subscribe(panelId, listener) {
|
|
171
|
+
if (!this.listeners.has(panelId)) {
|
|
172
|
+
this.listeners.set(panelId, /* @__PURE__ */ new Set());
|
|
173
|
+
}
|
|
174
|
+
this.listeners.get(panelId).add(listener);
|
|
175
|
+
return () => {
|
|
176
|
+
this.listeners.get(panelId)?.delete(listener);
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
subscribeGlobal(listener) {
|
|
180
|
+
this.globalListeners.add(listener);
|
|
181
|
+
return () => this.globalListeners.delete(listener);
|
|
182
|
+
}
|
|
183
|
+
subscribeActions(panelId, listener) {
|
|
184
|
+
if (!this.actionListeners.has(panelId)) {
|
|
185
|
+
this.actionListeners.set(panelId, /* @__PURE__ */ new Set());
|
|
186
|
+
}
|
|
187
|
+
this.actionListeners.get(panelId).add(listener);
|
|
188
|
+
return () => {
|
|
189
|
+
this.actionListeners.get(panelId)?.delete(listener);
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
triggerAction(panelId, path) {
|
|
193
|
+
this.actionListeners.get(panelId)?.forEach((fn) => fn(path));
|
|
194
|
+
}
|
|
195
|
+
savePreset(panelId, name) {
|
|
196
|
+
const panel = this.panels.get(panelId);
|
|
197
|
+
if (!panel) throw new Error(`Panel ${panelId} not found`);
|
|
198
|
+
const id = `preset-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;
|
|
199
|
+
const preset = {
|
|
200
|
+
id,
|
|
201
|
+
name,
|
|
202
|
+
values: { ...panel.values }
|
|
203
|
+
};
|
|
204
|
+
const existing = this.presets.get(panelId) ?? [];
|
|
205
|
+
this.presets.set(panelId, [...existing, preset]);
|
|
206
|
+
this.activePreset.set(panelId, id);
|
|
207
|
+
this.snapshots.set(panelId, { ...panel.values });
|
|
208
|
+
this.notify(panelId);
|
|
209
|
+
return id;
|
|
210
|
+
}
|
|
211
|
+
loadPreset(panelId, presetId) {
|
|
212
|
+
const panel = this.panels.get(panelId);
|
|
213
|
+
if (!panel) return;
|
|
214
|
+
const presets = this.presets.get(panelId) ?? [];
|
|
215
|
+
const preset = presets.find((p) => p.id === presetId);
|
|
216
|
+
if (!preset) return;
|
|
217
|
+
panel.values = { ...preset.values };
|
|
218
|
+
this.snapshots.set(panelId, { ...panel.values });
|
|
219
|
+
this.activePreset.set(panelId, presetId);
|
|
220
|
+
this.notify(panelId);
|
|
221
|
+
}
|
|
222
|
+
deletePreset(panelId, presetId) {
|
|
223
|
+
const presets = this.presets.get(panelId) ?? [];
|
|
224
|
+
this.presets.set(panelId, presets.filter((p) => p.id !== presetId));
|
|
225
|
+
if (this.activePreset.get(panelId) === presetId) {
|
|
226
|
+
this.activePreset.set(panelId, null);
|
|
227
|
+
}
|
|
228
|
+
const panel = this.panels.get(panelId);
|
|
229
|
+
if (panel) {
|
|
230
|
+
this.snapshots.set(panelId, { ...panel.values });
|
|
231
|
+
}
|
|
232
|
+
this.notify(panelId);
|
|
233
|
+
}
|
|
234
|
+
getPresets(panelId) {
|
|
235
|
+
return this.presets.get(panelId) ?? [];
|
|
236
|
+
}
|
|
237
|
+
getActivePresetId(panelId) {
|
|
238
|
+
return this.activePreset.get(panelId) ?? null;
|
|
239
|
+
}
|
|
240
|
+
clearActivePreset(panelId) {
|
|
241
|
+
const panel = this.panels.get(panelId);
|
|
242
|
+
const base = this.baseValues.get(panelId);
|
|
243
|
+
if (panel && base) {
|
|
244
|
+
panel.values = { ...base };
|
|
245
|
+
this.snapshots.set(panelId, { ...panel.values });
|
|
246
|
+
}
|
|
247
|
+
this.activePreset.set(panelId, null);
|
|
248
|
+
this.notify(panelId);
|
|
249
|
+
}
|
|
250
|
+
notify(panelId) {
|
|
251
|
+
this.listeners.get(panelId)?.forEach((fn) => fn());
|
|
252
|
+
}
|
|
253
|
+
notifyGlobal() {
|
|
254
|
+
this.globalListeners.forEach((fn) => fn());
|
|
255
|
+
}
|
|
256
|
+
initTransitionModes(config, prefix, values) {
|
|
257
|
+
for (const [key, value] of Object.entries(config)) {
|
|
258
|
+
if (key === "_collapsed") continue;
|
|
259
|
+
const path = prefix ? `${prefix}.${key}` : key;
|
|
260
|
+
if (this.isEasingConfig(value)) {
|
|
261
|
+
values[`${path}.__mode`] = "easing";
|
|
262
|
+
} else if (this.isSpringConfig(value)) {
|
|
263
|
+
const hasPhysics = value.stiffness !== void 0 || value.damping !== void 0 || value.mass !== void 0;
|
|
264
|
+
const hasTime = value.visualDuration !== void 0 || value.bounce !== void 0;
|
|
265
|
+
values[`${path}.__mode`] = hasPhysics && !hasTime ? "advanced" : "simple";
|
|
266
|
+
} else if (typeof value === "object" && value !== null && !Array.isArray(value) && !this.isActionConfig(value) && !this.isSelectConfig(value) && !this.isColorConfig(value) && !this.isTextConfig(value)) {
|
|
267
|
+
this.initTransitionModes(value, path, values);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
parseConfig(config, prefix) {
|
|
272
|
+
const controls = [];
|
|
273
|
+
for (const [key, value] of Object.entries(config)) {
|
|
274
|
+
if (key === "_collapsed") continue;
|
|
275
|
+
const path = prefix ? `${prefix}.${key}` : key;
|
|
276
|
+
const label = this.formatLabel(key);
|
|
277
|
+
if (Array.isArray(value) && value.length <= 4 && typeof value[0] === "number") {
|
|
278
|
+
controls.push({
|
|
279
|
+
type: "slider",
|
|
280
|
+
path,
|
|
281
|
+
label,
|
|
282
|
+
min: value[1],
|
|
283
|
+
max: value[2],
|
|
284
|
+
step: value[3] ?? this.inferStep(value[1], value[2])
|
|
285
|
+
});
|
|
286
|
+
} else if (typeof value === "number") {
|
|
287
|
+
const { min, max, step } = this.inferRange(value);
|
|
288
|
+
controls.push({ type: "slider", path, label, min, max, step });
|
|
289
|
+
} else if (typeof value === "boolean") {
|
|
290
|
+
controls.push({ type: "toggle", path, label });
|
|
291
|
+
} else if (this.isSpringConfig(value) || this.isEasingConfig(value)) {
|
|
292
|
+
controls.push({ type: "transition", path, label });
|
|
293
|
+
} else if (this.isActionConfig(value)) {
|
|
294
|
+
controls.push({ type: "action", path, label: value.label || label });
|
|
295
|
+
} else if (this.isSelectConfig(value)) {
|
|
296
|
+
controls.push({ type: "select", path, label, options: value.options });
|
|
297
|
+
} else if (this.isColorConfig(value)) {
|
|
298
|
+
controls.push({ type: "color", path, label });
|
|
299
|
+
} else if (this.isTextConfig(value)) {
|
|
300
|
+
controls.push({ type: "text", path, label, placeholder: value.placeholder });
|
|
301
|
+
} else if (typeof value === "string") {
|
|
302
|
+
if (this.isHexColor(value)) {
|
|
303
|
+
controls.push({ type: "color", path, label });
|
|
304
|
+
} else {
|
|
305
|
+
controls.push({ type: "text", path, label });
|
|
306
|
+
}
|
|
307
|
+
} else if (typeof value === "object" && value !== null) {
|
|
308
|
+
const folderConfig = value;
|
|
309
|
+
const defaultOpen = "_collapsed" in folderConfig ? !folderConfig._collapsed : true;
|
|
310
|
+
controls.push({
|
|
311
|
+
type: "folder",
|
|
312
|
+
path,
|
|
313
|
+
label,
|
|
314
|
+
defaultOpen,
|
|
315
|
+
children: this.parseConfig(folderConfig, path)
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
return controls;
|
|
320
|
+
}
|
|
321
|
+
flattenValues(config, prefix) {
|
|
322
|
+
const values = {};
|
|
323
|
+
for (const [key, value] of Object.entries(config)) {
|
|
324
|
+
if (key === "_collapsed") continue;
|
|
325
|
+
const path = prefix ? `${prefix}.${key}` : key;
|
|
326
|
+
if (Array.isArray(value) && value.length <= 4 && typeof value[0] === "number") {
|
|
327
|
+
values[path] = value[0];
|
|
328
|
+
} else if (typeof value === "number" || typeof value === "boolean" || typeof value === "string") {
|
|
329
|
+
values[path] = value;
|
|
330
|
+
} else if (this.isSpringConfig(value) || this.isEasingConfig(value)) {
|
|
331
|
+
values[path] = value;
|
|
332
|
+
} else if (this.isActionConfig(value)) {
|
|
333
|
+
values[path] = value;
|
|
334
|
+
} else if (this.isSelectConfig(value)) {
|
|
335
|
+
const firstOption = value.options[0];
|
|
336
|
+
const firstValue = typeof firstOption === "string" ? firstOption : firstOption.value;
|
|
337
|
+
values[path] = value.default ?? firstValue;
|
|
338
|
+
} else if (this.isColorConfig(value)) {
|
|
339
|
+
values[path] = value.default ?? "#000000";
|
|
340
|
+
} else if (this.isTextConfig(value)) {
|
|
341
|
+
values[path] = value.default ?? "";
|
|
342
|
+
} else if (typeof value === "object" && value !== null) {
|
|
343
|
+
Object.assign(values, this.flattenValues(value, path));
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
return values;
|
|
347
|
+
}
|
|
348
|
+
isSpringConfig(value) {
|
|
349
|
+
return typeof value === "object" && value !== null && "type" in value && value.type === "spring";
|
|
350
|
+
}
|
|
351
|
+
isEasingConfig(value) {
|
|
352
|
+
return typeof value === "object" && value !== null && "type" in value && value.type === "easing";
|
|
353
|
+
}
|
|
354
|
+
isActionConfig(value) {
|
|
355
|
+
return typeof value === "object" && value !== null && "type" in value && value.type === "action";
|
|
356
|
+
}
|
|
357
|
+
isSelectConfig(value) {
|
|
358
|
+
return typeof value === "object" && value !== null && "type" in value && value.type === "select" && "options" in value && Array.isArray(value.options);
|
|
359
|
+
}
|
|
360
|
+
isColorConfig(value) {
|
|
361
|
+
return typeof value === "object" && value !== null && "type" in value && value.type === "color";
|
|
362
|
+
}
|
|
363
|
+
isTextConfig(value) {
|
|
364
|
+
return typeof value === "object" && value !== null && "type" in value && value.type === "text";
|
|
365
|
+
}
|
|
366
|
+
isHexColor(value) {
|
|
367
|
+
return /^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})$/.test(value);
|
|
368
|
+
}
|
|
369
|
+
formatLabel(key) {
|
|
370
|
+
return key.replace(/([A-Z])/g, " $1").replace(/^./, (str) => str.toUpperCase()).trim();
|
|
371
|
+
}
|
|
372
|
+
inferRange(value) {
|
|
373
|
+
if (value >= 0 && value <= 1) {
|
|
374
|
+
return { min: 0, max: 1, step: 0.01 };
|
|
375
|
+
} else if (value >= 0 && value <= 10) {
|
|
376
|
+
return { min: 0, max: value * 3 || 10, step: 0.1 };
|
|
377
|
+
} else if (value >= 0 && value <= 100) {
|
|
378
|
+
return { min: 0, max: value * 3 || 100, step: 1 };
|
|
379
|
+
} else if (value >= 0) {
|
|
380
|
+
return { min: 0, max: value * 3 || 1e3, step: 10 };
|
|
381
|
+
} else {
|
|
382
|
+
return { min: value * 3, max: -value * 3, step: 1 };
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
inferStep(min, max) {
|
|
386
|
+
const range = max - min;
|
|
387
|
+
if (range <= 1) return 0.01;
|
|
388
|
+
if (range <= 10) return 0.1;
|
|
389
|
+
if (range <= 100) return 1;
|
|
390
|
+
return 10;
|
|
391
|
+
}
|
|
392
|
+
normalizePreservedValue(existingValue, defaultValue, control) {
|
|
393
|
+
if (existingValue === void 0 || !control) {
|
|
394
|
+
return defaultValue;
|
|
395
|
+
}
|
|
396
|
+
switch (control.type) {
|
|
397
|
+
case "slider": {
|
|
398
|
+
if (typeof existingValue !== "number" || typeof defaultValue !== "number") {
|
|
399
|
+
return defaultValue;
|
|
400
|
+
}
|
|
401
|
+
const min = control.min ?? Number.NEGATIVE_INFINITY;
|
|
402
|
+
const max = control.max ?? Number.POSITIVE_INFINITY;
|
|
403
|
+
const clamped = Math.min(max, Math.max(min, existingValue));
|
|
404
|
+
if (typeof control.step !== "number" || control.step <= 0) {
|
|
405
|
+
return clamped;
|
|
406
|
+
}
|
|
407
|
+
return this.roundToStep(clamped, min, max, control.step);
|
|
408
|
+
}
|
|
409
|
+
case "toggle":
|
|
410
|
+
return typeof existingValue === "boolean" ? existingValue : defaultValue;
|
|
411
|
+
case "select": {
|
|
412
|
+
if (typeof existingValue !== "string") {
|
|
413
|
+
return defaultValue;
|
|
414
|
+
}
|
|
415
|
+
const options = control.options ?? [];
|
|
416
|
+
const validValues = new Set(options.map((option) => typeof option === "string" ? option : option.value));
|
|
417
|
+
return validValues.has(existingValue) ? existingValue : defaultValue;
|
|
418
|
+
}
|
|
419
|
+
case "color":
|
|
420
|
+
case "text":
|
|
421
|
+
return typeof existingValue === "string" ? existingValue : defaultValue;
|
|
422
|
+
case "transition":
|
|
423
|
+
if (this.isSpringConfig(defaultValue)) {
|
|
424
|
+
return this.isSpringConfig(existingValue) ? existingValue : defaultValue;
|
|
425
|
+
}
|
|
426
|
+
if (this.isEasingConfig(defaultValue)) {
|
|
427
|
+
return this.isEasingConfig(existingValue) ? existingValue : defaultValue;
|
|
428
|
+
}
|
|
429
|
+
return defaultValue;
|
|
430
|
+
case "action":
|
|
431
|
+
return defaultValue;
|
|
432
|
+
default:
|
|
433
|
+
return defaultValue;
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
roundToStep(value, min, max, step) {
|
|
437
|
+
const snapped = min + Math.round((value - min) / step) * step;
|
|
438
|
+
const clamped = Math.min(max, Math.max(min, snapped));
|
|
439
|
+
const precision = this.stepPrecision(step);
|
|
440
|
+
return Number(clamped.toFixed(precision));
|
|
441
|
+
}
|
|
442
|
+
stepPrecision(step) {
|
|
443
|
+
const text = String(step);
|
|
444
|
+
const decimalIndex = text.indexOf(".");
|
|
445
|
+
return decimalIndex === -1 ? 0 : text.length - decimalIndex - 1;
|
|
446
|
+
}
|
|
447
|
+
mapControlsByPath(controls) {
|
|
448
|
+
const map = /* @__PURE__ */ new Map();
|
|
449
|
+
const visit = (nodes) => {
|
|
450
|
+
for (const node of nodes) {
|
|
451
|
+
if (node.type === "folder" && node.children) {
|
|
452
|
+
visit(node.children);
|
|
453
|
+
continue;
|
|
454
|
+
}
|
|
455
|
+
map.set(node.path, node);
|
|
456
|
+
}
|
|
457
|
+
};
|
|
458
|
+
visit(controls);
|
|
459
|
+
return map;
|
|
460
|
+
}
|
|
461
|
+
};
|
|
462
|
+
var DialStore = new DialStoreClass();
|
|
463
|
+
|
|
464
|
+
// src/solid/createDialKit.ts
|
|
465
|
+
function createDialKit(name, config, options) {
|
|
466
|
+
const id = (0, import_solid_js.createUniqueId)();
|
|
467
|
+
const panelId = `${name}-${id}`;
|
|
468
|
+
const [values, setValues] = (0, import_solid_js.createSignal)(
|
|
469
|
+
DialStore.getValues(panelId)
|
|
470
|
+
);
|
|
471
|
+
(0, import_solid_js.onMount)(() => {
|
|
472
|
+
DialStore.registerPanel(panelId, name, config);
|
|
473
|
+
setValues(DialStore.getValues(panelId));
|
|
474
|
+
const unsubValues = DialStore.subscribe(panelId, () => {
|
|
475
|
+
setValues(DialStore.getValues(panelId));
|
|
476
|
+
});
|
|
477
|
+
const unsubActions = options?.onAction ? DialStore.subscribeActions(panelId, options.onAction) : void 0;
|
|
478
|
+
(0, import_solid_js.onCleanup)(() => {
|
|
479
|
+
unsubValues();
|
|
480
|
+
unsubActions?.();
|
|
481
|
+
DialStore.unregisterPanel(panelId);
|
|
482
|
+
});
|
|
483
|
+
});
|
|
484
|
+
return (0, import_solid_js.createMemo)(() => buildResolvedValues(config, values(), ""));
|
|
485
|
+
}
|
|
486
|
+
function buildResolvedValues(config, flatValues, prefix) {
|
|
487
|
+
const result = {};
|
|
488
|
+
for (const [key, configValue] of Object.entries(config)) {
|
|
489
|
+
if (key === "_collapsed") continue;
|
|
490
|
+
const path = prefix ? `${prefix}.${key}` : key;
|
|
491
|
+
if (Array.isArray(configValue) && configValue.length <= 4 && typeof configValue[0] === "number") {
|
|
492
|
+
result[key] = flatValues[path] ?? configValue[0];
|
|
493
|
+
} else if (typeof configValue === "number" || typeof configValue === "boolean" || typeof configValue === "string") {
|
|
494
|
+
result[key] = flatValues[path] ?? configValue;
|
|
495
|
+
} else if (isSpringConfig(configValue)) {
|
|
496
|
+
result[key] = flatValues[path] ?? configValue;
|
|
497
|
+
} else if (isActionConfig(configValue)) {
|
|
498
|
+
result[key] = flatValues[path] ?? configValue;
|
|
499
|
+
} else if (isSelectConfig(configValue)) {
|
|
500
|
+
const defaultValue = configValue.default ?? getFirstOptionValue(configValue.options);
|
|
501
|
+
result[key] = flatValues[path] ?? defaultValue;
|
|
502
|
+
} else if (isColorConfig(configValue)) {
|
|
503
|
+
result[key] = flatValues[path] ?? configValue.default ?? "#000000";
|
|
504
|
+
} else if (isTextConfig(configValue)) {
|
|
505
|
+
result[key] = flatValues[path] ?? configValue.default ?? "";
|
|
506
|
+
} else if (typeof configValue === "object" && configValue !== null) {
|
|
507
|
+
result[key] = buildResolvedValues(configValue, flatValues, path);
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
return result;
|
|
511
|
+
}
|
|
512
|
+
function hasType(value, type) {
|
|
513
|
+
return typeof value === "object" && value !== null && "type" in value && value.type === type;
|
|
514
|
+
}
|
|
515
|
+
function isSpringConfig(value) {
|
|
516
|
+
return hasType(value, "spring");
|
|
517
|
+
}
|
|
518
|
+
function isActionConfig(value) {
|
|
519
|
+
return hasType(value, "action");
|
|
520
|
+
}
|
|
521
|
+
function isSelectConfig(value) {
|
|
522
|
+
return hasType(value, "select") && "options" in value && Array.isArray(value.options);
|
|
523
|
+
}
|
|
524
|
+
function isColorConfig(value) {
|
|
525
|
+
return hasType(value, "color");
|
|
526
|
+
}
|
|
527
|
+
function isTextConfig(value) {
|
|
528
|
+
return hasType(value, "text");
|
|
529
|
+
}
|
|
530
|
+
function getFirstOptionValue(options) {
|
|
531
|
+
const first = options[0];
|
|
532
|
+
return typeof first === "string" ? first : first.value;
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
// src/solid/components/DialRoot.tsx
|
|
536
|
+
var import_web78 = require("solid-js/web");
|
|
537
|
+
var import_web79 = require("solid-js/web");
|
|
538
|
+
var import_web80 = require("solid-js/web");
|
|
539
|
+
var import_web81 = require("solid-js/web");
|
|
540
|
+
var import_web82 = require("solid-js/web");
|
|
541
|
+
var import_web83 = require("solid-js/web");
|
|
542
|
+
var import_solid_js11 = require("solid-js");
|
|
543
|
+
var import_web84 = require("solid-js/web");
|
|
544
|
+
|
|
545
|
+
// src/solid/components/Panel.tsx
|
|
546
|
+
var import_web72 = require("solid-js/web");
|
|
547
|
+
var import_web73 = require("solid-js/web");
|
|
548
|
+
var import_web74 = require("solid-js/web");
|
|
549
|
+
var import_web75 = require("solid-js/web");
|
|
550
|
+
var import_web76 = require("solid-js/web");
|
|
551
|
+
var import_web77 = require("solid-js/web");
|
|
552
|
+
var import_solid_js10 = require("solid-js");
|
|
553
|
+
var import_motion6 = require("motion");
|
|
554
|
+
|
|
555
|
+
// src/solid/components/Folder.tsx
|
|
556
|
+
var import_web = require("solid-js/web");
|
|
557
|
+
var import_web2 = require("solid-js/web");
|
|
558
|
+
var import_web3 = require("solid-js/web");
|
|
559
|
+
var import_web4 = require("solid-js/web");
|
|
560
|
+
var import_web5 = require("solid-js/web");
|
|
561
|
+
var import_web6 = require("solid-js/web");
|
|
562
|
+
var import_web7 = require("solid-js/web");
|
|
563
|
+
var import_web8 = require("solid-js/web");
|
|
564
|
+
var import_web9 = require("solid-js/web");
|
|
565
|
+
var import_web10 = require("solid-js/web");
|
|
566
|
+
var import_solid_js2 = require("solid-js");
|
|
567
|
+
var import_motion = require("motion");
|
|
568
|
+
var _tmpl$ = /* @__PURE__ */ (0, import_web.template)(`<div class=dialkit-panel-toolbar>`);
|
|
569
|
+
var _tmpl$2 = /* @__PURE__ */ (0, import_web.template)(`<div class=dialkit-folder-content><div class=dialkit-folder-inner>`);
|
|
570
|
+
var _tmpl$3 = /* @__PURE__ */ (0, import_web.template)(`<div><div><div class=dialkit-folder-header-top>`);
|
|
571
|
+
var _tmpl$4 = /* @__PURE__ */ (0, import_web.template)(`<div class=dialkit-folder-title-row><span class="dialkit-folder-title dialkit-folder-title-root">`);
|
|
572
|
+
var _tmpl$5 = /* @__PURE__ */ (0, import_web.template)(`<div class=dialkit-folder-title-row><span class=dialkit-folder-title>`);
|
|
573
|
+
var _tmpl$6 = /* @__PURE__ */ (0, import_web.template)(`<svg class=dialkit-panel-icon viewBox="0 0 16 16"fill=none><path opacity=0.5 d="M6.84766 11.75C6.78583 11.9899 6.75 12.2408 6.75 12.5C6.75 12.7592 6.78583 13.0101 6.84766 13.25H2C1.58579 13.25 1.25 12.9142 1.25 12.5C1.25 12.0858 1.58579 11.75 2 11.75H6.84766ZM14 11.75C14.4142 11.75 14.75 12.0858 14.75 12.5C14.75 12.9142 14.4142 13.25 14 13.25H12.6523C12.7142 13.0101 12.75 12.7592 12.75 12.5C12.75 12.2408 12.7142 11.9899 12.6523 11.75H14ZM3.09766 7.25C3.03583 7.48994 3 7.74075 3 8C3 8.25925 3.03583 8.51006 3.09766 8.75H2C1.58579 8.75 1.25 8.41421 1.25 8C1.25 7.58579 1.58579 7.25 2 7.25H3.09766ZM14 7.25C14.4142 7.25 14.75 7.58579 14.75 8C14.75 8.41421 14.4142 8.75 14 8.75H8.90234C8.96417 8.51006 9 8.25925 9 8C9 7.74075 8.96417 7.48994 8.90234 7.25H14ZM7.59766 2.75C7.53583 2.98994 7.5 3.24075 7.5 3.5C7.5 3.75925 7.53583 4.01006 7.59766 4.25H2C1.58579 4.25 1.25 3.91421 1.25 3.5C1.25 3.08579 1.58579 2.75 2 2.75H7.59766ZM14 2.75C14.4142 2.75 14.75 3.08579 14.75 3.5C14.75 3.91421 14.4142 4.25 14 4.25H13.4023C13.4642 4.01006 13.5 3.75925 13.5 3.5C13.5 3.24075 13.4642 2.98994 13.4023 2.75H14Z"fill=currentColor></path><circle cx=6 cy=8 r=0.998596 fill=currentColor stroke=currentColor stroke-width=1.25></circle><circle cx=10.4999 cy=3.5 r=0.998657 fill=currentColor stroke=currentColor stroke-width=1.25></circle><circle cx=9.75015 cy=12.5 r=0.997986 fill=currentColor stroke=currentColor stroke-width=1.25>`);
|
|
574
|
+
var _tmpl$7 = /* @__PURE__ */ (0, import_web.template)(`<svg class=dialkit-folder-icon viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=2.5 stroke-linecap=round stroke-linejoin=round><path d="M6 9.5L12 15.5L18 9.5">`);
|
|
575
|
+
var _tmpl$8 = /* @__PURE__ */ (0, import_web.template)(`<div class=dialkit-panel-inner>`);
|
|
576
|
+
function Folder(props) {
|
|
577
|
+
const [isOpen, setIsOpen] = (0, import_solid_js2.createSignal)(props.defaultOpen ?? true);
|
|
578
|
+
const [isCollapsed, setIsCollapsed] = (0, import_solid_js2.createSignal)(!(props.defaultOpen ?? true));
|
|
579
|
+
const [contentHeight, setContentHeight] = (0, import_solid_js2.createSignal)(void 0);
|
|
580
|
+
const [contentMounted, setContentMounted] = (0, import_solid_js2.createSignal)(props.defaultOpen ?? true);
|
|
581
|
+
let skipFirstAnim = props.defaultOpen ?? true;
|
|
582
|
+
let sectionContentRef;
|
|
583
|
+
let sectionAnim = null;
|
|
584
|
+
let folderChevronRef;
|
|
585
|
+
let chevronAnim = null;
|
|
586
|
+
let chevronInitialized = false;
|
|
587
|
+
let panelTapAnim = null;
|
|
588
|
+
let contentRef;
|
|
589
|
+
(0, import_solid_js2.createEffect)(() => {
|
|
590
|
+
if (!props.isRoot || !isOpen()) return;
|
|
591
|
+
const el = contentRef;
|
|
592
|
+
if (!el) return;
|
|
593
|
+
const ro = new ResizeObserver(() => {
|
|
594
|
+
const h = el.offsetHeight;
|
|
595
|
+
setContentHeight((prev) => prev === h ? prev : h);
|
|
596
|
+
});
|
|
597
|
+
ro.observe(el);
|
|
598
|
+
(0, import_solid_js2.onCleanup)(() => ro.disconnect());
|
|
599
|
+
});
|
|
600
|
+
(0, import_solid_js2.createEffect)(() => {
|
|
601
|
+
if (props.isRoot || !folderChevronRef) return;
|
|
602
|
+
const open = isOpen();
|
|
603
|
+
chevronAnim?.stop();
|
|
604
|
+
if (!chevronInitialized) {
|
|
605
|
+
folderChevronRef.style.transform = `rotate(${open ? 0 : 180}deg)`;
|
|
606
|
+
chevronInitialized = true;
|
|
607
|
+
return;
|
|
608
|
+
}
|
|
609
|
+
chevronAnim = (0, import_motion.animate)(folderChevronRef, {
|
|
610
|
+
rotate: open ? 0 : 180
|
|
611
|
+
}, {
|
|
612
|
+
type: "spring",
|
|
613
|
+
visualDuration: 0.35,
|
|
614
|
+
bounce: 0.15
|
|
615
|
+
});
|
|
616
|
+
(0, import_solid_js2.onCleanup)(() => chevronAnim?.stop());
|
|
617
|
+
});
|
|
618
|
+
const handleToggle = () => {
|
|
619
|
+
const next = !isOpen();
|
|
620
|
+
setIsOpen(next);
|
|
621
|
+
if (next) {
|
|
622
|
+
setIsCollapsed(false);
|
|
623
|
+
if (!props.isRoot) {
|
|
624
|
+
sectionAnim?.stop();
|
|
625
|
+
sectionAnim = null;
|
|
626
|
+
if (sectionContentRef) {
|
|
627
|
+
sectionAnim = (0, import_motion.animate)(sectionContentRef, {
|
|
628
|
+
height: "auto",
|
|
629
|
+
opacity: 1
|
|
630
|
+
}, {
|
|
631
|
+
type: "spring",
|
|
632
|
+
visualDuration: 0.35,
|
|
633
|
+
bounce: 0.1,
|
|
634
|
+
onComplete: () => {
|
|
635
|
+
sectionAnim = null;
|
|
636
|
+
}
|
|
637
|
+
});
|
|
638
|
+
} else {
|
|
639
|
+
setContentMounted(true);
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
} else {
|
|
643
|
+
setIsCollapsed(true);
|
|
644
|
+
if (!props.isRoot) {
|
|
645
|
+
if (sectionContentRef) {
|
|
646
|
+
const currentHeight = sectionContentRef.getBoundingClientRect().height;
|
|
647
|
+
sectionContentRef.style.height = `${currentHeight}px`;
|
|
648
|
+
sectionAnim?.stop();
|
|
649
|
+
sectionAnim = (0, import_motion.animate)(sectionContentRef, {
|
|
650
|
+
height: 0,
|
|
651
|
+
opacity: 0
|
|
652
|
+
}, {
|
|
653
|
+
type: "spring",
|
|
654
|
+
visualDuration: 0.35,
|
|
655
|
+
bounce: 0.1,
|
|
656
|
+
onComplete: () => {
|
|
657
|
+
setContentMounted(false);
|
|
658
|
+
sectionAnim = null;
|
|
659
|
+
sectionContentRef = void 0;
|
|
660
|
+
}
|
|
661
|
+
});
|
|
662
|
+
} else {
|
|
663
|
+
setContentMounted(false);
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
props.onOpenChange?.(next);
|
|
668
|
+
};
|
|
669
|
+
const folderContent = () => (() => {
|
|
670
|
+
var _el$ = _tmpl$3(), _el$2 = _el$.firstChild, _el$3 = _el$2.firstChild;
|
|
671
|
+
(0, import_web10.use)((el) => {
|
|
672
|
+
if (props.isRoot) contentRef = el;
|
|
673
|
+
}, _el$);
|
|
674
|
+
_el$2.$$click = handleToggle;
|
|
675
|
+
(0, import_web8.insert)(_el$3, (() => {
|
|
676
|
+
var _c$ = (0, import_web9.memo)(() => !!props.isRoot);
|
|
677
|
+
return () => _c$() ? (0, import_web7.createComponent)(import_solid_js2.Show, {
|
|
678
|
+
get when() {
|
|
679
|
+
return isOpen();
|
|
680
|
+
},
|
|
681
|
+
get children() {
|
|
682
|
+
var _el$7 = _tmpl$4(), _el$8 = _el$7.firstChild;
|
|
683
|
+
(0, import_web8.insert)(_el$8, () => props.title);
|
|
684
|
+
return _el$7;
|
|
685
|
+
}
|
|
686
|
+
}) : (() => {
|
|
687
|
+
var _el$9 = _tmpl$5(), _el$0 = _el$9.firstChild;
|
|
688
|
+
(0, import_web8.insert)(_el$0, () => props.title);
|
|
689
|
+
return _el$9;
|
|
690
|
+
})();
|
|
691
|
+
})(), null);
|
|
692
|
+
(0, import_web8.insert)(_el$3, (() => {
|
|
693
|
+
var _c$2 = (0, import_web9.memo)(() => !!props.isRoot);
|
|
694
|
+
return () => _c$2() ? _tmpl$6() : (() => {
|
|
695
|
+
var _el$10 = _tmpl$7();
|
|
696
|
+
var _ref$ = folderChevronRef;
|
|
697
|
+
typeof _ref$ === "function" ? (0, import_web10.use)(_ref$, _el$10) : folderChevronRef = _el$10;
|
|
698
|
+
return _el$10;
|
|
699
|
+
})();
|
|
700
|
+
})(), null);
|
|
701
|
+
(0, import_web8.insert)(_el$2, (0, import_web7.createComponent)(import_solid_js2.Show, {
|
|
702
|
+
get when() {
|
|
703
|
+
return (0, import_web9.memo)(() => !!(props.isRoot && props.toolbar))() && isOpen();
|
|
704
|
+
},
|
|
705
|
+
get children() {
|
|
706
|
+
var _el$4 = _tmpl$();
|
|
707
|
+
_el$4.$$click = (e) => e.stopPropagation();
|
|
708
|
+
(0, import_web8.insert)(_el$4, () => props.toolbar);
|
|
709
|
+
return _el$4;
|
|
710
|
+
}
|
|
711
|
+
}), null);
|
|
712
|
+
(0, import_web8.insert)(_el$, (0, import_web7.createComponent)(import_solid_js2.Show, {
|
|
713
|
+
get when() {
|
|
714
|
+
return (0, import_web9.memo)(() => !!props.isRoot)() ? isOpen() : contentMounted();
|
|
715
|
+
},
|
|
716
|
+
get children() {
|
|
717
|
+
var _el$5 = _tmpl$2(), _el$6 = _el$5.firstChild;
|
|
718
|
+
(0, import_web10.use)((el) => {
|
|
719
|
+
if (props.isRoot) return;
|
|
720
|
+
sectionContentRef = el;
|
|
721
|
+
if (skipFirstAnim) {
|
|
722
|
+
skipFirstAnim = false;
|
|
723
|
+
return;
|
|
724
|
+
}
|
|
725
|
+
sectionAnim?.stop();
|
|
726
|
+
el.style.height = "0px";
|
|
727
|
+
el.style.opacity = "0";
|
|
728
|
+
sectionAnim = (0, import_motion.animate)(el, {
|
|
729
|
+
height: "auto",
|
|
730
|
+
opacity: 1
|
|
731
|
+
}, {
|
|
732
|
+
type: "spring",
|
|
733
|
+
visualDuration: 0.35,
|
|
734
|
+
bounce: 0.1,
|
|
735
|
+
onComplete: () => {
|
|
736
|
+
sectionAnim = null;
|
|
737
|
+
}
|
|
738
|
+
});
|
|
739
|
+
}, _el$5);
|
|
740
|
+
(0, import_web8.insert)(_el$6, () => props.children);
|
|
741
|
+
(0, import_web6.effect)((_$p) => (0, import_web5.style)(_el$5, !props.isRoot ? {
|
|
742
|
+
"clip-path": "inset(0 -20px)"
|
|
743
|
+
} : void 0, _$p));
|
|
744
|
+
return _el$5;
|
|
745
|
+
}
|
|
746
|
+
}), null);
|
|
747
|
+
(0, import_web6.effect)((_p$) => {
|
|
748
|
+
var _v$ = `dialkit-folder ${props.isRoot ? "dialkit-folder-root" : ""}`, _v$2 = `dialkit-folder-header ${props.isRoot ? "dialkit-panel-header" : ""}`;
|
|
749
|
+
_v$ !== _p$.e && (0, import_web4.className)(_el$, _p$.e = _v$);
|
|
750
|
+
_v$2 !== _p$.t && (0, import_web4.className)(_el$2, _p$.t = _v$2);
|
|
751
|
+
return _p$;
|
|
752
|
+
}, {
|
|
753
|
+
e: void 0,
|
|
754
|
+
t: void 0
|
|
755
|
+
});
|
|
756
|
+
return _el$;
|
|
757
|
+
})();
|
|
758
|
+
if (props.isRoot) {
|
|
759
|
+
let panelRef;
|
|
760
|
+
let rootPanelAnim = null;
|
|
761
|
+
let rootPanelInitialized = false;
|
|
762
|
+
let lastRootOpen = isOpen();
|
|
763
|
+
(0, import_solid_js2.createEffect)(() => {
|
|
764
|
+
if (!panelRef || isOpen()) return;
|
|
765
|
+
const handler = (e) => {
|
|
766
|
+
e.stopPropagation();
|
|
767
|
+
handleToggle();
|
|
768
|
+
};
|
|
769
|
+
panelRef.addEventListener("click", handler);
|
|
770
|
+
(0, import_solid_js2.onCleanup)(() => panelRef.removeEventListener("click", handler));
|
|
771
|
+
});
|
|
772
|
+
(0, import_solid_js2.createEffect)(() => {
|
|
773
|
+
if (!panelRef) return;
|
|
774
|
+
const open = isOpen();
|
|
775
|
+
const measuredOpenHeight = contentHeight() !== void 0 ? contentHeight() + 24 : panelRef.getBoundingClientRect().height;
|
|
776
|
+
const target = {
|
|
777
|
+
width: open ? 280 : 42,
|
|
778
|
+
height: open ? measuredOpenHeight : 42,
|
|
779
|
+
borderRadius: open ? 14 : 21,
|
|
780
|
+
boxShadow: open ? "0 8px 32px rgba(0, 0, 0, 0.5)" : "0 4px 16px rgba(0, 0, 0, 0.25)"
|
|
781
|
+
};
|
|
782
|
+
panelRef.style.cursor = open ? "" : "pointer";
|
|
783
|
+
panelRef.style.overflow = open ? "" : "hidden";
|
|
784
|
+
if (!rootPanelInitialized) {
|
|
785
|
+
rootPanelInitialized = true;
|
|
786
|
+
panelRef.style.width = `${target.width}px`;
|
|
787
|
+
panelRef.style.height = `${target.height}px`;
|
|
788
|
+
panelRef.style.borderRadius = `${target.borderRadius}px`;
|
|
789
|
+
panelRef.style.boxShadow = target.boxShadow;
|
|
790
|
+
lastRootOpen = open;
|
|
791
|
+
return;
|
|
792
|
+
}
|
|
793
|
+
if (open !== lastRootOpen) {
|
|
794
|
+
rootPanelAnim?.stop();
|
|
795
|
+
rootPanelAnim = (0, import_motion.animate)(panelRef, target, {
|
|
796
|
+
type: "spring",
|
|
797
|
+
visualDuration: 0.15,
|
|
798
|
+
bounce: 0.3,
|
|
799
|
+
onComplete: () => {
|
|
800
|
+
rootPanelAnim = null;
|
|
801
|
+
}
|
|
802
|
+
});
|
|
803
|
+
lastRootOpen = open;
|
|
804
|
+
return;
|
|
805
|
+
}
|
|
806
|
+
if (open) {
|
|
807
|
+
panelRef.style.height = `${target.height}px`;
|
|
808
|
+
}
|
|
809
|
+
});
|
|
810
|
+
(0, import_solid_js2.onCleanup)(() => {
|
|
811
|
+
rootPanelAnim?.stop();
|
|
812
|
+
panelTapAnim?.stop();
|
|
813
|
+
});
|
|
814
|
+
return (() => {
|
|
815
|
+
var _el$11 = _tmpl$8();
|
|
816
|
+
_el$11.addEventListener("pointerleave", () => {
|
|
817
|
+
if (isOpen()) return;
|
|
818
|
+
panelTapAnim?.stop();
|
|
819
|
+
panelTapAnim = (0, import_motion.animate)(panelRef, {
|
|
820
|
+
scale: 1
|
|
821
|
+
}, {
|
|
822
|
+
type: "spring",
|
|
823
|
+
visualDuration: 0.15,
|
|
824
|
+
bounce: 0.3
|
|
825
|
+
});
|
|
826
|
+
});
|
|
827
|
+
_el$11.addEventListener("pointercancel", () => {
|
|
828
|
+
if (isOpen()) return;
|
|
829
|
+
panelTapAnim?.stop();
|
|
830
|
+
panelTapAnim = (0, import_motion.animate)(panelRef, {
|
|
831
|
+
scale: 1
|
|
832
|
+
}, {
|
|
833
|
+
type: "spring",
|
|
834
|
+
visualDuration: 0.15,
|
|
835
|
+
bounce: 0.3
|
|
836
|
+
});
|
|
837
|
+
});
|
|
838
|
+
_el$11.$$pointerup = () => {
|
|
839
|
+
if (isOpen()) return;
|
|
840
|
+
panelTapAnim?.stop();
|
|
841
|
+
panelTapAnim = (0, import_motion.animate)(panelRef, {
|
|
842
|
+
scale: 1
|
|
843
|
+
}, {
|
|
844
|
+
type: "spring",
|
|
845
|
+
visualDuration: 0.15,
|
|
846
|
+
bounce: 0.3
|
|
847
|
+
});
|
|
848
|
+
};
|
|
849
|
+
_el$11.$$pointerdown = () => {
|
|
850
|
+
if (isOpen()) return;
|
|
851
|
+
document.activeElement?.blur?.();
|
|
852
|
+
panelTapAnim?.stop();
|
|
853
|
+
panelTapAnim = (0, import_motion.animate)(panelRef, {
|
|
854
|
+
scale: 0.9
|
|
855
|
+
}, {
|
|
856
|
+
type: "spring",
|
|
857
|
+
visualDuration: 0.15,
|
|
858
|
+
bounce: 0.3
|
|
859
|
+
});
|
|
860
|
+
};
|
|
861
|
+
var _ref$2 = panelRef;
|
|
862
|
+
typeof _ref$2 === "function" ? (0, import_web10.use)(_ref$2, _el$11) : panelRef = _el$11;
|
|
863
|
+
(0, import_web8.insert)(_el$11, folderContent);
|
|
864
|
+
(0, import_web6.effect)(() => (0, import_web3.setAttribute)(_el$11, "data-collapsed", String(isCollapsed())));
|
|
865
|
+
return _el$11;
|
|
866
|
+
})();
|
|
867
|
+
}
|
|
868
|
+
return folderContent();
|
|
869
|
+
}
|
|
870
|
+
(0, import_web2.delegateEvents)(["click", "pointerdown", "pointerup"]);
|
|
871
|
+
|
|
872
|
+
// src/solid/components/Slider.tsx
|
|
873
|
+
var import_web11 = require("solid-js/web");
|
|
874
|
+
var import_web12 = require("solid-js/web");
|
|
875
|
+
var import_web13 = require("solid-js/web");
|
|
876
|
+
var import_web14 = require("solid-js/web");
|
|
877
|
+
var import_web15 = require("solid-js/web");
|
|
878
|
+
var import_web16 = require("solid-js/web");
|
|
879
|
+
var import_web17 = require("solid-js/web");
|
|
880
|
+
var import_web18 = require("solid-js/web");
|
|
881
|
+
var import_solid_js3 = require("solid-js");
|
|
882
|
+
var import_motion2 = require("motion");
|
|
883
|
+
var _tmpl$9 = /* @__PURE__ */ (0, import_web11.template)(`<div class=dialkit-slider-hashmark>`);
|
|
884
|
+
var _tmpl$22 = /* @__PURE__ */ (0, import_web11.template)(`<div class=dialkit-slider-wrapper><div><div class=dialkit-slider-hashmarks></div><div class=dialkit-slider-fill style="transition:background 0.15s"></div><div class=dialkit-slider-handle style="transform:translateY(-50%) scaleX(0.25) scaleY(1);opacity:0;background:rgba(255, 255, 255, 0.9)"></div><span class=dialkit-slider-label>`);
|
|
885
|
+
var _tmpl$32 = /* @__PURE__ */ (0, import_web11.template)(`<input type=text class=dialkit-slider-input>`);
|
|
886
|
+
var _tmpl$42 = /* @__PURE__ */ (0, import_web11.template)(`<span>`);
|
|
887
|
+
var CLICK_THRESHOLD = 3;
|
|
888
|
+
var DEAD_ZONE = 32;
|
|
889
|
+
var MAX_CURSOR_RANGE = 200;
|
|
890
|
+
var MAX_STRETCH = 8;
|
|
891
|
+
function decimalsForStep(step) {
|
|
892
|
+
const s = step.toString();
|
|
893
|
+
const dot = s.indexOf(".");
|
|
894
|
+
return dot === -1 ? 0 : s.length - dot - 1;
|
|
895
|
+
}
|
|
896
|
+
function roundValue(val, step) {
|
|
897
|
+
const raw = Math.round(val / step) * step;
|
|
898
|
+
return parseFloat(raw.toFixed(decimalsForStep(step)));
|
|
899
|
+
}
|
|
900
|
+
function snapToDecile(rawValue, min, max) {
|
|
901
|
+
const normalized = (rawValue - min) / (max - min);
|
|
902
|
+
const nearest = Math.round(normalized * 10) / 10;
|
|
903
|
+
if (Math.abs(normalized - nearest) <= 0.03125) {
|
|
904
|
+
return min + nearest * (max - min);
|
|
905
|
+
}
|
|
906
|
+
return rawValue;
|
|
907
|
+
}
|
|
908
|
+
function Slider(props) {
|
|
909
|
+
const min = () => props.min ?? 0;
|
|
910
|
+
const max = () => props.max ?? 1;
|
|
911
|
+
const step = () => props.step ?? 0.01;
|
|
912
|
+
let wrapperRef;
|
|
913
|
+
let trackRef;
|
|
914
|
+
let fillRef;
|
|
915
|
+
let handleRef;
|
|
916
|
+
let labelRef;
|
|
917
|
+
let valueSpanRef;
|
|
918
|
+
let inputRef;
|
|
919
|
+
const [isInteracting, setIsInteracting] = (0, import_solid_js3.createSignal)(false);
|
|
920
|
+
const [isDragging, setIsDragging] = (0, import_solid_js3.createSignal)(false);
|
|
921
|
+
const [isHovered, setIsHovered] = (0, import_solid_js3.createSignal)(false);
|
|
922
|
+
const [isValueHovered, setIsValueHovered] = (0, import_solid_js3.createSignal)(false);
|
|
923
|
+
const [isValueEditable, setIsValueEditable] = (0, import_solid_js3.createSignal)(false);
|
|
924
|
+
const [showInput, setShowInput] = (0, import_solid_js3.createSignal)(false);
|
|
925
|
+
const [inputValue, setInputValue] = (0, import_solid_js3.createSignal)("");
|
|
926
|
+
const fillPercent = (0, import_motion2.motionValue)((props.value - min()) / (max() - min()) * 100);
|
|
927
|
+
const rubberStretchPx = (0, import_motion2.motionValue)(0);
|
|
928
|
+
const handleOpacityMv = (0, import_motion2.motionValue)(0);
|
|
929
|
+
const handleScaleXMv = (0, import_motion2.motionValue)(0.25);
|
|
930
|
+
const handleScaleYMv = (0, import_motion2.motionValue)(1);
|
|
931
|
+
const applyFillStyles = (pct) => {
|
|
932
|
+
if (fillRef) fillRef.style.width = `${pct}%`;
|
|
933
|
+
if (handleRef) handleRef.style.left = `max(5px, calc(${pct}% - 9px))`;
|
|
934
|
+
};
|
|
935
|
+
const applyRubberStyles = (stretch) => {
|
|
936
|
+
if (!trackRef) return;
|
|
937
|
+
trackRef.style.width = `calc(100% + ${Math.abs(stretch)}px)`;
|
|
938
|
+
trackRef.style.transform = `translateX(${stretch < 0 ? stretch : 0}px)`;
|
|
939
|
+
};
|
|
940
|
+
const applyHandleVisualStyles = () => {
|
|
941
|
+
if (!handleRef) return;
|
|
942
|
+
handleRef.style.opacity = String(handleOpacityMv.get());
|
|
943
|
+
handleRef.style.transform = `translateY(-50%) scaleX(${handleScaleXMv.get()}) scaleY(${handleScaleYMv.get()})`;
|
|
944
|
+
};
|
|
945
|
+
(0, import_solid_js3.createEffect)(() => {
|
|
946
|
+
if (!isInteracting() && !snapAnim) {
|
|
947
|
+
fillPercent.jump((props.value - min()) / (max() - min()) * 100);
|
|
948
|
+
}
|
|
949
|
+
});
|
|
950
|
+
const percentage = () => (props.value - min()) / (max() - min()) * 100;
|
|
951
|
+
const isActive = () => isInteracting() || isHovered();
|
|
952
|
+
let pointerDownPos = null;
|
|
953
|
+
let isClickFlag = true;
|
|
954
|
+
let wrapperRect = null;
|
|
955
|
+
let scaleVal = 1;
|
|
956
|
+
let hoverTimeout = null;
|
|
957
|
+
let snapAnim = null;
|
|
958
|
+
let rubberAnim = null;
|
|
959
|
+
let handleOpacityAnim = null;
|
|
960
|
+
let handleScaleXAnim = null;
|
|
961
|
+
let handleScaleYAnim = null;
|
|
962
|
+
const positionToValue = (clientX) => {
|
|
963
|
+
if (!wrapperRect) return props.value;
|
|
964
|
+
const screenX = clientX - wrapperRect.left;
|
|
965
|
+
const sceneX = screenX / scaleVal;
|
|
966
|
+
const nativeWidth = wrapperRef ? wrapperRef.offsetWidth : wrapperRect.width;
|
|
967
|
+
const percent = Math.max(0, Math.min(1, sceneX / nativeWidth));
|
|
968
|
+
const rawValue = min() + percent * (max() - min());
|
|
969
|
+
return Math.max(min(), Math.min(max(), rawValue));
|
|
970
|
+
};
|
|
971
|
+
const percentFromValue = (v) => (v - min()) / (max() - min()) * 100;
|
|
972
|
+
const computeRubberStretch = (clientX, sign) => {
|
|
973
|
+
if (!wrapperRect) return 0;
|
|
974
|
+
const distancePast = sign < 0 ? wrapperRect.left - clientX : clientX - wrapperRect.right;
|
|
975
|
+
const overflow = Math.max(0, distancePast - DEAD_ZONE);
|
|
976
|
+
return sign * MAX_STRETCH * Math.sqrt(Math.min(overflow / MAX_CURSOR_RANGE, 1));
|
|
977
|
+
};
|
|
978
|
+
const cancelInteraction = () => {
|
|
979
|
+
if (!isInteracting()) return;
|
|
980
|
+
setIsInteracting(false);
|
|
981
|
+
setIsDragging(false);
|
|
982
|
+
rubberStretchPx.jump(0);
|
|
983
|
+
pointerDownPos = null;
|
|
984
|
+
};
|
|
985
|
+
const handlePointerDown = (e) => {
|
|
986
|
+
if (showInput()) return;
|
|
987
|
+
e.preventDefault();
|
|
988
|
+
e.currentTarget.setPointerCapture(e.pointerId);
|
|
989
|
+
pointerDownPos = {
|
|
990
|
+
x: e.clientX,
|
|
991
|
+
y: e.clientY
|
|
992
|
+
};
|
|
993
|
+
isClickFlag = true;
|
|
994
|
+
setIsInteracting(true);
|
|
995
|
+
if (wrapperRef) {
|
|
996
|
+
wrapperRect = wrapperRef.getBoundingClientRect();
|
|
997
|
+
scaleVal = wrapperRect.width / wrapperRef.offsetWidth;
|
|
998
|
+
}
|
|
999
|
+
};
|
|
1000
|
+
const handlePointerMove = (e) => {
|
|
1001
|
+
if (!isInteracting() || !pointerDownPos) return;
|
|
1002
|
+
const dx = e.clientX - pointerDownPos.x;
|
|
1003
|
+
const dy = e.clientY - pointerDownPos.y;
|
|
1004
|
+
const distance = Math.sqrt(dx * dx + dy * dy);
|
|
1005
|
+
if (isClickFlag && distance > CLICK_THRESHOLD) {
|
|
1006
|
+
isClickFlag = false;
|
|
1007
|
+
setIsDragging(true);
|
|
1008
|
+
}
|
|
1009
|
+
if (!isClickFlag) {
|
|
1010
|
+
if (wrapperRect) {
|
|
1011
|
+
if (e.clientX < wrapperRect.left) {
|
|
1012
|
+
rubberStretchPx.jump(computeRubberStretch(e.clientX, -1));
|
|
1013
|
+
} else if (e.clientX > wrapperRect.right) {
|
|
1014
|
+
rubberStretchPx.jump(computeRubberStretch(e.clientX, 1));
|
|
1015
|
+
} else {
|
|
1016
|
+
rubberStretchPx.jump(0);
|
|
1017
|
+
}
|
|
1018
|
+
}
|
|
1019
|
+
const newValue = positionToValue(e.clientX);
|
|
1020
|
+
const newPct = percentFromValue(newValue);
|
|
1021
|
+
if (snapAnim) {
|
|
1022
|
+
snapAnim.stop();
|
|
1023
|
+
snapAnim = null;
|
|
1024
|
+
}
|
|
1025
|
+
fillPercent.jump(newPct);
|
|
1026
|
+
props.onChange(roundValue(newValue, step()));
|
|
1027
|
+
}
|
|
1028
|
+
};
|
|
1029
|
+
const handlePointerUp = (e) => {
|
|
1030
|
+
if (!isInteracting()) return;
|
|
1031
|
+
if (isClickFlag) {
|
|
1032
|
+
const rawValue = positionToValue(e.clientX);
|
|
1033
|
+
const discreteSteps2 = (max() - min()) / step();
|
|
1034
|
+
const snappedValue = discreteSteps2 <= 10 ? Math.max(min(), Math.min(max(), min() + Math.round((rawValue - min()) / step()) * step())) : snapToDecile(rawValue, min(), max());
|
|
1035
|
+
const newPct = percentFromValue(snappedValue);
|
|
1036
|
+
if (snapAnim) snapAnim.stop();
|
|
1037
|
+
snapAnim = (0, import_motion2.animate)(fillPercent, newPct, {
|
|
1038
|
+
type: "spring",
|
|
1039
|
+
stiffness: 300,
|
|
1040
|
+
damping: 25,
|
|
1041
|
+
mass: 0.8,
|
|
1042
|
+
onComplete: () => {
|
|
1043
|
+
snapAnim = null;
|
|
1044
|
+
}
|
|
1045
|
+
});
|
|
1046
|
+
props.onChange(roundValue(snappedValue, step()));
|
|
1047
|
+
}
|
|
1048
|
+
if (rubberStretchPx.get() !== 0) {
|
|
1049
|
+
if (rubberAnim) rubberAnim.stop();
|
|
1050
|
+
rubberAnim = (0, import_motion2.animate)(rubberStretchPx, 0, {
|
|
1051
|
+
type: "spring",
|
|
1052
|
+
visualDuration: 0.35,
|
|
1053
|
+
bounce: 0.15
|
|
1054
|
+
});
|
|
1055
|
+
}
|
|
1056
|
+
setIsInteracting(false);
|
|
1057
|
+
setIsDragging(false);
|
|
1058
|
+
pointerDownPos = null;
|
|
1059
|
+
};
|
|
1060
|
+
const handlePointerCancel = () => {
|
|
1061
|
+
cancelInteraction();
|
|
1062
|
+
};
|
|
1063
|
+
(0, import_solid_js3.createEffect)(() => {
|
|
1064
|
+
const hovered = isValueHovered();
|
|
1065
|
+
const editing = showInput();
|
|
1066
|
+
const editable = isValueEditable();
|
|
1067
|
+
(0, import_solid_js3.onCleanup)(() => {
|
|
1068
|
+
if (hoverTimeout) {
|
|
1069
|
+
clearTimeout(hoverTimeout);
|
|
1070
|
+
hoverTimeout = null;
|
|
1071
|
+
}
|
|
1072
|
+
});
|
|
1073
|
+
if (hovered && !editing && !editable) {
|
|
1074
|
+
hoverTimeout = setTimeout(() => setIsValueEditable(true), 800);
|
|
1075
|
+
} else if (!hovered && !editing) {
|
|
1076
|
+
setIsValueEditable(false);
|
|
1077
|
+
}
|
|
1078
|
+
});
|
|
1079
|
+
(0, import_solid_js3.onCleanup)(() => {
|
|
1080
|
+
if (hoverTimeout) clearTimeout(hoverTimeout);
|
|
1081
|
+
snapAnim?.stop();
|
|
1082
|
+
rubberAnim?.stop();
|
|
1083
|
+
handleOpacityAnim?.stop();
|
|
1084
|
+
handleScaleXAnim?.stop();
|
|
1085
|
+
handleScaleYAnim?.stop();
|
|
1086
|
+
});
|
|
1087
|
+
(0, import_solid_js3.onMount)(() => {
|
|
1088
|
+
const unsubFill = fillPercent.on("change", applyFillStyles);
|
|
1089
|
+
const unsubRubber = rubberStretchPx.on("change", applyRubberStyles);
|
|
1090
|
+
const unsubHandleOpacity = handleOpacityMv.on("change", applyHandleVisualStyles);
|
|
1091
|
+
const unsubHandleScaleX = handleScaleXMv.on("change", applyHandleVisualStyles);
|
|
1092
|
+
const unsubHandleScaleY = handleScaleYMv.on("change", applyHandleVisualStyles);
|
|
1093
|
+
applyFillStyles(fillPercent.get());
|
|
1094
|
+
applyRubberStyles(rubberStretchPx.get());
|
|
1095
|
+
applyHandleVisualStyles();
|
|
1096
|
+
(0, import_solid_js3.onCleanup)(() => {
|
|
1097
|
+
unsubFill();
|
|
1098
|
+
unsubRubber();
|
|
1099
|
+
unsubHandleOpacity();
|
|
1100
|
+
unsubHandleScaleX();
|
|
1101
|
+
unsubHandleScaleY();
|
|
1102
|
+
});
|
|
1103
|
+
});
|
|
1104
|
+
(0, import_solid_js3.createEffect)(() => {
|
|
1105
|
+
if (showInput() && inputRef) {
|
|
1106
|
+
inputRef.focus();
|
|
1107
|
+
inputRef.select();
|
|
1108
|
+
}
|
|
1109
|
+
});
|
|
1110
|
+
const handleInputSubmit = () => {
|
|
1111
|
+
const parsed = parseFloat(inputValue());
|
|
1112
|
+
if (!isNaN(parsed)) {
|
|
1113
|
+
const clamped = Math.max(min(), Math.min(max(), parsed));
|
|
1114
|
+
props.onChange(roundValue(clamped, step()));
|
|
1115
|
+
}
|
|
1116
|
+
setShowInput(false);
|
|
1117
|
+
setIsValueHovered(false);
|
|
1118
|
+
setIsValueEditable(false);
|
|
1119
|
+
};
|
|
1120
|
+
const handleValueClick = (e) => {
|
|
1121
|
+
if (isValueEditable()) {
|
|
1122
|
+
e.stopPropagation();
|
|
1123
|
+
e.preventDefault();
|
|
1124
|
+
setShowInput(true);
|
|
1125
|
+
setInputValue(props.value.toFixed(decimalsForStep(step())));
|
|
1126
|
+
}
|
|
1127
|
+
};
|
|
1128
|
+
const handleInputKeyDown = (e) => {
|
|
1129
|
+
if (e.key === "Enter") handleInputSubmit();
|
|
1130
|
+
else if (e.key === "Escape") {
|
|
1131
|
+
setShowInput(false);
|
|
1132
|
+
setIsValueHovered(false);
|
|
1133
|
+
}
|
|
1134
|
+
};
|
|
1135
|
+
const displayValue = () => props.value.toFixed(decimalsForStep(step()));
|
|
1136
|
+
const HANDLE_BUFFER = 8;
|
|
1137
|
+
const LABEL_CSS_LEFT = 10;
|
|
1138
|
+
const VALUE_CSS_RIGHT = 10;
|
|
1139
|
+
const leftThreshold = () => {
|
|
1140
|
+
const trackWidth = wrapperRef?.offsetWidth;
|
|
1141
|
+
if (trackWidth && labelRef) {
|
|
1142
|
+
return (LABEL_CSS_LEFT + labelRef.offsetWidth + HANDLE_BUFFER) / trackWidth * 100;
|
|
1143
|
+
}
|
|
1144
|
+
return 30;
|
|
1145
|
+
};
|
|
1146
|
+
const rightThreshold = () => {
|
|
1147
|
+
const trackWidth = wrapperRef?.offsetWidth;
|
|
1148
|
+
if (trackWidth && valueSpanRef) {
|
|
1149
|
+
return (trackWidth - VALUE_CSS_RIGHT - valueSpanRef.offsetWidth - HANDLE_BUFFER) / trackWidth * 100;
|
|
1150
|
+
}
|
|
1151
|
+
return 78;
|
|
1152
|
+
};
|
|
1153
|
+
const valueDodge = () => percentage() < leftThreshold() || percentage() > rightThreshold();
|
|
1154
|
+
const handleOpacity = () => {
|
|
1155
|
+
if (!isActive()) return 0;
|
|
1156
|
+
if (valueDodge()) return 0.1;
|
|
1157
|
+
if (isDragging()) return 0.9;
|
|
1158
|
+
return 0.5;
|
|
1159
|
+
};
|
|
1160
|
+
(0, import_solid_js3.createEffect)(() => {
|
|
1161
|
+
const targetOpacity = handleOpacity();
|
|
1162
|
+
const targetScaleX = isActive() ? 1 : 0.25;
|
|
1163
|
+
const targetScaleY = isActive() && valueDodge() ? 0.75 : 1;
|
|
1164
|
+
handleOpacityAnim?.stop();
|
|
1165
|
+
handleScaleXAnim?.stop();
|
|
1166
|
+
handleScaleYAnim?.stop();
|
|
1167
|
+
handleOpacityAnim = (0, import_motion2.animate)(handleOpacityMv, targetOpacity, {
|
|
1168
|
+
duration: 0.15
|
|
1169
|
+
});
|
|
1170
|
+
handleScaleXAnim = (0, import_motion2.animate)(handleScaleXMv, targetScaleX, {
|
|
1171
|
+
type: "spring",
|
|
1172
|
+
visualDuration: 0.25,
|
|
1173
|
+
bounce: 0.15
|
|
1174
|
+
});
|
|
1175
|
+
handleScaleYAnim = (0, import_motion2.animate)(handleScaleYMv, targetScaleY, {
|
|
1176
|
+
type: "spring",
|
|
1177
|
+
visualDuration: 0.2,
|
|
1178
|
+
bounce: 0.1
|
|
1179
|
+
});
|
|
1180
|
+
});
|
|
1181
|
+
const fillBackground = () => isActive() ? "rgba(255, 255, 255, 0.15)" : "rgba(255, 255, 255, 0.11)";
|
|
1182
|
+
const discreteSteps = () => (max() - min()) / step();
|
|
1183
|
+
const hashMarks = () => {
|
|
1184
|
+
const ds = discreteSteps();
|
|
1185
|
+
if (ds <= 10) {
|
|
1186
|
+
return Array.from({
|
|
1187
|
+
length: ds - 1
|
|
1188
|
+
}, (_, i) => {
|
|
1189
|
+
const pct = (i + 1) * step() / (max() - min()) * 100;
|
|
1190
|
+
return (() => {
|
|
1191
|
+
var _el$ = _tmpl$9();
|
|
1192
|
+
(0, import_web18.setStyleProperty)(_el$, "left", `${pct}%`);
|
|
1193
|
+
return _el$;
|
|
1194
|
+
})();
|
|
1195
|
+
});
|
|
1196
|
+
}
|
|
1197
|
+
return Array.from({
|
|
1198
|
+
length: 9
|
|
1199
|
+
}, (_, i) => {
|
|
1200
|
+
const pct = (i + 1) * 10;
|
|
1201
|
+
return (() => {
|
|
1202
|
+
var _el$2 = _tmpl$9();
|
|
1203
|
+
(0, import_web18.setStyleProperty)(_el$2, "left", `${pct}%`);
|
|
1204
|
+
return _el$2;
|
|
1205
|
+
})();
|
|
1206
|
+
});
|
|
1207
|
+
};
|
|
1208
|
+
return (() => {
|
|
1209
|
+
var _el$3 = _tmpl$22(), _el$4 = _el$3.firstChild, _el$5 = _el$4.firstChild, _el$6 = _el$5.nextSibling, _el$7 = _el$6.nextSibling, _el$8 = _el$7.nextSibling;
|
|
1210
|
+
var _ref$ = wrapperRef;
|
|
1211
|
+
typeof _ref$ === "function" ? (0, import_web17.use)(_ref$, _el$3) : wrapperRef = _el$3;
|
|
1212
|
+
_el$4.addEventListener("mouseleave", () => setIsHovered(false));
|
|
1213
|
+
_el$4.addEventListener("mouseenter", () => setIsHovered(true));
|
|
1214
|
+
_el$4.addEventListener("pointercancel", handlePointerCancel);
|
|
1215
|
+
_el$4.$$pointerup = handlePointerUp;
|
|
1216
|
+
_el$4.$$pointermove = handlePointerMove;
|
|
1217
|
+
_el$4.$$pointerdown = handlePointerDown;
|
|
1218
|
+
var _ref$2 = trackRef;
|
|
1219
|
+
typeof _ref$2 === "function" ? (0, import_web17.use)(_ref$2, _el$4) : trackRef = _el$4;
|
|
1220
|
+
(0, import_web16.insert)(_el$5, hashMarks);
|
|
1221
|
+
var _ref$3 = fillRef;
|
|
1222
|
+
typeof _ref$3 === "function" ? (0, import_web17.use)(_ref$3, _el$6) : fillRef = _el$6;
|
|
1223
|
+
var _ref$4 = handleRef;
|
|
1224
|
+
typeof _ref$4 === "function" ? (0, import_web17.use)(_ref$4, _el$7) : handleRef = _el$7;
|
|
1225
|
+
var _ref$5 = labelRef;
|
|
1226
|
+
typeof _ref$5 === "function" ? (0, import_web17.use)(_ref$5, _el$8) : labelRef = _el$8;
|
|
1227
|
+
(0, import_web16.insert)(_el$8, () => props.label);
|
|
1228
|
+
(0, import_web16.insert)(_el$4, (() => {
|
|
1229
|
+
var _c$ = (0, import_web15.memo)(() => !!showInput());
|
|
1230
|
+
return () => _c$() ? (() => {
|
|
1231
|
+
var _el$9 = _tmpl$32();
|
|
1232
|
+
_el$9.$$mousedown = (e) => e.stopPropagation();
|
|
1233
|
+
_el$9.$$click = (e) => e.stopPropagation();
|
|
1234
|
+
_el$9.addEventListener("blur", handleInputSubmit);
|
|
1235
|
+
_el$9.$$keydown = handleInputKeyDown;
|
|
1236
|
+
_el$9.$$input = (e) => setInputValue(e.currentTarget.value);
|
|
1237
|
+
var _ref$6 = inputRef;
|
|
1238
|
+
typeof _ref$6 === "function" ? (0, import_web17.use)(_ref$6, _el$9) : inputRef = _el$9;
|
|
1239
|
+
(0, import_web14.effect)(() => _el$9.value = inputValue());
|
|
1240
|
+
return _el$9;
|
|
1241
|
+
})() : (() => {
|
|
1242
|
+
var _el$0 = _tmpl$42();
|
|
1243
|
+
_el$0.$$mousedown = (e) => isValueEditable() && e.stopPropagation();
|
|
1244
|
+
_el$0.$$click = handleValueClick;
|
|
1245
|
+
_el$0.addEventListener("mouseleave", () => setIsValueHovered(false));
|
|
1246
|
+
_el$0.addEventListener("mouseenter", () => setIsValueHovered(true));
|
|
1247
|
+
var _ref$7 = valueSpanRef;
|
|
1248
|
+
typeof _ref$7 === "function" ? (0, import_web17.use)(_ref$7, _el$0) : valueSpanRef = _el$0;
|
|
1249
|
+
(0, import_web16.insert)(_el$0, displayValue);
|
|
1250
|
+
(0, import_web14.effect)((_p$) => {
|
|
1251
|
+
var _v$5 = `dialkit-slider-value ${isValueEditable() ? "dialkit-slider-value-editable" : ""}`, _v$6 = isValueEditable() ? "text" : "default";
|
|
1252
|
+
_v$5 !== _p$.e && (0, import_web13.className)(_el$0, _p$.e = _v$5);
|
|
1253
|
+
_v$6 !== _p$.t && (0, import_web18.setStyleProperty)(_el$0, "cursor", _p$.t = _v$6);
|
|
1254
|
+
return _p$;
|
|
1255
|
+
}, {
|
|
1256
|
+
e: void 0,
|
|
1257
|
+
t: void 0
|
|
1258
|
+
});
|
|
1259
|
+
return _el$0;
|
|
1260
|
+
})();
|
|
1261
|
+
})(), null);
|
|
1262
|
+
(0, import_web14.effect)((_p$) => {
|
|
1263
|
+
var _v$ = `dialkit-slider ${isActive() ? "dialkit-slider-active" : ""}`, _v$2 = fillBackground(), _v$3 = `${fillPercent.get()}%`, _v$4 = `max(5px, calc(${fillPercent.get()}% - 9px))`;
|
|
1264
|
+
_v$ !== _p$.e && (0, import_web13.className)(_el$4, _p$.e = _v$);
|
|
1265
|
+
_v$2 !== _p$.t && (0, import_web18.setStyleProperty)(_el$6, "background", _p$.t = _v$2);
|
|
1266
|
+
_v$3 !== _p$.a && (0, import_web18.setStyleProperty)(_el$6, "width", _p$.a = _v$3);
|
|
1267
|
+
_v$4 !== _p$.o && (0, import_web18.setStyleProperty)(_el$7, "left", _p$.o = _v$4);
|
|
1268
|
+
return _p$;
|
|
1269
|
+
}, {
|
|
1270
|
+
e: void 0,
|
|
1271
|
+
t: void 0,
|
|
1272
|
+
a: void 0,
|
|
1273
|
+
o: void 0
|
|
1274
|
+
});
|
|
1275
|
+
return _el$3;
|
|
1276
|
+
})();
|
|
1277
|
+
}
|
|
1278
|
+
(0, import_web12.delegateEvents)(["pointerdown", "pointermove", "pointerup", "input", "keydown", "click", "mousedown"]);
|
|
1279
|
+
|
|
1280
|
+
// src/solid/components/Toggle.tsx
|
|
1281
|
+
var import_web27 = require("solid-js/web");
|
|
1282
|
+
var import_web28 = require("solid-js/web");
|
|
1283
|
+
var import_web29 = require("solid-js/web");
|
|
1284
|
+
var import_web30 = require("solid-js/web");
|
|
1285
|
+
|
|
1286
|
+
// src/solid/components/SegmentedControl.tsx
|
|
1287
|
+
var import_web19 = require("solid-js/web");
|
|
1288
|
+
var import_web20 = require("solid-js/web");
|
|
1289
|
+
var import_web21 = require("solid-js/web");
|
|
1290
|
+
var import_web22 = require("solid-js/web");
|
|
1291
|
+
var import_web23 = require("solid-js/web");
|
|
1292
|
+
var import_web24 = require("solid-js/web");
|
|
1293
|
+
var import_web25 = require("solid-js/web");
|
|
1294
|
+
var import_web26 = require("solid-js/web");
|
|
1295
|
+
var import_solid_js4 = require("solid-js");
|
|
1296
|
+
var import_motion3 = require("motion");
|
|
1297
|
+
var _tmpl$10 = /* @__PURE__ */ (0, import_web19.template)(`<div class=dialkit-segmented><div class=dialkit-segmented-pill style=left:0px;width:0px>`);
|
|
1298
|
+
var _tmpl$23 = /* @__PURE__ */ (0, import_web19.template)(`<button class=dialkit-segmented-button>`);
|
|
1299
|
+
function SegmentedControl(props) {
|
|
1300
|
+
let containerRef;
|
|
1301
|
+
let pillRef;
|
|
1302
|
+
const buttonRefs = /* @__PURE__ */ new Map();
|
|
1303
|
+
const [pillReady, setPillReady] = (0, import_solid_js4.createSignal)(false);
|
|
1304
|
+
let hasAnimated = false;
|
|
1305
|
+
let pillAnim = null;
|
|
1306
|
+
const measurePill = () => {
|
|
1307
|
+
const button = buttonRefs.get(props.value);
|
|
1308
|
+
if (!button || !containerRef) return null;
|
|
1309
|
+
const containerRect = containerRef.getBoundingClientRect();
|
|
1310
|
+
const buttonRect = button.getBoundingClientRect();
|
|
1311
|
+
return {
|
|
1312
|
+
left: buttonRect.left - containerRect.left,
|
|
1313
|
+
width: buttonRect.width
|
|
1314
|
+
};
|
|
1315
|
+
};
|
|
1316
|
+
const setPillImmediate = (left, width) => {
|
|
1317
|
+
if (!pillRef) return;
|
|
1318
|
+
pillRef.style.left = `${left}px`;
|
|
1319
|
+
pillRef.style.width = `${width}px`;
|
|
1320
|
+
};
|
|
1321
|
+
const updatePill = (shouldAnimate) => {
|
|
1322
|
+
const next = measurePill();
|
|
1323
|
+
if (!next) return;
|
|
1324
|
+
if (!pillReady()) {
|
|
1325
|
+
setPillImmediate(next.left, next.width);
|
|
1326
|
+
setPillReady(true);
|
|
1327
|
+
return;
|
|
1328
|
+
}
|
|
1329
|
+
if (!shouldAnimate || !hasAnimated) {
|
|
1330
|
+
pillAnim?.stop();
|
|
1331
|
+
pillAnim = null;
|
|
1332
|
+
setPillImmediate(next.left, next.width);
|
|
1333
|
+
return;
|
|
1334
|
+
}
|
|
1335
|
+
pillAnim?.stop();
|
|
1336
|
+
pillAnim = (0, import_motion3.animate)(pillRef, {
|
|
1337
|
+
left: next.left,
|
|
1338
|
+
width: next.width
|
|
1339
|
+
}, {
|
|
1340
|
+
type: "spring",
|
|
1341
|
+
visualDuration: 0.2,
|
|
1342
|
+
bounce: 0.15,
|
|
1343
|
+
onComplete: () => {
|
|
1344
|
+
pillAnim = null;
|
|
1345
|
+
}
|
|
1346
|
+
});
|
|
1347
|
+
};
|
|
1348
|
+
(0, import_solid_js4.createRenderEffect)(() => {
|
|
1349
|
+
const _ = props.value;
|
|
1350
|
+
if (!pillReady()) return;
|
|
1351
|
+
updatePill(true);
|
|
1352
|
+
});
|
|
1353
|
+
(0, import_solid_js4.onMount)(() => {
|
|
1354
|
+
requestAnimationFrame(() => {
|
|
1355
|
+
updatePill(false);
|
|
1356
|
+
hasAnimated = true;
|
|
1357
|
+
});
|
|
1358
|
+
if (typeof ResizeObserver === "undefined") return;
|
|
1359
|
+
const ro = new ResizeObserver(() => updatePill(false));
|
|
1360
|
+
ro.observe(containerRef);
|
|
1361
|
+
(0, import_solid_js4.onCleanup)(() => {
|
|
1362
|
+
pillAnim?.stop();
|
|
1363
|
+
ro.disconnect();
|
|
1364
|
+
});
|
|
1365
|
+
});
|
|
1366
|
+
return (() => {
|
|
1367
|
+
var _el$ = _tmpl$10(), _el$2 = _el$.firstChild;
|
|
1368
|
+
var _ref$ = containerRef;
|
|
1369
|
+
typeof _ref$ === "function" ? (0, import_web26.use)(_ref$, _el$) : containerRef = _el$;
|
|
1370
|
+
var _ref$2 = pillRef;
|
|
1371
|
+
typeof _ref$2 === "function" ? (0, import_web26.use)(_ref$2, _el$2) : pillRef = _el$2;
|
|
1372
|
+
(0, import_web24.insert)(_el$, (0, import_web25.createComponent)(import_solid_js4.For, {
|
|
1373
|
+
get each() {
|
|
1374
|
+
return props.options;
|
|
1375
|
+
},
|
|
1376
|
+
children: (option) => (() => {
|
|
1377
|
+
var _el$3 = _tmpl$23();
|
|
1378
|
+
_el$3.$$click = () => props.onChange(option.value);
|
|
1379
|
+
(0, import_web26.use)((el) => {
|
|
1380
|
+
if (!el) return;
|
|
1381
|
+
buttonRefs.set(option.value, el);
|
|
1382
|
+
}, _el$3);
|
|
1383
|
+
(0, import_web24.insert)(_el$3, () => option.label);
|
|
1384
|
+
(0, import_web23.effect)(() => (0, import_web21.setAttribute)(_el$3, "data-active", String(props.value === option.value)));
|
|
1385
|
+
return _el$3;
|
|
1386
|
+
})()
|
|
1387
|
+
}), null);
|
|
1388
|
+
(0, import_web23.effect)((_$p) => (0, import_web22.setStyleProperty)(_el$2, "visibility", pillReady() ? "visible" : "hidden"));
|
|
1389
|
+
return _el$;
|
|
1390
|
+
})();
|
|
1391
|
+
}
|
|
1392
|
+
(0, import_web20.delegateEvents)(["click"]);
|
|
1393
|
+
|
|
1394
|
+
// src/solid/components/Toggle.tsx
|
|
1395
|
+
var _tmpl$11 = /* @__PURE__ */ (0, import_web27.template)(`<div class=dialkit-labeled-control><span class=dialkit-labeled-control-label>`);
|
|
1396
|
+
function Toggle(props) {
|
|
1397
|
+
return (() => {
|
|
1398
|
+
var _el$ = _tmpl$11(), _el$2 = _el$.firstChild;
|
|
1399
|
+
(0, import_web30.insert)(_el$2, () => props.label);
|
|
1400
|
+
(0, import_web30.insert)(_el$, (0, import_web28.createComponent)(SegmentedControl, {
|
|
1401
|
+
options: [{
|
|
1402
|
+
value: "off",
|
|
1403
|
+
label: "Off"
|
|
1404
|
+
}, {
|
|
1405
|
+
value: "on",
|
|
1406
|
+
label: "On"
|
|
1407
|
+
}],
|
|
1408
|
+
get value() {
|
|
1409
|
+
return props.checked ? "on" : "off";
|
|
1410
|
+
},
|
|
1411
|
+
onChange: (val) => props.onChange(val === "on")
|
|
1412
|
+
}), null);
|
|
1413
|
+
return _el$;
|
|
1414
|
+
})();
|
|
1415
|
+
}
|
|
1416
|
+
|
|
1417
|
+
// src/solid/components/SpringControl.tsx
|
|
1418
|
+
var import_web35 = require("solid-js/web");
|
|
1419
|
+
var import_web36 = require("solid-js/web");
|
|
1420
|
+
var import_web37 = require("solid-js/web");
|
|
1421
|
+
var import_web38 = require("solid-js/web");
|
|
1422
|
+
var import_solid_js5 = require("solid-js");
|
|
1423
|
+
|
|
1424
|
+
// src/solid/components/SpringVisualization.tsx
|
|
1425
|
+
var import_web31 = require("solid-js/web");
|
|
1426
|
+
var import_web32 = require("solid-js/web");
|
|
1427
|
+
var import_web33 = require("solid-js/web");
|
|
1428
|
+
var import_web34 = require("solid-js/web");
|
|
1429
|
+
var _tmpl$12 = /* @__PURE__ */ (0, import_web31.template)(`<svg><line y1=0 y2=140 stroke="rgba(255, 255, 255, 0.08)"stroke-width=1></svg>`, false, true, false);
|
|
1430
|
+
var _tmpl$24 = /* @__PURE__ */ (0, import_web31.template)(`<svg><line x1=0 x2=256 stroke="rgba(255, 255, 255, 0.08)"stroke-width=1></svg>`, false, true, false);
|
|
1431
|
+
var _tmpl$33 = /* @__PURE__ */ (0, import_web31.template)(`<svg viewBox="0 0 256 140"class=dialkit-spring-viz><line x1=0 y1=70 x2=256 y2=70 stroke="rgba(255, 255, 255, 0.15)"stroke-width=1 stroke-dasharray=4,4></line><path fill=none stroke="rgba(255, 255, 255, 0.6)"stroke-width=2 stroke-linecap=round stroke-linejoin=round>`);
|
|
1432
|
+
function generateSpringCurve(stiffness, damping, mass, duration) {
|
|
1433
|
+
const points = [];
|
|
1434
|
+
const steps = 100;
|
|
1435
|
+
const dt = duration / steps;
|
|
1436
|
+
let position = 0;
|
|
1437
|
+
let velocity = 0;
|
|
1438
|
+
const target = 1;
|
|
1439
|
+
for (let i = 0; i <= steps; i++) {
|
|
1440
|
+
const time = i * dt;
|
|
1441
|
+
points.push([time, position]);
|
|
1442
|
+
const springForce = -stiffness * (position - target);
|
|
1443
|
+
const dampingForce = -damping * velocity;
|
|
1444
|
+
const acceleration = (springForce + dampingForce) / mass;
|
|
1445
|
+
velocity += acceleration * dt;
|
|
1446
|
+
position += velocity * dt;
|
|
1447
|
+
}
|
|
1448
|
+
return points;
|
|
1449
|
+
}
|
|
1450
|
+
function SpringVisualization(props) {
|
|
1451
|
+
const width = 256;
|
|
1452
|
+
const height = 140;
|
|
1453
|
+
const params = () => {
|
|
1454
|
+
let stiffness;
|
|
1455
|
+
let damping;
|
|
1456
|
+
let mass;
|
|
1457
|
+
if (props.isSimpleMode) {
|
|
1458
|
+
const visualDuration = props.spring.visualDuration ?? 0.3;
|
|
1459
|
+
const bounce = props.spring.bounce ?? 0.2;
|
|
1460
|
+
mass = 1;
|
|
1461
|
+
stiffness = Math.pow(2 * Math.PI / visualDuration, 2);
|
|
1462
|
+
const dampingRatio = 1 - bounce;
|
|
1463
|
+
damping = 2 * dampingRatio * Math.sqrt(stiffness * mass);
|
|
1464
|
+
} else {
|
|
1465
|
+
stiffness = props.spring.stiffness ?? 400;
|
|
1466
|
+
damping = props.spring.damping ?? 17;
|
|
1467
|
+
mass = props.spring.mass ?? 1;
|
|
1468
|
+
}
|
|
1469
|
+
const duration = 2;
|
|
1470
|
+
const points = generateSpringCurve(stiffness, damping, mass, duration);
|
|
1471
|
+
const values = points.map(([, value]) => value);
|
|
1472
|
+
const minValue = Math.min(...values);
|
|
1473
|
+
const maxValue = Math.max(...values);
|
|
1474
|
+
const valueRange = maxValue - minValue;
|
|
1475
|
+
const pathData = points.map(([time, value], i) => {
|
|
1476
|
+
const x = time / duration * width;
|
|
1477
|
+
const normalizedValue = (value - minValue) / (valueRange || 1);
|
|
1478
|
+
const y = height - (normalizedValue * height * 0.6 + height * 0.2);
|
|
1479
|
+
return `${i === 0 ? "M" : "L"} ${x} ${y}`;
|
|
1480
|
+
}).join(" ");
|
|
1481
|
+
return pathData;
|
|
1482
|
+
};
|
|
1483
|
+
const gridLines = () => {
|
|
1484
|
+
const lines = [];
|
|
1485
|
+
for (let i = 1; i < 4; i++) {
|
|
1486
|
+
const x = width / 4 * i;
|
|
1487
|
+
const y = height / 4 * i;
|
|
1488
|
+
lines.push((() => {
|
|
1489
|
+
var _el$ = _tmpl$12();
|
|
1490
|
+
(0, import_web34.setAttribute)(_el$, "x1", x);
|
|
1491
|
+
(0, import_web34.setAttribute)(_el$, "x2", x);
|
|
1492
|
+
return _el$;
|
|
1493
|
+
})(), (() => {
|
|
1494
|
+
var _el$2 = _tmpl$24();
|
|
1495
|
+
(0, import_web34.setAttribute)(_el$2, "y1", y);
|
|
1496
|
+
(0, import_web34.setAttribute)(_el$2, "y2", y);
|
|
1497
|
+
return _el$2;
|
|
1498
|
+
})());
|
|
1499
|
+
}
|
|
1500
|
+
return lines;
|
|
1501
|
+
};
|
|
1502
|
+
return (() => {
|
|
1503
|
+
var _el$3 = _tmpl$33(), _el$4 = _el$3.firstChild, _el$5 = _el$4.nextSibling;
|
|
1504
|
+
(0, import_web33.insert)(_el$3, gridLines, _el$4);
|
|
1505
|
+
(0, import_web32.effect)(() => (0, import_web34.setAttribute)(_el$5, "d", params()));
|
|
1506
|
+
return _el$3;
|
|
1507
|
+
})();
|
|
1508
|
+
}
|
|
1509
|
+
|
|
1510
|
+
// src/solid/components/SpringControl.tsx
|
|
1511
|
+
var _tmpl$13 = /* @__PURE__ */ (0, import_web35.template)(`<div style=display:flex;flex-direction:column;gap:6px><div class=dialkit-labeled-control><span class=dialkit-labeled-control-label>Type`);
|
|
1512
|
+
function SpringControl(props) {
|
|
1513
|
+
const [mode, setMode] = (0, import_solid_js5.createSignal)(DialStore.getSpringMode(props.panelId, props.path));
|
|
1514
|
+
(0, import_solid_js5.onMount)(() => {
|
|
1515
|
+
const unsub = DialStore.subscribe(props.panelId, () => {
|
|
1516
|
+
setMode(DialStore.getSpringMode(props.panelId, props.path));
|
|
1517
|
+
});
|
|
1518
|
+
(0, import_solid_js5.onCleanup)(unsub);
|
|
1519
|
+
});
|
|
1520
|
+
const isSimpleMode = () => mode() === "simple";
|
|
1521
|
+
const handleModeChange = (newMode) => {
|
|
1522
|
+
DialStore.updateSpringMode(props.panelId, props.path, newMode);
|
|
1523
|
+
if (newMode === "simple") {
|
|
1524
|
+
const {
|
|
1525
|
+
stiffness,
|
|
1526
|
+
damping,
|
|
1527
|
+
mass,
|
|
1528
|
+
...rest
|
|
1529
|
+
} = props.spring;
|
|
1530
|
+
props.onChange({
|
|
1531
|
+
...rest,
|
|
1532
|
+
type: "spring",
|
|
1533
|
+
visualDuration: props.spring.visualDuration ?? 0.3,
|
|
1534
|
+
bounce: props.spring.bounce ?? 0.2
|
|
1535
|
+
});
|
|
1536
|
+
} else {
|
|
1537
|
+
const {
|
|
1538
|
+
visualDuration,
|
|
1539
|
+
bounce,
|
|
1540
|
+
...rest
|
|
1541
|
+
} = props.spring;
|
|
1542
|
+
props.onChange({
|
|
1543
|
+
...rest,
|
|
1544
|
+
type: "spring",
|
|
1545
|
+
stiffness: props.spring.stiffness ?? 200,
|
|
1546
|
+
damping: props.spring.damping ?? 25,
|
|
1547
|
+
mass: props.spring.mass ?? 1
|
|
1548
|
+
});
|
|
1549
|
+
}
|
|
1550
|
+
};
|
|
1551
|
+
const handleUpdate = (key, value) => {
|
|
1552
|
+
if (isSimpleMode()) {
|
|
1553
|
+
const {
|
|
1554
|
+
stiffness,
|
|
1555
|
+
damping,
|
|
1556
|
+
mass,
|
|
1557
|
+
...rest
|
|
1558
|
+
} = props.spring;
|
|
1559
|
+
props.onChange({
|
|
1560
|
+
...rest,
|
|
1561
|
+
[key]: value
|
|
1562
|
+
});
|
|
1563
|
+
} else {
|
|
1564
|
+
const {
|
|
1565
|
+
visualDuration,
|
|
1566
|
+
bounce,
|
|
1567
|
+
...rest
|
|
1568
|
+
} = props.spring;
|
|
1569
|
+
props.onChange({
|
|
1570
|
+
...rest,
|
|
1571
|
+
[key]: value
|
|
1572
|
+
});
|
|
1573
|
+
}
|
|
1574
|
+
};
|
|
1575
|
+
return (0, import_web38.createComponent)(Folder, {
|
|
1576
|
+
get title() {
|
|
1577
|
+
return props.label;
|
|
1578
|
+
},
|
|
1579
|
+
defaultOpen: true,
|
|
1580
|
+
get children() {
|
|
1581
|
+
var _el$ = _tmpl$13(), _el$2 = _el$.firstChild, _el$3 = _el$2.firstChild;
|
|
1582
|
+
(0, import_web37.insert)(_el$, (0, import_web38.createComponent)(SpringVisualization, {
|
|
1583
|
+
get spring() {
|
|
1584
|
+
return props.spring;
|
|
1585
|
+
},
|
|
1586
|
+
get isSimpleMode() {
|
|
1587
|
+
return isSimpleMode();
|
|
1588
|
+
}
|
|
1589
|
+
}), _el$2);
|
|
1590
|
+
(0, import_web37.insert)(_el$2, (0, import_web38.createComponent)(SegmentedControl, {
|
|
1591
|
+
options: [{
|
|
1592
|
+
value: "simple",
|
|
1593
|
+
label: "Time"
|
|
1594
|
+
}, {
|
|
1595
|
+
value: "advanced",
|
|
1596
|
+
label: "Physics"
|
|
1597
|
+
}],
|
|
1598
|
+
get value() {
|
|
1599
|
+
return mode();
|
|
1600
|
+
},
|
|
1601
|
+
onChange: handleModeChange
|
|
1602
|
+
}), null);
|
|
1603
|
+
(0, import_web37.insert)(_el$, (() => {
|
|
1604
|
+
var _c$ = (0, import_web36.memo)(() => !!isSimpleMode());
|
|
1605
|
+
return () => _c$() ? [(0, import_web38.createComponent)(Slider, {
|
|
1606
|
+
label: "Duration",
|
|
1607
|
+
get value() {
|
|
1608
|
+
return props.spring.visualDuration ?? 0.3;
|
|
1609
|
+
},
|
|
1610
|
+
onChange: (v) => handleUpdate("visualDuration", v),
|
|
1611
|
+
min: 0.1,
|
|
1612
|
+
max: 1,
|
|
1613
|
+
step: 0.05,
|
|
1614
|
+
unit: "s"
|
|
1615
|
+
}), (0, import_web38.createComponent)(Slider, {
|
|
1616
|
+
label: "Bounce",
|
|
1617
|
+
get value() {
|
|
1618
|
+
return props.spring.bounce ?? 0.2;
|
|
1619
|
+
},
|
|
1620
|
+
onChange: (v) => handleUpdate("bounce", v),
|
|
1621
|
+
min: 0,
|
|
1622
|
+
max: 1,
|
|
1623
|
+
step: 0.05
|
|
1624
|
+
})] : [(0, import_web38.createComponent)(Slider, {
|
|
1625
|
+
label: "Stiffness",
|
|
1626
|
+
get value() {
|
|
1627
|
+
return props.spring.stiffness ?? 400;
|
|
1628
|
+
},
|
|
1629
|
+
onChange: (v) => handleUpdate("stiffness", v),
|
|
1630
|
+
min: 1,
|
|
1631
|
+
max: 1e3,
|
|
1632
|
+
step: 10
|
|
1633
|
+
}), (0, import_web38.createComponent)(Slider, {
|
|
1634
|
+
label: "Damping",
|
|
1635
|
+
get value() {
|
|
1636
|
+
return props.spring.damping ?? 17;
|
|
1637
|
+
},
|
|
1638
|
+
onChange: (v) => handleUpdate("damping", v),
|
|
1639
|
+
min: 1,
|
|
1640
|
+
max: 100,
|
|
1641
|
+
step: 1
|
|
1642
|
+
}), (0, import_web38.createComponent)(Slider, {
|
|
1643
|
+
label: "Mass",
|
|
1644
|
+
get value() {
|
|
1645
|
+
return props.spring.mass ?? 1;
|
|
1646
|
+
},
|
|
1647
|
+
onChange: (v) => handleUpdate("mass", v),
|
|
1648
|
+
min: 0.1,
|
|
1649
|
+
max: 10,
|
|
1650
|
+
step: 0.1
|
|
1651
|
+
})];
|
|
1652
|
+
})(), null);
|
|
1653
|
+
return _el$;
|
|
1654
|
+
}
|
|
1655
|
+
});
|
|
1656
|
+
}
|
|
1657
|
+
|
|
1658
|
+
// src/solid/components/TextControl.tsx
|
|
1659
|
+
var import_web39 = require("solid-js/web");
|
|
1660
|
+
var import_web40 = require("solid-js/web");
|
|
1661
|
+
var import_web41 = require("solid-js/web");
|
|
1662
|
+
var import_web42 = require("solid-js/web");
|
|
1663
|
+
var import_web43 = require("solid-js/web");
|
|
1664
|
+
var import_solid_js6 = require("solid-js");
|
|
1665
|
+
var _tmpl$14 = /* @__PURE__ */ (0, import_web39.template)(`<div class=dialkit-text-control><label class=dialkit-text-label></label><input type=text class=dialkit-text-input>`);
|
|
1666
|
+
function TextControl(props) {
|
|
1667
|
+
const inputId = (0, import_solid_js6.createUniqueId)();
|
|
1668
|
+
return (() => {
|
|
1669
|
+
var _el$ = _tmpl$14(), _el$2 = _el$.firstChild, _el$3 = _el$2.nextSibling;
|
|
1670
|
+
(0, import_web43.setAttribute)(_el$2, "for", inputId);
|
|
1671
|
+
(0, import_web42.insert)(_el$2, () => props.label);
|
|
1672
|
+
_el$3.$$input = (e) => props.onChange(e.currentTarget.value);
|
|
1673
|
+
(0, import_web43.setAttribute)(_el$3, "id", inputId);
|
|
1674
|
+
(0, import_web41.effect)(() => (0, import_web43.setAttribute)(_el$3, "placeholder", props.placeholder));
|
|
1675
|
+
(0, import_web41.effect)(() => _el$3.value = props.value);
|
|
1676
|
+
return _el$;
|
|
1677
|
+
})();
|
|
1678
|
+
}
|
|
1679
|
+
(0, import_web40.delegateEvents)(["input"]);
|
|
1680
|
+
|
|
1681
|
+
// src/solid/components/SelectControl.tsx
|
|
1682
|
+
var import_web44 = require("solid-js/web");
|
|
1683
|
+
var import_web45 = require("solid-js/web");
|
|
1684
|
+
var import_web46 = require("solid-js/web");
|
|
1685
|
+
var import_web47 = require("solid-js/web");
|
|
1686
|
+
var import_web48 = require("solid-js/web");
|
|
1687
|
+
var import_web49 = require("solid-js/web");
|
|
1688
|
+
var import_web50 = require("solid-js/web");
|
|
1689
|
+
var import_web51 = require("solid-js/web");
|
|
1690
|
+
var import_web52 = require("solid-js/web");
|
|
1691
|
+
var import_solid_js7 = require("solid-js");
|
|
1692
|
+
var import_web53 = require("solid-js/web");
|
|
1693
|
+
var import_motion4 = require("motion");
|
|
1694
|
+
var _tmpl$15 = /* @__PURE__ */ (0, import_web44.template)(`<div class=dialkit-select-dropdown>`);
|
|
1695
|
+
var _tmpl$25 = /* @__PURE__ */ (0, import_web44.template)(`<div class=dialkit-select-row><button class=dialkit-select-trigger><span class=dialkit-select-label></span><div class=dialkit-select-right><span class=dialkit-select-value></span><svg class=dialkit-select-chevron viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=2.5 stroke-linecap=round stroke-linejoin=round><path d="M6 9.5L12 15.5L18 9.5">`);
|
|
1696
|
+
var _tmpl$34 = /* @__PURE__ */ (0, import_web44.template)(`<button class=dialkit-select-option>`);
|
|
1697
|
+
function toTitleCase(s) {
|
|
1698
|
+
return s.replace(/\b\w/g, (c) => c.toUpperCase());
|
|
1699
|
+
}
|
|
1700
|
+
function normalizeOptions(options) {
|
|
1701
|
+
return options.map((opt) => typeof opt === "string" ? {
|
|
1702
|
+
value: opt,
|
|
1703
|
+
label: toTitleCase(opt)
|
|
1704
|
+
} : opt);
|
|
1705
|
+
}
|
|
1706
|
+
function SelectControl(props) {
|
|
1707
|
+
const [isOpen, setIsOpen] = (0, import_solid_js7.createSignal)(false);
|
|
1708
|
+
const [mounted, setMounted] = (0, import_solid_js7.createSignal)(false);
|
|
1709
|
+
const [pos, setPos] = (0, import_solid_js7.createSignal)(null);
|
|
1710
|
+
const [portalTarget, setPortalTarget] = (0, import_solid_js7.createSignal)(null);
|
|
1711
|
+
let triggerRef;
|
|
1712
|
+
let dropdownRef;
|
|
1713
|
+
let chevronRef;
|
|
1714
|
+
let closeAnim = null;
|
|
1715
|
+
let chevronAnim = null;
|
|
1716
|
+
const normalized = () => normalizeOptions(props.options);
|
|
1717
|
+
const selectedOption = () => normalized().find((o) => o.value === props.value);
|
|
1718
|
+
(0, import_solid_js7.onMount)(() => {
|
|
1719
|
+
const root = triggerRef?.closest(".dialkit-root");
|
|
1720
|
+
setPortalTarget(root ?? document.body);
|
|
1721
|
+
if (chevronRef) {
|
|
1722
|
+
chevronRef.style.transform = `rotate(${isOpen() ? 180 : 0}deg)`;
|
|
1723
|
+
}
|
|
1724
|
+
(0, import_solid_js7.onCleanup)(() => {
|
|
1725
|
+
closeAnim?.stop();
|
|
1726
|
+
chevronAnim?.stop();
|
|
1727
|
+
});
|
|
1728
|
+
});
|
|
1729
|
+
(0, import_solid_js7.createEffect)(() => {
|
|
1730
|
+
if (!chevronRef) return;
|
|
1731
|
+
const open = isOpen();
|
|
1732
|
+
chevronAnim?.stop();
|
|
1733
|
+
chevronAnim = (0, import_motion4.animate)(chevronRef, {
|
|
1734
|
+
rotate: open ? 180 : 0
|
|
1735
|
+
}, {
|
|
1736
|
+
type: "spring",
|
|
1737
|
+
visualDuration: 0.2,
|
|
1738
|
+
bounce: 0.15
|
|
1739
|
+
});
|
|
1740
|
+
});
|
|
1741
|
+
const updatePos = () => {
|
|
1742
|
+
if (!triggerRef) return;
|
|
1743
|
+
const rect = triggerRef.getBoundingClientRect();
|
|
1744
|
+
const dropdownHeight = 8 + normalized().length * 36;
|
|
1745
|
+
const spaceBelow = window.innerHeight - rect.bottom - 4;
|
|
1746
|
+
const above = spaceBelow < dropdownHeight && rect.top > spaceBelow;
|
|
1747
|
+
setPos({
|
|
1748
|
+
top: above ? rect.top - 4 : rect.bottom + 4,
|
|
1749
|
+
left: rect.left,
|
|
1750
|
+
width: rect.width,
|
|
1751
|
+
above
|
|
1752
|
+
});
|
|
1753
|
+
};
|
|
1754
|
+
const openDropdown = () => {
|
|
1755
|
+
closeAnim?.stop();
|
|
1756
|
+
closeAnim = null;
|
|
1757
|
+
updatePos();
|
|
1758
|
+
setMounted(true);
|
|
1759
|
+
setIsOpen(true);
|
|
1760
|
+
};
|
|
1761
|
+
const closeDropdown = () => {
|
|
1762
|
+
setIsOpen(false);
|
|
1763
|
+
if (!dropdownRef) {
|
|
1764
|
+
setMounted(false);
|
|
1765
|
+
return;
|
|
1766
|
+
}
|
|
1767
|
+
const above = pos()?.above ?? false;
|
|
1768
|
+
closeAnim?.stop();
|
|
1769
|
+
closeAnim = (0, import_motion4.animate)(dropdownRef, {
|
|
1770
|
+
opacity: 0,
|
|
1771
|
+
y: above ? 8 : -8,
|
|
1772
|
+
scale: 0.95
|
|
1773
|
+
}, {
|
|
1774
|
+
type: "spring",
|
|
1775
|
+
visualDuration: 0.15,
|
|
1776
|
+
bounce: 0,
|
|
1777
|
+
onComplete: () => {
|
|
1778
|
+
setMounted(false);
|
|
1779
|
+
closeAnim = null;
|
|
1780
|
+
}
|
|
1781
|
+
});
|
|
1782
|
+
};
|
|
1783
|
+
(0, import_solid_js7.createEffect)(() => {
|
|
1784
|
+
if (!isOpen()) return;
|
|
1785
|
+
const handleViewportChange = () => updatePos();
|
|
1786
|
+
const handleClick = (e) => {
|
|
1787
|
+
const target = e.target;
|
|
1788
|
+
if (triggerRef && !triggerRef.contains(target) && dropdownRef && !dropdownRef.contains(target)) {
|
|
1789
|
+
closeDropdown();
|
|
1790
|
+
}
|
|
1791
|
+
};
|
|
1792
|
+
updatePos();
|
|
1793
|
+
document.addEventListener("mousedown", handleClick);
|
|
1794
|
+
window.addEventListener("resize", handleViewportChange);
|
|
1795
|
+
window.addEventListener("scroll", handleViewportChange, true);
|
|
1796
|
+
(0, import_solid_js7.onCleanup)(() => {
|
|
1797
|
+
document.removeEventListener("mousedown", handleClick);
|
|
1798
|
+
window.removeEventListener("resize", handleViewportChange);
|
|
1799
|
+
window.removeEventListener("scroll", handleViewportChange, true);
|
|
1800
|
+
});
|
|
1801
|
+
});
|
|
1802
|
+
const dropdownStyle = () => {
|
|
1803
|
+
const p = pos();
|
|
1804
|
+
if (!p) return {};
|
|
1805
|
+
return {
|
|
1806
|
+
position: "fixed",
|
|
1807
|
+
left: `${p.left}px`,
|
|
1808
|
+
width: `${p.width}px`,
|
|
1809
|
+
...p.above ? {
|
|
1810
|
+
bottom: `${window.innerHeight - p.top}px`,
|
|
1811
|
+
"transform-origin": "bottom"
|
|
1812
|
+
} : {
|
|
1813
|
+
top: `${p.top}px`,
|
|
1814
|
+
"transform-origin": "top"
|
|
1815
|
+
}
|
|
1816
|
+
};
|
|
1817
|
+
};
|
|
1818
|
+
return (() => {
|
|
1819
|
+
var _el$ = _tmpl$25(), _el$2 = _el$.firstChild, _el$3 = _el$2.firstChild, _el$4 = _el$3.nextSibling, _el$5 = _el$4.firstChild, _el$6 = _el$5.nextSibling;
|
|
1820
|
+
_el$2.$$click = () => isOpen() ? closeDropdown() : openDropdown();
|
|
1821
|
+
var _ref$ = triggerRef;
|
|
1822
|
+
typeof _ref$ === "function" ? (0, import_web52.use)(_ref$, _el$2) : triggerRef = _el$2;
|
|
1823
|
+
(0, import_web51.insert)(_el$3, () => props.label);
|
|
1824
|
+
(0, import_web51.insert)(_el$5, () => selectedOption()?.label ?? props.value);
|
|
1825
|
+
var _ref$2 = chevronRef;
|
|
1826
|
+
typeof _ref$2 === "function" ? (0, import_web52.use)(_ref$2, _el$6) : chevronRef = _el$6;
|
|
1827
|
+
(0, import_web51.insert)(_el$, (0, import_web49.createComponent)(import_solid_js7.Show, {
|
|
1828
|
+
get when() {
|
|
1829
|
+
return !!portalTarget();
|
|
1830
|
+
},
|
|
1831
|
+
get children() {
|
|
1832
|
+
return (0, import_web49.createComponent)(import_web53.Portal, {
|
|
1833
|
+
get mount() {
|
|
1834
|
+
return portalTarget();
|
|
1835
|
+
},
|
|
1836
|
+
get children() {
|
|
1837
|
+
return (0, import_web49.createComponent)(import_solid_js7.Show, {
|
|
1838
|
+
get when() {
|
|
1839
|
+
return (0, import_web50.memo)(() => !!mounted())() && pos();
|
|
1840
|
+
},
|
|
1841
|
+
get children() {
|
|
1842
|
+
var _el$7 = _tmpl$15();
|
|
1843
|
+
(0, import_web52.use)((el) => {
|
|
1844
|
+
dropdownRef = el;
|
|
1845
|
+
const above = pos()?.above ?? false;
|
|
1846
|
+
(0, import_motion4.animate)(el, {
|
|
1847
|
+
opacity: [0, 1],
|
|
1848
|
+
y: [above ? 8 : -8, 0],
|
|
1849
|
+
scale: [0.95, 1]
|
|
1850
|
+
}, {
|
|
1851
|
+
type: "spring",
|
|
1852
|
+
visualDuration: 0.15,
|
|
1853
|
+
bounce: 0
|
|
1854
|
+
});
|
|
1855
|
+
}, _el$7);
|
|
1856
|
+
(0, import_web51.insert)(_el$7, (0, import_web49.createComponent)(import_solid_js7.For, {
|
|
1857
|
+
get each() {
|
|
1858
|
+
return normalized();
|
|
1859
|
+
},
|
|
1860
|
+
children: (option) => (() => {
|
|
1861
|
+
var _el$8 = _tmpl$34();
|
|
1862
|
+
_el$8.$$click = () => {
|
|
1863
|
+
props.onChange(option.value);
|
|
1864
|
+
closeDropdown();
|
|
1865
|
+
};
|
|
1866
|
+
(0, import_web51.insert)(_el$8, () => option.label);
|
|
1867
|
+
(0, import_web48.effect)(() => (0, import_web46.setAttribute)(_el$8, "data-selected", String(option.value === props.value)));
|
|
1868
|
+
return _el$8;
|
|
1869
|
+
})()
|
|
1870
|
+
}));
|
|
1871
|
+
(0, import_web48.effect)((_$p) => (0, import_web47.style)(_el$7, dropdownStyle(), _$p));
|
|
1872
|
+
return _el$7;
|
|
1873
|
+
}
|
|
1874
|
+
});
|
|
1875
|
+
}
|
|
1876
|
+
});
|
|
1877
|
+
}
|
|
1878
|
+
}), null);
|
|
1879
|
+
(0, import_web48.effect)(() => (0, import_web46.setAttribute)(_el$2, "data-open", String(isOpen())));
|
|
1880
|
+
return _el$;
|
|
1881
|
+
})();
|
|
1882
|
+
}
|
|
1883
|
+
(0, import_web45.delegateEvents)(["click"]);
|
|
1884
|
+
|
|
1885
|
+
// src/solid/components/ColorControl.tsx
|
|
1886
|
+
var import_web54 = require("solid-js/web");
|
|
1887
|
+
var import_web55 = require("solid-js/web");
|
|
1888
|
+
var import_web56 = require("solid-js/web");
|
|
1889
|
+
var import_web57 = require("solid-js/web");
|
|
1890
|
+
var import_web58 = require("solid-js/web");
|
|
1891
|
+
var import_web59 = require("solid-js/web");
|
|
1892
|
+
var import_web60 = require("solid-js/web");
|
|
1893
|
+
var import_web61 = require("solid-js/web");
|
|
1894
|
+
var import_solid_js8 = require("solid-js");
|
|
1895
|
+
var _tmpl$16 = /* @__PURE__ */ (0, import_web54.template)(`<input type=text class=dialkit-color-hex-input autofocus>`);
|
|
1896
|
+
var _tmpl$26 = /* @__PURE__ */ (0, import_web54.template)(`<div class=dialkit-color-control><label class=dialkit-color-label></label><div class=dialkit-color-inputs><button class=dialkit-color-swatch title="Pick color"></button><input type=color class=dialkit-color-picker-native>`);
|
|
1897
|
+
var _tmpl$35 = /* @__PURE__ */ (0, import_web54.template)(`<span class=dialkit-color-hex>`);
|
|
1898
|
+
var HEX_COLOR_REGEX = /^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})$/;
|
|
1899
|
+
function expandShorthandHex(hex) {
|
|
1900
|
+
if (hex.length !== 4) return hex;
|
|
1901
|
+
return `#${hex[1]}${hex[1]}${hex[2]}${hex[2]}${hex[3]}${hex[3]}`;
|
|
1902
|
+
}
|
|
1903
|
+
function ColorControl(props) {
|
|
1904
|
+
const [isEditing, setIsEditing] = (0, import_solid_js8.createSignal)(false);
|
|
1905
|
+
const [editValue, setEditValue] = (0, import_solid_js8.createSignal)(props.value);
|
|
1906
|
+
const textInputId = (0, import_solid_js8.createUniqueId)();
|
|
1907
|
+
let colorInputRef;
|
|
1908
|
+
(0, import_solid_js8.createEffect)(() => {
|
|
1909
|
+
if (!isEditing()) {
|
|
1910
|
+
setEditValue(props.value);
|
|
1911
|
+
}
|
|
1912
|
+
});
|
|
1913
|
+
const handleTextSubmit = () => {
|
|
1914
|
+
setIsEditing(false);
|
|
1915
|
+
if (HEX_COLOR_REGEX.test(editValue())) {
|
|
1916
|
+
props.onChange(editValue());
|
|
1917
|
+
} else {
|
|
1918
|
+
setEditValue(props.value);
|
|
1919
|
+
}
|
|
1920
|
+
};
|
|
1921
|
+
const handleKeyDown = (e) => {
|
|
1922
|
+
if (e.key === "Enter") handleTextSubmit();
|
|
1923
|
+
else if (e.key === "Escape") {
|
|
1924
|
+
setIsEditing(false);
|
|
1925
|
+
setEditValue(props.value);
|
|
1926
|
+
}
|
|
1927
|
+
};
|
|
1928
|
+
return (() => {
|
|
1929
|
+
var _el$ = _tmpl$26(), _el$2 = _el$.firstChild, _el$3 = _el$2.nextSibling, _el$5 = _el$3.firstChild, _el$6 = _el$5.nextSibling;
|
|
1930
|
+
(0, import_web61.setAttribute)(_el$2, "for", textInputId);
|
|
1931
|
+
(0, import_web60.insert)(_el$2, () => props.label);
|
|
1932
|
+
(0, import_web60.insert)(_el$3, (0, import_web58.createComponent)(import_solid_js8.Show, {
|
|
1933
|
+
get when() {
|
|
1934
|
+
return isEditing();
|
|
1935
|
+
},
|
|
1936
|
+
get fallback() {
|
|
1937
|
+
return (() => {
|
|
1938
|
+
var _el$7 = _tmpl$35();
|
|
1939
|
+
_el$7.$$click = () => setIsEditing(true);
|
|
1940
|
+
(0, import_web60.insert)(_el$7, () => (props.value ?? "").toUpperCase());
|
|
1941
|
+
return _el$7;
|
|
1942
|
+
})();
|
|
1943
|
+
},
|
|
1944
|
+
get children() {
|
|
1945
|
+
var _el$4 = _tmpl$16();
|
|
1946
|
+
_el$4.$$keydown = handleKeyDown;
|
|
1947
|
+
_el$4.addEventListener("blur", handleTextSubmit);
|
|
1948
|
+
_el$4.$$input = (e) => setEditValue(e.currentTarget.value);
|
|
1949
|
+
(0, import_web61.setAttribute)(_el$4, "id", textInputId);
|
|
1950
|
+
(0, import_web59.effect)(() => _el$4.value = editValue());
|
|
1951
|
+
return _el$4;
|
|
1952
|
+
}
|
|
1953
|
+
}), _el$5);
|
|
1954
|
+
_el$5.$$click = () => colorInputRef?.click();
|
|
1955
|
+
_el$6.$$input = (e) => props.onChange(e.currentTarget.value);
|
|
1956
|
+
var _ref$ = colorInputRef;
|
|
1957
|
+
typeof _ref$ === "function" ? (0, import_web57.use)(_ref$, _el$6) : colorInputRef = _el$6;
|
|
1958
|
+
(0, import_web59.effect)((_p$) => {
|
|
1959
|
+
var _v$ = props.value, _v$2 = `Pick color for ${props.label}`, _v$3 = `${props.label} color picker`;
|
|
1960
|
+
_v$ !== _p$.e && (0, import_web56.setStyleProperty)(_el$5, "background-color", _p$.e = _v$);
|
|
1961
|
+
_v$2 !== _p$.t && (0, import_web61.setAttribute)(_el$5, "aria-label", _p$.t = _v$2);
|
|
1962
|
+
_v$3 !== _p$.a && (0, import_web61.setAttribute)(_el$6, "aria-label", _p$.a = _v$3);
|
|
1963
|
+
return _p$;
|
|
1964
|
+
}, {
|
|
1965
|
+
e: void 0,
|
|
1966
|
+
t: void 0,
|
|
1967
|
+
a: void 0
|
|
1968
|
+
});
|
|
1969
|
+
(0, import_web59.effect)(() => _el$6.value = props.value.length === 4 ? expandShorthandHex(props.value) : props.value.slice(0, 7));
|
|
1970
|
+
return _el$;
|
|
1971
|
+
})();
|
|
1972
|
+
}
|
|
1973
|
+
(0, import_web55.delegateEvents)(["input", "keydown", "click"]);
|
|
1974
|
+
|
|
1975
|
+
// src/solid/components/PresetManager.tsx
|
|
1976
|
+
var import_web62 = require("solid-js/web");
|
|
1977
|
+
var import_web63 = require("solid-js/web");
|
|
1978
|
+
var import_web64 = require("solid-js/web");
|
|
1979
|
+
var import_web65 = require("solid-js/web");
|
|
1980
|
+
var import_web66 = require("solid-js/web");
|
|
1981
|
+
var import_web67 = require("solid-js/web");
|
|
1982
|
+
var import_web68 = require("solid-js/web");
|
|
1983
|
+
var import_web69 = require("solid-js/web");
|
|
1984
|
+
var import_web70 = require("solid-js/web");
|
|
1985
|
+
var import_solid_js9 = require("solid-js");
|
|
1986
|
+
var import_web71 = require("solid-js/web");
|
|
1987
|
+
var import_motion5 = require("motion");
|
|
1988
|
+
var _tmpl$17 = /* @__PURE__ */ (0, import_web62.template)(`<div class="dialkit-root dialkit-preset-dropdown"style=position:fixed><div class=dialkit-preset-item><span class=dialkit-preset-name>Version 1`);
|
|
1989
|
+
var _tmpl$27 = /* @__PURE__ */ (0, import_web62.template)(`<div class=dialkit-preset-manager><button class=dialkit-preset-trigger><span class=dialkit-preset-label></span><svg class=dialkit-select-chevron viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=2.5 stroke-linecap=round stroke-linejoin=round><path d="M6 9.5L12 15.5L18 9.5">`);
|
|
1990
|
+
var _tmpl$36 = /* @__PURE__ */ (0, import_web62.template)(`<div class=dialkit-preset-item><span class=dialkit-preset-name></span><button class=dialkit-preset-delete title="Delete preset"><svg viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round><path d="M5 6.5L5.80734 18.2064C5.91582 19.7794 7.22348 21 8.80023 21H15.1998C16.7765 21 18.0842 19.7794 18.1927 18.2064L19 6.5"></path><path d="M10 11V16"></path><path d="M14 11V16"></path><path d="M3.5 6H20.5"></path><path d="M8.07092 5.74621C8.42348 3.89745 10.0485 2.5 12 2.5C13.9515 2.5 15.5765 3.89745 15.9291 5.74621">`);
|
|
1991
|
+
function PresetManager(props) {
|
|
1992
|
+
const [isOpen, setIsOpen] = (0, import_solid_js9.createSignal)(false);
|
|
1993
|
+
const [mounted, setMounted] = (0, import_solid_js9.createSignal)(false);
|
|
1994
|
+
const [pos, setPos] = (0, import_solid_js9.createSignal)({
|
|
1995
|
+
top: 0,
|
|
1996
|
+
left: 0,
|
|
1997
|
+
width: 0
|
|
1998
|
+
});
|
|
1999
|
+
const [portalTarget, setPortalTarget] = (0, import_solid_js9.createSignal)(null);
|
|
2000
|
+
let triggerRef;
|
|
2001
|
+
let dropdownRef;
|
|
2002
|
+
let chevronRef;
|
|
2003
|
+
let closeAnim = null;
|
|
2004
|
+
let chevronAnim = null;
|
|
2005
|
+
const hasPresets = () => props.presets.length > 0;
|
|
2006
|
+
const activePreset = () => props.presets.find((p) => p.id === props.activePresetId);
|
|
2007
|
+
(0, import_solid_js9.onMount)(() => {
|
|
2008
|
+
const root = triggerRef?.closest(".dialkit-root");
|
|
2009
|
+
setPortalTarget(root ?? document.body);
|
|
2010
|
+
if (chevronRef) {
|
|
2011
|
+
chevronRef.style.transform = `rotate(${isOpen() ? 180 : 0}deg)`;
|
|
2012
|
+
chevronRef.style.opacity = String(hasPresets() ? 0.6 : 0.25);
|
|
2013
|
+
}
|
|
2014
|
+
(0, import_solid_js9.onCleanup)(() => {
|
|
2015
|
+
closeAnim?.stop();
|
|
2016
|
+
chevronAnim?.stop();
|
|
2017
|
+
});
|
|
2018
|
+
});
|
|
2019
|
+
(0, import_solid_js9.createEffect)(() => {
|
|
2020
|
+
if (!chevronRef) return;
|
|
2021
|
+
const open = isOpen();
|
|
2022
|
+
const has = hasPresets();
|
|
2023
|
+
chevronAnim?.stop();
|
|
2024
|
+
chevronAnim = (0, import_motion5.animate)(chevronRef, {
|
|
2025
|
+
rotate: open ? 180 : 0,
|
|
2026
|
+
opacity: has ? 0.6 : 0.25
|
|
2027
|
+
}, {
|
|
2028
|
+
type: "spring",
|
|
2029
|
+
visualDuration: 0.2,
|
|
2030
|
+
bounce: 0.15
|
|
2031
|
+
});
|
|
2032
|
+
});
|
|
2033
|
+
const updatePos = () => {
|
|
2034
|
+
const rect = triggerRef?.getBoundingClientRect();
|
|
2035
|
+
if (!rect) return;
|
|
2036
|
+
setPos({
|
|
2037
|
+
top: rect.bottom + 4,
|
|
2038
|
+
left: rect.left,
|
|
2039
|
+
width: rect.width
|
|
2040
|
+
});
|
|
2041
|
+
};
|
|
2042
|
+
const openDropdown = () => {
|
|
2043
|
+
if (!hasPresets()) return;
|
|
2044
|
+
updatePos();
|
|
2045
|
+
closeAnim?.stop();
|
|
2046
|
+
closeAnim = null;
|
|
2047
|
+
setMounted(true);
|
|
2048
|
+
setIsOpen(true);
|
|
2049
|
+
};
|
|
2050
|
+
const closeDropdown = () => {
|
|
2051
|
+
setIsOpen(false);
|
|
2052
|
+
if (!dropdownRef) {
|
|
2053
|
+
setMounted(false);
|
|
2054
|
+
return;
|
|
2055
|
+
}
|
|
2056
|
+
closeAnim?.stop();
|
|
2057
|
+
closeAnim = (0, import_motion5.animate)(dropdownRef, {
|
|
2058
|
+
opacity: 0,
|
|
2059
|
+
y: 4,
|
|
2060
|
+
scale: 0.97
|
|
2061
|
+
}, {
|
|
2062
|
+
type: "spring",
|
|
2063
|
+
visualDuration: 0.15,
|
|
2064
|
+
bounce: 0,
|
|
2065
|
+
onComplete: () => {
|
|
2066
|
+
setMounted(false);
|
|
2067
|
+
closeAnim = null;
|
|
2068
|
+
}
|
|
2069
|
+
});
|
|
2070
|
+
};
|
|
2071
|
+
const toggle = () => {
|
|
2072
|
+
if (isOpen()) closeDropdown();
|
|
2073
|
+
else openDropdown();
|
|
2074
|
+
};
|
|
2075
|
+
(0, import_solid_js9.createEffect)(() => {
|
|
2076
|
+
if (!isOpen()) return;
|
|
2077
|
+
const handleViewportChange = () => updatePos();
|
|
2078
|
+
const handler = (e) => {
|
|
2079
|
+
const target = e.target;
|
|
2080
|
+
if (triggerRef?.contains(target) || dropdownRef?.contains(target)) return;
|
|
2081
|
+
closeDropdown();
|
|
2082
|
+
};
|
|
2083
|
+
updatePos();
|
|
2084
|
+
document.addEventListener("mousedown", handler);
|
|
2085
|
+
window.addEventListener("resize", handleViewportChange);
|
|
2086
|
+
window.addEventListener("scroll", handleViewportChange, true);
|
|
2087
|
+
(0, import_solid_js9.onCleanup)(() => {
|
|
2088
|
+
document.removeEventListener("mousedown", handler);
|
|
2089
|
+
window.removeEventListener("resize", handleViewportChange);
|
|
2090
|
+
window.removeEventListener("scroll", handleViewportChange, true);
|
|
2091
|
+
});
|
|
2092
|
+
});
|
|
2093
|
+
const handleSelect = (presetId) => {
|
|
2094
|
+
if (presetId) DialStore.loadPreset(props.panelId, presetId);
|
|
2095
|
+
else DialStore.clearActivePreset(props.panelId);
|
|
2096
|
+
closeDropdown();
|
|
2097
|
+
};
|
|
2098
|
+
const handleDelete = (e, presetId) => {
|
|
2099
|
+
e.stopPropagation();
|
|
2100
|
+
DialStore.deletePreset(props.panelId, presetId);
|
|
2101
|
+
};
|
|
2102
|
+
return (() => {
|
|
2103
|
+
var _el$ = _tmpl$27(), _el$2 = _el$.firstChild, _el$3 = _el$2.firstChild, _el$4 = _el$3.nextSibling;
|
|
2104
|
+
_el$2.$$click = toggle;
|
|
2105
|
+
var _ref$ = triggerRef;
|
|
2106
|
+
typeof _ref$ === "function" ? (0, import_web70.use)(_ref$, _el$2) : triggerRef = _el$2;
|
|
2107
|
+
(0, import_web68.insert)(_el$3, (() => {
|
|
2108
|
+
var _c$ = (0, import_web69.memo)(() => !!activePreset());
|
|
2109
|
+
return () => _c$() ? activePreset().name : "Version 1";
|
|
2110
|
+
})());
|
|
2111
|
+
var _ref$2 = chevronRef;
|
|
2112
|
+
typeof _ref$2 === "function" ? (0, import_web70.use)(_ref$2, _el$4) : chevronRef = _el$4;
|
|
2113
|
+
(0, import_web68.insert)(_el$, (0, import_web67.createComponent)(import_solid_js9.Show, {
|
|
2114
|
+
get when() {
|
|
2115
|
+
return !!portalTarget();
|
|
2116
|
+
},
|
|
2117
|
+
get children() {
|
|
2118
|
+
return (0, import_web67.createComponent)(import_web71.Portal, {
|
|
2119
|
+
get mount() {
|
|
2120
|
+
return portalTarget();
|
|
2121
|
+
},
|
|
2122
|
+
get children() {
|
|
2123
|
+
return (0, import_web67.createComponent)(import_solid_js9.Show, {
|
|
2124
|
+
get when() {
|
|
2125
|
+
return mounted();
|
|
2126
|
+
},
|
|
2127
|
+
get children() {
|
|
2128
|
+
var _el$5 = _tmpl$17(), _el$6 = _el$5.firstChild;
|
|
2129
|
+
(0, import_web70.use)((el) => {
|
|
2130
|
+
dropdownRef = el;
|
|
2131
|
+
(0, import_motion5.animate)(el, {
|
|
2132
|
+
opacity: [0, 1],
|
|
2133
|
+
y: [4, 0],
|
|
2134
|
+
scale: [0.97, 1]
|
|
2135
|
+
}, {
|
|
2136
|
+
type: "spring",
|
|
2137
|
+
visualDuration: 0.15,
|
|
2138
|
+
bounce: 0
|
|
2139
|
+
});
|
|
2140
|
+
}, _el$5);
|
|
2141
|
+
_el$6.$$click = () => handleSelect(null);
|
|
2142
|
+
(0, import_web68.insert)(_el$5, (0, import_web67.createComponent)(import_solid_js9.For, {
|
|
2143
|
+
get each() {
|
|
2144
|
+
return props.presets;
|
|
2145
|
+
},
|
|
2146
|
+
children: (preset) => (() => {
|
|
2147
|
+
var _el$7 = _tmpl$36(), _el$8 = _el$7.firstChild, _el$9 = _el$8.nextSibling;
|
|
2148
|
+
_el$7.$$click = () => handleSelect(preset.id);
|
|
2149
|
+
(0, import_web68.insert)(_el$8, () => preset.name);
|
|
2150
|
+
_el$9.$$click = (e) => handleDelete(e, preset.id);
|
|
2151
|
+
(0, import_web66.effect)(() => (0, import_web64.setAttribute)(_el$7, "data-active", String(preset.id === props.activePresetId)));
|
|
2152
|
+
return _el$7;
|
|
2153
|
+
})()
|
|
2154
|
+
}), null);
|
|
2155
|
+
(0, import_web66.effect)((_p$) => {
|
|
2156
|
+
var _v$ = `${pos().top}px`, _v$2 = `${pos().left}px`, _v$3 = `${pos().width}px`, _v$4 = String(!props.activePresetId);
|
|
2157
|
+
_v$ !== _p$.e && (0, import_web65.setStyleProperty)(_el$5, "top", _p$.e = _v$);
|
|
2158
|
+
_v$2 !== _p$.t && (0, import_web65.setStyleProperty)(_el$5, "left", _p$.t = _v$2);
|
|
2159
|
+
_v$3 !== _p$.a && (0, import_web65.setStyleProperty)(_el$5, "min-width", _p$.a = _v$3);
|
|
2160
|
+
_v$4 !== _p$.o && (0, import_web64.setAttribute)(_el$6, "data-active", _p$.o = _v$4);
|
|
2161
|
+
return _p$;
|
|
2162
|
+
}, {
|
|
2163
|
+
e: void 0,
|
|
2164
|
+
t: void 0,
|
|
2165
|
+
a: void 0,
|
|
2166
|
+
o: void 0
|
|
2167
|
+
});
|
|
2168
|
+
return _el$5;
|
|
2169
|
+
}
|
|
2170
|
+
});
|
|
2171
|
+
}
|
|
2172
|
+
});
|
|
2173
|
+
}
|
|
2174
|
+
}), null);
|
|
2175
|
+
(0, import_web66.effect)((_p$) => {
|
|
2176
|
+
var _v$5 = String(isOpen()), _v$6 = String(!!activePreset()), _v$7 = String(!hasPresets());
|
|
2177
|
+
_v$5 !== _p$.e && (0, import_web64.setAttribute)(_el$2, "data-open", _p$.e = _v$5);
|
|
2178
|
+
_v$6 !== _p$.t && (0, import_web64.setAttribute)(_el$2, "data-has-preset", _p$.t = _v$6);
|
|
2179
|
+
_v$7 !== _p$.a && (0, import_web64.setAttribute)(_el$2, "data-disabled", _p$.a = _v$7);
|
|
2180
|
+
return _p$;
|
|
2181
|
+
}, {
|
|
2182
|
+
e: void 0,
|
|
2183
|
+
t: void 0,
|
|
2184
|
+
a: void 0
|
|
2185
|
+
});
|
|
2186
|
+
return _el$;
|
|
2187
|
+
})();
|
|
2188
|
+
}
|
|
2189
|
+
(0, import_web63.delegateEvents)(["click"]);
|
|
2190
|
+
|
|
2191
|
+
// src/solid/components/Panel.tsx
|
|
2192
|
+
var _tmpl$18 = /* @__PURE__ */ (0, import_web72.template)(`<button class=dialkit-button>`);
|
|
2193
|
+
var _tmpl$28 = /* @__PURE__ */ (0, import_web72.template)(`<button class=dialkit-toolbar-add title="Add preset"><svg viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=2.5 stroke-linecap=round stroke-linejoin=round><path d="M4 6H20"></path><path d="M4 12H10"></path><path d="M15 15L21 15"></path><path d="M18 12V18"></path><path d="M4 18H10">`);
|
|
2194
|
+
var _tmpl$37 = /* @__PURE__ */ (0, import_web72.template)(`<button class=dialkit-toolbar-copy title="Copy parameters"><span class=dialkit-toolbar-copy-icon-wrap><span class=dialkit-toolbar-copy-icon style=opacity:1;transform:scale(1);filter:blur(0px)><svg viewBox="0 0 24 24"fill=none width=16 height=16><path d="M8 6C8 4.34315 9.34315 3 11 3H13C14.6569 3 16 4.34315 16 6V7H8V6Z"stroke=currentColor stroke-width=2 stroke-linejoin=round></path><path d="M19.2405 16.1852L18.5436 14.3733C18.4571 14.1484 18.241 14 18 14C17.759 14 17.5429 14.1484 17.4564 14.3733L16.7595 16.1852C16.658 16.4493 16.4493 16.658 16.1852 16.7595L14.3733 17.4564C14.1484 17.5429 14 17.759 14 18C14 18.241 14.1484 18.4571 14.3733 18.5436L16.1852 19.2405C16.4493 19.342 16.658 19.5507 16.7595 19.8148L17.4564 21.6267C17.5429 21.8516 17.759 22 18 22C18.241 22 18.4571 21.8516 18.5436 21.6267L19.2405 19.8148C19.342 19.5507 19.5507 19.342 19.8148 19.2405L21.6267 18.5436C21.8516 18.4571 22 18.241 22 18C22 17.759 21.8516 17.5429 21.6267 17.4564L19.8148 16.7595C19.5507 16.658 19.342 16.4493 19.2405 16.1852Z"fill=currentColor></path><path d="M16 5H17C18.6569 5 20 6.34315 20 8V11M8 5H7C5.34315 5 4 6.34315 4 8V18C4 19.6569 5.34315 21 7 21H12"stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round></path></svg></span><span class=dialkit-toolbar-copy-icon style=opacity:0;transform:scale(0.5);filter:blur(4px)><svg viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round width=16 height=16><path d="M5 12.75L10 19L19 5"></path></svg></span></span>Copy`);
|
|
2195
|
+
var _tmpl$43 = /* @__PURE__ */ (0, import_web72.template)(`<div class=dialkit-panel-wrapper>`);
|
|
2196
|
+
function Panel(props) {
|
|
2197
|
+
const [copied, setCopied] = (0, import_solid_js10.createSignal)(false);
|
|
2198
|
+
const [isPanelOpen, setIsPanelOpen] = (0, import_solid_js10.createSignal)(props.defaultOpen ?? true);
|
|
2199
|
+
const [values, setValues] = (0, import_solid_js10.createSignal)(DialStore.getValues(props.panel.id));
|
|
2200
|
+
const [presets, setPresets] = (0, import_solid_js10.createSignal)(DialStore.getPresets(props.panel.id));
|
|
2201
|
+
const [activePresetId, setActivePresetId] = (0, import_solid_js10.createSignal)(DialStore.getActivePresetId(props.panel.id));
|
|
2202
|
+
let addButtonRef;
|
|
2203
|
+
let copyButtonRef;
|
|
2204
|
+
let copyClipboardIconRef;
|
|
2205
|
+
let copyCheckIconRef;
|
|
2206
|
+
let addTapAnim = null;
|
|
2207
|
+
let copyTapAnim = null;
|
|
2208
|
+
let copyClipboardAnim = null;
|
|
2209
|
+
let copyCheckAnim = null;
|
|
2210
|
+
let didInitCopyIcons = false;
|
|
2211
|
+
const tapTransition = {
|
|
2212
|
+
type: "spring",
|
|
2213
|
+
visualDuration: 0.15,
|
|
2214
|
+
bounce: 0.3
|
|
2215
|
+
};
|
|
2216
|
+
(0, import_solid_js10.onMount)(() => {
|
|
2217
|
+
const unsub = DialStore.subscribe(props.panel.id, () => {
|
|
2218
|
+
setValues(DialStore.getValues(props.panel.id));
|
|
2219
|
+
setPresets(DialStore.getPresets(props.panel.id));
|
|
2220
|
+
setActivePresetId(DialStore.getActivePresetId(props.panel.id));
|
|
2221
|
+
});
|
|
2222
|
+
if (copyClipboardIconRef && copyCheckIconRef) {
|
|
2223
|
+
copyClipboardIconRef.style.transformOrigin = "50% 50%";
|
|
2224
|
+
copyClipboardIconRef.style.opacity = "1";
|
|
2225
|
+
copyClipboardIconRef.style.transform = "scale(1)";
|
|
2226
|
+
copyClipboardIconRef.style.filter = "blur(0px)";
|
|
2227
|
+
copyCheckIconRef.style.transformOrigin = "50% 50%";
|
|
2228
|
+
copyCheckIconRef.style.opacity = "0";
|
|
2229
|
+
copyCheckIconRef.style.transform = "scale(0.5)";
|
|
2230
|
+
copyCheckIconRef.style.filter = "blur(4px)";
|
|
2231
|
+
didInitCopyIcons = true;
|
|
2232
|
+
}
|
|
2233
|
+
(0, import_solid_js10.onCleanup)(unsub);
|
|
2234
|
+
});
|
|
2235
|
+
const handleAddPreset = () => {
|
|
2236
|
+
const nextNum = presets().length + 2;
|
|
2237
|
+
DialStore.savePreset(props.panel.id, `Version ${nextNum}`);
|
|
2238
|
+
};
|
|
2239
|
+
const handleCopy = () => {
|
|
2240
|
+
const jsonStr = JSON.stringify(values(), null, 2);
|
|
2241
|
+
const instruction = `Update the createDialKit configuration for "${props.panel.name}" with these values:
|
|
2242
|
+
|
|
2243
|
+
\`\`\`json
|
|
2244
|
+
${jsonStr}
|
|
2245
|
+
\`\`\`
|
|
2246
|
+
|
|
2247
|
+
Apply these values as the new defaults in the createDialKit call.`;
|
|
2248
|
+
navigator.clipboard.writeText(instruction);
|
|
2249
|
+
setCopied(true);
|
|
2250
|
+
setTimeout(() => setCopied(false), 1500);
|
|
2251
|
+
};
|
|
2252
|
+
(0, import_solid_js10.createEffect)(() => {
|
|
2253
|
+
const isCopied = copied();
|
|
2254
|
+
if (!copyClipboardIconRef || !copyCheckIconRef) return;
|
|
2255
|
+
copyClipboardAnim?.stop();
|
|
2256
|
+
copyCheckAnim?.stop();
|
|
2257
|
+
if (!didInitCopyIcons) return;
|
|
2258
|
+
const transition = {
|
|
2259
|
+
type: "spring",
|
|
2260
|
+
visualDuration: 0.3,
|
|
2261
|
+
bounce: 0.2
|
|
2262
|
+
};
|
|
2263
|
+
copyClipboardAnim = (0, import_motion6.animate)(copyClipboardIconRef, {
|
|
2264
|
+
opacity: isCopied ? 0 : 1,
|
|
2265
|
+
scale: isCopied ? 0.5 : 1,
|
|
2266
|
+
filter: isCopied ? "blur(4px)" : "blur(0px)"
|
|
2267
|
+
}, transition);
|
|
2268
|
+
copyCheckAnim = (0, import_motion6.animate)(copyCheckIconRef, {
|
|
2269
|
+
opacity: isCopied ? 1 : 0,
|
|
2270
|
+
scale: isCopied ? 1 : 0.5,
|
|
2271
|
+
filter: isCopied ? "blur(0px)" : "blur(4px)"
|
|
2272
|
+
}, transition);
|
|
2273
|
+
});
|
|
2274
|
+
(0, import_solid_js10.onCleanup)(() => {
|
|
2275
|
+
addTapAnim?.stop();
|
|
2276
|
+
copyTapAnim?.stop();
|
|
2277
|
+
copyClipboardAnim?.stop();
|
|
2278
|
+
copyCheckAnim?.stop();
|
|
2279
|
+
});
|
|
2280
|
+
const handleAddTapStart = () => {
|
|
2281
|
+
if (!addButtonRef) return;
|
|
2282
|
+
addTapAnim?.stop();
|
|
2283
|
+
addTapAnim = (0, import_motion6.animate)(addButtonRef, {
|
|
2284
|
+
scale: 0.9
|
|
2285
|
+
}, tapTransition);
|
|
2286
|
+
};
|
|
2287
|
+
const handleAddTapEnd = () => {
|
|
2288
|
+
if (!addButtonRef) return;
|
|
2289
|
+
addTapAnim?.stop();
|
|
2290
|
+
addTapAnim = (0, import_motion6.animate)(addButtonRef, {
|
|
2291
|
+
scale: 1
|
|
2292
|
+
}, tapTransition);
|
|
2293
|
+
};
|
|
2294
|
+
const handleCopyTapStart = () => {
|
|
2295
|
+
if (!copyButtonRef) return;
|
|
2296
|
+
copyTapAnim?.stop();
|
|
2297
|
+
copyTapAnim = (0, import_motion6.animate)(copyButtonRef, {
|
|
2298
|
+
scale: 0.95
|
|
2299
|
+
}, tapTransition);
|
|
2300
|
+
};
|
|
2301
|
+
const handleCopyTapEnd = () => {
|
|
2302
|
+
if (!copyButtonRef) return;
|
|
2303
|
+
copyTapAnim?.stop();
|
|
2304
|
+
copyTapAnim = (0, import_motion6.animate)(copyButtonRef, {
|
|
2305
|
+
scale: 1
|
|
2306
|
+
}, tapTransition);
|
|
2307
|
+
};
|
|
2308
|
+
const renderControl = (control) => {
|
|
2309
|
+
const value = () => values()[control.path];
|
|
2310
|
+
switch (control.type) {
|
|
2311
|
+
case "slider":
|
|
2312
|
+
return (0, import_web77.createComponent)(Slider, {
|
|
2313
|
+
get label() {
|
|
2314
|
+
return control.label;
|
|
2315
|
+
},
|
|
2316
|
+
get value() {
|
|
2317
|
+
return value();
|
|
2318
|
+
},
|
|
2319
|
+
onChange: (v) => DialStore.updateValue(props.panel.id, control.path, v),
|
|
2320
|
+
get min() {
|
|
2321
|
+
return control.min;
|
|
2322
|
+
},
|
|
2323
|
+
get max() {
|
|
2324
|
+
return control.max;
|
|
2325
|
+
},
|
|
2326
|
+
get step() {
|
|
2327
|
+
return control.step;
|
|
2328
|
+
}
|
|
2329
|
+
});
|
|
2330
|
+
case "toggle":
|
|
2331
|
+
return (0, import_web77.createComponent)(Toggle, {
|
|
2332
|
+
get label() {
|
|
2333
|
+
return control.label;
|
|
2334
|
+
},
|
|
2335
|
+
get checked() {
|
|
2336
|
+
return value();
|
|
2337
|
+
},
|
|
2338
|
+
onChange: (v) => DialStore.updateValue(props.panel.id, control.path, v)
|
|
2339
|
+
});
|
|
2340
|
+
case "spring":
|
|
2341
|
+
return (0, import_web77.createComponent)(SpringControl, {
|
|
2342
|
+
get panelId() {
|
|
2343
|
+
return props.panel.id;
|
|
2344
|
+
},
|
|
2345
|
+
get path() {
|
|
2346
|
+
return control.path;
|
|
2347
|
+
},
|
|
2348
|
+
get label() {
|
|
2349
|
+
return control.label;
|
|
2350
|
+
},
|
|
2351
|
+
get spring() {
|
|
2352
|
+
return value();
|
|
2353
|
+
},
|
|
2354
|
+
onChange: (v) => DialStore.updateValue(props.panel.id, control.path, v)
|
|
2355
|
+
});
|
|
2356
|
+
case "folder":
|
|
2357
|
+
return (0, import_web77.createComponent)(Folder, {
|
|
2358
|
+
get title() {
|
|
2359
|
+
return control.label;
|
|
2360
|
+
},
|
|
2361
|
+
get defaultOpen() {
|
|
2362
|
+
return control.defaultOpen ?? true;
|
|
2363
|
+
},
|
|
2364
|
+
get children() {
|
|
2365
|
+
return (0, import_web77.createComponent)(import_solid_js10.For, {
|
|
2366
|
+
get each() {
|
|
2367
|
+
return control.children ?? [];
|
|
2368
|
+
},
|
|
2369
|
+
children: (child) => (0, import_web76.memo)(() => renderControl(child))
|
|
2370
|
+
});
|
|
2371
|
+
}
|
|
2372
|
+
});
|
|
2373
|
+
case "text":
|
|
2374
|
+
return (0, import_web77.createComponent)(TextControl, {
|
|
2375
|
+
get label() {
|
|
2376
|
+
return control.label;
|
|
2377
|
+
},
|
|
2378
|
+
get value() {
|
|
2379
|
+
return value();
|
|
2380
|
+
},
|
|
2381
|
+
onChange: (v) => DialStore.updateValue(props.panel.id, control.path, v),
|
|
2382
|
+
get placeholder() {
|
|
2383
|
+
return control.placeholder;
|
|
2384
|
+
}
|
|
2385
|
+
});
|
|
2386
|
+
case "select":
|
|
2387
|
+
return (0, import_web77.createComponent)(SelectControl, {
|
|
2388
|
+
get label() {
|
|
2389
|
+
return control.label;
|
|
2390
|
+
},
|
|
2391
|
+
get value() {
|
|
2392
|
+
return value();
|
|
2393
|
+
},
|
|
2394
|
+
get options() {
|
|
2395
|
+
return control.options ?? [];
|
|
2396
|
+
},
|
|
2397
|
+
onChange: (v) => DialStore.updateValue(props.panel.id, control.path, v)
|
|
2398
|
+
});
|
|
2399
|
+
case "color":
|
|
2400
|
+
return (0, import_web77.createComponent)(ColorControl, {
|
|
2401
|
+
get label() {
|
|
2402
|
+
return control.label;
|
|
2403
|
+
},
|
|
2404
|
+
get value() {
|
|
2405
|
+
return value();
|
|
2406
|
+
},
|
|
2407
|
+
onChange: (v) => DialStore.updateValue(props.panel.id, control.path, v)
|
|
2408
|
+
});
|
|
2409
|
+
default:
|
|
2410
|
+
return null;
|
|
2411
|
+
}
|
|
2412
|
+
};
|
|
2413
|
+
const renderControls = () => {
|
|
2414
|
+
return (0, import_web77.createComponent)(import_solid_js10.For, {
|
|
2415
|
+
get each() {
|
|
2416
|
+
return props.panel.controls;
|
|
2417
|
+
},
|
|
2418
|
+
children: (control) => (0, import_web76.memo)(() => (0, import_web76.memo)(() => control.type === "action")() ? (() => {
|
|
2419
|
+
var _el$ = _tmpl$18();
|
|
2420
|
+
_el$.$$click = () => DialStore.triggerAction(props.panel.id, control.path);
|
|
2421
|
+
(0, import_web75.insert)(_el$, () => control.label);
|
|
2422
|
+
return _el$;
|
|
2423
|
+
})() : renderControl(control))
|
|
2424
|
+
});
|
|
2425
|
+
};
|
|
2426
|
+
const toolbar = [(() => {
|
|
2427
|
+
var _el$2 = _tmpl$28();
|
|
2428
|
+
_el$2.addEventListener("pointerleave", handleAddTapEnd);
|
|
2429
|
+
_el$2.addEventListener("pointercancel", handleAddTapEnd);
|
|
2430
|
+
_el$2.$$pointerup = handleAddTapEnd;
|
|
2431
|
+
_el$2.$$pointerdown = handleAddTapStart;
|
|
2432
|
+
_el$2.$$click = handleAddPreset;
|
|
2433
|
+
var _ref$ = addButtonRef;
|
|
2434
|
+
typeof _ref$ === "function" ? (0, import_web74.use)(_ref$, _el$2) : addButtonRef = _el$2;
|
|
2435
|
+
return _el$2;
|
|
2436
|
+
})(), (0, import_web77.createComponent)(PresetManager, {
|
|
2437
|
+
get panelId() {
|
|
2438
|
+
return props.panel.id;
|
|
2439
|
+
},
|
|
2440
|
+
get presets() {
|
|
2441
|
+
return presets();
|
|
2442
|
+
},
|
|
2443
|
+
get activePresetId() {
|
|
2444
|
+
return activePresetId();
|
|
2445
|
+
},
|
|
2446
|
+
onAdd: handleAddPreset
|
|
2447
|
+
}), (() => {
|
|
2448
|
+
var _el$3 = _tmpl$37(), _el$4 = _el$3.firstChild, _el$5 = _el$4.firstChild, _el$6 = _el$5.nextSibling;
|
|
2449
|
+
_el$3.addEventListener("pointerleave", handleCopyTapEnd);
|
|
2450
|
+
_el$3.addEventListener("pointercancel", handleCopyTapEnd);
|
|
2451
|
+
_el$3.$$pointerup = handleCopyTapEnd;
|
|
2452
|
+
_el$3.$$pointerdown = handleCopyTapStart;
|
|
2453
|
+
_el$3.$$click = handleCopy;
|
|
2454
|
+
var _ref$2 = copyButtonRef;
|
|
2455
|
+
typeof _ref$2 === "function" ? (0, import_web74.use)(_ref$2, _el$3) : copyButtonRef = _el$3;
|
|
2456
|
+
var _ref$3 = copyClipboardIconRef;
|
|
2457
|
+
typeof _ref$3 === "function" ? (0, import_web74.use)(_ref$3, _el$5) : copyClipboardIconRef = _el$5;
|
|
2458
|
+
var _ref$4 = copyCheckIconRef;
|
|
2459
|
+
typeof _ref$4 === "function" ? (0, import_web74.use)(_ref$4, _el$6) : copyCheckIconRef = _el$6;
|
|
2460
|
+
return _el$3;
|
|
2461
|
+
})()];
|
|
2462
|
+
return (() => {
|
|
2463
|
+
var _el$7 = _tmpl$43();
|
|
2464
|
+
(0, import_web75.insert)(_el$7, (0, import_web77.createComponent)(Folder, {
|
|
2465
|
+
get title() {
|
|
2466
|
+
return props.panel.name;
|
|
2467
|
+
},
|
|
2468
|
+
get defaultOpen() {
|
|
2469
|
+
return props.defaultOpen ?? true;
|
|
2470
|
+
},
|
|
2471
|
+
isRoot: true,
|
|
2472
|
+
onOpenChange: setIsPanelOpen,
|
|
2473
|
+
toolbar,
|
|
2474
|
+
get children() {
|
|
2475
|
+
return renderControls();
|
|
2476
|
+
}
|
|
2477
|
+
}));
|
|
2478
|
+
return _el$7;
|
|
2479
|
+
})();
|
|
2480
|
+
}
|
|
2481
|
+
(0, import_web73.delegateEvents)(["click", "pointerdown", "pointerup"]);
|
|
2482
|
+
|
|
2483
|
+
// src/solid/components/DialRoot.tsx
|
|
2484
|
+
var _tmpl$19 = /* @__PURE__ */ (0, import_web78.template)(`<div class=dialkit-root><div class=dialkit-panel>`);
|
|
2485
|
+
function DialRoot(props) {
|
|
2486
|
+
const [panels, setPanels] = (0, import_solid_js11.createSignal)([]);
|
|
2487
|
+
const [mounted, setMounted] = (0, import_solid_js11.createSignal)(false);
|
|
2488
|
+
(0, import_solid_js11.onMount)(() => {
|
|
2489
|
+
setMounted(true);
|
|
2490
|
+
setPanels(DialStore.getPanels());
|
|
2491
|
+
const unsub = DialStore.subscribeGlobal(() => {
|
|
2492
|
+
setPanels(DialStore.getPanels());
|
|
2493
|
+
});
|
|
2494
|
+
(0, import_solid_js11.onCleanup)(unsub);
|
|
2495
|
+
});
|
|
2496
|
+
return (0, import_web82.createComponent)(import_solid_js11.Show, {
|
|
2497
|
+
get when() {
|
|
2498
|
+
return (0, import_web83.memo)(() => !!(mounted() && typeof window !== "undefined"))() && panels().length > 0;
|
|
2499
|
+
},
|
|
2500
|
+
get children() {
|
|
2501
|
+
return (0, import_web82.createComponent)(import_web84.Portal, {
|
|
2502
|
+
get mount() {
|
|
2503
|
+
return document.body;
|
|
2504
|
+
},
|
|
2505
|
+
get children() {
|
|
2506
|
+
var _el$ = _tmpl$19(), _el$2 = _el$.firstChild;
|
|
2507
|
+
(0, import_web81.insert)(_el$2, (0, import_web82.createComponent)(import_solid_js11.For, {
|
|
2508
|
+
get each() {
|
|
2509
|
+
return panels();
|
|
2510
|
+
},
|
|
2511
|
+
children: (panel) => (0, import_web82.createComponent)(Panel, {
|
|
2512
|
+
panel,
|
|
2513
|
+
get defaultOpen() {
|
|
2514
|
+
return props.defaultOpen ?? true;
|
|
2515
|
+
}
|
|
2516
|
+
})
|
|
2517
|
+
}));
|
|
2518
|
+
(0, import_web80.effect)(() => (0, import_web79.setAttribute)(_el$2, "data-position", props.position ?? "top-right"));
|
|
2519
|
+
return _el$;
|
|
2520
|
+
}
|
|
2521
|
+
});
|
|
2522
|
+
}
|
|
2523
|
+
});
|
|
2524
|
+
}
|
|
2525
|
+
|
|
2526
|
+
// src/solid/components/ButtonGroup.tsx
|
|
2527
|
+
var import_web85 = require("solid-js/web");
|
|
2528
|
+
var import_web86 = require("solid-js/web");
|
|
2529
|
+
var import_web87 = require("solid-js/web");
|
|
2530
|
+
var import_web88 = require("solid-js/web");
|
|
2531
|
+
var import_web89 = require("solid-js/web");
|
|
2532
|
+
var import_solid_js12 = require("solid-js");
|
|
2533
|
+
var _tmpl$20 = /* @__PURE__ */ (0, import_web85.template)(`<div class=dialkit-button-group>`);
|
|
2534
|
+
var _tmpl$29 = /* @__PURE__ */ (0, import_web85.template)(`<button class=dialkit-button>`);
|
|
2535
|
+
function ButtonGroup(props) {
|
|
2536
|
+
return (() => {
|
|
2537
|
+
var _el$ = _tmpl$20();
|
|
2538
|
+
(0, import_web88.insert)(_el$, (0, import_web89.createComponent)(import_solid_js12.For, {
|
|
2539
|
+
get each() {
|
|
2540
|
+
return props.buttons;
|
|
2541
|
+
},
|
|
2542
|
+
children: (button) => (() => {
|
|
2543
|
+
var _el$2 = _tmpl$29();
|
|
2544
|
+
(0, import_web87.addEventListener)(_el$2, "click", button.onClick, true);
|
|
2545
|
+
(0, import_web88.insert)(_el$2, () => button.label);
|
|
2546
|
+
return _el$2;
|
|
2547
|
+
})()
|
|
2548
|
+
}));
|
|
2549
|
+
return _el$;
|
|
2550
|
+
})();
|
|
2551
|
+
}
|
|
2552
|
+
(0, import_web86.delegateEvents)(["click"]);
|
|
2553
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
2554
|
+
0 && (module.exports = {
|
|
2555
|
+
ButtonGroup,
|
|
2556
|
+
ColorControl,
|
|
2557
|
+
DialRoot,
|
|
2558
|
+
DialStore,
|
|
2559
|
+
Folder,
|
|
2560
|
+
PresetManager,
|
|
2561
|
+
SelectControl,
|
|
2562
|
+
Slider,
|
|
2563
|
+
SpringControl,
|
|
2564
|
+
SpringVisualization,
|
|
2565
|
+
TextControl,
|
|
2566
|
+
Toggle,
|
|
2567
|
+
createDialKit
|
|
2568
|
+
});
|
|
2569
|
+
//# sourceMappingURL=index.cjs.map
|