@lt-three/love3 0.1.0 → 0.1.1
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/README.md +40 -40
- package/dist/native/analytics/animation.d.ts +1 -1
- package/dist/native/analytics/animation.js +1 -1
- package/dist/native/analytics/chart.types.d.ts +3 -3
- package/dist/native/analytics/metric-card.d.ts +3 -3
- package/dist/native/analytics/metric-card.js +3 -3
- package/dist/native/analytics/multi-line-chart.d.ts +9 -8
- package/dist/native/analytics/multi-line-chart.js +14 -13
- package/dist/native/analytics/pie-chart.d.ts +7 -7
- package/dist/native/analytics/pie-chart.js +8 -8
- package/dist/native/analytics/single-number.d.ts +4 -4
- package/dist/native/analytics/single-number.js +2 -2
- package/dist/native/atom/avatar.d.ts +6 -6
- package/dist/native/atom/avatar.js +2 -2
- package/dist/native/atom/badge.d.ts +5 -5
- package/dist/native/atom/button.d.ts +12 -12
- package/dist/native/atom/button.js +8 -8
- package/dist/native/atom/checkbox.d.ts +4 -4
- package/dist/native/atom/checkbox.js +2 -2
- package/dist/native/atom/colored-value.d.ts +4 -4
- package/dist/native/atom/colored-value.js +4 -4
- package/dist/native/atom/image.d.ts +7 -7
- package/dist/native/atom/image.js +2 -2
- package/dist/native/atom/label.d.ts +5 -5
- package/dist/native/atom/label.js +2 -2
- package/dist/native/atom/link.d.ts +5 -5
- package/dist/native/atom/link.js +5 -5
- package/dist/native/atom/readout.d.ts +7 -7
- package/dist/native/atom/readout.js +3 -3
- package/dist/native/atom/search-input.d.ts +2 -2
- package/dist/native/atom/search-input.js +2 -2
- package/dist/native/atom/select.d.ts +14 -14
- package/dist/native/atom/select.js +8 -8
- package/dist/native/atom/separator.d.ts +2 -3
- package/dist/native/atom/separator.js +2 -3
- package/dist/native/atom/skeleton.d.ts +3 -3
- package/dist/native/atom/skeleton.js +3 -3
- package/dist/native/atom/slider.d.ts +6 -6
- package/dist/native/atom/slider.js +3 -3
- package/dist/native/atom/spinner.d.ts +4 -4
- package/dist/native/atom/spinner.js +2 -2
- package/dist/native/atom/switch.d.ts +4 -4
- package/dist/native/atom/switch.js +3 -3
- package/dist/native/atom/symbol.d.ts +7 -7
- package/dist/native/atom/symbol.js +7 -7
- package/dist/native/atom/symbol.types.d.ts +8 -8
- package/dist/native/atom/symbol.types.js +7 -7
- package/dist/native/atom/text-field.d.ts +15 -15
- package/dist/native/atom/text-field.js +5 -5
- package/dist/native/atom/theme-toggle.d.ts +7 -7
- package/dist/native/atom/theme-toggle.js +4 -4
- package/dist/native/atom/timezone-select.d.ts +5 -5
- package/dist/native/atom/timezone-select.js +4 -4
- package/dist/native/atom/typography.d.ts +2 -2
- package/dist/native/atom/typography.js +2 -2
- package/dist/native/base/button.d.ts +13 -13
- package/dist/native/base/button.js +4 -4
- package/dist/native/base/form.d.ts +15 -15
- package/dist/native/base/form.js +11 -11
- package/dist/native/base/glass-card.d.ts +3 -3
- package/dist/native/base/glass-card.js +3 -3
- package/dist/native/base/input.d.ts +8 -8
- package/dist/native/base/input.js +7 -7
- package/dist/native/base/sheet.d.ts +27 -27
- package/dist/native/base/sheet.js +15 -15
- package/dist/native/form/checkbox.d.ts +3 -3
- package/dist/native/form/checkbox.js +2 -2
- package/dist/native/form/date-picker.d.ts +9 -9
- package/dist/native/form/date-picker.js +9 -9
- package/dist/native/form/form.d.ts +5 -6
- package/dist/native/form/form.js +4 -5
- package/dist/native/form/radio-group.d.ts +5 -5
- package/dist/native/form/radio-group.js +4 -4
- package/dist/native/form/select.d.ts +2 -2
- package/dist/native/form/select.js +2 -2
- package/dist/native/form/slider.d.ts +2 -2
- package/dist/native/form/slider.js +2 -2
- package/dist/native/form/switch.d.ts +2 -2
- package/dist/native/form/switch.js +2 -2
- package/dist/native/form/text-area.d.ts +2 -2
- package/dist/native/form/text-area.js +1 -1
- package/dist/native/form/text-input.d.ts +5 -5
- package/dist/native/form/text-input.js +8 -8
- package/dist/native/layout/accordion.d.ts +5 -5
- package/dist/native/layout/accordion.js +2 -2
- package/dist/native/layout/card.d.ts +8 -8
- package/dist/native/layout/card.js +3 -3
- package/dist/native/layout/description.d.ts +2 -2
- package/dist/native/layout/description.js +2 -2
- package/dist/native/layout/error.d.ts +5 -5
- package/dist/native/layout/error.js +2 -2
- package/dist/native/layout/information.d.ts +4 -4
- package/dist/native/layout/information.js +3 -3
- package/dist/native/layout/locked.d.ts +15 -15
- package/dist/native/layout/locked.js +7 -7
- package/dist/native/layout/modal.d.ts +8 -8
- package/dist/native/layout/modal.js +5 -5
- package/dist/native/layout/not-found.d.ts +4 -4
- package/dist/native/layout/not-found.js +3 -3
- package/dist/native/layout/page-frame.d.ts +8 -8
- package/dist/native/layout/page-frame.js +3 -3
- package/dist/native/layout/panel.d.ts +5 -5
- package/dist/native/layout/panel.js +5 -5
- package/dist/native/layout/reorderable-list.d.ts +14 -14
- package/dist/native/layout/reorderable-list.js +10 -10
- package/dist/native/layout/sheet.d.ts +10 -10
- package/dist/native/layout/sheet.js +4 -4
- package/dist/native/layout/simple-dialog.d.ts +3 -3
- package/dist/native/layout/simple-dialog.js +2 -2
- package/dist/native/layout/simple-table.d.ts +18 -18
- package/dist/native/layout/simple-table.js +1 -1
- package/dist/native/layout/tab-bar.d.ts +10 -10
- package/dist/native/layout/tab-bar.js +4 -4
- package/dist/native/layout/tabs.d.ts +6 -6
- package/dist/native/layout/tabs.js +4 -4
- package/dist/native/layout/tuning-panel.d.ts +10 -10
- package/dist/native/layout/tuning-panel.js +15 -15
- package/dist/native/lib/autocomplete.d.ts +1 -1
- package/dist/native/lib/autocomplete.js +1 -1
- package/dist/native/lib/breakpoints.d.ts +3 -3
- package/dist/native/lib/breakpoints.js +3 -3
- package/dist/native/lib/chart-palette.d.ts +2 -2
- package/dist/native/lib/chart-palette.js +2 -2
- package/dist/native/lib/confirm.d.ts +15 -16
- package/dist/native/lib/confirm.js +9 -10
- package/dist/native/lib/control.d.ts +9 -9
- package/dist/native/lib/external-store.d.ts +4 -5
- package/dist/native/lib/keyboard.d.ts +7 -7
- package/dist/native/lib/keyboard.js +7 -7
- package/dist/native/lib/labels.d.ts +6 -6
- package/dist/native/lib/labels.js +6 -6
- package/dist/native/lib/loading.d.ts +3 -3
- package/dist/native/lib/loading.js +3 -3
- package/dist/native/lib/network.d.ts +5 -6
- package/dist/native/lib/network.js +5 -6
- package/dist/native/lib/scheme.d.ts +7 -7
- package/dist/native/lib/scheme.js +3 -3
- package/dist/native/lib/snackbar.d.ts +12 -13
- package/dist/native/lib/snackbar.js +7 -8
- package/dist/native/lib/theme.d.ts +15 -15
- package/dist/native/lib/theme.js +15 -15
- package/dist/native/lib/timezone.d.ts +13 -13
- package/dist/native/lib/timezone.js +13 -13
- package/dist/native/lib/token-color.d.ts +1 -1
- package/dist/native/lib/token-color.js +1 -1
- package/dist/native/lib/tuning-context.d.ts +2 -2
- package/dist/native/lib/tuning.d.ts +10 -10
- package/dist/native/lib/tuning.js +8 -8
- package/dist/native/lib/typography.d.ts +3 -3
- package/dist/native/lib/typography.js +3 -3
- package/dist/native/lib/utils.d.ts +3 -3
- package/dist/native/lib/utils.js +3 -3
- package/dist/native/once/confirm.d.ts +2 -2
- package/dist/native/once/confirm.js +2 -2
- package/dist/native/once/error-boundary.d.ts +3 -3
- package/dist/native/once/error-boundary.js +2 -2
- package/dist/native/once/loading-lock.d.ts +3 -3
- package/dist/native/once/loading-lock.js +3 -3
- package/dist/native/once/offline-banner.d.ts +6 -6
- package/dist/native/once/offline-banner.js +5 -5
- package/dist/native/once/snackbar.d.ts +7 -7
- package/dist/native/once/snackbar.js +5 -5
- package/dist/native/styles.css +21 -21
- package/dist/shared/analytics.d.ts +23 -23
- package/dist/shared/button.d.ts +1 -1
- package/dist/shared/form.d.ts +7 -7
- package/dist/shared/form.js +2 -2
- package/dist/tokens/contrast-pairs.d.ts +9 -9
- package/dist/tokens/contrast-pairs.js +10 -10
- package/dist/tokens/index.d.ts +1 -1
- package/dist/tokens/index.js +1 -1
- package/dist/tokens/styles.gen.css +87 -87
- package/dist/tokens/tokens.gen.d.ts +2 -2
- package/dist/tokens/tokens.gen.js +2 -2
- package/dist/tuning/catalog.d.ts +8 -8
- package/dist/tuning/catalog.js +9 -9
- package/dist/tuning/color.d.ts +4 -4
- package/dist/tuning/color.js +5 -5
- package/dist/tuning/css.d.ts +13 -13
- package/dist/tuning/css.js +17 -17
- package/dist/tuning/model.d.ts +11 -11
- package/dist/tuning/model.js +11 -11
- package/dist/tuning/native.d.ts +18 -18
- package/dist/tuning/native.js +18 -18
- package/dist/tuning/schema.d.ts +15 -15
- package/dist/tuning/schema.js +22 -22
- package/dist/tuning/types.d.ts +25 -25
- package/dist/tuning/types.js +6 -6
- package/dist/web/analytics/line-chart.d.ts +6 -6
- package/dist/web/analytics/line-chart.js +3 -3
- package/dist/web/analytics/metric-card.d.ts +6 -6
- package/dist/web/analytics/metric-card.js +5 -5
- package/dist/web/analytics/multi-line-chart.d.ts +23 -23
- package/dist/web/analytics/multi-line-chart.js +33 -33
- package/dist/web/atom/avatar.d.ts +1 -1
- package/dist/web/atom/checkbox.d.ts +6 -6
- package/dist/web/atom/checkbox.js +2 -2
- package/dist/web/atom/colored-value.d.ts +4 -4
- package/dist/web/atom/colored-value.js +4 -4
- package/dist/web/atom/help.d.ts +1 -1
- package/dist/web/atom/segmented-control.d.ts +13 -14
- package/dist/web/atom/segmented-control.js +6 -7
- package/dist/web/atom/select.d.ts +7 -7
- package/dist/web/atom/select.js +5 -5
- package/dist/web/atom/slider.d.ts +3 -3
- package/dist/web/atom/slider.js +2 -2
- package/dist/web/atom/switch.d.ts +3 -3
- package/dist/web/atom/text-area.d.ts +9 -8
- package/dist/web/atom/text-area.js +9 -8
- package/dist/web/atom/text-field.d.ts +5 -4
- package/dist/web/atom/text-field.js +5 -4
- package/dist/web/atom/toggle-chip.d.ts +6 -6
- package/dist/web/atom/toggle-chip.js +4 -4
- package/dist/web/atom/tooltip.d.ts +6 -6
- package/dist/web/atom/tooltip.js +2 -2
- package/dist/web/base/accordion.js +1 -1
- package/dist/web/base/breadcrumb.d.ts +1 -1
- package/dist/web/base/breadcrumb.js +1 -1
- package/dist/web/base/card.d.ts +3 -3
- package/dist/web/base/card.js +2 -2
- package/dist/web/base/dialog.d.ts +1 -1
- package/dist/web/base/dialog.js +1 -1
- package/dist/web/base/form.d.ts +7 -7
- package/dist/web/base/form.js +5 -5
- package/dist/web/base/pagination.d.ts +5 -5
- package/dist/web/base/pagination.js +1 -1
- package/dist/web/base/sheet.d.ts +1 -1
- package/dist/web/base/sheet.js +1 -1
- package/dist/web/base/slider.d.ts +1 -1
- package/dist/web/base/sonner.d.ts +2 -2
- package/dist/web/base/sonner.js +2 -2
- package/dist/web/base/spinner.js +1 -1
- package/dist/web/form/checkbox.d.ts +8 -8
- package/dist/web/form/checkbox.js +3 -3
- package/dist/web/form/radio-group.js +3 -3
- package/dist/web/form/select.js +1 -1
- package/dist/web/form/slider.d.ts +3 -3
- package/dist/web/form/slider.js +3 -3
- package/dist/web/form/switch.d.ts +3 -3
- package/dist/web/form/switch.js +4 -4
- package/dist/web/form/text-area.js +1 -1
- package/dist/web/form/text-input.d.ts +1 -1
- package/dist/web/form/text-input.js +1 -1
- package/dist/web/layout/accordion.d.ts +5 -5
- package/dist/web/layout/accordion.js +2 -2
- package/dist/web/layout/alert-modal.d.ts +11 -11
- package/dist/web/layout/alert-modal.js +7 -7
- package/dist/web/layout/card.d.ts +1 -1
- package/dist/web/layout/information.d.ts +9 -9
- package/dist/web/layout/information.js +7 -7
- package/dist/web/layout/modal.d.ts +1 -1
- package/dist/web/layout/page-frame.d.ts +14 -14
- package/dist/web/layout/page-frame.js +7 -7
- package/dist/web/layout/scroll-area.d.ts +1 -1
- package/dist/web/layout/sheet.d.ts +4 -4
- package/dist/web/layout/simple-table.d.ts +18 -18
- package/dist/web/layout/simple-table.js +2 -2
- package/dist/web/layout/tabs.d.ts +4 -4
- package/dist/web/layout/titled-modal.d.ts +10 -11
- package/dist/web/layout/titled-modal.js +7 -8
- package/dist/web/lib/css-vars.d.ts +6 -6
- package/dist/web/lib/css-vars.js +5 -5
- package/dist/web/lib/dialog.d.ts +4 -4
- package/dist/web/lib/labels.d.ts +8 -8
- package/dist/web/lib/labels.js +8 -8
- package/dist/web/lib/modal-open-focus.d.ts +7 -7
- package/dist/web/lib/modal-open-focus.js +9 -9
- package/dist/web/lib/restore-focus.d.ts +4 -4
- package/dist/web/lib/restore-focus.js +4 -4
- package/dist/web/styles.css +33 -33
- package/package.json +2 -2
|
@@ -6,16 +6,16 @@ import { TriangleAlertIcon } from "lucide-react";
|
|
|
6
6
|
|
|
7
7
|
//#region src/web/layout/alert-modal.tsx
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
9
|
+
* A small modal for confirmation (it has no ×).
|
|
10
10
|
*
|
|
11
|
-
*
|
|
12
|
-
* `danger
|
|
13
|
-
*
|
|
11
|
+
* Overlay surface, p-5, width 400 (fitted to the viewport). A heading (16/24 semibold) and body text (13/20, muted), with right-aligned actions (gap-2, the default Button size).
|
|
12
|
+
* With `danger`, a small state-error icon is added to the left of the heading and the primary action gets the destructive-solid fill.
|
|
13
|
+
* No border and no ring (it floats on the shadow alone, like `DialogContent`). The caller holds the open state (controlled only).
|
|
14
14
|
*
|
|
15
|
-
*
|
|
15
|
+
* While shown it carries `data-modal-open`, so floating persistent UI can be hidden with CSS.
|
|
16
16
|
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
17
|
+
* The initial focus on open goes to the first action only when it was opened by keyboard, and otherwise to the modal body
|
|
18
|
+
* (so that no ring appears on the first button when opened with the mouse; `useModalOpenAutoFocus`).
|
|
19
19
|
*/
|
|
20
20
|
function AlertModal({ open, onOpenChange, tone = "default", title, description, actions, dismissible = true, "data-testid": testId }) {
|
|
21
21
|
const danger = tone === "danger";
|
|
@@ -3,7 +3,7 @@ import React from "react";
|
|
|
3
3
|
//#region src/web/layout/card.d.ts
|
|
4
4
|
export type CardProps = {
|
|
5
5
|
title?: React.ReactNode;
|
|
6
|
-
/**
|
|
6
|
+
/** Make the title a heading (`<h2>` to `<h6>`). Pass it when you want it in the heading hierarchy (omitted means `<div>`). Native has the same name. */
|
|
7
7
|
headingLevel?: CardHeadingLevel;
|
|
8
8
|
description?: React.ReactNode;
|
|
9
9
|
action?: React.ReactNode;
|
|
@@ -15,21 +15,21 @@ type InformationProps = {
|
|
|
15
15
|
fields: InformationField[][];
|
|
16
16
|
wrap?: "no-wrap" | "pre-wrap";
|
|
17
17
|
/**
|
|
18
|
-
*
|
|
19
|
-
*
|
|
18
|
+
* The class of the inner element (a flex container) that lays out the columns. `className` goes on the outer container (`@container`),
|
|
19
|
+
* so use this one when changing the column spacing (`gap-*`) or direction (`flex-*`).
|
|
20
20
|
*/
|
|
21
21
|
columnsClassName?: string;
|
|
22
22
|
} & React.HTMLAttributes<HTMLDivElement>;
|
|
23
23
|
/**
|
|
24
|
-
*
|
|
24
|
+
* A read-only detail view that lays out pairs of a label and a value.
|
|
25
25
|
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
* `w-full`
|
|
26
|
+
* **It assumes the parent has a width.** Whether columns stack vertically or sit side by side is decided by the outer element's container query (`@container`, `@xl:`).
|
|
27
|
+
* A container query cannot measure the outer width from the content (inline-size containment), so inside a **parent whose width is determined by its content**
|
|
28
|
+
* (a `flex` child, `inline-block`, `inline-flex`, a table cell, `grid-cols-[auto_…]`) it collapses to width 0.
|
|
29
|
+
* In such parents, give `className` a concrete width (such as `w-96`; `flex-1` also works for a `flex` child).
|
|
30
|
+
* `w-full` does not work (the parent's width is decided by the content, so there is no basis for the percentage).
|
|
31
31
|
*
|
|
32
|
-
* `className`
|
|
32
|
+
* `className` and the remaining attributes go on the **outer container**.
|
|
33
33
|
*/
|
|
34
34
|
export declare const Information: ({ displayType, highlighted, fields, className, columnsClassName, wrap, ...remain }: InformationProps) => React.JSX.Element;
|
|
35
35
|
//#endregion
|
|
@@ -5,15 +5,15 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
5
5
|
|
|
6
6
|
//#region src/web/layout/information.tsx
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
8
|
+
* A read-only detail view that lays out pairs of a label and a value.
|
|
9
9
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* `w-full`
|
|
10
|
+
* **It assumes the parent has a width.** Whether columns stack vertically or sit side by side is decided by the outer element's container query (`@container`, `@xl:`).
|
|
11
|
+
* A container query cannot measure the outer width from the content (inline-size containment), so inside a **parent whose width is determined by its content**
|
|
12
|
+
* (a `flex` child, `inline-block`, `inline-flex`, a table cell, `grid-cols-[auto_…]`) it collapses to width 0.
|
|
13
|
+
* In such parents, give `className` a concrete width (such as `w-96`; `flex-1` also works for a `flex` child).
|
|
14
|
+
* `w-full` does not work (the parent's width is decided by the content, so there is no basis for the percentage).
|
|
15
15
|
*
|
|
16
|
-
* `className`
|
|
16
|
+
* `className` and the remaining attributes go on the **outer container**.
|
|
17
17
|
*/
|
|
18
18
|
const Information = ({ displayType = "fitContent", highlighted, fields, className, columnsClassName, wrap = "pre-wrap", ...remain }) => {
|
|
19
19
|
return /* @__PURE__ */ jsx("div", {
|
|
@@ -8,7 +8,7 @@ type Props = {
|
|
|
8
8
|
content: React.ReactNode;
|
|
9
9
|
footer: React.ReactNode;
|
|
10
10
|
size?: "md" | "flexible";
|
|
11
|
-
/**
|
|
11
|
+
/** Accessible name of the close button (defaults to the Japanese "Close" label) */
|
|
12
12
|
closeLabel?: string;
|
|
13
13
|
};
|
|
14
14
|
export declare function Modal({ title, description, dialog, content, footer, size, closeLabel }: Props): React.JSX.Element;
|
|
@@ -2,36 +2,36 @@ import React from "react";
|
|
|
2
2
|
//#region src/web/layout/page-frame.d.ts
|
|
3
3
|
export type PageFrameNavItem = {
|
|
4
4
|
label: string;
|
|
5
|
-
/**
|
|
5
|
+
/** The current screen. It gets `aria-current="page"`. */
|
|
6
6
|
current?: boolean;
|
|
7
|
-
/**
|
|
7
|
+
/** A link (`<a>`) when present, otherwise a button (`<button>`; pressing it calls `onSelect`). */
|
|
8
8
|
href?: string;
|
|
9
9
|
onSelect?: () => void;
|
|
10
10
|
};
|
|
11
11
|
export type PageFrameProps = {
|
|
12
|
-
/**
|
|
12
|
+
/** The brand at the left end of the header (text or an element). */
|
|
13
13
|
brand: React.ReactNode;
|
|
14
14
|
nav?: readonly PageFrameNavItem[];
|
|
15
|
-
/**
|
|
15
|
+
/** Accessible name of the nav (to tell landmarks apart when there are several). */
|
|
16
16
|
navLabel?: string;
|
|
17
|
-
/**
|
|
17
|
+
/** The right end of the header (theme toggle, user and so on). */
|
|
18
18
|
trailing?: React.ReactNode;
|
|
19
19
|
children: React.ReactNode;
|
|
20
|
-
/**
|
|
20
|
+
/** The content of the footer. When omitted, a copyright notice with no year (the year is decided by the consumer). */
|
|
21
21
|
footer?: React.ReactNode;
|
|
22
|
-
/**
|
|
22
|
+
/** The maximum width of the header, body and footer content (a Tailwind class). */
|
|
23
23
|
maxWidthClassName?: string;
|
|
24
24
|
className?: string;
|
|
25
25
|
};
|
|
26
26
|
/**
|
|
27
|
-
*
|
|
28
|
-
*
|
|
27
|
+
* The skeleton of a page. It has `header` (banner), `nav`, `main` and `footer` (contentinfo), so the landmarks are complete.
|
|
28
|
+
* Assembling each screen by hand leads to forgetting `main`, a nav with no name, and breaking at narrow widths, so it is placed here once.
|
|
29
29
|
*
|
|
30
|
-
* -
|
|
31
|
-
* Tab
|
|
32
|
-
* -
|
|
33
|
-
* PageFrame
|
|
34
|
-
* -
|
|
30
|
+
* - The DOM order of the header (brand, nav, right end) matches the visual order (one row at a time at narrow widths). Swapping only the look with `order`
|
|
31
|
+
* would make the Tab order differ from the visual order
|
|
32
|
+
* - The body is `flex-1` (the footer sticks to the bottom even on a short screen). The `id` of `main` is `main` (the target a consumer can jump to when placing a skip link.
|
|
33
|
+
* PageFrame itself places no skip link. The `main` landmark satisfies axe's bypass (skipping blocks))
|
|
34
|
+
* - Colours are only `border-border` / `text-muted-foreground`. The tokens switch them for dark
|
|
35
35
|
*/
|
|
36
36
|
export declare function PageFrame({ brand, nav, navLabel, trailing, children, footer, maxWidthClassName, className }: PageFrameProps): React.JSX.Element;
|
|
37
37
|
//#endregion
|
|
@@ -3,14 +3,14 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
|
|
4
4
|
//#region src/web/layout/page-frame.tsx
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
7
|
-
*
|
|
6
|
+
* The skeleton of a page. It has `header` (banner), `nav`, `main` and `footer` (contentinfo), so the landmarks are complete.
|
|
7
|
+
* Assembling each screen by hand leads to forgetting `main`, a nav with no name, and breaking at narrow widths, so it is placed here once.
|
|
8
8
|
*
|
|
9
|
-
* -
|
|
10
|
-
* Tab
|
|
11
|
-
* -
|
|
12
|
-
* PageFrame
|
|
13
|
-
* -
|
|
9
|
+
* - The DOM order of the header (brand, nav, right end) matches the visual order (one row at a time at narrow widths). Swapping only the look with `order`
|
|
10
|
+
* would make the Tab order differ from the visual order
|
|
11
|
+
* - The body is `flex-1` (the footer sticks to the bottom even on a short screen). The `id` of `main` is `main` (the target a consumer can jump to when placing a skip link.
|
|
12
|
+
* PageFrame itself places no skip link. The `main` landmark satisfies axe's bypass (skipping blocks))
|
|
13
|
+
* - Colours are only `border-border` / `text-muted-foreground`. The tokens switch them for dark
|
|
14
14
|
*/
|
|
15
15
|
function PageFrame({ brand, nav = [], navLabel = "メイン", trailing, children, footer, maxWidthClassName = "max-w-[1280px]", className }) {
|
|
16
16
|
return /* @__PURE__ */ jsxs("div", {
|
|
@@ -2,7 +2,7 @@ import { ScrollArea as ScrollArea$1 } from "../base/scroll-area.js";
|
|
|
2
2
|
import { ComponentProps } from "react";
|
|
3
3
|
//#region src/web/layout/scroll-area.d.ts
|
|
4
4
|
type ScrollAreaProps = ComponentProps<typeof ScrollArea$1> & {
|
|
5
|
-
/**
|
|
5
|
+
/** Show the horizontal scrollbar */
|
|
6
6
|
horizontal?: boolean;
|
|
7
7
|
};
|
|
8
8
|
export declare function ScrollArea({ horizontal, children, ...props }: ScrollAreaProps): import("react").JSX.Element;
|
|
@@ -7,13 +7,13 @@ type BaseProps = {
|
|
|
7
7
|
description?: string;
|
|
8
8
|
content: React.ReactNode;
|
|
9
9
|
footer?: React.ReactNode;
|
|
10
|
-
/**
|
|
10
|
+
/** The direction the sheet appears from */
|
|
11
11
|
side?: ComponentProps<typeof SheetContent>["side"];
|
|
12
|
-
/** SheetContent
|
|
12
|
+
/** Class name passed to SheetContent */
|
|
13
13
|
contentClassName?: string;
|
|
14
|
-
/** SheetTitle
|
|
14
|
+
/** Class name passed to SheetTitle */
|
|
15
15
|
titleClassName?: string;
|
|
16
|
-
/**
|
|
16
|
+
/** Accessible name of the close button (defaults to the Japanese "Close" label) */
|
|
17
17
|
closeLabel?: string;
|
|
18
18
|
};
|
|
19
19
|
type DialogModeProps = BaseProps & {
|
|
@@ -2,46 +2,46 @@ import { TableRow } from "../base/table.js";
|
|
|
2
2
|
import React from "react";
|
|
3
3
|
//#region src/web/layout/simple-table.d.ts
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
5
|
+
* A declarative data table with thin rules. Just pass columns / data.
|
|
6
|
+
* The header is a pale frame surface and the row rules are an ultra-thin 1px line (following base/table).
|
|
7
|
+
* Numeric columns are mono + tabular-nums + right-aligned.
|
|
8
8
|
*
|
|
9
|
-
* TanStack
|
|
10
|
-
*
|
|
9
|
+
* It is a different thing from a TanStack-based DataTable (with pagination and selection),
|
|
10
|
+
* and is a lightweight version for short tables that need no sorting or paging (dashboard summaries and the like).
|
|
11
11
|
*/
|
|
12
12
|
export type SimpleColumn<T> = {
|
|
13
|
-
/**
|
|
13
|
+
/** Column key (unique within a row). */
|
|
14
14
|
key: string;
|
|
15
15
|
header: React.ReactNode;
|
|
16
|
-
/**
|
|
16
|
+
/** Alignment of the cell / header (default left). */
|
|
17
17
|
align?: "left" | "right" | "center";
|
|
18
|
-
/**
|
|
18
|
+
/** Monospace + tabular-nums (for numbers and IDs). */
|
|
19
19
|
mono?: boolean;
|
|
20
|
-
/**
|
|
20
|
+
/** Emphasis (font-medium). */
|
|
21
21
|
strong?: boolean;
|
|
22
|
-
/**
|
|
22
|
+
/** Extra class for the cell. */
|
|
23
23
|
cellClassName?: string;
|
|
24
|
-
/**
|
|
24
|
+
/** Extra class for the header. */
|
|
25
25
|
headClassName?: string;
|
|
26
|
-
/**
|
|
26
|
+
/** Cell rendering. When not given, row[key] is shown. */
|
|
27
27
|
render?: (row: T) => React.ReactNode;
|
|
28
28
|
/**
|
|
29
|
-
*
|
|
30
|
-
*
|
|
29
|
+
* Hide the column when narrower than this width (a Tailwind breakpoint). Used to fold away columns that are not important at narrow widths (IDs, supplements and so on)
|
|
30
|
+
* and avoid horizontal scrolling. When not given, the column is always shown.
|
|
31
31
|
*/
|
|
32
32
|
hideBelow?: "sm" | "md" | "lg";
|
|
33
33
|
};
|
|
34
34
|
export declare function SimpleTable<T extends object>({ columns, data, getRowKey, onRowClick, getRowProps, className, wrapperClassName }: {
|
|
35
35
|
columns: SimpleColumn<T>[];
|
|
36
36
|
data: T[];
|
|
37
|
-
/**
|
|
37
|
+
/** Derives the row key. When not given, the index is used. */
|
|
38
38
|
getRowKey?: (row: T, index: number) => string;
|
|
39
39
|
/**
|
|
40
|
-
*
|
|
41
|
-
*
|
|
40
|
+
* Row click (optional). When passed, a row can take focus (tabIndex=0) and can also be pressed with Enter and Space.
|
|
41
|
+
* It does not steal key handling from buttons or links inside the row (it reacts only when the row itself has focus).
|
|
42
42
|
*/
|
|
43
43
|
onRowClick?: (row: T) => void;
|
|
44
|
-
/**
|
|
44
|
+
/** Extra attributes per row (data-* / className and so on). Used for whole-row clicks and for attaching e2e selectors. */
|
|
45
45
|
getRowProps?: (row: T, index: number) => Omit<React.ComponentPropsWithoutRef<typeof TableRow>, "key">;
|
|
46
46
|
className?: string;
|
|
47
47
|
wrapperClassName?: string;
|
|
@@ -4,7 +4,7 @@ import { isValidElement } from "react";
|
|
|
4
4
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
5
|
|
|
6
6
|
//#region src/web/layout/simple-table.tsx
|
|
7
|
-
/** Tailwind
|
|
7
|
+
/** Tailwind picks up class names statically, so they are kept in a table rather than assembled from strings. */
|
|
8
8
|
const hideBelowClass = {
|
|
9
9
|
sm: "hidden sm:table-cell",
|
|
10
10
|
md: "hidden md:table-cell",
|
|
@@ -15,7 +15,7 @@ const alignClass = {
|
|
|
15
15
|
right: "text-right",
|
|
16
16
|
center: "text-center"
|
|
17
17
|
};
|
|
18
|
-
/** `render
|
|
18
|
+
/** The default rendering of a column with no `render`. It shows the row's `key` value only when it is a string, a number or an element. */
|
|
19
19
|
function cellValue(row, key) {
|
|
20
20
|
const value = Reflect.get(row, key);
|
|
21
21
|
if (typeof value === "string" || typeof value === "number" || isValidElement(value)) return value;
|
|
@@ -11,14 +11,14 @@ export type TabsProps = {
|
|
|
11
11
|
tabs: TabType;
|
|
12
12
|
full?: boolean;
|
|
13
13
|
defaultValue?: string;
|
|
14
|
-
/**
|
|
14
|
+
/** Controlled mode: specify when the value is managed from outside */
|
|
15
15
|
value?: string;
|
|
16
16
|
onValueChange?: (value: string) => void;
|
|
17
|
-
/** TabsList
|
|
17
|
+
/** A slot on the right, laid out side by side at the same height as TabsList (used like a toolbar) */
|
|
18
18
|
trailing?: React.ReactNode;
|
|
19
19
|
/**
|
|
20
|
-
* DEV-E2E:
|
|
21
|
-
*
|
|
20
|
+
* DEV-E2E: adds a data-testid of `${testIdPrefix}-${value}` to each trigger.
|
|
21
|
+
* When omitted, no data-testid is output.
|
|
22
22
|
*/
|
|
23
23
|
testIdPrefix?: string;
|
|
24
24
|
};
|
|
@@ -4,29 +4,28 @@ type TitledModalProps = {
|
|
|
4
4
|
open: boolean;
|
|
5
5
|
onOpenChange: (open: boolean) => void;
|
|
6
6
|
title: React$1.ReactNode;
|
|
7
|
-
/**
|
|
7
|
+
/** A description placed at the top of the body. It also serves as the description for assistive technology. */
|
|
8
8
|
description?: React$1.ReactNode;
|
|
9
9
|
children?: React$1.ReactNode;
|
|
10
|
-
/**
|
|
10
|
+
/** Actions laid out right-aligned. When present, a 1px divider is added above them. */
|
|
11
11
|
footer?: React$1.ReactNode;
|
|
12
|
-
/**
|
|
12
|
+
/** Accessible name of the close button. */
|
|
13
13
|
closeLabel?: string;
|
|
14
|
-
/** ×
|
|
14
|
+
/** The content of the × (lucide's X when omitted). */
|
|
15
15
|
closeIcon?: React$1.ReactNode;
|
|
16
16
|
className?: string;
|
|
17
17
|
"data-testid"?: string;
|
|
18
18
|
};
|
|
19
19
|
/**
|
|
20
|
-
*
|
|
20
|
+
* A larger modal with a heading and a ×.
|
|
21
21
|
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
22
|
+
* Overlay surface (no border or ring, shadow only), width 560. A thin 1px divider under the heading (16/24 semibold) and ×, the body is p-5,
|
|
23
|
+
* and if there is a footer, a divider is drawn above it and the actions are laid out right-aligned. The caller holds the open state (controlled only).
|
|
24
24
|
*
|
|
25
|
-
*
|
|
26
|
-
* (`body:has([data-modal-open])`)。
|
|
25
|
+
* While shown it carries `data-modal-open`, so floating persistent UI can be hidden with CSS
|
|
27
26
|
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
27
|
+
* The initial focus on open goes to the first action only when it was opened by keyboard, and otherwise to the modal body
|
|
28
|
+
* (so that no ring appears on the first button when opened with the mouse; `useModalOpenAutoFocus`).
|
|
30
29
|
*/
|
|
31
30
|
export declare function TitledModal({ open, onOpenChange, title, description, children, footer, closeLabel, closeIcon, className, "data-testid": testId }: TitledModalProps): React$1.JSX.Element;
|
|
32
31
|
//#endregion
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { CLOSE_LABEL } from "../lib/labels.js";
|
|
2
1
|
import { cn } from "../lib/utils.js";
|
|
2
|
+
import { CLOSE_LABEL } from "../lib/labels.js";
|
|
3
3
|
import { Dialog, DialogClose, DialogContent, DialogDescription, DialogTitle } from "../base/dialog.js";
|
|
4
4
|
import { useModalOpenAutoFocus } from "../lib/modal-open-focus.js";
|
|
5
5
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -7,16 +7,15 @@ import { XIcon } from "lucide-react";
|
|
|
7
7
|
|
|
8
8
|
//#region src/web/layout/titled-modal.tsx
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
10
|
+
* A larger modal with a heading and a ×.
|
|
11
11
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
12
|
+
* Overlay surface (no border or ring, shadow only), width 560. A thin 1px divider under the heading (16/24 semibold) and ×, the body is p-5,
|
|
13
|
+
* and if there is a footer, a divider is drawn above it and the actions are laid out right-aligned. The caller holds the open state (controlled only).
|
|
14
14
|
*
|
|
15
|
-
*
|
|
16
|
-
* (`body:has([data-modal-open])`)。
|
|
15
|
+
* While shown it carries `data-modal-open`, so floating persistent UI can be hidden with CSS
|
|
17
16
|
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
17
|
+
* The initial focus on open goes to the first action only when it was opened by keyboard, and otherwise to the modal body
|
|
18
|
+
* (so that no ring appears on the first button when opened with the mouse; `useModalOpenAutoFocus`).
|
|
20
19
|
*/
|
|
21
20
|
function TitledModal({ open, onOpenChange, title, description, children, footer, closeLabel = CLOSE_LABEL, closeIcon, className, "data-testid": testId }) {
|
|
22
21
|
const { contentRef, onOpenAutoFocus } = useModalOpenAutoFocus();
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { CSSProperties } from "react";
|
|
2
2
|
//#region src/web/lib/css-vars.d.ts
|
|
3
|
-
/** CSS
|
|
3
|
+
/** A style part that holds only CSS custom properties (`--foo`). */
|
|
4
4
|
export type CssVars = Record<`--${string}`, string | number>;
|
|
5
5
|
/**
|
|
6
|
-
* CSS
|
|
6
|
+
* Turns CSS custom properties into something that can be passed to `style`.
|
|
7
7
|
*
|
|
8
|
-
* `CSSProperties`
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* `overrides`
|
|
8
|
+
* `CSSProperties` does not know about `--foo`, so passing an object literal directly makes tsc
|
|
9
|
+
* reject it as an excess property. Silencing it with `as CSSProperties` removes the type check, so
|
|
10
|
+
* it is received with template-literal-type keys and returned as `CSSProperties`.
|
|
11
|
+
* `overrides` wins (a `style` passed by the caller can override the default variables).
|
|
12
12
|
*/
|
|
13
13
|
export declare function cssVars(vars: CssVars, overrides?: CSSProperties): CSSProperties;
|
|
14
14
|
//#endregion
|
package/dist/web/lib/css-vars.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
//#region src/web/lib/css-vars.ts
|
|
2
2
|
/**
|
|
3
|
-
* CSS
|
|
3
|
+
* Turns CSS custom properties into something that can be passed to `style`.
|
|
4
4
|
*
|
|
5
|
-
* `CSSProperties`
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* `overrides`
|
|
5
|
+
* `CSSProperties` does not know about `--foo`, so passing an object literal directly makes tsc
|
|
6
|
+
* reject it as an excess property. Silencing it with `as CSSProperties` removes the type check, so
|
|
7
|
+
* it is received with template-literal-type keys and returned as `CSSProperties`.
|
|
8
|
+
* `overrides` wins (a `style` passed by the caller can override the default variables).
|
|
9
9
|
*/
|
|
10
10
|
function cssVars(vars, overrides) {
|
|
11
11
|
return {
|
package/dist/web/lib/dialog.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
//#region src/web/lib/dialog.d.ts
|
|
2
2
|
/**
|
|
3
|
-
* `Modal` / `Sheet`
|
|
4
|
-
* `useState
|
|
5
|
-
*
|
|
3
|
+
* The shape (a structural type) in which `Modal` / `Sheet` receive the open/close state.
|
|
4
|
+
* You can build it yourself with `useState`, or pass the return value of an app-side hook with an unsaved-changes guard as is
|
|
5
|
+
* (love3 depends on neither i18n nor forms, so it does not include the hook itself).
|
|
6
6
|
*/
|
|
7
7
|
export type DialogController = {
|
|
8
8
|
isOpen: boolean;
|
|
9
9
|
close: () => void;
|
|
10
|
-
/**
|
|
10
|
+
/** Decides whether a click outside may close it. When you want to insert a confirmation, handle it here (by default it is treated the same as `close`) */
|
|
11
11
|
onOutsideClick: () => void;
|
|
12
12
|
};
|
|
13
13
|
//#endregion
|
package/dist/web/lib/labels.d.ts
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
//#region src/web/lib/labels.d.ts
|
|
2
|
-
/**
|
|
2
|
+
/** Close button (Dialog, Sheet, TitledModal) */
|
|
3
3
|
export declare const CLOSE_LABEL = "閉じる";
|
|
4
|
-
/**
|
|
4
|
+
/** Help trigger (atom/help, FormLabel of base/form) */
|
|
5
5
|
export declare const HELP_LABEL = "ヘルプ";
|
|
6
|
-
/**
|
|
6
|
+
/** Loading indicator (Spinner) */
|
|
7
7
|
export declare const LOADING_LABEL = "読み込み中";
|
|
8
|
-
/**
|
|
8
|
+
/** The pagination nav and the buttons inside it */
|
|
9
9
|
export declare const PAGINATION_LABEL = "ページネーション";
|
|
10
10
|
export declare const PREVIOUS_PAGE_LABEL = "前のページへ";
|
|
11
11
|
export declare const NEXT_PAGE_LABEL = "次のページへ";
|
|
12
|
-
/**
|
|
12
|
+
/** Page numbers that are omitted in the middle */
|
|
13
13
|
export declare const MORE_PAGES_LABEL = "他のページ";
|
|
14
|
-
/**
|
|
14
|
+
/** The breadcrumb nav and the omitted levels in the middle */
|
|
15
15
|
export declare const BREADCRUMB_LABEL = "パンくずリスト";
|
|
16
16
|
export declare const MORE_LEVELS_LABEL = "他の階層";
|
|
17
|
-
/**
|
|
17
|
+
/** Column names of the line chart's table alternative (a table hidden for screen readers), and the default name */
|
|
18
18
|
export declare const LINE_CHART_TABLE_SERIES_LABEL = "系列";
|
|
19
19
|
export declare const LINE_CHART_TABLE_POINT_LABEL = "見出し";
|
|
20
20
|
export declare const LINE_CHART_TABLE_VALUE_LABEL = "値";
|
|
21
21
|
export declare const LINE_CHART_DEFAULT_LABEL = "折れ線チャート";
|
|
22
22
|
export declare const LINE_CHART_SINGLE_SERIES_LABEL = "値";
|
|
23
23
|
export declare const LINE_CHART_EMPTY_TEXT = "データがありません";
|
|
24
|
-
/**
|
|
24
|
+
/** Notes added to the table for screen readers (when non-numeric points were dropped, or when many points were sampled) */
|
|
25
25
|
export declare const lineChartTableDropped: (count: number) => string;
|
|
26
26
|
export declare const lineChartTableThinned: (shown: number, total: number) => string;
|
|
27
27
|
//#endregion
|
package/dist/web/lib/labels.js
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
//#region src/web/lib/labels.ts
|
|
2
|
-
/**
|
|
2
|
+
/** Close button (Dialog, Sheet, TitledModal) */
|
|
3
3
|
const CLOSE_LABEL = "閉じる";
|
|
4
|
-
/**
|
|
4
|
+
/** Help trigger (atom/help, FormLabel of base/form) */
|
|
5
5
|
const HELP_LABEL = "ヘルプ";
|
|
6
|
-
/**
|
|
6
|
+
/** Loading indicator (Spinner) */
|
|
7
7
|
const LOADING_LABEL = "読み込み中";
|
|
8
|
-
/**
|
|
8
|
+
/** The pagination nav and the buttons inside it */
|
|
9
9
|
const PAGINATION_LABEL = "ページネーション";
|
|
10
10
|
const PREVIOUS_PAGE_LABEL = "前のページへ";
|
|
11
11
|
const NEXT_PAGE_LABEL = "次のページへ";
|
|
12
|
-
/**
|
|
12
|
+
/** Page numbers that are omitted in the middle */
|
|
13
13
|
const MORE_PAGES_LABEL = "他のページ";
|
|
14
|
-
/**
|
|
14
|
+
/** The breadcrumb nav and the omitted levels in the middle */
|
|
15
15
|
const BREADCRUMB_LABEL = "パンくずリスト";
|
|
16
16
|
const MORE_LEVELS_LABEL = "他の階層";
|
|
17
|
-
/**
|
|
17
|
+
/** Column names of the line chart's table alternative (a table hidden for screen readers), and the default name */
|
|
18
18
|
const LINE_CHART_TABLE_SERIES_LABEL = "系列";
|
|
19
19
|
const LINE_CHART_TABLE_POINT_LABEL = "見出し";
|
|
20
20
|
const LINE_CHART_TABLE_VALUE_LABEL = "値";
|
|
21
21
|
const LINE_CHART_DEFAULT_LABEL = "折れ線チャート";
|
|
22
22
|
const LINE_CHART_SINGLE_SERIES_LABEL = "値";
|
|
23
23
|
const LINE_CHART_EMPTY_TEXT = "データがありません";
|
|
24
|
-
/**
|
|
24
|
+
/** Notes added to the table for screen readers (when non-numeric points were dropped, or when many points were sampled) */
|
|
25
25
|
const lineChartTableDropped = (count) => `数でない値の点 ${count.toString()} 件は除いています。`;
|
|
26
26
|
const lineChartTableThinned = (shown, total) => `点が多いので、${total.toString()} 点のうち ${shown.toString()} 点を等間隔に抜き出しています。`;
|
|
27
27
|
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
//#region src/web/lib/modal-open-focus.d.ts
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Changes where the initial focus goes when a modal opens, depending on how it was opened.
|
|
4
4
|
*
|
|
5
|
-
* -
|
|
6
|
-
* -
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* Esc
|
|
5
|
+
* - Opened by keyboard: put it on the first action (a button), as Radix does by default. The focus ring also shows
|
|
6
|
+
* - Opened by pointer / opened with no interaction (something shown at start-up, etc.): put it on the modal body.
|
|
7
|
+
* No ring appears on the first button (WebKit applies `:focus-visible` even to script-driven focus,
|
|
8
|
+
* so putting it on the button would show a ring). Focus is inside the modal, so Tab moves to the first action,
|
|
9
|
+
* Esc closes it, and assistive technology announces it as a dialog
|
|
10
10
|
*
|
|
11
|
-
*
|
|
11
|
+
* Pass the returned `contentRef` and `onOpenAutoFocus` to DialogContent. Give the body `outline-none`.
|
|
12
12
|
*/
|
|
13
13
|
export declare function useModalOpenAutoFocus(): {
|
|
14
14
|
contentRef: import("react").RefObject<HTMLDivElement | null>;
|
|
@@ -4,8 +4,8 @@ import { useCallback, useRef } from "react";
|
|
|
4
4
|
let lastModality = "unknown";
|
|
5
5
|
let listening = false;
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
8
|
-
* capture
|
|
7
|
+
* Remembers whether the previous action was by keyboard or by pointer (attached to the document only once).
|
|
8
|
+
* It listens in the capture phase, so it is not missed even if stopPropagation is called along the way.
|
|
9
9
|
*/
|
|
10
10
|
function listenModality() {
|
|
11
11
|
if (listening || typeof document === "undefined") return;
|
|
@@ -17,15 +17,15 @@ function listenModality() {
|
|
|
17
17
|
document.addEventListener("pointerdown", () => lastModality = "pointer", true);
|
|
18
18
|
}
|
|
19
19
|
/**
|
|
20
|
-
*
|
|
20
|
+
* Changes where the initial focus goes when a modal opens, depending on how it was opened.
|
|
21
21
|
*
|
|
22
|
-
* -
|
|
23
|
-
* -
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* Esc
|
|
22
|
+
* - Opened by keyboard: put it on the first action (a button), as Radix does by default. The focus ring also shows
|
|
23
|
+
* - Opened by pointer / opened with no interaction (something shown at start-up, etc.): put it on the modal body.
|
|
24
|
+
* No ring appears on the first button (WebKit applies `:focus-visible` even to script-driven focus,
|
|
25
|
+
* so putting it on the button would show a ring). Focus is inside the modal, so Tab moves to the first action,
|
|
26
|
+
* Esc closes it, and assistive technology announces it as a dialog
|
|
27
27
|
*
|
|
28
|
-
*
|
|
28
|
+
* Pass the returned `contentRef` and `onOpenAutoFocus` to DialogContent. Give the body `outline-none`.
|
|
29
29
|
*/
|
|
30
30
|
function useModalOpenAutoFocus() {
|
|
31
31
|
listenModality();
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
//#region src/web/lib/restore-focus.d.ts
|
|
2
2
|
/**
|
|
3
|
-
* Radix
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
3
|
+
* Radix's Dialog returns focus after closing only to `DialogTrigger`. love3's Modal, Sheet and AlertModal keep `open` in state
|
|
4
|
+
* (there is no trigger), so as is, focus falls to `body` (keyboard and assistive-technology users lose track of where they opened it).
|
|
5
|
+
* It remembers the element that had focus when the dialog opened and returns focus there on close. When there is no remembered element, such as when it was opened with `DialogTrigger`, or
|
|
6
|
+
* when the caller called `preventDefault`, it does nothing (it leaves it to Radix's default behaviour).
|
|
7
7
|
*/
|
|
8
8
|
export declare function useRestoreFocus(onOpenAutoFocus: ((event: Event) => void) | undefined, onCloseAutoFocus: ((event: Event) => void) | undefined): {
|
|
9
9
|
onOpenAutoFocus: (event: Event) => void;
|