@pathscale/ui 2.11.7 → 2.11.9
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/dist/components/color-wheel/ColorWheel.generated.js +4 -1
- package/dist/components/color-wheel/ComplexColorWheel.css +1 -1
- package/dist/components/color-wheel/ComplexColorWheel.generated.js +180 -173
- package/dist/components/color-wheel-flower/ColorWheelFlower.css +84 -3
- package/dist/components/color-wheel-flower/ColorWheelFlower.generated.d.ts +2 -0
- package/dist/components/color-wheel-flower/ColorWheelFlower.generated.js +18 -247
- package/dist/components/dock/Dock.generated.js +1 -1
- package/dist/components/dropdown/Dropdown.css +32 -1
- package/dist/components/dropdown/Dropdown.generated.d.ts +1 -1
- package/dist/components/dropdown/Dropdown.generated.js +49 -42
- package/dist/components/inline-edit/InlineEdit.generated.js +19 -15
- package/dist/components/language-switcher/LanguageSwitcher.generated.d.ts +2 -0
- package/dist/components/panel-toggle/PanelToggle.css +72 -0
- package/dist/components/panel-toggle/PanelToggle.generated.d.ts +18 -0
- package/dist/components/panel-toggle/PanelToggle.generated.js +41 -0
- package/dist/components/panel-toggle/PanelToggle.recipe.d.ts +21 -0
- package/dist/components/panel-toggle/PanelToggle.recipe.js +45 -0
- package/dist/components/panel-toggle/index.d.ts +2 -0
- package/dist/components/panel-toggle/index.js +2 -0
- package/dist/components/select/Select.generated.js +116 -88
- package/dist/components/slider/Slider.generated.js +11 -4
- package/dist/components/tabs/Tabs.css +5 -0
- package/dist/components/tabs/Tabs.generated.js +4 -3
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/layouts.manifest.json +4 -1
- package/dist/motion/engine.js +11 -5
- package/dist/purge-manifest.json +117 -9
- package/package.json +7 -5
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createComponent, insert, memo, mergeProps,
|
|
1
|
+
import { createComponent, insert, memo, mergeProps, spread, template } from "@solidjs/web";
|
|
2
2
|
import { defineComponent } from "solid-layouts/solid-2/application-boundary";
|
|
3
3
|
import "./ColorWheelFlower.css";
|
|
4
4
|
import { For, createMemo, createSignal, createTrackedEffect, onCleanup } from "solid-js";
|
|
@@ -9,7 +9,7 @@ import color_swatch_picker from "../color-swatch-picker/index.js";
|
|
|
9
9
|
import { useColorPickerContext } from "./colorWheelFlowerContext.js";
|
|
10
10
|
import { createColorFromHsl, parseColor, rgbToHex, rgbToHsl } from "./ColorUtils.js";
|
|
11
11
|
import { resolveColorWheelFlowerPalette } from "./ColorWheelFlower.palette.js";
|
|
12
|
-
import {
|
|
12
|
+
import { prefersReducedMotion } from "../../motion/index.js";
|
|
13
13
|
import { CLASSES, componentRecipe } from "./ColorWheelFlower.recipe.js";
|
|
14
14
|
import { flowerPetalPosition } from "./ColorWheelFlower.geometry.js";
|
|
15
15
|
var _tmpl$ = /*#__PURE__*/ template("<div><div><div><div>"), _tmpl$2 = /*#__PURE__*/ template("<div><div><div><span></span><span>");
|
|
@@ -52,67 +52,6 @@ const createColorItem = (id, color, offsetX, offsetY, options)=>{
|
|
|
52
52
|
isCenter: options?.isCenter
|
|
53
53
|
};
|
|
54
54
|
};
|
|
55
|
-
const readMotionState = (el)=>{
|
|
56
|
-
if ("u" < typeof getComputedStyle) return {
|
|
57
|
-
opacity: 1,
|
|
58
|
-
x: 0,
|
|
59
|
-
y: 0,
|
|
60
|
-
scale: 1
|
|
61
|
-
};
|
|
62
|
-
const styles = getComputedStyle(el);
|
|
63
|
-
const opacityValue = Number.parseFloat(styles.opacity);
|
|
64
|
-
const opacity = Number.isFinite(opacityValue) ? opacityValue : 1;
|
|
65
|
-
const transform = styles.transform;
|
|
66
|
-
if (!transform || "none" === transform) return {
|
|
67
|
-
opacity,
|
|
68
|
-
x: 0,
|
|
69
|
-
y: 0,
|
|
70
|
-
scale: 1
|
|
71
|
-
};
|
|
72
|
-
if ("u" > typeof DOMMatrixReadOnly) {
|
|
73
|
-
const matrix = new DOMMatrixReadOnly(transform);
|
|
74
|
-
return {
|
|
75
|
-
opacity,
|
|
76
|
-
x: matrix.m41,
|
|
77
|
-
y: matrix.m42,
|
|
78
|
-
scale: matrix.a
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
const matrixMatch = transform.match(/matrix\(([^)]+)\)/);
|
|
82
|
-
if (!matrixMatch) return {
|
|
83
|
-
opacity,
|
|
84
|
-
x: 0,
|
|
85
|
-
y: 0,
|
|
86
|
-
scale: 1
|
|
87
|
-
};
|
|
88
|
-
const values = matrixMatch[1].split(",").map((value)=>Number.parseFloat(value.trim()));
|
|
89
|
-
return {
|
|
90
|
-
opacity,
|
|
91
|
-
scale: Number.isFinite(values[0]) ? values[0] : 1,
|
|
92
|
-
x: Number.isFinite(values[4]) ? values[4] : 0,
|
|
93
|
-
y: Number.isFinite(values[5]) ? values[5] : 0
|
|
94
|
-
};
|
|
95
|
-
};
|
|
96
|
-
const applyMotionState = (el, state)=>{
|
|
97
|
-
el.style.opacity = String(state.opacity ?? 1);
|
|
98
|
-
el.style.transform = `translate3d(${state.x ?? 0}px, ${state.y ?? 0}px, 0) scale(${state.scale ?? 1})`;
|
|
99
|
-
};
|
|
100
|
-
const getLiftOffset = (item, distance)=>{
|
|
101
|
-
const radius = Math.sqrt(item.offsetX ** 2 + item.offsetY ** 2);
|
|
102
|
-
if (!Number.isFinite(radius) || 0 === radius) return {
|
|
103
|
-
x: 0,
|
|
104
|
-
y: 0
|
|
105
|
-
};
|
|
106
|
-
return {
|
|
107
|
-
x: item.offsetX / radius * distance,
|
|
108
|
-
y: item.offsetY / radius * distance
|
|
109
|
-
};
|
|
110
|
-
};
|
|
111
|
-
const easeOutBack = (overshoot = 1.4)=>(t)=>{
|
|
112
|
-
const c1 = overshoot;
|
|
113
|
-
const c3 = c1 + 1;
|
|
114
|
-
return 1 + c3 * (t - 1) ** 3 + c1 * (t - 1) ** 2;
|
|
115
|
-
};
|
|
116
55
|
const toRgba = (rgb, alpha)=>{
|
|
117
56
|
const match = rgb.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
|
|
118
57
|
if (!match) return rgb;
|
|
@@ -291,19 +230,9 @@ function buildColors(palette) {
|
|
|
291
230
|
} : void 0));
|
|
292
231
|
}
|
|
293
232
|
const CENTER_INDEX = LAYOUT.findIndex((l)=>l.isCenter);
|
|
294
|
-
const MAX_RADIUS = Math.max(...LAYOUT.map((l)=>Math.sqrt(l.offsetX ** 2 + l.offsetY ** 2)));
|
|
295
|
-
const MAX_WAVE_DISTANCE = 2 * MAX_RADIUS;
|
|
296
|
-
const MAX_WAVE_DELAY = 0.12;
|
|
297
233
|
const __solidLayoutColorWheelFlower = (_stable, p)=>{
|
|
298
234
|
const context = useColorPickerContext();
|
|
299
235
|
const [selectedIndex, setSelectedIndex] = createSignal(null);
|
|
300
|
-
const [hoveredIndex, setHoveredIndex] = createSignal(null);
|
|
301
|
-
const [pressedIndex, setPressedIndex] = createSignal(null);
|
|
302
|
-
const [pointer, setPointer] = createSignal({
|
|
303
|
-
x: 0,
|
|
304
|
-
y: 0,
|
|
305
|
-
active: false
|
|
306
|
-
});
|
|
307
236
|
const [pulseState, setPulseState] = createSignal(null);
|
|
308
237
|
const [currentTheme, setCurrentTheme] = createSignal("u" > typeof document && "dark" === document.documentElement.getAttribute("data-theme") ? "dark" : "light");
|
|
309
238
|
if ("u" > typeof window && "u" > typeof MutationObserver) {
|
|
@@ -322,12 +251,6 @@ const __solidLayoutColorWheelFlower = (_stable, p)=>{
|
|
|
322
251
|
const mode = ()=>p.mode ?? currentTheme();
|
|
323
252
|
const colors = createMemo(()=>buildColors(resolveColorWheelFlowerPalette(mode(), p.palette)));
|
|
324
253
|
const reduceMotion = prefersReducedMotion();
|
|
325
|
-
reduceMotion || (motionDurations.slow, motionEasings.inOut);
|
|
326
|
-
const hoverLift = reduceMotion ? 0 : motionDistances.sm;
|
|
327
|
-
const pressScale = 0.96;
|
|
328
|
-
const pulseScale = 1.12;
|
|
329
|
-
let containerRef;
|
|
330
|
-
let pointerTimeout;
|
|
331
254
|
let pulseTimeout;
|
|
332
255
|
const closestIndex = createMemo(()=>{
|
|
333
256
|
const current = context.color();
|
|
@@ -401,48 +324,20 @@ const __solidLayoutColorWheelFlower = (_stable, p)=>{
|
|
|
401
324
|
if (!selectedItem) return;
|
|
402
325
|
if (!isNearColor(current, selectedItem)) setSelectedIndex(null);
|
|
403
326
|
});
|
|
404
|
-
const handlePointerMove = (event)=>{
|
|
405
|
-
const node = containerRef;
|
|
406
|
-
if (!node) return;
|
|
407
|
-
const rect = node.getBoundingClientRect();
|
|
408
|
-
const x = event.clientX - rect.left - rect.width / 2;
|
|
409
|
-
const y = event.clientY - rect.top - rect.height / 2;
|
|
410
|
-
setPointer({
|
|
411
|
-
x,
|
|
412
|
-
y,
|
|
413
|
-
active: true
|
|
414
|
-
});
|
|
415
|
-
if (void 0 !== pointerTimeout) clearTimeout(pointerTimeout);
|
|
416
|
-
pointerTimeout = window.setTimeout(()=>{
|
|
417
|
-
setPointer((prev)=>({
|
|
418
|
-
...prev,
|
|
419
|
-
active: false
|
|
420
|
-
}));
|
|
421
|
-
}, 120);
|
|
422
|
-
};
|
|
423
|
-
const handlePointerLeave = ()=>{
|
|
424
|
-
setPointer((prev)=>({
|
|
425
|
-
...prev,
|
|
426
|
-
active: false
|
|
427
|
-
}));
|
|
428
|
-
setHoveredIndex(null);
|
|
429
|
-
if (void 0 !== pointerTimeout) clearTimeout(pointerTimeout);
|
|
430
|
-
};
|
|
431
327
|
onCleanup(()=>{
|
|
432
328
|
if (void 0 !== pulseTimeout) clearTimeout(pulseTimeout);
|
|
433
|
-
if (void 0 !== pointerTimeout) clearTimeout(pointerTimeout);
|
|
434
329
|
});
|
|
435
330
|
const pickerValue = ()=>colors()[visualSelectedIndex()]?.hex;
|
|
436
331
|
var _el$ = _tmpl$(), _el$2 = _el$.firstChild, _el$3 = _el$2.firstChild, _el$4 = _el$3.firstChild;
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
332
|
+
spread(_el$, mergeProps({
|
|
333
|
+
get id () {
|
|
334
|
+
return p.id;
|
|
335
|
+
}
|
|
336
|
+
}, ()=>({
|
|
440
337
|
class: twMerge(CLASSES.base, clsx({
|
|
441
338
|
[CLASSES.flag.disabled]: context.disabled()
|
|
442
339
|
}), p.class)
|
|
443
340
|
}), {
|
|
444
|
-
onMouseMove: handlePointerMove,
|
|
445
|
-
onMouseLeave: handlePointerLeave,
|
|
446
341
|
"data-slot": "color-wheel-flower",
|
|
447
342
|
get ["data-color-mode"] () {
|
|
448
343
|
return mode();
|
|
@@ -460,7 +355,11 @@ const __solidLayoutColorWheelFlower = (_stable, p)=>{
|
|
|
460
355
|
spread(_el$4, mergeProps(()=>({
|
|
461
356
|
class: twMerge(CLASSES.ring.base, CLASSES.ring.inner)
|
|
462
357
|
})), false);
|
|
463
|
-
insert(_el$, createComponent(color_swatch_picker, mergeProps(
|
|
358
|
+
insert(_el$, createComponent(color_swatch_picker, mergeProps({
|
|
359
|
+
get id () {
|
|
360
|
+
return memo(()=>!!p.id)() ? `${p.id}-palette` : void 0;
|
|
361
|
+
}
|
|
362
|
+
}, ()=>({
|
|
464
363
|
class: CLASSES.picker
|
|
465
364
|
}), {
|
|
466
365
|
get value () {
|
|
@@ -477,112 +376,10 @@ const __solidLayoutColorWheelFlower = (_stable, p)=>{
|
|
|
477
376
|
return colors();
|
|
478
377
|
},
|
|
479
378
|
children: (item, index)=>{
|
|
480
|
-
let motionRef;
|
|
481
|
-
let dotControl = null;
|
|
482
|
-
let hasPaintedFinalState = false;
|
|
483
|
-
const isHovered = ()=>hoveredIndex() === index();
|
|
484
|
-
const isPressed = ()=>pressedIndex() === index();
|
|
485
379
|
const isPulsing = ()=>pulseState()?.index === index();
|
|
486
|
-
const dotBaseTarget = createMemo(()=>{
|
|
487
|
-
if (context.disabled()) return {
|
|
488
|
-
opacity: 0.5,
|
|
489
|
-
scale: 1,
|
|
490
|
-
x: 0,
|
|
491
|
-
y: 0
|
|
492
|
-
};
|
|
493
|
-
const pointerState = pointer();
|
|
494
|
-
const anchorIdx = hoveredIndex();
|
|
495
|
-
let scale = 1;
|
|
496
|
-
let offsetX = 0;
|
|
497
|
-
let offsetY = 0;
|
|
498
|
-
if (null !== anchorIdx && pointerState.active) {
|
|
499
|
-
const anchor = colors()[anchorIdx];
|
|
500
|
-
const distance = Math.sqrt((item.offsetX - anchor.offsetX) ** 2 + (item.offsetY - anchor.offsetY) ** 2);
|
|
501
|
-
const waveRadius = 0.9 * MAX_RADIUS;
|
|
502
|
-
const influence = Math.max(0, 1 - distance / waveRadius);
|
|
503
|
-
if (influence > 0) {
|
|
504
|
-
const maxDelta = 16;
|
|
505
|
-
const deltaX = Math.max(-maxDelta, Math.min(maxDelta, pointerState.x - anchor.offsetX));
|
|
506
|
-
const deltaY = Math.max(-maxDelta, Math.min(maxDelta, pointerState.y - anchor.offsetY));
|
|
507
|
-
const waveStrength = isHovered() ? 0.25 : 0.18;
|
|
508
|
-
offsetX += deltaX * influence * waveStrength;
|
|
509
|
-
offsetY += deltaY * influence * waveStrength;
|
|
510
|
-
const liftStrength = isHovered() ? 0.8 : 0.35;
|
|
511
|
-
const lift = getLiftOffset(item, hoverLift * liftStrength);
|
|
512
|
-
offsetX += lift.x * influence;
|
|
513
|
-
offsetY += lift.y * influence;
|
|
514
|
-
const scaleBoost = isHovered() ? 0.06 : 0.03;
|
|
515
|
-
scale += influence * scaleBoost;
|
|
516
|
-
}
|
|
517
|
-
}
|
|
518
|
-
return {
|
|
519
|
-
opacity: 1,
|
|
520
|
-
scale,
|
|
521
|
-
x: offsetX,
|
|
522
|
-
y: offsetY
|
|
523
|
-
};
|
|
524
|
-
});
|
|
525
|
-
const dotTarget = createMemo(()=>{
|
|
526
|
-
const base = dotBaseTarget();
|
|
527
|
-
let scale = base.scale ?? 1;
|
|
528
|
-
if (isPulsing()) scale *= pulseScale;
|
|
529
|
-
if (isPressed()) scale *= pressScale;
|
|
530
|
-
return {
|
|
531
|
-
...base,
|
|
532
|
-
scale
|
|
533
|
-
};
|
|
534
|
-
});
|
|
535
|
-
const glowOpacity = createMemo(()=>{
|
|
536
|
-
if (context.disabled()) return 0;
|
|
537
|
-
if (isHovered()) return 0.6;
|
|
538
|
-
if (isPulsing()) return 0.35;
|
|
539
|
-
return 0;
|
|
540
|
-
});
|
|
541
|
-
const dotTransition = ()=>{
|
|
542
|
-
if (reduceMotion) return {
|
|
543
|
-
duration: 0
|
|
544
|
-
};
|
|
545
|
-
const anchorIdx = hoveredIndex();
|
|
546
|
-
const pointerState = pointer();
|
|
547
|
-
let delay = 0;
|
|
548
|
-
if (null !== anchorIdx && pointerState.active) {
|
|
549
|
-
const anchor = colors()[anchorIdx];
|
|
550
|
-
const distance = Math.sqrt((item.offsetX - anchor.offsetX) ** 2 + (item.offsetY - anchor.offsetY) ** 2);
|
|
551
|
-
delay = Math.min(MAX_WAVE_DELAY, distance / MAX_WAVE_DISTANCE * MAX_WAVE_DELAY);
|
|
552
|
-
}
|
|
553
|
-
if (isPulsing()) return {
|
|
554
|
-
duration: motionDurations.fast,
|
|
555
|
-
easing: easeOutBack(1.25)
|
|
556
|
-
};
|
|
557
|
-
if (isHovered()) return {
|
|
558
|
-
duration: motionDurations.fast,
|
|
559
|
-
easing: motionEasings.out,
|
|
560
|
-
delay
|
|
561
|
-
};
|
|
562
|
-
return {
|
|
563
|
-
duration: motionDurations.base,
|
|
564
|
-
easing: motionEasings.out,
|
|
565
|
-
delay
|
|
566
|
-
};
|
|
567
|
-
};
|
|
568
|
-
createTrackedEffect(()=>{
|
|
569
|
-
if (!motionRef) return;
|
|
570
|
-
const target = dotTarget();
|
|
571
|
-
if (!hasPaintedFinalState) {
|
|
572
|
-
applyMotionState(motionRef, target);
|
|
573
|
-
hasPaintedFinalState = true;
|
|
574
|
-
return;
|
|
575
|
-
}
|
|
576
|
-
const transition = dotTransition();
|
|
577
|
-
dotControl?.stop();
|
|
578
|
-
dotControl = runMotion(motionRef, readMotionState(motionRef), target, transition);
|
|
579
|
-
});
|
|
580
|
-
onCleanup(()=>{
|
|
581
|
-
dotControl?.stop();
|
|
582
|
-
});
|
|
583
380
|
var _el$5 = _tmpl$2(), _el$6 = _el$5.firstChild, _el$7 = _el$6.firstChild, _el$8 = _el$7.firstChild, _el$9 = _el$8.nextSibling;
|
|
584
381
|
spread(_el$5, mergeProps(()=>({
|
|
585
|
-
class: CLASSES.dot.base
|
|
382
|
+
class: clsx(CLASSES.dot.base, isPulsing() && "color-wheel-flower__dot--pulsing")
|
|
586
383
|
}), {
|
|
587
384
|
get style () {
|
|
588
385
|
return flowerPetalPosition(item.offsetX, item.offsetY);
|
|
@@ -591,9 +388,6 @@ const __solidLayoutColorWheelFlower = (_stable, p)=>{
|
|
|
591
388
|
spread(_el$6, mergeProps(()=>({
|
|
592
389
|
class: CLASSES.dot.frame
|
|
593
390
|
})), true);
|
|
594
|
-
ref(()=>(el)=>{
|
|
595
|
-
motionRef = el;
|
|
596
|
-
}, _el$7);
|
|
597
391
|
spread(_el$7, mergeProps(()=>({
|
|
598
392
|
class: CLASSES.dot.motion
|
|
599
393
|
})), true);
|
|
@@ -602,13 +396,14 @@ const __solidLayoutColorWheelFlower = (_stable, p)=>{
|
|
|
602
396
|
}), {
|
|
603
397
|
get style () {
|
|
604
398
|
return {
|
|
605
|
-
|
|
606
|
-
"box-shadow": `0 0 8px ${toRgba(item.rgb, 0.3)}, 0 0 3px rgba(255,255,255,0.35)`,
|
|
607
|
-
transition: reduceMotion ? "none" : "opacity 200ms ease-out, box-shadow 200ms ease-out"
|
|
399
|
+
"box-shadow": `0 0 8px ${toRgba(item.rgb, 0.3)}, 0 0 3px rgba(255,255,255,0.35)`
|
|
608
400
|
};
|
|
609
401
|
}
|
|
610
402
|
}), false);
|
|
611
403
|
insert(_el$7, createComponent(color_swatch, mergeProps({
|
|
404
|
+
get id () {
|
|
405
|
+
return memo(()=>!!p.id)() ? `${p.id}-petal-${index()}` : void 0;
|
|
406
|
+
},
|
|
612
407
|
get color () {
|
|
613
408
|
return item.hex;
|
|
614
409
|
},
|
|
@@ -621,34 +416,10 @@ const __solidLayoutColorWheelFlower = (_stable, p)=>{
|
|
|
621
416
|
},
|
|
622
417
|
get state () {
|
|
623
418
|
return context.disabled() ? "disabled" : void 0;
|
|
624
|
-
},
|
|
625
|
-
onMouseEnter: ()=>{
|
|
626
|
-
if (!context.disabled()) setHoveredIndex(index());
|
|
627
|
-
},
|
|
628
|
-
onMouseLeave: ()=>{
|
|
629
|
-
if (!context.disabled()) setHoveredIndex(null);
|
|
630
|
-
},
|
|
631
|
-
onFocus: ()=>{
|
|
632
|
-
if (!context.disabled()) setHoveredIndex(index());
|
|
633
|
-
},
|
|
634
|
-
onBlur: ()=>{
|
|
635
|
-
if (!context.disabled()) setHoveredIndex(null);
|
|
636
|
-
},
|
|
637
|
-
onPointerDown: ()=>{
|
|
638
|
-
if (!context.disabled()) setPressedIndex(index());
|
|
639
|
-
},
|
|
640
|
-
onPointerUp: ()=>{
|
|
641
|
-
if (!context.disabled()) setPressedIndex(null);
|
|
642
|
-
},
|
|
643
|
-
onPointerLeave: ()=>{
|
|
644
|
-
if (!context.disabled()) setPressedIndex(null);
|
|
645
|
-
},
|
|
646
|
-
onPointerCancel: ()=>{
|
|
647
|
-
if (!context.disabled()) setPressedIndex(null);
|
|
648
419
|
}
|
|
649
420
|
})), _el$9);
|
|
650
421
|
spread(_el$9, mergeProps(()=>({
|
|
651
|
-
class: clsx(CLASSES.highlight.base,
|
|
422
|
+
class: clsx(CLASSES.highlight.base, isPulsing() && CLASSES.highlight.pulsing)
|
|
652
423
|
})), false);
|
|
653
424
|
return _el$5;
|
|
654
425
|
}
|
|
@@ -5,7 +5,7 @@ import { For, Show, createSignal, omit, onCleanup, onSettled } from "solid-js";
|
|
|
5
5
|
import { twMerge } from "../../lib/twMerge.js";
|
|
6
6
|
import { CLASSES, componentRecipe } from "./Dock.recipe.js";
|
|
7
7
|
var _tmpl$ = /*#__PURE__*/ template("<div>"), _tmpl$2 = /*#__PURE__*/ template("<div><div>"), _tmpl$3 = /*#__PURE__*/ template("<button>"), _tmpl$4 = /*#__PURE__*/ template("<a>"), _tmpl$5 = /*#__PURE__*/ template("<div><!><!>"), _tmpl$6 = /*#__PURE__*/ template("<div><button>"), _tmpl$7 = /*#__PURE__*/ template('<svg><path d="M4 6h16"></path><path d="M4 12h16"></path><path d="M4 18h16">');
|
|
8
|
-
const prefersReducedMotion = "u" > typeof window && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
8
|
+
const prefersReducedMotion = "u" > typeof window && "function" == typeof window.matchMedia && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
9
9
|
function createSpring(initial, opts = {}) {
|
|
10
10
|
const mass = opts.mass ?? 1;
|
|
11
11
|
const stiffness = opts.stiffness ?? 150;
|
|
@@ -12,6 +12,20 @@
|
|
|
12
12
|
position: relative;
|
|
13
13
|
isolation: isolate;
|
|
14
14
|
display: inline-flex;
|
|
15
|
+
/*
|
|
16
|
+
* The border is inside the height a consumer asks for.
|
|
17
|
+
*
|
|
18
|
+
* There is no global `box-sizing` reset in this library, so this element
|
|
19
|
+
* was `content-box`: `height: 24px` set the *content* box and the 1px
|
|
20
|
+
* border on each side was added on top. AgencyZero's composer pill asks
|
|
21
|
+
* for `h-[24px]` and rendered at 28, measured on a running app, which is
|
|
22
|
+
* the sort of few-pixel drift that reads as a component quietly breaking
|
|
23
|
+
* its own contract.
|
|
24
|
+
*
|
|
25
|
+
* `border-box` makes an explicit height mean the height that lands on
|
|
26
|
+
* screen, which is what every caller already assumed.
|
|
27
|
+
*/
|
|
28
|
+
box-sizing: border-box;
|
|
15
29
|
min-height: 2.25rem;
|
|
16
30
|
width: fit-content;
|
|
17
31
|
align-items: center;
|
|
@@ -36,9 +50,26 @@
|
|
|
36
50
|
background-color: var(--dropdown-trigger-bg);
|
|
37
51
|
color: var(--dropdown-trigger-fg);
|
|
38
52
|
border-color: var(--dropdown-trigger-border);
|
|
39
|
-
|
|
53
|
+
/*
|
|
54
|
+
* The drop shadow is a variable so a caller can turn it off.
|
|
55
|
+
*
|
|
56
|
+
* `0 1px 2px` paints about 3px below the border box, and a shadow is not
|
|
57
|
+
* part of the box: an element declared `24px` occupies 24px of layout and
|
|
58
|
+
* reports bounds of 27.8. That is correct CSS and still wrong for a pill
|
|
59
|
+
* sized to sit inside a fixed-height composer row, where the visual result
|
|
60
|
+
* reads as the control quietly ignoring its own height. Measured on the
|
|
61
|
+
* running application: border-box 24.1, outer bounds 27.8, with border
|
|
62
|
+
* 0.9 and zero vertical padding - the whole 3.7px difference is this
|
|
63
|
+
* shadow.
|
|
64
|
+
*
|
|
65
|
+
* A variable rather than removal, because a dropdown on an ordinary
|
|
66
|
+
* surface wants the elevation. Set `--dropdown-trigger-shadow: none` on
|
|
67
|
+
* the trigger to opt out.
|
|
68
|
+
*/
|
|
69
|
+
--dropdown-trigger-shadow:
|
|
40
70
|
0 1px 2px rgb(var(--shadow-color, 0 0 0) / 6%),
|
|
41
71
|
0 1px 0 oklch(100% 0 0 / 0.03) inset;
|
|
72
|
+
box-shadow: var(--dropdown-trigger-shadow);
|
|
42
73
|
transition:
|
|
43
74
|
transform 250ms cubic-bezier(0.22, 1, 0.36, 1),
|
|
44
75
|
background-color 150ms ease,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Component as __LayoutComponent } from "solid-js";
|
|
2
2
|
import "./Dropdown.css";
|
|
3
|
-
import type
|
|
3
|
+
import { type JSX } from "@solidjs/web";
|
|
4
4
|
import { type OverlayPlacement } from "../_shared/overlayPosition";
|
|
5
5
|
type DropdownAlign = "start" | "end";
|
|
6
6
|
type DropdownPlacement = OverlayPlacement;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { createComponent, insert, mergeProps, ref, spread, template } from "@solidjs/web";
|
|
1
|
+
import { Portal, createComponent, insert, mergeProps, ref, spread, template } from "@solidjs/web";
|
|
2
2
|
import { defineComponent } from "solid-layouts/solid-2/application-boundary";
|
|
3
3
|
import "./Dropdown.css";
|
|
4
|
-
import { Show, createContext, createSignal, createTrackedEffect, createUniqueId, omit, onCleanup, onSettled, useContext } from "solid-js";
|
|
4
|
+
import { Show, createContext, createSignal, createTrackedEffect, createUniqueId, flush, omit, onCleanup, onSettled, useContext } from "solid-js";
|
|
5
5
|
import { twMerge } from "../../lib/twMerge.js";
|
|
6
6
|
import { createOverlayPosition } from "../_shared/overlayPosition.js";
|
|
7
7
|
import { CLASSES, componentRecipe } from "./Dropdown.recipe.js";
|
|
@@ -22,9 +22,11 @@ const sortItemsByDomOrder = (items)=>[
|
|
|
22
22
|
});
|
|
23
23
|
const __solidLayoutDropdownRoot = (_stable, p)=>{
|
|
24
24
|
const others = omit(p, "children", "class", "open", "defaultOpen", "onOpenChange", "placement", "autoFlip", "disabled", "dataTheme", "ref");
|
|
25
|
-
const
|
|
26
|
-
const
|
|
27
|
-
const
|
|
25
|
+
const generatedBaseId = createUniqueId();
|
|
26
|
+
const authoredBaseId = "string" == typeof p.id ? p.id.trim() : "";
|
|
27
|
+
const baseId = authoredBaseId || generatedBaseId;
|
|
28
|
+
const triggerId = `${baseId}--trigger`;
|
|
29
|
+
const menuId = `${baseId}--menu`;
|
|
28
30
|
const [internalOpen, setInternalOpen] = createSignal(Boolean(p.defaultOpen));
|
|
29
31
|
const [items, setItems] = createSignal([]);
|
|
30
32
|
const [focusedKey, setFocusedKey] = createSignal(void 0);
|
|
@@ -117,6 +119,7 @@ const __solidLayoutDropdownRoot = (_stable, p)=>{
|
|
|
117
119
|
if (menuRef()?.contains(target)) return;
|
|
118
120
|
if (triggerRef()?.contains(target)) return;
|
|
119
121
|
setOpen(false);
|
|
122
|
+
flush();
|
|
120
123
|
};
|
|
121
124
|
document.addEventListener("pointerdown", handlePointerDown);
|
|
122
125
|
return ()=>{
|
|
@@ -337,44 +340,48 @@ const __solidLayoutDropdownMenu = (_stable, p)=>{
|
|
|
337
340
|
return ctx.open();
|
|
338
341
|
},
|
|
339
342
|
get children () {
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
343
|
+
return createComponent(Portal, {
|
|
344
|
+
get children () {
|
|
345
|
+
var _el$6 = _tmpl$3(), _el$7 = _el$6.firstChild;
|
|
346
|
+
var _ref$ = ctx.setMenuRef;
|
|
347
|
+
"function" == typeof _ref$ || Array.isArray(_ref$) ? ref(()=>_ref$, _el$6) : ctx.setMenuRef = _el$6;
|
|
348
|
+
spread(_el$6, mergeProps(others, {
|
|
349
|
+
get id () {
|
|
350
|
+
return ctx.menuId;
|
|
351
|
+
}
|
|
352
|
+
}, ()=>({
|
|
353
|
+
class: twMerge(CLASSES.slot.popover, p.class)
|
|
354
|
+
}), {
|
|
355
|
+
get role () {
|
|
356
|
+
return p.role ?? "menu";
|
|
357
|
+
},
|
|
358
|
+
"data-slot": "dropdown-popover",
|
|
359
|
+
get ["data-open"] () {
|
|
360
|
+
return ctx.open() ? "true" : "false";
|
|
361
|
+
},
|
|
362
|
+
get ["data-align"] () {
|
|
363
|
+
return p.align ?? "start";
|
|
364
|
+
},
|
|
365
|
+
get ["data-placement"] () {
|
|
366
|
+
return overlayPosition.placement();
|
|
367
|
+
},
|
|
368
|
+
get ["aria-hidden"] () {
|
|
369
|
+
return ctx.open() ? "false" : "true";
|
|
370
|
+
},
|
|
371
|
+
get style () {
|
|
372
|
+
return menuStyle();
|
|
373
|
+
},
|
|
374
|
+
onKeyDown: handleKeyDown
|
|
375
|
+
}), true);
|
|
376
|
+
spread(_el$7, mergeProps(()=>({
|
|
377
|
+
class: CLASSES.slot.menu
|
|
378
|
+
}), {
|
|
379
|
+
"data-slot": "dropdown-menu"
|
|
380
|
+
}), true);
|
|
381
|
+
insert(_el$7, ()=>p.children);
|
|
382
|
+
return _el$6;
|
|
346
383
|
}
|
|
347
|
-
}
|
|
348
|
-
class: twMerge(CLASSES.slot.popover, p.class)
|
|
349
|
-
}), {
|
|
350
|
-
get role () {
|
|
351
|
-
return p.role ?? "menu";
|
|
352
|
-
},
|
|
353
|
-
"data-slot": "dropdown-popover",
|
|
354
|
-
get ["data-open"] () {
|
|
355
|
-
return ctx.open() ? "true" : "false";
|
|
356
|
-
},
|
|
357
|
-
get ["data-align"] () {
|
|
358
|
-
return p.align ?? "start";
|
|
359
|
-
},
|
|
360
|
-
get ["data-placement"] () {
|
|
361
|
-
return overlayPosition.placement();
|
|
362
|
-
},
|
|
363
|
-
get ["aria-hidden"] () {
|
|
364
|
-
return ctx.open() ? "false" : "true";
|
|
365
|
-
},
|
|
366
|
-
get style () {
|
|
367
|
-
return menuStyle();
|
|
368
|
-
},
|
|
369
|
-
onKeyDown: handleKeyDown
|
|
370
|
-
}), true);
|
|
371
|
-
spread(_el$7, mergeProps(()=>({
|
|
372
|
-
class: CLASSES.slot.menu
|
|
373
|
-
}), {
|
|
374
|
-
"data-slot": "dropdown-menu"
|
|
375
|
-
}), true);
|
|
376
|
-
insert(_el$7, ()=>p.children);
|
|
377
|
-
return _el$6;
|
|
384
|
+
});
|
|
378
385
|
}
|
|
379
386
|
});
|
|
380
387
|
};
|
|
@@ -50,23 +50,27 @@ const __solidLayoutInlineEdit = (_stable, p)=>{
|
|
|
50
50
|
effect(()=>({
|
|
51
51
|
e: CLASSES.slot.read,
|
|
52
52
|
t: CLASSES.slot.value,
|
|
53
|
-
a: p.
|
|
54
|
-
o: p.
|
|
55
|
-
i:
|
|
56
|
-
n: CLASSES.slot.
|
|
57
|
-
s:
|
|
58
|
-
h: p.
|
|
59
|
-
r:
|
|
60
|
-
|
|
53
|
+
a: p.id ? `${p.id}-trigger` : void 0,
|
|
54
|
+
o: p.disabled,
|
|
55
|
+
i: p.label,
|
|
56
|
+
n: CLASSES.slot.trigger,
|
|
57
|
+
s: CLASSES.slot.edit,
|
|
58
|
+
h: p.id ? `${p.id}-field` : void 0,
|
|
59
|
+
r: p.value,
|
|
60
|
+
d: p.label,
|
|
61
|
+
l: twMerge(CLASSES.slot.field, p.fieldClass)
|
|
62
|
+
}), ({ e, t, a, o, i, n, s, h, r, d, l }, _p$)=>{
|
|
61
63
|
className(_el$2, e, _p$?.e);
|
|
62
64
|
className(_el$3, t, _p$?.t);
|
|
63
|
-
a !== _p$?.a && setAttribute(_el$4, "
|
|
64
|
-
o !== _p$?.o && setAttribute(_el$4, "
|
|
65
|
-
|
|
66
|
-
className(_el$
|
|
67
|
-
_el$
|
|
68
|
-
h !== _p$?.h && setAttribute(_el$6, "
|
|
69
|
-
|
|
65
|
+
a !== _p$?.a && setAttribute(_el$4, "id", a);
|
|
66
|
+
o !== _p$?.o && setAttribute(_el$4, "disabled", o);
|
|
67
|
+
i !== _p$?.i && setAttribute(_el$4, "aria-label", i);
|
|
68
|
+
className(_el$4, n, _p$?.n);
|
|
69
|
+
className(_el$5, s, _p$?.s);
|
|
70
|
+
h !== _p$?.h && setAttribute(_el$6, "id", h);
|
|
71
|
+
_el$6.value = r ?? "";
|
|
72
|
+
d !== _p$?.d && setAttribute(_el$6, "aria-label", d);
|
|
73
|
+
className(_el$6, l, _p$?.l);
|
|
70
74
|
});
|
|
71
75
|
return _el$;
|
|
72
76
|
};
|
|
@@ -4,6 +4,8 @@ import type { DropdownAlign } from "../dropdown";
|
|
|
4
4
|
import type { UIBaseProps } from "../vocabulary";
|
|
5
5
|
import type { I18nStore } from "./createI18n";
|
|
6
6
|
export interface LanguageSwitcherProps extends UIBaseProps {
|
|
7
|
+
/** Stable identity for the native language control. */
|
|
8
|
+
id?: string;
|
|
7
9
|
/**
|
|
8
10
|
* The i18n store to use for language state
|
|
9
11
|
*/
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
@layer components {
|
|
2
|
+
.panel-toggle {
|
|
3
|
+
position: absolute;
|
|
4
|
+
top: 50%;
|
|
5
|
+
z-index: 20;
|
|
6
|
+
display: inline-flex;
|
|
7
|
+
width: 0.5rem;
|
|
8
|
+
height: 3rem;
|
|
9
|
+
flex-shrink: 0;
|
|
10
|
+
transform: translateY(-50%);
|
|
11
|
+
align-items: center;
|
|
12
|
+
justify-content: center;
|
|
13
|
+
border: 1px solid color-mix(in oklab, var(--color-primary) 40%, transparent);
|
|
14
|
+
padding: 0;
|
|
15
|
+
background: color-mix(in oklab, var(--color-primary) 20%, transparent);
|
|
16
|
+
color: var(--color-primary);
|
|
17
|
+
cursor: pointer;
|
|
18
|
+
outline: none;
|
|
19
|
+
transition:
|
|
20
|
+
background-color 150ms ease,
|
|
21
|
+
border-color 150ms ease;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.panel-toggle:hover,
|
|
25
|
+
.panel-toggle[data-hovered="true"] {
|
|
26
|
+
border-color: color-mix(in oklab, var(--color-primary) 60%, transparent);
|
|
27
|
+
background: color-mix(in oklab, var(--color-primary) 30%, transparent);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.panel-toggle:focus-visible,
|
|
31
|
+
.panel-toggle[data-focus-visible="true"] {
|
|
32
|
+
outline: var(--focus-ring-width, 2px) solid var(--color-primary);
|
|
33
|
+
outline-offset: var(--focus-ring-offset, 2px);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.panel-toggle--right {
|
|
37
|
+
left: 100%;
|
|
38
|
+
border-left: 0;
|
|
39
|
+
border-radius: 0 0.5rem 0.5rem 0;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.panel-toggle--left {
|
|
43
|
+
right: 100%;
|
|
44
|
+
border-right: 0;
|
|
45
|
+
border-radius: 0.5rem 0 0 0.5rem;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.panel-toggle__indicator {
|
|
49
|
+
width: 0.375rem;
|
|
50
|
+
height: 0.375rem;
|
|
51
|
+
border-right: 0.125rem solid currentColor;
|
|
52
|
+
border-bottom: 0.125rem solid currentColor;
|
|
53
|
+
transition: transform 200ms ease;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.panel-toggle--right[data-expanded="true"] .panel-toggle__indicator,
|
|
57
|
+
.panel-toggle--left[data-expanded="false"] .panel-toggle__indicator {
|
|
58
|
+
transform: rotate(-45deg);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.panel-toggle--right[data-expanded="false"] .panel-toggle__indicator,
|
|
62
|
+
.panel-toggle--left[data-expanded="true"] .panel-toggle__indicator {
|
|
63
|
+
transform: rotate(135deg);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
@media (prefers-reduced-motion: reduce) {
|
|
67
|
+
.panel-toggle,
|
|
68
|
+
.panel-toggle__indicator {
|
|
69
|
+
transition: none;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|