@apliteni/apliteni-ui 0.167.0 → 0.168.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.
@@ -569,7 +569,8 @@ edge of the panel. A row whose value is a field or a dropdown lines its label up
569
569
  This alignment happens by itself. There is no setting for it.
570
570
  Nothing inside a drawer draws a card, a row rule or an `<hr>`. Actions stay
571
571
  outside the scrolling body. **It moves on open and on close**, and both movements are instant when
572
- reduced motion is enabled. For when a flow should use a drawer or a page:
572
+ reduced motion is enabled. **An Escape a tooltip or a picker already handled closes only that
573
+ overlay, and the next Escape closes the drawer.** For when a flow should use a drawer or a page:
573
574
  [Drawer](../guidelines/drawer.md).
574
575
 
575
576
  ### The modal
@@ -615,6 +616,7 @@ what the bar says. No value may be reachable only by hovering. See
615
616
  React `Tooltip` shows a label, a value and an optional detail.
616
617
  `text` is still a shorthand for `label`. Empty parts are hidden.
617
618
  The focusable trigger provides the readout as its accessible description. Escape keeps focus on the trigger.
619
+ **Escape closes only the readout; the next Escape reaches the dialog around it.**
618
620
  The panel does not change the layout or intercept pointer events.
619
621
 
620
622
  **A pointer opens the readout after it rests for 300ms, and the readout closes at once when the
@@ -976,7 +978,8 @@ A `.ui-table__title` cell gives a text column the remaining width. A column take
976
978
  `title`, `code`, `long`, `strong` or `act`. `rowHeader` renders the column's body cells as `th scope="row"`.
977
979
  `DataTable` takes the vanilla hooks as props: `zebra`, `hover` (on unless `false`), `density`
978
980
  (`dense`, `compact` or `comfortable`),
979
- `stickyHeader` and `pinnedIdentity`. `rowState` marks a row `target` or `dead`, `footer` takes totals rows
981
+ `stickyHeader` and `pinnedIdentity`. **`pinnedIdentity: true` pins column 0; a column key pins that column**,
982
+ so a date can stand before the pinned identity. `rowState` marks a row `target` or `dead`, `footer` takes totals rows
980
983
  and `caption` names the table for assistive technology. A `dead` row is muted and shows its state as a word,
981
984
  with no strike line. `stack` is deprecated and ignored: a phone table scrolls sideways like any other. A table that does not scroll is the card's own child, so a dense table reaches the card's text edge.
982
985
  Its pager follows the measured table width and wraps when necessary.
@@ -1093,7 +1096,9 @@ field and white button on the dark one.
1093
1096
 
1094
1097
  `DatePicker` picks one month, a range of months, one date or a range of dates. At its ordinary
1095
1098
  width, it uses the dropdown's shell and adds only the grid inside it. The panel is a `dialog`,
1096
- because a calendar is a grid and a listbox may own only options. The panel is `inert` while closed.
1099
+ because a calendar is a grid and a listbox may own only options. The panel is `inert` while closed,
1100
+ and a shut panel carries `data-dd-shut`, as a shut Dropdown does. **Escape closes only the calendar,
1101
+ wherever focus is in the picker, and the next Escape closes the dialog around it.**
1097
1102
 
1098
1103
  **The grain and the span are two questions, not one:** `month` and `day` pick a single period.
1099
1104
  `range` and `day-range` pick a start and an end in the same two presses. Periods are ISO strings in
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apliteni/apliteni-ui",
3
- "version": "0.167.0",
3
+ "version": "0.168.0",
4
4
  "workspaces": [
5
5
  "react"
6
6
  ],
