@kolkrabbi/kol-component 0.279.0 → 0.281.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.281.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",
|
|
@@ -190,6 +190,8 @@ export default function ActionButton({
|
|
|
190
190
|
</button>
|
|
191
191
|
)
|
|
192
192
|
/* The label shows as the DS Tooltip, not a native `title` (kol-client-olina 2026-09-22) — and
|
|
193
|
-
* it follows the swap, so a Copy URL reads "Copied" while the check is up.
|
|
194
|
-
|
|
193
|
+
* it follows the swap, so a Copy URL reads "Copied" while the check is up. `asChild` anchors it to
|
|
194
|
+
* the control itself: a positioned control (CodeBlock's `kol-frame-control`) leaves the wrapper span
|
|
195
|
+
* behind in flow (kol-atlas 2026-10-19). */
|
|
196
|
+
return aria ? <Tooltip label={aria} asChild>{control}</Tooltip> : control
|
|
195
197
|
}
|
package/src/molecules/Modal.jsx
CHANGED
|
@@ -19,6 +19,13 @@ import ToggleCheckbox from '../atoms/ToggleCheckbox.jsx'
|
|
|
19
19
|
* stay OK / Cancel, existing callers untouched (ModalConfirmLabels,
|
|
20
20
|
* 2026-08-12). Enter/Escape keep their meanings regardless of labels.
|
|
21
21
|
*
|
|
22
|
+
* PASSWORD (ModalPromptPassword, kol-atlas 2026-10-19): `prompt(title, '', { type: 'password' })`
|
|
23
|
+
* masks the field (`autoComplete="current-password"`) for the family's sign-in prompts. The
|
|
24
|
+
* native fallback cannot mask — mount a ModalProvider. `placeholder` sits in the same options.
|
|
25
|
+
*
|
|
26
|
+
* KEYBOARD: the dialog opens focused (prompt → its field, confirm/alert → OK), Tab cycles inside
|
|
27
|
+
* it, and Enter on a focused button presses that button rather than submitting.
|
|
28
|
+
*
|
|
22
29
|
* Returned promise resolves to:
|
|
23
30
|
* - prompt → string (value) on submit, `null` on cancel
|
|
24
31
|
* - confirm → boolean: `true` on confirm, `false` on cancel
|
|
@@ -58,8 +65,8 @@ export function ModalProvider({ children }) {
|
|
|
58
65
|
})
|
|
59
66
|
}, [])
|
|
60
67
|
|
|
61
|
-
const prompt = useCallback((title, defaultValue = '', { okLabel, cancelLabel } = {}) =>
|
|
62
|
-
new Promise((resolve) => setState({ kind: 'prompt', title, defaultValue, okLabel, cancelLabel, resolve })),
|
|
68
|
+
const prompt = useCallback((title, defaultValue = '', { okLabel, cancelLabel, type = 'text', placeholder } = {}) =>
|
|
69
|
+
new Promise((resolve) => setState({ kind: 'prompt', title, defaultValue, okLabel, cancelLabel, type, placeholder, resolve })),
|
|
63
70
|
[])
|
|
64
71
|
|
|
65
72
|
const confirm = useCallback((title, { okLabel, cancelLabel, options } = {}) =>
|
|
@@ -85,6 +92,7 @@ function ModalView({ state, closeWith }) {
|
|
|
85
92
|
const [val, setVal] = useState(state.defaultValue ?? '')
|
|
86
93
|
const [values, setValues] = useState(() => Object.fromEntries((state.options ?? []).map((o) => [o.id, !!o.defaultValue])))
|
|
87
94
|
const inputRef = useRef(null)
|
|
95
|
+
const dialogRef = useRef(null)
|
|
88
96
|
|
|
89
97
|
/* alert resolves `undefined` whichever way it is dismissed; a confirm with toggles resolves
|
|
90
98
|
* `{ ok, values }` */
|
|
@@ -92,11 +100,24 @@ function ModalView({ state, closeWith }) {
|
|
|
92
100
|
const submit = () => closeWith(state.kind === 'prompt' ? val : state.kind === 'alert' ? undefined : answer(true))
|
|
93
101
|
const cancel = () => closeWith(state.kind === 'prompt' ? null : state.kind === 'alert' ? undefined : answer(false))
|
|
94
102
|
|
|
103
|
+
/* focus once on open — the key effect below re-runs per keystroke and would steal it back */
|
|
95
104
|
useEffect(() => {
|
|
96
105
|
if (state.kind === 'prompt') inputRef.current?.focus()
|
|
106
|
+
else dialogRef.current?.querySelector('[data-modal-ok]')?.focus()
|
|
107
|
+
}, [state.kind])
|
|
108
|
+
|
|
109
|
+
useEffect(() => {
|
|
97
110
|
const onKey = (e) => {
|
|
98
111
|
if (e.key === 'Escape') cancel()
|
|
99
|
-
if (e.key === 'Enter')
|
|
112
|
+
if (e.key === 'Enter' && e.target.tagName !== 'BUTTON') submit()
|
|
113
|
+
if (e.key === 'Tab') {
|
|
114
|
+
const els = [...(dialogRef.current?.querySelectorAll('button, input') ?? [])].filter((el) => !el.disabled)
|
|
115
|
+
if (!els.length) return
|
|
116
|
+
const i = els.indexOf(document.activeElement)
|
|
117
|
+
const next = e.shiftKey ? (i <= 0 ? els.length - 1 : i - 1) : (i === els.length - 1 ? 0 : i + 1)
|
|
118
|
+
e.preventDefault()
|
|
119
|
+
els[next].focus()
|
|
120
|
+
}
|
|
100
121
|
}
|
|
101
122
|
window.addEventListener('keydown', onKey)
|
|
102
123
|
return () => window.removeEventListener('keydown', onKey)
|
|
@@ -115,6 +136,10 @@ function ModalView({ state, closeWith }) {
|
|
|
115
136
|
}}
|
|
116
137
|
>
|
|
117
138
|
<div
|
|
139
|
+
ref={dialogRef}
|
|
140
|
+
role={state.kind === 'prompt' ? 'dialog' : 'alertdialog'}
|
|
141
|
+
aria-modal="true"
|
|
142
|
+
aria-labelledby="kol-modal-title"
|
|
118
143
|
onMouseDown={(e) => e.stopPropagation()}
|
|
119
144
|
className="kol-modal flex flex-col gap-4 p-5 rounded border border-fg-08"
|
|
120
145
|
style={{
|
|
@@ -127,10 +152,13 @@ function ModalView({ state, closeWith }) {
|
|
|
127
152
|
{/* kol-mono-12, not helper: dialog copy WRAPS, and helper's
|
|
128
153
|
* line-height 1 is single-line chrome only (type protocol). */}
|
|
129
154
|
{/* pre-line: an alert can carry a failure list, one per line */}
|
|
130
|
-
<p className="kol-mono-12 text-emphasis whitespace-pre-line">{state.title}</p>
|
|
155
|
+
<p id="kol-modal-title" className="kol-mono-12 text-emphasis whitespace-pre-line">{state.title}</p>
|
|
131
156
|
{state.kind === 'prompt' && (
|
|
132
157
|
<Input
|
|
133
158
|
ref={inputRef}
|
|
159
|
+
type={state.type}
|
|
160
|
+
autoComplete={state.type === 'password' ? 'current-password' : undefined}
|
|
161
|
+
placeholder={state.placeholder}
|
|
134
162
|
variant="outline"
|
|
135
163
|
size="sm"
|
|
136
164
|
value={val}
|
|
@@ -153,7 +181,9 @@ function ModalView({ state, closeWith }) {
|
|
|
153
181
|
)}
|
|
154
182
|
<div className="flex gap-2 justify-end">
|
|
155
183
|
{state.kind !== 'alert' && <Button size="sm" onClick={cancel}>{state.cancelLabel ?? 'Cancel'}</Button>}
|
|
156
|
-
|
|
184
|
+
{/* inverted, not primary: since tone-is-the-ground-axis (2026-09-03) primary is the
|
|
185
|
+
* dark ground, so OK drew the same as Cancel and nothing showed what Enter does */}
|
|
186
|
+
<Button tone="inverted" size="sm" onClick={submit} data-modal-ok>{state.okLabel ?? 'OK'}</Button>
|
|
157
187
|
</div>
|
|
158
188
|
</div>
|
|
159
189
|
</div>
|
|
@@ -636,6 +636,9 @@ export function MediaInspector({ files, index, onClose, onPrev, onNext, mediaUrl
|
|
|
636
636
|
* which remounts whenever the kind changes */
|
|
637
637
|
const [size, setSize] = useState(null)
|
|
638
638
|
const shownDims = dims && dims.key === o?.key ? dims : null
|
|
639
|
+
/* fill width is per file: paging lands on a key that is not this one, so it opens in fit */
|
|
640
|
+
const [fillKey, setFillKey] = useState(null)
|
|
641
|
+
const fill = fillKey != null && fillKey === o?.key
|
|
639
642
|
useEffect(() => {
|
|
640
643
|
const onKey = (e) => { if (e.shiftKey) return; if (e.key === 'ArrowLeft') onPrev(); if (e.key === 'ArrowRight') onNext() }
|
|
641
644
|
window.addEventListener('keydown', onKey)
|
|
@@ -694,11 +697,14 @@ export function MediaInspector({ files, index, onClose, onPrev, onNext, mediaUrl
|
|
|
694
697
|
</QuickLookFrame>
|
|
695
698
|
) : isImage(o.contentType) ? (
|
|
696
699
|
<QuickLookFrame {...frame}>
|
|
697
|
-
{/* A VECTOR HAS NO PIXEL SIZE (user 2026-09-24: a 32px logo.svg opened as a 32px
|
|
698
|
-
*
|
|
700
|
+
{/* A SMALL VECTOR HAS NO USEFUL PIXEL SIZE (user 2026-09-24: a 32px logo.svg opened as a 32px
|
|
701
|
+
* window). One under 640 wide — or with no size at all — is drawn in a 640 box, the window's
|
|
702
|
+
* max if that is smaller; a big one fits the window like a raster (kol-atlas 2026-10-19: its
|
|
703
|
+
* 1200×800 cards sat in the 640 box). A click toggles fit ↔ fill width; paging resets to fit. */}
|
|
699
704
|
<img src={mediaUrl(o.key)} alt={o.displayKey}
|
|
700
|
-
className=
|
|
701
|
-
style={extOf(o.key) === 'svg' || o.contentType === 'image/svg+xml' ? { width: 'min(var(--kol-ql-max-w), 640px)', height: 'min(var(--kol-ql-media-h), 640px)' } : undefined}
|
|
705
|
+
className={`kol-quicklook-media${fill ? ' kol-quicklook-media--fill' : ''}`}
|
|
706
|
+
style={!fill && (extOf(o.key) === 'svg' || o.contentType === 'image/svg+xml') && !(shownDims?.w >= 640) ? { width: 'min(var(--kol-ql-max-w), 640px)', height: 'min(var(--kol-ql-media-h), 640px)' } : undefined}
|
|
707
|
+
onClick={() => setFillKey(fill ? null : o.key)}
|
|
702
708
|
onLoad={(e) => setDims({ key: o.key, w: e.target.naturalWidth, h: e.target.naturalHeight })} />
|
|
703
709
|
</QuickLookFrame>
|
|
704
710
|
) : isVideo(o.contentType) ? (
|