@apliteni/apliteni-ui 0.154.0 → 0.155.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/docs/components.md +11 -0
- package/package.json +1 -1
- package/react/dist/index.d.ts +9 -2
- package/react/dist/index.js +5 -2
package/docs/components.md
CHANGED
|
@@ -721,6 +721,15 @@ give a different result in each case. A row that goes somewhere has an `href`. A
|
|
|
721
721
|
something reports a `ui-command` event. A row that destroys something names a confirm and opens
|
|
722
722
|
it. **A destructive row with no confirm is rendered disabled instead of running.**
|
|
723
723
|
|
|
724
|
+
**A same-tab pick can go through a client router.** Give the palette `onNavigate`, and a
|
|
725
|
+
same-tab pick on an `href` row calls it with the href instead of setting `window.location.href`,
|
|
726
|
+
so the page changes without a reload. A Cmd- or Ctrl-held pick still opens the tab itself.
|
|
727
|
+
Without the prop, a same-tab pick navigates the way it always has.
|
|
728
|
+
|
|
729
|
+
```tsx
|
|
730
|
+
<CommandPalette open groups={groups} onClose={close} onNavigate={(href) => router.push(href)} />
|
|
731
|
+
```
|
|
732
|
+
|
|
724
733
|
**Results are ranked by how the query matches the item, and you break every tie.** A whole label
|
|
725
734
|
beats a prefix. A prefix beats a word start. A word start beats a substring. A keyword beats a
|
|
726
735
|
note. Initials come last. Groups use the score of their best row. Equal scores keep the order
|
|
@@ -1240,6 +1249,8 @@ The button and tick follow `value` until the caller updates it. `AccountMenu` ma
|
|
|
1240
1249
|
and the section stays in the command palette. One section under a child page is a destination,
|
|
1241
1250
|
the page's parent, so that list is drawn and the row takes `aria-current="true"`.
|
|
1242
1251
|
`searchLabel` names the band trigger's words. `searchShortLabel` is deprecated and not drawn.
|
|
1252
|
+
**`onNavigate` hands the built-in palette's same-tab picks to a client router,** so the page
|
|
1253
|
+
changes without a reload. An app's own `palette` wins: its `onNavigate` is used when it sets one.
|
|
1243
1254
|
**With a sidebar, the account and `bandControl` stand in the sidebar, not on the band, and the
|
|
1244
1255
|
theme is a row of the account menu** (#732). The rail keeps the fold's control
|
|
1245
1256
|
in its head, `bandControl` under the head, then the sections and the account at its foot. A
|
package/package.json
CHANGED
package/react/dist/index.d.ts
CHANGED
|
@@ -281,6 +281,10 @@ type CommandPaletteProps = {
|
|
|
281
281
|
onSelect?: (item: CommandItem, meta: {
|
|
282
282
|
newTab: boolean;
|
|
283
283
|
}) => void;
|
|
284
|
+
/** Called instead of `window.location.href` for a same-tab pick, so a client
|
|
285
|
+
* router can change the page without a reload. A new-tab pick still opens
|
|
286
|
+
* the tab itself, as React Aria does. */
|
|
287
|
+
onNavigate?: (href: string) => void;
|
|
284
288
|
label?: string;
|
|
285
289
|
placeholder?: string;
|
|
286
290
|
empty?: string;
|
|
@@ -294,7 +298,7 @@ type CommandPaletteProps = {
|
|
|
294
298
|
rank?: boolean;
|
|
295
299
|
onQueryChange?: (query: string) => void;
|
|
296
300
|
};
|
|
297
|
-
declare function CommandPalette({ open, onClose, groups, onSelect, label, placeholder, empty, density, hint, rank, onQueryChange, }: CommandPaletteProps): react.ReactPortal | null;
|
|
301
|
+
declare function CommandPalette({ open, onClose, groups, onSelect, onNavigate, label, placeholder, empty, density, hint, rank, onQueryChange, }: CommandPaletteProps): react.ReactPortal | null;
|
|
298
302
|
|
|
299
303
|
type Column<T> = {
|
|
300
304
|
key: keyof T & string;
|
|
@@ -976,10 +980,13 @@ type AppShellProps = {
|
|
|
976
980
|
/** Server-read fold preference. The browser restores the shared rail cookie. */
|
|
977
981
|
defaultCollapsed?: boolean;
|
|
978
982
|
palette?: Omit<CommandPaletteProps, 'open' | 'onClose'>;
|
|
983
|
+
/** Called for a same-tab pick from the built-in palette, so a client router
|
|
984
|
+
* can change the page without a reload. A palette's own `onNavigate` wins. */
|
|
985
|
+
onNavigate?: (href: string) => void;
|
|
979
986
|
/** Spread linkProps onto the router link, including children and onClick. */
|
|
980
987
|
renderLink?: (section: AppShellSection, linkProps: ComponentPropsWithoutRef<'a'>) => ReactNode;
|
|
981
988
|
};
|
|
982
|
-
declare function AppShell({ sections, pathname, title, children, word, brand, layout, brandHref, width, back, lede, actions, tools, bandControl, headControl, account, accountItems, onSignOut, searchLabel, defaultCollapsed, palette, renderLink }: AppShellProps): react.JSX.Element;
|
|
989
|
+
declare function AppShell({ sections, pathname, title, children, word, brand, layout, brandHref, width, back, lede, actions, tools, bandControl, headControl, account, accountItems, onSignOut, searchLabel, defaultCollapsed, palette, onNavigate, renderLink }: AppShellProps): react.JSX.Element;
|
|
983
990
|
|
|
984
991
|
type AuthShellProps = Omit<HTMLAttributes<HTMLDivElement>, 'children'> & {
|
|
985
992
|
brand: ReactNode;
|
package/react/dist/index.js
CHANGED
|
@@ -1554,6 +1554,7 @@ function CommandPalette({
|
|
|
1554
1554
|
onClose,
|
|
1555
1555
|
groups,
|
|
1556
1556
|
onSelect,
|
|
1557
|
+
onNavigate,
|
|
1557
1558
|
label = "Command palette",
|
|
1558
1559
|
placeholder = "Search or run a command\u2026",
|
|
1559
1560
|
empty = "No matches",
|
|
@@ -1594,8 +1595,9 @@ function CommandPalette({
|
|
|
1594
1595
|
onClose();
|
|
1595
1596
|
if (!item.href) return;
|
|
1596
1597
|
if (newTab) window.open(item.href, "_blank", "noopener");
|
|
1598
|
+
else if (onNavigate) onNavigate(item.href);
|
|
1597
1599
|
else window.location.href = item.href;
|
|
1598
|
-
}, [onClose, onSelect]);
|
|
1600
|
+
}, [onClose, onSelect, onNavigate]);
|
|
1599
1601
|
const onKeyDown = (e) => {
|
|
1600
1602
|
if (e.key === "ArrowDown" || e.key === "ArrowUp") {
|
|
1601
1603
|
if (!rows.length) return;
|
|
@@ -4742,6 +4744,7 @@ function AppShell({
|
|
|
4742
4744
|
searchLabel = "Search or run a command\u2026",
|
|
4743
4745
|
defaultCollapsed = false,
|
|
4744
4746
|
palette,
|
|
4747
|
+
onNavigate,
|
|
4745
4748
|
renderLink
|
|
4746
4749
|
}) {
|
|
4747
4750
|
const uid = useId13();
|
|
@@ -4977,7 +4980,7 @@ function AppShell({
|
|
|
4977
4980
|
] })
|
|
4978
4981
|
}
|
|
4979
4982
|
),
|
|
4980
|
-
/* @__PURE__ */ jsx41(CommandPalette, { ...palette ?? { groups: [{ items: sections.map((section) => ({ id: section.href, ...section })) }] }, open: search, onClose: () => setSearch(false) })
|
|
4983
|
+
/* @__PURE__ */ jsx41(CommandPalette, { ...palette ?? { groups: [{ items: sections.map((section) => ({ id: section.href, ...section })) }] }, onNavigate: palette?.onNavigate ?? onNavigate, open: search, onClose: () => setSearch(false) })
|
|
4981
4984
|
] });
|
|
4982
4985
|
}
|
|
4983
4986
|
|