@zhin.js/console-ui 0.0.0-stage → 1.1.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 +54 -0
- package/LICENSE +21 -0
- package/README.md +195 -2
- package/audit/index.mjs +21 -0
- package/audit/layout-audit.mjs +492 -0
- package/audit/mount-page.jsx +90 -0
- package/audit/plugin-pages.mjs +186 -0
- package/dist/cn.d.ts +4 -0
- package/dist/cn.js +6 -0
- package/dist/components/BrandMark.d.ts +16 -0
- package/dist/components/BrandMark.js +21 -0
- package/dist/components/InfoHint.d.ts +12 -0
- package/dist/components/InfoHint.js +13 -0
- package/dist/components/PageHeader.d.ts +18 -0
- package/dist/components/PageHeader.js +11 -0
- package/dist/components/PageShell.d.ts +26 -0
- package/dist/components/PageShell.js +10 -0
- package/dist/components/RefreshControl.d.ts +28 -0
- package/dist/components/RefreshControl.js +68 -0
- package/dist/components/StatCard.d.ts +41 -0
- package/dist/components/StatCard.js +53 -0
- package/dist/components/StatusBadge.d.ts +14 -0
- package/dist/components/StatusBadge.js +19 -0
- package/dist/components/actions.d.ts +53 -0
- package/dist/components/actions.js +50 -0
- package/dist/components/code.d.ts +11 -0
- package/dist/components/code.js +10 -0
- package/dist/components/confirm-dialog-model.d.ts +9 -0
- package/dist/components/confirm-dialog-model.js +20 -0
- package/dist/components/confirm-dialog.d.ts +32 -0
- package/dist/components/confirm-dialog.js +72 -0
- package/dist/components/content-blocks.d.ts +141 -0
- package/dist/components/content-blocks.js +77 -0
- package/dist/components/empty-illustrations.d.ts +15 -0
- package/dist/components/empty-illustrations.js +36 -0
- package/dist/components/empty-state.d.ts +35 -0
- package/dist/components/empty-state.js +43 -0
- package/dist/components/error-alert.d.ts +15 -0
- package/dist/components/error-alert.js +23 -0
- package/dist/components/icon.d.ts +11 -0
- package/dist/components/icon.js +8 -0
- package/dist/components/layout.d.ts +38 -0
- package/dist/components/layout.js +28 -0
- package/dist/components/page-chrome.d.ts +53 -0
- package/dist/components/page-chrome.js +66 -0
- package/dist/components/refresh-control-model.d.ts +9 -0
- package/dist/components/refresh-control-model.js +26 -0
- package/dist/components/ui/accordion.d.ts +7 -0
- package/dist/components/ui/accordion.js +15 -0
- package/dist/components/ui/alert.d.ts +8 -0
- package/dist/components/ui/alert.js +24 -0
- package/dist/components/ui/badge.d.ts +9 -0
- package/dist/components/ui/badge.js +30 -0
- package/dist/components/ui/button.d.ts +20 -0
- package/dist/components/ui/button.js +52 -0
- package/dist/components/ui/card.d.ts +17 -0
- package/dist/components/ui/card.js +17 -0
- package/dist/components/ui/checkbox.d.ts +4 -0
- package/dist/components/ui/checkbox.js +10 -0
- package/dist/components/ui/control-variant.d.ts +10 -0
- package/dist/components/ui/control-variant.js +6 -0
- package/dist/components/ui/date-field-model.d.ts +39 -0
- package/dist/components/ui/date-field-model.js +105 -0
- package/dist/components/ui/date-field.d.ts +33 -0
- package/dist/components/ui/date-field.js +161 -0
- package/dist/components/ui/dialog.d.ts +24 -0
- package/dist/components/ui/dialog.js +27 -0
- package/dist/components/ui/dropdown-menu.d.ts +19 -0
- package/dist/components/ui/dropdown-menu.js +26 -0
- package/dist/components/ui/input.d.ts +8 -0
- package/dist/components/ui/input.js +9 -0
- package/dist/components/ui/list-item-button.d.ts +10 -0
- package/dist/components/ui/list-item-button.js +6 -0
- package/dist/components/ui/popover.d.ts +6 -0
- package/dist/components/ui/popover.js +9 -0
- package/dist/components/ui/radio-group.d.ts +5 -0
- package/dist/components/ui/radio-group.js +10 -0
- package/dist/components/ui/scroll-area.d.ts +5 -0
- package/dist/components/ui/scroll-area.js +13 -0
- package/dist/components/ui/searchable-select-model.d.ts +29 -0
- package/dist/components/ui/searchable-select-model.js +38 -0
- package/dist/components/ui/searchable-select.d.ts +26 -0
- package/dist/components/ui/searchable-select.js +85 -0
- package/dist/components/ui/select.d.ts +29 -0
- package/dist/components/ui/select.js +39 -0
- package/dist/components/ui/separator.d.ts +4 -0
- package/dist/components/ui/separator.js +11 -0
- package/dist/components/ui/sheet.d.ts +27 -0
- package/dist/components/ui/sheet.js +27 -0
- package/dist/components/ui/skeleton.d.ts +3 -0
- package/dist/components/ui/skeleton.js +6 -0
- package/dist/components/ui/switch.d.ts +4 -0
- package/dist/components/ui/switch.js +8 -0
- package/dist/components/ui/table.d.ts +27 -0
- package/dist/components/ui/table.js +47 -0
- package/dist/components/ui/tabs.d.ts +7 -0
- package/dist/components/ui/tabs.js +13 -0
- package/dist/components/ui/textarea.d.ts +8 -0
- package/dist/components/ui/textarea.js +9 -0
- package/dist/components/ui/tooltip.d.ts +7 -0
- package/dist/components/ui/tooltip.js +11 -0
- package/dist/components/use-container-width.d.ts +13 -0
- package/dist/components/use-container-width.js +30 -0
- package/dist/custom-media.css +13 -0
- package/dist/exports.json +178 -0
- package/dist/i18n/index.d.ts +27 -0
- package/dist/i18n/index.js +33 -0
- package/dist/i18n/messages.d.ts +55 -0
- package/dist/i18n/messages.js +110 -0
- package/dist/index.d.ts +56 -0
- package/dist/index.js +55 -0
- package/dist/scale.json +643 -0
- package/dist/shared-module.d.ts +28 -0
- package/dist/shared-module.js +24 -0
- package/dist/styles.css +3399 -0
- package/dist/theme.css +469 -0
- package/dist/tokens.css +652 -0
- package/dist/version.d.ts +6 -0
- package/dist/version.js +2 -0
- package/lint/eslint-plugin.mjs +128 -0
- package/lint/stylelint-config.mjs +43 -0
- package/lint/stylelint-plugin.mjs +195 -0
- package/lint/tailwind-classes.mjs +121 -0
- package/package.json +103 -3
- package/tokens/color.mjs +104 -0
- package/tokens/colors.css +220 -0
- package/tokens/generate.mjs +288 -0
- package/tokens/scale.mjs +137 -0
- package/tokens/tokens.mjs +362 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Icon rules of @zhin.js/console-ui (ADR 0063 D30, zhinjs/console#125): lucide icons only, one
|
|
3
|
+
* stroke width everywhere, 16px inside controls and 18px in navigation. Icons sit directly on the
|
|
4
|
+
* surface; lists, ⌘K and toolbars never put them in a tinted square.
|
|
5
|
+
*/
|
|
6
|
+
export const CONSOLE_ICON_STROKE_WIDTH = 1.75;
|
|
7
|
+
/** Icon sizes in px: `control` inside buttons, inputs, menus and badges; `nav` in navigation. */
|
|
8
|
+
export const CONSOLE_ICON_SIZE = Object.freeze({ control: 16, nav: 18 });
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { type HTMLAttributes, type ReactNode } from 'react';
|
|
2
|
+
export interface SectionProps extends Omit<HTMLAttributes<HTMLElement>, 'title'> {
|
|
3
|
+
title?: ReactNode;
|
|
4
|
+
/** Said once, under the title (D15 第 2 条). */
|
|
5
|
+
description?: ReactNode;
|
|
6
|
+
actions?: ReactNode;
|
|
7
|
+
children?: ReactNode;
|
|
8
|
+
className?: string;
|
|
9
|
+
}
|
|
10
|
+
/** A content block of a page: title, one description, actions, then its content (stack gap). */
|
|
11
|
+
export declare function Section({ title, description, actions, children, className, ...rest }: SectionProps): import("react").JSX.Element;
|
|
12
|
+
export interface GridProps extends Omit<HTMLAttributes<HTMLDivElement>, 'children'> {
|
|
13
|
+
children?: ReactNode;
|
|
14
|
+
/** Narrowest column before the grid drops a column; default 16rem. */
|
|
15
|
+
min?: string;
|
|
16
|
+
className?: string;
|
|
17
|
+
/** Accessible name when the grid is a landmark of its own. */
|
|
18
|
+
label?: string;
|
|
19
|
+
}
|
|
20
|
+
/** Card grid: `repeat(auto-fit, minmax(min(100%, min), 1fr))` with the grid gap (D18 第 3 条). */
|
|
21
|
+
export declare function Grid({ children, min, className, label, style: ownStyle, ...rest }: GridProps): import("react").JSX.Element;
|
|
22
|
+
export interface ListDetailProps {
|
|
23
|
+
/** The list (usually a Table). */
|
|
24
|
+
list: ReactNode;
|
|
25
|
+
/** Detail of the selected item; `null` / `undefined` when nothing is selected. */
|
|
26
|
+
detail?: ReactNode;
|
|
27
|
+
/** Title of the detail panel (used by the sheet on narrow containers). */
|
|
28
|
+
detailTitle?: ReactNode;
|
|
29
|
+
/** Called when the user closes the detail sheet on narrow containers. */
|
|
30
|
+
onDetailClose?: () => void;
|
|
31
|
+
className?: string;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* List + detail (ADR 0063 D18 第 5 条): from 90rem of container width the detail sits in a right
|
|
35
|
+
* column next to the list; below that it opens in a side sheet. Pages must not build this
|
|
36
|
+
* themselves.
|
|
37
|
+
*/
|
|
38
|
+
export declare function ListDetail({ list, detail, detailTitle, onDetailClose, className }: ListDetailProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useRef } from 'react';
|
|
3
|
+
import { cn } from '../cn.js';
|
|
4
|
+
import { useConsoleUiI18n } from '../i18n/index.js';
|
|
5
|
+
import { Sheet, SheetBody, SheetContent, SheetHeader, SheetTitle } from './ui/sheet.js';
|
|
6
|
+
import { CONSOLE_BREAKPOINTS_REM, useContainerAtLeast } from './use-container-width.js';
|
|
7
|
+
/** A content block of a page: title, one description, actions, then its content (stack gap). */
|
|
8
|
+
export function Section({ title, description, actions, children, className, ...rest }) {
|
|
9
|
+
return (_jsxs("section", { className: cn('console-section', className), "data-slot": "section", ...rest, children: [title != null || description != null || actions != null ? (_jsxs("div", { className: "console-section-header", children: [_jsxs("div", { className: "console-section-heading", children: [title != null ? _jsx("h2", { className: "console-section-title", children: title }) : null, description != null ? _jsx("p", { className: "console-section-description", children: description }) : null] }), actions != null ? _jsx("div", { className: "console-page-actions", children: actions }) : null] })) : null, children] }));
|
|
10
|
+
}
|
|
11
|
+
/** Card grid: `repeat(auto-fit, minmax(min(100%, min), 1fr))` with the grid gap (D18 第 3 条). */
|
|
12
|
+
export function Grid({ children, min, className, label, style: ownStyle, ...rest }) {
|
|
13
|
+
const style = min ? { ...ownStyle, '--grid-min': min } : ownStyle;
|
|
14
|
+
return (_jsx("div", { className: cn('console-grid', className), style: style, "data-slot": "grid", role: label ? 'group' : undefined, "aria-label": label, ...rest, children: children }));
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* List + detail (ADR 0063 D18 第 5 条): from 90rem of container width the detail sits in a right
|
|
18
|
+
* column next to the list; below that it opens in a side sheet. Pages must not build this
|
|
19
|
+
* themselves.
|
|
20
|
+
*/
|
|
21
|
+
export function ListDetail({ list, detail, detailTitle, onDetailClose, className }) {
|
|
22
|
+
const i18n = useConsoleUiI18n();
|
|
23
|
+
const ref = useRef(null);
|
|
24
|
+
const split = useContainerAtLeast(ref, CONSOLE_BREAKPOINTS_REM.xl) ?? false;
|
|
25
|
+
const hasDetail = detail != null;
|
|
26
|
+
return (_jsxs("div", { ref: ref, className: cn('console-list-detail-frame', className), "data-slot": "list-detail", children: [_jsxs("div", { className: "console-list-detail", "data-split": split && hasDetail ? 'true' : undefined, children: [_jsx("div", { className: "console-list-detail-list", children: list }), split && hasDetail ? (_jsx("aside", { className: "console-list-detail-aside", "aria-label": typeof detailTitle === 'string' ? detailTitle : i18n.t('listDetail.detail'), children: detail })) : null] }), !split ? (_jsx(Sheet, { open: hasDetail, onOpenChange: open => { if (!open)
|
|
27
|
+
onDetailClose?.(); }, children: _jsxs(SheetContent, { side: "right", children: [_jsx(SheetHeader, { children: _jsx(SheetTitle, { children: detailTitle ?? i18n.t('listDetail.detail') }) }), _jsx(SheetBody, { children: detail })] }) })) : null] }));
|
|
28
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import { type RefreshControlProps } from './RefreshControl.js';
|
|
3
|
+
import { type PageAction } from './actions.js';
|
|
4
|
+
/**
|
|
5
|
+
* Page chrome a page hands to the shell (ADR 0063 决策 2): the shell places the header actions and
|
|
6
|
+
* the refresh control; the page itself renders only its content.
|
|
7
|
+
*/
|
|
8
|
+
export interface PageChrome {
|
|
9
|
+
/**
|
|
10
|
+
* Page title the content knows better than the route (e.g. a localized blueprint title). A shell
|
|
11
|
+
* that already has a title area (the plugin detail page) may keep its own and use this as the tab label.
|
|
12
|
+
*/
|
|
13
|
+
readonly title?: string;
|
|
14
|
+
/** One-line description under the title. */
|
|
15
|
+
readonly description?: string;
|
|
16
|
+
/** Header actions (buttons, menus). */
|
|
17
|
+
readonly actions?: ReactNode;
|
|
18
|
+
/** Shows a RefreshControl in the header. */
|
|
19
|
+
readonly refresh?: RefreshControlProps;
|
|
20
|
+
/** Labelled actions: buttons on wide headers, folded into 「更多」 below 40rem (D18 第 7 条). */
|
|
21
|
+
readonly menuActions?: readonly PageAction[];
|
|
22
|
+
/** Actions that always live in the 「更多」 menu. */
|
|
23
|
+
readonly moreActions?: readonly PageAction[];
|
|
24
|
+
}
|
|
25
|
+
export interface PageChromeStore {
|
|
26
|
+
get(): PageChrome | undefined;
|
|
27
|
+
/** Replaces the chrome; returns a release function that clears it only if it is still the latest. */
|
|
28
|
+
set(chrome: PageChrome): () => void;
|
|
29
|
+
subscribe(listener: () => void): () => void;
|
|
30
|
+
}
|
|
31
|
+
/** One store per mounted page slot; the shell creates it and passes it to {@link PageChromeProvider}. */
|
|
32
|
+
export declare function createPageChromeStore(): PageChromeStore;
|
|
33
|
+
export interface PageChromeProviderProps {
|
|
34
|
+
/** Store owned by the shell; omit to let the provider create one. */
|
|
35
|
+
readonly store?: PageChromeStore;
|
|
36
|
+
readonly children?: ReactNode;
|
|
37
|
+
}
|
|
38
|
+
/** Wraps a page slot so pages inside can call {@link usePageChrome}. */
|
|
39
|
+
export declare function PageChromeProvider({ store, children }: PageChromeProviderProps): import("react").JSX.Element;
|
|
40
|
+
/**
|
|
41
|
+
* Hands header actions and the refresh control to the shell. Returns `true` when a shell is
|
|
42
|
+
* listening; `false` means the page renders outside a shell (e.g. an older Console) and may draw
|
|
43
|
+
* the controls itself.
|
|
44
|
+
*/
|
|
45
|
+
export declare function usePageChrome(chrome: PageChrome): boolean;
|
|
46
|
+
/** The chrome the current page registered; for the shell. */
|
|
47
|
+
export declare function usePageChromeState(store?: PageChromeStore): PageChrome | undefined;
|
|
48
|
+
export interface PageChromeActionsProps {
|
|
49
|
+
readonly store?: PageChromeStore;
|
|
50
|
+
readonly className?: string;
|
|
51
|
+
}
|
|
52
|
+
/** Renders the registered refresh control and actions; the shell puts it into `PageHeader.actions`. */
|
|
53
|
+
export declare function PageChromeActions({ store, className }: PageChromeActionsProps): import("react").JSX.Element | null;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useContext, useEffect, useMemo, useSyncExternalStore } from 'react';
|
|
3
|
+
import { cn } from '../cn.js';
|
|
4
|
+
import { RefreshControl } from './RefreshControl.js';
|
|
5
|
+
import { PageActions } from './actions.js';
|
|
6
|
+
/** One store per mounted page slot; the shell creates it and passes it to {@link PageChromeProvider}. */
|
|
7
|
+
export function createPageChromeStore() {
|
|
8
|
+
let current;
|
|
9
|
+
const listeners = new Set();
|
|
10
|
+
const emit = () => { for (const listener of [...listeners])
|
|
11
|
+
listener(); };
|
|
12
|
+
return {
|
|
13
|
+
get: () => current?.chrome,
|
|
14
|
+
set(chrome) {
|
|
15
|
+
const token = {};
|
|
16
|
+
current = { token, chrome };
|
|
17
|
+
emit();
|
|
18
|
+
return () => {
|
|
19
|
+
if (current?.token !== token)
|
|
20
|
+
return;
|
|
21
|
+
current = undefined;
|
|
22
|
+
emit();
|
|
23
|
+
};
|
|
24
|
+
},
|
|
25
|
+
subscribe(listener) {
|
|
26
|
+
listeners.add(listener);
|
|
27
|
+
return () => { listeners.delete(listener); };
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
const PageChromeContext = createContext(null);
|
|
32
|
+
/** Wraps a page slot so pages inside can call {@link usePageChrome}. */
|
|
33
|
+
export function PageChromeProvider({ store, children }) {
|
|
34
|
+
const value = useMemo(() => store ?? createPageChromeStore(), [store]);
|
|
35
|
+
return _jsx(PageChromeContext.Provider, { value: value, children: children });
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Hands header actions and the refresh control to the shell. Returns `true` when a shell is
|
|
39
|
+
* listening; `false` means the page renders outside a shell (e.g. an older Console) and may draw
|
|
40
|
+
* the controls itself.
|
|
41
|
+
*/
|
|
42
|
+
export function usePageChrome(chrome) {
|
|
43
|
+
const store = useContext(PageChromeContext);
|
|
44
|
+
const { title, description, actions, refresh, menuActions, moreActions } = chrome;
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
if (!store)
|
|
47
|
+
return;
|
|
48
|
+
return store.set({ title, description, actions, refresh, menuActions, moreActions });
|
|
49
|
+
}, [store, title, description, actions, refresh, menuActions, moreActions]);
|
|
50
|
+
return store !== null;
|
|
51
|
+
}
|
|
52
|
+
/** The chrome the current page registered; for the shell. */
|
|
53
|
+
export function usePageChromeState(store) {
|
|
54
|
+
const contextStore = useContext(PageChromeContext);
|
|
55
|
+
const target = store ?? contextStore;
|
|
56
|
+
return useSyncExternalStore(target?.subscribe ?? noopSubscribe, target?.get ?? noopGet, target?.get ?? noopGet);
|
|
57
|
+
}
|
|
58
|
+
const noopSubscribe = () => () => { };
|
|
59
|
+
const noopGet = () => undefined;
|
|
60
|
+
/** Renders the registered refresh control and actions; the shell puts it into `PageHeader.actions`. */
|
|
61
|
+
export function PageChromeActions({ store, className }) {
|
|
62
|
+
const chrome = usePageChromeState(store);
|
|
63
|
+
if (!chrome || (chrome.actions == null && !chrome.refresh && !chrome.menuActions?.length && !chrome.moreActions?.length))
|
|
64
|
+
return null;
|
|
65
|
+
return (_jsxs(PageActions, { className: cn('console-page-chrome-actions', className), actions: chrome.menuActions, moreActions: chrome.moreActions, children: [chrome.refresh ? _jsx(RefreshControl, { ...chrome.refresh }) : null, chrome.actions] }));
|
|
66
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** Auto-refresh choices offered by RefreshControl, in milliseconds (0 = manual). */
|
|
2
|
+
export declare const DEFAULT_REFRESH_INTERVALS: readonly number[];
|
|
3
|
+
/** The offered intervals plus `current` when it is not one of them (kept, so a custom value is not lost). */
|
|
4
|
+
export declare function refreshIntervalOptions(current: number, intervals?: readonly number[]): number[];
|
|
5
|
+
export declare function isValidInterval(value: unknown): value is number;
|
|
6
|
+
/** 「hh:mm:ss」 in 24-hour time; `null` when there is no valid time yet. */
|
|
7
|
+
export declare function formatRefreshTime(value: Date | number | string | null | undefined): string | null;
|
|
8
|
+
/** Whole seconds shown in the 「5s 自动」 label. */
|
|
9
|
+
export declare function intervalSeconds(intervalMs: number): number;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/** Auto-refresh choices offered by RefreshControl, in milliseconds (0 = manual). */
|
|
2
|
+
export const DEFAULT_REFRESH_INTERVALS = Object.freeze([0, 5_000, 15_000, 30_000]);
|
|
3
|
+
/** The offered intervals plus `current` when it is not one of them (kept, so a custom value is not lost). */
|
|
4
|
+
export function refreshIntervalOptions(current, intervals = DEFAULT_REFRESH_INTERVALS) {
|
|
5
|
+
const values = [...new Set(intervals.filter(isValidInterval))];
|
|
6
|
+
if (isValidInterval(current) && !values.includes(current))
|
|
7
|
+
values.push(current);
|
|
8
|
+
return values.sort((left, right) => left - right);
|
|
9
|
+
}
|
|
10
|
+
export function isValidInterval(value) {
|
|
11
|
+
return typeof value === 'number' && Number.isFinite(value) && value >= 0;
|
|
12
|
+
}
|
|
13
|
+
/** 「hh:mm:ss」 in 24-hour time; `null` when there is no valid time yet. */
|
|
14
|
+
export function formatRefreshTime(value) {
|
|
15
|
+
if (value === null || value === undefined || value === '')
|
|
16
|
+
return null;
|
|
17
|
+
const date = value instanceof Date ? value : new Date(value);
|
|
18
|
+
if (Number.isNaN(date.getTime()))
|
|
19
|
+
return null;
|
|
20
|
+
const pad = (part) => String(part).padStart(2, '0');
|
|
21
|
+
return `${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(date.getSeconds())}`;
|
|
22
|
+
}
|
|
23
|
+
/** Whole seconds shown in the 「5s 自动」 label. */
|
|
24
|
+
export function intervalSeconds(intervalMs) {
|
|
25
|
+
return Math.max(1, Math.round(intervalMs / 1000));
|
|
26
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type * as React from "react";
|
|
2
|
+
import * as Radix from "radix-ui";
|
|
3
|
+
declare const Accordion: React.ForwardRefExoticComponent<(Radix.Accordion.AccordionSingleProps | Radix.Accordion.AccordionMultipleProps) & React.RefAttributes<HTMLDivElement>>;
|
|
4
|
+
declare const AccordionItem: React.ForwardRefExoticComponent<Omit<Radix.Accordion.AccordionItemProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
5
|
+
declare const AccordionTrigger: React.ForwardRefExoticComponent<Omit<Radix.Accordion.AccordionTriggerProps & React.RefAttributes<HTMLButtonElement>, "ref"> & React.RefAttributes<HTMLButtonElement>>;
|
|
6
|
+
declare const AccordionContent: React.ForwardRefExoticComponent<Omit<Radix.Accordion.AccordionContentProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
7
|
+
export { Accordion, AccordionItem, AccordionTrigger, AccordionContent };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import * as Radix from "radix-ui";
|
|
4
|
+
const AccordionPrimitive = Radix.Accordion;
|
|
5
|
+
import { cn } from '../../cn.js';
|
|
6
|
+
import { ChevronDown } from "lucide-react";
|
|
7
|
+
import { CONSOLE_ICON_STROKE_WIDTH } from '../icon.js';
|
|
8
|
+
const Accordion = AccordionPrimitive.Root;
|
|
9
|
+
const AccordionItem = forwardRef(({ className, value, ...props }, ref) => (_jsx(AccordionPrimitive.Item, { ref: ref, value: value, className: cn("border-b", className), ...props })));
|
|
10
|
+
AccordionItem.displayName = "AccordionItem";
|
|
11
|
+
const AccordionTrigger = forwardRef(({ className, children, ...props }, ref) => (_jsx(AccordionPrimitive.Header, { className: "flex", children: _jsxs(AccordionPrimitive.Trigger, { ref: ref, className: cn("flex min-h-control flex-1 items-center justify-between py-3 text-body font-medium transition-all hover:underline [&[data-state=open]>svg]:rotate-180", className), ...props, children: [children, _jsx(ChevronDown, { strokeWidth: CONSOLE_ICON_STROKE_WIDTH, className: "h-4 w-4 shrink-0 text-muted-foreground transition-transform duration-200" })] }) })));
|
|
12
|
+
AccordionTrigger.displayName = "AccordionTrigger";
|
|
13
|
+
const AccordionContent = forwardRef(({ className, children, ...props }, ref) => (_jsx(AccordionPrimitive.Content, { ref: ref, className: "overflow-hidden text-body data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down", ...props, children: _jsx("div", { className: cn("pb-4 pt-0", className), children: children }) })));
|
|
14
|
+
AccordionContent.displayName = "AccordionContent";
|
|
15
|
+
export { Accordion, AccordionItem, AccordionTrigger, AccordionContent };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type * as React from "react";
|
|
2
|
+
import { type VariantProps } from "class-variance-authority";
|
|
3
|
+
declare const Alert: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & VariantProps<(props?: ({
|
|
4
|
+
variant?: "default" | "destructive" | "success" | "warning" | null | undefined;
|
|
5
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string> & React.RefAttributes<HTMLDivElement>>;
|
|
6
|
+
declare const AlertTitle: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLHeadingElement> & React.RefAttributes<HTMLParagraphElement>>;
|
|
7
|
+
declare const AlertDescription: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLParagraphElement> & React.RefAttributes<HTMLParagraphElement>>;
|
|
8
|
+
export { Alert, AlertTitle, AlertDescription };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import { cva } from "class-variance-authority";
|
|
4
|
+
import { cn } from '../../cn.js';
|
|
5
|
+
const alertVariants = cva("console-alert relative w-full rounded-card border px-4 py-3 text-body leading-relaxed [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:size-4 [&>svg]:text-foreground [&>svg~*]:pl-6", {
|
|
6
|
+
variants: {
|
|
7
|
+
variant: {
|
|
8
|
+
default: "border-transparent bg-secondary text-foreground",
|
|
9
|
+
destructive: "border-destructive/30 bg-destructive/5 text-destructive dark:border-destructive/40 [&>svg]:text-destructive",
|
|
10
|
+
success: "console-badge-success [&>svg]:text-success",
|
|
11
|
+
warning: "console-badge-warning [&>svg]:text-warning",
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
defaultVariants: {
|
|
15
|
+
variant: "default",
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
const Alert = forwardRef(({ className, variant, ...props }, ref) => (_jsx("div", { ref: ref, role: "alert", className: cn(alertVariants({ variant }), className), ...props })));
|
|
19
|
+
Alert.displayName = "Alert";
|
|
20
|
+
const AlertTitle = forwardRef(({ className, ...props }, ref) => (_jsx("h5", { ref: ref, className: cn("mb-1 font-strong leading-normal", className), ...props })));
|
|
21
|
+
AlertTitle.displayName = "AlertTitle";
|
|
22
|
+
const AlertDescription = forwardRef(({ className, ...props }, ref) => (_jsx("div", { ref: ref, className: cn("text-body [&_p]:leading-relaxed", className), ...props })));
|
|
23
|
+
AlertDescription.displayName = "AlertDescription";
|
|
24
|
+
export { Alert, AlertTitle, AlertDescription };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type * as React from "react";
|
|
2
|
+
import { type VariantProps } from "class-variance-authority";
|
|
3
|
+
declare const badgeVariants: (props?: ({
|
|
4
|
+
variant?: "default" | "destructive" | "success" | "warning" | "secondary" | "outline" | "info" | null | undefined;
|
|
5
|
+
size?: "default" | "sm" | null | undefined;
|
|
6
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
7
|
+
export type BadgeProps = React.ComponentPropsWithoutRef<"span"> & VariantProps<typeof badgeVariants>;
|
|
8
|
+
declare function Badge({ className, variant, size, ...props }: BadgeProps): React.JSX.Element;
|
|
9
|
+
export { Badge, badgeVariants };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { cva } from "class-variance-authority";
|
|
3
|
+
import { cn } from '../../cn.js';
|
|
4
|
+
const badgeVariants = cva("console-badge transition-colors", {
|
|
5
|
+
variants: {
|
|
6
|
+
variant: {
|
|
7
|
+
default: "border-primary-action-border bg-primary-action text-primary-action-foreground",
|
|
8
|
+
secondary: "border-transparent bg-foreground/6 text-secondary-foreground",
|
|
9
|
+
destructive: "console-badge-danger",
|
|
10
|
+
outline: "border-[color:var(--console-border-strong)] text-foreground",
|
|
11
|
+
// 「正常」 is not a colored badge (ADR 0063 D15 第 1 条): success renders as muted text.
|
|
12
|
+
success: "console-status-quiet border-transparent px-0",
|
|
13
|
+
warning: "console-badge-warning",
|
|
14
|
+
info: "console-badge-info",
|
|
15
|
+
},
|
|
16
|
+
// One badge implementation (D16): `sm` is kept for compatibility and renders the same.
|
|
17
|
+
size: {
|
|
18
|
+
default: "",
|
|
19
|
+
sm: "",
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
defaultVariants: {
|
|
23
|
+
variant: "default",
|
|
24
|
+
size: "default",
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
function Badge({ className, variant, size, ...props }) {
|
|
28
|
+
return _jsx("span", { "data-slot": "badge", className: cn(badgeVariants({ variant, size }), className), ...props });
|
|
29
|
+
}
|
|
30
|
+
export { Badge, badgeVariants };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type * as React from "react";
|
|
2
|
+
import { type VariantProps } from "class-variance-authority";
|
|
3
|
+
/**
|
|
4
|
+
* Button variants (ADR 0063 「色板角色与信号色」, zhinjs/console#125):
|
|
5
|
+
* primary solid brand, dark text — at most one per view (the next step: 登录, 保存, 发送, 筛选)
|
|
6
|
+
* soft palette tint, the former `default`; `default` is its deprecated alias until P4
|
|
7
|
+
* outline / secondary / ghost / link
|
|
8
|
+
* destructive ghost: destructive text, no fill — every dangerous entry point on a page
|
|
9
|
+
* destructive-outline outline button with destructive text (ADR 0063 决策 5)
|
|
10
|
+
* destructive-solid solid red — only the confirm button of a confirmation dialog
|
|
11
|
+
*/
|
|
12
|
+
declare const buttonVariants: (props?: ({
|
|
13
|
+
variant?: "link" | "default" | "destructive" | "secondary" | "outline" | "primary" | "soft" | "destructive-outline" | "destructive-solid" | "ghost" | null | undefined;
|
|
14
|
+
size?: "default" | "sm" | "lg" | "icon" | null | undefined;
|
|
15
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
16
|
+
export interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement>, VariantProps<typeof buttonVariants> {
|
|
17
|
+
asChild?: boolean;
|
|
18
|
+
}
|
|
19
|
+
declare const Button: React.ForwardRefExoticComponent<ButtonProps & React.RefAttributes<HTMLButtonElement>>;
|
|
20
|
+
export { Button, buttonVariants };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import * as Radix from "radix-ui";
|
|
4
|
+
import { cva } from "class-variance-authority";
|
|
5
|
+
import { cn } from '../../cn.js';
|
|
6
|
+
const SOFT = "border-primary-action-border bg-primary-action text-primary-action-foreground hover:border-primary hover:bg-primary-action/72";
|
|
7
|
+
/**
|
|
8
|
+
* Button variants (ADR 0063 「色板角色与信号色」, zhinjs/console#125):
|
|
9
|
+
* primary solid brand, dark text — at most one per view (the next step: 登录, 保存, 发送, 筛选)
|
|
10
|
+
* soft palette tint, the former `default`; `default` is its deprecated alias until P4
|
|
11
|
+
* outline / secondary / ghost / link
|
|
12
|
+
* destructive ghost: destructive text, no fill — every dangerous entry point on a page
|
|
13
|
+
* destructive-outline outline button with destructive text (ADR 0063 决策 5)
|
|
14
|
+
* destructive-solid solid red — only the confirm button of a confirmation dialog
|
|
15
|
+
*/
|
|
16
|
+
const buttonVariants = cva("console-control inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-control border border-transparent text-body font-medium transition-[background-color,border-color,color,box-shadow] disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0", {
|
|
17
|
+
variants: {
|
|
18
|
+
variant: {
|
|
19
|
+
// The light-theme brand (#76EEC6) is close to white, so the brand-text hairline gives the button its edge.
|
|
20
|
+
primary: "border-brand-text/70 bg-brand text-brand-foreground hover:bg-brand/85 dark:border-transparent",
|
|
21
|
+
soft: SOFT,
|
|
22
|
+
/** @deprecated Renamed to `soft` (zhinjs/console#125); same look, kept until ADR 0063 P4. */
|
|
23
|
+
default: SOFT,
|
|
24
|
+
destructive: "text-destructive hover:bg-destructive/8",
|
|
25
|
+
outline: "border-[color:var(--console-border-strong)] bg-card text-foreground hover:bg-[var(--console-surface-hover)]",
|
|
26
|
+
// Page-level entry to a dangerous action (ADR 0063 决策 5): the outline button with destructive text.
|
|
27
|
+
"destructive-outline": "border-[color:var(--console-border-strong)] bg-card text-destructive hover:bg-[var(--console-surface-hover)]",
|
|
28
|
+
// Only for the confirm button inside a confirmation dialog (ConfirmDialog variant="destructive").
|
|
29
|
+
"destructive-solid": "bg-destructive text-destructive-foreground hover:bg-destructive/90",
|
|
30
|
+
secondary: "bg-secondary text-secondary-foreground hover:bg-accent",
|
|
31
|
+
ghost: "text-foreground hover:bg-[var(--console-surface-hover)]",
|
|
32
|
+
link: "text-brand-text underline-offset-4 hover:underline",
|
|
33
|
+
},
|
|
34
|
+
size: {
|
|
35
|
+
default: "h-control px-3",
|
|
36
|
+
sm: "h-control-compact px-3 text-label",
|
|
37
|
+
lg: "h-control px-4",
|
|
38
|
+
icon: "size-control shrink-0",
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
defaultVariants: {
|
|
42
|
+
variant: "soft",
|
|
43
|
+
size: "default",
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
const Slot = Radix.Slot.Root;
|
|
47
|
+
const Button = forwardRef(({ className, variant, size, asChild = false, ...props }, ref) => {
|
|
48
|
+
const Comp = asChild ? Slot : "button";
|
|
49
|
+
return (_jsx(Comp, { "data-slot": "button", className: cn(buttonVariants({ variant, size, className })), ref: ref, ...props }));
|
|
50
|
+
});
|
|
51
|
+
Button.displayName = "Button";
|
|
52
|
+
export { Button, buttonVariants };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type * as React from "react";
|
|
2
|
+
export interface CardProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
3
|
+
interactive?: boolean;
|
|
4
|
+
/**
|
|
5
|
+
* The card fills the page column edge to edge on phone-width pages (below 40rem it reaches the
|
|
6
|
+
* screen edges and has no radius, ADR 0063 D16). Only for cards placed directly in the page.
|
|
7
|
+
*/
|
|
8
|
+
edge?: boolean;
|
|
9
|
+
}
|
|
10
|
+
/** Card: hairline border, no shadow when static; interactive cards lift (e-1) on wide containers. */
|
|
11
|
+
declare const Card: React.ForwardRefExoticComponent<CardProps & React.RefAttributes<HTMLDivElement>>;
|
|
12
|
+
declare const CardHeader: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
|
|
13
|
+
declare const CardTitle: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
|
|
14
|
+
declare const CardDescription: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
|
|
15
|
+
declare const CardContent: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
|
|
16
|
+
declare const CardFooter: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
|
|
17
|
+
export { Card, CardHeader, CardFooter, CardTitle, CardDescription, CardContent };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import { cn } from '../../cn.js';
|
|
4
|
+
/** Card: hairline border, no shadow when static; interactive cards lift (e-1) on wide containers. */
|
|
5
|
+
const Card = forwardRef(({ className, interactive, edge, ...props }, ref) => (_jsx("div", { ref: ref, "data-slot": "card", "data-interactive": interactive ? "" : undefined, "data-edge": edge ? "" : undefined, className: cn("console-card text-card-foreground", interactive && "console-card--interactive", className), ...props })));
|
|
6
|
+
Card.displayName = "Card";
|
|
7
|
+
const CardHeader = forwardRef(({ className, ...props }, ref) => (_jsx("div", { ref: ref, className: cn("console-card-header", className), ...props })));
|
|
8
|
+
CardHeader.displayName = "CardHeader";
|
|
9
|
+
const CardTitle = forwardRef(({ className, ...props }, ref) => (_jsx("div", { ref: ref, className: cn("console-section-title", className), ...props })));
|
|
10
|
+
CardTitle.displayName = "CardTitle";
|
|
11
|
+
const CardDescription = forwardRef(({ className, ...props }, ref) => (_jsx("div", { ref: ref, className: cn("console-text-body text-muted-foreground", className), ...props })));
|
|
12
|
+
CardDescription.displayName = "CardDescription";
|
|
13
|
+
const CardContent = forwardRef(({ className, ...props }, ref) => (_jsx("div", { ref: ref, className: cn("console-card-content", className), ...props })));
|
|
14
|
+
CardContent.displayName = "CardContent";
|
|
15
|
+
const CardFooter = forwardRef(({ className, ...props }, ref) => (_jsx("div", { ref: ref, className: cn("console-card-footer", className), ...props })));
|
|
16
|
+
CardFooter.displayName = "CardFooter";
|
|
17
|
+
export { Card, CardHeader, CardFooter, CardTitle, CardDescription, CardContent };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type * as React from "react";
|
|
2
|
+
import * as Radix from "radix-ui";
|
|
3
|
+
declare const Checkbox: React.ForwardRefExoticComponent<Omit<Radix.Checkbox.CheckboxProps & React.RefAttributes<HTMLButtonElement>, "ref"> & React.RefAttributes<HTMLButtonElement>>;
|
|
4
|
+
export { Checkbox };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import * as Radix from "radix-ui";
|
|
4
|
+
const CheckboxPrimitive = Radix.Checkbox;
|
|
5
|
+
import { cn } from '../../cn.js';
|
|
6
|
+
import { Check, Minus } from "lucide-react";
|
|
7
|
+
import { CONSOLE_ICON_STROKE_WIDTH } from '../icon.js';
|
|
8
|
+
const Checkbox = forwardRef(({ className, ...props }, ref) => (_jsx(CheckboxPrimitive.Root, { ref: ref, className: cn("console-control console-touch peer inline-flex size-4 shrink-0 items-center justify-center rounded-check border border-input bg-card text-background transition-colors disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:border-brand-text data-[state=checked]:bg-brand-text data-[state=indeterminate]:border-brand-text data-[state=indeterminate]:bg-brand-text", className), ...props, children: _jsxs(CheckboxPrimitive.Indicator, { className: "group/indicator flex items-center justify-center text-current", children: [_jsx(Check, { strokeWidth: CONSOLE_ICON_STROKE_WIDTH, className: "hidden h-3.5 w-3.5 group-data-[state=checked]/indicator:block" }), _jsx(Minus, { strokeWidth: CONSOLE_ICON_STROKE_WIDTH, className: "hidden h-3.5 w-3.5 group-data-[state=indeterminate]/indicator:block" })] }) })));
|
|
9
|
+
Checkbox.displayName = "Checkbox";
|
|
10
|
+
export { Checkbox };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Look of the text-like controls (Input, Textarea, SelectTrigger, SearchableSelectField,
|
|
3
|
+
* DateField, DateTimeField), ADR 0063 D29:
|
|
4
|
+
* default hairline border on a card surface
|
|
5
|
+
* ghost no border and no fill until hovered or focused; for secondary fields (fallback
|
|
6
|
+
* models, unset slots) so a long form does not become a wall of boxes
|
|
7
|
+
*/
|
|
8
|
+
export type ControlVariant = 'default' | 'ghost';
|
|
9
|
+
/** Border and surface classes of a control variant (Tailwind utilities, merged with `cn`). */
|
|
10
|
+
export declare function controlVariantClass(variant: ControlVariant | null | undefined): string;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
const DEFAULT = 'border-input bg-card hover:border-foreground/45 focus-visible:border-brand-text disabled:bg-muted';
|
|
2
|
+
const GHOST = 'border-transparent bg-transparent hover:border-input focus-visible:border-brand-text aria-expanded:border-input data-[state=open]:border-input disabled:bg-transparent';
|
|
3
|
+
/** Border and surface classes of a control variant (Tailwind utilities, merged with `cn`). */
|
|
4
|
+
export function controlVariantClass(variant) {
|
|
5
|
+
return variant === 'ghost' ? GHOST : DEFAULT;
|
|
6
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure date logic of `DateField` / `DateTimeField` (no DOM, no time zone surprises): values are
|
|
3
|
+
* ISO 8601 strings in local time — `YYYY-MM-DD` for a date, `YYYY-MM-DDTHH:mm` for a date and time
|
|
4
|
+
* (the value format of the native `date` / `datetime-local` inputs), `''` when empty.
|
|
5
|
+
*/
|
|
6
|
+
export interface CalendarDate {
|
|
7
|
+
readonly year: number;
|
|
8
|
+
/** 1–12 */
|
|
9
|
+
readonly month: number;
|
|
10
|
+
readonly day: number;
|
|
11
|
+
}
|
|
12
|
+
export interface CalendarDateTime extends CalendarDate {
|
|
13
|
+
readonly hour: number;
|
|
14
|
+
readonly minute: number;
|
|
15
|
+
}
|
|
16
|
+
export declare function daysInMonth(year: number, month: number): number;
|
|
17
|
+
/** Reads the date part of a date or date-time value; `null` when empty or invalid. */
|
|
18
|
+
export declare function parseDateValue(value: string | null | undefined): CalendarDate | null;
|
|
19
|
+
/** Reads a date-time value (a bare date counts as 00:00); `null` when empty or invalid. */
|
|
20
|
+
export declare function parseDateTimeValue(value: string | null | undefined): CalendarDateTime | null;
|
|
21
|
+
export declare function formatDateValue(date: CalendarDate): string;
|
|
22
|
+
export declare function formatDateTimeValue(value: CalendarDateTime): string;
|
|
23
|
+
export declare function fromDate(date: Date): CalendarDate;
|
|
24
|
+
export declare function compareDates(a: CalendarDate, b: CalendarDate): number;
|
|
25
|
+
export declare function sameDate(a: CalendarDate | null, b: CalendarDate | null): boolean;
|
|
26
|
+
export declare function addDays(date: CalendarDate, days: number): CalendarDate;
|
|
27
|
+
/** Same day in another month, clamped to that month's last day (Jan 31 + 1 month = Feb 28/29). */
|
|
28
|
+
export declare function addMonths(date: CalendarDate, months: number): CalendarDate;
|
|
29
|
+
/** Whether `date` is inside `[min, max]` (date parts of the bounds; either bound may be empty). */
|
|
30
|
+
export declare function isWithin(date: CalendarDate, min?: string, max?: string): boolean;
|
|
31
|
+
export declare function clampDate(date: CalendarDate, min?: string, max?: string): CalendarDate;
|
|
32
|
+
/** 0 = Sunday … 6 = Saturday */
|
|
33
|
+
export declare function weekday(date: CalendarDate): number;
|
|
34
|
+
/** First day of the week that contains `date`. */
|
|
35
|
+
export declare function startOfWeek(date: CalendarDate, weekStartsOn: 0 | 1): CalendarDate;
|
|
36
|
+
/** Six weeks × seven days covering the month (leading / trailing days of the neighbour months included). */
|
|
37
|
+
export declare function calendarMonth(year: number, month: number, weekStartsOn: 0 | 1): CalendarDate[][];
|
|
38
|
+
/** Hour / minute typed into the time boxes: digits only, clamped into range; `null` when not a number. */
|
|
39
|
+
export declare function clampTimePart(text: string, max: number): number | null;
|