@apliteni/apliteni-ui 0.154.0 → 0.156.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.
@@ -422,10 +422,13 @@ should use a dropdown instead of a filter. The bound does not work with an inlin
422
422
  A chip also cannot become narrower than the selected value's min-content width.
423
423
 
424
424
  **An open menu is wide enough to read.** A chip's trigger is only as wide as the value it shows.
425
- When open, the menu uses the kit's 240px menu floor instead of the trigger's width. If its row is
426
- narrower, it uses the row's width. When the side where it opens is short, it moves back along the
427
- row. It never leaves the row or makes the page wider. When closed, the menu keeps the trigger's
428
- width. This prevents the page from growing before any script runs. The floor is measured after
425
+ When open, the menu uses the kit's 240px menu floor instead of the trigger's width. Its row is
426
+ the toolbar line that holds the bar, or the bar itself when no toolbar holds it, so a bar with one
427
+ chip still gets a readable menu (`src/logic/dropdown-placement.js:100` `function filterPanelRow`).
428
+ If its row is narrower than the floor, it uses the row's width. When the side where it opens is
429
+ short, it moves back along the row. It never leaves the row or makes the page wider. Its rows use
430
+ the body weight, because they list the values the chip prints. When closed, the menu keeps the
431
+ trigger's width. This prevents the page from growing before any script runs. The floor is measured after
429
432
  the kit's JavaScript runs. It is measured again when the row changes width or the chip moves
430
433
  along the row. The width remains held until the menu finishes fading out. Nothing is painted
431
434
  narrower than the row allows. `filterPanelFit(dropdown, floor)` and `DD_MENU_FLOOR` are
@@ -721,6 +724,15 @@ give a different result in each case. A row that goes somewhere has an `href`. A
721
724
  something reports a `ui-command` event. A row that destroys something names a confirm and opens
722
725
  it. **A destructive row with no confirm is rendered disabled instead of running.**
723
726
 
727
+ **A same-tab pick can go through a client router.** Give the palette `onNavigate`, and a
728
+ same-tab pick on an `href` row calls it with the href instead of setting `window.location.href`,
729
+ so the page changes without a reload. A Cmd- or Ctrl-held pick still opens the tab itself.
730
+ Without the prop, a same-tab pick navigates the way it always has.
731
+
732
+ ```tsx
733
+ <CommandPalette open groups={groups} onClose={close} onNavigate={(href) => router.push(href)} />
734
+ ```
735
+
724
736
  **Results are ranked by how the query matches the item, and you break every tie.** A whole label
725
737
  beats a prefix. A prefix beats a word start. A word start beats a substring. A keyword beats a
726
738
  note. Initials come last. Groups use the score of their best row. Equal scores keep the order
@@ -1240,6 +1252,8 @@ The button and tick follow `value` until the caller updates it. `AccountMenu` ma
1240
1252
  and the section stays in the command palette. One section under a child page is a destination,
1241
1253
  the page's parent, so that list is drawn and the row takes `aria-current="true"`.
1242
1254
  `searchLabel` names the band trigger's words. `searchShortLabel` is deprecated and not drawn.
1255
+ **`onNavigate` hands the built-in palette's same-tab picks to a client router,** so the page
1256
+ changes without a reload. An app's own `palette` wins: its `onNavigate` is used when it sets one.
1243
1257
  **With a sidebar, the account and `bandControl` stand in the sidebar, not on the band, and the
