@krizaka/ui 3.64.1 → 3.65.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/dist/account-menu.d.ts +7 -3
- package/dist/account-menu.js +14 -10
- package/dist/account-menu.js.map +1 -1
- package/dist/app-frame/server.d.ts +123 -0
- package/dist/app-frame/server.js +109 -0
- package/dist/app-frame/server.js.map +1 -0
- package/dist/app-frame.d.ts +210 -0
- package/dist/app-frame.js +220 -0
- package/dist/app-frame.js.map +1 -0
- package/dist/desktop-window.d.ts +223 -0
- package/dist/desktop-window.js +261 -0
- package/dist/desktop-window.js.map +1 -0
- package/dist/file-upload.d.ts +2 -2
- package/dist/filter-bar.d.ts +3 -3
- package/dist/language-switch.d.ts +9 -9
- package/dist/native.d.ts +218 -3
- package/dist/native.js +1638 -1450
- package/dist/native.js.map +1 -1
- package/dist/theme.d.ts +3 -1
- package/dist/theme.js +4 -0
- package/dist/theme.js.map +1 -1
- package/package.json +47 -5
- package/registry/account-menu.json +22 -8
- package/registry/account-settings.json +1 -1
- package/registry/achievement.json +1 -1
- package/registry/action-bar.json +1 -1
- package/registry/activity-feed.json +1 -1
- package/registry/agenda.json +1 -1
- package/registry/alert.json +1 -1
- package/registry/analysis-report.json +1 -1
- package/registry/anatomy-plate.json +1 -1
- package/registry/app-frame.json +564 -0
- package/registry/app-header.json +1 -1
- package/registry/app-shell.json +1 -1
- package/registry/argument-card.json +1 -1
- package/registry/audio-player.json +1 -1
- package/registry/auth-layout.json +1 -1
- package/registry/avatar.json +1 -1
- package/registry/badge.json +1 -1
- package/registry/bird-plate.json +1 -1
- package/registry/button.json +1 -1
- package/registry/captcha.json +1 -1
- package/registry/card-grid.json +1 -1
- package/registry/card.json +1 -1
- package/registry/catalogue-page.json +1 -1
- package/registry/changelog-page.json +1 -1
- package/registry/chapter.json +1 -1
- package/registry/chat.json +1 -1
- package/registry/checkbox.json +1 -1
- package/registry/chip-link.json +1 -1
- package/registry/chip-row.json +1 -1
- package/registry/chip.json +1 -1
- package/registry/choice-grid.json +1 -1
- package/registry/code-block.json +1 -1
- package/registry/combobox.json +1 -1
- package/registry/command.json +1 -1
- package/registry/comparison-table.json +1 -1
- package/registry/component-page.json +1 -1
- package/registry/confirm-button.json +1 -1
- package/registry/contact-page.json +1 -1
- package/registry/continue-prompt.json +1 -1
- package/registry/countdown.json +1 -1
- package/registry/cover-hero.json +1 -1
- package/registry/cta-panel.json +1 -1
- package/registry/dashboard-layout.json +1 -1
- package/registry/data-table.json +1 -1
- package/registry/date-picker.json +3 -3
- package/registry/decision-list.json +1 -1
- package/registry/description-list.json +1 -1
- package/registry/desktop-window.json +407 -0
- package/registry/detail-layout.json +1 -1
- package/registry/dialog.json +1 -1
- package/registry/docs-article-page.json +1 -1
- package/registry/docs-hub-page.json +1 -1
- package/registry/docs-layout.json +1 -1
- package/registry/docs-nav.json +1 -1
- package/registry/document-viewer.json +1 -1
- package/registry/doodle.json +1 -1
- package/registry/drop-overlay.json +1 -1
- package/registry/dropdown-menu.json +1 -1
- package/registry/elephant.json +2 -2
- package/registry/embed-facade.json +1 -1
- package/registry/empty-state.json +1 -1
- package/registry/engine-flow.json +1 -1
- package/registry/environment-notice.json +1 -1
- package/registry/error-page.json +1 -1
- package/registry/examples/app-frame/admin.d.ts +4 -0
- package/registry/examples/app-frame/admin.js +32 -0
- package/registry/examples/app-frame/admin.tsx +33 -0
- package/registry/examples/app-frame/app.d.ts +4 -0
- package/registry/examples/app-frame/app.js +53 -0
- package/registry/examples/app-frame/app.tsx +56 -0
- package/registry/examples/desktop-window/library.d.ts +4 -0
- package/registry/examples/desktop-window/library.js +49 -0
- package/registry/examples/desktop-window/library.tsx +58 -0
- package/registry/examples/form-flow/native/signup.d.ts +4 -0
- package/registry/examples/form-flow/native/signup.dark.png +0 -0
- package/registry/examples/form-flow/native/signup.js +26 -0
- package/registry/examples/form-flow/native/signup.light.png +0 -0
- package/registry/examples/form-flow/native/signup.tsx +23 -0
- package/registry/examples/grid/native/columns.d.ts +4 -0
- package/registry/examples/grid/native/columns.dark.png +0 -0
- package/registry/examples/grid/native/columns.js +23 -0
- package/registry/examples/grid/native/columns.light.png +0 -0
- package/registry/examples/grid/native/columns.tsx +20 -0
- package/registry/examples/grid/native/photos.d.ts +4 -0
- package/registry/examples/grid/native/photos.dark.png +0 -0
- package/registry/examples/grid/native/photos.js +14 -0
- package/registry/examples/grid/native/photos.light.png +0 -0
- package/registry/examples/grid/native/photos.tsx +18 -0
- package/registry/examples/grid/native/stats.d.ts +4 -0
- package/registry/examples/grid/native/stats.dark.png +0 -0
- package/registry/examples/grid/native/stats.js +22 -0
- package/registry/examples/grid/native/stats.light.png +0 -0
- package/registry/examples/grid/native/stats.tsx +24 -0
- package/registry/examples/list-detail/native/inbox.d.ts +4 -0
- package/registry/examples/list-detail/native/inbox.dark.png +0 -0
- package/registry/examples/list-detail/native/inbox.js +35 -0
- package/registry/examples/list-detail/native/inbox.light.png +0 -0
- package/registry/examples/list-detail/native/inbox.tsx +35 -0
- package/registry/examples/screen/native/dashboard.d.ts +4 -0
- package/registry/examples/screen/native/dashboard.dark.png +0 -0
- package/registry/examples/screen/native/dashboard.js +48 -0
- package/registry/examples/screen/native/dashboard.light.png +0 -0
- package/registry/examples/screen/native/dashboard.tsx +52 -0
- package/registry/examples/screen/native/settings-home.d.ts +4 -0
- package/registry/examples/screen/native/settings-home.dark.png +0 -0
- package/registry/examples/screen/native/settings-home.js +26 -0
- package/registry/examples/screen/native/settings-home.light.png +0 -0
- package/registry/examples/screen/native/settings-home.tsx +25 -0
- package/registry/examples/shop/hero-tv.js +1 -1
- package/registry/examples/shop/hero-tv.tsx +1 -1
- package/registry/examples/state-screen/native/empty.d.ts +4 -0
- package/registry/examples/state-screen/native/empty.dark.png +0 -0
- package/registry/examples/state-screen/native/empty.js +12 -0
- package/registry/examples/state-screen/native/empty.light.png +0 -0
- package/registry/examples/state-screen/native/empty.tsx +11 -0
- package/registry/examples/state-screen/native/error.d.ts +4 -0
- package/registry/examples/state-screen/native/error.dark.png +0 -0
- package/registry/examples/state-screen/native/error.js +21 -0
- package/registry/examples/state-screen/native/error.light.png +0 -0
- package/registry/examples/state-screen/native/error.tsx +17 -0
- package/registry/examples/state-screen/native/offline.d.ts +4 -0
- package/registry/examples/state-screen/native/offline.dark.png +0 -0
- package/registry/examples/state-screen/native/offline.js +15 -0
- package/registry/examples/state-screen/native/offline.light.png +0 -0
- package/registry/examples/state-screen/native/offline.tsx +12 -0
- package/registry/field.json +1 -1
- package/registry/file-upload.json +1 -1
- package/registry/filter-bar.json +1 -1
- package/registry/flock.json +1 -1
- package/registry/footnote.json +1 -1
- package/registry/force-update-screen.json +1 -1
- package/registry/form-flow.json +152 -0
- package/registry/form.json +1 -1
- package/registry/gallery-page.json +1 -1
- package/registry/genui.json +1 -1
- package/registry/glossary-term.json +1 -1
- package/registry/glossary.json +1 -1
- package/registry/glow-card.json +1 -1
- package/registry/goal-gauge.json +1 -1
- package/registry/grade-stamp.json +1 -1
- package/registry/grid.json +262 -0
- package/registry/how-it-works-page.json +1 -1
- package/registry/image-cropper.json +1 -1
- package/registry/index.json +314 -12
- package/registry/iso.json +1 -1
- package/registry/kanban.json +1 -1
- package/registry/kbd.json +1 -1
- package/registry/kind-config-editor.json +1 -1
- package/registry/kpi-explained.json +1 -1
- package/registry/landing-page.json +1 -1
- package/registry/landscape.json +1 -1
- package/registry/language-switch.json +1 -1
- package/registry/legal-page.json +1 -1
- package/registry/link-card.json +1 -1
- package/registry/list-detail.json +188 -0
- package/registry/list.json +1 -1
- package/registry/loader.json +1 -1
- package/registry/longform-page.json +1 -1
- package/registry/maintenance-screen.json +1 -1
- package/registry/map.json +2 -2
- package/registry/margin-layout.json +1 -1
- package/registry/markdown.json +1 -1
- package/registry/marketing-layout.json +1 -1
- package/registry/marquee.json +1 -1
- package/registry/mascot-quote.json +1 -1
- package/registry/mascot-state.json +1 -1
- package/registry/mascots.json +1 -1
- package/registry/match-dialog.json +1 -1
- package/registry/media-capture.json +1 -1
- package/registry/media-gallery.json +1 -1
- package/registry/media-grid.json +1 -1
- package/registry/meta-row.json +1 -1
- package/registry/meter.json +1 -1
- package/registry/nav-bar.json +2 -2
- package/registry/next-actions.json +1 -1
- package/registry/notification-preferences.json +1 -1
- package/registry/number-ticker.json +1 -1
- package/registry/onboarding.json +3 -0
- package/registry/opening-hours.json +1 -1
- package/registry/page-header.json +1 -1
- package/registry/page-hero.json +1 -1
- package/registry/page-index.json +1 -1
- package/registry/page.json +1 -1
- package/registry/pagination.json +1 -1
- package/registry/photo-grid.json +1 -1
- package/registry/pointer-light.json +1 -1
- package/registry/popover.json +1 -1
- package/registry/pricing-page.json +1 -1
- package/registry/product-page.json +1 -1
- package/registry/profile-card.json +1 -1
- package/registry/progress.json +1 -1
- package/registry/promise-card.json +1 -1
- package/registry/quota-meter.json +1 -1
- package/registry/radio-group.json +1 -1
- package/registry/rail-nav.json +2 -2
- package/registry/recipes.json +1 -1
- package/registry/retro-tv.json +1 -1
- package/registry/reviews.json +1 -1
- package/registry/router.json +1 -1
- package/registry/screen.json +68 -4
- package/registry/scroll-stage.json +1 -1
- package/registry/search-field.json +1 -1
- package/registry/section-backdrop.json +1 -1
- package/registry/separator.json +1 -1
- package/registry/service-card.json +1 -1
- package/registry/settings-layout.json +5 -2
- package/registry/shop-composer.json +1 -1
- package/registry/shop.json +3 -3
- package/registry/showcase.json +1 -1
- package/registry/signature.json +1 -1
- package/registry/site-cahier.json +1 -1
- package/registry/site-footer.json +4 -4
- package/registry/sites.json +1 -1
- package/registry/skeleton.json +1 -1
- package/registry/skip-link.json +1 -1
- package/registry/slider.json +1 -1
- package/registry/slot-picker.json +1 -1
- package/registry/slot.json +1 -1
- package/registry/specimen-tag.json +1 -1
- package/registry/speed-lines.json +1 -1
- package/registry/spinner.json +1 -1
- package/registry/split-view.json +1 -1
- package/registry/stage-banner.json +1 -1
- package/registry/stat.json +1 -1
- package/registry/state-screen.json +224 -0
- package/registry/status-chip.json +1 -1
- package/registry/status-page.json +1 -1
- package/registry/step-progress.json +1 -1
- package/registry/step-showcase.json +1 -1
- package/registry/stepper.json +1 -1
- package/registry/sticky-action.json +1 -1
- package/registry/stuck.json +1 -1
- package/registry/swipe-deck.json +1 -1
- package/registry/switch.json +1 -1
- package/registry/tabs.json +1 -1
- package/registry/tag-input.json +1 -1
- package/registry/tag-selector.json +1 -1
- package/registry/taped-photo.json +1 -1
- package/registry/terminal-replay.json +1 -1
- package/registry/text-style.json +1 -1
- package/registry/theme.json +3 -3
- package/registry/toast.json +1 -1
- package/registry/toc.json +1 -1
- package/registry/tooltip.json +1 -1
- package/registry/tree-view.json +1 -1
- package/registry/update-prompt.json +1 -1
- package/registry/upload-queue.json +1 -1
- package/registry/usage.json +1 -1
- package/registry/verified-badge.json +1 -1
- package/registry/versus-card.json +1 -1
- package/registry/vertical-video.json +1 -1
- package/registry/video-player.json +1 -1
- package/registry/video-trimmer.json +1 -1
- package/registry/virtual.json +1 -1
- package/registry/wall.json +1 -1
- package/registry/waveform.json +1 -1
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/app-frame/app-frame.tsx
|
|
4
|
+
import { AccountMenu } from "@krizaka/ui/account-menu";
|
|
5
|
+
import { AppHeader } from "@krizaka/ui/app-header";
|
|
6
|
+
import { AppHeaderSearch } from "@krizaka/ui/app-header/search";
|
|
7
|
+
import { Badge } from "@krizaka/ui/badge";
|
|
8
|
+
import { RailNav } from "@krizaka/ui/rail-nav";
|
|
9
|
+
import { useOptionalTheme } from "@krizaka/ui/theme";
|
|
10
|
+
|
|
11
|
+
// src/app-frame/contract.ts
|
|
12
|
+
var ACCOUNT_LINK_IDS = ["profile", "settings", "billing", "administration"];
|
|
13
|
+
var ACCOUNT_MENU_ORDER = ["identity", "profile", "settings", "billing", "administration", "language", "theme", "signOut"];
|
|
14
|
+
var MAIN_SECTIONS_MAX = 5;
|
|
15
|
+
function framePlaces(sections, accountLinks = []) {
|
|
16
|
+
const result = { main: [], foot: [], dropped: [] };
|
|
17
|
+
for (const section of sections) {
|
|
18
|
+
if (section.gated) result.dropped.push({ id: section.id, reason: "gated" });
|
|
19
|
+
else if (accountLinks.includes(section.id)) result.dropped.push({ id: section.id, reason: "account" });
|
|
20
|
+
else result[section.place === "foot" ? "foot" : "main"].push(section);
|
|
21
|
+
}
|
|
22
|
+
return result;
|
|
23
|
+
}
|
|
24
|
+
function orderAccountLinks(links, admin = false) {
|
|
25
|
+
if (!links) return [];
|
|
26
|
+
return ACCOUNT_LINK_IDS.flatMap((id) => {
|
|
27
|
+
const link = links[id];
|
|
28
|
+
return link && !(admin && id === "administration") ? [{ id, link }] : [];
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
function frameIssues(sections, accountLinks = []) {
|
|
32
|
+
const issues = [];
|
|
33
|
+
const ids = sections.map((s) => s.id);
|
|
34
|
+
for (const id of new Set(ids)) if (ids.filter((x) => x === id).length > 1) issues.push(`The section "${id}" is declared twice.`);
|
|
35
|
+
const places = framePlaces(sections, accountLinks);
|
|
36
|
+
for (const { id, reason } of places.dropped) if (reason === "account") issues.push(`"${id}" is on the rail and under the avatar: a place is in one of them, so the rail drops it.`);
|
|
37
|
+
if (places.main.length > MAIN_SECTIONS_MAX) issues.push(`${places.main.length} main sections: a phone's tab bar carries ${MAIN_SECTIONS_MAX} at most.`);
|
|
38
|
+
return issues;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// src/app-frame/vocabulary.ts
|
|
42
|
+
var navWords = {
|
|
43
|
+
en: {
|
|
44
|
+
docs: "Docs",
|
|
45
|
+
terms: "Terms",
|
|
46
|
+
privacy: "Privacy",
|
|
47
|
+
settings: "Settings",
|
|
48
|
+
billing: "Billing",
|
|
49
|
+
profile: "Profile",
|
|
50
|
+
administration: "Administration",
|
|
51
|
+
account: "Account",
|
|
52
|
+
language: "Language",
|
|
53
|
+
theme: "Theme",
|
|
54
|
+
themeLight: "Light",
|
|
55
|
+
themeDark: "Dark",
|
|
56
|
+
themeSystem: "System",
|
|
57
|
+
signOut: "Sign out",
|
|
58
|
+
howItWorks: "How it works",
|
|
59
|
+
pricing: "Pricing",
|
|
60
|
+
download: "Download",
|
|
61
|
+
contact: "Contact",
|
|
62
|
+
search: "Search",
|
|
63
|
+
notifications: "Notifications",
|
|
64
|
+
expand: "Show the words",
|
|
65
|
+
collapse: "Hide the words"
|
|
66
|
+
},
|
|
67
|
+
fr: {
|
|
68
|
+
docs: "Docs",
|
|
69
|
+
terms: "Conditions d'utilisation",
|
|
70
|
+
privacy: "Confidentialit\xE9",
|
|
71
|
+
settings: "R\xE9glages",
|
|
72
|
+
billing: "Facturation",
|
|
73
|
+
profile: "Profil",
|
|
74
|
+
administration: "Administration",
|
|
75
|
+
account: "Compte",
|
|
76
|
+
language: "Langue",
|
|
77
|
+
theme: "Th\xE8me",
|
|
78
|
+
themeLight: "Clair",
|
|
79
|
+
themeDark: "Sombre",
|
|
80
|
+
themeSystem: "Syst\xE8me",
|
|
81
|
+
signOut: "Se d\xE9connecter",
|
|
82
|
+
howItWorks: "Comment \xE7a marche",
|
|
83
|
+
pricing: "Tarifs",
|
|
84
|
+
download: "T\xE9l\xE9charger",
|
|
85
|
+
contact: "Contact",
|
|
86
|
+
search: "Rechercher",
|
|
87
|
+
notifications: "Notifications",
|
|
88
|
+
expand: "Afficher les mots",
|
|
89
|
+
collapse: "Masquer les mots"
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
function navVocabulary(locale = "en") {
|
|
93
|
+
return navWords[locale.toLowerCase().startsWith("fr") ? "fr" : "en"];
|
|
94
|
+
}
|
|
95
|
+
function navWord(locale, key) {
|
|
96
|
+
return navVocabulary(locale)[key];
|
|
97
|
+
}
|
|
98
|
+
var PUBLIC_BAR_MAX = 4;
|
|
99
|
+
function publicBarLinks(hrefs, locale) {
|
|
100
|
+
const order = ["howItWorks", "pricing", "docs", "download"];
|
|
101
|
+
return order.flatMap((id) => {
|
|
102
|
+
const href = hrefs[id];
|
|
103
|
+
return href ? [{ id, label: navWord(locale, id), href }] : [];
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// src/app-frame/app-frame.tsx
|
|
108
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
109
|
+
var MODES = ["light", "dark", "system"];
|
|
110
|
+
function useFrameTheme(theme) {
|
|
111
|
+
const provided = useOptionalTheme();
|
|
112
|
+
if (theme === false) return null;
|
|
113
|
+
if (theme) return theme;
|
|
114
|
+
return provided ? { value: provided.mode, onChange: provided.setMode } : null;
|
|
115
|
+
}
|
|
116
|
+
function AppFrame({
|
|
117
|
+
name,
|
|
118
|
+
mark,
|
|
119
|
+
headerMark,
|
|
120
|
+
homeHref,
|
|
121
|
+
accent,
|
|
122
|
+
sections,
|
|
123
|
+
currentId,
|
|
124
|
+
account,
|
|
125
|
+
primary,
|
|
126
|
+
search,
|
|
127
|
+
notifications,
|
|
128
|
+
chips,
|
|
129
|
+
variant = "app",
|
|
130
|
+
language,
|
|
131
|
+
theme,
|
|
132
|
+
locale = "en",
|
|
133
|
+
words,
|
|
134
|
+
linkAs: Link,
|
|
135
|
+
children,
|
|
136
|
+
label
|
|
137
|
+
}) {
|
|
138
|
+
const w = { ...navVocabulary(locale), ...words };
|
|
139
|
+
const admin = variant === "admin";
|
|
140
|
+
const links = orderAccountLinks(account.links, admin);
|
|
141
|
+
const places = framePlaces(sections, links.map((l) => l.id));
|
|
142
|
+
const frameTheme = useFrameTheme(theme);
|
|
143
|
+
const item = (section) => /* @__PURE__ */ jsx(
|
|
144
|
+
RailNav.Item,
|
|
145
|
+
{
|
|
146
|
+
asChild: Boolean(Link),
|
|
147
|
+
href: Link ? void 0 : section.href,
|
|
148
|
+
icon: section.icon,
|
|
149
|
+
label: section.label,
|
|
150
|
+
current: section.id === currentId,
|
|
151
|
+
badge: section.badge,
|
|
152
|
+
badgeLabel: section.badgeLabel,
|
|
153
|
+
children: Link ? /* @__PURE__ */ jsx(Link, { href: section.href }) : void 0
|
|
154
|
+
},
|
|
155
|
+
section.id
|
|
156
|
+
);
|
|
157
|
+
const menuLinks = links.map(({ id, link }) => ({ id, label: link.label ?? w[id], href: link.href, icon: link.icon }));
|
|
158
|
+
const modeLabels = { light: w.themeLight, dark: w.themeDark, system: w.themeSystem };
|
|
159
|
+
return /* @__PURE__ */ jsxs(RailNav.Shell, { "data-variant": variant, children: [
|
|
160
|
+
/* @__PURE__ */ jsx(
|
|
161
|
+
RailNav.Root,
|
|
162
|
+
{
|
|
163
|
+
label: label ?? name,
|
|
164
|
+
accent,
|
|
165
|
+
mark: Link ? /* @__PURE__ */ jsx(Link, { href: homeHref, "aria-label": name, children: mark }) : /* @__PURE__ */ jsx("a", { href: homeHref, "aria-label": name, children: mark }),
|
|
166
|
+
footer: places.foot.length > 0 ? places.foot.map(item) : void 0,
|
|
167
|
+
children: places.main.map(item)
|
|
168
|
+
}
|
|
169
|
+
),
|
|
170
|
+
/* @__PURE__ */ jsxs(RailNav.Body, { children: [
|
|
171
|
+
/* @__PURE__ */ jsx(
|
|
172
|
+
AppHeader,
|
|
173
|
+
{
|
|
174
|
+
name,
|
|
175
|
+
mark: headerMark ?? mark,
|
|
176
|
+
href: Link ? void 0 : homeHref,
|
|
177
|
+
homeLink: Link ? /* @__PURE__ */ jsx(Link, { href: homeHref }) : void 0,
|
|
178
|
+
chips: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
179
|
+
admin && /* @__PURE__ */ jsx(Badge, { tone: "accent", children: w.administration }),
|
|
180
|
+
chips
|
|
181
|
+
] }),
|
|
182
|
+
search: search && /* @__PURE__ */ jsx(AppHeaderSearch, { label: search.label, onOpen: search.onOpen }),
|
|
183
|
+
notifications,
|
|
184
|
+
primary,
|
|
185
|
+
account: /* @__PURE__ */ jsx(
|
|
186
|
+
AccountMenu,
|
|
187
|
+
{
|
|
188
|
+
label: w.account,
|
|
189
|
+
name: account.name,
|
|
190
|
+
email: account.email,
|
|
191
|
+
avatar: account.avatar,
|
|
192
|
+
showName: "lg",
|
|
193
|
+
links: menuLinks,
|
|
194
|
+
linkAs: Link,
|
|
195
|
+
language: language && { label: w.language, value: language.value, options: language.options, onChange: language.onChange },
|
|
196
|
+
theme: frameTheme ? { label: w.theme, value: frameTheme.value, options: MODES.map((value) => ({ value, label: modeLabels[value] })), onChange: (value) => frameTheme.onChange(value) } : void 0,
|
|
197
|
+
signOut: { label: w.signOut, onSelect: account.onSignOut }
|
|
198
|
+
}
|
|
199
|
+
)
|
|
200
|
+
}
|
|
201
|
+
),
|
|
202
|
+
children
|
|
203
|
+
] })
|
|
204
|
+
] });
|
|
205
|
+
}
|
|
206
|
+
export {
|
|
207
|
+
ACCOUNT_LINK_IDS,
|
|
208
|
+
ACCOUNT_MENU_ORDER,
|
|
209
|
+
AppFrame,
|
|
210
|
+
MAIN_SECTIONS_MAX,
|
|
211
|
+
PUBLIC_BAR_MAX,
|
|
212
|
+
frameIssues,
|
|
213
|
+
framePlaces,
|
|
214
|
+
navVocabulary,
|
|
215
|
+
navWord,
|
|
216
|
+
navWords,
|
|
217
|
+
orderAccountLinks,
|
|
218
|
+
publicBarLinks
|
|
219
|
+
};
|
|
220
|
+
//# sourceMappingURL=app-frame.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/app-frame/app-frame.tsx","../src/app-frame/contract.ts","../src/app-frame/vocabulary.ts"],"sourcesContent":["// Client (the rail's state, the account menu, the theme). THE signed-in frame of every Krizaka web product (audit F1, F2,\n// F6): the rail (a bottom tab bar on a phone) and the family's top bar, composed once from data. The product keeps its\n// list of sections; the frame owns the rest — the account menu's content and order, where the preferences live (always in\n// the menu: a header has no room for them on a phone), which place is on the rail and which is under the avatar.\nimport { AccountMenu, type AccountMenuLink } from \"@krizaka/ui/account-menu\";\nimport { AppHeader } from \"@krizaka/ui/app-header\";\nimport { AppHeaderSearch } from \"@krizaka/ui/app-header/search\";\nimport { Badge } from \"@krizaka/ui/badge\";\nimport { RailNav } from \"@krizaka/ui/rail-nav\";\nimport { type Mode, useOptionalTheme } from \"@krizaka/ui/theme\";\nimport * as React from \"react\";\n\nimport type { BrandId } from \"../marks/ProductLogo\";\nimport { type AccountLinkId, framePlaces, type FrameSection, orderAccountLinks } from \"./contract\";\nimport { navVocabulary, type NavWords } from \"./vocabulary\";\n\nexport interface AppFrameAccountLink {\n href: string;\n /** Overrides the shared word (`Credits and usage` for billing where credits exist). */\n label?: string;\n icon?: React.ReactNode;\n}\n\nexport interface AppFrameAccount {\n name?: string;\n email?: string;\n /** `src`, or `defaultAvatar` (`{ brand, seed }`). */\n avatar?: React.ComponentProps<typeof AccountMenu>[\"avatar\"];\n /**\n * The places under the avatar. Pass the ones the product has: Billing only when it sells, Administration only for an\n * admin. The frame draws them in its order (Profile, Settings, Billing, Administration), Settings landing on the settings home.\n */\n links?: Partial<Record<AccountLinkId, AppFrameAccountLink>>;\n /** Called by Sign out. */\n onSignOut: () => void;\n}\n\nexport interface AppFrameLanguage {\n value: string;\n options: readonly { value: string; label: string }[];\n onChange: (value: string) => void;\n}\n\nexport interface AppFrameTheme {\n value: Mode;\n onChange: (mode: Mode) => void;\n}\n\nexport interface AppFrameProps {\n /** The product's name, as text in the top bar. */\n name: string;\n /** The product's mark (`<ProductLogo id=\"yomizaka\" size={26} />`): on the rail on a desktop, in the top bar on a phone. */\n mark: React.ReactNode;\n /** The mark in the top bar below `md` (smaller). Defaults to `mark`. */\n headerMark?: React.ReactNode;\n /** Where the mark and the name lead (`/app`). */\n homeHref: string;\n /** The product's brand: scopes its colours over the rail. */\n accent?: BrandId;\n /** The destinations. `place: \"foot\"` puts one at the rail's foot; `gated` leaves one out for this person. */\n sections: readonly FrameSection[];\n /** The id of the section the person is in. */\n currentId?: string;\n /** Who is signed in, the places under their avatar and Sign out. */\n account: AppFrameAccount;\n /** The one primary action of the app (« Check a document »). */\n primary?: React.ReactNode;\n /** The search (⌘K): opens the app's command palette. */\n search?: { label: string; onOpen: () => void };\n /** Notifications: an `AppHeaderCount`, or the trigger of the host's popover. */\n notifications?: React.ReactNode;\n /** Chips beside the name (`Dev`, `Local · Sovereign`). */\n chips?: React.ReactNode;\n /** `admin`: the administration's frame — a chip says so, and the way into it is not offered again. */\n variant?: \"app\" | \"admin\";\n /** The language row of the account menu; absent for a product with one language. */\n language?: AppFrameLanguage;\n /** The theme row. By default the `ThemeProvider`'s; pass `false` for a product that has none. */\n theme?: AppFrameTheme | false;\n /** `en` or `fr`: the words of the shared vocabulary. @default \"en\" */\n locale?: string;\n /** Overrides of the shared words, for a product that needs one different (use sparingly). */\n words?: Partial<NavWords>;\n /** The router's link component (Next's `Link`) for the rail and the menu. */\n linkAs?: React.ElementType;\n /** The page, inside `RailNav.Body` under the top bar. */\n children: React.ReactNode;\n /** The rail's accessible name. Defaults to the product's name. */\n label?: string;\n}\n\nconst MODES: readonly Mode[] = [\"light\", \"dark\", \"system\"];\n\nfunction useFrameTheme(theme: AppFrameProps[\"theme\"]): AppFrameTheme | null {\n const provided = useOptionalTheme();\n if (theme === false) return null;\n if (theme) return theme;\n return provided ? { value: provided.mode, onChange: provided.setMode } : null;\n}\n\n/** The signed-in frame: sections, account and the primary action in; the rail, the top bar and the account menu out. */\nexport function AppFrame({\n name, mark, headerMark, homeHref, accent, sections, currentId, account, primary, search, notifications, chips, variant = \"app\", language, theme, locale = \"en\", words, linkAs: Link, children, label,\n}: AppFrameProps) {\n const w = { ...navVocabulary(locale), ...words };\n const admin = variant === \"admin\";\n const links = orderAccountLinks(account.links, admin);\n const places = framePlaces(sections, links.map((l) => l.id));\n const frameTheme = useFrameTheme(theme);\n const item = (section: FrameSection) => (\n <RailNav.Item\n key={section.id}\n asChild={Boolean(Link)}\n href={Link ? undefined : section.href}\n icon={section.icon}\n label={section.label}\n current={section.id === currentId}\n badge={section.badge}\n badgeLabel={section.badgeLabel}\n >\n {Link ? <Link href={section.href} /> : undefined}\n </RailNav.Item>\n );\n const menuLinks: AccountMenuLink[] = links.map(({ id, link }) => ({ id, label: link.label ?? w[id], href: link.href, icon: link.icon }));\n const modeLabels: Record<Mode, string> = { light: w.themeLight, dark: w.themeDark, system: w.themeSystem };\n return (\n <RailNav.Shell data-variant={variant}>\n <RailNav.Root\n label={label ?? name}\n accent={accent}\n mark={Link ? <Link href={homeHref} aria-label={name}>{mark}</Link> : <a href={homeHref} aria-label={name}>{mark}</a>}\n footer={places.foot.length > 0 ? places.foot.map(item) : undefined}\n >\n {places.main.map(item)}\n </RailNav.Root>\n <RailNav.Body>\n <AppHeader\n name={name}\n mark={headerMark ?? mark}\n href={Link ? undefined : homeHref}\n homeLink={Link ? <Link href={homeHref} /> : undefined}\n chips={\n <>\n {admin && <Badge tone=\"accent\">{w.administration}</Badge>}\n {chips}\n </>\n }\n search={search && <AppHeaderSearch label={search.label} onOpen={search.onOpen} />}\n notifications={notifications}\n primary={primary}\n account={\n <AccountMenu\n label={w.account}\n name={account.name}\n email={account.email}\n avatar={account.avatar}\n showName=\"lg\"\n links={menuLinks}\n linkAs={Link}\n language={language && { label: w.language, value: language.value, options: language.options, onChange: language.onChange }}\n theme={frameTheme ? { label: w.theme, value: frameTheme.value, options: MODES.map((value) => ({ value, label: modeLabels[value] })), onChange: (value) => frameTheme.onChange(value as Mode) } : undefined}\n signOut={{ label: w.signOut, onSelect: account.onSignOut }}\n />\n }\n />\n {children}\n </RailNav.Body>\n </RailNav.Shell>\n );\n}\n","// Server-safe, pure. The rules of the signed-in frame, written once and tested (the audit's F1 and F2): what the account\n// menu holds and in which order, where a place lives (the rail or the avatar, never both), what a phone's tab bar can carry.\nimport type * as React from \"react\";\n\n/** The places the account menu can hold, in the order the frame draws them. */\nexport const ACCOUNT_LINK_IDS = [\"profile\", \"settings\", \"billing\", \"administration\"] as const;\nexport type AccountLinkId = (typeof ACCOUNT_LINK_IDS)[number];\n\n/** The account menu from top to bottom: who you are, the places, the preferences, Sign out. Fixed by the frame, not by the product. */\nexport const ACCOUNT_MENU_ORDER = [\"identity\", \"profile\", \"settings\", \"billing\", \"administration\", \"language\", \"theme\", \"signOut\"] as const;\n\n/** The most destinations a phone's tab bar carries (the rail's main items; the foot follows them in the same bar). */\nexport const MAIN_SECTIONS_MAX = 5;\n\nexport interface FrameSection {\n /** Stable id; `settings`, `billing`, `profile`, `administration` are the account menu's places. */\n id: string;\n label: string;\n href: string;\n icon: React.ReactNode;\n /** Not offered to this person (a permission, a feature not open): left out of the rail and the tab bar. */\n gated?: boolean;\n /** A count on the icon. */\n badge?: string | number;\n /** The count in words (« 3 to decide »). */\n badgeLabel?: string;\n /** `main`: what the person works in (the tab bar on a phone). `foot`: the rail's foot. @default \"main\" */\n place?: \"main\" | \"foot\";\n}\n\nexport interface FramePlaces {\n main: FrameSection[];\n foot: FrameSection[];\n /** Sections left out of the rail because the account menu already holds that place (or because they are gated). */\n dropped: { id: string; reason: \"account\" | \"gated\" }[];\n}\n\n/**\n * Splits the sections into the rail's main and foot, in the order given. A place is on the rail or under the avatar,\n * never both: a section whose id is one of the account links the frame was given leaves the rail (the avatar owns it).\n * A gated section leaves too.\n */\nexport function framePlaces(sections: readonly FrameSection[], accountLinks: readonly string[] = []): FramePlaces {\n const result: FramePlaces = { main: [], foot: [], dropped: [] };\n for (const section of sections) {\n if (section.gated) result.dropped.push({ id: section.id, reason: \"gated\" });\n else if (accountLinks.includes(section.id)) result.dropped.push({ id: section.id, reason: \"account\" });\n else result[section.place === \"foot\" ? \"foot\" : \"main\"].push(section);\n }\n return result;\n}\n\n/** The account links the frame draws, in the frame's order, whatever the order they were written in. Only what was passed. */\nexport function orderAccountLinks<T>(links: Partial<Record<AccountLinkId, T>> | undefined, admin = false): { id: AccountLinkId; link: T }[] {\n if (!links) return [];\n return ACCOUNT_LINK_IDS.flatMap((id) => {\n const link = links[id];\n // Inside the administration, the way into it is not offered again.\n return link && !(admin && id === \"administration\") ? [{ id, link }] : [];\n });\n}\n\n/** What is wrong with a frame's data, in words for the developer (empty: it is right). Used by the tests and by the dev warning. */\nexport function frameIssues(sections: readonly FrameSection[], accountLinks: readonly string[] = []): string[] {\n const issues: string[] = [];\n const ids = sections.map((s) => s.id);\n for (const id of new Set(ids)) if (ids.filter((x) => x === id).length > 1) issues.push(`The section \"${id}\" is declared twice.`);\n const places = framePlaces(sections, accountLinks);\n for (const { id, reason } of places.dropped) if (reason === \"account\") issues.push(`\"${id}\" is on the rail and under the avatar: a place is in one of them, so the rail drops it.`);\n if (places.main.length > MAIN_SECTIONS_MAX) issues.push(`${places.main.length} main sections: a phone's tab bar carries ${MAIN_SECTIONS_MAX} at most.`);\n return issues;\n}\n","// Server-safe: data and pure functions, no React. The words every Krizaka product says the same way (the audit's F4): the\n// frame's menus, the public bar's links and the footers read them, so « Docs », « Terms » and « Settings » never differ\n// between two products. English is the reference; a French key is required by the type.\nexport const navWords = {\n en: {\n docs: \"Docs\",\n terms: \"Terms\",\n privacy: \"Privacy\",\n settings: \"Settings\",\n billing: \"Billing\",\n profile: \"Profile\",\n administration: \"Administration\",\n account: \"Account\",\n language: \"Language\",\n theme: \"Theme\",\n themeLight: \"Light\",\n themeDark: \"Dark\",\n themeSystem: \"System\",\n signOut: \"Sign out\",\n howItWorks: \"How it works\",\n pricing: \"Pricing\",\n download: \"Download\",\n contact: \"Contact\",\n search: \"Search\",\n notifications: \"Notifications\",\n expand: \"Show the words\",\n collapse: \"Hide the words\",\n },\n fr: {\n docs: \"Docs\",\n terms: \"Conditions d'utilisation\",\n privacy: \"Confidentialité\",\n settings: \"Réglages\",\n billing: \"Facturation\",\n profile: \"Profil\",\n administration: \"Administration\",\n account: \"Compte\",\n language: \"Langue\",\n theme: \"Thème\",\n themeLight: \"Clair\",\n themeDark: \"Sombre\",\n themeSystem: \"Système\",\n signOut: \"Se déconnecter\",\n howItWorks: \"Comment ça marche\",\n pricing: \"Tarifs\",\n download: \"Télécharger\",\n contact: \"Contact\",\n search: \"Rechercher\",\n notifications: \"Notifications\",\n expand: \"Afficher les mots\",\n collapse: \"Masquer les mots\",\n },\n} as const satisfies Record<\"en\" | \"fr\", Record<string, string>>;\n\nexport type NavLocale = keyof typeof navWords;\nexport type NavWords = { [K in keyof (typeof navWords)[\"en\"]]: string };\nexport type NavWordKey = keyof NavWords;\n\n/** The words of a locale (`fr`, `fr-CA`…); any other falls back to English. */\nexport function navVocabulary(locale: string = \"en\"): NavWords {\n return navWords[locale.toLowerCase().startsWith(\"fr\") ? \"fr\" : \"en\"];\n}\n\n/** One word of the shared vocabulary. */\nexport function navWord(locale: string | undefined, key: NavWordKey): string {\n return navVocabulary(locale)[key];\n}\n\n/** The most links a product's public bar holds: past four, the bar is a menu in disguise (audit F3). */\nexport const PUBLIC_BAR_MAX = 4;\n\nexport type PublicBarSlot = \"howItWorks\" | \"pricing\" | \"docs\" | \"download\";\nexport interface PublicBarLink {\n id: PublicBarSlot;\n label: string;\n href: string;\n}\n\n/**\n * The one shape of a product's public bar: flat links, in this order, four at most — How it works · Pricing (when the\n * product has a price) · Docs · Download (when an app exists). Privacy and Terms are the footer's, « Overview » is the mark.\n * Pass the address of each slot the product has; the words come from the shared vocabulary.\n */\nexport function publicBarLinks(hrefs: Partial<Record<PublicBarSlot, string>>, locale?: string): PublicBarLink[] {\n const order: PublicBarSlot[] = [\"howItWorks\", \"pricing\", \"docs\", \"download\"];\n return order.flatMap((id) => {\n const href = hrefs[id];\n return href ? [{ id, label: navWord(locale, id), href }] : [];\n });\n}\n"],"mappings":";;;AAIA,SAAS,mBAAyC;AAClD,SAAS,iBAAiB;AAC1B,SAAS,uBAAuB;AAChC,SAAS,aAAa;AACtB,SAAS,eAAe;AACxB,SAAoB,wBAAwB;;;ACJrC,IAAM,mBAAmB,CAAC,WAAW,YAAY,WAAW,gBAAgB;AAI5E,IAAM,qBAAqB,CAAC,YAAY,WAAW,YAAY,WAAW,kBAAkB,YAAY,SAAS,SAAS;AAG1H,IAAM,oBAAoB;AA8B1B,SAAS,YAAY,UAAmC,eAAkC,CAAC,GAAgB;AAChH,QAAM,SAAsB,EAAE,MAAM,CAAC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O,OAAO,WAAW,OAAO,SAAS,MAAM,IAAI,CAAC,WAAW,EAAE,OAAO,OAAO,WAAW,KAAK,EAAE,EAAE,GAAG,UAAU,CAAC,UAAU,WAAW,SAAS,KAAa,EAAE,IAAI;AAAA,cACjM,SAAS,EAAE,OAAO,EAAE,SAAS,UAAU,QAAQ,UAAU;AAAA;AAAA,UAC3D;AAAA;AAAA,MAEJ;AAAA,MACC;AAAA,OACH;AAAA,KACF;AAEJ;","names":[]}
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
import * as tailwind_variants from 'tailwind-variants';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
|
|
4
|
+
interface DesktopCommand {
|
|
5
|
+
/** Sent back by the menu when chosen: lowercase letters, digits, `.` and `-` (`view.sidebar`). */
|
|
6
|
+
id: string;
|
|
7
|
+
/** The menu item's words, passed translated (`Hide sidebar`). */
|
|
8
|
+
label: string;
|
|
9
|
+
/** The menu it belongs to (`View`, `File`), passed translated: the product's menus sit between Edit and Window. */
|
|
10
|
+
menu: string;
|
|
11
|
+
/** A chord (`mod+b`): the menu shows it and the page answers it. A sequence (`g d`) is the page's only. */
|
|
12
|
+
shortcut?: string;
|
|
13
|
+
/** Runs the command. */
|
|
14
|
+
run: () => void;
|
|
15
|
+
/** A separator before it in its menu. */
|
|
16
|
+
separated?: boolean;
|
|
17
|
+
/** Dimmed in the menu while false (default true). */
|
|
18
|
+
enabled?: boolean;
|
|
19
|
+
}
|
|
20
|
+
/** The shape `setNativeMenu` takes for its `menus` (structurally the same as `MenuSpec["menus"]` of @krizaka/app-desktop). */
|
|
21
|
+
interface DesktopMenu {
|
|
22
|
+
title: string;
|
|
23
|
+
items: {
|
|
24
|
+
id: string;
|
|
25
|
+
label: string;
|
|
26
|
+
accelerator?: string;
|
|
27
|
+
enabled?: boolean;
|
|
28
|
+
separated?: boolean;
|
|
29
|
+
}[];
|
|
30
|
+
}
|
|
31
|
+
interface DesktopMenus {
|
|
32
|
+
/** For `setNativeMenu(bridge, { labels, menus }, handlers)`. */
|
|
33
|
+
menus: DesktopMenu[];
|
|
34
|
+
/** For its `handlers`: the id of the chosen item → what it does. */
|
|
35
|
+
handlers: Record<string, () => void>;
|
|
36
|
+
/** For `useShortcuts`: the chords of the commands, answered in the page. */
|
|
37
|
+
shortcuts: Record<string, () => void>;
|
|
38
|
+
}
|
|
39
|
+
/** Turns the commands into the menu bar's menus, its handlers and the page's shortcuts — one source for the three. Throws on a bad or repeated id, or a shortcut given twice. */
|
|
40
|
+
declare function desktopMenus(commands: readonly DesktopCommand[]): DesktopMenus;
|
|
41
|
+
|
|
42
|
+
declare const desktopWindow: tailwind_variants.TVReturnType<{
|
|
43
|
+
[key: string]: {
|
|
44
|
+
[key: string]: tailwind_variants.ClassValue | {
|
|
45
|
+
pane?: tailwind_variants.ClassValue;
|
|
46
|
+
sidebar?: tailwind_variants.ClassValue;
|
|
47
|
+
titlebar?: tailwind_variants.ClassValue;
|
|
48
|
+
scroll?: tailwind_variants.ClassValue;
|
|
49
|
+
middle?: tailwind_variants.ClassValue;
|
|
50
|
+
inspector?: tailwind_variants.ClassValue;
|
|
51
|
+
content?: tailwind_variants.ClassValue;
|
|
52
|
+
toolbarTitle?: tailwind_variants.ClassValue;
|
|
53
|
+
toolbarGroup?: tailwind_variants.ClassValue;
|
|
54
|
+
toggle?: tailwind_variants.ClassValue;
|
|
55
|
+
root?: tailwind_variants.ClassValue;
|
|
56
|
+
separator?: tailwind_variants.ClassValue;
|
|
57
|
+
toolbar?: tailwind_variants.ClassValue;
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
} | {
|
|
61
|
+
[x: string]: {
|
|
62
|
+
[x: string]: tailwind_variants.ClassValue | {
|
|
63
|
+
pane?: tailwind_variants.ClassValue;
|
|
64
|
+
sidebar?: tailwind_variants.ClassValue;
|
|
65
|
+
titlebar?: tailwind_variants.ClassValue;
|
|
66
|
+
scroll?: tailwind_variants.ClassValue;
|
|
67
|
+
middle?: tailwind_variants.ClassValue;
|
|
68
|
+
inspector?: tailwind_variants.ClassValue;
|
|
69
|
+
content?: tailwind_variants.ClassValue;
|
|
70
|
+
toolbarTitle?: tailwind_variants.ClassValue;
|
|
71
|
+
toolbarGroup?: tailwind_variants.ClassValue;
|
|
72
|
+
toggle?: tailwind_variants.ClassValue;
|
|
73
|
+
root?: tailwind_variants.ClassValue;
|
|
74
|
+
separator?: tailwind_variants.ClassValue;
|
|
75
|
+
toolbar?: tailwind_variants.ClassValue;
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
} | {}, {
|
|
79
|
+
root: string;
|
|
80
|
+
pane: string;
|
|
81
|
+
sidebar: string;
|
|
82
|
+
titlebar: string;
|
|
83
|
+
scroll: string;
|
|
84
|
+
middle: string;
|
|
85
|
+
inspector: string;
|
|
86
|
+
separator: string;
|
|
87
|
+
content: string;
|
|
88
|
+
toolbar: string;
|
|
89
|
+
toolbarTitle: string;
|
|
90
|
+
toolbarGroup: string;
|
|
91
|
+
toggle: string;
|
|
92
|
+
}, undefined, {
|
|
93
|
+
[key: string]: {
|
|
94
|
+
[key: string]: tailwind_variants.ClassValue | {
|
|
95
|
+
pane?: tailwind_variants.ClassValue;
|
|
96
|
+
sidebar?: tailwind_variants.ClassValue;
|
|
97
|
+
titlebar?: tailwind_variants.ClassValue;
|
|
98
|
+
scroll?: tailwind_variants.ClassValue;
|
|
99
|
+
middle?: tailwind_variants.ClassValue;
|
|
100
|
+
inspector?: tailwind_variants.ClassValue;
|
|
101
|
+
content?: tailwind_variants.ClassValue;
|
|
102
|
+
toolbarTitle?: tailwind_variants.ClassValue;
|
|
103
|
+
toolbarGroup?: tailwind_variants.ClassValue;
|
|
104
|
+
toggle?: tailwind_variants.ClassValue;
|
|
105
|
+
root?: tailwind_variants.ClassValue;
|
|
106
|
+
separator?: tailwind_variants.ClassValue;
|
|
107
|
+
toolbar?: tailwind_variants.ClassValue;
|
|
108
|
+
};
|
|
109
|
+
};
|
|
110
|
+
} | {}, {
|
|
111
|
+
root: string;
|
|
112
|
+
pane: string;
|
|
113
|
+
sidebar: string;
|
|
114
|
+
titlebar: string;
|
|
115
|
+
scroll: string;
|
|
116
|
+
middle: string;
|
|
117
|
+
inspector: string;
|
|
118
|
+
separator: string;
|
|
119
|
+
content: string;
|
|
120
|
+
toolbar: string;
|
|
121
|
+
toolbarTitle: string;
|
|
122
|
+
toolbarGroup: string;
|
|
123
|
+
toggle: string;
|
|
124
|
+
}, tailwind_variants.TVReturnTypeLike<unknown, {
|
|
125
|
+
root: string;
|
|
126
|
+
pane: string;
|
|
127
|
+
sidebar: string;
|
|
128
|
+
titlebar: string;
|
|
129
|
+
scroll: string;
|
|
130
|
+
middle: string;
|
|
131
|
+
inspector: string;
|
|
132
|
+
separator: string;
|
|
133
|
+
content: string;
|
|
134
|
+
toolbar: string;
|
|
135
|
+
toolbarTitle: string;
|
|
136
|
+
toolbarGroup: string;
|
|
137
|
+
toggle: string;
|
|
138
|
+
}>>;
|
|
139
|
+
interface DesktopWindowLabels {
|
|
140
|
+
/** The sidebar's accessible name (`Library`). */
|
|
141
|
+
sidebar: string;
|
|
142
|
+
/** The inspector's accessible name (`Details`). */
|
|
143
|
+
inspector: string;
|
|
144
|
+
/** The separators' names (`Resize the sidebar`, `Resize the inspector`). */
|
|
145
|
+
resizeSidebar: string;
|
|
146
|
+
resizeInspector: string;
|
|
147
|
+
/** The toolbar buttons that fold the panes (`Show or hide the sidebar`). */
|
|
148
|
+
toggleSidebar: string;
|
|
149
|
+
toggleInspector: string;
|
|
150
|
+
}
|
|
151
|
+
interface DesktopWindowProps {
|
|
152
|
+
/** The sidebar's content: a list of places, a `Tree`. It scrolls by itself. */
|
|
153
|
+
sidebar: React.ReactNode;
|
|
154
|
+
/** The main content under the toolbar. */
|
|
155
|
+
children: React.ReactNode;
|
|
156
|
+
/** The inspector's content: the selected item's details. Without it, a two-pane window. */
|
|
157
|
+
inspector?: React.ReactNode;
|
|
158
|
+
/** The toolbar's title, centred in the drag region. */
|
|
159
|
+
title?: React.ReactNode;
|
|
160
|
+
/** After the sidebar's toggle, at the start of the toolbar (back, forward). */
|
|
161
|
+
toolbarStart?: React.ReactNode;
|
|
162
|
+
/** Before the inspector's toggle, at the end of the toolbar (actions, search). */
|
|
163
|
+
toolbarEnd?: React.ReactNode;
|
|
164
|
+
/** The words of the panes, the dividers and the toggles — passed translated. */
|
|
165
|
+
labels: DesktopWindowLabels;
|
|
166
|
+
/** The sidebar is open (controlled). Pair with `onSidebarOpenChange`: the menu bar's command toggles it too. */
|
|
167
|
+
sidebarOpen?: boolean;
|
|
168
|
+
/** The sidebar starts open (default true) when uncontrolled. */
|
|
169
|
+
defaultSidebarOpen?: boolean;
|
|
170
|
+
/** Called when the sidebar folds or unfolds (the toolbar, a divider, the shortcut). */
|
|
171
|
+
onSidebarOpenChange?: (open: boolean) => void;
|
|
172
|
+
/** The inspector is open (controlled). */
|
|
173
|
+
inspectorOpen?: boolean;
|
|
174
|
+
/** The inspector starts open (default true) when uncontrolled. */
|
|
175
|
+
defaultInspectorOpen?: boolean;
|
|
176
|
+
/** Called when the inspector folds or unfolds. */
|
|
177
|
+
onInspectorOpenChange?: (open: boolean) => void;
|
|
178
|
+
/** The sizes in px: the sidebar's, the inspector's. Persist them with `onSizesChange`. */
|
|
179
|
+
defaultSizes?: {
|
|
180
|
+
sidebar?: number;
|
|
181
|
+
inspector?: number;
|
|
182
|
+
};
|
|
183
|
+
/** Called with the sizes in px after a drag or a key: persist them. */
|
|
184
|
+
onSizesChange?: (sizes: {
|
|
185
|
+
sidebar: number;
|
|
186
|
+
inspector: number;
|
|
187
|
+
}) => void;
|
|
188
|
+
/** The least the content keeps when the window is narrow (default 360). */
|
|
189
|
+
contentMin?: number;
|
|
190
|
+
/** The keys that fold the panes (a chord, or `false` for none): ⌘B and ⌘I by default. Pass `false` when the menu bar's commands (`useDesktopCommands`) own them. */
|
|
191
|
+
shortcuts?: {
|
|
192
|
+
sidebar?: string | false;
|
|
193
|
+
inspector?: string | false;
|
|
194
|
+
};
|
|
195
|
+
/** Classes for the window (`[--kz-window-height:34rem]` to size it inside a page). */
|
|
196
|
+
className?: string;
|
|
197
|
+
}
|
|
198
|
+
/** The window of a Mac app: sidebar · content · inspector, a toolbar that moves the window, the desktop's density. */
|
|
199
|
+
declare function DesktopWindow({ sidebar, children, inspector, title, toolbarStart, toolbarEnd, labels, sidebarOpen, defaultSidebarOpen, onSidebarOpenChange, inspectorOpen, defaultInspectorOpen, onInspectorOpenChange, defaultSizes, onSizesChange, contentMin, shortcuts, className, }: DesktopWindowProps): React.JSX.Element;
|
|
200
|
+
/**
|
|
201
|
+
* The window's commands as one source: registers their chords in the page (`useShortcuts`, the browser's too) and returns
|
|
202
|
+
* the native menu bar's data — `menus` and `handlers` for `setNativeMenu(bridge, { labels, menus }, handlers)` of
|
|
203
|
+
* `@krizaka/app-desktop` — so the menu shows the keys the page answers.
|
|
204
|
+
*/
|
|
205
|
+
declare function useDesktopCommands(commands: readonly DesktopCommand[]): DesktopMenus;
|
|
206
|
+
|
|
207
|
+
interface PaneLimits {
|
|
208
|
+
min: number;
|
|
209
|
+
max: number;
|
|
210
|
+
}
|
|
211
|
+
declare const clamp: (value: number, min: number, max: number) => number;
|
|
212
|
+
/**
|
|
213
|
+
* The most a pane may take: its own maximum, and what leaves the content its minimum beside the other open pane and the
|
|
214
|
+
* two separators. A window that is too small for both gives the content priority, down to the pane's own minimum.
|
|
215
|
+
*/
|
|
216
|
+
declare function paneMax(limits: PaneLimits, windowWidth: number, otherOpenWidth: number, contentMin: number, separators: number): number;
|
|
217
|
+
/** The size after a drag of `delta` px along the reading direction (`direction` 1 in LTR, -1 in RTL; `side` 1 for the start pane, -1 for the end one). */
|
|
218
|
+
declare function dragged(start: number, delta: number, direction: 1 | -1, side: 1 | -1, limits: PaneLimits, ceiling?: number): number;
|
|
219
|
+
/** The size after an arrow key: the arrow that points away from the pane's edge grows it (→ for the start pane in LTR). `null` for another key. */
|
|
220
|
+
declare function keyed(key: string, current: number, direction: 1 | -1, side: 1 | -1, limits: PaneLimits, shift: boolean, ceiling?: number): number | null;
|
|
221
|
+
|
|
222
|
+
export { DesktopWindow, clamp, desktopMenus, desktopWindow, dragged, keyed, paneMax, useDesktopCommands };
|
|
223
|
+
export type { DesktopCommand, DesktopMenu, DesktopMenus, DesktopWindowLabels, DesktopWindowProps, PaneLimits };
|