@softure-ai/theme-notion 0.31.0 → 0.33.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/CHANGELOG.md CHANGED
@@ -4,6 +4,39 @@ Newest first. Each version lists what changed for an app that uses the theme. Wh
4
4
  production, the version gets a line `verified in: <app>@<commit>` ([docs/05](../../docs/05-adoption-playbook.md),
5
5
  "Definition of done").
6
6
 
7
+ ## 0.33.0
8
+
9
+ - `DialogContent` and `SheetContent` (#1476): on open they focus the first form field (`input` other than hidden,
10
+ `select`, `textarea`, `[role=combobox]`, not disabled) instead of the first focusable element, so a dialog whose
11
+ first focusable is a help `TooltipTrigger` opens with no tooltip over the form. With no field Radix's default focus
12
+ stays; an app's own `onOpenAutoFocus` runs first and keeps control when it prevents the default.
13
+ - Migration: an app that focused the first field itself in `onOpenAutoFocus` (to keep a tooltip shut) drops the
14
+ handler.
15
+ - `TabBar` (#1477): when the tabs overflow the strip (a phone), the strip scrolls itself, never the page, so the
16
+ current tab is whole on load (a deep link to a late tab) and whenever `current` changes, with a fade's width of room
17
+ so no fade covers it; nothing moves when it is already in view. Each edge that hides tabs fades out (a static 32 px
18
+ mask) and is marked on the nav with `data-overflow-start` / `data-overflow-end`, so a tab cut at the edge reads as a
19
+ scrollable list. `TabBar` is now a client component; its props are unchanged.
20
+ - Migration: an app that scrolled the current tab into view itself, or drew its own edge fade, drops that code.
21
+
22
+ ## 0.32.0
23
+
24
+ - `FoldRow` (#1463): the bar and its opened content share one 8 px horizontal inset. The summary is padded `px-2`
25
+ (was `px-1`), the opened content `px-2 py-3` (was `p-3`), so the chevron and the details table start at the same x;
26
+ the actions keep the same inset on the bar's right (`pr-2`, was `pr-1`). `isInset` content starts under the title
27
+ at the new inset (`py-2 pr-2 pl-8`, was `py-2 pr-1 pl-6`).
28
+ - Migration: an app that aligned the row itself
29
+ (`[&_[data-slot=fold-row-summary]]:px-2 [&_[data-slot=fold-row-content]]:px-2` on the row) drops the override.
30
+ - `FoldRow` (#1471): the right column of a row with `actions` spans the summary's full height and lights with it as one
31
+ box, open or hovered, however many lines the summary wraps to (it used to stop under the control). A new `status`
32
+ prop draws a status above the actions in that column (`data-slot="fold-row-status"`; a status alone draws the
33
+ column too); the actions sit in `data-slot="fold-row-action-list"`. Below `md` the column falls under the summary
34
+ and each action is at least 44 px. With a column, the row is a grid and the opened content is the details' sibling
35
+ under the whole bar (shown while the row is open), so find-in-page no longer opens a closed row with actions.
36
+ - Migration: an app that wrapped `FoldRow` to put a status above its action and light both as one box passes
37
+ `status` and `actions` instead and drops the wrapper. Selectors that looked for `fold-row-content` inside the
38
+ `<details>` of a row with actions look in `fold-row-with-actions` instead.
39
+
7
40
  ## 0.31.0
8
41
 
9
42
  - `PageLayout`: a screen inside the app shell, its `PageHeader` (the `header` prop takes the same props) and then its
package/README.md CHANGED
@@ -116,6 +116,10 @@ name outside a `CommandDialog`; without it the field has none), `SortableList in
116
116
  edge, so put content padding on its children (`SheetHeader`, `SheetFooter`, an inner `div`). An app pads its own
117
117
  screen roots with the same classes: `pt-[env(safe-area-inset-top)]`, `pb-[env(safe-area-inset-bottom)]`,
118
118
  `pl-[env(safe-area-inset-left)]`, `pr-[env(safe-area-inset-right)]`.
119
+ - `DialogContent` and `SheetContent` focus their first form field on open (`input`, `select`, `textarea` or a
120
+ `combobox`, not disabled), not the first focusable element, so a help `TooltipTrigger` beside a label does not open
121
+ its tooltip over the form. With no field Radix's default focus stays; an app's `onOpenAutoFocus` runs first and
122
+ keeps control when it calls `event.preventDefault()`. Tab onto the trigger still shows the tooltip.
119
123
  - Figures, bar segments and box edges take a **tone** by what they mean: `default` (text colour), `success` (green,
120
124
  done), `warning` (orange, to do), `danger` (red, owed or failing), `muted` (gray, out of play). `TONE_COLORS` gives
121
125
  a tone's palette colour (`null` for `default`); `TONE_TEXT`, `TONE_FILL` and `TONE_EDGE` give literal class names
@@ -171,7 +175,9 @@ and zoom; one row per document with its type, size and an "available offline" ma
171
175
  (`DropdownMenuContent size="touch"`, or `size="touch"` on a `DropdownMenuItem`, `DropdownMenuCheckboxItem`,
172
176
  `DropdownMenuRadioItem` or `DropdownMenuSubTrigger`) and the tabs (`TabsList size="touch"` grows to its triggers,
173
177
  each at least 44 × 44, or `TabsTrigger size="touch"`). `TabBar size="touch"` draws every tab link at least 44 × 44 (`data-size="touch"`), and its
174
- `tabClassName` goes on every link after the size (`tabClassName="md:h-control-height md:min-w-0"` on a desktop). `Switch size="touch"` is a 44 × 44 square that draws the same 26 × 16 track
178
+ `tabClassName` goes on every link after the size (`tabClassName="md:h-control-height md:min-w-0"` on a desktop). When its tabs overflow the strip (a phone), `TabBar` scrolls the strip itself, never the page, so the current tab is
179
+ whole on load and whenever `current` changes, and fades each edge that hides tabs (`data-overflow-start`,
180
+ `data-overflow-end` on the nav, a static 32 px mask, so nothing moves under reduced motion). `Switch size="touch"` is a 44 × 44 square that draws the same 26 × 16 track
175
181
  inside it and keeps the track's place in the layout (negative margins), so a phone taps the whole square; `className="md:m-0
176
182
  md:h-4 md:w-[26px]"` brings the plain switch back on a desktop. `AccordionTrigger size="touch"` is at least 44 px high
177
183
  whatever its padding, and `DialogContent closeButtonSize="touch"` draws the close button 44 × 44 around the same
@@ -213,16 +219,19 @@ is `min-w-0`, so a wide table scrolls inside its card instead of widening the pa
213
219
  ```
214
220
 
215
221
  **`FoldRow`.** An item as one list row in a native `<details>`: a chevron, the title, short facts and badges on the
216
- right; opened, it shows a `DetailTable` and its `children`. The opened content is padded 12 px on all four sides
217
- (`p-3`), so a table sits centred under the row; `isInset` indents it under the title instead (24 px on the left) and
218
- sets `data-inset` on the content, like `StatsFold`. A row with a summary of its own (icons, a status) passes `summary`,
222
+ right; opened, it shows a `DetailTable` and its `children`. The bar and the opened content share one 8 px
223
+ horizontal inset (`px-2`; the content is padded 12 px top and bottom, `py-3`), so the table starts under the chevron;
224
+ `isInset` indents it under the title instead (32 px on the left) and sets `data-inset` on the content, like
225
+ `StatsFold`. A row with a summary of its own (icons, a status) passes `summary`,
219
226
  drawn after the chevron in place of `title`, `facts` and `badges`; `details` and `detailsLabel` are optional together,
220
227
  so the content can be several tables or a list. `size="touch"` makes the summary at least the `touch-target` height
221
- (44 px) instead of the row height, for a phone list. `actions` puts controls on the row's right (a delete button,
222
- a menu), beside the `<details>` rather than inside its `<summary>`, so clicking one never folds the row; they show
223
- whether the row is open or closed, centred on the summary's first line. They sit at the right end of the row's bar:
224
- the summary's background runs under them when the row is open or hovered, so the bar reads as one. The row's bottom
225
- border moves to the wrapper (`data-slot="fold-row-with-actions"`). `isOpenInitially` renders the row open (`<details open>`), for the row the
228
+ (44 px) instead of the row height, for a phone list. `actions` puts controls in a right column of the row's bar (a
229
+ delete button, a menu), beside the `<details>` rather than inside its `<summary>`, so clicking one never folds the row;
230
+ `status` puts the item's status above them in the same column. The column spans the summary's full height however
231
+ many lines it wraps to, and the summary and the column light as one box when the row is open or hovered. Below `md`
232
+ the column falls under the summary and each action is at least 44 px. With a column the row is a grid
233
+ (`data-slot="fold-row-with-actions"`, which carries the bottom border) and the opened content sits under the whole bar
234
+ as the details' sibling, shown while it is open. `isOpenInitially` renders the row open (`<details open>`), for the row the
226
235
  address points at; only the first render reads it, and the reader can still fold the row.
227
236
 
228
237
  ```tsx
@@ -230,7 +239,7 @@ address points at; only the first render reads it, and the reader can still fold
230
239
  <FoldRow summary={<><Receipt aria-hidden="true" className="size-4" /> Invoice 12/2026 <Badge>Paid</Badge></>}>
231
240
  <InvoiceLines />
232
241
  </FoldRow>
233
- <FoldRow title="clip.mp4" badges={[]} actions={<DeleteButton />} />
242
+ <FoldRow title="clip.mp4" badges={[]} status={<Status color="green">Paid</Status>} actions={<DeleteButton />} />
234
243
  ```
235
244
 
236
245
  **`FilterChip`.** The filters above a list or a table, drawn the way a Notion database view draws them: a 24 px pill
@@ -0,0 +1,7 @@
1
+ /**
2
+ * An `onOpenAutoFocus` handler for a Radix dialog or sheet content: it runs the app's own handler first, then, unless
3
+ * that prevented the default, focuses the first form field inside the content instead of the first focusable element.
4
+ * With no field, Radix's default focus stays.
5
+ */
6
+ export declare function withFirstFieldFocus(onOpenAutoFocus: ((event: Event) => void) | undefined): (event: Event) => void;
7
+ //# sourceMappingURL=focus-first-field.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"focus-first-field.d.ts","sourceRoot":"","sources":["../../src/lib/focus-first-field.ts"],"names":[],"mappings":"AAsBA;;;;GAIG;AACH,wBAAgB,mBAAmB,CACjC,eAAe,EAAE,CAAC,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC,GAAG,SAAS,GACpD,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CASxB"}
@@ -0,0 +1,39 @@
1
+ // The form controls a dialog or sheet focuses on open, ahead of any button before them (a tooltip trigger beside a
2
+ // label opens its tooltip on focus, #1476).
3
+ const FIELD_SELECTOR = [
4
+ 'input:not([type="hidden"]):not(:disabled)',
5
+ "select:not(:disabled)",
6
+ "textarea:not(:disabled)",
7
+ '[role="combobox"]:not(:disabled):not([aria-disabled="true"])',
8
+ ].join(", ");
9
+ function findFirstField(container) {
10
+ for (const candidate of container.querySelectorAll(FIELD_SELECTOR)) {
11
+ if (candidate.closest("[hidden], [inert]") === null)
12
+ return candidate;
13
+ }
14
+ return null;
15
+ }
16
+ function focusField(field) {
17
+ field.focus({ preventScroll: true });
18
+ // Selected as Radix selects the first text input it focuses.
19
+ if (field instanceof HTMLInputElement && document.activeElement === field)
20
+ field.select();
21
+ }
22
+ /**
23
+ * An `onOpenAutoFocus` handler for a Radix dialog or sheet content: it runs the app's own handler first, then, unless
24
+ * that prevented the default, focuses the first form field inside the content instead of the first focusable element.
25
+ * With no field, Radix's default focus stays.
26
+ */
27
+ export function withFirstFieldFocus(onOpenAutoFocus) {
28
+ return (event) => {
29
+ onOpenAutoFocus?.(event);
30
+ if (event.defaultPrevented || !(event.currentTarget instanceof Element))
31
+ return;
32
+ const field = findFirstField(event.currentTarget);
33
+ if (field === null)
34
+ return;
35
+ event.preventDefault();
36
+ focusField(field);
37
+ };
38
+ }
39
+ //# sourceMappingURL=focus-first-field.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"focus-first-field.js","sourceRoot":"","sources":["../../src/lib/focus-first-field.ts"],"names":[],"mappings":"AAAA,mHAAmH;AACnH,4CAA4C;AAC5C,MAAM,cAAc,GAAG;IACrB,2CAA2C;IAC3C,uBAAuB;IACvB,yBAAyB;IACzB,8DAA8D;CAC/D,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AAEZ,SAAS,cAAc,CAAC,SAAkB;IACxC,KAAK,MAAM,SAAS,IAAI,SAAS,CAAC,gBAAgB,CAAc,cAAc,CAAC,EAAE,CAAC;QAChF,IAAI,SAAS,CAAC,OAAO,CAAC,mBAAmB,CAAC,KAAK,IAAI;YAAE,OAAO,SAAS,CAAA;IACvE,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC;AAED,SAAS,UAAU,CAAC,KAAkB;IACpC,KAAK,CAAC,KAAK,CAAC,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAA;IACpC,6DAA6D;IAC7D,IAAI,KAAK,YAAY,gBAAgB,IAAI,QAAQ,CAAC,aAAa,KAAK,KAAK;QAAE,KAAK,CAAC,MAAM,EAAE,CAAA;AAC3F,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CACjC,eAAqD;IAErD,OAAO,CAAC,KAAK,EAAE,EAAE;QACf,eAAe,EAAE,CAAC,KAAK,CAAC,CAAA;QACxB,IAAI,KAAK,CAAC,gBAAgB,IAAI,CAAC,CAAC,KAAK,CAAC,aAAa,YAAY,OAAO,CAAC;YAAE,OAAM;QAC/E,MAAM,KAAK,GAAG,cAAc,CAAC,KAAK,CAAC,aAAa,CAAC,CAAA;QACjD,IAAI,KAAK,KAAK,IAAI;YAAE,OAAM;QAC1B,KAAK,CAAC,cAAc,EAAE,CAAA;QACtB,UAAU,CAAC,KAAK,CAAC,CAAA;IACnB,CAAC,CAAA;AACH,CAAC"}
@@ -32,7 +32,7 @@ export type FoldRowDetailsProps = {
32
32
  readonly details?: never;
33
33
  };
34
34
  export type FoldRowProps = FoldRowSummaryProps & FoldRowDetailsProps & {
35
- /** Indents the opened content to line up with the title after the chevron; by default it is padded equally. */
35
+ /** Indents the opened content to line up with the title after the chevron; by default it starts under the chevron. */
36
36
  readonly isInset?: boolean;
37
37
  /** `touch` makes the summary at least the touch target high (44 px) instead of the row height. */
38
38
  readonly size?: "default" | "touch";
@@ -44,11 +44,14 @@ export type FoldRowProps = FoldRowSummaryProps & FoldRowDetailsProps & {
44
44
  */
45
45
  readonly isOpenInitially?: boolean;
46
46
  /**
47
- * Controls at the right end of the row's bar (a delete button, a menu). They sit beside the `<summary>`, not in
48
- * it, so clicking them never folds the row, but they share its background: the bar runs under them when the row
49
- * is open or hovered. Shown whether the row is open or closed, centred on the summary's first line.
47
+ * Controls in the right column of the row's bar (a delete button, a menu). The column sits beside the `<summary>`,
48
+ * not in it, so clicking a control never folds the row; it spans the summary's full height and lights with it when
49
+ * the row is open or hovered, so the bar reads as one box. On a phone (below `md`) the column falls under the
50
+ * summary and each control is at least the touch target (44 px).
50
51
  */
51
52
  readonly actions?: ReactNode;
53
+ /** The item's status, drawn in the same column above the actions (with no actions, the column holds only it). */
54
+ readonly status?: ReactNode;
52
55
  };
53
56
  export declare function FoldRow(props: FoldRowProps): import("react").JSX.Element;
54
57
  //# sourceMappingURL=FoldRow.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"FoldRow.d.ts","sourceRoot":"","sources":["../../src/notion/FoldRow.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAKvC,OAAO,EAAe,KAAK,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE/D,OAAO,EAAe,KAAK,IAAI,EAAE,MAAM,YAAY,CAAC;AAEpD,MAAM,WAAW,YAAY;IAC3B,gEAAgE;IAChE,QAAQ,CA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AAC,OAAO,EAAE,SAAS,SAAS,EAAE,CAAC;CACxC,GACD;IACE,QAAQ,CAAC,YAAY,CAAC,EAAE,KAAK,CAAC;IAC9B,QAAQ,CAAC,OAAO,CAAC,EAAE,KAAK,CAAC;CAC1B,CAAC;AAEN,MAAM,MAAM,YAAY,GAAG,mBAAmB,GAC5C,mBAAmB,GAAG;IACpB,sHAAsH;IACtH,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAC3B,kGAAkG;IAClG,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,GAAG,OAAO,CAAC;IACpC,gDAAgD;IAChD,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,CAAC;IAC9B;;;OAGG;IACH,QAAQ,CAAC,eAAe,CAAC,EAAE,OAAO,CAAC;IACnC;;;;;OAKG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,CAAC;IAC7B,iHAAiH;IACjH,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,CAAC;CAC7B,CAAC;AAkEJ,wBAAgB,OAAO,CAAC,KAAK,EAAE,YAAY,+BAiD1C"}
@@ -5,8 +5,10 @@ import { Badge } from "../ui/badge.js";
5
5
  import { DetailTable } from "./DetailTable.js";
6
6
  import { ICON_STROKE_WIDTH } from "./icon-stroke.js";
7
7
  import { TONE_COLORS } from "./tones.js";
8
- const CONTENT_CLASS = "flex flex-col gap-2 p-3 empty:hidden";
9
- const INSET_CONTENT_CLASS = "flex flex-col gap-2 py-2 pr-1 pl-6 empty:hidden";
8
+ // The bar and its opened content share one 8 px horizontal inset, so the details start under the chevron; the inset
9
+ // variant starts under the title instead (8 px inset, 16 px chevron, 8 px gap).
10
+ const CONTENT_LAYOUT = "flex-col gap-2 px-2 py-3";
11
+ const INSET_CONTENT_LAYOUT = "flex-col gap-2 py-2 pr-2 pl-8";
10
12
  function FoldRowFixedSummary({ title, facts = [], badges, }) {
11
13
  return (_jsxs(_Fragment, { children: [_jsxs("span", { "data-slot": "fold-row-heading", className: "flex min-w-0 items-center gap-2", children: [_jsx(FoldRowChevron, {}), _jsx("span", { className: "min-w-0 text-ui-medium", children: title })] }), facts.map((fact, index) => (_jsx("span", { "data-slot": "fold-row-fact", className: "text-ui text-muted-foreground", children: fact }, index))), badges.length === 0 ? null : (_jsx("span", { "data-slot": "fold-row-badges", className: "ml-auto inline-flex flex-wrap gap-1", children: badges.map((badge) => {
12
14
  const tone = badge.tone ?? "default";
@@ -16,21 +18,27 @@ function FoldRowFixedSummary({ title, facts = [], badges, }) {
16
18
  function FoldRowChevron() {
17
19
  return (_jsx(ChevronRight, { "aria-hidden": "true", strokeWidth: ICON_STROKE_WIDTH, className: "size-4 shrink-0 text-muted-foreground transition-transform duration-150 group-open/fold-row:rotate-90" }));
18
20
  }
21
+ function isDrawn(node) {
22
+ return node !== undefined && node !== null;
23
+ }
19
24
  // An item as one folding list row: a native `<details>` that opens in place to its details, with no client state.
20
25
  export function FoldRow(props) {
21
- const { actions, size = "default" } = props;
22
- if (actions === undefined || actions === null) {
23
- return _jsx(FoldRowDetails, { ...props, className: "border-b border-border" });
26
+ const { actions, status, isInset = false } = props;
27
+ if (!isDrawn(actions) && !isDrawn(status)) {
28
+ return (_jsx(FoldRowDetails, { ...props, className: "border-b border-border", content: _jsx(FoldRowContent, { ...props, className: cn("flex", isInset ? INSET_CONTENT_LAYOUT : CONTENT_LAYOUT, "empty:hidden") }) }));
24
29
  }
25
- // The actions sit beside the `<details>`, not in its `<summary>`: a control inside the summary would fold the row.
26
- // They carry the summary's background (the details is their peer: open; the wrapper is the hover group), so the
27
- // summary and the actions read as one bar with the controls at its right end.
28
- return (_jsxs("div", { "data-slot": "fold-row-with-actions", className: "group/fold-row-with-actions flex items-start border-b border-border", children: [_jsx(FoldRowDetails, { ...props, className: "peer/fold-row min-w-0 flex-1", hasActions: true }), _jsx("div", { "data-slot": "fold-row-actions", className: cn("flex shrink-0 items-center gap-1 rounded-r-md pr-1 transition-colors duration-120 group-hover/fold-row-with-actions:bg-accent peer-open/fold-row:bg-accent", size === "touch" ? "min-h-touch-target" : "min-h-row-height"), children: actions })] }));
30
+ // The right column sits beside the `<details>`, not in its `<summary>`: a control inside the summary would fold the
31
+ // row. To make the column exactly as high as the summary, the `<details>` holds only its summary and shares a grid
32
+ // row with the column (grid items stretch to their row); the opened content is the next row, shown while the
33
+ // details is open (`peer-open`). The details and the column carry the bar's light together, so they read as one box.
34
+ return (_jsxs("div", { "data-slot": "fold-row-with-actions", className: "group/fold-row-with-actions grid grid-cols-1 border-b border-border md:grid-cols-[minmax(0,1fr)_auto]", children: [_jsx(FoldRowDetails, { ...props, className: "peer/fold-row min-w-0 rounded-md transition-colors duration-120 group-hover/fold-row-with-actions:bg-accent open:bg-accent max-md:rounded-b-none md:rounded-r-none", isLitByRow: true }), _jsxs("div", { "data-slot": "fold-row-actions", className: "flex flex-wrap items-center gap-2 rounded-b-md pr-2 pb-1 pl-8 transition-colors duration-120 group-hover/fold-row-with-actions:bg-accent peer-open/fold-row:bg-accent md:flex-col md:flex-nowrap md:items-end md:justify-center md:gap-1 md:rounded-b-none md:rounded-r-md md:py-1 md:pl-0", children: [isDrawn(status) ? (_jsx("div", { "data-slot": "fold-row-status", className: "flex items-center", children: status })) : null, isDrawn(actions) ? (_jsx("div", { "data-slot": "fold-row-action-list", className: "flex items-center gap-1 max-md:*:min-h-touch-target max-md:*:min-w-touch-target", children: actions })) : null] }), _jsx(FoldRowContent, { ...props, className: cn("col-span-full hidden", isInset ? INSET_CONTENT_LAYOUT : CONTENT_LAYOUT, "peer-open/fold-row:not-empty:flex") })] }));
35
+ }
36
+ function FoldRowContent(props) {
37
+ const { isInset = false, children, className } = props;
38
+ return (_jsxs("div", { "data-slot": "fold-row-content", "data-inset": isInset, className: className, children: [props.details === undefined ? null : _jsx(DetailTable, { label: props.detailsLabel, rows: props.details }), children] }));
29
39
  }
30
40
  function FoldRowDetails(props) {
31
- const { isInset = false, isOpenInitially = false, size = "default", children, className, hasActions = false } = props;
32
- return (_jsxs("details", { "data-slot": "fold-row", open: isOpenInitially || undefined, className: cn("group/fold-row", className), children: [_jsx("summary", { "data-slot": "fold-row-summary", className: cn("flex cursor-pointer list-none flex-wrap items-center gap-x-2 gap-y-1 rounded-md px-1 py-1 transition-colors duration-120 group-open/fold-row:bg-accent hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none [&::-webkit-details-marker]:hidden", size === "touch" ? "min-h-touch-target" : "min-h-row-height",
33
- // With actions the bar continues under them: no rounding on the right, and hovering them lights it too.
34
- hasActions && "rounded-r-none group-hover/fold-row-with-actions:bg-accent"), children: props.summary === undefined ? (_jsx(FoldRowFixedSummary, { title: props.title, facts: props.facts, badges: props.badges ?? [] })) : (_jsxs(_Fragment, { children: [_jsx(FoldRowChevron, {}), _jsx("span", { "data-slot": "fold-row-summary-slot", className: "flex min-w-0 flex-1 flex-wrap items-center gap-x-2 gap-y-1", children: props.summary })] })) }), _jsxs("div", { "data-slot": "fold-row-content", "data-inset": isInset, className: isInset ? INSET_CONTENT_CLASS : CONTENT_CLASS, children: [props.details === undefined ? null : _jsx(DetailTable, { label: props.detailsLabel, rows: props.details }), children] })] }));
41
+ const { isOpenInitially = false, size = "default", className, isLitByRow = false, content } = props;
42
+ return (_jsxs("details", { "data-slot": "fold-row", open: isOpenInitially || undefined, className: cn("group/fold-row", className), children: [_jsx("summary", { "data-slot": "fold-row-summary", className: cn("flex cursor-pointer list-none flex-wrap items-center gap-x-2 gap-y-1 rounded-md px-2 py-1", !isLitByRow && "transition-colors duration-120 group-open/fold-row:bg-accent hover:bg-accent", "focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none [&::-webkit-details-marker]:hidden", size === "touch" ? "min-h-touch-target" : "min-h-row-height"), children: props.summary === undefined ? (_jsx(FoldRowFixedSummary, { title: props.title, facts: props.facts, badges: props.badges ?? [] })) : (_jsxs(_Fragment, { children: [_jsx(FoldRowChevron, {}), _jsx("span", { "data-slot": "fold-row-summary-slot", className: "flex min-w-0 flex-1 flex-wrap items-center gap-x-2 gap-y-1", children: props.summary })] })) }), content] }));
35
43
  }
36
44
  //# sourceMappingURL=FoldRow.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"FoldRow.js","sourceRoot":"","sources":["../../src/notion/FoldRow.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAG5C,OAAO,EAAE,EAAE,EAAE,MAAM,iBAAiB,CAAC;AACrC,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAEvC,OAAO,EAAE,WAAW,EAAkB,MAAM,kBAAkB,CAAC;AAC/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAa,MAAM,YAAY,CAAC;AA4DpD,MAAM,aAAa,GAAG,sCAAsC,CAAC;AAC7D,MAAM,mBAAmB,GAAG,iDAAiD,CAAC;AAE9E,SAAS,mBAAmB,CAAC,EAC3B,KAAK,EACL,KAAK,GAAG,EAAE,EACV,MAAM,GAKP;IACC,OAAO,CACL,8BAEE,6BAAgB,kBAAkB,EAAC,SAAS,EAAC,iCAAiC,aAC5E,KAAC,cAAc,KAAG,EAClB,eAAM,SAAS,EAAC,wBAAwB,YAAE,KAAK,GAAQ,IAClD,EACN,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,CAE1B,4BAA4B,eAAe,EAAC,SAAS,EAAC,+BAA+B,YAClF,IAAI,IADI,KAAK,CAET,CACR,CAAC,EACD,MAAM,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAC5B,4BAAgB,iBAAiB,EAAC,SAAS,EAAC,qCAAqC,YAC9E,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;oBACpB,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,IAAI,SAAS,CAAC;oBACrC,OAAO,CACL,KAA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,KAAG,EAClB,4BACY,uBAAuB,EACjC,SAAS,EAAC,4DAA4D,YAErE,KAAK,CAAC,OAAO,GACT,IACN,CACJ,GACO,EACT,OAAO,IACA,CACX,CAAC;AACJ,CAAC"}
@@ -1,4 +1,4 @@
1
- import type { ReactNode } from "react";
1
+ import { type ReactNode } from "react";
2
2
  export interface TabBarItem<Key extends string> {
3
3
  readonly key: Key;
4
4
  readonly label: string;
@@ -1 +1 @@
1
- {"version":3,"file":"TabBar.d.ts","sourceRoot":"","sources":["../../src/notion/TabBar.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAIvC,MAAM,WAAW,UAAU,CAAC,GAAG,SAAS,MAAM;IAE5C,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC;IAClB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,CAAC;IAE1B,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,WAAW,CAAC,GAAG,SAAS,MAAM;IAE7C,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,SAAS,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;IAC1C,QAAQ,CAAC,OAAO,EAAE,GAAG,CAAC;IAEtB,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,GAAG,OAAO,CAAC;IAGpC,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;CAChC;AAQD,wBAAgB,MAAM,CAAC,GAAG,SAAS,MAAM,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,IAAgB,EAAE,YAAY,EAAE,EAAE,WAAW,CAAC,GAAG,CAAC,+BA2BpH"}
1
+ {"version":3,"file":"TabBar.d.ts","sourceRoot":"","sources":["../../src/notion/TabBar.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAqB,KAAK,SAAS,EAAkB,MAAM,OAAO,CAAC;AAI1E,MAAM,WAAW,UAAU,CAAC,GAAG,SAAS,MAAM;IAE5C,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC;IAClB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,CAAC;IAE1B,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,WAAW,CAAC,GAAG,SAAS,MAAM;IAE7C,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,SAAS,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;IAC1C,QAAQ,CAAC,OAAO,EAAE,GAAG,CAAC;IAEtB,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,GAAG,OAAO,CAAC;IAGpC,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;CAChC;AAwDD,wBAAgB,MAAM,CAAC,GAAG,SAAS,MAAM,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,IAAgB,EAAE,YAAY,EAAE,EAAE,WAAW,CAAC,GAAG,CAAC,+BA6BpH"}
@@ -1,10 +1,60 @@
1
+ "use client";
1
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useEffect, useRef } from "react";
2
4
  import { cn } from "../lib/utils.js";
3
5
  const TAB_CLASS = "relative inline-flex h-control-height items-center gap-1.5 rounded-md px-2 text-ui-medium whitespace-nowrap text-muted-foreground transition-colors duration-120 after:absolute after:inset-x-0 after:-bottom-1 after:h-0.5 after:bg-foreground after:opacity-0 hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none aria-[current=page]:text-foreground aria-[current=page]:after:opacity-100 [&_svg]:size-4 [&_svg]:shrink-0";
4
6
  const TOUCH_TAB_CLASS = "h-touch-target min-w-touch-target justify-center px-3";
7
+ // Static fades (no motion, so nothing to drop under prefers-reduced-motion) on each edge that hides tabs.
8
+ const NAV_CLASS = "overflow-x-auto border-b border-border data-overflow-start:mask-l-from-[calc(100%---spacing(8))] data-overflow-end:mask-r-from-[calc(100%---spacing(8))]";
9
+ // Marks each edge that hides tabs (`data-overflow-start`, `data-overflow-end`); a pixel of rounding is not overflow.
10
+ function markOverflowEdges(strip) {
11
+ strip.toggleAttribute("data-overflow-start", strip.scrollLeft > 1);
12
+ strip.toggleAttribute("data-overflow-end", strip.scrollWidth - strip.clientWidth - strip.scrollLeft > 1);
13
+ }
14
+ // The edge fade's width (`--spacing(8)` in NAV_CLASS): the current tab keeps this much room, so no fade covers it.
15
+ const FADE_WIDTH_PX = 32;
16
+ // Scrolls the strip itself (never the page) just far enough that the current tab is whole and clear of the fades.
17
+ function scrollTabIntoStrip(strip, current) {
18
+ const link = [...strip.querySelectorAll("a[data-tab]")].find((candidate) => candidate.dataset["tab"] === current);
19
+ if (link === undefined)
20
+ return;
21
+ const linkBox = link.getBoundingClientRect();
22
+ const start = linkBox.left - strip.getBoundingClientRect().left + strip.scrollLeft;
23
+ const end = start + linkBox.width;
24
+ const maxScroll = Math.max(0, strip.scrollWidth - strip.clientWidth);
25
+ if (start < strip.scrollLeft)
26
+ strip.scrollLeft = Math.max(0, start - FADE_WIDTH_PX);
27
+ else if (end > strip.scrollLeft + strip.clientWidth)
28
+ strip.scrollLeft = Math.min(maxScroll, end + FADE_WIDTH_PX - strip.clientWidth);
29
+ }
30
+ // Keeps the current tab in view (on mount and when it changes) and the overflow marks in step (on scroll and resize).
31
+ function useStripScroll(strip, current) {
32
+ useEffect(() => {
33
+ const element = strip.current;
34
+ if (element === null)
35
+ return;
36
+ const markEdges = () => markOverflowEdges(element);
37
+ element.addEventListener("scroll", markEdges, { passive: true });
38
+ const observer = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(markEdges);
39
+ observer?.observe(element);
40
+ return () => {
41
+ element.removeEventListener("scroll", markEdges);
42
+ observer?.disconnect();
43
+ };
44
+ }, [strip]);
45
+ useEffect(() => {
46
+ const element = strip.current;
47
+ if (element === null)
48
+ return;
49
+ scrollTabIntoStrip(element, current);
50
+ markOverflowEdges(element);
51
+ }, [strip, current]);
52
+ }
5
53
  // A screen's tabs as line tabs where each tab is a link, so the shown tab lives in the address and survives a reload.
6
54
  export function TabBar({ label, tabs, current, size = "default", tabClassName }) {
7
55
  const linkClass = cn(TAB_CLASS, size === "touch" && TOUCH_TAB_CLASS, tabClassName);
8
- return (_jsx("nav", { "aria-label": label, "data-slot": "tab-bar", className: "overflow-x-auto border-b border-border", children: _jsx("ul", { className: "flex gap-1 pb-1", children: tabs.map((tab) => (_jsx("li", { children: _jsxs("a", { href: tab.href, className: linkClass, "data-tab": tab.key, "data-size": size === "touch" ? "touch" : undefined, "aria-current": tab.key === current ? "page" : undefined, children: [tab.icon, tab.label, tab.count === undefined ? null : (_jsx("span", { "data-slot": "tab-bar-count", className: "rounded-xs bg-accent px-1 text-small text-muted-foreground tabular-nums", children: tab.count }))] }) }, tab.key))) }) }));
56
+ const stripRef = useRef(null);
57
+ useStripScroll(stripRef, current);
58
+ return (_jsx("nav", { ref: stripRef, "aria-label": label, "data-slot": "tab-bar", className: NAV_CLASS, children: _jsx("ul", { className: "flex gap-1 pb-1", children: tabs.map((tab) => (_jsx("li", { children: _jsxs("a", { href: tab.href, className: linkClass, "data-tab": tab.key, "data-size": size === "touch" ? "touch" : undefined, "aria-current": tab.key === current ? "page" : undefined, children: [tab.icon, tab.label, tab.count === undefined ? null : (_jsx("span", { "data-slot": "tab-bar-count", className: "rounded-xs bg-accent px-1 text-small text-muted-foreground tabular-nums", children: tab.count }))] }) }, tab.key))) }) }));
9
59
  }
10
60
  //# sourceMappingURL=TabBar.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"TabBar.js","sourceRoot":"","sources":["../../src/notion/TabBar.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,EAAE,EAAE,MAAM,iBAAiB,CAAC;AAyBrC,MAAM,SAAS,GACb,ydAAyd,CAAC;AAE5d,MAAM,eAAe,GAAG,uDAAuD,CAAC;AAEhF,sHAAsH;AACtH,MAAM,UAAU,MAAM,CAAqB,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,GAAG,SAAS,EAAE,YAAY,EAAoB;IACnH,MAAM,SAAS,GAAG,EAAE,CAAC,SAAS,EAAE,IAAI,KAAK,OAAO,IAAI,eAAe,EAAE,YAAY,CAAC,CAAC;IACnF,OAAO,CACL,4BAAiB,KAAK,eAAY,SAAS,EAAC,SAAS,EAAC,wCAAwC,YAC5F,aAAI,SAAS,EAAC,iBAAiB,YAC5B,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CACjB,uBACE,aACE,IAAI,EAAE,GAAG,CAAC,IAAI,EACd,SAAS,EAAE,SAAS,cACV,GAAG,CAAC,GAAG,eACN,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,kBACnC,GAAG,CAAC,GAAG,KAAK,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,aAErD,GAAG,CAAC,IAAI,EACR,GAAG,CAAC,KAAK,EACT,GAAG,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAChC,4BAAgB,eAAe,EAAC,SAAS,EAAC,yEAAyE,YAChH,GAAG,CAAC,KAAK,GACL,CACR,IACC,IAfG,GAAG,CAAC,GAAG,CAgBX,CACN,CAAC,GACC,GACD,CACP,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"TabBar.js","sourceRoot":"","sources":["../../src/notion/TabBar.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,SAAS,EAAE,M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AC;IAC7B,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC;AACvB,CAAC;AAED,sHAAsH;AACtH,MAAM,UAAU,MAAM,CAAqB,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,GAAG,SAAS,EAAE,YAAY,EAAoB;IACnH,MAAM,SAAS,GAAG,EAAE,CAAC,SAAS,EAAE,IAAI,KAAK,OAAO,IAAI,eAAe,EAAE,YAAY,CAAC,CAAC;IACnF,MAAM,QAAQ,GAAG,MAAM,CAAqB,IAAI,CAAC,CAAC;IAClD,cAAc,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAClC,OAAO,CACL,cAAK,GAAG,EAAE,QAAQ,gBAAc,KAAK,eAAY,SAAS,EAAC,SAAS,EAAE,SAAS,YAC7E,aAAI,SAAS,EAAC,iBAAiB,YAC5B,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CACjB,uBACE,aACE,IAAI,EAAE,GAAG,CAAC,IAAI,EACd,SAAS,EAAE,SAAS,cACV,GAAG,CAAC,GAAG,eACN,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,kBACnC,GAAG,CAAC,GAAG,KAAK,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,aAErD,GAAG,CAAC,IAAI,EACR,GAAG,CAAC,KAAK,EACT,GAAG,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAChC,4BAAgB,eAAe,EAAC,SAAS,EAAC,yEAAyE,YAChH,GAAG,CAAC,KAAK,GACL,CACR,IACC,IAfG,GAAG,CAAC,GAAG,CAgBX,CACN,CAAC,GACC,GACD,CACP,CAAC;AACJ,CAAC"}
@@ -5,7 +5,7 @@ declare function DialogTrigger({ ...props }: React.ComponentProps<typeof DialogP
5
5
  declare function DialogPortal({ ...props }: React.ComponentProps<typeof DialogPrimitive.Portal>): React.JSX.Element;
6
6
  declare function DialogClose({ ...props }: React.ComponentProps<typeof DialogPrimitive.Close>): React.JSX.Element;
7
7
  declare function DialogOverlay({ className, ...props }: React.ComponentProps<typeof DialogPrimitive.Overlay>): React.JSX.Element;
8
- declare function DialogContent({ className, children, showCloseButton, closeLabel, closeButtonSize, size, ...props }: React.ComponentProps<typeof DialogPrimitive.Content> & {
8
+ declare function DialogContent({ className, children, showCloseButton, closeLabel, closeButtonSize, size, onOpenAutoFocus, ...props }: React.ComponentProps<typeof DialogPrimitive.Content> & {
9
9
  showCloseButton?: boolean;
10
10
  closeLabel?: string;
11
11
  closeButtonSize?: "default" | "touch";
@@ -1 +1 @@
1
- {"version":3,"file":"dialog.d.ts","sourceRoot":"","sources":["../../src/ui/dialog.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAI9B,OAAO,EAAE,MAAM,IAAI,eAAe,EAAE,MAAM,UAAU,CAAA;AAIpD,iBAAS,MAAM,CAAC,EACd,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,eAAe,CAAC,IAAI,CAAC,qBAEnD;AAED,iBAAS,aAAa,CAAC,EACrB,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,eAAe,CAAC,OAAO,CAAC,qBAEtD;AAED,iBAAS,YAAY,CAAC,EACpB,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,eAAe,CAAC,MAAM,CAAC,qBAErD;AAED,iBAAS,WAAW,CAAC,EACnB,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,eAAe,CAAC,KAAK,CAAC,qBAEpD;AAED,iBAAS,aAAa,CAAC,EACrB,SAAS,EACT,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,eAAe,CAAC,OAAO,CAAC,qBAWtD;AAED,iBAAS,aAAa,CAAC,EACrB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AClC,QAAQ,EACR,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,GAAG;IAC/B,eAAe,CAAC,EAAE,OAAO,CAAA;IAEzB,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB,qBAkBA;AAED,iBAAS,WAAW,CAAC,EACnB,SAAS,EACT,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,eAAe,CAAC,KAAK,CAAC,qBAQpD;AAED,iBAAS,iBAAiB,CAAC,EACzB,SAAS,EACT,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,eAAe,CAAC,WAAW,CAAC,qBAQ1D;AAED,OAAO,EACL,MAAM,EACN,WAAW,EACX,aAAa,EACb,iBAAiB,EACjB,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,YAAY,EACZ,WAAW,EACX,aAAa,GACd,CAAA"}
package/dist/ui/dialog.js CHANGED
@@ -2,6 +2,7 @@
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import * as React from "react";
4
4
  import { en as messages } from "../messages/en.js";
5
+ import { withFirstFieldFocus } from "../lib/focus-first-field.js";
5
6
  import { cn } from "../lib/utils.js";
6
7
  import { XIcon } from "lucide-react";
7
8
  import { Dialog as DialogPrimitive } from "radix-ui";
@@ -21,8 +22,8 @@ function DialogClose({ ...props }) {
21
22
  function DialogOverlay({ className, ...props }) {
22
23
  return (_jsx(DialogPrimitive.Overlay, { "data-slot": "dialog-overlay", className: cn("fixed inset-0 z-50 bg-overlay duration-200 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0", className), ...props }));
23
24
  }
24
- function DialogContent({ className, children, showCloseButton = true, closeLabel = messages.dialog.close, closeButtonSize = "default", size = "default", ...props }) {
25
- return (_jsxs(DialogPortal, { "data-slot": "dialog-portal", children: [_jsx(DialogOverlay, {}), _jsxs(DialogPrimitive.Content, { "data-slot": "dialog-content", className: cn("fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-xl bg-popover p-6 text-popover-foreground shadow-dialog duration-200 outline-none data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 sm:max-w-lg", size === "wide" && "lg:max-w-1/2", size === "lg" &&
25
+ function DialogContent({ className, children, showCloseButton = true, closeLabel = messages.dialog.close, closeButtonSize = "default", size = "default", onOpenAutoFocus, ...props }) {
26
+ return (_jsxs(DialogPortal, { "data-slot": "dialog-portal", children: [_jsx(DialogOverlay, {}), _jsxs(DialogPrimitive.Content, { "data-slot": "dialog-content", onOpenAutoFocus: withFirstFieldFocus(onOpenAutoFocus), className: cn("fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-xl bg-popover p-6 text-popover-foreground shadow-dialog duration-200 outline-none data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 sm:max-w-lg", size === "wide" && "lg:max-w-1/2", size === "lg" &&
26
27
  "flex h-[calc(100dvh-2rem)] flex-col overflow-y-auto sm:h-3/4 sm:max-w-3/4 lg:h-1/2 lg:min-h-96 lg:max-w-1/2", size === "sm" && "max-h-[calc(100dvh-2rem)] overflow-y-auto sm:max-w-md", className), ...props, children: [children, showCloseButton && (_jsxs(DialogPrimitive.Close, { "data-slot": "dialog-close", className: cn("absolute top-4 right-4 rounded-xs opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", closeButtonSize === "touch" &&
27
28
  "top-0.5 right-0.5 inline-flex size-touch-target items-center justify-center rounded-md"), children: [_jsx(XIcon, {}), _jsx("span", { className: "sr-only", children: closeLabel })] }))] })] }));
28
29
  }
@@ -1 +1 @@
1
- {"version":3,"file":"dialog.js","sourceRoot":"","sources":["../../src/ui/dialog.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAE,EAAE,IAAI,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAClD,OAAO,EAAE,EAAE,EAAE,MAAM,iBAAiB,CAAA;AACpC,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAA;AACpC,OAAO,EAAE,MAAM,IAAI,eAAe,EAAE,MAAM,UAAU,CAAA;AAEpD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAEpC,SAAS,MAAM,CAAC,EACd,GAAG,KAAK,EAC0C;IAClD,OAAO,KAAC,eAAe,CAAC,IAAI,iBAAW,QAAQ,KAAK,KAAK,GAAI,CAAA;AAC/D,CAAC;AAED,SAAS,aAAa,CAAC,EACrB,GAAG,KAAK,EAC6C;IACrD,OAAO,KAAC,eAAe,CAAC,OAAO,iBAAW,gBAAgB,KAAK,KAAK,GAAI,CAAA;AAC1E,CAAC;AAED,SAAS,YAAY,CAAC,EACpB,GAAG,KAAK,EAC4C;IACpD,OAAO,KAAC,eAAe,CAAC,MAAM,iBAAW,eAAe,KAAK,KAAK,GAAI,CAAA;AACxE,CAAC;AAED,SAAS,WAAW,CAAC,EACnB,GAAG,KAAK,EAC2C;IACnD,OAAO,KAAC,eAAe,CAAC,KAAK,iBAAW,cAAc,KAAK,KAAK,GAAI,CAAA;AACtE,CAAC;AAED,SAAS,aAAa,CAAC,EACrB,SAAS,EACT,GAAG,KAAK,EAC6C;IACrD,OAAO,CACL,KAAC,eAAe,CAAC,OAAO,iBACZ,gBAAgB,EAC1B,SAAS,EAA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,EAC9B,SAAS,EAAE,EAAE,CAAC,+BAA+B,EAAE,SAAS,CAAC,KACrD,KAAK,GACT,CACH,CAAA;AACH,CAAC;AAED,OAAO,EACL,MAAM,EACN,WAAW,EACX,aAAa,EACb,iBAAiB,EACjB,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,YAAY,EACZ,WAAW,EACX,aAAa,GACd,CAAA"}
@@ -3,7 +3,7 @@ import { Dialog as SheetPrimitive } from "radix-ui";
3
3
  declare function Sheet({ ...props }: React.ComponentProps<typeof SheetPrimitive.Root>): React.JSX.Element;
4
4
  declare function SheetTrigger({ ...props }: React.ComponentProps<typeof SheetPrimitive.Trigger>): React.JSX.Element;
5
5
  declare function SheetClose({ ...props }: React.ComponentProps<typeof SheetPrimitive.Close>): React.JSX.Element;
6
- declare function SheetContent({ className, children, side, showCloseButton, closeLabel, ...props }: React.ComponentProps<typeof SheetPrimitive.Content> & {
6
+ declare function SheetContent({ className, children, side, showCloseButton, closeLabel, onOpenAutoFocus, ...props }: React.ComponentProps<typeof SheetPrimitive.Content> & {
7
7
  side?: "top" | "right" | "bottom" | "left";
8
8
  showCloseButton?: boolean;
9
9
  closeLabel?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"sheet.d.ts","sourceRoot":"","sources":["../../src/ui/sheet.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAI9B,OAAO,EAAE,MAAM,IAAI,cAAc,EAAE,MAAM,UAAU,CAAA;AAEnD,iBAAS,KAAK,CAAC,EAAE,GAAG,KAAK,EAAE,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,cAAc,CAAC,IAAI,CAAC,qBAE5E;AAED,iBAAS,YAAY,CAAC,EACpB,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,cAAc,CAAC,OAAO,CAAC,qBAErD;AAED,iBAAS,UAAU,CAAC,EAClB,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,O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 -2,6 +2,7 @@
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import * as React from "react";
4
4
  import { en as messages } from "../messages/en.js";
5
+ import { withFirstFieldFocus } from "../lib/focus-first-field.js";
5
6
  import { cn } from "../lib/utils.js";
6
7
  import { XIcon } from "lucide-react";
7
8
  import { Dialog as SheetPrimitive } from "radix-ui";
@@ -20,8 +21,8 @@ function SheetPortal({ ...props }) {
20
21
  function SheetOverlay({ className, ...props }) {
21
22
  return (_jsx(SheetPrimitive.Overlay, { "data-slot": "sheet-overlay", className: cn("fixed inset-0 z-50 bg-overlay data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0", className), ...props }));
22
23
  }
23
- function SheetContent({ className, children, side = "right", showCloseButton = true, closeLabel = messages.sheet.close, ...props }) {
24
- return (_jsxs(SheetPortal, { children: [_jsx(SheetOverlay, {}), _jsxs(SheetPrimitive.Content, { "data-slot": "sheet-content", className: cn("fixed z-50 flex flex-col gap-4 bg-popover text-popover-foreground shadow-lg transition ease-in-out data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:animate-in data-[state=open]:duration-500", side === "right" &&
24
+ function SheetContent({ className, children, side = "right", showCloseButton = true, closeLabel = messages.sheet.close, onOpenAutoFocus, ...props }) {
25
+ return (_jsxs(SheetPortal, { children: [_jsx(SheetOverlay, {}), _jsxs(SheetPrimitive.Content, { "data-slot": "sheet-content", onOpenAutoFocus: withFirstFieldFocus(onOpenAutoFocus), className: cn("fixed z-50 flex flex-col gap-4 bg-popover text-popover-foreground shadow-lg transition ease-in-out data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:animate-in data-[state=open]:duration-500", side === "right" &&
25
26
  "inset-y-0 right-0 h-full pt-[env(safe-area-inset-top)] pr-[env(safe-area-inset-right)] pb-[env(safe-area-inset-bottom)] w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm", side === "left" &&
26
27
  "inset-y-0 left-0 h-full pt-[env(safe-area-inset-top)] pb-[env(safe-area-inset-bottom)] pl-[env(safe-area-inset-left)] w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm", side === "top" &&
27
28
  "inset-x-0 top-0 h-auto pt-[env(safe-area-inset-top)] pr-[env(safe-area-inset-right)] pl-[env(safe-area-inset-left)] border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top", side === "bottom" &&
@@ -1 +1 @@
1
- {"version":3,"file":"sheet.js","sourceRoot":"","sources":["../../src/ui/sheet.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAE,EAAE,IAAI,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAClD,OAAO,EAAE,EAAE,EAAE,MAAM,iBAAiB,CAAA;AACpC,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAA;AACpC,OAAO,EAAE,MAAM,IAAI,cAAc,EAAE,MAAM,UAAU,CAAA;AAEnD,SAAS,KAAK,CAAC,EAAE,GAAG,KAAK,EAAoD;IAC3E,OAAO,KAAC,cAAc,CAAC,IAAI,iBAAW,OAAO,KAAK,KAAK,GAAI,CAAA;AAC7D,CAAC;AAED,SAAS,YAAY,CAAC,EACpB,GAAG,KAAK,EAC4C;IACpD,OAAO,KAAC,cAAc,CAAC,OAAO,iBAAW,eAAe,KAAK,KAAK,GAAI,CAAA;AACxE,CAAC;AAED,SAAS,UAAU,CAAC,EAClB,GAAG,KAAK,EAC0C;IAClD,OAAO,KAAC,cAAc,CAAC,KAAK,iBAAW,aAAa,KAAK,KAAK,GAAI,CAAA;AACpE,CAAC;AAED,SAAS,WAAW,CAAC,EACnB,GAAG,KAAK,EAC2C;IACnD,OAAO,KAAC,cAAc,CAAC,MAAM,iBAAW,cAAc,KAAK,KAAK,GAAI,CAAA;AACtE,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AAW,EACX,WAAW,EACX,UAAU,EACV,gBAAgB,GACjB,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@softure-ai/theme-notion",
3
- "version": "0.31.0",
3
+ "version": "0.33.0",
4
4
  "description": "SOFTURE AI Notion theme: shadcn/ui components (new-york v4, Radix, Tailwind CSS v4, lucide) with the Notion design system's tokens and deltas, ready to import.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -0,0 +1,39 @@
1
+ // The form controls a dialog or sheet focuses on open, ahead of any button before them (a tooltip trigger beside a
2
+ // label opens its tooltip on focus, #1476).
3
+ const FIELD_SELECTOR = [
4
+ 'input:not([type="hidden"]):not(:disabled)',
5
+ "select:not(:disabled)",
6
+ "textarea:not(:disabled)",
7
+ '[role="combobox"]:not(:disabled):not([aria-disabled="true"])',
8
+ ].join(", ")
9
+
10
+ function findFirstField(container: Element): HTMLElement | null {
11
+ for (const candidate of container.querySelectorAll<HTMLElement>(FIELD_SELECTOR)) {
12
+ if (candidate.closest("[hidden], [inert]") === null) return candidate
13
+ }
14
+ return null
15
+ }
16
+
17
+ function focusField(field: HTMLElement): void {
18
+ field.focus({ preventScroll: true })
19
+ // Selected as Radix selects the first text input it focuses.
20
+ if (field instanceof HTMLInputElement && document.activeElement === field) field.select()
21
+ }
22
+
23
+ /**
24
+ * An `onOpenAutoFocus` handler for a Radix dialog or sheet content: it runs the app's own handler first, then, unless
25
+ * that prevented the default, focuses the first form field inside the content instead of the first focusable element.
26
+ * With no field, Radix's default focus stays.
27
+ */
28
+ export function withFirstFieldFocus(
29
+ onOpenAutoFocus: ((event: Event) => void) | undefined
30
+ ): (event: Event) => void {
31
+ return (event) => {
32
+ onOpenAutoFocus?.(event)
33
+ if (event.defaultPrevented || !(event.currentTarget instanceof Element)) return
34
+ const field = findFirstField(event.currentTarget)
35
+ if (field === null) return
36
+ event.preventDefault()
37
+ focusField(field)
38
+ }
39
+ }
@@ -47,7 +47,7 @@ export type FoldRowDetailsProps =
47
47
 
48
48
  export type FoldRowProps = FoldRowSummaryProps &
49
49
  FoldRowDetailsProps & {
50
- /** Indents the opened content to line up with the title after the chevron; by default it is padded equally. */
50
+ /** Indents the opened content to line up with the title after the chevron; by default it starts under the chevron. */
51
51
  readonly isInset?: boolean;
52
52
  /** `touch` makes the summary at least the touch target high (44 px) instead of the row height. */
53
53
  readonly size?: "default" | "touch";
@@ -59,15 +59,20 @@ export type FoldRowProps = FoldRowSummaryProps &
59
59
  */
60
60
  readonly isOpenInitially?: boolean;
61
61
  /**
62
- * Controls at the right end of the row's bar (a delete button, a menu). They sit beside the `<summary>`, not in
63
- * it, so clicking them never folds the row, but they share its background: the bar runs under them when the row
64
- * is open or hovered. Shown whether the row is open or closed, centred on the summary's first line.
62
+ * Controls in the right column of the row's bar (a delete button, a menu). The column sits beside the `<summary>`,
63
+ * not in it, so clicking a control never folds the row; it spans the summary's full height and lights with it when
64
+ * the row is open or hovered, so the bar reads as one box. On a phone (below `md`) the column falls under the
65
+ * summary and each control is at least the touch target (44 px).
65
66
  */
66
67
  readonly actions?: ReactNode;
68
+ /** The item's status, drawn in the same column above the actions (with no actions, the column holds only it). */
69
+ readonly status?: ReactNode;
67
70
  };
68
71
 
69
- const CONTENT_CLASS = "flex flex-col gap-2 p-3 empty:hidden";
70
- const INSET_CONTENT_CLASS = "flex flex-col gap-2 py-2 pr-1 pl-6 empty:hidden";
72
+ // The bar and its opened content share one 8 px horizontal inset, so the details start under the chevron; the inset
73
+ // variant starts under the title instead (8 px inset, 16 px chevron, 8 px gap).
74
+ const CONTENT_LAYOUT = "flex-col gap-2 px-2 py-3";
75
+ const INSET_CONTENT_LAYOUT = "flex-col gap-2 py-2 pr-2 pl-8";
71
76
 
72
77
  function FoldRowFixedSummary({
73
78
  title,
@@ -123,42 +128,91 @@ function FoldRowChevron() {
123
128
  );
124
129
  }
125
130
 
131
+ function isDrawn(node: ReactNode): boolean {
132
+ return node !== undefined && node !== null;
133
+ }
134
+
126
135
  // An item as one folding list row: a native `<details>` that opens in place to its details, with no client state.
127
136
  export function FoldRow(props: FoldRowProps) {
128
- const { actions, size = "default" } = props;
129
- if (actions === undefined || actions === null) {
130
- return <FoldRowDetails {...props} className="border-b border-border" />;
137
+ const { actions, status, isInset = false } = props;
138
+ if (!isDrawn(actions) && !isDrawn(status)) {
139
+ return (
140
+ <FoldRowDetails
141
+ {...props}
142
+ className="border-b border-border"
143
+ content={<FoldRowContent {...props} className={cn("flex", isInset ? INSET_CONTENT_LAYOUT : CONTENT_LAYOUT, "empty:hidden")} />}
144
+ />
145
+ );
131
146
  }
132
- // The actions sit beside the `<details>`, not in its `<summary>`: a control inside the summary would fold the row.
133
- // They carry the summary's background (the details is their peer: open; the wrapper is the hover group), so the
134
- // summary and the actions read as one bar with the controls at its right end.
147
+ // The right column sits beside the `<details>`, not in its `<summary>`: a control inside the summary would fold the
148
+ // row. To make the column exactly as high as the summary, the `<details>` holds only its summary and shares a grid
149
+ // row with the column (grid items stretch to their row); the opened content is the next row, shown while the
150
+ // details is open (`peer-open`). The details and the column carry the bar's light together, so they read as one box.
135
151
  return (
136
- <div data-slot="fold-row-with-actions" className="group/fold-row-with-actions flex items-start border-b border-border">
137
- <FoldRowDetails {...props} className="peer/fold-row min-w-0 flex-1" hasActions />
152
+ <div
153
+ data-slot="fold-row-with-actions"
154
+ className="group/fold-row-with-actions grid grid-cols-1 border-b border-border md:grid-cols-[minmax(0,1fr)_auto]"
155
+ >
156
+ <FoldRowDetails
157
+ {...props}
158
+ className="peer/fold-row min-w-0 rounded-md transition-colors duration-120 group-hover/fold-row-with-actions:bg-accent open:bg-accent max-md:rounded-b-none md:rounded-r-none"
159
+ isLitByRow
160
+ />
138
161
  <div
139
162
  data-slot="fold-row-actions"
140
- className={cn(
141
- "flex shrink-0 items-center gap-1 rounded-r-md pr-1 transition-colors duration-120 group-hover/fold-row-with-actions:bg-accent peer-open/fold-row:bg-accent",
142
- size === "touch" ? "min-h-touch-target" : "min-h-row-height",
143
- )}
163
+ className="flex flex-wrap items-center gap-2 rounded-b-md pr-2 pb-1 pl-8 transition-colors duration-120 group-hover/fold-row-with-actions:bg-accent peer-open/fold-row:bg-accent md:flex-col md:flex-nowrap md:items-end md:justify-center md:gap-1 md:rounded-b-none md:rounded-r-md md:py-1 md:pl-0"
144
164
  >
145
- {actions}
165
+ {isDrawn(status) ? (
166
+ <div data-slot="fold-row-status" className="flex items-center">
167
+ {status}
168
+ </div>
169
+ ) : null}
170
+ {isDrawn(actions) ? (
171
+ <div
172
+ data-slot="fold-row-action-list"
173
+ className="flex items-center gap-1 max-md:*:min-h-touch-target max-md:*:min-w-touch-target"
174
+ >
175
+ {actions}
176
+ </div>
177
+ ) : null}
146
178
  </div>
179
+ <FoldRowContent
180
+ {...props}
181
+ className={cn("col-span-full hidden", isInset ? INSET_CONTENT_LAYOUT : CONTENT_LAYOUT, "peer-open/fold-row:not-empty:flex")}
182
+ />
147
183
  </div>
148
184
  );
149
185
  }
150
186
 
151
- function FoldRowDetails(props: FoldRowProps & { readonly className: string; readonly hasActions?: boolean }) {
152
- const { isInset = false, isOpenInitially = false, size = "default", children, className, hasActions = false } = props;
187
+ function FoldRowContent(props: FoldRowProps & { readonly className: string }) {
188
+ const { isInset = false, children, className } = props;
189
+ return (
190
+ <div data-slot="fold-row-content" data-inset={isInset} className={className}>
191
+ {props.details === undefined ? null : <DetailTable label={props.detailsLabel} rows={props.details} />}
192
+ {children}
193
+ </div>
194
+ );
195
+ }
196
+
197
+ function FoldRowDetails(
198
+ props: FoldRowProps & {
199
+ readonly className: string;
200
+ /** The summary lights on its own, or the wrapper lights the whole details (with the right column). */
201
+ readonly isLitByRow?: boolean;
202
+ /** The opened content, when it lives inside the details. */
203
+ readonly content?: ReactNode;
204
+ },
205
+ ) {
206
+ const { isOpenInitially = false, size = "default", className, isLitByRow = false, content } = props;
153
207
  return (
154
208
  <details data-slot="fold-row" open={isOpenInitially || undefined} className={cn("group/fold-row", className)}>
155
209
  <summary
156
210
  data-slot="fold-row-summary"
157
211
  className={cn(
158
- "flex cursor-pointer list-none flex-wrap items-center gap-x-2 gap-y-1 rounded-md px-1 py-1 transition-colors duration-120 group-open/fold-row:bg-accent hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none [&::-webkit-details-marker]:hidden",
212
+ "flex cursor-pointer list-none flex-wrap items-center gap-x-2 gap-y-1 rounded-md px-2 py-1",
213
+ !isLitByRow && "transition-colors duration-120 group-open/fold-row:bg-accent hover:bg-accent",
214
+ "focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none [&::-webkit-details-marker]:hidden",
159
215
  size === "touch" ? "min-h-touch-target" : "min-h-row-height",
160
- // With actions the bar continues under them: no rounding on the right, and hovering them lights it too.
161
- hasActions && "rounded-r-none group-hover/fold-row-with-actions:bg-accent",
162
216
  )}
163
217
  >
164
218
  {props.summary === undefined ? (
@@ -175,10 +229,7 @@ function FoldRowDetails(props: FoldRowProps & { readonly className: string; read
175
229
  </>
176
230
  )}
177
231
  </summary>
178
- <div data-slot="fold-row-content" data-inset={isInset} className={isInset ? INSET_CONTENT_CLASS : CONTENT_CLASS}>
179
- {props.details === undefined ? null : <DetailTable label={props.detailsLabel} rows={props.details} />}
180
- {children}
181
- </div>
232
+ {content}
182
233
  </details>
183
234
  );
184
235
  }
@@ -1,4 +1,6 @@
1
- import type { ReactNode } from "react";
1
+ "use client";
2
+
3
+ import { useEffect, useRef, type ReactNode, type RefObject } from "react";
2
4
 
3
5
  import { cn } from "../lib/utils.js";
4
6
 
@@ -30,11 +32,61 @@ const TAB_CLASS =
30
32
 
31
33
  const TOUCH_TAB_CLASS = "h-touch-target min-w-touch-target justify-center px-3";
32
34
 
35
+ // Static fades (no motion, so nothing to drop under prefers-reduced-motion) on each edge that hides tabs.
36
+ const NAV_CLASS =
37
+ "overflow-x-auto border-b border-border data-overflow-start:mask-l-from-[calc(100%---spacing(8))] data-overflow-end:mask-r-from-[calc(100%---spacing(8))]";
38
+
39
+ // Marks each edge that hides tabs (`data-overflow-start`, `data-overflow-end`); a pixel of rounding is not overflow.
40
+ function markOverflowEdges(strip: HTMLElement) {
41
+ strip.toggleAttribute("data-overflow-start", strip.scrollLeft > 1);
42
+ strip.toggleAttribute("data-overflow-end", strip.scrollWidth - strip.clientWidth - strip.scrollLeft > 1);
43
+ }
44
+
45
+ // The edge fade's width (`--spacing(8)` in NAV_CLASS): the current tab keeps this much room, so no fade covers it.
46
+ const FADE_WIDTH_PX = 32;
47
+
48
+ // Scrolls the strip itself (never the page) just far enough that the current tab is whole and clear of the fades.
49
+ function scrollTabIntoStrip(strip: HTMLElement, current: string) {
50
+ const link = [...strip.querySelectorAll<HTMLElement>("a[data-tab]")].find((candidate) => candidate.dataset["tab"] === current);
51
+ if (link === undefined) return;
52
+ const linkBox = link.getBoundingClientRect();
53
+ const start = linkBox.left - strip.getBoundingClientRect().left + strip.scrollLeft;
54
+ const end = start + linkBox.width;
55
+ const maxScroll = Math.max(0, strip.scrollWidth - strip.clientWidth);
56
+ if (start < strip.scrollLeft) strip.scrollLeft = Math.max(0, start - FADE_WIDTH_PX);
57
+ else if (end > strip.scrollLeft + strip.clientWidth) strip.scrollLeft = Math.min(maxScroll, end + FADE_WIDTH_PX - strip.clientWidth);
58
+ }
59
+
60
+ // Keeps the current tab in view (on mount and when it changes) and the overflow marks in step (on scroll and resize).
61
+ function useStripScroll(strip: RefObject<HTMLElement | null>, current: string) {
62
+ useEffect(() => {
63
+ const element = strip.current;
64
+ if (element === null) return;
65
+ const markEdges = () => markOverflowEdges(element);
66
+ element.addEventListener("scroll", markEdges, { passive: true });
67
+ const observer = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(markEdges);
68
+ observer?.observe(element);
69
+ return () => {
70
+ element.removeEventListener("scroll", markEdges);
71
+ observer?.disconnect();
72
+ };
73
+ }, [strip]);
74
+
75
+ useEffect(() => {
76
+ const element = strip.current;
77
+ if (element === null) return;
78
+ scrollTabIntoStrip(element, current);
79
+ markOverflowEdges(element);
80
+ }, [strip, current]);
81
+ }
82
+
33
83
  // A screen's tabs as line tabs where each tab is a link, so the shown tab lives in the address and survives a reload.
34
84
  export function TabBar<Key extends string>({ label, tabs, current, size = "default", tabClassName }: TabBarProps<Key>) {
35
85
  const linkClass = cn(TAB_CLASS, size === "touch" && TOUCH_TAB_CLASS, tabClassName);
86
+ const stripRef = useRef<HTMLElement | null>(null);
87
+ useStripScroll(stripRef, current);
36
88
  return (
37
- <nav aria-label={label} data-slot="tab-bar" className="overflow-x-auto border-b border-border">
89
+ <nav ref={stripRef} aria-label={label} data-slot="tab-bar" className={NAV_CLASS}>
38
90
  <ul className="flex gap-1 pb-1">
39
91
  {tabs.map((tab) => (
40
92
  <li key={tab.key}>
package/src/ui/dialog.tsx CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  import * as React from "react"
4
4
  import { en as messages } from "../messages/en.js"
5
+ import { withFirstFieldFocus } from "../lib/focus-first-field.js"
5
6
  import { cn } from "../lib/utils.js"
6
7
  import { XIcon } from "lucide-react"
7
8
  import { Dialog as DialogPrimitive } from "radix-ui"
@@ -55,6 +56,7 @@ function DialogContent({
55
56
  closeLabel = messages.dialog.close,
56
57
  closeButtonSize = "default",
57
58
  size = "default",
59
+ onOpenAutoFocus,
58
60
  ...props
59
61
  }: React.ComponentProps<typeof DialogPrimitive.Content> & {
60
62
  showCloseButton?: boolean
@@ -72,6 +74,7 @@ function DialogContent({
72
74
  <DialogOverlay />
73
75
  <DialogPrimitive.Content
74
76
  data-slot="dialog-content"
77
+ onOpenAutoFocus={withFirstFieldFocus(onOpenAutoFocus)}
75
78
  className={cn(
76
79
  "fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-xl bg-popover p-6 text-popover-foreground shadow-dialog duration-200 outline-none data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 sm:max-w-lg",
77
80
  size === "wide" && "lg:max-w-1/2",
package/src/ui/sheet.tsx CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  import * as React from "react"
4
4
  import { en as messages } from "../messages/en.js"
5
+ import { withFirstFieldFocus } from "../lib/focus-first-field.js"
5
6
  import { cn } from "../lib/utils.js"
6
7
  import { XIcon } from "lucide-react"
7
8
  import { Dialog as SheetPrimitive } from "radix-ui"
@@ -50,6 +51,7 @@ function SheetContent({
50
51
  side = "right",
51
52
  showCloseButton = true,
52
53
  closeLabel = messages.sheet.close,
54
+ onOpenAutoFocus,
53
55
  ...props
54
56
  }: React.ComponentProps<typeof SheetPrimitive.Content> & {
55
57
  side?: "top" | "right" | "bottom" | "left"
@@ -62,6 +64,7 @@ function SheetContent({
62
64
  <SheetOverlay />
63
65
  <SheetPrimitive.Content
64
66
  data-slot="sheet-content"
67
+ onOpenAutoFocus={withFirstFieldFocus(onOpenAutoFocus)}
65
68
  className={cn(
66
69
  "fixed z-50 flex flex-col gap-4 bg-popover text-popover-foreground shadow-lg transition ease-in-out data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:animate-in data-[state=open]:duration-500",
67
70
  side === "right" &&