1244
1258
  theme is a row of the account menu** (#732). The rail keeps the fold's control
1245
1259
  in its head, `bandControl` under the head, then the sections and the account at its foot. A
@@ -68,7 +68,7 @@
68
68
 
69
69
  **Rule:** Limit each column to its longest cell plus the cell inset.
70
70
 
71
- **Do:** Keep amounts beside their references in a two-column table.
71
+ **Do:** Let each amount sit beside its reference.
72
72
 
73
73
  **Don't:** Stretch short tables across the page.
74
74
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apliteni/apliteni-ui",
3
- "version": "0.154.0",
3
+ "version": "0.156.0",
4
4
  "workspaces": [
5
5
  "react"
6
6
  ],
@@ -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;
@@ -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
 
package/src/index.d.ts CHANGED
@@ -44,7 +44,8 @@ export declare function dropdownAvail(opts: {
44
44
  }): number;
45
45
  /** The kit's menu floor, the width `.ui-dropdown__panel` writes. */
46
46
  export declare const DD_MENU_FLOOR: number;
47
- /** The `.ui-filter-bar` an anchored menu's fit is measured inside, or `null`.
47
+ /** The `.ui-toolbar` that holds the bar, else the `.ui-filter-bar`, an anchored
48
+ * menu's fit is measured inside, or `null`.
48
49
  * A chip's menu, and a menu that asks for a width with `--ui-filter-panel-ask` on
49
50
  * its own panel: the slide is that trigger's offset along the row, so those two
50
51
  * are the subjects and a panel anchored to the row itself sizes itself.
@@ -95,13 +95,15 @@ const ddFitPanelOf = (dd) => (typeof dd?.querySelector === 'function'
95
95
  * drift from the stylesheet. why: src/styles/filter-bar.css
96
96
  *
97
97
  * @param {Element} dd a `.ui-dropdown` that may be inside a filter row
98
- * @returns {Element|null} the `.ui-filter-bar` this menu's fit is measured in
98
+ * @returns {Element|null} the `.ui-toolbar` or `.ui-filter-bar` this menu's fit is measured in
99
99
  */
100
100
  export function filterPanelRow(dd) {
101
101
  if (typeof dd?.closest !== 'function') return null;
102
102
  const chip = dd.closest('.ui-filter-bar__chip');
103
- if (chip) return chip.closest('.ui-filter-bar');
104
- return ddPanelAsk(ddFitPanelOf(dd)) ? dd.closest('.ui-filter-bar') : null;
103
+ const bar = chip ? chip.closest('.ui-filter-bar') : ddPanelAsk(ddFitPanelOf(dd)) && dd.closest('.ui-filter-bar');
104
+ // A bar in a toolbar is only as wide as its chips, so one chip's menu was that chip's
105
+ // width. The toolbar's line is the row. #757
106
+ return bar ? bar.closest('.ui-toolbar') || bar : null;
105
107
  }
106
108
 
107
109
  /**
@@ -109,6 +109,9 @@
109
109
  Primer and Radix all tick a chosen menu row. #549
110
110
  why: docs/components.md#a-filter-row-holds-its-panels */
111
111
  .ui-filter-bar .ui-dropdown__item.is-selected { background: var(--glow-purple); /* code-bg: inherit — a translucent wash moves the ground, not the chip on it. */ }
112
+ /* A chip's menu lists the values the chip prints, so its rows take the body weight and
113
+ not the kit's semibold menu label. #757 */
114
+ .ui-filter-bar__chip .ui-dropdown__label { font-weight: var(--weight-normal); }
112
115
  /* Kit-wide a chosen label steps down to --text, which left the row in force the
113
116
  faintest in the panel. Under the wash it holds --strong. */
114
117
  .ui-filter-bar .ui-dropdown__item.is-selected .ui-dropdown__label { color: var(--strong); }
@@ -305,7 +305,10 @@
305
305
  .ui-card > .ui-table-scroll:has(> .ui-table--dense) {
306
306
  margin-inline: calc(-1 * var(--space-4));
307
307
  }
308
- .ui-card > .ui-table-scroll > .ui-table--dense {
308
+ /* A hover table's 8px row inset came on top of the bleed above, so a dense hover table
309
+ straight in a card started 8px inside the card's text edge. #757 */
310
+ .ui-card > .ui-table-scroll > .ui-table--dense,
311
+ .ui-card > .ui-table--dense.ui-table--hover:not(.ui-table--zebra) {
309
312
  padding-inline: 0;
310
313
  }
311
314
  /* A hover table's row inset plus the frame's 4px band is one --space-3, so the