pixelize-design-library 2.4.2-beta.58 → 2.4.2-beta.59
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/CHANGELOG.md +75 -0
- package/COMPONENT-GOTCHAS.md +88 -2
- package/DESIGN-GUIDE.md +26 -3
- package/dist/Components/AppSwitcher/AppSwitcher.js +5 -1
- package/dist/Components/AppSwitcher/AppSwitcherProps.d.ts +2 -0
- package/dist/Components/AppSwitcher/AppSwitcherProps.js +7 -4
- package/dist/Components/Breadcrumbs/Breadcrumbs.d.ts +1 -1
- package/dist/Components/Breadcrumbs/Breadcrumbs.js +33 -10
- package/dist/Components/Breadcrumbs/BreadcrumbsProps.d.ts +16 -2
- package/dist/Components/Card/Card.d.ts +3 -1
- package/dist/Components/Card/Card.js +12 -2
- package/dist/Components/Card/CardProps.d.ts +5 -1
- package/dist/Components/Editor/Editor.js +50 -2
- package/dist/Components/Editor/EditorFieldBar.d.ts +15 -0
- package/dist/Components/Editor/EditorFieldBar.js +19 -0
- package/dist/Components/Editor/EditorProps.d.ts +74 -1
- package/dist/Components/Editor/MakeDynamicDialog.d.ts +12 -0
- package/dist/Components/Editor/MakeDynamicDialog.js +59 -0
- package/dist/Components/Editor/editorLabels.d.ts +4 -0
- package/dist/Components/Editor/editorLabels.js +24 -0
- package/dist/Components/Editor/editorTokenStyles.d.ts +28 -0
- package/dist/Components/Editor/editorTokenStyles.js +30 -0
- package/dist/Components/Editor/editorTokens.d.ts +26 -0
- package/dist/Components/Editor/editorTokens.js +134 -0
- package/dist/Components/Editor/useEditorBridge.d.ts +40 -0
- package/dist/Components/Editor/useEditorBridge.js +141 -0
- package/dist/Components/Kbd/Kbd.d.ts +6 -0
- package/dist/Components/Kbd/Kbd.js +33 -0
- package/dist/Components/Kbd/KbdProps.d.ts +17 -0
- package/dist/Components/Kbd/KbdProps.js +2 -0
- package/dist/Components/LauncherTrigger/LauncherTrigger.d.ts +4 -0
- package/dist/Components/LauncherTrigger/LauncherTrigger.js +41 -0
- package/dist/Components/LauncherTrigger/LauncherTriggerProps.d.ts +16 -0
- package/dist/Components/LauncherTrigger/LauncherTriggerProps.js +2 -0
- package/dist/Components/NavLauncher/NavLauncher.d.ts +3 -0
- package/dist/Components/NavLauncher/NavLauncher.js +395 -0
- package/dist/Components/NavLauncher/NavLauncherProps.d.ts +187 -0
- package/dist/Components/NavLauncher/NavLauncherProps.js +2 -0
- package/dist/Components/NavLauncher/NewTabLink.d.ts +3 -0
- package/dist/Components/NavLauncher/NewTabLink.js +14 -0
- package/dist/Components/NavLauncher/PinToggle.d.ts +3 -0
- package/dist/Components/NavLauncher/PinToggle.js +21 -0
- package/dist/Components/NavLauncher/launcherParts.d.ts +93 -0
- package/dist/Components/NavLauncher/launcherParts.js +130 -0
- package/dist/Components/NavLauncher/match.d.ts +53 -0
- package/dist/Components/NavLauncher/match.js +178 -0
- package/dist/Components/NavLauncher/revealStyles.d.ts +4 -0
- package/dist/Components/NavLauncher/revealStyles.js +19 -0
- package/dist/Components/NavigationBar/NavigationBar.d.ts +1 -1
- package/dist/Components/NavigationBar/NavigationBar.js +2 -2
- package/dist/Components/NavigationBar/NavigationBarProps.d.ts +2 -0
- package/dist/Components/PageHeader/PageHeader.d.ts +1 -1
- package/dist/Components/PageHeader/PageHeader.js +9 -2
- package/dist/Components/PageHeader/PageHeaderProps.d.ts +8 -0
- package/dist/Components/PdfViewer/PdfViewer.d.ts +21 -4
- package/dist/Components/PdfViewer/PdfViewer.js +124 -3
- package/dist/Components/Search/Search.js +2 -1
- package/dist/Components/SideBar/SecondaryBar.js +4 -3
- package/dist/Components/SideBar/SideBar.d.ts +1 -1
- package/dist/Components/SideBar/SideBar.js +30 -9
- package/dist/Components/SideBar/SideBarProps.d.ts +32 -0
- package/dist/Components/SideBar/components/MenuItemBox.d.ts +6 -0
- package/dist/Components/SideBar/components/MenuItemBox.js +8 -4
- package/dist/Components/SideBar/components/MenuPopoverContent.js +3 -2
- package/dist/Components/SideBar/components/OtherApps.js +2 -1
- package/dist/Components/SideBar/components/PinnedSection.d.ts +17 -0
- package/dist/Components/SideBar/components/PinnedSection.js +98 -0
- package/dist/Components/SideBar/sidebarFocus.d.ts +23 -0
- package/dist/Components/SideBar/sidebarFocus.js +20 -0
- package/dist/Components/StageProgress/StageProgress.js +2 -2
- package/dist/Components/StageProgress/StageProgressProps.d.ts +2 -0
- package/dist/Components/StageProgress/StepperStage.js +5 -2
- package/dist/Components/WizardDialog/WizardDialog.d.ts +9 -0
- package/dist/Components/WizardDialog/WizardDialog.js +102 -0
- package/dist/Components/WizardDialog/WizardDialogProps.d.ts +48 -0
- package/dist/Components/WizardDialog/WizardDialogProps.js +2 -0
- package/dist/Components/WizardDialog/useWizardFlow.d.ts +22 -0
- package/dist/Components/WizardDialog/useWizardFlow.js +47 -0
- package/dist/Components/WizardDialog/wizardSteps.d.ts +31 -0
- package/dist/Components/WizardDialog/wizardSteps.js +40 -0
- package/dist/esm/Components/AppSwitcher/AppSwitcher.js +2 -1
- package/dist/esm/Components/AppSwitcher/AppSwitcherProps.js +5 -3
- package/dist/esm/Components/Breadcrumbs/Breadcrumbs.js +35 -12
- package/dist/esm/Components/Card/Card.js +12 -2
- package/dist/esm/Components/Editor/Editor.js +48 -3
- package/dist/esm/Components/Editor/EditorFieldBar.js +13 -0
- package/dist/esm/Components/Editor/MakeDynamicDialog.js +20 -0
- package/dist/esm/Components/Editor/editorLabels.js +20 -0
- package/dist/esm/Components/Editor/editorTokenStyles.js +25 -0
- package/dist/esm/Components/Editor/editorTokens.js +121 -0
- package/dist/esm/Components/Editor/useEditorBridge.js +138 -0
- package/dist/esm/Components/Kbd/Kbd.js +28 -0
- package/dist/esm/Components/Kbd/KbdProps.js +1 -0
- package/dist/esm/Components/LauncherTrigger/LauncherTrigger.js +37 -0
- package/dist/esm/Components/LauncherTrigger/LauncherTriggerProps.js +1 -0
- package/dist/esm/Components/NavLauncher/NavLauncher.js +356 -0
- package/dist/esm/Components/NavLauncher/NavLauncherProps.js +1 -0
- package/dist/esm/Components/NavLauncher/NewTabLink.js +11 -0
- package/dist/esm/Components/NavLauncher/PinToggle.js +18 -0
- package/dist/esm/Components/NavLauncher/launcherParts.js +110 -0
- package/dist/esm/Components/NavLauncher/match.js +172 -0
- package/dist/esm/Components/NavLauncher/revealStyles.js +15 -0
- package/dist/esm/Components/NavigationBar/NavigationBar.js +3 -3
- package/dist/esm/Components/PageHeader/PageHeader.js +9 -2
- package/dist/esm/Components/PdfViewer/PdfViewer.js +123 -2
- package/dist/esm/Components/Search/Search.js +3 -2
- package/dist/esm/Components/SideBar/SecondaryBar.js +4 -3
- package/dist/esm/Components/SideBar/SideBar.js +31 -10
- package/dist/esm/Components/SideBar/components/MenuItemBox.js +4 -2
- package/dist/esm/Components/SideBar/components/MenuPopoverContent.js +3 -2
- package/dist/esm/Components/SideBar/components/OtherApps.js +2 -1
- package/dist/esm/Components/SideBar/components/PinnedSection.js +92 -0
- package/dist/esm/Components/SideBar/sidebarFocus.js +15 -0
- package/dist/esm/Components/StageProgress/StageProgress.js +2 -2
- package/dist/esm/Components/StageProgress/StepperStage.js +5 -2
- package/dist/esm/Components/WizardDialog/WizardDialog.js +58 -0
- package/dist/esm/Components/WizardDialog/WizardDialogProps.js +1 -0
- package/dist/esm/Components/WizardDialog/useWizardFlow.js +44 -0
- package/dist/esm/Components/WizardDialog/wizardSteps.js +35 -0
- package/dist/esm/index.js +7 -0
- package/dist/index.d.ts +19 -4
- package/dist/index.js +21 -1
- package/package.json +1 -1
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useEditorBridge = useEditorBridge;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const editorTokens_1 = require("./editorTokens");
|
|
6
|
+
function useEditorBridge({ value, onChange, onBlur, mergeFields, syntax, chipLabel, apiRef, onReady, onUnknownTokens, }) {
|
|
7
|
+
const enabled = mergeFields !== undefined;
|
|
8
|
+
const fieldsKey = JSON.stringify(mergeFields);
|
|
9
|
+
const ctx = (0, react_1.useMemo)(() => ({ fields: mergeFields !== null && mergeFields !== void 0 ? mergeFields : [], syntax, chipLabel }),
|
|
10
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
11
|
+
[fieldsKey, syntax.open, syntax.close, chipLabel]);
|
|
12
|
+
const joditRef = (0, react_1.useRef)(null);
|
|
13
|
+
const rangeRef = (0, react_1.useRef)(null);
|
|
14
|
+
const lastRef = (0, react_1.useRef)(null);
|
|
15
|
+
const appliedFieldsKey = (0, react_1.useRef)(fieldsKey);
|
|
16
|
+
const live = (0, react_1.useRef)({ enabled, ctx, onChange, onBlur, onReady, fieldsKey });
|
|
17
|
+
live.current = { enabled, ctx, onChange, onBlur, onReady, fieldsKey };
|
|
18
|
+
const [instance, setInstance] = (0, react_1.useState)(null);
|
|
19
|
+
const [raw, setRaw] = (0, react_1.useState)(value !== null && value !== void 0 ? value : "");
|
|
20
|
+
(0, react_1.useEffect)(() => {
|
|
21
|
+
if (value !== undefined)
|
|
22
|
+
setRaw(value);
|
|
23
|
+
}, [value]);
|
|
24
|
+
const handleChange = (0, react_1.useCallback)((html) => {
|
|
25
|
+
const { enabled: on, ctx: c, onChange: emit } = live.current;
|
|
26
|
+
const next = on ? (0, editorTokens_1.serializeChips)(html, c.syntax) : html;
|
|
27
|
+
lastRef.current = { raw: next, jodit: html };
|
|
28
|
+
setRaw(next);
|
|
29
|
+
emit === null || emit === void 0 ? void 0 : emit(next);
|
|
30
|
+
}, []);
|
|
31
|
+
const handleBlur = (0, react_1.useCallback)((html, event) => {
|
|
32
|
+
const { enabled: on, ctx: c, onBlur: emit } = live.current;
|
|
33
|
+
emit === null || emit === void 0 ? void 0 : emit(on ? (0, editorTokens_1.serializeChips)(html, c.syntax) : html, event);
|
|
34
|
+
}, []);
|
|
35
|
+
const attachEditor = (0, react_1.useCallback)((jodit) => {
|
|
36
|
+
joditRef.current = jodit;
|
|
37
|
+
rangeRef.current = null;
|
|
38
|
+
appliedFieldsKey.current = live.current.fieldsKey;
|
|
39
|
+
const remember = () => {
|
|
40
|
+
if (jodit.s.isInsideArea)
|
|
41
|
+
rangeRef.current = jodit.s.range.cloneRange();
|
|
42
|
+
};
|
|
43
|
+
jodit.events.on("keyup mouseup touchend", remember);
|
|
44
|
+
jodit.events.on("change", handleChange);
|
|
45
|
+
jodit.events.on("blur", (event) => handleBlur(jodit.value, event));
|
|
46
|
+
const deleteChip = (event) => {
|
|
47
|
+
if (!live.current.enabled)
|
|
48
|
+
return false;
|
|
49
|
+
if (event.key !== "Backspace" && event.key !== "Delete")
|
|
50
|
+
return false;
|
|
51
|
+
const chip = (0, editorTokens_1.adjacentChip)(jodit.s.range, event.key === "Backspace" ? "backward" : "forward");
|
|
52
|
+
if (!chip)
|
|
53
|
+
return false;
|
|
54
|
+
chip.remove();
|
|
55
|
+
jodit.synchronizeValues();
|
|
56
|
+
event.preventDefault();
|
|
57
|
+
return true;
|
|
58
|
+
};
|
|
59
|
+
jodit.events.on("keydown", ((event) => (deleteChip(event) ? false : undefined)));
|
|
60
|
+
jodit.editor.addEventListener("keydown", (event) => {
|
|
61
|
+
if (deleteChip(event))
|
|
62
|
+
event.stopImmediatePropagation();
|
|
63
|
+
}, true);
|
|
64
|
+
jodit.waitForReady().then(() => {
|
|
65
|
+
var _a, _b;
|
|
66
|
+
if (joditRef.current !== jodit)
|
|
67
|
+
return;
|
|
68
|
+
setInstance(jodit);
|
|
69
|
+
(_b = (_a = live.current).onReady) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
70
|
+
});
|
|
71
|
+
}, [handleChange, handleBlur]);
|
|
72
|
+
(0, react_1.useEffect)(() => {
|
|
73
|
+
if (!instance || !enabled || appliedFieldsKey.current === fieldsKey)
|
|
74
|
+
return;
|
|
75
|
+
appliedFieldsKey.current = fieldsKey;
|
|
76
|
+
const html = (0, editorTokens_1.chipify)((0, editorTokens_1.serializeChips)(instance.value, ctx.syntax), ctx);
|
|
77
|
+
instance.value = html;
|
|
78
|
+
lastRef.current = { raw: (0, editorTokens_1.serializeChips)(html, ctx.syntax), jodit: instance.value };
|
|
79
|
+
}, [instance, enabled, fieldsKey, ctx]);
|
|
80
|
+
const api = (0, react_1.useMemo)(() => {
|
|
81
|
+
const current = () => joditRef.current;
|
|
82
|
+
const currentRaw = (jodit) => live.current.enabled ? (0, editorTokens_1.serializeChips)(jodit.value, live.current.ctx.syntax) : jodit.value;
|
|
83
|
+
const insertHTML = (html) => {
|
|
84
|
+
const jodit = current();
|
|
85
|
+
if (!jodit)
|
|
86
|
+
return;
|
|
87
|
+
if (rangeRef.current)
|
|
88
|
+
jodit.s.selectRange(rangeRef.current, true);
|
|
89
|
+
jodit.s.insertHTML(html);
|
|
90
|
+
rangeRef.current = jodit.s.range.cloneRange();
|
|
91
|
+
};
|
|
92
|
+
return {
|
|
93
|
+
insertHTML,
|
|
94
|
+
insertField: (path) => {
|
|
95
|
+
const { enabled: on, ctx: c } = live.current;
|
|
96
|
+
insertHTML(on ? (0, editorTokens_1.chipHtml)(path, c) : (0, editorTokens_1.fieldToken)(path, c.syntax));
|
|
97
|
+
},
|
|
98
|
+
getSelectionText: () => (rangeRef.current ? rangeRef.current.toString().trim() : ""),
|
|
99
|
+
replaceAll: (text, path) => {
|
|
100
|
+
const jodit = current();
|
|
101
|
+
if (!jodit)
|
|
102
|
+
return 0;
|
|
103
|
+
const { enabled: on, ctx: c, onChange: emit } = live.current;
|
|
104
|
+
const result = (0, editorTokens_1.makeDynamic)(currentRaw(jodit), text, path, c.syntax);
|
|
105
|
+
if (result.count === 0)
|
|
106
|
+
return 0;
|
|
107
|
+
jodit.value = on ? (0, editorTokens_1.chipify)(result.html, c) : result.html;
|
|
108
|
+
lastRef.current = { raw: result.html, jodit: jodit.value };
|
|
109
|
+
rangeRef.current = null;
|
|
110
|
+
setRaw(result.html);
|
|
111
|
+
emit === null || emit === void 0 ? void 0 : emit(result.html);
|
|
112
|
+
return result.count;
|
|
113
|
+
},
|
|
114
|
+
countOccurrences: (text) => {
|
|
115
|
+
const jodit = current();
|
|
116
|
+
return jodit ? (0, editorTokens_1.countOccurrences)(currentRaw(jodit), text, live.current.ctx.syntax) : 0;
|
|
117
|
+
},
|
|
118
|
+
focus: () => {
|
|
119
|
+
var _a;
|
|
120
|
+
(_a = current()) === null || _a === void 0 ? void 0 : _a.s.focus();
|
|
121
|
+
},
|
|
122
|
+
};
|
|
123
|
+
}, []);
|
|
124
|
+
(0, react_1.useImperativeHandle)(apiRef, () => api, [api]);
|
|
125
|
+
const unknown = (0, react_1.useMemo)(() => (enabled ? (0, editorTokens_1.unknownTokens)(raw, ctx.fields, syntax) : []), [enabled, raw, ctx, syntax]);
|
|
126
|
+
const unknownKey = unknown.join("\n");
|
|
127
|
+
const reported = (0, react_1.useRef)("");
|
|
128
|
+
(0, react_1.useEffect)(() => {
|
|
129
|
+
if (!enabled || reported.current === unknownKey)
|
|
130
|
+
return;
|
|
131
|
+
reported.current = unknownKey;
|
|
132
|
+
onUnknownTokens === null || onUnknownTokens === void 0 ? void 0 : onUnknownTokens(unknown);
|
|
133
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
134
|
+
}, [enabled, unknownKey]);
|
|
135
|
+
const last = lastRef.current;
|
|
136
|
+
let joditValue = value;
|
|
137
|
+
if (enabled && value !== undefined) {
|
|
138
|
+
joditValue = last && last.raw === value ? last.jodit : (0, editorTokens_1.chipify)(value, ctx);
|
|
139
|
+
}
|
|
140
|
+
return { joditValue, attachEditor, api, instance, raw, unknown, ctx };
|
|
141
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { KbdProps, KbdShortcutProps } from "./KbdProps";
|
|
2
|
+
export declare const detectApple: () => boolean;
|
|
3
|
+
/** One keyboard key cap; decorative hint rows should wrap it in `aria-hidden`. */
|
|
4
|
+
declare const Kbd: ({ children, size, "data-testid": testId }: KbdProps) => import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
export declare const KbdShortcut: ({ shortcut, size, isApple, "data-testid": testId }: KbdShortcutProps) => import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
export default Kbd;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.KbdShortcut = exports.detectApple = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("@chakra-ui/react");
|
|
6
|
+
const useCustomTheme_1 = require("../../Theme/useCustomTheme");
|
|
7
|
+
const AppSwitcherProps_1 = require("../AppSwitcher/AppSwitcherProps");
|
|
8
|
+
const HEIGHT = { xs: "1rem", sm: "1.25rem" };
|
|
9
|
+
const SPOKEN = {
|
|
10
|
+
mod: "Command",
|
|
11
|
+
cmd: "Command",
|
|
12
|
+
ctrl: "Control",
|
|
13
|
+
alt: "Option",
|
|
14
|
+
shift: "Shift",
|
|
15
|
+
enter: "Enter",
|
|
16
|
+
esc: "Escape",
|
|
17
|
+
};
|
|
18
|
+
const detectApple = () => typeof navigator !== "undefined" && /Mac|iPhone|iPad/.test(navigator.platform);
|
|
19
|
+
exports.detectApple = detectApple;
|
|
20
|
+
/** One keyboard key cap; decorative hint rows should wrap it in `aria-hidden`. */
|
|
21
|
+
const Kbd = ({ children, size = "sm", "data-testid": testId }) => {
|
|
22
|
+
const { colors } = (0, useCustomTheme_1.useCustomTheme)();
|
|
23
|
+
return ((0, jsx_runtime_1.jsx)(react_1.Box, { as: "kbd", "data-testid": testId, display: "inline-flex", alignItems: "center", justifyContent: "center", minW: HEIGHT[size], h: HEIGHT[size], px: 1.5, fontFamily: "inherit", fontSize: "0.6875rem", fontWeight: 600, lineHeight: 1, whiteSpace: "nowrap", borderWidth: "1px", borderColor: colors.boxborder[200], borderRadius: "base", bg: colors.backgroundColor.subtle, color: colors.textMuted, children: children }));
|
|
24
|
+
};
|
|
25
|
+
const KbdShortcut = ({ shortcut, size, isApple, "data-testid": testId }) => {
|
|
26
|
+
const parts = shortcut.split("+").map((p) => p.trim()).filter(Boolean);
|
|
27
|
+
const apple = isApple !== null && isApple !== void 0 ? isApple : (0, exports.detectApple)();
|
|
28
|
+
const spoken = parts.map((p) => { var _a; return (_a = SPOKEN[p.toLowerCase()]) !== null && _a !== void 0 ? _a : p.toUpperCase(); }).join(" ");
|
|
29
|
+
const keys = (0, AppSwitcherProps_1.shortcutKeys)(shortcut, apple);
|
|
30
|
+
return ((0, jsx_runtime_1.jsx)(react_1.Box, { as: "span", display: "inline-flex", gap: 1, role: "img", "aria-label": spoken, "data-testid": testId, children: keys.map((key, i) => ((0, jsx_runtime_1.jsx)(Kbd, { size: size, children: key }, `${key}-${i}`))) }));
|
|
31
|
+
};
|
|
32
|
+
exports.KbdShortcut = KbdShortcut;
|
|
33
|
+
exports.default = Kbd;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
/** Props for a single keyboard key cap. */
|
|
3
|
+
export interface KbdProps {
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
/** `sm` is 20px tall (default); `xs` is 16px. */
|
|
6
|
+
size?: "xs" | "sm";
|
|
7
|
+
"data-testid"?: string;
|
|
8
|
+
}
|
|
9
|
+
/** Props for a key chord such as `mod+k`, rendered as one `Kbd` per key. */
|
|
10
|
+
export interface KbdShortcutProps {
|
|
11
|
+
/** Chord in `AppSwitcher` notation, e.g. `mod+shift+k`. */
|
|
12
|
+
shortcut: string;
|
|
13
|
+
size?: KbdProps["size"];
|
|
14
|
+
/** Forces Apple glyphs (⌘ ⇧) or Ctrl/Shift words; defaults to platform detection. */
|
|
15
|
+
isApple?: boolean;
|
|
16
|
+
"data-testid"?: string;
|
|
17
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { LauncherTriggerProps } from "./LauncherTriggerProps";
|
|
2
|
+
export declare const keyShortcutsFor: (shortcut: string) => string;
|
|
3
|
+
declare const LauncherTrigger: ({ onClick, isOpen, label, shortcut, icon: Icon, "aria-label": ariaLabel, "data-testid": testId, }: LauncherTriggerProps) => import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
export default LauncherTrigger;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.keyShortcutsFor = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("@chakra-ui/react");
|
|
6
|
+
const lucide_react_1 = require("lucide-react");
|
|
7
|
+
const useCustomTheme_1 = require("../../Theme/useCustomTheme");
|
|
8
|
+
const motion_1 = require("../../Theme/chakra/motion");
|
|
9
|
+
const focusRing_styles_1 = require("../../Theme/chakra/focusRing.styles");
|
|
10
|
+
const motion_2 = require("../../Theme/tokens/primitives/motion");
|
|
11
|
+
const useMatchMedia_1 = require("../../Hooks/useMatchMedia");
|
|
12
|
+
const Kbd_1 = require("../Kbd/Kbd");
|
|
13
|
+
const AppSwitcherProps_1 = require("../AppSwitcher/AppSwitcherProps");
|
|
14
|
+
const MD_QUERY = "(min-width: 48em)";
|
|
15
|
+
const KEY_NAMES = {
|
|
16
|
+
mod: ["Meta", "Control"],
|
|
17
|
+
cmd: ["Meta"],
|
|
18
|
+
ctrl: ["Control"],
|
|
19
|
+
alt: ["Alt"],
|
|
20
|
+
shift: ["Shift"],
|
|
21
|
+
esc: ["Escape"],
|
|
22
|
+
};
|
|
23
|
+
const keyShortcutsFor = (shortcut) => {
|
|
24
|
+
const options = shortcut
|
|
25
|
+
.split("+")
|
|
26
|
+
.map((p) => p.trim())
|
|
27
|
+
.filter(Boolean)
|
|
28
|
+
.map((p) => { var _a; return (_a = KEY_NAMES[p.toLowerCase()]) !== null && _a !== void 0 ? _a : [p.length === 1 ? p.toUpperCase() : p]; });
|
|
29
|
+
const variants = Math.max(1, ...options.map((o) => o.length));
|
|
30
|
+
const chords = Array.from({ length: variants }, (_, v) => options.map((o) => o[Math.min(v, o.length - 1)]).join("+"));
|
|
31
|
+
return Array.from(new Set(chords)).join(" ");
|
|
32
|
+
};
|
|
33
|
+
exports.keyShortcutsFor = keyShortcutsFor;
|
|
34
|
+
const LauncherTrigger = ({ onClick, isOpen, label = "Menu", shortcut = "mod+k", icon: Icon = lucide_react_1.Compass, "aria-label": ariaLabel, "data-testid": testId, }) => {
|
|
35
|
+
const { colors } = (0, useCustomTheme_1.useCustomTheme)();
|
|
36
|
+
const showHint = (0, useMatchMedia_1.useMatchMedia)(MD_QUERY, true);
|
|
37
|
+
const ring = (0, focusRing_styles_1.focusVisibleRing)(colors);
|
|
38
|
+
const hint = shortcut ? (0, AppSwitcherProps_1.formatShortcut)(shortcut, (0, Kbd_1.detectApple)()) : "";
|
|
39
|
+
return ((0, jsx_runtime_1.jsxs)(react_1.Box, { as: "button", type: "button", "data-testid": testId, onClick: onClick, "aria-haspopup": "dialog", "aria-expanded": isOpen, "aria-label": ariaLabel, "aria-keyshortcuts": shortcut ? (0, exports.keyShortcutsFor)(shortcut) : undefined, display: "inline-flex", alignItems: "center", gap: 2, flexShrink: 0, h: "2.25rem", pl: "0.625rem", pr: "0.375rem", borderRadius: "10px", borderWidth: "1px", borderColor: colors.primary[100], bg: colors.primary[50], color: colors.accentText, fontSize: "0.84375rem", fontWeight: 600, lineHeight: 1, cursor: "pointer", transition: (0, motion_2.transitionFor)(["background-color", "border-color", "box-shadow"]), _hover: { borderColor: colors.primary[300] }, sx: { _focusVisible: ring, [focusRing_styles_1.FOCUS_VISIBLE_OVER_STATE]: ring, ...(0, motion_1.reducedMotionSx)() }, children: [(0, jsx_runtime_1.jsxs)(react_1.Box, { as: "span", display: "inline-flex", alignItems: "center", gap: 2, "aria-hidden": ariaLabel ? true : undefined, children: [(0, jsx_runtime_1.jsx)(Icon, { size: 17, "aria-hidden": "true" }), (0, jsx_runtime_1.jsx)("span", { children: label })] }), hint && showHint && ((0, jsx_runtime_1.jsx)(react_1.Box, { as: "kbd", "aria-hidden": "true", fontFamily: "inherit", fontSize: "0.6875rem", fontWeight: 600, lineHeight: "normal", px: "6px", py: "2px", borderRadius: "6px", borderWidth: "1px", borderColor: colors.primary[100], bg: colors.surfaceRaised, children: hint }))] }));
|
|
40
|
+
};
|
|
41
|
+
exports.default = LauncherTrigger;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ElementType } from "react";
|
|
2
|
+
/** Props for the chip that opens an app-owned launcher; it renders the trigger only and binds no shortcut. */
|
|
3
|
+
export interface LauncherTriggerProps {
|
|
4
|
+
onClick: () => void;
|
|
5
|
+
/** Whether the launcher is open; drives `aria-expanded`. */
|
|
6
|
+
isOpen: boolean;
|
|
7
|
+
/** Visible text. Default "Menu". */
|
|
8
|
+
label?: string;
|
|
9
|
+
/** Chord in `AppSwitcher` notation shown as a hint above `md` and exposed as `aria-keyshortcuts`; `null` hides both. Default "mod+k". */
|
|
10
|
+
shortcut?: string | null;
|
|
11
|
+
/** Component rendered at 17px before the label. Default lucide `Compass`. */
|
|
12
|
+
icon?: ElementType;
|
|
13
|
+
/** Overrides the accessible name; the visible label and hint then become `aria-hidden`. */
|
|
14
|
+
"aria-label"?: string;
|
|
15
|
+
"data-testid"?: string;
|
|
16
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { NavLauncherProps } from "./NavLauncherProps";
|
|
2
|
+
/** Left-drawer navigation launcher: browse every module, pins, Frequent, Recent, search and (compact) the suite's apps. */
|
|
3
|
+
export default function NavLauncher({ isOpen, onClose, sections: rawSections, pinnedIds, frequentIds, recentIds, onTogglePin, onNavigate, linkAs, actions, extraResults, query: controlledQuery, onQueryChange, isSearching, isLoading, keyScreenLimit, frequentLimit, suggestions, searchHint, openShortcutHint, modKeyLabel, maxWidth, labels: labelOverrides, apps, currentAppId, onAppSelect, appsVisibility, "data-testid": testId, }: NavLauncherProps): import("react/jsx-runtime").JSX.Element;
|