@kolkrabbi/kol-component 0.252.0 → 0.254.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/package.json
CHANGED
|
@@ -47,7 +47,7 @@ import { glyphSize } from '../hooks/glyphLadders.js'
|
|
|
47
47
|
* `icon` and `shortcut` rows, which any menu wants.
|
|
48
48
|
*
|
|
49
49
|
* @param {Object} props
|
|
50
|
-
* @param {{id: string, label: string, icon: string, shortcut?: string}[]} props.variants - Variants: menu rows + trigger glyph
|
|
50
|
+
* @param {{id: string, label: string, icon: string, shortcut?: string, disabled?: boolean}[]} props.variants - Variants: menu rows + trigger glyph. A `disabled` row is drawn greyed, never hidden; its click does nothing and the fold stays open
|
|
51
51
|
* @param {string} props.value - Active variant id (controlled)
|
|
52
52
|
* @param {Function} props.onChange - Fires with a variant id — on menu pick, and on trigger click while inactive (arming)
|
|
53
53
|
* @param {string} props.lastPicked - Variant id the trigger shows while the group is inactive (default: variants[0])
|
|
@@ -55,7 +55,7 @@ import { glyphSize } from '../hooks/glyphLadders.js'
|
|
|
55
55
|
* @param {'xs'|'sm'|'md'|'lg'} props.size - Trigger box on the pinned-square ladder — 22 · 26 · 32 · 40 (default: 'md'). The glyph follows the SOLO ladder; it is never set at the call site
|
|
56
56
|
* @param {boolean} props.blurOnClick - Blur the trigger after click so a canvas can reclaim focus and refresh its cursor (default: false)
|
|
57
57
|
* @param {Function} props.onTrigger - Replaces the trigger's arm: fires with the trigger variant's id on every click. For a fold of one-shot ACTIONS (Boolean: the trigger re-runs the last-picked op) — no pressed state is implied (default: arm via `onChange`)
|
|
58
|
-
* @param {boolean} props.disabled -
|
|
58
|
+
* @param {boolean} props.disabled - Disarms the trigger's ACTION and dims it; the fold still opens, so what the tool offers stays visible (SplitToolButtonFoldAlwaysOpens, kol-fxr 2026-10-13 — user: *"even if nothing is applicable shouldn't it still show what's available"*). Grey the rows that do not apply with `variants[].disabled` (default: false)
|
|
59
59
|
* @param {ElementType} props.iconComponent - Glyph renderer receiving `{ name, size, className, style }` — Button's seam (default: DS `Icon`)
|
|
60
60
|
* @param {string} props.aria-label - Trigger label fallback when no variant resolves
|
|
61
61
|
*
|
|
@@ -108,12 +108,14 @@ const SplitToolButton = ({
|
|
|
108
108
|
/* Arm the last-picked variant on the same click that toggles the menu —
|
|
109
109
|
* floating-ui's useClick (on the reference) handles the open/close half. */
|
|
110
110
|
const handleTriggerClick = (event) => {
|
|
111
|
+
if (disabled) return
|
|
111
112
|
if (onTrigger) { if (triggerVariant) onTrigger(triggerVariant.id) }
|
|
112
113
|
else if (!active && triggerVariant) onChange?.(triggerVariant.id)
|
|
113
114
|
if (blurOnClick) event.currentTarget.blur()
|
|
114
115
|
}
|
|
115
116
|
|
|
116
117
|
const handleSelect = (variant) => {
|
|
118
|
+
if (variant.disabled) return
|
|
117
119
|
if (variant.onSelect) variant.onSelect()
|
|
118
120
|
else { onChange?.(variant.id); setOwnLast(variant.id) }
|
|
119
121
|
setOpen(false)
|
|
@@ -127,7 +129,9 @@ const SplitToolButton = ({
|
|
|
127
129
|
{...popover.getReferenceProps({ onClick: handleTriggerClick })}
|
|
128
130
|
type="button"
|
|
129
131
|
className={`relative kol-btn kol-btn-ghost kol-btn-icon kol-btn-${size} ${active ? 'kol-btn-pressed' : 'kol-btn-quiet'} ${className}`.trim()}
|
|
130
|
-
disabled
|
|
132
|
+
/* NOT the `disabled` attribute — that kills the click that opens the fold. Dimmed inline so
|
|
133
|
+
* it outranks the tool palette's `.kol-btn-quiet { opacity: 1 }`. */
|
|
134
|
+
style={disabled ? { opacity: 'var(--kol-opacity-disabled)' } : undefined}
|
|
131
135
|
aria-pressed={onTrigger ? undefined : active}
|
|
132
136
|
aria-label={label}
|
|
133
137
|
>
|
|
@@ -148,8 +152,11 @@ const SplitToolButton = ({
|
|
|
148
152
|
<button
|
|
149
153
|
key={variant.id}
|
|
150
154
|
type="button"
|
|
155
|
+
disabled={variant.disabled}
|
|
151
156
|
onClick={() => handleSelect(variant)}
|
|
152
|
-
|
|
157
|
+
/* `flex`, not `inline-flex` — inline rows in this `w-max` panel measured as one line,
|
|
158
|
+
* as wide as the canvas (MenuDropdownItemBlockRow's fix, 0.252.0, applied here) */
|
|
159
|
+
className="w-full kol-helper-12 px-3 h-8 flex items-center gap-2 text-body hover:text-emphasis disabled:opacity-40 disabled:cursor-not-allowed disabled:hover:text-body text-left"
|
|
153
160
|
>
|
|
154
161
|
<span className="shrink-0 w-4 inline-flex items-center justify-center">
|
|
155
162
|
<IconC name={variant.icon} size={14} />
|
|
@@ -22,8 +22,25 @@ import Hls from 'hls.js'
|
|
|
22
22
|
* @param {boolean} active plays only while true (default true) — an
|
|
23
23
|
* off-stage carousel slide pauses instead of autoplaying beside the
|
|
24
24
|
* active one (FeaturedCarouselFullWidth, 2026-08-26)
|
|
25
|
+
* @param {Object} hlsConfig hls.js config spread over `HLS_DEFAULTS`; read when `src` attaches
|
|
26
|
+
* (a changed object alone does not reload the stream)
|
|
25
27
|
*/
|
|
26
|
-
|
|
28
|
+
/* START WHERE THE PLAYER CAN SHOW IT (BackgroundVideoStartsAtLowestRendition, kol-website
|
|
29
|
+
* 2026-10-13 — user: *"why is this video so low res? … its super long lag till you get good res?"*).
|
|
30
|
+
* A bare `new Hls()` starts at the manifest's FIRST rendition (360p on every bucket master) on a
|
|
31
|
+
* 500 kbps guess and only climbs after measured fragments, so a 640px card played upscaled 360p
|
|
32
|
+
* until ABR caught up. Auto start level, a broadband guess until measured, and never above the
|
|
33
|
+
* element's own size. The ticket's three keys plus `testBandwidth: false`. */
|
|
34
|
+
export const HLS_DEFAULTS = {
|
|
35
|
+
startLevel: -1,
|
|
36
|
+
/* without this, an auto start still loads its FIRST fragment at the lowest rendition to measure
|
|
37
|
+
* bandwidth — measured 2026-10-13: 360 → 720 with it on, 720 from the first fragment with it off */
|
|
38
|
+
testBandwidth: false,
|
|
39
|
+
abrEwmaDefaultEstimate: 8_000_000,
|
|
40
|
+
capLevelToPlayerSize: true,
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export default function BackgroundVideo({ src, poster, className, onEnded, active = true, hlsConfig, ...props }) {
|
|
27
44
|
const videoRef = useRef(null)
|
|
28
45
|
|
|
29
46
|
useEffect(() => {
|
|
@@ -38,7 +55,7 @@ export default function BackgroundVideo({ src, poster, className, onEnded, activ
|
|
|
38
55
|
if (!video || !src) return
|
|
39
56
|
|
|
40
57
|
if (Hls.isSupported()) {
|
|
41
|
-
const hls = new Hls()
|
|
58
|
+
const hls = new Hls({ ...HLS_DEFAULTS, ...hlsConfig })
|
|
42
59
|
hls.loadSource(src)
|
|
43
60
|
hls.attachMedia(video)
|
|
44
61
|
return () => hls.destroy()
|
|
@@ -46,7 +63,7 @@ export default function BackgroundVideo({ src, poster, className, onEnded, activ
|
|
|
46
63
|
// Safari native HLS support
|
|
47
64
|
video.src = src
|
|
48
65
|
}
|
|
49
|
-
}, [src])
|
|
66
|
+
}, [src]) // eslint-disable-line react-hooks/exhaustive-deps -- hlsConfig is read at attach
|
|
50
67
|
|
|
51
68
|
return (
|
|
52
69
|
<video
|
|
@@ -34,8 +34,14 @@ import { Tooltip } from '../utilities/Popover.jsx'
|
|
|
34
34
|
* unaffected.
|
|
35
35
|
*
|
|
36
36
|
* The label also counter-SCALES rather than just re-sizing: `scale(1/zoom)`
|
|
37
|
-
*
|
|
38
|
-
*
|
|
37
|
+
* keeps its padding, radius and letter-spacing screen-constant too, which a
|
|
38
|
+
* font-size alone does not.
|
|
39
|
+
*
|
|
40
|
+
* THE LABEL DOES NOT ROTATE (SelectionOverlayLabelUpright, kol-fxr 2026-10-13 —
|
|
41
|
+
* user: *"the size here glued to the side is so small it can't be read"*). It
|
|
42
|
+
* sits outside the rotated chrome, upright and centred under the rotated box's
|
|
43
|
+
* BOUNDS — Figma's chip — so at −90° it reads below the box instead of standing
|
|
44
|
+
* on end against its side. 12px.
|
|
39
45
|
*
|
|
40
46
|
* @param {{x:number,y:number,w:number,h:number,rotation?:number}} box virtual-coord position + size; null/x==null → renders nothing. `rotation` in degrees turns the chrome with the box about its centre
|
|
41
47
|
* @param {boolean} showHandles render the 8 resize handles (default true)
|
|
@@ -86,8 +92,12 @@ export default function SelectionOverlay({
|
|
|
86
92
|
* the base 0 rather than throwing on `${{…}}deg` — editing chrome over
|
|
87
93
|
* animated transforms is a consumer-side v1 limitation, and fxr's guard. */
|
|
88
94
|
const rot = typeof box.rotation === 'number' ? box.rotation : 0
|
|
95
|
+
/* half the rotated box's axis-aligned height — the label hangs below that, centred */
|
|
96
|
+
const rad = (rot * Math.PI) / 180
|
|
97
|
+
const halfBoundsH = (Math.abs(w * Math.sin(rad)) + Math.abs(h * Math.cos(rad))) / 2
|
|
89
98
|
|
|
90
99
|
return (
|
|
100
|
+
<>
|
|
91
101
|
<div
|
|
92
102
|
style={{
|
|
93
103
|
position: 'absolute',
|
|
@@ -146,19 +156,19 @@ export default function SelectionOverlay({
|
|
|
146
156
|
}}
|
|
147
157
|
/>
|
|
148
158
|
))}
|
|
159
|
+
</div>
|
|
149
160
|
{showLabel && (
|
|
150
161
|
<span
|
|
151
162
|
style={{
|
|
152
163
|
position: 'absolute',
|
|
153
|
-
left:
|
|
154
|
-
top:
|
|
155
|
-
marginTop: 6 / zoom,
|
|
164
|
+
left: x + w / 2,
|
|
165
|
+
top: y + h / 2 + halfBoundsH + 6 / zoom,
|
|
156
166
|
/* counter-scale, not just a smaller font: padding, radius and
|
|
157
167
|
* tracking have to stay screen-constant too */
|
|
158
|
-
transform: `scale(${1 / zoom})`,
|
|
159
|
-
transformOrigin: 'top
|
|
168
|
+
transform: `translateX(-50%) scale(${1 / zoom})`,
|
|
169
|
+
transformOrigin: 'top center',
|
|
160
170
|
fontFamily: 'var(--kol-font-family-mono)',
|
|
161
|
-
fontSize:
|
|
171
|
+
fontSize: 12,
|
|
162
172
|
letterSpacing: '0.04em',
|
|
163
173
|
color: accentColor,
|
|
164
174
|
background: 'rgba(0,0,0,0.6)', /* a label chip on a canvas, not a scrim (sweep 2026-09-03) */
|
|
@@ -166,11 +176,12 @@ export default function SelectionOverlay({
|
|
|
166
176
|
borderRadius: 2,
|
|
167
177
|
whiteSpace: 'nowrap',
|
|
168
178
|
pointerEvents: 'none',
|
|
179
|
+
zIndex: 100,
|
|
169
180
|
}}
|
|
170
181
|
>
|
|
171
182
|
{labelFormatter(box)}
|
|
172
183
|
</span>
|
|
173
184
|
)}
|
|
174
|
-
|
|
185
|
+
</>
|
|
175
186
|
)
|
|
176
187
|
}
|