@kolkrabbi/kol-component 0.252.0 → 0.253.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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kolkrabbi/kol-component",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.253.0",
|
|
4
4
|
"description": "The core component library",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
"embla-carousel-react": "^8.6.0",
|
|
27
27
|
"pdfjs-dist": "^6.3.289",
|
|
28
28
|
"react-syntax-highlighter": "^16.1.1",
|
|
29
|
-
"@kolkrabbi/kol-
|
|
30
|
-
"@kolkrabbi/kol-
|
|
29
|
+
"@kolkrabbi/kol-search": "^0.3.0",
|
|
30
|
+
"@kolkrabbi/kol-markdown": "^0.1.3"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
33
|
"@kolkrabbi/kol-icons": ">=0.22.0",
|
|
@@ -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} />
|
|
@@ -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
|
}
|