@gecko-ui-kit/react 0.0.0-stage → 0.3.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/src/motion.js ADDED
@@ -0,0 +1,176 @@
1
+ 'use client';
2
+ /* Motions from @gecko-ui-kit/motion that wrap elements you already have: Rise (rise / slide / deal / reveal
3
+ entrances), Magnetic, Lift, Tilt, Spotlight and Marquee. Any other helper (flash, pop, shake, swap…) runs on
4
+ your own element with useMotion(fn, options) from the core. */
5
+ import { Children, forwardRef, useEffect, useImperativeHandle, useRef } from 'react';
6
+ import * as M from '@gecko-ui-kit/motion';
7
+ import { h, cx, same, changedOnly, useLatest, useIsoLayoutEffect, enhancer } from './core.js';
8
+
9
+ /* ---------------- Rise ---------------- */
10
+
11
+ const KINDS = ['rise', 'slide', 'deal', 'reveal'];
12
+ /**
13
+ * <Rise className="gk-grid">{bikes.map((b) => <BikeCard key={b.id} bike={b} />)}</Rise>
14
+ * <Rise kind="slide" x={-24} stagger={0.04}>{rows}</Rise> <Rise kind="deal" tilt={4}>{cards}</Rise>
15
+ * Same as rise / slide / deal(els, options): the children arrive one after another when it mounts, and children
16
+ * added later arrive the same way (animateNew). kind="reveal" is the small fade-down of reveal(el, y) on the
17
+ * element itself (an accordion body). items: a selector inside instead of the direct children.
18
+ */
19
+ export const Rise = forwardRef(function Rise({ as, kind = 'rise', items, y, x, stagger, delay, duration, tilt, animateNew = true, children, ...rest }, ref) {
20
+ const el = useRef(null), seen = useRef(null);
21
+ const o = useLatest({ kind: KINDS.includes(kind) ? kind : 'rise', items, y, x, stagger, delay, duration, tilt });
22
+ useImperativeHandle(ref, () => el.current, []);
23
+ const targets = (node) => {
24
+ const { kind: k, items: sel } = o.current;
25
+ if (!node) return [];
26
+ if (sel) return [...node.querySelectorAll(sel)];
27
+ return k === 'reveal' ? [node] : [...node.children];
28
+ };
29
+ const play = (els, first) => {
30
+ const { kind: k, y, x, stagger, delay, duration, tilt } = o.current;
31
+ const d = first ? delay : 0;
32
+ if (k === 'slide') M.slide(els, { x, y, stagger, delay: d, duration });
33
+ else if (k === 'deal') M.deal(els, { stagger, delay: d, tilt });
34
+ else if (k === 'reveal') els.forEach((e) => M.reveal(e, y));
35
+ else M.rise(els, { y, stagger, delay: d, duration });
36
+ };
37
+ useIsoLayoutEffect(() => {
38
+ const node = el.current, all = targets(node);
39
+ seen.current = new WeakSet(all);
40
+ play(all, true);
41
+ return () => {
42
+ seen.current = null;
43
+ const now = [...new Set([...all, ...targets(node)])];
44
+ M.g.killTweensOf(now); M.g.set(now, { clearProps: 'transform,opacity' });
45
+ };
46
+ }, []);
47
+ useIsoLayoutEffect(() => {
48
+ const s = seen.current; if (!s || !animateNew) return;
49
+ const fresh = targets(el.current).filter((t) => !s.has(t));
50
+ fresh.forEach((t) => s.add(t));
51
+ if (fresh.length) play(fresh, false);
52
+ });
53
+ return h(as || 'div', { ref: el, ...rest }, children);
54
+ });
55
+
56
+ /* ---------------- Magnetic & Lift ---------------- */
57
+
58
+ const MagneticMotion = enhancer('Magnetic', (el, o) => M.magnetic(el, o), { tag: 'span', options: ['strength', 'strengthY'] });
59
+ /**
60
+ * <Magnetic><Button variant="primary" iconRight="arrowR">Book a bike</Button></Magnetic>
61
+ * Same as magnetic(el, { strength, strengthY }): the element leans toward the pointer and springs back
62
+ * (mouse / trackpad only). magnet multiplies the pull (data-magnet). as="a" makes the element itself magnetic.
63
+ */
64
+ export const Magnetic = forwardRef(function Magnetic({ magnet, className, style, ...props }, ref) {
65
+ return h(MagneticMotion, {
66
+ ...props, ref, 'data-magnet': magnet, className: cx('gk-magnetic', className),
67
+ style: props.as ? style : { display: 'inline-block', ...style },
68
+ });
69
+ });
70
+ Magnetic.displayName = 'Magnetic';
71
+
72
+ const LiftMotion = enhancer('Lift', (el, o) => M.lift(el, o.y), { options: ['y'] });
73
+ /**
74
+ * <Lift as="article" y={-6} className="gk-card">…</Lift>
75
+ * Same as lift(el, y): the element rises a few pixels while the pointer is over it (mouse / trackpad only).
76
+ */
77
+ export const Lift = forwardRef(function Lift(props, ref) {
78
+ return h(LiftMotion, { ...props, ref, 'data-lift': props.y != null ? String(props.y) : '' });
79
+ });
80
+ Lift.displayName = 'Lift';
81
+
82
+ /* ---------------- Tilt ---------------- */
83
+
84
+ const TiltMotion = enhancer('Tilt', (el, o) => M.tilt(el, o), {
85
+ options: ['max', 'scale', 'perspective', 'glare', 'parallax', 'follow', 'spring'], rerunOnChildren: true,
86
+ });
87
+ /**
88
+ * <Tilt max={12} glare className="gk-card"><img data-depth="40" src="lamp.png" alt="" /><h3 data-depth="20">Lamp</h3></Tilt>
89
+ * Same as tilt(el, options). Children with data-depth float above the card. as="article" changes the element.
90
+ */
91
+ export const Tilt = forwardRef(function Tilt({ className, ...props }, ref) {
92
+ return h(TiltMotion, { ...props, ref, className: cx('gk-tilt', className) });
93
+ });
94
+ Tilt.displayName = 'Tilt';
95
+
96
+ /* ---------------- Spotlight ---------------- */
97
+
98
+ const SpotlightMotion = enhancer('Spotlight', (el, o) => M.spotlight(el, o), {
99
+ options: ['items', 'size', 'follow', 'border', 'fill', 'focus'], rerunOnChildren: true,
100
+ });
101
+ /**
102
+ * <Spotlight className="plans" size={300}>{plans.map((p) => <div className="gk-card" key={p.id}>…</div>)}</Spotlight>
103
+ * Same as spotlight(group, options): a soft light follows the pointer across the cards (its children, or `items`)
104
+ * and lights up their edges; a card with keyboard focus pulls the light onto itself.
105
+ */
106
+ export const Spotlight = forwardRef(function Spotlight({ className, ...props }, ref) {
107
+ return h(SpotlightMotion, {
108
+ ...props, ref,
109
+ className: cx('gk-spotlight', props.border === false && 'gk-spotlight--no-ring', props.fill === false && 'gk-spotlight--no-fill', className),
110
+ });
111
+ });
112
+ Spotlight.displayName = 'Spotlight';
113
+
114
+ /* ---------------- Marquee ---------------- */
115
+
116
+ const MQ_SET = ['speed', 'direction', 'gap', 'fade'];
117
+ const MQ_KEYS = [...MQ_SET, 'pauseOnHover', 'button', 'words', 'paused'];
118
+ const resolve = (x) => (x && typeof x === 'object' && 'current' in x ? x.current : x) ?? null;
119
+ const live = (o, latest) => {
120
+ const out = {};
121
+ for (const k in o) { const v = o[k]; out[k] = typeof v === 'function' ? (...a) => latest.current[k]?.(...a) : v; }
122
+ return out;
123
+ };
124
+ /* A fingerprint of the items, so the copies are measured again when they change. */
125
+ const keyOf = (c) => (c == null || typeof c === 'boolean' ? '' : typeof c !== 'object' ? String(c) : Array.isArray(c) ? c.map(keyOf).join('\u0001')
126
+ : c.props ? `<${c.key ?? ''}>${keyOf(c.props.children)}` : '?');
127
+
128
+ /**
129
+ * <Marquee aria-label="Our partners" speed={50} gap={48}>{logos.map((l) => <img key={l.id} src={l.src} alt={l.name} />)}</Marquee>
130
+ * Same as marquee(el, options): an endless strip; each child becomes one item (an <li>). Hover or focus slows it
131
+ * to a stop; `paused` stops it; button (element, ref or selector) gets play/pause wiring. speed, direction, gap
132
+ * and fade change in place; new items are measured again. ref → { play(), pause(), toggle(), paused, refresh(), el }.
133
+ */
134
+ export const Marquee = forwardRef(function Marquee({ as, listAs = 'ul', className, style, children, ...props }, ref) {
135
+ const o = {}, dom = {};
136
+ for (const k in props) { if (MQ_KEYS.includes(k)) { if (props[k] !== undefined) o[k] = props[k]; } else dom[k] = props[k]; }
137
+ const latest = useLatest(o);
138
+ const el = useRef(null), cur = useRef(null), mine = useRef('');
139
+ const items = keyOf(children);
140
+ const own = cx('gk-marquee', o.fade !== false && 'gk-marquee--fade', className);
141
+ const node = el.current, ours = new Set(mine.current.split(/\s+/));
142
+ const kept = node ? [...node.classList].filter((c) => !ours.has(c)).join(' ') : '';
143
+ const proxy = useRef(null);
144
+ if (!proxy.current) {
145
+ proxy.current = new Proxy({}, {
146
+ get(_, k) { if (k === 'el') return el.current; const m = cur.current?.m; if (!m) return undefined; const v = m[k]; return typeof v === 'function' ? v.bind(m) : v; },
147
+ has(_, k) { return k === 'el' || (!!cur.current?.m && k in cur.current.m); },
148
+ });
149
+ }
150
+ useImperativeHandle(ref, () => proxy.current, []);
151
+
152
+ const start = () => {
153
+ const { paused, button, ...rest } = live(latest.current, latest);
154
+ const m = M.marquee(el.current, { ...rest, button: resolve(button) });
155
+ if (paused) m.pause();
156
+ cur.current = { m, o: latest.current, items };
157
+ };
158
+ const end = () => { const c = cur.current; cur.current = null; c?.m.destroy(); };
159
+ useIsoLayoutEffect(() => { mine.current = own; });
160
+ useEffect(() => { start(); return end; }, []); // after paint: a button ref of a sibling is set by then
161
+ useEffect(() => {
162
+ const c = cur.current; if (!c) return;
163
+ const next = latest.current, prev = c.o;
164
+ if (!same(next, prev)) {
165
+ if (!changedOnly(next, prev, [...MQ_SET, 'paused'])) { end(); start(); return; }
166
+ if (MQ_SET.some((k) => !same(next[k], prev[k]))) c.m.set({ speed: 50, direction: 'left', fade: true, ...Object.fromEntries(MQ_SET.filter((k) => next[k] !== undefined).map((k) => [k, next[k]])) });
167
+ if (!!next.paused !== !!prev.paused) (next.paused ? c.m.pause() : c.m.play());
168
+ c.o = next;
169
+ }
170
+ if (c.items !== items) { c.items = items; c.m.refresh(); }
171
+ });
172
+ const gap = o.gap != null ? { '--gk-marquee-gap': typeof o.gap === 'number' ? `${o.gap}px` : o.gap } : null;
173
+ const item = listAs === 'ul' || listAs === 'ol' ? 'li' : 'div';
174
+ return h(as || 'div', { ref: el, ...dom, className: cx(own, kept), style: gap ? { ...gap, ...style } : style },
175
+ h(listAs, { className: 'gk-marquee__list' }, Children.map(children, (c) => (c == null || typeof c === 'boolean' ? null : h(item, null, c)))));
176
+ });
@@ -0,0 +1,454 @@
1
+ import type * as React from 'react';
2
+
3
+ /** An element, a ref to one, or (where it says so) a CSS selector. */
4
+ export type AnchorLike = HTMLElement | React.RefObject<HTMLElement | null> | null | undefined;
5
+
6
+ export interface ModalProps {
7
+ /** Labels: { close } is the ✕ button's accessible name (default 'Close'). */
8
+ words?: { close?: string };
9
+ /** Open (true) or closed (false). It opens and closes with its animation. */
10
+ open: boolean;
11
+ /** Called when the modal closes itself (✕, scrim, Esc): set open to false here. */
12
+ onClose?: () => void;
13
+ /** The heading. Text or React nodes; may change while open. */
14
+ title?: React.ReactNode;
15
+ /** A smaller line under the heading. Text or React nodes; may change while open. */
16
+ sub?: React.ReactNode;
17
+ /** '' (540px), 'sm' (420px) or 'lg' (760px). */
18
+ size?: '' | 'sm' | 'lg';
19
+ /** The element it zooms out of: an element or a ref to one. */
20
+ anchor?: AnchorLike;
21
+ /** Buttons at the bottom. */
22
+ footer?: React.ReactNode;
23
+ /** The body. */
24
+ children?: React.ReactNode;
25
+ }
26
+ /** <Modal open={open} onClose={() => setOpen(false)} title="Edit">…</Modal> — zooms out of `anchor`; bottom sheet on phones. */
27
+ export function Modal(props: ModalProps): React.ReactElement | null;
28
+
29
+ export interface DrawerProps {
30
+ /** Labels: { close } is the ✕ button's accessible name (default 'Close'). */
31
+ words?: { close?: string };
32
+ /** Open (true) or closed (false). */
33
+ open: boolean;
34
+ /** Called when the drawer closes itself (✕, scrim, Esc, another drawer opening): set open to false here. */
35
+ onClose?: () => void;
36
+ /** The heading. Text or React nodes. */
37
+ title?: React.ReactNode;
38
+ /** A smaller line under the heading. */
39
+ sub?: React.ReactNode;
40
+ /** Something before the heading, e.g. an avatar. */
41
+ head?: React.ReactNode;
42
+ /** Which side it slides in from (phones: always a bottom sheet). Default 'right'. */
43
+ side?: 'right' | 'left';
44
+ /** Buttons at the bottom. */
45
+ footer?: React.ReactNode;
46
+ /** The body; its children drift up one by one as it lands. */
47
+ children?: React.ReactNode;
48
+ }
49
+ /** <Drawer open={open} onClose={() => setOpen(false)} title="Somchai K.">…</Drawer> */
50
+ export function Drawer(props: DrawerProps): React.ReactElement | null;
51
+
52
+ export interface ConfirmOptions {
53
+ /** The question. Plain text. Default 'Are you sure?'. */
54
+ title?: string;
55
+ /** More detail under it. Plain text. */
56
+ body?: string;
57
+ /** The OK button's text. Default 'Confirm'. */
58
+ ok?: string;
59
+ /** The cancel button's text. Default 'Cancel'. */
60
+ cancel?: string;
61
+ /** A red OK button (for deleting). */
62
+ danger?: boolean;
63
+ /** The element it zooms out of. */
64
+ anchor?: AnchorLike;
65
+ }
66
+ /** const ok = await confirm({ title, body, ok: 'Delete', danger: true }) — true for OK, false otherwise. Text only (safe). */
67
+ export function confirm(options?: ConfirmOptions): Promise<boolean>;
68
+ /** const confirm = useConfirm(); — the same, and a dialog still open when the component unmounts is closed. */
69
+ export function useConfirm(): (options?: ConfirmOptions) => Promise<boolean>;
70
+
71
+ export interface PopoverHandle {
72
+ open(): void;
73
+ close(): void;
74
+ /** True while it is open. */
75
+ readonly isOpen: boolean;
76
+ /** The open panel (.gk-pop), or null. */
77
+ readonly el: HTMLElement | null;
78
+ }
79
+ export interface PopoverProps {
80
+ /** What goes inside: React nodes, or (close) => nodes. */
81
+ content: React.ReactNode | ((close: () => void) => React.ReactNode);
82
+ /** Controlled: open or not. Leave it out to let a click on the trigger toggle it. */
83
+ open?: boolean;
84
+ /** Uncontrolled: start open. */
85
+ defaultOpen?: boolean;
86
+ /** Called with the new state when the trigger is clicked or it closes itself (click outside, Esc, resize). */
87
+ onOpenChange?: (open: boolean) => void;
88
+ /** Line it up with the trigger's start, center or end. Default 'start'. */
89
+ align?: 'start' | 'center' | 'end';
90
+ /** Extra class on the panel, e.g. 'pop--wide' (380px). */
91
+ className?: string;
92
+ /** Read out by screen readers. */
93
+ label?: string;
94
+ /** The trigger: one element (a button). */
95
+ children: React.ReactElement;
96
+ }
97
+ /** <Popover content={<ShareForm />}><Button>Share</Button></Popover> — pops out of its trigger. */
98
+ export const Popover: React.ForwardRefExoticComponent<PopoverProps & React.RefAttributes<PopoverHandle>>;
99
+
100
+ /** A menu row: '-' is a line, { section } a small heading, anything else an action. */
101
+ export type MenuItem = '-' | { section: string } | {
102
+ /** Text of the row. */
103
+ label: string;
104
+ /** An icon name from @gecko-ui-kit/icons. */
105
+ icon?: string;
106
+ /** A shortcut hint shown on the right (bind the key yourself). */
107
+ kbd?: string;
108
+ /** Red text, for deleting. */
109
+ danger?: boolean;
110
+ /** Runs after the menu closed, with the trigger element. */
111
+ run?: (trigger: HTMLElement) => void;
112
+ /** Anything else you need back in onSelect. */
113
+ [key: string]: unknown;
114
+ };
115
+ export interface MenuHandle {
116
+ open(): void;
117
+ close(): void;
118
+ readonly isOpen: boolean;
119
+ }
120
+ export interface MenuProps {
121
+ /** The rows. */
122
+ items: MenuItem[];
123
+ /** Called after an action row is picked (after its run), with the item and its index in items. */
124
+ onSelect?: (item: Exclude<MenuItem, '-' | { section: string }>, index: number) => void;
125
+ /** Line it up with the trigger's start, center or end. Default 'start'. */
126
+ align?: 'start' | 'center' | 'end';
127
+ /** Extra class on the panel. */
128
+ className?: string;
129
+ /** Read out by screen readers. */
130
+ label?: string;
131
+ /** The trigger: one element (a button). */
132
+ children: React.ReactElement;
133
+ }
134
+ /** <Menu items={[…]} onSelect={…}><IconButton icon="more" label="More" /></Menu> */
135
+ export const Menu: React.ForwardRefExoticComponent<MenuProps & React.RefAttributes<MenuHandle>>;
136
+
137
+ /** A context-menu row: '-' / { sep: true } a line, { section } a heading, { items } a submenu, { checked } a tick. */
138
+ export type ContextMenuItem = '-' | { sep: true } | { section: string } | {
139
+ /** Text of the row. */
140
+ label: string;
141
+ /** An icon name from @gecko-ui-kit/icons. */
142
+ icon?: string;
143
+ /** A shortcut hint shown on the right (bind the key yourself). */
144
+ kbd?: string;
145
+ /** A second, smaller line. */
146
+ hint?: string;
147
+ /** Greyed out; it shakes when clicked. */
148
+ disabled?: boolean;
149
+ /** Red text, for deleting. */
150
+ danger?: boolean;
151
+ /** A tick column; picking flips it (on a copy) before run / onSelect get the item. */
152
+ checked?: boolean;
153
+ /** A submenu. */
154
+ items?: ContextMenuItem[];
155
+ /** Runs after the menu closed, with the element that was right-clicked and the (copied) item. */
156
+ run?: (el: HTMLElement, item: any) => void;
157
+ [key: string]: unknown;
158
+ };
159
+ export interface ContextMenuHandle {
160
+ /** Open it at a point (viewport px), for the element el (default: the wrapper). */
161
+ open(x: number, y: number, el?: HTMLElement): boolean | undefined;
162
+ close(): void;
163
+ readonly isOpen: boolean;
164
+ /** The open menu, or null. */
165
+ readonly menu: HTMLElement | null;
166
+ /** The wrapper element. */
167
+ readonly el: HTMLElement | null;
168
+ }
169
+ export interface ContextMenuProps extends Omit<React.HTMLAttributes<HTMLElement>, 'onSelect'> {
170
+ /** The rows, or (event, el) => rows on every open (event is null for ref.open()). Return [] for the browser's own menu. */
171
+ items: ContextMenuItem[] | ((event: Event | null, el: HTMLElement) => ContextMenuItem[] | null | undefined);
172
+ /** Called after a row is picked (after its run), with the (copied) item and the element. */
173
+ onSelect?: (item: any, el: HTMLElement) => void;
174
+ /** Called when it opens / closes, with the element. */
175
+ onOpen?: (el: HTMLElement) => void;
176
+ onClose?: (el: HTMLElement) => void;
177
+ /** Only elements inside that match open the menu (el = that element). */
178
+ selector?: string;
179
+ /** ms a finger must rest to open it on touch (0 = off). Default 500. */
180
+ longPress?: number;
181
+ /** Shift + right-click shows the browser's own menu. Default true. */
182
+ nativeOnShift?: boolean;
183
+ /** Show item icons. Default true. */
184
+ icons?: boolean;
185
+ /** Show kbd hints. Default true. */
186
+ shortcuts?: boolean;
187
+ /** label: the menu's name for screen readers (text or (el) => text). */
188
+ words?: { label?: string | ((el: HTMLElement) => string) };
189
+ /** The wrapper element. Default 'div'. */
190
+ as?: React.ElementType;
191
+ children?: React.ReactNode;
192
+ }
193
+ /** <ContextMenu items={…}>…</ContextMenu> — right-click / long-press / Shift+F10 menu that grows from the pointer. */
194
+ export const ContextMenu: React.ForwardRefExoticComponent<ContextMenuProps & React.RefAttributes<ContextMenuHandle>>;
195
+
196
+ export interface TooltipProps {
197
+ /** The label: text (a line break makes a second line) or React nodes. Empty = no tooltip. */
198
+ text: React.ReactNode;
199
+ /** 'below' (default) or 'right' (beside it, as in a collapsed sidebar). */
200
+ side?: 'below' | 'right';
201
+ /** Turn it off for now. */
202
+ disabled?: boolean;
203
+ /** The element it explains: one element. */
204
+ children: React.ReactElement;
205
+ }
206
+ /** <Tooltip text="Edit"><IconButton icon="edit" label="Edit" /></Tooltip> — on hover / focus; hidden on phones. */
207
+ export function Tooltip(props: TooltipProps): React.ReactElement;
208
+
209
+ export interface ToastOptions {
210
+ /** Shows an Undo button that calls this. */
211
+ undo?: () => void;
212
+ /** Colour of the icon: '' | 'good' | 'warn' | 'bad'. */
213
+ tone?: '' | 'good' | 'warn' | 'bad';
214
+ /** Old shortcut for tone: 'warn'. */
215
+ warn?: boolean;
216
+ /** An icon name. Default 'check' ('alert' for warn). */
217
+ icon?: string;
218
+ /** ms before it goes. Default 4200. */
219
+ duration?: number;
220
+ /** Text of the Undo button. Default 'Undo'. */
221
+ undoLabel?: string;
222
+ /** Toast shown after Undo. Default 'Undone'. */
223
+ undoneText?: string;
224
+ }
225
+ /** toast('Booking saved', { tone: 'good' }) → close(). Call it from anywhere in the browser. Plain text (safe). */
226
+ export function toast(text: string, options?: ToastOptions): () => void;
227
+
228
+ export interface CookieCategory {
229
+ /** Key in the choices object. */
230
+ id: string;
231
+ /** Name shown. */
232
+ label?: string;
233
+ /** A line about it. */
234
+ text?: string;
235
+ /** Always on and locked (e.g. necessary). */
236
+ required?: boolean;
237
+ }
238
+ export type CookieChoices = Record<string, boolean>;
239
+ export interface CookieBannerHandle {
240
+ /** The saved choice, or null if none yet. */
241
+ readonly choices: CookieChoices | null;
242
+ /** True while it is on screen. */
243
+ readonly visible: boolean;
244
+ /** The banner element. */
245
+ readonly el: HTMLElement | null;
246
+ /** True when that type is allowed (required ones always are). */
247
+ allowed(id: string): boolean;
248
+ /** Bring it back (e.g. from a "Cookie settings" link). settings: open the switches too. */
249
+ open(options?: { settings?: boolean; focus?: boolean }): void;
250
+ close(): void;
251
+ /** Forget the saved choice. */
252
+ reset(): void;
253
+ }
254
+ export interface CookieBannerProps {
255
+ /** The cookie types. Default: necessary (locked on), analytics, marketing. */
256
+ categories?: CookieCategory[];
257
+ /** Where the choice is saved in localStorage ('' = not saved). Default 'gecko:consent'. */
258
+ storageKey?: string;
259
+ /** Raise it when the categories change: everyone is asked again. Default 1. */
260
+ version?: number;
261
+ /** 'auto' = show when there is no saved choice; false = only on ref.open(). */
262
+ show?: 'auto' | false;
263
+ /** 'bottom' (full-width bar) or 'start' / 'end' (a card in a bottom corner). */
264
+ position?: 'bottom' | 'start' | 'end';
265
+ /** Show it along the bottom of this element instead of the window. */
266
+ mount?: AnchorLike | string;
267
+ /** Link to your privacy policy. */
268
+ policy?: string;
269
+ /** Texts: label, title, text, accept, reject, settings, save, always, policy. */
270
+ words?: Partial<Record<'label' | 'title' | 'text' | 'accept' | 'reject' | 'settings' | 'save' | 'always' | 'policy', string>>;
271
+ /** Called after a choice, with every type → allowed, and { action: 'accept' | 'reject' | 'save', at }. */
272
+ onChange?: (choices: CookieChoices, info: { action: 'accept' | 'reject' | 'save'; at: number }) => void;
273
+ }
274
+ /** <CookieBanner policy="/privacy" onChange={…} /> — asks once which cookies are allowed, remembers it. */
275
+ export const CookieBanner: React.ForwardRefExoticComponent<CookieBannerProps & React.RefAttributes<CookieBannerHandle>>;
276
+
277
+ export interface LoadingBarOptions {
278
+ /** Element (or ref / selector) to run along the top of. Default: the window. */
279
+ mount?: AnchorLike | string;
280
+ /** Height in px (or any CSS length). Default 3. */
281
+ height?: number | string;
282
+ /** Any CSS colour. Default var(--gk-accent). */
283
+ color?: string;
284
+ /** Creep forward on its own: true, a speed (0.5 slower, 2 faster) or false. */
285
+ trickle?: boolean | number;
286
+ /** ms to wait before showing; loads done sooner never show it. Default 150. */
287
+ delay?: number;
288
+ /** The progress bar's name for screen readers. */
289
+ label?: string;
290
+ /** Texts: label, and loading / done / failed (announced politely; '' = say nothing). */
291
+ words?: Partial<Record<'label' | 'loading' | 'done' | 'failed', string>>;
292
+ }
293
+ export interface LoadingBarHandle {
294
+ /** Start a load (every start needs its done). */
295
+ start(): LoadingBarHandle;
296
+ /** Finish a load; done(true) finishes even if other loads still run. */
297
+ done(all?: boolean): LoadingBarHandle;
298
+ /** Turn red, run to the end, fade. */
299
+ fail(): LoadingBarHandle;
300
+ /** Jump to 0..1 (starts it if it isn't running). */
301
+ set(value: number): LoadingBarHandle;
302
+ /** Move forward by n (starts it if it isn't running). */
303
+ inc(n?: number): LoadingBarHandle;
304
+ readonly value: number;
305
+ readonly loads: number;
306
+ readonly active: boolean;
307
+ readonly el: HTMLElement | null;
308
+ }
309
+ /** const bar = useLoadingBar(); bar.start(); … bar.done() — removed when the component unmounts. */
310
+ export function useLoadingBar(options?: LoadingBarOptions): LoadingBarHandle;
311
+ export interface LoadingBarProps extends LoadingBarOptions {
312
+ /** Starts the bar when it turns true, finishes it when it turns false. */
313
+ active?: boolean;
314
+ }
315
+ /** <LoadingBar active={isPending} /> — the thin loading line along the top. */
316
+ export const LoadingBar: React.ForwardRefExoticComponent<LoadingBarProps & React.RefAttributes<LoadingBarHandle>>;
317
+
318
+ export interface PaletteItem {
319
+ /** Main text. */
320
+ title: string;
321
+ /** Smaller line. */
322
+ sub?: string;
323
+ /** An icon name. Default 'arrowR'. */
324
+ icon?: string;
325
+ /** Runs after the palette closed. */
326
+ run?: () => void;
327
+ [key: string]: unknown;
328
+ }
329
+ export interface PaletteGroup {
330
+ /** Small heading over the group. */
331
+ label: string;
332
+ items: PaletteItem[];
333
+ }
334
+ export interface CommandPaletteProps {
335
+ /** Open (true) or closed (false). */
336
+ open: boolean;
337
+ /** Called when it closes itself (Esc, scrim, an item picked): set open to false here. */
338
+ onClose?: () => void;
339
+ /** Called after an item is picked (after its run). */
340
+ onSelect?: (item: PaletteItem) => void;
341
+ /** (q) → groups, called on every key with the trimmed, lowercased text ('' at first). */
342
+ search: (query: string) => PaletteGroup[];
343
+ /** Text in the empty field. Default 'Search…'. */
344
+ placeholder?: string;
345
+ /** Shown when nothing matches. */
346
+ emptyTitle?: string;
347
+ emptyBody?: string;
348
+ }
349
+ /** <CommandPalette open={open} onClose={…} search={(q) => groups} /> — the ⌘K search window. */
350
+ export function CommandPalette(props: CommandPaletteProps): null;
351
+
352
+ export interface TourStep {
353
+ /** What to point at: a ref, an element or a selector. Not on the page → skipped. Left out → bubble in the middle. */
354
+ target?: string | HTMLElement | React.RefObject<HTMLElement | null> | null;
355
+ /** Heading of the bubble. */
356
+ title?: string;
357
+ /** Text of the bubble. */
358
+ text?: string;
359
+ /** React nodes instead of text. */
360
+ content?: React.ReactNode;
361
+ /** Side for this step's bubble. */
362
+ placement?: 'auto' | 'top' | 'bottom' | 'left' | 'right';
363
+ /** px between the target and the spotlight's edge. */
364
+ padding?: number;
365
+ /** Spotlight corners in px. */
366
+ radius?: number | null;
367
+ }
368
+ export interface TourHandle {
369
+ /** Open on step i (default: the start prop). False when there is nothing to show. */
370
+ start(index?: number): boolean;
371
+ next(): void;
372
+ prev(): void;
373
+ go(index: number): void;
374
+ /** End it (onEnd(false)). */
375
+ stop(): void;
376
+ /** The step on screen, -1 when closed. */
377
+ readonly index: number;
378
+ readonly active: boolean;
379
+ }
380
+ export interface TourProps {
381
+ /** The stops. */
382
+ steps: TourStep[];
383
+ /** Running (true) or not. Setting it to false ends the tour without calling onEnd. */
384
+ open?: boolean;
385
+ /** The step it opens on. Default 0. */
386
+ start?: number;
387
+ /** After each step is shown. */
388
+ onStep?: (index: number, step: TourStep) => void;
389
+ /** When it ends by itself: finished = true when Done was pressed on the last step. Set open to false here. */
390
+ onEnd?: (finished: boolean) => void;
391
+ /** Default side for the bubble. Default 'auto'. */
392
+ placement?: 'auto' | 'top' | 'bottom' | 'left' | 'right';
393
+ /** px between the target and the spotlight's edge. Default 8. */
394
+ padding?: number;
395
+ /** Spotlight corners in px; null = the target's own + padding. */
396
+ radius?: number | null;
397
+ /** Dim the page and block clicks on it (default true); false = only a ring. */
398
+ backdrop?: boolean;
399
+ /** Scroll each target into view. Default true. */
400
+ scroll?: boolean;
401
+ /** Texts: label, next, back, skip, done, stepOf ('Step {n} of {total}' or (n, total) => text). */
402
+ words?: Partial<Record<'label' | 'next' | 'back' | 'skip' | 'done', string>> & { stepOf?: string | ((n: number, total: number) => string) };
403
+ }
404
+ /** <Tour open={touring} onEnd={() => setTouring(false)} steps={[…]} /> — spotlight walk-through. */
405
+ export const Tour: React.ForwardRefExoticComponent<TourProps & React.RefAttributes<TourHandle>>;
406
+
407
+ export interface LightboxImage {
408
+ /** The big image. */
409
+ src: string;
410
+ alt?: string;
411
+ caption?: string;
412
+ /** Its size, if known (sharper opening animation). */
413
+ w?: number;
414
+ h?: number;
415
+ /** The thumbnail it grows out of: an element, a ref or a selector. */
416
+ from?: string | AnchorLike;
417
+ }
418
+ export interface LightboxProps {
419
+ /** Image addresses or image objects. */
420
+ items: Array<string | LightboxImage>;
421
+ /** Open (true) or closed (false). */
422
+ open: boolean;
423
+ /** The image shown; changing it while open moves there. Default 0. */
424
+ index?: number;
425
+ /** Called when it closes itself (✕, Esc, drag down, a tap outside), with the last index: set open to false here. */
426
+ onClose?: (index: number) => void;
427
+ /** Called when another image comes on screen. */
428
+ onChange?: (index: number) => void;
429
+ /** Double-tap zoom. Default 2.5. */
430
+ zoom?: number;
431
+ /** The most a pinch may reach. Default 4. */
432
+ maxZoom?: number;
433
+ /** Texts: label, close, prev, next, zoomIn, zoomOut, count(i, n), image(i, n, caption). */
434
+ words?: Record<string, string | ((...a: any[]) => string)>;
435
+ }
436
+ /** <Lightbox open={i >= 0} index={i} items={…} onClose={() => setI(-1)} /> — full-screen images. */
437
+ export function Lightbox(props: LightboxProps): null;
438
+
439
+ export interface LightboxGalleryProps extends Omit<React.HTMLAttributes<HTMLElement>, 'onChange'> {
440
+ /** Which elements open it. Default '[data-lightbox]'. */
441
+ selector?: string;
442
+ zoom?: number;
443
+ maxZoom?: number;
444
+ words?: LightboxProps['words'];
445
+ onChange?: (index: number) => void;
446
+ onClose?: (index: number) => void;
447
+ /** The wrapper element. Default 'div'. */
448
+ as?: React.ElementType;
449
+ children?: React.ReactNode;
450
+ }
451
+ /** <LightboxGallery>…<a href="big.jpg" data-lightbox="bikes"><img …/></a>…</LightboxGallery> */
452
+ export const LightboxGallery: React.ForwardRefExoticComponent<LightboxGalleryProps & React.RefAttributes<HTMLElement>>;
453
+
454
+ export {};