@hamster-note/components 0.2.1-beta.2 → 0.3.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/README.md +334 -89
- package/dist/{icon-DUpDkTEa.js → Icon-BBSPOBTI.js} +54 -11
- package/dist/button-DjMS8bKj.js +20 -0
- package/dist/button.js +1 -1
- package/dist/components/button/Button.d.ts +3 -2
- package/dist/components/dialog/Dialog.d.ts +3 -1
- package/dist/components/drawer/Drawer.d.ts +3 -1
- package/dist/components/icon/icon-names.d.ts +3 -3
- package/dist/components/menu/Menu.d.ts +10 -10
- package/dist/components/menu/Menu.placement.test.d.ts +1 -0
- package/dist/components/menu/MenuSubmenu.d.ts +13 -0
- package/dist/components/menu/MenuSurface.d.ts +12 -0
- package/dist/components/menu/index.d.ts +1 -1
- package/dist/components/menu/menu-tree-context.d.ts +9 -0
- package/dist/components/popover/use-anchor-position.d.ts +16 -1
- package/dist/components/popover/use-anchor-position.test.d.ts +1 -0
- package/dist/components/theme/theme-context.d.ts +10 -0
- package/dist/{confirm-3eBmopl8.js → confirm-Faavk_5T.js} +4 -5
- package/dist/confirm.js +1 -1
- package/dist/dialog-BYlEUJ_j.js +102 -0
- package/dist/dialog.js +1 -1
- package/dist/drawer-BV9RFSna.js +120 -0
- package/dist/drawer.js +1 -1
- package/dist/hamster-note-components.css +1 -1
- package/dist/icon-BFAcjkFI.js +5 -0
- package/dist/icon.js +2 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +11 -10
- package/dist/menu-B4WwCQyw.js +179 -0
- package/dist/menu.js +1 -1
- package/dist/popover-D00SlGpL.js +82 -0
- package/dist/popover.js +1 -1
- package/dist/test/fields-and-cards.test.d.ts +1 -0
- package/dist/test/imperative-apis.test.d.ts +1 -0
- package/dist/test/modals.test.d.ts +1 -0
- package/dist/test/primitives.test.d.ts +1 -0
- package/dist/test/setup.d.ts +0 -0
- package/dist/test/theme-and-popover.test.d.ts +1 -0
- package/dist/{theme-C0p_hpKk.js → theme-CVNLJL1G.js} +29 -21
- package/dist/theme-context-CdWvVVP8.js +8 -0
- package/dist/theme.js +1 -1
- package/dist/use-anchor-position-D3QBcIet.js +166 -0
- package/package.json +16 -3
- package/dist/button-DRz0VTkf.js +0 -18
- package/dist/dialog-B4xS5zlK.js +0 -53
- package/dist/drawer-DoeuGAHD.js +0 -60
- package/dist/menu-DKWGPsiS.js +0 -142
- package/dist/popover-Bx4b_3E9.js +0 -166
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/* empty css */
|
|
2
1
|
import { Fragment as e, jsx as t, jsxs as n } from "react/jsx-runtime";
|
|
3
2
|
//#region src/components/icon/Icon.tsx
|
|
4
3
|
var r = {
|
|
@@ -205,6 +204,11 @@ var r = {
|
|
|
205
204
|
/* @__PURE__ */ t("path", { d: "M12 7l5 5" }),
|
|
206
205
|
/* @__PURE__ */ t("path", { d: "M3 21h18" })
|
|
207
206
|
] }),
|
|
207
|
+
comment: /* @__PURE__ */ n(e, { children: [
|
|
208
|
+
/* @__PURE__ */ t("path", { d: "M21 15a4 4 0 0 1-4 4H8l-5 3V7a4 4 0 0 1 4-4h10a4 4 0 0 1 4 4z" }),
|
|
209
|
+
/* @__PURE__ */ t("path", { d: "M8 9h8" }),
|
|
210
|
+
/* @__PURE__ */ t("path", { d: "M8 13h5" })
|
|
211
|
+
] }),
|
|
208
212
|
keyboard: /* @__PURE__ */ n(e, { children: [
|
|
209
213
|
/* @__PURE__ */ t("rect", {
|
|
210
214
|
height: "12",
|
|
@@ -281,6 +285,36 @@ var r = {
|
|
|
281
285
|
/* @__PURE__ */ t("path", { d: "M7 14h6" }),
|
|
282
286
|
/* @__PURE__ */ t("path", { d: "M7 17h4" })
|
|
283
287
|
] }),
|
|
288
|
+
minimap: /* @__PURE__ */ n(e, { children: [
|
|
289
|
+
/* @__PURE__ */ t("rect", {
|
|
290
|
+
height: "18",
|
|
291
|
+
rx: "2",
|
|
292
|
+
width: "18",
|
|
293
|
+
x: "3",
|
|
294
|
+
y: "3"
|
|
295
|
+
}),
|
|
296
|
+
/* @__PURE__ */ t("rect", {
|
|
297
|
+
height: "7",
|
|
298
|
+
rx: "1",
|
|
299
|
+
width: "9",
|
|
300
|
+
x: "7",
|
|
301
|
+
y: "7"
|
|
302
|
+
}),
|
|
303
|
+
/* @__PURE__ */ t("path", { d: "M7 17h6" })
|
|
304
|
+
] }),
|
|
305
|
+
"font-size": /* @__PURE__ */ n(e, { children: [
|
|
306
|
+
/* @__PURE__ */ t("path", { d: "M5 16L9 7l4 9" }),
|
|
307
|
+
/* @__PURE__ */ t("path", { d: "M6.5 13h5" }),
|
|
308
|
+
/* @__PURE__ */ t("path", { d: "M15 18l2.5-5 2.5 5" }),
|
|
309
|
+
/* @__PURE__ */ t("path", { d: "M16 16.5h3" })
|
|
310
|
+
] }),
|
|
311
|
+
drag: /* @__PURE__ */ n(e, { children: [
|
|
312
|
+
/* @__PURE__ */ t("path", { d: "M18 11V6a2 2 0 0 0-4 0v5" }),
|
|
313
|
+
/* @__PURE__ */ t("path", { d: "M14 10V4a2 2 0 0 0-4 0v6" }),
|
|
314
|
+
/* @__PURE__ */ t("path", { d: "M10 10.5V6a2 2 0 0 0-4 0v8" }),
|
|
315
|
+
/* @__PURE__ */ t("path", { d: "M18 8a2 2 0 1 1 4 0v6a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15" })
|
|
316
|
+
] }),
|
|
317
|
+
crop: /* @__PURE__ */ n(e, { children: [/* @__PURE__ */ t("path", { d: "M6 2v14a2 2 0 0 0 2 2h14" }), /* @__PURE__ */ t("path", { d: "M18 22V8a2 2 0 0 0-2-2H2" })] }),
|
|
284
318
|
search: /* @__PURE__ */ n(e, { children: [/* @__PURE__ */ t("circle", {
|
|
285
319
|
cx: "11",
|
|
286
320
|
cy: "11",
|
|
@@ -418,6 +452,18 @@ var r = {
|
|
|
418
452
|
/* @__PURE__ */ t("path", { d: "M21 21l-4.3-4.3" }),
|
|
419
453
|
/* @__PURE__ */ t("path", { d: "M8 11h6" })
|
|
420
454
|
] }),
|
|
455
|
+
fullscreen: /* @__PURE__ */ n(e, { children: [
|
|
456
|
+
/* @__PURE__ */ t("path", { d: "M9 4H4v5" }),
|
|
457
|
+
/* @__PURE__ */ t("path", { d: "M15 4h5v5" }),
|
|
458
|
+
/* @__PURE__ */ t("path", { d: "M20 15v5h-5" }),
|
|
459
|
+
/* @__PURE__ */ t("path", { d: "M9 20H4v-5" })
|
|
460
|
+
] }),
|
|
461
|
+
"fullscreen-exit": /* @__PURE__ */ n(e, { children: [
|
|
462
|
+
/* @__PURE__ */ t("path", { d: "M4 9h5V4" }),
|
|
463
|
+
/* @__PURE__ */ t("path", { d: "M20 9h-5V4" }),
|
|
464
|
+
/* @__PURE__ */ t("path", { d: "M15 20v-5h5" }),
|
|
465
|
+
/* @__PURE__ */ t("path", { d: "M9 20v-5H4" })
|
|
466
|
+
] }),
|
|
421
467
|
menu: /* @__PURE__ */ n(e, { children: [
|
|
422
468
|
/* @__PURE__ */ t("path", { d: "M4 7h16" }),
|
|
423
469
|
/* @__PURE__ */ t("path", { d: "M4 12h16" }),
|
|
@@ -456,12 +502,12 @@ var r = {
|
|
|
456
502
|
/* @__PURE__ */ t("path", { d: "M14 16h6" })
|
|
457
503
|
] })
|
|
458
504
|
};
|
|
459
|
-
function i({ label: e, name:
|
|
460
|
-
return /* @__PURE__ */
|
|
505
|
+
function i({ label: e, name: i, className: a, ...o }) {
|
|
506
|
+
return /* @__PURE__ */ n("svg", {
|
|
461
507
|
className: [
|
|
462
508
|
"hn-icon",
|
|
463
|
-
`hn-icon--${
|
|
464
|
-
|
|
509
|
+
`hn-icon--${i}`,
|
|
510
|
+
a
|
|
465
511
|
].filter(Boolean).join(" "),
|
|
466
512
|
fill: "none",
|
|
467
513
|
focusable: "false",
|
|
@@ -477,12 +523,9 @@ function i({ label: e, name: n, className: i, ...a }) {
|
|
|
477
523
|
"aria-label": e,
|
|
478
524
|
role: "img"
|
|
479
525
|
},
|
|
480
|
-
...
|
|
481
|
-
children: r[
|
|
526
|
+
...o,
|
|
527
|
+
children: [/* @__PURE__ */ t("title", { children: e ?? i }), r[i]]
|
|
482
528
|
});
|
|
483
529
|
}
|
|
484
530
|
//#endregion
|
|
485
|
-
|
|
486
|
-
var a = /* @__PURE__ */ "file.save.study.switch.mouse.line.curve.polygon.lasso.rectangle.ellipse.pen.eraser.magnet.locate.delete.add.copy.paste.info.touch.edit.keyboard.type.handle.card.search.close.check.chevron-down.chevron-up.chevron-left.chevron-right.arrow-up.arrow-down.arrow-left.arrow-right.settings.user.home.star.bookmark.link.image.calendar.clock.bell.download.upload.share.undo.redo.zoom-in.zoom-out.menu.more.filter.sort".split(".");
|
|
487
|
-
//#endregion
|
|
488
|
-
export { i as n, a as t };
|
|
531
|
+
export { i as t };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/* empty css */
|
|
2
|
+
import { jsx as e } from "react/jsx-runtime";
|
|
3
|
+
//#region src/components/button/Button.tsx
|
|
4
|
+
function t({ children: t, className: n, ghost: r = !1, size: i = "medium", type: a = "button", variant: o = "secondary", ...s }) {
|
|
5
|
+
let c = o === "ghost" ? "secondary" : o, l = r || o === "ghost";
|
|
6
|
+
return /* @__PURE__ */ e("button", {
|
|
7
|
+
className: [
|
|
8
|
+
"hn-button",
|
|
9
|
+
`hn-button--${c}`,
|
|
10
|
+
l && "hn-button--ghost",
|
|
11
|
+
`hn-button--${i}`,
|
|
12
|
+
n
|
|
13
|
+
].filter(Boolean).join(" "),
|
|
14
|
+
type: a,
|
|
15
|
+
...s,
|
|
16
|
+
children: t
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
//#endregion
|
|
20
|
+
export { t };
|
package/dist/button.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as e } from "./button-
|
|
1
|
+
import { t as e } from "./button-DjMS8bKj.js";
|
|
2
2
|
export { e as Button };
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { ButtonHTMLAttributes, ReactNode } from 'react';
|
|
2
|
-
export type ButtonVariant = 'primary' | 'secondary' | 'ghost';
|
|
2
|
+
export type ButtonVariant = 'primary' | 'secondary' | 'ghost' | 'danger' | 'warning' | 'success' | 'info';
|
|
3
3
|
export type ButtonSize = 'small' | 'medium' | 'large';
|
|
4
4
|
export interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
5
5
|
readonly children: ReactNode;
|
|
6
|
+
readonly ghost?: boolean;
|
|
6
7
|
readonly variant?: ButtonVariant;
|
|
7
8
|
readonly size?: ButtonSize;
|
|
8
9
|
}
|
|
9
|
-
export declare function Button({ children, className, size, type, variant, ...props }: ButtonProps): import("react").JSX.Element;
|
|
10
|
+
export declare function Button({ children, className, ghost, size, type, variant, ...props }: ButtonProps): import("react").JSX.Element;
|
|
@@ -6,6 +6,8 @@ export interface DialogProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
6
6
|
readonly description?: string | undefined;
|
|
7
7
|
readonly closeOnEsc?: boolean | undefined;
|
|
8
8
|
readonly closeOnBackdrop?: boolean | undefined;
|
|
9
|
+
readonly showCloseButton?: boolean | undefined;
|
|
10
|
+
readonly showFullscreenButton?: boolean | undefined;
|
|
9
11
|
readonly ref?: Ref<HTMLDivElement>;
|
|
10
12
|
}
|
|
11
|
-
export declare function Dialog({ children, className, title, description, open, onClose, closeOnEsc, closeOnBackdrop, ref, style, ...props }: DialogProps): import('react').ReactPortal | null;
|
|
13
|
+
export declare function Dialog({ children, className, title, description, open, onClose, closeOnEsc, closeOnBackdrop, showCloseButton, showFullscreenButton, ref, style, ...props }: DialogProps): import('react').ReactPortal | null;
|
|
@@ -9,6 +9,8 @@ export interface DrawerProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
9
9
|
readonly size?: number | undefined;
|
|
10
10
|
readonly closeOnEsc?: boolean | undefined;
|
|
11
11
|
readonly closeOnBackdrop?: boolean | undefined;
|
|
12
|
+
readonly showCloseButton?: boolean | undefined;
|
|
13
|
+
readonly showFullscreenButton?: boolean | undefined;
|
|
12
14
|
readonly ref?: Ref<HTMLDivElement>;
|
|
13
15
|
}
|
|
14
|
-
export declare function Drawer({ children, className, title, description, open, onClose, placement, size, closeOnEsc, closeOnBackdrop, ref, style, ...props }: DrawerProps): import('react').ReactPortal | null;
|
|
16
|
+
export declare function Drawer({ children, className, title, description, open, onClose, placement, size, closeOnEsc, closeOnBackdrop, showCloseButton, showFullscreenButton, ref, style, ...props }: DrawerProps): import('react').ReactPortal | null;
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* 设计:单一数据源。IconName 类型从 ICON_NAMES 数组派生,避免数组与联合
|
|
10
10
|
* 类型之间出现漂移。新增图标只需在数组里追加一个字面量。
|
|
11
11
|
*/
|
|
12
|
-
/**
|
|
13
|
-
export declare const ICON_NAMES: readonly ["file", "save", "study", "switch", "mouse", "line", "curve", "polygon", "lasso", "rectangle", "ellipse", "pen", "eraser", "magnet", "locate", "delete", "add", "copy", "paste", "info", "touch", "edit", "keyboard", "type", "handle", "card", "search", "close", "check", "chevron-down", "chevron-up", "chevron-left", "chevron-right", "arrow-up", "arrow-down", "arrow-left", "arrow-right", "settings", "user", "home", "star", "bookmark", "link", "image", "calendar", "clock", "bell", "download", "upload", "share", "undo", "redo", "zoom-in", "zoom-out", "menu", "more", "filter", "sort"];
|
|
14
|
-
/**
|
|
12
|
+
/** 59 个图标名称字面量数组(运行时枚举与 demo 遍历用) */
|
|
13
|
+
export declare const ICON_NAMES: readonly ["file", "save", "study", "switch", "mouse", "line", "curve", "polygon", "lasso", "rectangle", "ellipse", "pen", "eraser", "magnet", "locate", "delete", "add", "copy", "paste", "info", "touch", "edit", "comment", "keyboard", "type", "handle", "card", "minimap", "font-size", "drag", "crop", "search", "close", "check", "chevron-down", "chevron-up", "chevron-left", "chevron-right", "arrow-up", "arrow-down", "arrow-left", "arrow-right", "settings", "user", "home", "star", "bookmark", "link", "image", "calendar", "clock", "bell", "download", "upload", "share", "undo", "redo", "zoom-in", "zoom-out", "fullscreen", "fullscreen-exit", "menu", "more", "filter", "sort"];
|
|
14
|
+
/** 59 个图标的名称联合类型(从 ICON_NAMES 派生,单一数据源) */
|
|
15
15
|
export type IconName = (typeof ICON_NAMES)[number];
|
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
import { ButtonHTMLAttributes, HTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
import { MenuSurfaceProps } from './MenuSurface';
|
|
3
|
+
import { MenuPlacement } from './menu-tree-context';
|
|
4
|
+
export type { MenuSubmenuProps } from './MenuSubmenu';
|
|
5
|
+
export { MenuSubmenu } from './MenuSubmenu';
|
|
6
|
+
export type { MenuPlacement } from './menu-tree-context';
|
|
2
7
|
export type MenuItemTone = 'default' | 'danger';
|
|
3
|
-
export interface MenuProps extends
|
|
4
|
-
readonly
|
|
8
|
+
export interface MenuProps extends MenuSurfaceProps {
|
|
9
|
+
readonly submenuPlacement?: MenuPlacement;
|
|
10
|
+
readonly submenuOffset?: number;
|
|
11
|
+
readonly submenuViewportMargin?: number;
|
|
5
12
|
}
|
|
6
13
|
export interface MenuItemProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
7
14
|
readonly children: ReactNode;
|
|
@@ -12,14 +19,7 @@ export type MenuSeparatorProps = Omit<HTMLAttributes<HTMLHRElement>, 'children'>
|
|
|
12
19
|
export interface MenuLabelProps extends HTMLAttributes<HTMLDivElement> {
|
|
13
20
|
readonly children: ReactNode;
|
|
14
21
|
}
|
|
15
|
-
export
|
|
16
|
-
readonly label: ReactNode;
|
|
17
|
-
readonly children: ReactNode;
|
|
18
|
-
readonly 'aria-label'?: string;
|
|
19
|
-
readonly disabled?: boolean;
|
|
20
|
-
}
|
|
21
|
-
export declare function Menu({ children, className, ...props }: MenuProps): import("react").JSX.Element;
|
|
22
|
+
export declare function Menu({ submenuOffset, submenuPlacement, submenuViewportMargin, ...props }: MenuProps): import("react").JSX.Element;
|
|
22
23
|
export declare function MenuItem({ children, className, shortcut, tone, type, ...props }: MenuItemProps): import("react").JSX.Element;
|
|
23
24
|
export declare function MenuSeparator({ className, ...props }: MenuSeparatorProps): import("react").JSX.Element;
|
|
24
25
|
export declare function MenuLabel({ children, className, ...props }: MenuLabelProps): import("react").JSX.Element;
|
|
25
|
-
export declare function MenuSubmenu({ label, children, className, disabled, 'aria-label': ariaLabel, ...props }: MenuSubmenuProps): import("react").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { HTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
import { MenuPlacement } from './menu-tree-context';
|
|
3
|
+
export interface MenuSubmenuProps extends Omit<HTMLAttributes<HTMLDivElement>, 'children'> {
|
|
4
|
+
readonly label: ReactNode;
|
|
5
|
+
readonly children: ReactNode;
|
|
6
|
+
readonly 'aria-label'?: string;
|
|
7
|
+
readonly disabled?: boolean;
|
|
8
|
+
readonly panelTheme?: 'light' | 'dark';
|
|
9
|
+
readonly placement?: MenuPlacement;
|
|
10
|
+
readonly offset?: number;
|
|
11
|
+
readonly viewportMargin?: number;
|
|
12
|
+
}
|
|
13
|
+
export declare function MenuSubmenu({ label, children, className, disabled, offset, panelTheme, placement, viewportMargin, 'aria-label': ariaLabel, ...props }: MenuSubmenuProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { HTMLAttributes, ReactNode, Ref } from 'react';
|
|
2
|
+
import { MenuPlacement } from './menu-tree-context';
|
|
3
|
+
export interface MenuSurfaceProps extends HTMLAttributes<HTMLDivElement> {
|
|
4
|
+
readonly children: ReactNode;
|
|
5
|
+
readonly anchor?: HTMLElement | null;
|
|
6
|
+
readonly placement?: MenuPlacement;
|
|
7
|
+
readonly anchorOffset?: number;
|
|
8
|
+
readonly anchorCrossOffset?: number;
|
|
9
|
+
readonly viewportMargin?: number;
|
|
10
|
+
readonly ref?: Ref<HTMLDivElement>;
|
|
11
|
+
}
|
|
12
|
+
export declare function MenuSurface({ children, className, anchor, placement, anchorOffset, anchorCrossOffset, viewportMargin, ref, style, ...props }: MenuSurfaceProps): import("react").JSX.Element;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export type { MenuItemProps, MenuItemTone, MenuLabelProps, MenuProps, MenuSeparatorProps, MenuSubmenuProps, } from './Menu';
|
|
1
|
+
export type { MenuItemProps, MenuItemTone, MenuLabelProps, MenuPlacement, MenuProps, MenuSeparatorProps, MenuSubmenuProps, } from './Menu';
|
|
2
2
|
export { Menu, MenuItem, MenuLabel, MenuSeparator, MenuSubmenu } from './Menu';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { FloatingPlacement } from '../popover/use-anchor-position';
|
|
2
|
+
export type MenuPlacement = FloatingPlacement;
|
|
3
|
+
export interface MenuTreeConfig {
|
|
4
|
+
readonly submenuOffset: number;
|
|
5
|
+
readonly submenuPlacement: MenuPlacement;
|
|
6
|
+
readonly submenuViewportMargin: number;
|
|
7
|
+
}
|
|
8
|
+
export declare const DEFAULT_MENU_TREE_CONFIG: MenuTreeConfig;
|
|
9
|
+
export declare const MenuTreeContext: import('react').Context<MenuTreeConfig>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CSSProperties, RefObject } from 'react';
|
|
2
|
-
export type FloatingPlacement = 'top-start' | 'top-end' | 'bottom-start' | 'bottom-end' | 'left-start' | 'right-start';
|
|
2
|
+
export type FloatingPlacement = 'top-start' | 'top' | 'top-end' | 'bottom-start' | 'bottom' | 'bottom-end' | 'left-start' | 'left' | 'left-end' | 'right-start' | 'right' | 'right-end';
|
|
3
3
|
export interface UseAnchorPositionOptions {
|
|
4
4
|
readonly anchor: HTMLElement | null;
|
|
5
5
|
readonly placement?: FloatingPlacement;
|
|
@@ -11,4 +11,19 @@ export interface UseAnchorPositionResult {
|
|
|
11
11
|
readonly floatingRef: RefObject<HTMLDivElement | null>;
|
|
12
12
|
readonly style: CSSProperties;
|
|
13
13
|
}
|
|
14
|
+
export interface ComputeFloatingPositionOptions {
|
|
15
|
+
readonly anchorRect: DOMRect;
|
|
16
|
+
readonly crossOffset: number;
|
|
17
|
+
readonly floatingHeight: number;
|
|
18
|
+
readonly floatingWidth: number;
|
|
19
|
+
readonly offset: number;
|
|
20
|
+
readonly placement: FloatingPlacement;
|
|
21
|
+
readonly viewportHeight: number;
|
|
22
|
+
readonly viewportMargin: number;
|
|
23
|
+
readonly viewportWidth: number;
|
|
24
|
+
}
|
|
25
|
+
export declare function computeFloatingPosition({ anchorRect, crossOffset, floatingHeight, floatingWidth, offset, placement, viewportHeight, viewportMargin, viewportWidth, }: ComputeFloatingPositionOptions): {
|
|
26
|
+
readonly left: number;
|
|
27
|
+
readonly top: number;
|
|
28
|
+
};
|
|
14
29
|
export declare function useAnchorPosition({ anchor, placement, offset, crossOffset, viewportMargin, }: UseAnchorPositionOptions): UseAnchorPositionResult;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { CSSProperties } from 'react';
|
|
2
|
+
import { ThemeMode } from './theme';
|
|
3
|
+
export type ThemeStyle = CSSProperties & Partial<Record<'--hn-color-accent' | '--hn-color-accent-hover' | '--hn-focus-ring', string>>;
|
|
4
|
+
export interface ThemeScope {
|
|
5
|
+
readonly accent: string;
|
|
6
|
+
readonly mode: ThemeMode;
|
|
7
|
+
readonly style: ThemeStyle;
|
|
8
|
+
}
|
|
9
|
+
export declare const ThemeContext: import('react').Context<ThemeScope | null>;
|
|
10
|
+
export declare function useThemeScope(): ThemeScope | null;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* empty css */
|
|
2
|
-
import { t as e } from "./button-
|
|
3
|
-
import { t } from "./dialog-
|
|
2
|
+
import { t as e } from "./button-DjMS8bKj.js";
|
|
3
|
+
import { t } from "./dialog-BYlEUJ_j.js";
|
|
4
4
|
import { jsx as n, jsxs as r } from "react/jsx-runtime";
|
|
5
5
|
import { createContext as i, createElement as a, useCallback as o, useContext as s, useMemo as c, useState as l } from "react";
|
|
6
6
|
import { createRoot as u } from "react-dom/client";
|
|
@@ -19,12 +19,11 @@ function f({ open: i, title: a, description: o, confirmText: s = "确认", cance
|
|
|
19
19
|
title: a,
|
|
20
20
|
children: /* @__PURE__ */ r("div", {
|
|
21
21
|
className: "hn-confirm__footer",
|
|
22
|
-
"data-tone": l,
|
|
23
22
|
children: [/* @__PURE__ */ n(e, {
|
|
24
23
|
disabled: u,
|
|
24
|
+
ghost: !0,
|
|
25
25
|
onClick: h,
|
|
26
26
|
type: "button",
|
|
27
|
-
variant: "ghost",
|
|
28
27
|
children: c
|
|
29
28
|
}), /* @__PURE__ */ n(e, {
|
|
30
29
|
disabled: u,
|
|
@@ -32,7 +31,7 @@ function f({ open: i, title: a, description: o, confirmText: s = "确认", cance
|
|
|
32
31
|
d();
|
|
33
32
|
},
|
|
34
33
|
type: "button",
|
|
35
|
-
variant: "primary",
|
|
34
|
+
variant: l === "danger" ? "danger" : "primary",
|
|
36
35
|
children: u ? "处理中…" : s
|
|
37
36
|
})]
|
|
38
37
|
})
|
package/dist/confirm.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as e, n as t, r as n, t as r } from "./confirm-
|
|
1
|
+
import { i as e, n as t, r as n, t as r } from "./confirm-Faavk_5T.js";
|
|
2
2
|
export { t as Confirm, n as ConfirmProvider, r as confirm, r as confirmDialog, e as useConfirm };
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/* empty css */
|
|
2
|
+
import { t as e } from "./Icon-BBSPOBTI.js";
|
|
3
|
+
import { n as t } from "./theme-context-CdWvVVP8.js";
|
|
4
|
+
import { t as n } from "./use-modal-K9L8aPS0.js";
|
|
5
|
+
import { Fragment as r, jsx as i, jsxs as a } from "react/jsx-runtime";
|
|
6
|
+
import { useState as o } from "react";
|
|
7
|
+
import { createPortal as s } from "react-dom";
|
|
8
|
+
//#region src/components/dialog/Dialog.tsx
|
|
9
|
+
function c({ children: c, className: l, title: u, description: d, open: f, onClose: p, closeOnEsc: m = !0, closeOnBackdrop: h = !0, showCloseButton: g = !1, showFullscreenButton: _ = !1, ref: v, style: y, ...b }) {
|
|
10
|
+
let [x, S] = o({
|
|
11
|
+
fullscreen: !1,
|
|
12
|
+
open: f
|
|
13
|
+
});
|
|
14
|
+
x.open !== f && S({
|
|
15
|
+
fullscreen: !f && x.fullscreen,
|
|
16
|
+
open: f
|
|
17
|
+
});
|
|
18
|
+
let C = x.fullscreen, w = t(), { dataState: T, mounted: E, backdropRef: D, panelRef: O, titleId: k, descriptionId: A, handlePanelKeyDown: j, handleBackdropPointerDown: M } = n({
|
|
19
|
+
open: f,
|
|
20
|
+
onClose: p,
|
|
21
|
+
closeOnEsc: m,
|
|
22
|
+
closeOnBackdrop: h
|
|
23
|
+
});
|
|
24
|
+
if (!E || typeof document > "u") return null;
|
|
25
|
+
let N = [
|
|
26
|
+
"hn-dialog__panel",
|
|
27
|
+
C ? "hn-dialog__panel--fullscreen" : "",
|
|
28
|
+
l
|
|
29
|
+
].filter(Boolean).join(" "), P = u === void 0 ? void 0 : k, F = d === void 0 ? void 0 : A, I = (e) => {
|
|
30
|
+
O.current = e, typeof v == "function" ? v(e) : v != null && (v.current = e);
|
|
31
|
+
}, L = /* @__PURE__ */ a(r, { children: [/* @__PURE__ */ i("div", {
|
|
32
|
+
className: "hn-dialog__backdrop",
|
|
33
|
+
"data-state": T,
|
|
34
|
+
onPointerDown: M,
|
|
35
|
+
ref: D
|
|
36
|
+
}), /* @__PURE__ */ a("div", {
|
|
37
|
+
...b,
|
|
38
|
+
"aria-describedby": F,
|
|
39
|
+
"aria-labelledby": P,
|
|
40
|
+
"aria-modal": "true",
|
|
41
|
+
className: N,
|
|
42
|
+
"data-state": T,
|
|
43
|
+
onKeyDown: j,
|
|
44
|
+
ref: I,
|
|
45
|
+
role: "dialog",
|
|
46
|
+
style: y,
|
|
47
|
+
tabIndex: -1,
|
|
48
|
+
children: [
|
|
49
|
+
g || _ ? /* @__PURE__ */ a("div", {
|
|
50
|
+
className: "hn-dialog__actions",
|
|
51
|
+
children: [_ ? /* @__PURE__ */ i("button", {
|
|
52
|
+
"aria-label": C ? "退出全屏" : "全屏显示",
|
|
53
|
+
"aria-pressed": C,
|
|
54
|
+
className: "hn-dialog__icon-button",
|
|
55
|
+
onClick: () => {
|
|
56
|
+
S((e) => ({
|
|
57
|
+
...e,
|
|
58
|
+
fullscreen: !e.fullscreen
|
|
59
|
+
}));
|
|
60
|
+
},
|
|
61
|
+
type: "button",
|
|
62
|
+
children: /* @__PURE__ */ i(e, {
|
|
63
|
+
"aria-hidden": "true",
|
|
64
|
+
name: C ? "fullscreen-exit" : "fullscreen"
|
|
65
|
+
})
|
|
66
|
+
}) : null, g ? /* @__PURE__ */ i("button", {
|
|
67
|
+
"aria-label": "关闭对话框",
|
|
68
|
+
className: "hn-dialog__icon-button",
|
|
69
|
+
onClick: p,
|
|
70
|
+
type: "button",
|
|
71
|
+
children: /* @__PURE__ */ i(e, {
|
|
72
|
+
"aria-hidden": "true",
|
|
73
|
+
name: "close"
|
|
74
|
+
})
|
|
75
|
+
}) : null]
|
|
76
|
+
}) : null,
|
|
77
|
+
u === void 0 ? null : /* @__PURE__ */ i("h2", {
|
|
78
|
+
className: "hn-dialog__title",
|
|
79
|
+
id: k,
|
|
80
|
+
children: u
|
|
81
|
+
}),
|
|
82
|
+
d === void 0 ? null : /* @__PURE__ */ i("p", {
|
|
83
|
+
className: "hn-dialog__description",
|
|
84
|
+
id: A,
|
|
85
|
+
children: d
|
|
86
|
+
}),
|
|
87
|
+
/* @__PURE__ */ i("div", {
|
|
88
|
+
className: "hn-dialog__content",
|
|
89
|
+
children: c
|
|
90
|
+
})
|
|
91
|
+
]
|
|
92
|
+
})] });
|
|
93
|
+
return s(w === null ? L : /* @__PURE__ */ i("div", {
|
|
94
|
+
className: "hn-theme",
|
|
95
|
+
"data-accent": w.accent,
|
|
96
|
+
"data-mode": w.mode,
|
|
97
|
+
style: w.style,
|
|
98
|
+
children: L
|
|
99
|
+
}), document.body);
|
|
100
|
+
}
|
|
101
|
+
//#endregion
|
|
102
|
+
export { c as t };
|
package/dist/dialog.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as e } from "./dialog-
|
|
1
|
+
import { t as e } from "./dialog-BYlEUJ_j.js";
|
|
2
2
|
export { e as Dialog };
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/* empty css */
|
|
2
|
+
import { t as e } from "./Icon-BBSPOBTI.js";
|
|
3
|
+
import { n as t } from "./theme-context-CdWvVVP8.js";
|
|
4
|
+
import { t as n } from "./use-modal-K9L8aPS0.js";
|
|
5
|
+
import { Fragment as r, jsx as i, jsxs as a } from "react/jsx-runtime";
|
|
6
|
+
import { useRef as o, useState as s } from "react";
|
|
7
|
+
import { createPortal as c } from "react-dom";
|
|
8
|
+
//#region src/components/drawer/Drawer.tsx
|
|
9
|
+
function l({ children: l, className: u, title: d, description: f, open: p, onClose: m, placement: h = "right", size: g, closeOnEsc: _ = !0, closeOnBackdrop: v = !0, showCloseButton: y = !1, showFullscreenButton: b = !1, ref: x, style: S, ...C }) {
|
|
10
|
+
let [w, T] = s({
|
|
11
|
+
fullscreen: !1,
|
|
12
|
+
open: p
|
|
13
|
+
});
|
|
14
|
+
w.open !== p && T({
|
|
15
|
+
fullscreen: !p && w.fullscreen,
|
|
16
|
+
open: p
|
|
17
|
+
});
|
|
18
|
+
let E = w.fullscreen, D = h === "bottom" ? E ? "arrow-down" : "arrow-up" : E ? "fullscreen-exit" : "fullscreen", O = o(null), k = t(), { dataState: A, mounted: j, backdropRef: M, panelRef: N, titleId: P, descriptionId: F, handlePanelKeyDown: I, handleBackdropPointerDown: L } = n({
|
|
19
|
+
open: p,
|
|
20
|
+
onClose: m,
|
|
21
|
+
closeOnEsc: _,
|
|
22
|
+
closeOnBackdrop: v
|
|
23
|
+
});
|
|
24
|
+
if (!j || typeof document > "u") return null;
|
|
25
|
+
let R = [
|
|
26
|
+
"hn-drawer__panel",
|
|
27
|
+
`hn-drawer__panel--${h}`,
|
|
28
|
+
E ? "hn-drawer__panel--fullscreen" : "",
|
|
29
|
+
u
|
|
30
|
+
].filter(Boolean).join(" "), z = {
|
|
31
|
+
...g === void 0 ? {} : { "--hn-drawer-size": `${String(g)}px` },
|
|
32
|
+
...S
|
|
33
|
+
}, B = d === void 0 ? void 0 : P, V = f === void 0 ? void 0 : F, H = (e) => {
|
|
34
|
+
e.target instanceof Element && e.target.closest("button") !== null || (O.current = e.clientY, e.currentTarget.setPointerCapture(e.pointerId));
|
|
35
|
+
}, U = (e) => {
|
|
36
|
+
let t = O.current;
|
|
37
|
+
if (O.current = null, e.currentTarget.hasPointerCapture(e.pointerId) && e.currentTarget.releasePointerCapture(e.pointerId), t === null) return;
|
|
38
|
+
let n = e.clientY - t;
|
|
39
|
+
n <= -56 ? T((e) => ({
|
|
40
|
+
...e,
|
|
41
|
+
fullscreen: !0
|
|
42
|
+
})) : n >= 56 && T((e) => ({
|
|
43
|
+
...e,
|
|
44
|
+
fullscreen: !1
|
|
45
|
+
}));
|
|
46
|
+
}, W = (e) => {
|
|
47
|
+
N.current = e, typeof x == "function" ? x(e) : x != null && (x.current = e);
|
|
48
|
+
}, G = /* @__PURE__ */ a(r, { children: [/* @__PURE__ */ i("div", {
|
|
49
|
+
className: "hn-drawer__backdrop",
|
|
50
|
+
"data-state": A,
|
|
51
|
+
onPointerDown: L,
|
|
52
|
+
ref: M
|
|
53
|
+
}), /* @__PURE__ */ a("div", {
|
|
54
|
+
...C,
|
|
55
|
+
"aria-describedby": V,
|
|
56
|
+
"aria-labelledby": B,
|
|
57
|
+
"aria-modal": "true",
|
|
58
|
+
className: R,
|
|
59
|
+
"data-state": A,
|
|
60
|
+
onKeyDown: I,
|
|
61
|
+
ref: W,
|
|
62
|
+
role: "dialog",
|
|
63
|
+
style: z,
|
|
64
|
+
tabIndex: -1,
|
|
65
|
+
children: [d !== void 0 || f !== void 0 || y || b ? /* @__PURE__ */ a("header", {
|
|
66
|
+
className: "hn-drawer__header",
|
|
67
|
+
onPointerCancel: U,
|
|
68
|
+
onPointerDown: H,
|
|
69
|
+
onPointerUp: U,
|
|
70
|
+
children: [/* @__PURE__ */ a("div", {
|
|
71
|
+
className: "hn-drawer__heading",
|
|
72
|
+
children: [b ? /* @__PURE__ */ i("button", {
|
|
73
|
+
"aria-label": E ? "退出全屏" : "全屏显示",
|
|
74
|
+
"aria-pressed": E,
|
|
75
|
+
className: "hn-drawer__icon-button",
|
|
76
|
+
onClick: () => {
|
|
77
|
+
T((e) => ({
|
|
78
|
+
...e,
|
|
79
|
+
fullscreen: !e.fullscreen
|
|
80
|
+
}));
|
|
81
|
+
},
|
|
82
|
+
type: "button",
|
|
83
|
+
children: /* @__PURE__ */ i(e, {
|
|
84
|
+
"aria-hidden": "true",
|
|
85
|
+
name: D
|
|
86
|
+
})
|
|
87
|
+
}) : null, /* @__PURE__ */ a("div", { children: [d === void 0 ? null : /* @__PURE__ */ i("h2", {
|
|
88
|
+
className: "hn-drawer__title",
|
|
89
|
+
id: P,
|
|
90
|
+
children: d
|
|
91
|
+
}), f === void 0 ? null : /* @__PURE__ */ i("p", {
|
|
92
|
+
className: "hn-drawer__description",
|
|
93
|
+
id: F,
|
|
94
|
+
children: f
|
|
95
|
+
})] })]
|
|
96
|
+
}), y ? /* @__PURE__ */ i("button", {
|
|
97
|
+
"aria-label": "关闭抽屉",
|
|
98
|
+
className: "hn-drawer__icon-button",
|
|
99
|
+
onClick: m,
|
|
100
|
+
type: "button",
|
|
101
|
+
children: /* @__PURE__ */ i(e, {
|
|
102
|
+
"aria-hidden": "true",
|
|
103
|
+
name: "close"
|
|
104
|
+
})
|
|
105
|
+
}) : null]
|
|
106
|
+
}) : null, /* @__PURE__ */ i("div", {
|
|
107
|
+
className: "hn-drawer__content",
|
|
108
|
+
children: l
|
|
109
|
+
})]
|
|
110
|
+
})] });
|
|
111
|
+
return c(k === null ? G : /* @__PURE__ */ i("div", {
|
|
112
|
+
className: "hn-theme",
|
|
113
|
+
"data-accent": k.accent,
|
|
114
|
+
"data-mode": k.mode,
|
|
115
|
+
style: k.style,
|
|
116
|
+
children: G
|
|
117
|
+
}), document.body);
|
|
118
|
+
}
|
|
119
|
+
//#endregion
|
|
120
|
+
export { l as t };
|
package/dist/drawer.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as e } from "./drawer-
|
|
1
|
+
import { t as e } from "./drawer-BV9RFSna.js";
|
|
2
2
|
export { e as Drawer };
|