@@ -376,7 +376,8 @@ type DataTableProps<T> = {
376
376
  dense?: boolean;
377
377
  density?: 'default' | 'dense' | 'compact' | 'comfortable';
378
378
  stickyHeader?: boolean;
379
- pinnedIdentity?: boolean;
379
+ /** `true` pins column 0. A column key pins that column, so a date can stand before the pinned identity. */
380
+ pinnedIdentity?: boolean | (keyof T & string);
380
381
  scrollLabel?: string;
381
382
  empty?: ReactNode;
382
383
  pageSize?: number;
@@ -527,7 +527,7 @@ function noteClose() {
527
527
  import { useEffect as useEffect2, useId as useId3, useLayoutEffect as useLayoutEffect2, useRef as useRef2, useState as useState3 } from "react";
528
528
  import { Fragment as Fragment3, jsx as jsx11, jsxs as jsxs7 } from "react/jsx-runtime";
529
529
  var DOC_EVENTS = ["pointerdown", "pointercancel", "click", "keydown", "touchend"];
530
- var CAPTURED = /* @__PURE__ */ new Set(["pointerdown", "pointercancel"]);
530
+ var CAPTURED = /* @__PURE__ */ new Set(["pointerdown", "pointercancel", "keydown"]);
531
531
  var wirings = /* @__PURE__ */ new WeakMap();
532
532
  function wireDocument(doc, handlers) {
533
533
  let wiring2 = wirings.get(doc);
@@ -629,7 +629,10 @@ function Tooltip({ text: text2, label = text2, value, detail: detail2, placement
629
629
  ignoreMouseUntil.current = 0;
630
630
  pointerKind.current = "";
631
631
  pendingClick.current = null;
632
- if (event.key === "Escape") close();
632
+ if (event.key === "Escape") {
633
+ if (active.current) event.preventDefault();
634
+ close();
635
+ }
633
636
  };
634
637
  shared.current.touchend = (event) => {
635
638
  if (!host.current?.contains(event.target)) close(true);
@@ -854,8 +857,10 @@ function trapTab(panel, e) {
854
857
  function onKey(e) {
855
858
  const top = stack[stack.length - 1];
856
859
  if (!top) return;
857
- if (e.key === "Escape") top.close();
858
- else if (e.key === "Tab") trapTab(top.panel, e);
860
+ if (e.key === "Escape") {
861
+ if (e.defaultPrevented) return;
862
+ top.close();
863
+ } else if (e.key === "Tab") trapTab(top.panel, e);
859
864
  }
860
865
  function sync() {
861
866
  for (const [el, was] of marked) if (!was) el.removeAttribute("inert");
@@ -2147,6 +2152,7 @@ function Pagination({
2147
2152
  // src/DataTable.tsx
2148
2153
  import { Fragment as Fragment12, jsx as jsx23, jsxs as jsxs19 } from "react/jsx-runtime";
2149
2154
  var CELL_CLASS = { title: "ui-table__title", code: "ui-table__code", long: "ui-table__long", strong: "ui-table__num--strong", act: "ui-table__act" };
2155
+ var pinnedColumn = (pinnedIdentity, key, index) => pinnedIdentity === true ? index === 0 : pinnedIdentity === key;
2150
2156
  var NO_SORT = { key: void 0, dir: -1 };
2151
2157
  function sortTableRows(rows, sort) {
2152
2158
  if (sort.key === void 0) return [...rows];
@@ -2297,7 +2303,7 @@ function DataTable({
2297
2303
  "th",
2298
2304
  {
2299
2305
  scope: "col",
2300
- className: [pinnedIdentity && columnIndex === 0 && "ui-table__identity", c.num && "ui-table__num", c.sortable && "rx-sortable"].filter(Boolean).join(" "),
2306
+ className: [pinnedColumn(pinnedIdentity, c.key, columnIndex) && "ui-table__identity", c.num && "ui-table__num", c.sortable && "rx-sortable"].filter(Boolean).join(" "),
2301
2307
  "aria-sort": sort.key === c.key ? sort.dir === 1 ? "ascending" : "descending" : c.sortable && sortIsKnown ? "none" : void 0,
2302
2308
  children: c.sortable ? (
2303
2309
  // The label is its own box so it can truncate: in a pinned
@@ -2335,7 +2341,7 @@ function DataTable({
2335
2341
  Cell,
2336
2342
  {
2337
2343
  scope: c.rowHeader ? "row" : void 0,
2338
- className: [c.num && "ui-table__num", c.cell && CELL_CLASS[c.cell], pinnedIdentity && columnIndex === 0 && "ui-table__identity", c.linked && "ui-table__linked"].filter(Boolean).join(" ") || void 0,
2344
+ className: [c.num && "ui-table__num", c.cell && CELL_CLASS[c.cell], pinnedColumn(pinnedIdentity, c.key, columnIndex) && "ui-table__identity", c.linked && "ui-table__linked"].filter(Boolean).join(" ") || void 0,
2339
2345
  children: c.render ? c.render(r) : String(r[c.key])
2340
2346
  },
2341
2347
  c.key
@@ -2466,7 +2472,7 @@ import {
2466
2472
  useRef as useRef14,
2467
2473
  useState as useState11
2468
2474
  } from "react";
2469
- import { dropdownViewportFit } from "@apliteni/apliteni-ui";
2475
+ import { dropdownRest, dropdownViewportFit } from "@apliteni/apliteni-ui";
2470
2476
  import { jsx as jsx25, jsxs as jsxs21 } from "react/jsx-runtime";
2471
2477
  var cx5 = (...a) => a.filter(Boolean).join(" ");
2472
2478
  var pad = (n) => String(n).padStart(2, "0");
@@ -2652,18 +2658,16 @@ function DatePicker({
2652
2658
  const onClick = (e) => {
2653
2659
  if (!root.current?.contains(e.target)) close.current(false);
2654
2660
  };
2655
- const onKey2 = (e) => {
2656
- if (e.key !== "Escape") return;
2657
- close.current(false);
2658
- trigger.current?.focus();
2659
- };
2660
2661
  doc.addEventListener("click", onClick);
2661
- doc.addEventListener("keydown", onKey2);
2662
2662
  return () => {
2663
2663
  doc.removeEventListener("click", onClick);
2664
- doc.removeEventListener("keydown", onKey2);
2665
2664
  };
2666
2665
  }, [open]);
2666
+ useIsoLayoutEffect(() => {
2667
+ const el = panel.current;
2668
+ if (!el || !root.current) return void 0;
2669
+ return dropdownRest(root.current, el, open);
2670
+ }, [open, asSheet]);
2667
2671
  useIsoLayoutEffect(() => {
2668
2672
  if (!open || !land.current) return;
2669
2673
  land.current = false;
@@ -2908,49 +2912,62 @@ function DatePicker({
2908
2912
  // `open` on the root whichever form the panel takes, so the trigger's
2909
2913
  // chevron flips for the sheet as it does for the popover. The panel rules
2910
2914
  // it also switches on have no panel to find while the sheet is up.
2911
- /* @__PURE__ */ jsxs21("div", { className: cx5("ui-dropdown", "ui-datepicker", open && "open"), ref: root, children: [
2912
- /* @__PURE__ */ jsxs21(
2913
- "button",
2914
- {
2915
- type: "button",
2916
- className: "ui-dropdown__trigger ui-datepicker__trigger",
2917
- id,
2918
- "aria-haspopup": "dialog",
2919
- "aria-expanded": open,
2920
- "aria-label": ariaLabel || void 0,
2921
- disabled,
2922
- ref: trigger,
2923
- onClick: (e) => {
2924
- e.stopPropagation();
2925
- setOpen(!open);
2926
- },
2927
- children: [
2928
- /* @__PURE__ */ jsx25("span", { className: "ui-dropdown__value", children: shown ?? empty }),
2929
- /* @__PURE__ */ jsx25("span", { className: "ui-dropdown__chevron", "aria-hidden": "true" })
2930
- ]
2931
- }
2932
- ),
2933
- asSheet ? (
2934
- // A sheet is the kit's drawer, not a wide popover: the scrim, the close
2935
- // control, the focus trap, the inert page behind it and the restored
2936
- // focus all come from <Drawer>, because changing the FORM of the panel
2937
- // without taking the sheet's affordances left a phone reader with no
2938
- // visible way out and a Tab that walked into the live page behind it.
2939
- // why: guidelines/drawer.md
2940
- /* @__PURE__ */ jsx25(Drawer, { open, side: "bottom", size: "md", title: name, onClose: () => setOpen(false), children: calendar })
2941
- ) : /* @__PURE__ */ jsx25(
2942
- "div",
2943
- {
2944
- className: cx5("ui-dropdown__panel", "ui-datepicker__panel", align === "end" && "is-end"),
2945
- ref: panel,
2946
- role: "dialog",
2947
- "aria-label": name,
2948
- inert: !open,
2949
- onClick: (e) => e.stopPropagation(),
2950
- children: calendar
2951
- }
2952
- )
2953
- ] })
2915
+ /* @__PURE__ */ jsxs21(
2916
+ "div",
2917
+ {
2918
+ className: cx5("ui-dropdown", "ui-datepicker", open && "open"),
2919
+ ref: root,
2920
+ onKeyDown: (e) => {
2921
+ if (asSheet || !open || e.key !== "Escape") return;
2922
+ e.preventDefault();
2923
+ close.current(false);
2924
+ trigger.current?.focus();
2925
+ },
2926
+ children: [
2927
+ /* @__PURE__ */ jsxs21(
2928
+ "button",
2929
+ {
2930
+ type: "button",
2931
+ className: "ui-dropdown__trigger ui-datepicker__trigger",
2932
+ id,
2933
+ "aria-haspopup": "dialog",
2934
+ "aria-expanded": open,
2935
+ "aria-label": ariaLabel || void 0,
2936
+ disabled,
2937
+ ref: trigger,
2938
+ onClick: (e) => {
2939
+ e.stopPropagation();
2940
+ setOpen(!open);
2941
+ },
2942
+ children: [
2943
+ /* @__PURE__ */ jsx25("span", { className: "ui-dropdown__value", children: shown ?? empty }),
2944
+ /* @__PURE__ */ jsx25("span", { className: "ui-dropdown__chevron", "aria-hidden": "true" })
2945
+ ]
2946
+ }
2947
+ ),
2948
+ asSheet ? (
2949
+ // A sheet is the kit's drawer, not a wide popover: the scrim, the close
2950
+ // control, the focus trap, the inert page behind it and the restored
2951
+ // focus all come from <Drawer>, because changing the FORM of the panel
2952
+ // without taking the sheet's affordances left a phone reader with no
2953
+ // visible way out and a Tab that walked into the live page behind it.
2954
+ // why: guidelines/drawer.md
2955
+ /* @__PURE__ */ jsx25(Drawer, { open, side: "bottom", size: "md", title: name, onClose: () => setOpen(false), children: calendar })
2956
+ ) : /* @__PURE__ */ jsx25(
2957
+ "div",
2958
+ {
2959
+ className: cx5("ui-dropdown__panel", "ui-datepicker__panel", align === "end" && "is-end"),
2960
+ ref: panel,
2961
+ role: "dialog",
2962
+ "aria-label": name,
2963
+ inert: !open,
2964
+ onClick: (e) => e.stopPropagation(),
2965
+ children: calendar
2966
+ }
2967
+ )
2968
+ ]
2969
+ }
2970
+ )
2954
2971
  );
2955
2972
  }
2956
2973
 
@@ -2974,7 +2991,7 @@ import {
2974
2991
  dropdownHeightFit,
2975
2992
  dropdownLift,
2976
2993
  dropdownReveal,
2977
- dropdownRest,
2994
+ dropdownRest as dropdownRest2,
2978
2995
  dropdownSnap,
2979
2996
  filterPanelRow
2980
2997
  } from "@apliteni/apliteni-ui";
@@ -3218,7 +3235,7 @@ function Dropdown({
3218
3235
  useIsoLayoutEffect(() => {
3219
3236
  const el = panel.current;
3220
3237
  if (!el || !root.current) return void 0;
3221
- return dropdownRest(root.current, el, open);
3238
+ return dropdownRest2(root.current, el, open);
3222
3239
  }, [open]);
3223
3240
  useIsoLayoutEffect(() => {
3224
3241
  const dd = root.current;
@@ -488,7 +488,7 @@ a.ui-identity:hover { text-decoration: underline; }
488
488
  /* One width reserves the selection track and offsets the adjacent identity. */
489
489
  .ui-table--pinned { --ui-table-selection-width: var(--space-12); --ui-table-identity-max: min(var(--panel-sm), 50vw); }
490
490
  .ui-table--pinned .ui-table__selection { box-sizing: border-box; width: var(--ui-table-selection-width); min-width: var(--ui-table-selection-width); max-width: var(--ui-table-selection-width); padding-inline: 0; text-align: center; }
491
- .ui-table--pinned .ui-table__selection + .ui-table__identity { left: var(--ui-table-selection-width); }
491
+ .ui-table--pinned .ui-table__selection ~ .ui-table__identity { left: var(--ui-table-selection-width); }
492
492
 
493
493
  /* ============================================================================
494
494
  * Running text in a cell — .ui-table__long