@gecko-ui-kit/react 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +1823 -2
- package/index.d.ts +12 -0
- package/index.js +15 -0
- package/package.json +49 -4
- package/src/actions.d.ts +192 -0
- package/src/actions.js +238 -0
- package/src/basics.d.ts +268 -0
- package/src/basics.js +308 -0
- package/src/charts.d.ts +207 -0
- package/src/charts.js +79 -0
- package/src/controls.d.ts +159 -0
- package/src/controls.js +261 -0
- package/src/core.d.ts +78 -0
- package/src/core.js +284 -0
- package/src/data.d.ts +762 -0
- package/src/data.js +608 -0
- package/src/effects.d.ts +410 -0
- package/src/effects.js +580 -0
- package/src/forms.d.ts +724 -0
- package/src/forms.js +403 -0
- package/src/motion.d.ts +130 -0
- package/src/motion.js +176 -0
- package/src/overlays.d.ts +450 -0
- package/src/overlays.js +580 -0
- package/src/shell.d.ts +206 -0
- package/src/shell.js +602 -0
- package/src/text.d.ts +316 -0
- package/src/text.js +354 -0
package/src/shell.d.ts
ADDED
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import type * as React from 'react';
|
|
2
|
+
|
|
3
|
+
/** A sub-page: [id, label] or [id, label, href], or { id, label, href }. */
|
|
4
|
+
export type ShellSub = [id: string, label: string, href?: string] | { id: string; label: string; href?: string };
|
|
5
|
+
export interface ShellItem {
|
|
6
|
+
/** Route id: the address is `${base}/${id}` unless href is given. */
|
|
7
|
+
id: string;
|
|
8
|
+
/** Text in the menu, breadcrumbs, tab bar and palette. */
|
|
9
|
+
label: string;
|
|
10
|
+
/** An icon name from @gecko-ui-kit/icons, or any React node. */
|
|
11
|
+
icon?: string | React.ReactNode;
|
|
12
|
+
/** Its own address (e.g. '/' for the home page). */
|
|
13
|
+
href?: string;
|
|
14
|
+
/** A number badge (hidden at 0) or a function giving it; it flashes when it changes. */
|
|
15
|
+
count?: number | (() => number);
|
|
16
|
+
/** Sub-pages: unfold under the item when it is open, and become tabs in <PageHeader>. */
|
|
17
|
+
subs?: ShellSub[];
|
|
18
|
+
/** A short line in the rail flyout and the palette. */
|
|
19
|
+
blurb?: string;
|
|
20
|
+
/** false: no sub-page tabs in <PageHeader> for this item. */
|
|
21
|
+
tabs?: boolean;
|
|
22
|
+
}
|
|
23
|
+
export interface ShellGroup {
|
|
24
|
+
/** Small heading over the group (optional). */
|
|
25
|
+
label?: string;
|
|
26
|
+
items: ShellItem[];
|
|
27
|
+
}
|
|
28
|
+
/** An account-menu row: '-' a line, { section } a heading, else an action. */
|
|
29
|
+
export type ShellMenuItem = '-' | { section: string } | { label: string; icon?: string; kbd?: string; danger?: boolean; run?: (button: HTMLElement) => void };
|
|
30
|
+
export interface ShellUser {
|
|
31
|
+
name: string;
|
|
32
|
+
/** Initials in the avatar (default: from the name). */
|
|
33
|
+
ini?: string;
|
|
34
|
+
/** Avatar colour: indigo teal rose amber violet green slate sky. */
|
|
35
|
+
tone?: string;
|
|
36
|
+
/** Second line, e.g. 'Manager'. */
|
|
37
|
+
role?: string;
|
|
38
|
+
/** Green dot. Default true. */
|
|
39
|
+
online?: boolean;
|
|
40
|
+
/** Rows in the account menu. */
|
|
41
|
+
menu?: ShellMenuItem[];
|
|
42
|
+
}
|
|
43
|
+
export interface ShellBrand {
|
|
44
|
+
name: string;
|
|
45
|
+
sub?: string;
|
|
46
|
+
/** An icon name or your logo as a React node. Default 'logo'. */
|
|
47
|
+
icon?: string | React.ReactNode;
|
|
48
|
+
/** Where the brand links to (default: the home item). */
|
|
49
|
+
href?: string;
|
|
50
|
+
}
|
|
51
|
+
/** Every text the shell shows (English defaults); pass the ones you want to change. */
|
|
52
|
+
export interface ShellWords {
|
|
53
|
+
sidebar?: string; main?: string; collapse?: string; expand?: string; collapseTip?: string; expandTip?: string; account?: string; open?: string;
|
|
54
|
+
menu?: string; breadcrumb?: string; search?: string; searchPlaceholder?: string; searchKey?: string; theme?: string; themeTip?: string;
|
|
55
|
+
bell?: string; primary?: string; tabs?: string; more?: string; sections?: string; shortcuts?: string; replay?: string; searchPages?: string;
|
|
56
|
+
goTo?: string; toggleRail?: string; thisList?: string; close?: string;
|
|
57
|
+
}
|
|
58
|
+
/** What every part needs to know about the menu and where we are. */
|
|
59
|
+
export interface ShellNavProps {
|
|
60
|
+
/** Groups of menu items. */
|
|
61
|
+
nav: ShellGroup[];
|
|
62
|
+
/** Items pinned to the bottom (settings, help). */
|
|
63
|
+
end?: ShellItem[];
|
|
64
|
+
/** The current path, e.g. usePathname(). It picks the current item and sub-page. */
|
|
65
|
+
path: string;
|
|
66
|
+
/** Prefix for item addresses (e.g. '/app'). Default ''. */
|
|
67
|
+
base?: string;
|
|
68
|
+
/** Id of the home item (brand link). Default: the first item. */
|
|
69
|
+
home?: string;
|
|
70
|
+
/** Called with the address on a plain click of any link, and from menus, the palette and keys (e.g. router.push). */
|
|
71
|
+
onNavigate?: (href: string) => void;
|
|
72
|
+
/** The component links are drawn with (e.g. Next's Link). Default 'a'. */
|
|
73
|
+
link?: React.ElementType;
|
|
74
|
+
/** Texts. */
|
|
75
|
+
words?: ShellWords;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export interface SidebarHandle {
|
|
79
|
+
/** Collapse (true) or expand (false) with the motion. Call it from an event handler. */
|
|
80
|
+
setRail(rail: boolean): void;
|
|
81
|
+
isRail(): boolean;
|
|
82
|
+
readonly el: HTMLElement | null;
|
|
83
|
+
}
|
|
84
|
+
export interface SidebarProps extends ShellNavProps {
|
|
85
|
+
/** Top of the sidebar. */
|
|
86
|
+
brand?: ShellBrand;
|
|
87
|
+
/** Account button at the bottom. */
|
|
88
|
+
user?: ShellUser | null;
|
|
89
|
+
/** Prefix for saved choices: '<key>:pinned'. Default 'gecko'. */
|
|
90
|
+
storageKey?: string;
|
|
91
|
+
/** With nothing saved, narrower windows start as a rail. Default 1280. */
|
|
92
|
+
railBreakpoint?: number;
|
|
93
|
+
/** Phone layout at this width and below. Default 760. */
|
|
94
|
+
mobile?: number;
|
|
95
|
+
}
|
|
96
|
+
/** The main menu with pill, sub-pages, rail + flyout. */
|
|
97
|
+
export const Sidebar: React.ForwardRefExoticComponent<SidebarProps & React.RefAttributes<SidebarHandle>>;
|
|
98
|
+
|
|
99
|
+
export interface TopbarProps extends ShellNavProps {
|
|
100
|
+
/** Text for the first breadcrumb. */
|
|
101
|
+
crumbsRoot?: string;
|
|
102
|
+
/** { placeholder, onOpen } or false to hide the search button. */
|
|
103
|
+
search?: false | { placeholder?: string; onOpen?: () => void };
|
|
104
|
+
/** false hides the theme switch. */
|
|
105
|
+
theme?: boolean;
|
|
106
|
+
/** A bell with a number badge: it wiggles when count goes up. */
|
|
107
|
+
bell?: { count?: number; onClick?: (button: HTMLElement) => void } | null;
|
|
108
|
+
/** The main button on the right (icon only on phones). */
|
|
109
|
+
primary?: { label?: string; icon?: string | React.ReactNode; tip?: string; run?: (button: HTMLElement) => void } | null;
|
|
110
|
+
/** Called by the search button when search.onOpen is not given. */
|
|
111
|
+
onSearch?: () => void;
|
|
112
|
+
/** Prefix for the saved theme: '<key>:theme'. Default 'gecko'. */
|
|
113
|
+
storageKey?: string;
|
|
114
|
+
/** Extra buttons before the theme switch. */
|
|
115
|
+
children?: React.ReactNode;
|
|
116
|
+
}
|
|
117
|
+
/** The bar above the page. ref → the <header>. */
|
|
118
|
+
export const Topbar: React.ForwardRefExoticComponent<TopbarProps & React.RefAttributes<HTMLElement>>;
|
|
119
|
+
|
|
120
|
+
export interface MobileTabbarProps extends ShellNavProps {
|
|
121
|
+
/** Ids of the items that get a tab (default: the first four); the rest go under “More”. */
|
|
122
|
+
tabbar?: string[];
|
|
123
|
+
}
|
|
124
|
+
/** The phone tab bar (hidden on wider screens). ref → the <nav>. */
|
|
125
|
+
export const MobileTabbar: React.ForwardRefExoticComponent<MobileTabbarProps & React.RefAttributes<HTMLElement>>;
|
|
126
|
+
|
|
127
|
+
/** A tab: { id, label, count, href } or [id, label, count?, href?]. */
|
|
128
|
+
export type PageTab = { id: string; label: React.ReactNode; count?: number; href?: string } | [id: string, label: string, count?: number, href?: string];
|
|
129
|
+
export interface PageHeaderProps {
|
|
130
|
+
/** The big title (its letters roll up, again when it changes). */
|
|
131
|
+
title: string;
|
|
132
|
+
/** Small coloured line above it. */
|
|
133
|
+
eyebrow?: React.ReactNode;
|
|
134
|
+
/** A line of text under it. */
|
|
135
|
+
sub?: React.ReactNode;
|
|
136
|
+
/** Buttons on the right. */
|
|
137
|
+
actions?: React.ReactNode;
|
|
138
|
+
/** Tabs under it. Inside AppShell the current item's sub-pages are used by themselves; false hides them. */
|
|
139
|
+
tabs?: PageTab[] | false;
|
|
140
|
+
/** The chosen tab's id (for your own tabs). */
|
|
141
|
+
value?: string;
|
|
142
|
+
/** Called with the id when a button tab (one without href) is clicked. */
|
|
143
|
+
onTabChange?: (id: string) => void;
|
|
144
|
+
/** Number badges on the tabs: { tabId: n }. */
|
|
145
|
+
counts?: Record<string, number>;
|
|
146
|
+
className?: string;
|
|
147
|
+
/** sections: the tabs' name for screen readers. */
|
|
148
|
+
words?: ShellWords;
|
|
149
|
+
}
|
|
150
|
+
/** The top of a page. ref → the <header>. */
|
|
151
|
+
export const PageHeader: React.ForwardRefExoticComponent<PageHeaderProps & React.RefAttributes<HTMLElement>>;
|
|
152
|
+
|
|
153
|
+
export interface AppShellProps extends ShellNavProps {
|
|
154
|
+
brand?: ShellBrand;
|
|
155
|
+
user?: ShellUser | null;
|
|
156
|
+
/** Topbar parts: search, theme, bell, primary, and extra (React nodes before the theme switch). */
|
|
157
|
+
top?: { search?: TopbarProps['search']; theme?: boolean; bell?: TopbarProps['bell']; primary?: TopbarProps['primary']; extra?: React.ReactNode };
|
|
158
|
+
/** Text for the first breadcrumb. */
|
|
159
|
+
crumbsRoot?: string;
|
|
160
|
+
/** Ids of the items in the phone tab bar (default: the first four). */
|
|
161
|
+
tabbar?: string[];
|
|
162
|
+
/** Sub-pages as tabs in <PageHeader> (item.tabs overrides). Default true. */
|
|
163
|
+
tabs?: boolean;
|
|
164
|
+
/** Sidebar and topbar play in on load. Default true. */
|
|
165
|
+
intro?: boolean;
|
|
166
|
+
/** The built-in keys: ⌘K and / search, [ rail, ? list, Esc close. Default true. */
|
|
167
|
+
shortcuts?: boolean;
|
|
168
|
+
/** Your own single-key shortcuts, also listed under ?. */
|
|
169
|
+
keys?: Array<{ key: string; label: string; run?: (shell: ShellApi) => void }>;
|
|
170
|
+
/** Extra groups at the top of the ⌘K palette: (q) → [{ label, items: [{ title, sub, icon, run }] }]. */
|
|
171
|
+
search?: (query: string) => Array<{ label: string; items: Array<{ title: string; sub?: string; icon?: string; run?: () => void }> }>;
|
|
172
|
+
/** Prefix for saved choices: '<key>:pinned', '<key>:theme'. Default 'gecko'. */
|
|
173
|
+
storageKey?: string;
|
|
174
|
+
/** With nothing saved, narrower windows start as a rail. Default 1280. */
|
|
175
|
+
railBreakpoint?: number;
|
|
176
|
+
/** Phone layout at this width and below (also sets the overlays' config.mobile). Default 760. */
|
|
177
|
+
mobile?: number;
|
|
178
|
+
className?: string;
|
|
179
|
+
/** The page. */
|
|
180
|
+
children?: React.ReactNode;
|
|
181
|
+
}
|
|
182
|
+
/** What useShell() gives inside <AppShell>. */
|
|
183
|
+
export interface ShellApi {
|
|
184
|
+
/** The current item id (null when no item matches) and sub-page id ('' when none). */
|
|
185
|
+
route: { page: string | null; sub: string };
|
|
186
|
+
path: string;
|
|
187
|
+
/** Go somewhere (onNavigate, else a normal page load). */
|
|
188
|
+
navigate(href: string): void;
|
|
189
|
+
/** Open search (top.search.onOpen or the palette). */
|
|
190
|
+
palette(): void;
|
|
191
|
+
/** Open the keyboard shortcuts list. */
|
|
192
|
+
shortcuts(): void;
|
|
193
|
+
/** Play the intro again. */
|
|
194
|
+
intro(): void;
|
|
195
|
+
/** Collapse / expand the sidebar (from an event handler). */
|
|
196
|
+
setRail(rail: boolean): void;
|
|
197
|
+
isRail(): boolean;
|
|
198
|
+
}
|
|
199
|
+
/** The whole app frame around your page. */
|
|
200
|
+
export function AppShell(props: AppShellProps): React.ReactElement;
|
|
201
|
+
/** Inside <AppShell>: the shell's state and actions; null outside. */
|
|
202
|
+
export function useShell(): ShellApi | null;
|
|
203
|
+
/** A script for <head> that sets the saved theme and rail before the first paint. */
|
|
204
|
+
export function shellBootScript(options?: { storageKey?: string; railBreakpoint?: number }): string;
|
|
205
|
+
|
|
206
|
+
export {};
|